ckanext-spatial
ckanext-spatial copied to clipboard
Support for multipolygon geometries
Multipolygons are largelly used for acipelag and country and regional borders but unfortunatelly are not supported by the extension. It seems SOLR have sypport for it already when using JTS
If you are using the solr-spatial-field
backend for the spatial search, and your geometry is a valid MultiPolygon
, the search should work just fine.
This extent works for me (by works I mean that the dataset is found on a spatial search):
{"type":"MultiPolygon", "coordinates": [[[[-62.637519836425774,17.09321364464215],[-62.637519836425774,17.20868918828472],[-62.537612915039055,17.20868918828472],[-62.537612915039055,17.09321364464215],[-62.637519836425774,17.09321364464215]]],[[[-62.87200927734374,17.214264312027566],[-62.87200927734374,17.41616680065724],[-62.60696411132812,17.41616680065724],[-62.60696411132812,17.214264312027566],[-62.87200927734374,17.214264312027566]]]]}
But not this one:
{"type":"MultiPolygon","coordinates":[[[[-62.89947509765625,17.197210463331256],[-62.89947509765625,17.42271835184761],[-62.589111328125,17.42271835184761],[-62.589111328125,17.197210463331256],[-62.89947509765625,17.197210463331256]]],[[[-62.65777587890625,17.06728740376787],[-62.65777587890625,17.219511333785114],[-62.51495361328124,17.219511333785114],[-62.51495361328124,17.06728740376787],[-62.65777587890625,17.06728740376787]]] ]}
Note that on the second one the polygons are overlapping. This is flagged as an invalid geometry by shapely, the library that we use to validate them:
WARNI [shapely.geos] Self-intersection at or near point -62.589111328125 17.219511333785114
(The proper way to go in this case would probably be a GeometryCollection
with two Polygon
objects but that is not supported in CKAN)
If I bypass the validation for this particular case, Solr indexes the geometry just fine and the dataset is found on a spatial search. I'd need to investigate a bit more to see if we can add an exception for this particular case.
that would be nice as I got the same error for the overlapping geometries that reflect my case i.e (Vatican City or San Marino part of the Italy borders are a shapes not overlapping but even contained into the main one).
Hi everyone, has there been any progress on this? What is the current recommended workaround when migrating from PostGIS, where overlapping Multipolygons worked correctly, to newer versions of CKAN without PostGIS? Thanks!