mapnik / mapnik-support

Use the issues queue here to ask questions and offer help on using Mapnik (maybe if this works well we can retire the mailing list at http://mapnik.org/contact/?)
6 stars 6 forks source link

Cut labels even with big buffer-size #113

Closed zdila closed 5 years ago

zdila commented 5 years ago

Hello,

I am using mapnik 3.0.20 and have problem with cut text:

image

I've set buffer-size even to 1024 on Map and Layer but the text is still cut.

<Map background-color="white" srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs +over" buffer-size="1024">
  <Style name="infopoints">
    <Rule>
      <Filter>[type] = 'guidepost'</Filter>
      <MaxScaleDenominator>200000</MaxScaleDenominator>
      <TextSymbolizer size="10" face-name="DejaVu Sans Book" fill="black" halo-fill="white" halo-radius="1" dy="-8" wrap-width="80" wrap-before="true">[name] + '\n' + [ele]</TextSymbolizer>
    </Rule>
  </Style>

  <Layer buffer-size="1024">
    <StyleName>infopoints</StyleName>
    <Datasource base="db">
      <Parameter name="table">(select name, ele, type, geometry from import.osm_infopoints order by osm_id) as foo</Parameter>
    </Datasource>
  </Layer>
</Map>

Am I doing something wrong?

PS: I don't want to use avoid-edges property as it elemitinates too many labels.

talaj commented 5 years ago

Ahoj!

I would say that those labels does not collide deterministically. Try to sort the datasource result by id, for example. Order of rows returned from a PostgreSQL command is undefined without sorting.

zdila commented 5 years ago

Hi @talaj. Thanks for your answer. You can see in the SQL that I am already sorting it by osm_id.

zdila commented 5 years ago

I found a fix to my problem - I had to provide { buffer_size: 256 } to options of map.render nodejs function (OK, I forgot to mention that I use nodejs). But does it mean that if nodejs is used then buffer-size attribute of the Map is ignored?

talaj commented 5 years ago

Oh, sorry for my blindness.

It seems like a bug. Buffer-size zero is passed here by default. Collision detector with zero buffer is then created here.

zdila commented 5 years ago

Thanks for the analysis. Should I report it to mapnik/mapnik issues or is this report sufficient?

talaj commented 5 years ago

It would be great if you can report it in node-mapnik.

talaj commented 5 years ago

It seems to be intentional: https://github.com/mapnik/node-mapnik/issues/342. In this case the only thing to do is to emphasize it in the documentation.