Add PointOnLine symbolizer #788

Open
artemp opened this Issue Oct 11, 2011 · 4 comments

Projects

None yet

3 participants

@artemp
Member
artemp commented Oct 11, 2011

Mapnik should be able to draw icon for point turned to be in same direction as direction of way on which that point lies.

This is needed to render highway crossings, power towers and other.

See crossings on Osmarender: http://www.openstreetmap.org/?mlat=50.0895787775517&layers=O&mlon=14.4224497675896&zoom=17

@artemp
Member
artemp commented Oct 11, 2011

[springmeyer] are you sure those crossing are not actual data? (e.g. perpendicular lines draw in place)

@artemp
Member
artemp commented Oct 11, 2011
@PetrDlouhy
Contributor

This is now with Mapnik 2.1.0 possible since the SVG transform can be parametrized. The syntax is following:

  <Style name="crossings">
      <Rule>
        &maxscale_zoom16;
        <PointSymbolizer file="&symbols;/SVG/crossing.svg" allow-overlap="true" ignore-placement="true" transform="rotate([angle])" placement="interior"/>
      </Rule>
  </Style>

  <Layer name="crossings" status="on" srs="&osm2pgsql_projection;">
      <StyleName>crossings</StyleName>
      <Datasource>
        <Parameter name="table">
        (
        select distinct on (p.way) p.way as way,
          l.highway as int_tc_type,
          degrees( ST_azimuth(coalesce(ST_Line_Interpolate_Point(l.way, ST_line_locate_point(l.way,p.way) * 0.99), p.way),
                              coalesce(ST_Line_Interpolate_Point(l.way, (1 - (1 - ST_line_locate_point(l.way,p.way)) * 0.99)), p.way))) as angle

         from &prefix;_point p
         join &prefix;_line l
          on ST_DWithin(p.way,l.way,&dwithin_node_way;)
         join (values
          ('motorway',1),
          ('trunk',2),
          ('primary',3),
          ('secondary',4),
          ('tertiary',5),
          ('unclassified',6),
          ('residential',7),
          ('living_street',8),
          ('service',9),
          ('cycleway',10)
         ) as v (highway,prio)
          on v.highway=l.highway
         where p.highway='crossing'
         order by p.way,v.prio
       ) as crossing
        </Parameter>
        &datasource-settings;
      </Datasource>
  </Layer>

(The PSQL query is not very elegant, but it is the best I was able to make.)
The result can be seen on http://cozpserver3.jinonice.cuni.cz/mtbmap/index.html?zoom=18&lat=50.07873&lon=14.40642&layers=000B00

To bring this feature for other users, it should be documented, even some syntax shortcuts would be nice.

@talaj
Member
talaj commented Apr 21, 2015

This should be solved by #2621.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment