This is a small demo implementation of the streaming capabilities of CityJSON v1.1.
It's a simple RESTful access to a few CityJSON files, implemented with a Flask server. cjio must be installed too to be run (v0.8+).
In /demo/
the code of the server is there.
There are a few CityJSON datasets in one folder, and then the behaviour of pygeoapi has been more or less copied.
It's not finished (OpenAPI and conformance are TODO), but it works and shows the idea are implementable.
-->demo is hosted online for a few users (if 1000s of you go there at the same time it might not work 😬)
The same hack as used by everyone: Line-delimited JSON: one JSON object per line, that is separated by a CR. There's a standard for it too: https://tools.ietf.org/html/rfc7464
Called GeoJSON Text Sequences also.
In the demo, if you add /stream
after a collection, you get a stream of CityJSONFeature
(type is json-seq
), with the first line containing the metadata and other data useful for the whole data (cjio myfile.city.json export --format jsonl
is used):
http://cityjson.pythonanywhere.com/collections/tudelft/stream/
Watch out, cjio must use v0.8+ otherwise nothing will work
$ env FLASK_APP=app.py flask run
In debug mode:
$ env FLASK_APP=app.py FLASK_ENV=development flask run
/collections/
-> HTML/JSON of all datasets/collections/{mycollection}/
-> overview of dataset (metadata [bbox, CRS], version CityJSON, extensions)/collections/{mycollection}/items/
-> a CityJSON object/collections/{mycollection}/items/{featureID}/
-> one CityJSONFeature (which can contain sub-parts, likeBuildingPart
)
If many Features must be returned, like all objects inside a bbox, then a CityJSON is returned (equivalent to a FeatureCollection.
http://localhost:5000/collections/tudelft/items/?limit=5&offset=10
http://localhost:5000/collections/tudelft/stream/
http://localhost:5000/collections/tudelft/items/?f=json
http://localhost:5000/collections/tudelft/items/?bbox=1.2,44.9,55.0,1909.1