[Mapserver-users] drawing lines with mapscript
Jeff Hoffmann
jeff at propertykey.com
Tue Mar 30 09:57:27 PST 2004
Eric Bridger wrote:
> On Tue, 2004-03-30 at 09:56, Jeff Hoffmann wrote:
>
>>Eric Bridger wrote:
>>
>>>On Mon, 2004-03-29 at 16:24, Jeff Hoffmann wrote:
>>>
>>>
>>>>I'm trying to create lines programmatically & draw them using mapscript,
>>>>but I just can't seem to get any output. It doesn't throw any errors,
>>>>but I don't see any output, either.
>>>>$layer = $map->getLayerByName('line_layer');
>>>>$layer->{status} = 1;
>>>>$class = $layer->getClass(0);
>>>>$class->setText($layer,"LINE");
>>>>my $shape = new mapscript::shapeObj($mapscript::MS_SHAPE_LINE);
>>>>$shape->add($line);
>>>
>>>
>>>Just a guess, but you could try $shape->setBounds() here.
>>>
>>>
>>>
>>>>$shape->draw($map, $layer, $img);
>>
>>That didn't change anything. Does anybody at least know if this looks
>>like it should be working? Are there any examples of code that does
>>this sort of thing?
>
>
> This should work. I had never used $shape->draw() so I modified a test
> script I had and it worked fine. I could not get $shape->{text} = "XX"
> to work. You haven't shown your $line creation. Perhaps your
> coordinates are off.
Thanks for trying to help me through this. I'm sure that the line has
points that fall in the map I'm drawing. I've hard-coded one line in
there that should draw a line from corner to corner, but still nothing
shows up. $shape->draw(...) returns 0, but I don't know if that means
"error" or "no error", the documentation just says it returns an integer.
----------------------------------
$layer = $map->getLayerByName('line_layer');
$layer->{status} = 1;
$class = $layer->getClass(0);
my $linePoint1 = new mapscript::pointObj();
$linePoint1->{x} = 272048; $linePoint1->{y} = 199772;
my $linePoint2 = new mapscript::pointObj();
$linePoint2->{x} = 272450; $linePoint2->{y} = 200074;
my $line = new mapscript::lineObj();
$line->add($linePoint1);
$line->add($linePoint2);
$class->setText($layer,"LINE");
my $shape = new mapscript::shapeObj($mapscript::MS_SHAPE_LINE);
$shape->add($line);
$shape->draw($map, $layer, $img);
----------------------------------
LAYER
NAME "line_layer"
STATUS ON
PROJECTION
"init=epsg:26958"
END
TYPE LINE
CLASS
LABEL
ANGLE AUTO
FONT arial
TYPE TRUETYPE
POSITION UC
SIZE 7
COLOR 0 0 0
END
COLOR 0 0 0
SIZE 10
END
END
--
Jeff Hoffmann
PropertyKey.com
More information about the MapServer-users
mailing list