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
(bleedingly new) postgis GEOMETRY doesn't support srid #4054
PR #4013 added GEOMETRY support, but its srid handling may have some issues.
There's a typo in building ST_GeomFromGeoJSON sql, when an srid is present in the field def, causing invalid SQL (example: ST_GeomFromGeoJSON('{"type":"Point","coordinates":[39.807222,-76.984722]}NaN'). The issue is the second + on
PostGIS' implementation of ST_GeomFromGeoJSON doesn't seem to support srid input at all. Neither source nor documentation mention accepting a second (srid) argument. Sequelize output is: SequelizeDatabaseError: function st_geomfromgeojson(unknown, integer) does not exist. (mysql ST_GeomFromGeoJSON does, fwiw).
PR #4013#4013 added GEOMETRY
support, but its srid handling may have some issues.
There's a typo in building ST_GeomFromGeoJSON sql, when an srid is
present in the field def, causing invalid SQL (example:
ST_GeomFromGeoJSON('{"type":"Point","coordinates":[39.807222,-76.984722]}NaN').
The issue is the second + on
PostGIS' implementation of ST_GeomFromGeoJSON doesn't seem to support
srid input at all. Neither source nor documentation mention accepting a
second (srid) argument. Sequelize output is: SequelizeDatabaseError:
function st_geomfromgeojson(unknown, integer) does not exist. (mysql
ST_GeomFromGeoJSON does, fwiw).
—
Reply to this email directly or view it on GitHub #4054.
Since our representation is geojson, the coordinate reference system is specified by the 'crs' field, like { type: 'Point', coordinates: [39.807222,-76.984722], crs:{ type: 'name', properties : { name: 'EPSG:3857'}}};. I'll remove the srid from the ST_GeomFromGeoJSON call as 1) postgis doesn't support it and 2) postgis expects it to be specified in the geojson object.
@mikeringrose, thanks - I agree removing it is best. I first played around with something like this, but I don't know enough about postgis / gis to feel comfortable with this type of change:
if (field.type.srid) {
s = "ST_SetSRID(" + s + "," + field.type.srid + ")";
}
I agree it is better to leave it up to the user to specify the crs field in the JSON.
Activity
mikeringrose commentedon Jul 2, 2015
Thanks. I'll take a look. Obviously I'm also missing a test case. 😠
On Thu, Jul 2, 2015, 7:37 PM igrayson [email protected] wrote:
mikeringrose commentedon Jul 5, 2015
Since our representation is geojson, the coordinate reference system is specified by the 'crs' field, like
{ type: 'Point', coordinates: [39.807222,-76.984722], crs:{ type: 'name', properties : { name: 'EPSG:3857'}}};. I'll remove the srid from the ST_GeomFromGeoJSON call as 1) postgis doesn't support it and 2) postgis expects it to be specified in the geojson object.krisr commentedon Jul 8, 2015
@mikeringrose, thanks - I agree removing it is best. I first played around with something like this, but I don't know enough about postgis / gis to feel comfortable with this type of change:
I agree it is better to leave it up to the user to specify the crs field in the JSON.
igrayson commentedon Jul 8, 2015
Looks good.
Declaring my column type as
type: DataTypes.GEOMETRY('Point'), and inserting point values asworks as expected.