【问题标题】:Adding a point geometry to Postgresql将点几何添加到 Postgresql
【发布时间】:2021-01-02 14:50:02
【问题描述】:

我想使用以下方法将点几何插入 PostgreSQL Db,但我收到一个我不知道它会出现的错误。

const point = {type:"Point",coordinates:[-48.23456,20.12345]}
tableName.create({ geom: point }, user_id: 9 })



"error": {
    "name": "SequelizeDatabaseError",
    "parent": {
        "name": "error",
        "length": 128,
        "severity": "ERROR",
        "code": "22023",
        "file": "gserialized_typmod.c",
        "line": "164",
        "routine": "postgis_valid_typmod",
        "sql": "INSERT INTO \"gps_tracking\" (\"id\",\"created\",\"user_id\",\"geom\") VALUES (DEFAULT,now(),$1,ST_GeomFromGeoJSON($2)) RETURNING *;",
        "parameters": [
            9,
            {
                "type": "Point",
                "coordinates": [
                    -48.23456,
                    20.12345
                ]
            }
        ]
 }

【问题讨论】:

  • 您是否尝试直接执行此 SQL 查询并查看您得到的错误?

标签: node.js postgresql sequelize.js postgis


【解决方案1】:

添加“crs”行解决了我的问题。谢谢

const point = {
     type: 'Point',
     coordinates: [39.807222, -76.984722],
     crs: { type: 'name', properties: { name: 'EPSG:4326' } }
 };

【讨论】:

    猜你喜欢
    • 2015-02-03
    • 2017-05-01
    • 2014-09-18
    • 2018-08-15
    • 2018-12-15
    • 2016-05-28
    • 1970-01-01
    • 2014-03-09
    • 1970-01-01
    相关资源
    最近更新 更多