Skip to content

(bleedingly new) postgis GEOMETRY doesn't support srid #4054

Closed

Description

@igrayson

Mostly @mikeringrose.

PR #4013 added GEOMETRY support, but its srid handling may have some issues.

  1. 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
    s += + ", " + field.type.srid;
    .
  2. 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).

Activity

  1. mikeringrose commented on Jul 2, 2015

    @mikeringrose

    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:

    Mostly @mikeringrose https://github.com/mikeringrose.

    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

    s += + ", " + field.type.srid;

    .
    2.

    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.

  2. added
    type: feature
    on Jul 3, 2015
  3. mikeringrose commented on Jul 5, 2015

    @mikeringrose

    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.

  4. krisr commented on Jul 8, 2015

    @krisr

    @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.

  5. igrayson commented on Jul 8, 2015

    @igrayson
    Author

    Looks good.

    Declaring my column type as type: DataTypes.GEOMETRY('Point'), and inserting point values as

    {
      type: 'Point',
      coordinates: [ lat, long ],
      crs: { type: 'name', properties: { name: 'EPSG:4326'} }
    }
    

    works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions