You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Plugin for reading/writing PostGIS types as GeoJSON #1787
ByteOrder is internal, therefore the plugin has no access to many NpgsqlReadBuffer methods. Should that enum be removed and replaced by bool meaning little endianness?
What if returning data has M dimension? Should we throw an exception because GeoJSON doesn't support it or ignore M?
What if the saving GeoJSON object has points with Z and without Z at the same time? Should we throw exception or treat nulls as zero? See the example below:
varline=newLineString(new[]{newPosition(1.0,1.0,2.0),// with ZnewPosition(1.0,1.0)});// without Z
@YohDeadfall wow, nice work... I'm wondering if Npgsql should provide GeoJSON directly or just pass through, say, NetTopologiySuite which has NetTopologySuite.IO.GeoJSON. But the nice thing about the new plugin model is that we can have all these optional plugins.
Regarding your questions specifically:
ByteOrder is internal, therefore the plugin has no access to many NpgsqlReadBuffer methods. Should that enum be removed and replaced by bool meaning little endianness?
That sounds right to me. The idea in any case is to remove the "native" PostGIS support from the Npgsql core and put it in its own plugin - so it's best to assume you don't have that enum exposed anyway. On the other we'd need to expose the endian-conditional read methods publicly, though. Replacing the enum by a bool is also seems OK to me.
What if returning data has M dimension? Should we throw an exception because GeoJSON doesn't support it or ignore M?
If GeoJSON doesn't support it, then yes, throwing (preferably a SafeReadException) sounds like a better option to me than ignoring. Same for the writing side, when validating the user-provided value. As an alternative, you could have a plugin parameter (to .UseGeoJSON()) specifying to ignore instead, but throwing definitely should be the default.
What if the saving GeoJSON object has points with Z and without Z at the same time? Should we throw exception or treat nulls as zero?
I admit I don't know the APIs or standards well enough, but intuitively I prefer throwing rather than silently treating null as zero here - it seems reasonable to expect the user to provide all-3D points or all-2D points for a given LineString etc...
A CRS object may indicate a coordinate reference system by name. In this case, the value of its "type" member must be the string "name". The value of its "properties" member must be an object containing a "name" member. The value of that "name" member must be a string identifying a coordinate reference system. OGC CRS URNs such as "urn:ogc:def:crs:OGC:1.3:CRS84" shall be preferred over legacy identifiers such as "EPSG:4326":
The coordinate reference system for all GeoJSON coordinates is a geographic coordinate reference system, using the World Geodetic System 1984 (WGS 84) [WGS84] datum, with longitude and latitude units of decimal degrees. This is equivalent to the coordinate reference system identified by the Open Geospatial Consortium (OGC) URN urn:ogc:def:crs:OGC::CRS84.
Note: the use of alternative coordinate reference systems was specified in [GJ2008], but it has been removed from this version of the specification because the use of different coordinate reference systems -- especially in the manner specified in [GJ2008] -- has proven to have interoperability issues.
So the RFC says that a CRS shouldn't be specified at all. It's for backward compatibility only. The questions is should the handler behave like the ST_AsGeoJSON function or not?
I really don't know anything about this... If it's zero effort to implement this, then why not. Otherwise I'd skip if it's really legacy backwards compat.
Activity
YohDeadfall commentedon Feb 14, 2018
Mostly done, but I have a few questions:
ByteOrderis internal, therefore the plugin has no access to manyNpgsqlReadBuffermethods. Should that enum be removed and replaced by bool meaning little endianness?roji commentedon Feb 17, 2018
@YohDeadfall wow, nice work... I'm wondering if Npgsql should provide GeoJSON directly or just pass through, say, NetTopologiySuite which has NetTopologySuite.IO.GeoJSON. But the nice thing about the new plugin model is that we can have all these optional plugins.
Regarding your questions specifically:
That sounds right to me. The idea in any case is to remove the "native" PostGIS support from the Npgsql core and put it in its own plugin - so it's best to assume you don't have that enum exposed anyway. On the other we'd need to expose the endian-conditional read methods publicly, though. Replacing the enum by a bool is also seems OK to me.
If GeoJSON doesn't support it, then yes, throwing (preferably a SafeReadException) sounds like a better option to me than ignoring. Same for the writing side, when validating the user-provided value. As an alternative, you could have a plugin parameter (to
.UseGeoJSON()) specifying to ignore instead, but throwing definitely should be the default.I admit I don't know the APIs or standards well enough, but intuitively I prefer throwing rather than silently treating null as zero here - it seems reasonable to expect the user to provide all-3D points or all-2D points for a given LineString etc...
YohDeadfall commentedon Mar 19, 2018
Should we support short (legacy) CRS names? PostGIS support that via setting
optionsofST_AsGeoJSONto 2 (docs).From the obsolete specification:
From RFC 7946, GeoJSON:
So the RFC says that a CRS shouldn't be specified at all. It's for backward compatibility only. The questions is should the handler behave like the
ST_AsGeoJSONfunction or not?roji commentedon Mar 19, 2018
I really don't know anything about this... If it's zero effort to implement this, then why not. Otherwise I'd skip if it's really legacy backwards compat.
YohDeadfall commentedon Mar 20, 2018
Added it too for compatibility with the
ST_AsGeoJSONfunction.YohDeadfall commentedon Mar 20, 2018
@roji please add PostGIS and plugins labels, and remove up for grabs.
roji commentedon Mar 20, 2018
@YohDeadfall done