Skip to content

Commit

Permalink
- fixes winding of GeoJSON to follow right-hand rule (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnk1 committed Sep 10, 2020
1 parent 7df684f commit aa4c1aa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Expand Up @@ -36,11 +36,11 @@ function tileToGeoJSON(tile) {
var poly = {
type: 'Polygon',
coordinates: [[
[bbox[0], bbox[1]],
[bbox[0], bbox[3]],
[bbox[2], bbox[3]],
[bbox[0], bbox[1]],
[bbox[2], bbox[1]],
[bbox[0], bbox[1]]
[bbox[2], bbox[3]],
[bbox[0], bbox[3]]
]]
};
return poly;
Expand Down
7 changes: 7 additions & 0 deletions test.js
Expand Up @@ -9,6 +9,13 @@ test('tile to geojson', function (t) {
var geojson = tilebelt.tileToGeoJSON(tile1);
t.ok(geojson, 'get geojson representation of tile');
t.equal(geojson.type, 'Polygon');
t.deepEqual(geojson.coordinates, [[
[-178.2421875, 84.73838712095339],
[-178.2421875, 84.7060489350415],
[-177.890625, 84.7060489350415],
[-177.890625, 84.73838712095339],
[-178.2421875, 84.73838712095339]
]], 'Coordinates');
t.end();
});

Expand Down

0 comments on commit aa4c1aa

Please sign in to comment.