-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(geojson): strip duplicate adjacent polygon ring vertices
- Loading branch information
1 parent
67d6471
commit c71b8d0
Showing
4 changed files
with
78 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import type * as geojson from 'geojson' | ||
import { test, describe } from 'node:test' | ||
import { deepEqual } from 'node:assert/strict' | ||
import { RegionCoverer } from './RegionCoverer' | ||
import * as cellid from '../s2/cellid' | ||
|
||
describe('RegionCoverer', () => { | ||
test('polygon - incorrect winding + duplicate adjacent vertices', (t) => { | ||
const polygon: geojson.Polygon = { | ||
type: 'Polygon', | ||
coordinates: [ | ||
[ | ||
[-1.599437, 53.803895], | ||
[-1.598511, 53.803895], | ||
[-1.595764, 53.803895], | ||
[-1.593018, 53.803895], | ||
[-1.593018, 53.802273], | ||
[-1.590271, 53.802273], | ||
[-1.587524, 53.802273], | ||
[-1.585241, 53.802273], | ||
[-1.584778, 53.802273], | ||
[-1.582031, 53.802273], | ||
[-1.582031, 53.801097], | ||
[-1.582031, 53.800651], | ||
[-1.579285, 53.800651], | ||
[-1.576538, 53.800651], | ||
[-1.576538, 53.799029], | ||
[-1.576538, 53.797406], | ||
[-1.577464, 53.797406], | ||
[-1.577464, 53.797406], | ||
[-1.581105, 53.797406], | ||
[-1.581424, 53.795784], | ||
[-1.584778, 53.795784], | ||
[-1.584778, 53.794162], | ||
[-1.584778, 53.794144], | ||
[-1.587524, 53.792594], | ||
[-1.587524, 53.790917], | ||
[-1.587524, 53.790917], | ||
[-1.592091, 53.790917], | ||
[-1.592091, 53.790917], | ||
[-1.593018, 53.790917], | ||
[-1.593018, 53.792539], | ||
[-1.595764, 53.792539], | ||
[-1.596722, 53.794162], | ||
[-1.596722, 53.794162], | ||
[-1.595764, 53.795784], | ||
[-1.595764, 53.797406], | ||
[-1.595764, 53.799029], | ||
[-1.595764, 53.800651], | ||
[-1.598511, 53.800651], | ||
[-1.599205, 53.801827], | ||
[-1.599118, 53.802273], | ||
[-1.599437, 53.803895], | ||
[-1.599437, 53.803895] | ||
] | ||
] | ||
} | ||
|
||
const cov = new RegionCoverer() | ||
const union = cov.covering(polygon) | ||
deepEqual( | ||
[...union.map(cellid.toToken)], | ||
['48795eb9', '48795ec4', '48795ed04', '48795ed0c', '48795ed74', '48795edc', '48795ee7c', '48795ee84'] | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters