glenrobertson / leaflet-tilelayer-geojson

Leaflet TileLayer for GeoJSON tiles
Other
250 stars 79 forks source link

Lines appear in shapes split across tiles #13

Closed mapmeld closed 10 years ago

mapmeld commented 10 years ago

When I use this layer with a line weight / opacity to shape borders, a small but visible gap appears in features split across tiles. You can see some horizontal lines which are almost parallel in the bottom third of this screenshot. The straight one is a tile gap.

screen shot 2014-02-03 at 6 20 46 pm

When I select one part and change fillColor, it colors the area on both sides of the gap, so I think that unique correctly puts them in the same featureGroup. The tricky part is merging the parts which were downloaded in different tiles.

I don't see this problem in the demo at http://bl.ocks.org/glenrobertson/6203331

Is there a client-side workaround? Is this a known problem where I could be using a geo library to merge features?

glenrobertson commented 10 years ago

I think the problem here is that the SVG clipping performed by the GeoJSON TileLayer is hiding the tile lines that each geometry is trimmed to, but you're adding an outline so they can be seen even after SVG clipping. When trimming the tiles on the server, you need to take into account the width of the tile outline you're rendering on the client.

So if you are rendering geometries with a 2 pixel thickness, you need to serve each tile where the geometries are buffered outside of the tile bounding box by 2 pixels. This is so the GeoJSON TileLayer can completely hide the tile outline..

Hope this makes sense!

mapmeld commented 10 years ago

thanks! in TileStache I just needed to find and set padded=True

Edit: my eventual solution in tilestache.cfg

"provider": {
  "name": "vector",
  "clipped": "padded",
  ...
}
glenrobertson commented 10 years ago

:boom: glad I could help!