Re: do you have an easy example of postgis and mapserver?

From: Bill Thoen <bthoen(at)gisnet(dot)com>
To: Ottavio Campana <ottavio(at)campana(dot)vi(dot)it>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: do you have an easy example of postgis and mapserver?
Date: 2007-08-21 13:07:54
Message-ID: 20070821130754.GB1175@www.gisnet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Aug 21, 2007 at 12:44:49PM +0200, Ottavio Campana wrote:
> I'm sorry this mail is not very in topic, but I hope you can help me.

Just so you know, perhaps a better list to contact with this is the
MapServer mailing list at
http://lists.umn.edu/archives/mapserver-users.html, or maybe the PostGIS
list at http://www.postgis.org/mailman/listinfo/postgis-users.

> I'm trying to learn how postgis and mapserver work together, but I
> cannot understand nearly anything. I mean, I read the documentation of
> postgis and I think I understood it, but I cannot do anything useful
> with it.

I think before you try to do something customized with python you should
get familiar the mapserver MAP file which contains all the instructions to
map features from various sources like shape files, MapInfo TAB files,
PostGIS data sources, and so on. An example for mapping a layer from a
PostGIS source in a MAP file looks like this:

LAYER
NAME states
TYPE POLYGON
STATUS ON
CONNECTION "user=gisuser password=******* dbname=us_data host=localhost
port=5432"
CONNECTIONTYPE POSTGIS
DATA "the_geom from states"
CLASSITEM 'name'
PROJECTION
"+proj=latlong +datum=WGS84"
END
CLASS
NAME "US States"
OUTLINECOLOR 0 0 0
COLOR 255 255 196
END
END

The key bits here related to PostGIS are the CONNECTION, where you specify
all the info needed to get access to your PostgreSQL database, the
CONNECTIONTYPE which you set to POSTGIS, and the DATA directive in which
you supply a string that contains the SQL expression that pulls out the
geometry features you want to map.

If you do this with python, then you would first need to create an instance
of a mapObj, and then create a layerObj and add it to the map object,
setting the properties for the connection. However, my knowledge of this
approach is still very sketchy.

Documentation is spread around, but the two sites you should peruse are
the MapServer docs at: http://mapserver.gis.umn.edu/docs and the PostGIS docs
at: http://postgis.refractions.net/docs/.

- Bill Thoen

In response to

Browse pgsql-general by date

  From Date Subject
Next Message hubert depesz lubaczewski 2007-08-21 13:08:07 Re: Using oid as pkey
Previous Message Alvaro Herrera 2007-08-21 12:42:11 Re: Solution to Bus error(coredump) from postgres binary