-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(gis): Move WKT parsing into gis module (#3117)
- Loading branch information
Showing
54 changed files
with
1,271 additions
and
113 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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -1,4 +1,26 @@ | ||
// loaders.gl | ||
// SPDX-License-Identifier: MIT | ||
// Copyright (c) vis.gl contributors | ||
|
||
// binary features | ||
import './binary-features/binary-to-geojson.spec'; | ||
import './binary-features/geojson-to-flat-geojson.spec'; | ||
import './binary-features/geojson-to-binary.spec'; | ||
import './binary-features/transform.spec'; | ||
|
||
// utils | ||
import './utils/hex-transcoder.spec'; | ||
|
||
// wkt parsers | ||
import './wkt/parse-wkb.spec'; | ||
import './wkt/encode-wkb.spec'; | ||
|
||
// import './wkt/parse-twkb.spec'; | ||
import './wkt/encode-twkb.spec'; | ||
|
||
import './wkt/parse-hex-wkb.spec'; | ||
|
||
import './wkt/parse-wkt.spec'; | ||
import './wkt/encode-wkt.spec'; | ||
|
||
import './wkt/parse-wkt-crs.spec'; |
File renamed without changes.
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,67 @@ | ||
// loaders.gl | ||
// SPDX-License-Identifier: MIT | ||
// Copyright (c) vis.gl contributors | ||
|
||
/** | ||
import test from 'tape-promise/tape'; | ||
import {fetchFile, encodeSync} from '@loaders.gl/core'; | ||
import {WKBWriter} from '@loaders.gl/wkt'; | ||
import {parseTestCases} from '@loaders.gl/gis/test/data/wkt/parse-test-cases'; | ||
const WKB_2D_TEST_CASES = '@loaders.gl/gis/test/data/wkb-testdata2d.json'; | ||
const WKB_2D_NAN_TEST_CASES = '@loaders.gl/gis/test/data/wkb-testdata2d-nan.json'; | ||
const WKB_Z_TEST_CASES = '@loaders.gl/gis/test/data/wkb-testdataZ.json'; | ||
const WKB_Z_NAN_TEST_CASES = '@loaders.gl/gis/test/data/wkb-testdataZ-nan.json'; | ||
test('encodeTWKB#2D', async (t) => { | ||
const response = await fetchFile(WKB_2D_TEST_CASES); | ||
const TEST_CASES = parseTestCases(await response.json()); | ||
for (const testCase of Object.values(TEST_CASES)) { | ||
const {geoJSON, wkb} = testCase; | ||
const encoded = encodeSync(geoJSON, WKBWriter, {wkb: {hasZ: false, hasM: false}}); | ||
t.deepEqual(encoded, wkb); | ||
} | ||
t.end(); | ||
}); | ||
test('encodeTWKB#2D NaN', async (t) => { | ||
const response = await fetchFile(WKB_2D_NAN_TEST_CASES); | ||
const TEST_CASES = parseTestCases(await response.json()); | ||
for (const testCase of Object.values(TEST_CASES)) { | ||
const {geoJSON, wkb} = testCase; | ||
const encoded = encodeSync(geoJSON, WKBWriter, {wkb: {hasZ: false, hasM: false}}); | ||
t.deepEqual(encoded, wkb); | ||
} | ||
t.end(); | ||
}); | ||
test('encodeTWKB#Z', async (t) => { | ||
const response = await fetchFile(WKB_Z_TEST_CASES); | ||
const TEST_CASES = parseTestCases(await response.json()); | ||
for (const testCase of Object.values(TEST_CASES)) { | ||
const {geoJSON, wkb} = testCase; | ||
const encoded = encodeSync(geoJSON, WKBWriter, {wkb: {hasZ: true, hasM: false}}); | ||
t.deepEqual(encoded, wkb); | ||
} | ||
t.end(); | ||
}); | ||
test('encodeTWKB#Z NaN', async (t) => { | ||
const response = await fetchFile(WKB_Z_NAN_TEST_CASES); | ||
const TEST_CASES = parseTestCases(await response.json()); | ||
for (const testCase of Object.values(TEST_CASES)) { | ||
const {geoJSON, wkb} = testCase; | ||
const encoded = encodeSync(geoJSON, WKBWriter, {wkb: {hasZ: true, hasM: false}}); | ||
t.deepEqual(encoded, wkb); | ||
} | ||
t.end(); | ||
}); | ||
*/ |
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,65 @@ | ||
// loaders.gl | ||
// SPDX-License-Identifier: MIT | ||
// Copyright (c) vis.gl contributors | ||
|
||
import test from 'tape-promise/tape'; | ||
import {fetchFile, encodeSync} from '@loaders.gl/core'; | ||
import {WKBWriter} from '@loaders.gl/wkt'; | ||
import {parseTestCases} from '@loaders.gl/gis/test/data/wkt/parse-test-cases'; | ||
|
||
const WKB_2D_TEST_CASES = '@loaders.gl/gis/test/data/wkt/wkb-testdata2d.json'; | ||
const WKB_2D_NAN_TEST_CASES = '@loaders.gl/gis/test/data/wkt/wkb-testdata2d-nan.json'; | ||
const WKB_Z_TEST_CASES = '@loaders.gl/gis/test/data/wkt/wkb-testdataZ.json'; | ||
const WKB_Z_NAN_TEST_CASES = '@loaders.gl/gis/test/data/wkt/wkb-testdataZ-nan.json'; | ||
|
||
test('encodeWKB#2D', async (t) => { | ||
const response = await fetchFile(WKB_2D_TEST_CASES); | ||
const TEST_CASES = parseTestCases(await response.json()); | ||
|
||
for (const testCase of Object.values(TEST_CASES)) { | ||
const {geoJSON, wkb} = testCase; | ||
const encoded = encodeSync(geoJSON, WKBWriter, {wkb: {hasZ: false, hasM: false}}); | ||
t.deepEqual(encoded, wkb); | ||
} | ||
|
||
t.end(); | ||
}); | ||
|
||
test('encodeWKB#2D NaN', async (t) => { | ||
const response = await fetchFile(WKB_2D_NAN_TEST_CASES); | ||
const TEST_CASES = parseTestCases(await response.json()); | ||
|
||
for (const testCase of Object.values(TEST_CASES)) { | ||
const {geoJSON, wkb} = testCase; | ||
const encoded = encodeSync(geoJSON, WKBWriter, {wkb: {hasZ: false, hasM: false}}); | ||
t.deepEqual(encoded, wkb); | ||
} | ||
|
||
t.end(); | ||
}); | ||
|
||
test('encodeWKB#Z', async (t) => { | ||
const response = await fetchFile(WKB_Z_TEST_CASES); | ||
const TEST_CASES = parseTestCases(await response.json()); | ||
|
||
for (const testCase of Object.values(TEST_CASES)) { | ||
const {geoJSON, wkb} = testCase; | ||
const encoded = encodeSync(geoJSON, WKBWriter, {wkb: {hasZ: true, hasM: false}}); | ||
t.deepEqual(encoded, wkb); | ||
} | ||
|
||
t.end(); | ||
}); | ||
|
||
test('encodeWKB#Z NaN', async (t) => { | ||
const response = await fetchFile(WKB_Z_NAN_TEST_CASES); | ||
const TEST_CASES = parseTestCases(await response.json()); | ||
|
||
for (const testCase of Object.values(TEST_CASES)) { | ||
const {geoJSON, wkb} = testCase; | ||
const encoded = encodeSync(geoJSON, WKBWriter, {wkb: {hasZ: true, hasM: false}}); | ||
t.deepEqual(encoded, wkb); | ||
} | ||
|
||
t.end(); | ||
}); |
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,49 @@ | ||
// loaders.gl | ||
// SPDX-License-Identifier: MIT | ||
// Copyright (c) vis.gl contributors | ||
|
||
import test from 'tape-promise/tape'; | ||
|
||
import {encodeTextSync} from '@loaders.gl/core'; | ||
import {WKTWriter} from '@loaders.gl/wkt'; | ||
|
||
test('encodeWKT', (t) => { | ||
t.throws( | ||
() => encodeTextSync({type: 'FeatureCollection'}, WKTWriter), | ||
'does not accept featurecollections' | ||
); | ||
|
||
// const fixtures = [ | ||
// 'LINESTRING (30 10, 10 30, 40 40)', | ||
// 'POINT (1 1)', | ||
// 'POINT (1 1 1 1)', | ||
// 'LINESTRING (1 2 3, 4 5 6)', | ||
// 'LINESTRING (1 2 3 4, 5 6 7 8)', | ||
// 'POLYGON ((30 10, 10 20, 20 40, 40 40, 30 10))', | ||
// 'POLYGON ((35 10, 10 20, 15 40, 45 45, 35 10), (20 30, 35 35, 30 20, 20 30))', | ||
// 'MULTIPOINT (1 1, 2 3)', | ||
// 'MULTIPOLYGON (((30 20, 10 40, 45 40, 30 20)), ((15 5, 40 10, 10 20, 5 10, 15 5), (10 10, 15 10, 15 15, 10 10)))', | ||
// 'MULTILINESTRING ((30 10, 10 30, 40 40), (30 10, 10 30, 40 40))', | ||
// 'GEOMETRYCOLLECTION (POINT (4 6), LINESTRING (4 6, 7 10))' | ||
// ]; | ||
|
||
// fixtures.forEach((fix) => t.equal(fix, encodeSync(parse(fix, WKTLoader), WKTWriter), fix)); | ||
|
||
t.equal( | ||
encodeTextSync( | ||
{ | ||
type: 'Feature', | ||
properties: {}, | ||
geometry: { | ||
type: 'Point', | ||
coordinates: [42, 20] | ||
} | ||
}, | ||
WKTWriter | ||
), | ||
'POINT (42 20)', | ||
'point equal' | ||
); | ||
|
||
t.end(); | ||
}); |
Oops, something went wrong.