This repository has been archived by the owner on Mar 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HARP-11013: Support GeoJson feature ids (#2104)
* HARP-11013: Support string feature ids and deprecate number ids. * HARP-11013: Get GeoJSON feature id on decoding.
- Loading branch information
1 parent
5fc1232
commit d6dcb53
Showing
17 changed files
with
414 additions
and
82 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
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,78 @@ | ||
/* | ||
* Copyright (C) 2021 HERE Europe B.V. | ||
* Licensed under Apache 2.0, see full license in LICENSE | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { FeatureCollection } from "@here/harp-datasource-protocol"; | ||
import { TileKey } from "@here/harp-geoutils"; | ||
import { expect } from "chai"; | ||
|
||
import { GeoJsonTiler } from "../lib/GeoJsonTiler"; | ||
|
||
const featureCollection: FeatureCollection = { | ||
type: "FeatureCollection", | ||
features: [ | ||
{ | ||
type: "Feature", | ||
id: "point id", | ||
properties: {}, | ||
|
||
geometry: { | ||
type: "Point", | ||
coordinates: [1, 2] | ||
} | ||
}, | ||
{ | ||
type: "Feature", | ||
id: "line id", | ||
properties: {}, | ||
|
||
geometry: { | ||
type: "LineString", | ||
coordinates: [ | ||
[1, 2], | ||
[3, 4] | ||
] | ||
} | ||
}, | ||
{ | ||
type: "Feature", | ||
id: "polygon id", | ||
properties: {}, | ||
|
||
geometry: { | ||
type: "Polygon", | ||
coordinates: [ | ||
[ | ||
[1, 2], | ||
[3, 4], | ||
[5, 6] | ||
] | ||
] | ||
} | ||
} | ||
] | ||
}; | ||
|
||
describe("GeoJsonTiler", function () { | ||
let tiler: GeoJsonTiler; | ||
|
||
beforeEach(function () { | ||
tiler = new GeoJsonTiler(); | ||
}); | ||
|
||
it("returns features with their original geojson ids", async function () { | ||
const indexId = "dummy"; | ||
await tiler.registerIndex(indexId, featureCollection); | ||
|
||
const tile = (await tiler.getTile(indexId, new TileKey(0, 0, 1))) as any; | ||
|
||
expect(tile.features).has.lengthOf(3); | ||
const expectedFeatureIds = featureCollection.features.map(feature => feature.id); | ||
const actualFeatureIds: string[] = tile.features.map( | ||
(feature: { id: string }) => feature.id | ||
); | ||
expect(actualFeatureIds).has.members(expectedFeatureIds); | ||
}); | ||
}); |
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
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
Oops, something went wrong.