[Mapserver-users] annotating multiple inline features
Dylan Keon
keon at nacse.org
Fri Mar 21 14:41:44 PST 2003
Thanks Steve, it's working now. After reading your message I reexamined
the docs and saw that classindex and text can be set using shape->set().
You wrote that the syntax is:
int draw(mapObj map, layerObj layer, imageObj image)
but the current documentation still says it's:
int draw(mapObj map, layerObj layer, imageObj img,
int class_index, string text)
Should I file a bug so that the documentation gets changed? Or is it
that way for a reason?
Thanks,
Dylan
Steve Lime wrote:
> What you write helped jog my memory. Class index and label text values
> are indeed held
> within a shapeObj structure. This was done so shapes were more
> autonomous. So, you
> should be able to set those parameters and then call the draw method.
> It probably worked
> for you before because the default classindex for a shape is 0.
>
> Steve
>
> Stephen Lime
> Data & Applications Manager
>
> Minnesota DNR
> 500 Lafayette Road
> St. Paul, MN 55155
> 651-297-2937
>
>
>>>>Dylan Keon <keon at nacse.org> 03/21/03 12:00PM >>>
>
> Yeah, I call drawLabelCache() right before saveWebImage().
>
> That bug report from the 3.5 era mentions the shape->draw() method no
> longer takes class index and text string arguments. The documentation
>
> hasn't changed, though. What's the status of shape->draw() in 3.6.x
> and
> 3.7?
>
> Seems like another way to do this might be to add an annotation layer
> to
> the mapfile, then for each line create a new shape containing one
> point,
> and use shape->set('text', 'test') to set annotation for that feature.
>
> I'll give this a shot. Anyone else tried this?
>
> Thanks,
> Dylan
>
>
> Steve Lime wrote:
>
>>Are you drawing the label cache further down in your code?
>>
>>
>>
>>>>>Dylan Keon <keon at nacse.org> 03/20/03 06:22PM >>>
>>
>>Hi,
>>
>>I'd like to label multiple inline features with text from user input.
>
>
>> From the 3.7 PHP MapScript docs it sounds like the ShapeObj draw()
>>method should do this ("The text string is used to annotate the
>>shape").
>> I figured I could label each feature this way as long as each
>
> feature
>
>>was put in a separate shape. The features are created just fine, but
>
> I
>
>>don't get any labels. I'm using 3.7 from a week ago.
>>
>>Is it related to this old bug?
>>http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=36
>>
>>If this method is no longer available, can someone recommend a way to
>
>
>>label inline features in a similar manner?
>>
>>Thanks,
>>Dylan
>>
>>
>> $image = $map->draw();
>> $layer = $map->getLayerByName('flightlines');
>>
>> for($i = 0; $i <= (count($beginlat) - 1); $i++) {
>>
>> $shape = ms_newShapeObj(MS_SHAPE_LINE);
>>
>> $line = ms_newLineObj();
>>
>> $line->addXY($beginlon[$i], $beginlat[$i]);
>> $line->addXY($endlon[$i], $endlat[$i]);
>> $shape->add($line);
>>
>> $shape->draw($map, $layer, $image, 0, $label[$i]);
>>
>> $line->free();
>>
>> $shape->free();
>>
>> }
>>
>>
>>LAYER
>> NAME flightlines
>> STATUS ON
>> #DATA #not needed, dynamic layer
>> TYPE LINE
>> CLASS
>> COLOR 255 0 0
>> SYMBOL 'circle'
>> SIZE 4
>> LABEL
>> TYPE TRUETYPE
>> FONT ARIAL
>> SIZE 14
>> COLOR 0 0 0
>> END
>> END
>>END
--
************************************************
Dylan Keon
GIS/Database Research Specialist
Northwest Alliance for Computational
Science and Engineering (NACSE)
Oregon State University
Corvallis, OR 97331
keon at nacse.org (541) 737-6608
************************************************
More information about the MapServer-users
mailing list