magellan icon indicating copy to clipboard operation
magellan copied to clipboard

Support Parsing of MultiPolygon in WKT Format

Open mdbuck opened this issue 7 years ago • 9 comments

Executing WKTParser.parseAll("MULTIPOLYGON (((-72.40704336 41.9571927, -72.4070466 41.95713969, -72.4071366 41.95329372, -72.40790556 41.95300077, -72.40704336 41.9571927)))") results in java.lang.RuntimeException: Extra(...704336 41.9571927))), [traced - not evaluated])

Is this a limitation of the parser of project-wide?

Thanks.

mdbuck avatar Oct 05 '17 18:10 mdbuck

WKT parser does not support multipolygons yet Neither does Shapefile format. Only GeoJSON does right now It's not prioritized, happy to accept contributions :)

harsha2010 avatar Oct 05 '17 18:10 harsha2010

I have no problem working on it but just need to know if it's just a parser issue or if support for MultiPolygons is problematic in other areas of the project. I would not want to implement in the WKTParser only to find that more work is needed in other, more "complicated" areas of the project that may take more time to address.

Thanks.

mdbuck avatar Oct 05 '17 18:10 mdbuck

Multipolygons are in general not fully supported in parsing. But once parsed they will be treated as one polygon per row essential flatmapping them. The rest of the processing then is identical

harsha2010 avatar Oct 05 '17 18:10 harsha2010

Excellent. Thanks!

mdbuck avatar Oct 05 '17 18:10 mdbuck

@mdbuck if you are implementing this, it might be good to follow the same approach as GeoJSON where one line of multi polygon results in multiple rows, one per polygon. This might require slightly generalizing the WKT expression. I can help with this, let me know if you'd want a skeleton PR that you can extend

harsha2010 avatar Oct 05 '17 21:10 harsha2010

Since I do not know what "generalizing the WKT expression" means any help is appreciated :)

mdbuck avatar Oct 06 '17 11:10 mdbuck

@mdbuck fair enough :), will create a PR with some tests and missing pieces for you to add in for this functionality... I should have time to put something together this weekend and will ping you on the PR so you can work off it Thanks for contributing!

harsha2010 avatar Oct 06 '17 15:10 harsha2010

@harsha2010 is there some progress regarding this issue?

geoHeil avatar Dec 19 '17 19:12 geoHeil

I have created a pull request. It isn't exactly what was discussed above, but you may find it useful until a full solution working the same as GeoJson is implemented.

https://github.com/harsha2010/magellan/pull/195

roblovelock avatar Feb 12 '18 18:02 roblovelock