TransWikia.com

Unable to insert geometry point using TypeScript and MassiveJS

Geographic Information Systems Asked by user3123590 on October 1, 2021

I am trying to simply trying to validate a point before I actually insert it into the db.

I am using the following:

  • TypeScript: 3.5.2
  • MassiveJS: 6.4.0
  • PostgreSQL: 11
  • PostGIS: 2.5
        const validGeom = await db.st_isvalidreason(await db.st_point(commonWeather.reqLon.toFixed(4),commonWeather.reqLat.toFixed(4)))
        console.log(validGeom)

I am consistently getting the following error:

error: parse error - invalid geometry
    at Connection.parseE (/app/node_modules/pg/lib/connection.js:581:48)
    at Connection.parseMessage (/app/node_modules/pg/lib/connection.js:380:19)
    at Socket.<anonymous> (/app/node_modules/pg/lib/connection.js:116:22)
    at Socket.emit (events.js:223:5)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:290:11)
    at Socket.Readable.push (_stream_readable.js:224:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:181:23) {
  name: 'error',
  length: 151,
  severity: 'ERROR',
  code: 'XX000',
  detail: undefined,
  hint: '"{"" <-- parse error at position 2 within geometry',
  position: '43',
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'lwgeom_pg.c',
  line: '177',
  routine: 'pg_parser_errhint'
}

One Answer

I will answer my own question. turns out massive support for PostGIS functions is not great. buried deep in their docs they flat out say this.

I ended up writing a custom script and invoking it with massive. This last part was actually kind of nice as massive allows you to pass in a javascript object and used named parameters in your SQL, so no need for this $1, $2 crazyness.

Answered by user3123590 on October 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP