Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

JSTS sometimes takes too long #35

Open
ericsoco opened this issue Sep 20, 2016 · 7 comments
Open

JSTS sometimes takes too long #35

ericsoco opened this issue Sep 20, 2016 · 7 comments
Assignees

Comments

@ericsoco
Copy link
Contributor

Not sure what we can do to optimize, but I want to take a pass. It takes upwards of 30s for some diffs to render, e.g. http://openredist.org/#/open-redist/California-State-Senate/4

@waldoj
Copy link

waldoj commented Sep 21, 2016

I'm dubious that we can do anything about it—I think this is just an inevitable byproduct of extremely detailed GeoJSON files. I imagine there may be some Javascript optimization wizardry to be done, but that's pretty substantially out of scope. :)

@ericsoco
Copy link
Contributor Author

ericsoco commented Sep 21, 2016

Yeah, for the purposes of this site, it might make sense to downsample geojson files for display.
Maybe this? https://github.com/maxogden/simplify-geojson
Not sure what effect that will have on e.g. block-level district boundaries tho.

@waldoj
Copy link

waldoj commented Sep 21, 2016

Ha! I'd be tickled to use one of Max's projects here. :) (He worked for US Open Data. Used to be on the board.)

@ericsoco
Copy link
Contributor Author

I gave it a quick shot:
ec4b41b
Didn't work out.

Some maps, like this one, end up with a really weird dashed line result:

screen shot 2016-09-21 at 9 46 50 am

Others, like this one, just error out completely. In this case the complaint from JSTS is found non-noded intersection between LINESTRING ( -121.316457 38.299853, -121.316931 38.30105 ) and LINESTRING ( -121.316899 38.302561, -121.31672443551557 38.300528359308295 ) [ (-121.31672443551557, 38.3005283593083, undefined) ]. Not sure what it means, but it appears the geometry became malformed -- could be that the shape was closed originally but the simplification caused it to become open?

Feel free to bounce off Max if he's game. This is getting in over my head...

@almccon
Copy link
Member

almccon commented Sep 21, 2016

Those internal dashed lines look like they used to be borders between shapes? It is trying to dissolve the yellow part of Virginia into a single polygon? Or were those supposed to remain separate?

If you're trying to dissolve, it probably just needs to have a tiny buffer applied to prevent those slivers.

@ericsoco
Copy link
Contributor Author

@almccon correct. I union before I diff. However, those lines should still be visible in the final product. (See #30.)

So, it's interesting that simplifying in this case half-fixes my problem of erasing data on union. But it's not a solution, it's a byproduct.

@ericsoco
Copy link
Contributor Author

Revisiting this...seems like JSTS operations would be a good candidate to push off to a web worker, to avoid locking the UI while the diff runs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants