Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Try successively line and then point placements for TextSymbolizer #1152

Open
dmentre opened this Issue Mar 27, 2012 · 2 comments

Comments

Projects
None yet
3 participants

dmentre commented Mar 27, 2012

Feature request.

To place a long street name on a map, we usually use placement="line" (for TextSymbolizer), eventually reducing size of the label to fit the small street (using advanced placement-type="simple"). But sometimes this is not enough: the street size is to short for the street name to fit in it. In that case, we would like to fall back to placement="point".

In short, we would like to have placement="line,point" for TextSymbolizer. Would it be possible?

@ghost ghost assigned herm Mar 28, 2012

Member

herm commented Mar 28, 2012

Currently it isn't possible, but it wouldn't be very hard to implement it.

I'm putting this on my TODO list.

This should be possible via the placement-type=list approach, but it doesn't currently work. Testcase attached:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map>
<Map background-color="white" srs="+proj=latlong +datum=WGS84">
  <Layer name="layer" srs="+proj=latlong +datum=WGS84">
    <StyleName>text</StyleName>
    <Datasource>
      <Parameter name="type">csv</Parameter>
      <Parameter name="inline">
      wkt,name
      "LINESTRING(0 0, 10 2)",reference text just fits
      </Parameter>
    </Datasource>
  </Layer>
  <Layer name="layer" srs="+proj=latlong +datum=WGS84">
    <StyleName>text</StyleName>
    <Datasource>
      <Parameter name="type">csv</Parameter>
      <Parameter name="inline">
      wkt,name
      "LINESTRING(0 2, 10 4)",too long to fit but ok with smaller spacing
      </Parameter>
    </Datasource>
  </Layer>
  <Layer name="layer" srs="+proj=latlong +datum=WGS84">
    <StyleName>text</StyleName>
    <Datasource>
      <Parameter name="type">csv</Parameter>
      <Parameter name="inline">
      wkt,name
      "LINESTRING(0 4, 10 6)",too long to fit with small spacing but should be placed on point with wrap
      </Parameter>
    </Datasource>
  </Layer>

  <Style name="text">
    <Rule>
      <LineSymbolizer stroke-width="0.2" stroke="#ff0000" />
      <TextSymbolizer fill="#8b4500" size="20" character-spacing="15" face-name="DejaVu Sans Book" placement="line" placement-type="list">[name]
        <Placement character-spacing='4' />
        <Placement character-spacing='1' size="10" placement="point" wrap-width="20" />
        </TextSymbolizer>
    </Rule>
  </Style>
</Map>

gives

foo

on mapnik 2.2.0 with nik2img.py placements.xml foo.png

@gravitystorm gravitystorm referenced this issue in mapbox/carto Jun 18, 2013

Open

Support list placement for text #238

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