[mapserver-users] PHP Mapscript Newbie: trouble with layers and logging.
Ben Logan
ben at wblogan.net
Fri Jun 28 03:43:26 PDT 2002
Hello, all.
I finally recompiled PHP so that I could use Mapscript with it, and I
have followed the "PHP/Mapscript By Example HOWTO." But now I've run
into some trouble getting additional layers to display. I also can't
seem to get it to write a log.
First the layer issue:
I have the following code:
...
$map = ms_newMapObj($map_path.$map_file);
...
$image = $map->draw();
$places_layer = $map->getLayer(1);
$places_layer->status = MS_ON;
$places_layer->draw($image) or print("<h3>Unable to draw layer.</h3>");
$image_url = $image->saveWebImage(MS_PNG, 1, 1, 0);
...
This is always unable to draw the layer. I tried using
"getLayerByName" as well, but with no success.
As for the logging, you can see that I have a LOG defined in my WEB
object in the map file. Also, test.log is writable by the web server.
Here's the map file:
#
# Start of map file
#
NAME TEST
STATUS ON
SIZE 400 400
#EXTENT -80.633987 36.708718 -80.104413 37.123488
EXTENT -81.379427 36.542485 -80.041493 37.366792
UNITS DD
#SHAPEPATH "data"
IMAGECOLOR 255 255 255
FONTSET "/var/www/html/ben/mapserv_demo/test/fonts"
#PROJECTION
# "proj=latlong"
# "datum=NAD83"
#END
# you may need to change this to match your MapServer build
#IMAGETYPE PNG
#
# Projection definition, consult the PROJ.4 documentation for parameter discussion
#
#PROJECTION
# "proj=utm"
# "ellps=GRS80"
# "zone=15"
# "north"
# "no_defs"
#
# OR:
#
# "init=epsg:26915"
#END
#
# Start of web interface definition (including WMS enabling metadata)
#
WEB
HEADER test_header.html
TEMPLATE test.html
FOOTER test_footer.html
LOG "/var/www/html/ben/mapserv_demo/local/test.log"
MINSCALE 1
MAXSCALE 2000000
IMAGEPATH "/var/www/html/ben/mapserv_demo/local/tmp/"
IMAGEURL "http://mach1/ben/mapserv_demo/local/tmp/"
METADATA
WMS_TITLE "A test map."
WMS_ABSTRACT "This is a test."
WMS_ACCESSCONSTRAINTS none
# change this value to match your setup
WMS_ONLINERESOURCE "http://mach1.log.cabin/ben/mapserv_demo/local/test_init.html"
WMS_SRS "EPSG:26915"
END
END
#
# Start of reference map
#
#REFERENCE
# IMAGE 'graphics/ref.png'
# EXTENT -80.633987 36.708718 -80.104413 37.123488
# SIZE 200 200
# STATUS ON
# COLOR -1 -1 -1
# OUTLINECOLOR 255 0 0
#END
#
# Start of legend
#
LEGEND
KEYSIZE 18 12
LABEL
TYPE BITMAP
SIZE MEDIUM
COLOR 0 0 89
END
STATUS ON
END
#
# Start of scalebar
#
SCALEBAR
IMAGECOLOR 255 255 255
LABEL
COLOR 0 255 0
SIZE tiny
END
STYLE 1
SIZE 80 2
COLOR 0 0 255
UNITS MILES
INTERVALS 1
TRANSPARENT TRUE
STATUS TRUE
END
#
# Start of symbol definitions (we're only using a few)
#
#
# Start of layer definitions
#
LAYER
NAME "County"
TYPE POLYGON
STATUS DEFAULT
#DATA "tgr51063cty00"
TILEINDEX "/var/www/html/ben/mapserv_demo/local/county.shp"
TILEITEM "location"
DATA "county"
HEADER "test_header.html"
FOOTER "test_footer.html"
CLASS
NAME "County"
OUTLINECOLOR 0 0 0
COLOR 255 255 200
END
END
#LAYER
# NAME "Relief"
# TYPE RASTER
# STATUS DEFAULT
# DATA "floyd.tif"
# #PROJECTION
# # "proj=utm"
# # "ellps=WGS84"
# # "zone=17"
# # "north"
# # "no_defs"
# #END
#END
#LAYER
# NAME "lpy"
# TYPE POLYGON
# STATUS OFF
## CONNECTIONTYPE OGR
## CONNECTION "data/carroll, 0"
# DATA "tgr51063lpy"
#
# #CLASSITEM 'STATES'
# CLASS
# NAME "LandmarkPoly"
# OUTLINECOLOR 0 0 255
# #COLOR 255 255 200
# END
#END
LAYER
NAME "Places"
TYPE POLYGON
STATUS OFF
TILEINDEX "/var/www/html/ben/mapserv_demo/local/plc00.shp"
TILEITEM "location"
LABELITEM "NAME"
DATA "plc00"
LABELMAXSCALE 500000
CLASS
NAME "Places"
OUTLINECOLOR 0 255 255
COLOR 240 240 180
LABEL
MINDISTANCE 150
POSITION AUTO
SIZE 9
TYPE truetype
FONT "arial"
COLOR 0 0 0
END
END
END
LAYER
NAME "majroads"
TYPE LINE
STATUS OFF
TILEINDEX "/var/www/html/ben/mapserv_demo/local/majroads.shp"
TILEITEM "location"
DATA "majroads"
LABELITEM "RTE_NUM"
LABELMAXSCALE 500000
#CLASSITEM 'STATES'
CLASS
NAME "Major Roads"
OUTLINECOLOR 0 0 0
COLOR 255 0 0
TEMPLATE "majroads.html"
LABEL
#ANGLE AUTO
#MINFEATURESIZE 40
MINDISTANCE 150
POSITION AUTO
#BACKGROUNDCOLOR 255 255 255
#BACKGROUNDSHADOWCOLOR 80 80 80
#OUTLINECOLOR 0 0 0
#BUFFER 2
SIZE 8
TYPE truetype
FONT "arial"
COLOR 0 0 0
END
END
END
LAYER
NAME "minroads"
TYPE LINE
STATUS OFF
TILEINDEX "/var/www/html/ben/mapserv_demo/local/minroads.shp"
TILEITEM "location"
DATA "minroads"
LABELITEM "NAME"
LABELMAXSCALE 200000
CLASS
NAME "Minor Roads"
OUTLINECOLOR 0 0 0
COLOR 0 255 0
TEMPLATE "minroads.html"
LABEL
#ANGLE AUTO
#MINFEATURESIZE 40
MINDISTANCE 150
POSITION AUTO
#BACKGROUNDCOLOR 255 255 255
#BACKGROUNDSHADOWCOLOR 80 80 80
#OUTLINECOLOR 255 255 255
#BUFFER 2
SIZE 8
TYPE truetype
FONT "arial"
COLOR 0 0 0
END
END
END
QUERYMAP
STATUS ON
STYLE HILITE
COLOR 0 255 255
END
END # Map File
Thanks for any help,
Ben
--
Ben Logan: ben at wblogan dot net
OpenPGP Key KeyID: A1ADD1F0
We were so poor that we thought new clothes meant someone had died.
More information about the MapServer-users
mailing list