Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we use a single line JSON stream for vector/webgl layers #312

Open
mapcentia opened this issue Jun 13, 2019 · 5 comments
Open

Can we use a single line JSON stream for vector/webgl layers #312

mapcentia opened this issue Jun 13, 2019 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@mapcentia
Copy link
Collaborator

mapcentia commented Jun 13, 2019

The GC2 SQL API creates a valid GeoJSON doc server side and sends it to the browser. This approach puts a limit on how many data can be send - depending on the memory limit in GC2. And it doesn't scale well.

I've created a simple "stream" API, which sends one-line JSON, using a cursor in the database. This way there is no limit on data size.

SQL API: https://swarm.gc2.io/api/v2/sql/horsens?q=select%20*%20from%20test.togstation%20limit%2010

SQL Stream API: https://swarm.gc2.io/api/v2/sql/stream/horsens?q=select%20*%20from%20test.togstation%20limit%2010

Can we use the SQL Stream API instead of SQL API to populate a vector or webgl layer? Especially webgl is interesting because it can handle much more data.

One way of doing it, is to compile a valid GeoJSON doc from the one-lines and from that do what we do now. But a more elegant and less memory consuming way is to build the layer while data streams in. This way the user also have a visual indicator seeing the layer being build.

@mapcentia mapcentia added enhancement New feature or request question Further information is requested labels Jun 13, 2019
@sashuk
Copy link
Owner

sashuk commented Jun 14, 2019

@mapcentia According to https://github.com/mapcentia/geocloud2/blob/b696654778431961b4159475385bcbc490cfbeba/app/models/Stream.php, the streaming is organized by iteratively calling the ... flush(); ob_flush(); ..., so there are more than one output iterations for one single server request.

Seems like there are already packages that can help with streaming data (GeoJSON in particular) - https://github.com/node-geojson/leaflet-geojson-stream based on https://github.com/substack/hyperquest, so I think it is surely possible to implement!

Another interesting side of this question is to use the web sockets for streaming https://github.com/perrygeo/websocket-geojson-leaflet, but it can be probably implemented later.

@sashuk sashuk removed the question Further information is requested label Jun 14, 2019
@sashuk
Copy link
Owner

sashuk commented Jun 18, 2019

@mapcentia Could you please specify if this should be implemented?

@sashuk sashuk added the question Further information is requested label Jun 18, 2019
@mapcentia
Copy link
Collaborator Author

@sashuk Yes, please start on this for WebGL, which is most relavant for big datasets. If you can get this to work, we can proced with styling, mouse-over and click for WebGL layers

@sashuk sashuk removed the question Further information is requested label Jun 19, 2019
@mapcentia
Copy link
Collaborator Author

@sashuk The endpoint is changed: https://swarm.gc2.io/api/v2/sql/horsens/stream?q=select%20*%20from%20test.togstation%20limit%2010
There're some debug info after each line - I'll get rid of that

@sashuk
Copy link
Owner

sashuk commented Aug 7, 2019

@mapcentia Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants