Open stevesong opened 7 months ago
Firstly acknowledging the sample code is wrong - it wasn't updated when we changed our thinking about multiple files. I think it should be (not tested):
from libcoveofds.geojson import GeoJSONToJSONConverter, GeoJSONAssumeFeatureType
...
worker.process_data(nodes_data, assumed_feature_type=GeoJSONAssumeFeatureType.NODE)
worker.process_data(spans_data, assumed_feature_type=GeoJSONAssumeFeatureType.SPAN)
Ah, I don't have access to the original GeoJSON data but looking at the outputted JSON I can make a guess.
In the first span it's
"start": "{\"id\": \"..........\", \"name\": \".........\", \"location\": {\"type\": \"Point\", \"coordinates\": [......,.........]}}",
Note, the value for the start key is not a dict - it's a string of the JSON representation of a dict! Has the value somehow been accidentally string-ifyed in the input data?
This is maybe something we could try and catch and fix in the converter, if this is a common problem
That was the hint I needed, thank you! I was using json.loads instead of json.load.
Your revised sample code works for me. :-)
We should fix our docs - can we leave this issue open to track that task?
lib-cove-ofds installs fine and I am able to use the command-line version of it to convert GeoJSON nodes and spans files into a single valid JSON file. However, when I attempt to use it in a python script, I run into problems. The sample code which suggests the following line triggers an error.
worker.process_data(nodes_data, spans_data)
process_data doesn't appear to accept two arguments. I am able to run it sequentially i.e.
worker.process_data(nodes_data) worker.process_data(spans_data)
The result produces a valid JSON file but not valid OFDS. It produces spans with node references that cannot be resolved. Temporary link to COVE output. I am not sure what I am doing wrong.