[mapserver-users] [EXTERNAL] Re: the lines one above other

thomas bonfort thomas.bonfort at gmail.com
Fri Feb 13 05:17:58 PST 2015


You can do it in a single layer, provided that you have someway of
determining via attributes that a given road segment isn't connected
to other road segments below it (typically that would be something
saying it's a bridge rather than a regular road). The behavior is
undocumented and relies on the knowledge of how mapserver treats the
line cache for casing.

CLASS
  EXPRESSION ("[type]"="bridge")
  STYLE
  END
  STYLE
    WIDTH 5
    COLOR bridge_outline_color
    LINECAP butt
  END
  STYLE
    WIDTH 3
    COLOR highway_color
  END
END
CLASS
  STYLE
    WIDTH 5
    COLOR highway_outline_color
  END
  STYLE
    WIDTH 3
    COLOR highway_color
  END
END

(The trick is to add an empty style block so the rendering order for
bridges is offset by one compared to normal roads)

In your sql query, you also use an "order by z_level asc" so higher
roads get drawn after (=over) lower ones.
You might want to take a look at https://github.com/mapserver/basemaps
where this (along with other tricks for dealing with complex road
maps) is used.

--
thomas

On 13 February 2015 at 07:52, Vladimir <fl_v at inbox.ru> wrote:
> I would draw your attention to the source of this discussion.
> http://osgeo-org.1560.x6.nabble.com/the-lines-one-above-other-td5187093.html
>
> It seems I found how to display multilevel junction of highway with "ORDER
> BY" in the case using a one layer. Adding "order by id desc" or "order by id
> asc" in subquery, also the definition $highwayStyle2 besides $highwayStyle1
> works fine.
> Please see the code and the illustrations below:
>
> --------------------------------------------------
>
> $highwayLayer->set('status', MS_ON);
> $highwayLayer->set('name', 'highway');
> $highwayLayer->set('labelitem', 'name');
> $highwayLayer->setConnectionType(MS_POSTGIS);
> $highwayLayer->set('connection', 'user=my_user password=my_pass dbname=my_db
> host=localhost');
>
> $highwayLayer->set("data","geom from (select id, 'id = '||id as name, geom
> from my_table
> where ST_Intersects(geom, !BOX!) order by id desc) as subquery using unique
> id using srid=3857");
> $highwayLayer->setprocessing("close_connection=defer");
> $highwayLayer->set("type",MS_LAYER_LINE);
>
> $highwayClass = new ClassObj($highwayLayer);
> $highwayClass->set('name', 'highway');
>
> $highwayStyle1 = new styleObj($highwayClass);
> $highwayStyle1->color->setRGB(254,173,0);
> $highwayStyle1->set('linecap','square');
> $highwayStyle1->set('width',4);
> $respdorStyle1->outlinecolor->setRGB(255,0,0);
> $respdorStyle1->set('outlinewidth',2);
>
> $highwayStyle2 = new styleObj($highwayClass);
> $highwayStyle2->color->setRGB(254,173,0);
> $highwayStyle2->set('linecap','square');
> $highwayStyle2->set('width',4);
> $respdorStyle2->outlinecolor->setRGB(255,0,0);
> $respdorStyle2->set('outlinewidth',2);
>
> -------------------------
>
> Result when "order by id asc":
> http://s22.postimg.org/esbobf18x/order_by_id_asc.jpg
>
> Result when "order by id desc":
> http://s10.postimg.org/qeokp2jrd/order_by_id_desc.jpg
>
> -------------------------
>
> That's the goods for me but there is the impression of using some
> undocumented singularity.
>
> Thanx for any comments.
>
>
>
>
>
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users


More information about the mapserver-users mailing list