[Mapserver-users] shapeObj label for PHP/MapScript
Rene Teniere
TENIERER at gov.ns.ca
Fri Feb 13 10:03:48 PST 2004
Hi All,
I have created a new empty layer based on an existing layer containing
all the proper values set and tested. The layer that the new layer is
based on is ("status", MS_OFF), but I use it to extract shape objects
from it using getShape() and put them into the new empty layer through
draw(). The question is: does the shape object carry over the attributes
("id") from the parent shapefile so that I can create labels for the new
shapeobjects, because they are not showing up. If not, how would I go
about doing this?
In case you couldn't follow what I'm talking about :), here's the
code:
Thanks,
Rene
<?php
$map_path = "C:/chameleon11a/websites/wap/";
$map = ms_newMapObj($map_path."sketch.map");
$map->setExtent($minX-10, $minY-10, $maxX+10, $maxY+10);
$image = $map->draw();
$wap = $map->getLayerByName("WAP");
$shapes = ms_newLayerObj($map, $wap);
$shapes->set("name", "Shapes");
$shapes->set("data", "");
$shapes_class = ms_newClassObj($shapes);
//Set colours
$style = ms_newStyleObj($shapes_class);
$cWhite = $style->color->setRGB(255,255,255);
$cBlack = $style->color->setRGB(0,0,0);
$wap->open();
for($j=0; $j<=$nCOUNT; $j=$j+1)
{
$nShape[$j] = $wap->getShape(-1, $nIndex[$j]);
$nShape[$j]->draw($map, $shapes, $image);
}
$wap->close();
$scalebar = $map->drawScaleBar();
$image_url = $image->saveWebImage();
$scalebar_url = $scalebar->saveWebImage();
?>
LAYER
NAME "WAP"
GROUP "Treatments"
STATUS OFF
TYPE POLYGON
MAXSCALE 500000
DATA "D:/gis_data/wap_2002/all"
LABELITEM "id"
CLASS
EXPRESSION ([TRTAREA] >0)
LABEL
TYPE BITMAP
SIZE MEDIUM
MAXSIZE 100000
POSITION CC
COLOR 0 0 0
END
STYLE
SYMBOL 0
COLOR 255 255 255
OUTLINECOLOR 0 0 0
SIZE 1
MINSIZE 1
MAXSIZE 100
END
END
END
More information about the MapServer-users
mailing list