[Mapserver-users] problems | postgis, projection, extent
Leah Roderman
elrod at oaktownunderground.com
Thu Mar 13 15:23:24 PST 2003
I seek the wisdom of the masses: I do not seem to have my mapfile configured properly. (Or, I need to adjust my understanding of what I am seeing.) There's a lot of detail in here, but I figure more is better...
I am running MapServer 3.6.4 (OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP SUPPORTS=PROJ SUPPORTS=TTF SUPPORTS=WMS_SERVER INPUT=TIFF INPUT=EPPL7 INPUT=JPEG INPUT=POSTGIS INPUT=GDAL INPUT=SHAPEFILE) on RedHat8.0 using PostGIS 0.7.4 and Postgres 7.3.2.
I successfully ran the demo and proceeded to create my own mapfile using data from CaSIL. The map was visible, I could identify county and water polygons. Then I introduced a layer with connectiontype postgis, which led to a round of debugging and testing to confirm that the db is indeed being connected to.
Problem #1: PostGIS layer produces a single dot (roughly in middle of box) which is not at the correct coordinates in relationship to the other layers. (Coordinates for S.F., CA but dot is hovering around Mammoth.) I am using filter, expression, symbol (see mapfile below). Tried adding additional expressions and changing query but the dot does not respond. Actually, I can make it change color and size, but it won't budge an inch.
So I thought about it...maybe I needed to use projection. After all, my data from CaSIL is Albers/NAD 27 in meters, and my geocoords stored in Postgres are lat/long NAD27...?
Problem #2: After adding projection to map object and each layer object, now all I see is a nice empty box of background color. I'm guessing I compounded problem #1 by tinkering with projection, and now I have two problems.
Here's an example of coordinates I have in a geometric column (used GeometryFromText to insert) in my db that I want to pull out and display on a layer:
SRID=-1;POINT(36.396331 -119.020059)
I can make the postgis layerconnection choke (change to user without grant) to see mapserver's query:
SELECT address_id::text,asbinary(force_collection(force_2d(mat_coord)),'NDR'),OID::text from addr_match WHERE (address_id = 11407) and (mat_coord && setSRID( 'BOX3D(-311074.95303064 -333852.22957132,71688.72916536 212953.03070868)'::BOX3D,find_srid('','addr_match','mat_coord') ));
and run it from psql command line to confirm that query returns something:
address_id | asbinary | oid
------------+--------------------------------------------------------------+----------
11407 | 010700000001000000010100000057790261A7E2424095456117459C5EC0 | 36035143
I've beat on this for a couple of days and trolled the archives, but I haven't found an answer yet. (It's probably something completely obvious that I'm missing, that would be Great.) If problem #1 rings any bells, please let me know -- not sure if it's a MapServer or a PostGIS issue. As for problem #2, I'm likely better off just solving one thing at a time, but I'd love some links to explanations of projection and extent. (I'm geography and cartography deficient, so though I understand the concept of a coordinate system, and projection as a means of selecting which distortion for sphere --> flat, the relationship between these and extent and imagesize gets my head fuzzy.)
Anyway, here's my mapfile that produces problem #1:
# map object
NAME CACO
STATUS ON
# attempted ratio to match extent
SIZE 700 1000
# derived extent from co100 using shpdump
EXTENT -373886.881 -604696.000 340099.435 449894.875
UNITS METERS
SHAPEPATH "shapedata"
IMAGECOLOR 154 179 220
SYMBOLSET "geo.sym"
# web object
WEB
HEADER geo_header.html
TEMPLATE geo.html
FOOTER geo_footer.html
LOG "mapserver.log"
METADATA
WMS_TITLE "Test Geo"
WMS_ABSTRACT "This is a test"
WMS_ACCESSCONSTRAINTS none
WMS_ONLINERESOURCE "http://www.kinakuta.com/geoenergy/geo_init.html"
END
END
# CaSIL CA counties
LAYER
NAME "COUNTY"
DATA co100a
STATUS DEFAULT
TYPE POLYGON
CLASSITEM "NAME"
CLASS
NAME "Alameda"
EXPRESSION "ALAMEDA"
COLOR 222 231 243
OUTLINECOLOR 0 0 0
END # class
CLASS
NAME "Contra Costa"
EXPRESSION "CONTRA COSTA"
COLOR 214 183 169
OUTLINECOLOR 0 0 0
END # class
CLASS
NAME "San Francsco"
EXPRESSION "SAN FRANCISCO"
COLOR 208 200 225
OUTLINECOLOR 0 0 0
END # class
CLASS
EXPRESSION /./
COLOR 193 214 180
OUTLINECOLOR 128 128 128
END # class
END # layer
# CaSIL CA Hydro
LAYER
NAME "CAHYDRO"
DATA hydrpola
STATUS DEFAULT
TYPE POLYGON
CLASSITEM "STATECODE"
CLASS
NAME "HYDRO"
EXPRESSION "1"
COLOR 154 179 220
OUTLINECOLOR 0 0 0
END # class
END # layer
# postgis addr_match
LAYER
CONNECTIONTYPE postgis
NAME "PLANTS"
CONNECTION "user=myuser dbname=mydb"
DATA "mat_coord from addr_match"
STATUS DEFAULT
TYPE POINT
FILTER "address_id = 11407"
CLASS
EXPRESSION ([address_id] = 11407)
SYMBOL "circle"
COLOR 255 1 3
SIZE 60
END # class
END # layer
END # map
-----------------
and for anyone interested in problem #2, I added this to the map object:
PROJECTION
"proj=aea"
"lat_1=34.0"
"lat_2=40.5"
"lat_0=0"
"lon_0=-120"
"x_0=0"
"y_0=-4,000,000"
"datum=NAD27"
END
and this to each layer:
PROJECTION
"proj=aea"
END
...but I didn't change extent or anything else. I derived projection from my CA Counties layer, which contains a text file with this information:
VITAL STATISTICS:
Datum: NAD 27
Projection: Albers
Units: Meters
1st Std. Parallel: 34 00 00 (34.0 degrees N)
2nd Std. Parallel: 40 30 00 (40.5 degrees N)
Longitude of Origin: -120 00 00 (120.0 degrees W)
Latitude of Origin: 00 00 00 (0.0 degrees)
Latitude of Origin: 00 00 00
False Easting (X shift): 0
False Northing (Y shift): -4,000,000
thank you all in advance,
- Leah
p.s. neither problem produces anything in my logfiles for mapserver or psql or apache
More information about the MapServer-users
mailing list