【发布时间】:2021-07-30 23:33:03
【问题描述】:
我有一个 Postgres 数据库,上面创建了 Postgis 扩展。
我想使用ST_GeomFromGeoJSON function。文档状态:
如果您没有启用 JSON-C,您将收到错误通知,而不是看到输出。要启用 JSON-C,请运行 configure --with-jsondir=/path/to/json-c。有关详细信息,请参阅第 2.2.3 节“构建配置”。
所以我确保我已安装 JSON-C 并使用它配置 Postgis...
# install json-c
curl -L --output /tmp/json-c.tar.gz https://s3.amazonaws.com/json-c_releases/releases/json-c-0.10-nodoc.tar.gz
tar -xvf /tmp/json-c.tar.gz -C /tmp/
mkdir -p /var/lib/include
cp -r /tmp/json-c-0.10 /var/lib/include/json-c
# install postgis
curl https://download.osgeo.org/postgis/source/postgis-3.0.3.tar.gz -o ./postgis-3.0.3.tar.gz \
&& tar xvzf postgis-3.0.3.tar.gz
# configure postgis
cd /tmp/postgis-3.0.3
./configure --without-raster --with-jsondir=/var/lib \
&& make \
&& make install
然后,我在数据库中运行以下命令
postgres=# create extension postgis;
CREATE EXTENSION
postgres=# select ST_GeomFromGeoJSON('{"type": "Point", "coordinates": [0,0]}');
ERROR: You need JSON-C for ST_GeomFromGeoJSON
为什么会出现这个错误?我在配置 postgis 时包含 JSON-C,不是吗?我在安装步骤中遗漏了什么吗?
Postgres:12.7
Postgis:3.0.3
【问题讨论】:
-
只是猜测:不应该是
--with-jsondir=/var/lib/include/json-c而不是--with-jsondir=/var/lib?
标签: postgresql postgis