Change of Data Source changes Mapserver behavior

Aaron Racicot aaronr at Z-PULLEY.COM
Thu May 3 20:30:04 PDT 2007


Hey there Matt,
Try:
1) Comment out your data statement for shapefile
2) Uncomment your three lines for PostGIS
3) Modify your data statement to be just [1]:
       DATA "the_geom from shp_counties"
4) If you need to have the more complex query [2] in the future for things
like sub-selects, then I believe you need a unique id in the " using unique
the_geom" part of your query.  Usually people use OID.

Hope that helps...

A

[1] - http://postgis.refractions.net/docs/ch04.html#id2893813
[2] - http://postgis.refractions.net/docs/ch04.html#id2894254
 

+----------------------------------------+
 Aaron Racicot - GIS Programmer  
 360.221.2441 - aaronr at ecotrust.org         
+----------------------------------------+
 e c o t r u s t                       
 pobox 1614
 langley wa 98260
 www.ecotrust.org                      
+----------------------------------------+ 
________________________________________
From: UMN MapServer Users List [mailto:MAPSERVER-USERS at LISTS.UMN.EDU] On
Behalf Of Matt Pettis
Sent: Thursday, May 03, 2007 8:00 PM
To: MAPSERVER-USERS at LISTS.UMN.EDU
Subject: [UMN_MAPSERVER-USERS] Change of Data Source changes Mapserver
behavior

Hi,
 
The map file at the end of this post is used by me to create a client-side
image map.  When I call this map file using a data source of .shp files
(which happens when SHAPEPATH and the 'NAME "counties"' lines are
uncommented), I get the proper result back to the calling webpage.  When
those lines are commented out and I instead use the lines that begin:
 
CONNECTION ...
CONNECTIONTYPE ...
DATA ...
 
to retrieve the same date from a POSTGIS/POSTGRESQL database, I don't get
the right results.  The following is a snippet of what I do get returned:
 
===
Content-type: text/html

<HTML>
<HEAD><TITLE>MapServer Message</TITLE></HEAD>
<!-- MapServer version 4.10.0 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP
OUTPUT=PDF OUTPUT=SWF OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=FREETYPE
SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER
SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=THREADS
SUPPORTS=GEOS INPUT=JPEG INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE
DEBUG=MSDEBUG -->
<BODY BGCOLOR="#FFFFFF">
</BODY></HTML>
===
 
Can anybody answer why the behavior changes when all i do is change the
datasource?  the shapefile and the table are the same (well, except for
whatever changes when I use the postgis tools to load the shapefile into the
Postgresql table, which should be only data format).  Does anybody know how
to fix/work around this?
 
Thanks!
 
Matt
 
=== map.map ===
MAP
    IMAGETYPE      PNG
    EXTENT  189783.546875 4810309 761653.5625 5472346.5
    SIZE    680 510
    SHAPEPATH "C:\ms4w\gisvote\data\shp"
    IMAGECOLOR     255 255 255
 
    WEB
#       HEADER   "imgmap-th.htm"
#       FOOTER   "imgmap-tf.htm"
#       TEMPLATE "imgmap-t.htm"
        IMAGEPATH   "C:\ms4w\Apache\htdocs\tmp\"
        IMAGEURL    "/tmp/"
    END
 
    QUERYMAP
        STATUS ON
        STYLE NORMAL
    END
 
    LAYER
        NAME         "counties"
 
### this is pulling straight from the .shp files
        DATA         "counties"
 
### or...
 
### this does not behave like calling info from shape files... i don't know
why yet
### when using this, probably don't need the SHAPEPATH setting.
#       CONNECTION "user=postgres dbname=postgis password=4theluv"
#       CONNECTIONTYPE POSTGIS
#       DATA "the_geom from (select * from shp_counties) as foo using unique
the_geom using SRID=-1"
 
        STATUS       DEFAULT
        TYPE         POLYGON
 
        TEMPLATE "imgmap-t.htm"
 
        CLASS
            NAME        "county_class"
            STYLE
                COLOR        232 232 232
                OUTLINECOLOR 32 32 32
            END
        END
    END
END
 
It is from the wellspring of our despair and the places that we are broken
that we come to repair the world.
-- Murray Waas
 



More information about the MapServer-users mailing list