codeforgermany / click_that_hood

A game where users must identify a city's neighborhoods as fast as possible
http://click-that-hood.com
MIT License
450 stars 639 forks source link

restore chicago-parks (changed geojson "winding order" #332

Closed epaulson closed 2 years ago

epaulson commented 2 years ago

The chicago-parks dataset didn't render right with the upgraded D3 - we got an ugly box that looked like this:

Screen Shot 2022-02-06 at 11 56 06 AM

So when we switched to D3 and MapboxGl, I just disabled chicago parks for the time being. This PR fixes it.

The problem is D3 is more particular about the "winding order" for geojson polygons - are the points on a polygon listed in clockwise or counterclockwise order? Most of the time this doesn't matter, but sometimes it does, and chicago-parks is one of those times. (Chicago-parks is I think the first and only dataset that uses both points and polygons in the same dataset - see #208 )

For more about the issue, see this StackOverflow question: https://stackoverflow.com/questions/49311001/d3-js-drawing-geojson-incorrectly and this comment on from the D3 repo: https://github.com/d3/d3-geo/pull/79#issuecomment-280935242

The stackoverflow question gives a couple of examples of how to fix it, I used this commandline utility: https://www.npmjs.com/package/geojson-rewind

npx geojson-rewind --counterclockwise <_work-in-progress/chicago-parks.geojson >chicago-parks.geojson

The parks dataset now renders correctly, or at least better than before!

Screen Shot 2022-02-06 at 12 21 14 PM
fnogatz commented 2 years ago

Thank you very much, @epaulson!