{"action":"created","issue":{"url":"https://api.github.com/repos/mapzen/vector-datasource/issues/698","repository_url":"https://api.github.com/repos/mapzen/vector-datasource","labels_url":"https://api.github.com/repos/mapzen/vector-datasource/issues/698/labels{/name}","comments_url":"https://api.github.com/repos/mapzen/vector-datasource/issues/698/comments","events_url":"https://api.github.com/repos/mapzen/vector-datasource/issues/698/events","html_url":"https://github.com/mapzen/vector-datasource/issues/698","id":147520449,"number":698,"title":"Invalid geom in some tiles (GeoJSON)","user":{"login":"nvkelso","id":853051,"avatar_url":"https://avatars.githubusercontent.com/u/853051?v=3","gravatar_id":"","url":"https://api.github.com/users/nvkelso","html_url":"https://github.com/nvkelso","followers_url":"https://api.github.com/users/nvkelso/followers","following_url":"https://api.github.com/users/nvkelso/following{/other_user}","gists_url":"https://api.github.com/users/nvkelso/gists{/gist_id}","starred_url":"https://api.github.com/users/nvkelso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nvkelso/subscriptions","organizations_url":"https://api.github.com/users/nvkelso/orgs","repos_url":"https://api.github.com/users/nvkelso/repos","events_url":"https://api.github.com/users/nvkelso/events{/privacy}","received_events_url":"https://api.github.com/users/nvkelso/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mapzen/vector-datasource/labels/in%20review","name":"in review","color":"e6e6e6"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/mapzen/vector-datasource/milestones/13","html_url":"https://github.com/mapzen/vector-datasource/milestones/v0.10.0","labels_url":"https://api.github.com/repos/mapzen/vector-datasource/milestones/13/labels","id":1640113,"number":13,"title":"v0.10.0","description":"","creator":{"login":"nvkelso","id":853051,"avatar_url":"https://avatars.githubusercontent.com/u/853051?v=3","gravatar_id":"","url":"https://api.github.com/users/nvkelso","html_url":"https://github.com/nvkelso","followers_url":"https://api.github.com/users/nvkelso/followers","following_url":"https://api.github.com/users/nvkelso/following{/other_user}","gists_url":"https://api.github.com/users/nvkelso/gists{/gist_id}","starred_url":"https://api.github.com/users/nvkelso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nvkelso/subscriptions","organizations_url":"https://api.github.com/users/nvkelso/orgs","repos_url":"https://api.github.com/users/nvkelso/repos","events_url":"https://api.github.com/users/nvkelso/events{/privacy}","received_events_url":"https://api.github.com/users/nvkelso/received_events","type":"User","site_admin":false},"open_issues":45,"closed_issues":3,"state":"open","created_at":"2016-03-12T01:28:14Z","updated_at":"2016-04-11T20:03:21Z","due_on":"2016-04-30T07:00:00Z","closed_at":null},"comments":1,"created_at":"2016-04-11T18:58:00Z","updated_at":"2016-04-11T22:13:10Z","closed_at":null,"body":"We've seen this a few times, and while Tangram mostly handles it okay, other tools barf on **invalid geometries**. \r\n\r\nSeems like the data is being transformed during vector tile creation (I suspect it's fine in PostGIS) and that transform results in self-intersecting geoms.\r\n\r\n@wboykinm [reported](https://twitter.com/morganherlocker/status/718121546506575872) this on Twitter last week. He's been testing Mapzen vector tiles with Turf.js and found recurring examples of geometry errors for many metro areas. Superficially, he suspects feature simplification is causing some of this. \r\n\r\n**Here's an example:** \r\n\r\n* http://vector.mapzen.com/osm/water/13/1916/3387.json?api_key=vector-tiles-TE70otI. (The feature in question is id=362822667)\r\n\r\n**More about the app:**\r\n\r\n* https://github.com/wboykinm/tribes. \r\n\r\nBill is trying to erase US census geometry with the Mapzen water geom using turf.js, see https://github.com/wboykinm/tribes/blob/mapzen/processing/water/piranha.js. \r\n\r\nPostGIS has ST_Makevalid() but Turf.js doesn't have a similar function so simple errors like self-intersecting polygons and non-noded intersections throw big unrecoverable errors that result in data loss.\r\n\r\nLooks like Mapnik does some **OGC validation** in their tiles:\r\n\r\n* http://mapnik.org/node-mapnik/documentation/3.5/#VectorTile.reportGeometryValidity\r\n\r\nTo find more invalid examples, Bill built a tool that tosses out self-intersecting polygons: https://www.npmjs.com/package/turf-bathwater. it'll also log the features that get thrown out."},"comment":{"url":"https://api.github.com/repos/mapzen/vector-datasource/issues/comments/208587836","html_url":"https://github.com/mapzen/vector-datasource/issues/698#issuecomment-208587836","issue_url":"https://api.github.com/repos/mapzen/vector-datasource/issues/698","id":208587836,"user":{"login":"rmarianski","id":53770,"avatar_url":"https://avatars.githubusercontent.com/u/53770?v=3","gravatar_id":"","url":"https://api.github.com/users/rmarianski","html_url":"https://github.com/rmarianski","followers_url":"https://api.github.com/users/rmarianski/followers","following_url":"https://api.github.com/users/rmarianski/following{/other_user}","gists_url":"https://api.github.com/users/rmarianski/gists{/gist_id}","starred_url":"https://api.github.com/users/rmarianski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmarianski/subscriptions","organizations_url":"https://api.github.com/users/rmarianski/orgs","repos_url":"https://api.github.com/users/rmarianski/repos","events_url":"https://api.github.com/users/rmarianski/events{/privacy}","received_events_url":"https://api.github.com/users/rmarianski/received_events","type":"User","site_admin":false},"created_at":"2016-04-11T22:13:09Z","updated_at":"2016-04-11T22:13:09Z","body":"It turns out that this is due to precision loss when we write the json out. @zerebubuth: what do you think we should do here?\r\n"}}