[mapserver-users] changing the color of a line

Andy Colson andy at squeakycode.net
Fri Feb 19 09:57:30 EST 2010


You can try this:

http://mapserver.org/ogc/sld.html

Like I said, I've never used it, have no idea if it'll work.

-Andy



On 2/19/2010 1:41 AM, ahmettemiz88 at gmail.com wrote:
> thank you
>
> Actually, I want to change color of contour map according to
> another map that lies beneath of contour map. Otherwise
> contours cannot be discerned.
>
> So, it' type is line.
>
> And I thought I might be able to change its color using
>
> "layer.updateFromString("COLOR 245 13 60");"
>
> but it failed.
>
> what might the alternative solutions be ?
>
> regards
>
> tarihinde, Andy Colson <andy at squeakycode.net> şunu yazdı:
>  > On 2/18/2010 1:35 PM, ahmet temiz wrote:
>  >
>  >
>  > hello
>  >
>  >
>  >
>  > how can I change the color of a line programmatically in mapscript
> environment
>  >
>  > (preferably in java)
>  >
>  >
>  >
>  > regards
>  >
>  >
>  >
>  >
>  > I think we need a little more info.  Is this line inside a layer...
> of type LINE?  Is the layer type POLYGON and you want to change one line
> of one polygon?  Is the line the only thing in the layer?  If there are
> lots of lines in the layer, do you know how to find the one you want?
>  >
>  >
>  >
>  > As an example, which may not be helpful... I have perl mapscript that
> highlights a polygon.
>  >
>  >
>  >
>  > In my mapfile I created a new, empty layer named annotate_pin, with
> coloring defined (green in my case).  I do sql on my PostGIS database to
> find the polygon I want to "highlight".  I copy the polygon from the
> "parcels" layer into the "annotate_pin" layer.
>  >
>  >
>  >
>  > my $layer = $map->getLayerByName('parcels');
>  >
>  > $layer->open();
>  >
>  >
>  >
>  > #newlayer is misnamed... it does exist in the .map file
>  >
>  > my $newlayer = $map->getLayerByName('annotate_pin');
>  >
>  > $newlayer->{status} = $mapscript::MS_ON;
>  >
>  >
>  >
>  > # sid here is set to the shape I want to copy/highlight
>  >
>  > $db->pg_result();
>  >
>  > ($sid) = $q->fetchrow_array;
>  >
>  >
>  >
>  > # get the shape
>  >
>  > my $shp = $layer->getFeature($sid);
>  >
>  > $layer->close();
>  >
>  > if (!$shp)
>  >
>  > {
>  >
>  >        print STDERR "---- cannot getFeature($sid) ----\n";
>  >
>  > }
>  >
>  >
>  >
>  > #copy it to a new shape
>  >
>  > my $shape = $shp->clone();
>  >
>  >
>  >
>  > #add new shape into the annotate_pin layer
>  >
>  > $newlayer->addFeature($shape);
>  >
>  >
>  >
>  > ... later we draw with $map, which has one polygon in the
> annotate_pin layer.
>  >
>  >
>  >
>  > Note that this is one way, there is the new styling options, but it's
> all xml and I cant stand xml, so I never even looked at it.  Not sure if
> this is at all what you were looking for, but hope it helps.
>  >
>  >
>  >
>  > -Andy
>  >



More information about the mapserver-users mailing list