am2222 / strapi-plugin-postgis

Add native postgis support to strapi.
https://am2222.github.io/strapi-plugin-postgis/
41 stars 15 forks source link

Invalid geometry on save #1

Open luckyguido opened 2 years ago

luckyguido commented 2 years ago

Hi, I'm testing this plugin but when i try to save any point in the map i get an API error of invalid geometry.

strapi version: 4.2.2 (node v16.15.1) plugin version: 0.1.5

GeoJSON generated by your plugin is :

{
   "type":"Point","coordinates":[-115.224609,64.125789]
}

my schema .json has this attributes:

  "attributes": {
    "description": {
      "type": "string"
    },
    "geom": { 
      "columnType": {
        "type": "specificType",
        "args": [
          "geometry(POINT,4326)"
        ]
      },
      "type": "json",
      "fieldRenderer": "postgis"
    }
  }

and error reported is:

[2022-07-06 18:02:01.475] error: insert into "public"."reports" ("created_at", "created_by_id", "description", "geom", "published_at", "updated_at", "updated_by_id") values ($1, $2, $3, $4, $5, $6, $7) returning "id" - parse error - invalid geometry
error: insert into "public"."reports" ("created_at", "created_by_id", "description", "geom", "published_at", "updated_at", "updated_by_id") values ($1, $2, $3, $4, $5, $6, $7) returning "id" - parse error - invalid geometry
    at Parser.parseErrorMessage (c:\*************************\node_modules\pg-protocol\dist\parser.js:287:98)
    at Parser.handlePacket (c:\*************************\node_modules\pg-protocol\dist\parser.js:126:29)
    at Parser.parse (c:\*************************\node_modules\pg-protocol\dist\parser.js:39:38)
    at Socket.<anonymous> (c:\*************************\node_modules\pg-protocol\dist\index.js:11:42)
    at Socket.emit (events.js:315:20)
    at Socket.EventEmitter.emit (domain.js:467:12)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at Socket.Readable.push (internal/streams/readable.js:223:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
am2222 commented 2 years ago

@luckyguido Thanks for testing the plugin. Can you tell me what version is your postgis? It should be printed in the strapi logs as something like: [2022-07-07 21:59:28.349] info: Welcome to Strapi Postgis ๐Ÿš€ + ๐Ÿ˜ + ๐Ÿ—บ๏ธ | 3.1 USE_GEOS=1 USE_PROJ=1 USE_STATS=1

Also can you please share list of installed plugins on your strapi? There might be a conflict there.

luckyguido commented 2 years ago

Postgis 3.0, this is the startup Log:

Welcome to Strapi Postgis ๐Ÿš€ + ๐Ÿ˜ + ๐Ÿ—บ๏ธ | 3.0 USE_GEOS=1 USE_PROJ=1 USE_STATS=1

It is a fresh installation of Strapi no other plugin installed (except the default one)

Doing some other test i inserted with a raw query a geometry with a point and then moved through your GUI and this worked fine, only the creation of a new point geometry seems to fail, i want to make a couple of other test:

thak you for your support

luckyguido commented 2 years ago

I can confirm is postgis 3.0 compatibility issues, it works fine with versions 3.1 and 3.2

am2222 commented 2 years ago

@luckyguido thanks for the tests. I am using https://github.com/jfgodoy/knex-postgis as underlying package to communicate with postgis. I will try to find out a solution for it.

emrahaydemir commented 2 years ago

Hi, im using postgis 3.1. but im getting same error. "invalid geometry".

schema.json

    "geometry": {
      "columnType": {
        "type": "specificType",
        "args": [
          "geometry(POINT,4326)"
        ]
      },
      "type": "json",
      "fieldRenderer": "postgis"
    }

Post Request

{
  "data": {
    "polygon": {
        "type":"Point","coordinates":[-115.224609,64.125789]
    }
  }
}

Result:

error: insert into "public"."deeds" ("geometry", "published_at", "updated_at") values ($1, $2, $3) returning "id" - parse error - invalid geometry