st_frechetdistance函数报错解决(postgis)--Linux

st_frechetdistance函数报错解决(postgis)
 
一。问题描述
 
SELECT st_frechetdistance('LINESTRING(0 0,100 0)'::geometry, 'LINESTRING(0 0,50 50,100 0)'::geometry);
 
ERROR:  The GEOS version this PostGIS binary was compiled against (36) doesn't support 'GEOSFechetDistance' function (3.7.0+ required)
错误:此PostGIS二进制文件编译的GEOS版本(36)不支持'GEOSFechetDistance'功能(需要3.7.0+)
 
查看postgis版本,发现geos版本确实是36
select postgis_full_version();
POSTGIS="2.5.0 r16836" [EXTENSION] PGSQL="100" GEOS="3.6.1-CAPI-1.10.1 r0" PROJ="Rel. 4.9.3, 15 August 2016" GDAL="GDAL 2.1.2, released 2016/10/24" LIBXML="2.9.7"
LIBJSON="0.13.1" TOPOLOGY RASTER
 
 
二。解决思路
 
升级geos版本,卸载postgis(找到安装目录,用make uninstall卸载),重新安装postgis
 
 
三。具体做法(Linux postgresql,postgis,geos等软件皆是源码安装)
 
 
1.停止postgresql服务
 
service postgresql stop
 
 
2.卸载geos(之前是安装到/usr/local/geos-3.6.1这边的)
 
cd /usr/local
 
rm -f -r geos-3.6.1
 
cd /usr/resource/pg/plugin
 
rm -f -r geos-3.6.1
 
rm -f -r geos-3.6.1.tar.bz2
 
 
3.重装更高版本的geos
 
tar -jxf geos-3.7.1.tar.bz2
cd geos-3.7.1
./configure --prefix=/usr/local/geos-3.7.1
make
make install
 
 
4.卸载postgis,再重装或者升级
 
 
4-1. 配置ld.so.conf
[root@VM_0_4_centos opt]# vi /etc/ld.so.conf
#编辑内容如下(之前geos是3.6.1,现改成3.7.1)
 
 
include ld.so.conf.d/*.conf
/usr/local/pgsql/lib
/usr/local/proj-4.9.3/lib
/usr/local/gdal-2.1.2/lib
/usr/local/geos-3.7.1/lib
/usr/local/json-c-0.13.1/lib
/usr/local/libxml2-2.9.7/lib
 
 
#编辑完成后wq!保存退出
#保存配置,重启生效
ldconfig -v
 
4-2. 卸载PostGIS,再安装(升级)
 
cd /usr/resource/pg/plugin/postgis-2.5.0
 
#先卸载
make uninstall
 
#删除之前的文件
cd ../
rm -f -r postgis-2.5.0
 
#重新解压安装(或者升级)
tar -zxvf postgis-2.5.0.tar.gz
cd postgis-2.5.0
./configure --prefix=/usr/local/pgsql --with-gdalconfig=/usr/local/gdal-2.1.2/bin/gdal-config --with-pgconfig=/usr/local/pgsql/bin/pg_config --with-geosconfig=/usr/local/geos-3.7.1/bin/geos-config --with-projdir=/usr/local/proj-4.9.3 --with-xml2config=/usr/local/libxml2-2.9.7/bin/xml2-config --with-jsondir=/usr/local/json-c-0.13.1
make
make install
 
 
5.启动数据库,执行PostGIS插件更新语句
 
service postgresql start
 
接下来在各个空间数据库内,执行PostGIS插件更新语句:
    
alter extension postgis update
 
 
6.验证
 
6-1.依赖验证    ldd /usr/local/pgsql/lib/postgis_topology-2.5.so
 
发现postgis依赖已经指向新装的geos3.7.1
 
 
6-2.版本验证
 
select postgis_full_version();
 
geos也是变成了3.7.1
 
6-3.函数验证
 
SELECT st_frechetdistance('LINESTRING(0 0,100 0)'::geometry, 'LINESTRING(0 0,50 50,100 0)'::geometry);
 
可以正常执行了
posted @ 2019-08-28 18:06  ejQiu  阅读(433)  评论(0编辑  收藏  举报