[Mapserver-users] Annotation setExpression() problem
Charlton Purvis
cpurvis at asg.sc.edu
Mon Feb 16 10:15:06 PST 2004
Rene:
I know that I have to put in opening and closing parens for my
setFilter's (for postgis), and that isn't explicitly documented in the
PHP documentation. Maybe you could try that?
Or what if you tried to dump everything to a .map to see the state of
all your variables?
Charlton
> -----Original Message-----
> From: Rene Teniere [mailto:TENIERER at gov.ns.ca]
> Sent: Monday, February 16, 2004 12:26 PM
> To: mapserver-users at lists.gis.umn.edu
> Subject: [Mapserver-users] Annotation setExpression() problem
>
> Hi all,
> Wondering if someone can help me here. I am creating an annotation
> layer with a dynamic expression to label only what I want each time.
> Problem is that I cannot set the expression through mapscript. It
works
> fine hard-coded in the mapfile, but it has to be done through php. The
> expression would look like: /1234|2345|3456/ or /1234/ That is
> represented in the $sExp variable in the code below. At first I set up
> the mapfile annotation layer without an expression then used
> $class->setExpression($sExp); to set the expression. That did not
work,
> even though the variable contents worked in the mapfile with the
desired
> results.
>
> Next, I got rid of the annotation layer in the map file and decided to
> create it through php/mapscript. The end results showed up with no
> annotation at all. The code for the layer creation is below, and I
have
> no idea why it will not work. Anyone have any ideas?
>
> 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","");
>
> //Create the annotation layer
> $anno = ms_newLayerObj($map);
> $anno->set("name","annolayer");
> $anno->set("maxscale",500000);
> $anno->set("status",MS_ON);
> $anno->set("data","D:\gis_data\wap_2002\all");
> $anno->set("type",MS_LAYER_ANNOTATION);
> $anno->set("labelitem","ID");
> $anno->set("classitem","ID");
>
>
> $class = ms_newClassObj($anno);
> $class->set("name","annoclass");
> $class->set("status",MS_ON);
>
> $class->label->type->MS_BITMAP;
> $class->label->size->MS_MEDIUM;
> $class->label->position->MS_CC;
> $class->label->color->setRGB(255,0,0);
>
> //Create Annotation Expression
> $sExp = "/".$nID[0];
> for($k=0; $k<=$nCOUNT; $k=$k+1)
> {
> if($k>0)
> {
> $sExp = $sExp."|".$nID[$k];
> }
> }
> $sExp = $sExp."/";
>
> //$expression = $class->getExpression();
> //error_log("Before:".$expression);
>
> $class->setExpression($sExp);
>
> //$expression = $class->getExpression();
> //error_log("After:".$expression);
>
> $shapes_class = ms_newClassObj($shapes);
>
> $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();
> ?>
>
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
More information about the MapServer-users
mailing list