You are not logged in.

Announcement

*** NOTICE: forum.openstreetmap.org is being retired. Please request a category for your community in the new ones as soon as possible using this process, which will allow you to propose your community moderators.
Please create new topics on the new site at community.openstreetmap.org. We expect the migration of data will take a few weeks, you can follow its progress here.***

#1 2015-03-02 05:42:41

n76
Member
Registered: 2013-05-22
Posts: 313

Mapnik XML stroke-width

I'd like to make some maps where when I really zoom in the roads are rendered at the actual width.

I think I've figured out a SQL select statement to get pixel width values based on the width=* tag if it exists, or estimate it from lanes=* tag if that exists or from assumptions about the number of lanes and lane width from values of highway=* as a last resort.

But now I don't see how to tell the renderer about it. The typical rendering rule is something like:

<Rule>
    <Filter>
        (([highway] = 'residential') or
         ([highway] = 'unclassified'))
    </Filter>
    <LineSymbolizer
        stroke="rgb(169,170,153)"
        stroke-width="8"
        stroke-linecap="round"
        smooth="0.7"
    />
</Rule>

When I try putting a SQL select field value after the stroke-width= it rejects it. I've tried

stroke-width="[pixel_width]"
stroke-width="pixel_width"
stroke-width=[pixel_width]
stroke-width=pixel_width

Where pixel_width is the results of my SQL select's calculation. The first two return and error message indicating that a number was expected. The latter two are invalid XML and are reported as such.

I guess if I back off from trying to do actual width properly scaled and just do lanes then I can setup a rule for each of the expected number of lanes and have the lane width in pixels hard coded for each zoom. But it seems I ought to be able to render a line with a width based on the width value someone has surveyed. Or in the case of using lanes, support an arbitrary number of lanes.

Any ideas?

Offline

#2 2016-11-08 11:52:42

chnav
Member
From: Russia, mapping Kazakhstan
Registered: 2010-03-18
Posts: 3,303

Re: Mapnik XML stroke-width

I leave it here just in case one comes across same problem
https://github.com/mapnik/mapnik/issues … t-48686925

As far as I know you can use ExpressionFormat from Mapnik 2.2 with the following attributes: 
- size
- halo-radius
- character-spacing
- opacity
- wrap-character

from Mapnik 3.0 ExpressionFormat also supports the attributes
- fill
- halo-fill

Offline

Board footer

Powered by FluxBB