[Mapserver-users] drawing lines with mapscript

Jeff Hoffmann jeff at propertykey.com
Mon Mar 29 13:24:33 PST 2004


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.  I've done it before with points & 
rectangles, but it looks like lines don't have a draw function defined 
for them the way points & rectangles do so I'm trying to turn the 
lineObj into a shapeObj and draw that.  The line that I'm adding to the 
shape has points with reasonable coordinates so I'm assuming that's not 
the problem.   I don't know if I'm doing the class stuff right, though, 
  but I can't find much documentation on how that works when drawing a 
shape.  Can someone give me an example of how to do this?  Here's 
basically what I've been trying to do:

$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);
$shape->draw($map, $layer, $img);


Here's the layer definition:

LAYER
   NAME line_layer
   STATUS OFF
   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
   END
END

-- 

Jeff Hoffmann
PropertyKey.com




More information about the MapServer-users mailing list