1.PostgreSQL+PGIS+GeoServer軟件安裝
(一)OSM2PGSQL
(1)osm2PGSQL下載:https://ci.appveyor.com/project/openstreetmap/osm2pgsql(從git上拉)(要有default.style文件)
(二)osm數(shù)據(jù)下載
中國(guó)數(shù)據(jù)下載:http://download.geofabrik.de/asia/china.html喝噪,有點(diǎn)慢
(三)修改PostgreSQL配置(重要氢妈,否則會(huì)報(bào)錯(cuò):no password supplied)
修改 pg_hba.conf (路徑:...\PostgreSQL\10\data)
將原 md5 改為 trust拧咳,改完重啟下
(四)導(dǎo)入數(shù)據(jù)
(1)為了方便命令行導(dǎo)入,可以修改下環(huán)境變量该窗,把OSM2PGSQL的路徑放到path下面剑刑。
(2)導(dǎo)入前可先創(chuàng)建一個(gè)數(shù)據(jù)庫 osm_china
(3)加載postgis對(duì)象和函數(shù)定義(postgis.sql)(否則會(huì)報(bào)錯(cuò):type "geometry" does not exist)
psql -U postgres -d osm_china -f D:\postGreSQL\share\contrib\postgis-3.1\postgis.sql
(4)加載EPSG坐標(biāo)系統(tǒng)定義(spatial_ref_sys.sql)
psql -U postgres -d osm_china -f D:\postGreSQL\share\contrib\postgis-3.1\spatial_ref_sys.sql
(5)導(dǎo)入
osm2pgsql -d osm_china -U postgres -P 5432 -C 12000 -S"D:\osm2pgsql-bin\default.style" D:\Data\osm\china-latest.osm.pbf
遇到的坑:
(1)命令行拋出的錯(cuò)誤信息脆栋,顯示亂碼問題:
找到postgresql.conf文件拓春,修改參數(shù)lc_messages的值為UTF8;重啟PostgreSQL的服務(wù)钦听。