I'm having a weird issue and it seems the geofield_compute_values() is doing something weird with my WKT.
I am importing a shapefile into my geofield. I have custom code to do this (hoping to release it soon as a geofield widget). The Shapefile has 4 features, all polygons.
I am trying to combine this into a multipolygon. When I sent the multipolygon feature into geofield_compute_values(), it removed some of the 4th polygon (by far the largest). While poking around, I tried reversing the order of the polygons, so that the largest one was entered first. Strangely, this seemed to preserve the data.
Clearly the order to the features shouldn't matter. Perhaps I am mangling the data somehow.
I have attached the two MULTIPOLYGON wkt features so that they can be tested. Running them through geofield_compute_values() shoud return the same data but it's not working for me.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | wkt_array_serialized.txt | 80.85 KB | dtarc |
| good.wkt_.txt | 80.81 KB | dtarc | |
| bad.wkt_.txt | 80.81 KB | dtarc |
Comments
Comment #1
dtarc commentedHere's the code I'm using to generate the WKT, from an array of polygons that have had the POLYGON( and ) stripped off:
Using it this way causes data loss. However, using it this way:
Pulls in data in just fine.
This seems very curious. I have attached the serialized array.
Comment #2
phayes commentedHi Dave,
I'm digging into this and it looks to be a problem with geoPHP's WKT parsing functions. Haven't found the absolute root cause yet. I do note however, that if GEOS is installed, the problem does not manifest (because GEOS takes over WKT parsing).
I won't have time to dig any deeper for two weeks, so I would encourage you to either use GEOS or to look into geoPHP's WKT Adapter.
Comment #3
phayes commentedTo ease debugging, here's a much simpler WKT snippet that has the same problem:
Comment #4
phayes commentedEven simpler: The inner-boundary on the second polygon is lost:
Comment #5
phayes commentedOkay, this is now fixed in the latest master branch of geoPHP
Comment #6
phayes commentedI've also rolled out a 0.6 version of geoPHP which incorporates this fix. On the geofield side I've bumped the recommend geoPHP version to 0.6