检查功能的函数,如Touches(), Contains(), Disjoint() 还有一些空间操作函数,如Intersection(), Union() 以及 Buffer()等 ,而Libxml2则提供了对GML和KML的操作函数,如ST_GeomFromGML(), ST_GeomFromKML()等,如果丧失了这样特性,空间数据库将会怎样
- wget http://download.osgeo.org/proj/proj-4.8.0.tar.gz
- wget http://download.osgeo.org/geos/geos-3.3.3.tar.bz2
- wget http://postgis.refractions.net/download/postgis-1.5.4.tar.gz
- tar -xvzf proj-4.8.0.tar.gz
- cd proj-4.8.0
- ./configure --prefix=/usr/local/proj
- make
- make install
- tar -jxvf geos-3.3.3.tar.bz2
- cd geos-3.3.3
- ./configure --prefix=/usr/local/geos
- make
- make install
- tar -xvzf postgis-1.5.4.tar.gz
- cd postgis-1.5.4
- ./configure --with-pgconfig=/usr/local/pgsql/bin/pg_config --with-projdir=/usr/local/proj --with-geosconfig=/usr/local/geos/bin/geos-config
PostGIS is now configured for x86_64-unknown-linux-gnu
-------------- Compiler Info -------------
C compiler: gcc -g -O2
C++ compiler: g++ -g -O2
-------------- Dependencies --------------
GEOS config: /usr/local/geos/bin/geos-config
GEOS version: 3.3.3
PostgreSQL config: /usr/local/pgsql/bin/pg_config
PostgreSQL version: PostgreSQL 9.1.3
PROJ4 version: 48
Libxml2 config: /usr/bin/xml2-config
Libxml2 version: 2.6.26
PostGIS debug level: 0
-------- Documentation Generation --------
xsltproc: /usr/bin/xsltproc
xsl style sheets:
dblatex:
convert:
- make
- make install
安装成功
启动 postgres
- su -postgres 切换到postgres用户下
- pg_ctl -D /data/pgsql/ -l /data/pgsql/pgsql.log start 启动数据库
- createdb template_postgis 创建数据库,此时,该数据库还没有具备空间特性
- psql -f /usr/local/pgsql/share/contrib/postgis-1.5/postgis.sql -d template_postgis 执行postgis.sql脚本,创建相关空间数据库相关的函数,类型,操作符等 执行完这个脚本,该数据库就具有了空间特性了
- psql template_postgis 连接到创建的空间数据库
- select postgis_full_version(); 查询postgis的版本信息,包含用到的三个库信息
-
POSTGIS="1.5.4" GEOS="3.3.3-CAPI-1.7.4" PROJ="Rel. 4.8.0, 6 March 2012" LIBXML="2.6.26" USE_STATS
- createdb [-U username] -T template_postgis my_spatial_db 下次再创建数据库,只要以这个模板就可以了
安装完毕...
注意事项:
将/usr/local/geos/lib添加到/etc/ld.so.conf中,然后运行/sbin/ldconfig,这样做的目的是/etc/ld.so.conf列出
的路径下的库文件缓存到/etc/ld.so.cache 以供使用,否则下面的编译可以会出现找不到xxx库的错误。
在执行psql -f /usr/local/pgsql/share/contrib/postgis-1.5/postgis.sql -d template_postgis
出现 Error# could not load library "/usr/local/pgsql/lib/postgis-1.5.so": libproj.so.0: 无法打开共享对象文件: 没有那个文件或目录
解决方法:LD_LIBRARY_PATH 中加入 geos lib proj lib .
cd /usr/local/pgsql/lib/ 建议链接 ln -s /usr/local/proj/lib/libproj.so.0 libproj.so.0
设置远程可访问数据库
vi /usr/local/pgsql/data/postgresql.conf
把listen_address = 'localhost' 改为 listen_address = '*'
vi /usr/local/pgsql/data/pg_hba.conf
在文件最后加入:
host all all 192.168.1.0/24 password
