alexgk
alexgk

Reputation: 13

Draw a POLYGON feature as as a line string in MapLibre / Mapbox

I have vector tiles that I want to render in MapLibre with a custom style. There are geofeatures with polygons that I want to render as a filled polygon. In addition, I want to render the outline of that polygon of the tiles, but I get unwanted lines along the tiles edges, as can be seen in the image:
problematic render

So how can I render the outline of a polygon with the same behavior as if it were a linestring, like shown here:
desired render

Here is a data sample of one instance of a geofeature that I want to render:

OGRFeature(LNDARE):98423398
  AGEN (Integer) = 550
  FIDN (Integer) = 55645658
  FIDS (Integer) = 8705
  GRUP (Integer) = 1
  LNAM (String) = 0226035115DA2201
  OBJL (Integer) = 71
  PRIM (Integer) = 3
  RCID (Integer) = 20
  RVER (Integer) = 1
  MULTIPOLYGON (((-8515941.28455114 5342031.0327944,-8516919.43964748 5342031.0327944,-8516919.43964748 5342463.37973564,-8515941.28455114 5342463.37973564,-8515941.28455114 5342031.0327944)))

And this is the "problematic" part of the style that leads to image 1:

{
[...]
    "layers": [
           "filter": [
               "any",
               [
                   "==",
                   "$type",
                   "Polygon"
               ],
               [
                   "==",
                   "$type",
                   "LineString"
               ]
           ],
           "id": "LNDARE_line_US5NY6DW",
           "paint": {
               "line-color": "#525a5c",
               "line-width": 2
           },
           "source": "US5NY6DW",
           "source-layer": "LNDARE",
           "minzoom": 0,
           "maxzoom": 24,
           "type": "line"
       },
[...]

I guess, my problem is correctly identified here, but no solution was given. Obviously, one solution would be to duplicate the values of the polygon to a linestring, but if possible, I would prefer a solution that does not alter the map data and instead fixes the rendering in the style. In the style spec I could not find the right expressions to filter the unwanted line segments from the source.

Upvotes: 0

Views: 186

Answers (0)

Related Questions