我有一个Postgres数据库,并在其上创建了Postgis扩展。
我想使用GeomFromGeoJSON函数。文档声明:
如果您没有启用JSON,您将得到一个错误通知,而不是看到一个输出。要启用json,请运行配置--with=/path/ To /json。有关详细信息,请参阅2.2.3节“构建配置”。
所以我确保我安装了JSON并配置了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,不是吗?我在安装步骤中遗漏了什么吗?
邮政: 12.7
邮政信息系统: 3.0.3
发布于 2021-07-30 15:33:03
原来我安装得不对。当我像这样安装它时:
apt-get install libjson-c-dev并在./configure中使用了下面的内容
--with-jsondir=/usr啊,真灵。
您可以看到json-c头安装在/usr/include/json-c上。
ls /usr/include/json-c
arraylist.h json_c_version.h json_object_iterator.h linkhash.h
bits.h json.h json_object_private.h printbuf.h
debug.h json_inttypes.h json_tokener.h random_seed.h因此,/usr成为您的--with-jsondir
发布于 2021-07-30 04:05:00
可以运行选择PostGIS_Full_Version();postgis_full_version吗?
POSTGIS="3.0.0dev r17211“扩展PGSQL="110”GEOS=“3.8.0dev-1.11.0 df24b6bb”SFCGAL="1.3.6“PROJ="Rel. 5.2.0 2018年9月15日”GDAL="GDAL 2.3.2“发布2018/09/21”LIBXML="2.9.9“df24b6bb LIBPROTOBUF="1.3.1”WAGYU="0.4.3 (内部)拓扑光栅(1行)
它将显示LIBJSON是否集成。尝试升级到下一个postgis服务包版本。
https://stackoverflow.com/questions/68582308
复制相似问题