Table of Contents |
---|
Introduction
Do this slowly and carefully, and if your lucky, you won't get hurt.
keywords
Code Block |
---|
Fedora 8
Fedora 9
centos
proj.4
geos
postgis
postgresql
|
In order to build postGIS you need some artifacts from the postgresQL development package. This is not as straight forward as it should be.<br>
I encourage you to take a few minutes to read this through. First, your "disto repository" is not likely to be up to date with respect to postgresql packages. In other words, if you blindly type "yum install postgresql-devel", you may have trouble getting everything installed properly. I've seen errors regarding missing libraries and the like. To avoid the fuss, when you are installing postgresql packages, use the postgresql repositories instead of your ditsro repsository.
...
OBSOLETE
See the postgresql installation page.
Installation
We assume you have already installed postgresql.
This is a good how to:
...
...
...
...
...
First install these packages:
proj.4 installation
geos installation
OK, now we build postGIS.
todo - where and how do we get the postgis package?
from code.google.com/p/eas/downloads
make sure these paths are correct!
Code Block |
---|
$ yum install postgresql-devel $ tar xvfz postgis-1.3.1.tar.gz $ cd postgis-1.3.1 $ ./configure \--with-pgsql=/usr/bin/pg_config \--with-geos=/usr/local/bin/geos-config \--with-proj-libdir=/usr/local/share/proj $ make $ su $ make install $ exit |
Errors
...
error
Code Block |
---|
configure: error: Can't find 'flex'
|
solution
Code Block |
---|
yum install flex |
Errors I've seen:
error:
Code Block |
---|
configure: error: no acceptable C compiler found in $PATH |
Solution:
yum install gcc-c++
|
Errors I've seen:
error:
Code Block |
---|
configure: error: readline library not found
|
Solution:
Code Block |
---|
yum install readline-devel.x86_64
|
Errors I've seen:
error:
Code Block |
---|
configure: error: zlib library not found
|
Solution:
Code Block |
---|
yum install zlib.x86_64 zlib-devel.x86_64
|
...
postgis_template
This is optional.
This page shows how to create and use a db template:
http://geospatial.nomad-labs.com/2006/12/24/postgis-template-database/
make a database
You can make a postgis db "by hand" (see below)<br>
Or you can make a postgis db by using the template (see previous)<br>
Code Block |
---|
$ su postgres
$ cd
$ createdb sfmaps
$ createlang plpgsql sfmaps
$ psql \-f /usr/share/lwpostgis.sql \-d sfmaps (error: could not load library)
$ psql \-f /usr/share/spatial_ref_sys.sql \-d sfmaps
$ psql sfmaps
|
if you encounter this error:
Code Block |
---|
libgeos_c.so.1: cannot open shared object file: No such file or directory<br>
|
do this<br>
Add /usr/local/lib to the dynamic linker run-time bindings
Code Block |
---|
echo '/usr/local/lib' >> /etc/ld.so.conf.d/local-lib.conf ldconfig |
test
How do we know if everything is working properly?
First, follow the install instructions (which I may not have included herein - sorry!)
http://postgis.refractions.net/docs/ch02.html#id2630100
Have the developers run the automated unit tests. But if your impatient I think the following should work...
...test proj4 by running this SQL
Code Block |
---|
select asewkt(transform(GeomFromText('POINT(-122.4195 37.77767)', 4326), 900913))
|
If proj4 is installed and running properly you should see this:
Code Block |
---|
SRID=900913;POINT(-13627676.4031672 4548065.4753209)
|
If not, you’ll get a SQL error.
To test geos run this sql (needs eas database to be restored):
todo: need some sql here that does not require a database
Code Block |
---|
select *
from
address_base ab,
addresses a
where contains(
st_transform(
st_envelope(ST_GeomFromEWKT('SRID=4326;POLYGON((-122.42134 37.77179 0,-122.42134 37.77780 0,-122.41537 37.77780 0,-122.41537 37.77179 0,-122.42134 37.77179 0))')),
2227
),
ab.geometry
)
and ab.address_base_id = a.address_base_id
limit 100;
|