Pickling: fix SRID handling + update linearring test#1245
Pickling: fix SRID handling + update linearring test#1245jorisvandenbossche merged 5 commits intoshapely:mainfrom
Conversation
|
In pygeos, we didn't have the |
|
I suppose I can then actually remove the C version ( |
|
Looks good. I still don't like the idea of SRID support. Not supporting SRID up to this point has eliminated a source of complexity and thus has been good for Shapely. And the GEOS project doesn't consider SRID to be a useful feature, either. |
|
As long as we limit the SRID support strictly to IO (i.e. pickling and read/write WKB), I don't think it will really add a source of complexitly / issues. If someone opens an issue related to SRID for anything else, we can simply close as out-of-scope / defer to GEOS. I personally don't care that much about preserving SRID for pickling, as long as we support it for WKB (which is needed for example for PostGIS interaction) |
|
Personally I also think that srids are out of scope. However if users want to carry this information (any information really) along with the geometries, then I think it is fine to support that. As long as we never base any logic on it. |
|
I looked in geopandas and it seems that it is only depending on a geometry's SRID due to a design choice and not because there is no other way. Instead of checking to see if an SRID is set on the first geometry at https://github.com/geopandas/geopandas/blob/d006fad416a9f33fd88c1a00744ae9f98cb9c6d0/geopandas/io/sql.py#L88 (if there was a bug here it would be super confusing), this function could instead call https://postgis.net/docs/Find_SRID.html via |
|
We still use SRID for WKB export to PostGIS as well (that doesn't need to be on the geometry though, but as mentioned above still need it in the WKB IO functions) |
|
For the reading side, it is true that we don't need the |
Pull Request Test Coverage Report for Build 1627350912Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
|
Since this PR is only fixing the LinearRing pickling and making it consistent with the other geometry classes, I am planning to merge this. |
The goal here is to consolidate the pickling behaviour between pygeos and shapely. The differences:
This PR combines both features, preserving both LinearRing type and SRID.
I currently did this in the Python layer, while we also have a base
__reduce__implementation in C (which is probably unused now in practice):https://github.com/Toblerity/Shapely/blob/2e513b143c1f0a84b9cd23cbe409f72bfa78f40f/src/pygeom.c#L408
I suppose we could also keep the logic in C. The main reason that I currently need to override
__reduce__in the python subclasses is because the C version ends up passing the WKB to the class__new__. The baselib.Geometryclass accepts WKB for construction, but the subclasses currently do not (egshapely.geometry.Point(..)only accepts actual coordinate values).Closes #988