Skip to content

Instantly share code, notes, and snippets.

@ponkore
Created November 6, 2012 12:03
Show Gist options
  • Save ponkore/4024269 to your computer and use it in GitHub Desktop.
Save ponkore/4024269 to your computer and use it in GitHub Desktop.
postgis-2.0.1 on MacOSX (MacPorts) メモ (こっちは楽勝...でもなかった)
# install
$ sudo port install postgis2
$ port info postgis2
postgis2 @2.0.1 (databases, gis)
Variants: comments, gui, postgresql90, postgresql91, [+]postgresql92, [+]raster, [+]topology, universal
Description: PostGIS 2 adds geometrical, geographical and topological types, and functions operating thereon, to the PostGreSQL database. The 2.0 release also provides raster handling
and basic 3D geometry capacities (TIN and polyhedra).
Homepage: http://postgis.refractions.net/
Build Dependencies: autoconf, automake, libtool
Library Dependencies: geos, proj, libiconv, libxml2, postgresql92, gdal
Conflicts with: postgis
Platforms: darwin
License: GPL
Maintainers: [email protected], [email protected]
$
## ここで、postgis 用にデータベースとスキーマを作る。
## そのためには、一旦 make しなければならない。
$ ./configure --with-projdir=/opt/local
checking build system type... x86_64-apple-darwin11.4.2
checking host system type... x86_64-apple-darwin11.4.2
: (中略)
config.status: executing po-directories commands
PostGIS is now configured for x86_64-apple-darwin11.4.2
-------------- Compiler Info -------------
C compiler: gcc -g -O2
C++ compiler: g++ -g -O2
SQL preprocessor: /usr/bin/cpp -traditional-cpp -P
-------------- Dependencies --------------
GEOS config: /opt/local/bin/geos-config
GEOS version: 3.3.5
GDAL config: /opt/local/bin/gdal-config
GDAL version: 1.9.1
PostgreSQL config: /opt/local/lib/postgresql92/bin/pg_config
PostgreSQL version: PostgreSQL 9.2.1
PROJ4 version: 48
Libxml2 config: /opt/local/bin/xml2-config
Libxml2 version: 2.8.0
JSON-C support: no
PostGIS debug level: 0
Perl: /opt/local/bin/perl
--------------- Extensions ---------------
PostGIS Raster: enabled
PostGIS Topology: enabled
-------- Documentation Generation --------
xsltproc: /opt/local/bin/xsltproc
xsl style sheets: /opt/local/share/xsl/docbook-xsl
dblatex:
convert: /opt/local/bin/convert
mathml2.dtd: http://www.w3.org/Math/DTD/mathml2/mathml2.dtd
$ make
: (省略)
$
## make 完了。make 作業の中で、スキーマを作る SQL である、postgis/postgis.sql が生成される。
## 以下でデータベース postgis_db と専用のユーザ postgis を作る。
$ psql -U postgres
psql (9.2.1)
Type "help" for help.
postgres=# create database postgis_db;
CREATE DATABASE
postgres=# create user postgis encrypted password 'postgis';
postgres=# \q
$
## README.postgis には、以下の createlang が必要、とあるが、自分の環境では不要だった。
##
$ createlang -U postgres plpgsql postgis_db
createlang: language "plpgsql" is already installed in database "postgis_db"
$
## スキーマを作る SQL である postgis/postgis.sql を実行する。
##
$ psql -U postgres -f postgis/postgis.sql -d postgis_db > psql.log 2>&1
$ cat psql.log
SET
BEGIN
CREATE FUNCTION
CREATE FUNCTION
CREATE TYPE
: (中略)
CREATE FUNCTION
COMMIT
$
## 次に、README.postgis にある、raster support のための SQL (postgis/rtpostgis.sql) を実行、
## しようと思ったのだが、postgis/ 以下には無く、./raster/rt_pg/ 以下にあったのでそちらを実行(いいかげん...)。
$ psql -U postgres -f ./raster/rt_pg/rtpostgis.sql -d postgis_db > rt_postgis.log 2>&1
$ cat rt_postgis.log
SET
BEGIN
CREATE FUNCTION
CREATE FUNCTION
CREATE TYPE
CREATE FUNCTION
: (中略)
CREATE FUNCTION
COMMIT
$
## 最後に、spatial_ref_sys.sql のデータを投入。
##
$ psql -U postgres -d postgis_db -f spatial_ref_sys.sql > spatial_ref_sys.sql.log 2>&1
$ more spatial_ref_sys.sql.log
BEGIN
INSERT 0 1
INSERT 0 1
: (中略)
INSERT 0 1
INSERT 0 1
COMMIT
ANALYZE
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment