Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not self intersecting geojson becomes self intersecting as a result of simplify #185

Open
tiokmu1731 opened this issue Jul 25, 2024 · 2 comments

Comments

@tiokmu1731
Copy link

First, I thank everyone participating in this project.

I guess it's not a bug, but I now found the case that

  • The original geojson is not self intersecting.
  • As a result of simplify in converting to vector-tile, generated vector-tile becomes self intersecting.

The original data I used is data of the Amami Islands from National land numerical information, Japan.
The geojson I attached is clipped from the original.
This clipped geojson is not self intersecting.

A20-070402_46_AmamiIslands_kasari.json

But after I converting this geojson to vector-tile using geojson-vt in the code below,
generated vector-tile becomes self intersecting as a result of simplify.

import geojsonvt from 'geojson-vt';
import geojson from "./geojson/A20-070402_46_AmamiIslands_kasari.json";

const tileIndex = geojsonvt(geojson);

const z = 10;
const x = 880;
const y = 427;

// request a particular tile
const features = tileIndex.getTile(z, x, y).features;

const amami_geometry = features[12].geometry[0];

// get WKT
let cood = "POLYGON((";

for (let i = 0; i < amami_geometry.length; i++) {
    cood+= amami_geometry[i][0] + (' -') + amami_geometry[i][1] + ',';
}

cood += "))";
console.log(cood);

Left: Original geojson
Right: Geometry made into vector tiles using geojson-vt
amami-airport-self-intersecting

I'm using Maplibre and it seems to use geojson-vt in converting to vector-tile.
In Maplibre project, an issue that self intersecting vector tile causes displaying unexpected form has been raised before.
I tried to display the geojson I attached in Maplibre, but it is also not displayed as I expected.
*An acute-angled triangle is displayed in particular zoom level:9.0-10.9. (At the point of blue arrow)

amami_description

The result I expect is the generated vector tile from geojson-vt is not self intersecting
if the original geo-json is as well. Is it possible to fix this case in geojson-vt?
*As I search similar cases, Tippecanoe corrects the geometry using mapbox/wagyu libraly.

@mourner
Copy link
Member

mourner commented Jul 25, 2024

Yes, basically this is still an unsolved problem, and I still don't know how to address it. You can read more context / history on the issue in mapbox/mapbox-gl-js#7023

@tiokmu1731
Copy link
Author

@mourner
I was very surprised to receive a reply from the original author of Leaflet.
Our team often uses Leaflet, and we appreciate your development of this wonderful map library.

I learned that this issue has already existed in mapbox-gl-js since 2018, and I understood that it would be technically difficult to resolve.
Your quick reply was very helpful. Thank you for letting us know about this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants