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

some geojsons are not displayed properly in v2 #224

Closed
donatso opened this issue Nov 13, 2020 · 1 comment
Closed

some geojsons are not displayed properly in v2 #224

donatso opened this issue Nov 13, 2020 · 1 comment

Comments

@donatso
Copy link

donatso commented Nov 13, 2020

Updating to v2 shows up strange problem with drawing geojson with geoPath. Most of geojson I tried doesn't draw correctly. In examples below is same code with two versions of d3-geo. on v1 both maps are drawen correctly, on v2 first map is off.

Edit: it seems that problem occurs when calculating the bonds of geojson geoPath.bounds

v1: https://jsfiddle.net/donatso/najf04ve/4/
v2: https://jsfiddle.net/donatso/najf04ve/2/

@Fil
Copy link
Member

Fil commented Nov 13, 2020

If you log console.log("area", d3.geoArea(props.geometry)) in both versions you will see that the polygons are all covering the sphere. This happens because they are not in the correct winding order.

However there was a bug in d3-geo@1 that was miscalculating the very small polygons, and so the two issues kind of cancelled each other, and you ended up with the (visually) correct result in d3-geo@1.

See also #140 (comment) and #141

Our current recommendation is to "rewind" the polygons, possibly with https://github.com/Turfjs/turf/tree/master/packages/turf-rewind

@Fil Fil closed this as completed Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants