2

I had created a CSS for postgres planet_osm_line source on geoserver, for roads displaing in client, using WMS. CSS seted like:

/*.....*/

 /* @title Residential */
 [@scale < 20000] [highway = 'residential'] {
    stroke: #e2e1e1, #fefefe;
    label: [name];
    z-index: 0, 1;
    stroke-linecap: round;
    font-family: DejaVu Sans;
    font-weight: bold;
    font-size: 10;
   label-follow-line: true;
     label-max-angle-delta: 90;
     label-max-displacement: 250;
     label-repeat: 300;
  }

 /* @title Tertiary */
 [@scale < 20000] [highway = 'tertiary'] {
    stroke: #e5e5a8, #f8f8ba;
    stroke-width: 10px, 8px;
    label: [name];
    color: #dadada;
    z-index: 2, 3;
    stroke-linecap: round;
    font-family: DejaVu Sans;
    font-weight: bold;
    font-size: 10;
   label-follow-line: true;
     label-max-angle-delta: 90;
     label-max-displacement: 100;
     label-repeat: 100;
  }
 /*.....*/

But a unnormal artefact was detected: some line labels displays twice after n Zoom level: enter image description here

red line shows double label, green normal label. How to fix it using css or geoserver or OpenLayers configs?

2

You need to add the label-group operator to make sure lines with the same name are treated as a single line. See the manual for this and other options.

[@scale < 20000] [highway = 'residential'] {
    stroke: #e2e1e1, #fefefe;
    label: [name];
    z-index: 0, 1;
    stroke-linecap: round;
    font-family: DejaVu Sans;
    font-weight: bold;
    font-size: 10;
    label-follow-line: true;
    label-max-angle-delta: 90;
    label-max-displacement: 250;
    label-group: true;
    label-repeat: 300;
  }
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.