Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
HARP-13254: Add a test to reproduce the bug.
Browse files Browse the repository at this point in the history
This change adds an IBCT test case demonstrating the bug when
extruding polygons touching the tile bounds.

Signed-off-by: Roberto Raggi <roberto.raggi@here.com>
  • Loading branch information
robertoraggi committed Feb 2, 2021
1 parent beb6011 commit 4e82235
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 0 deletions.
57 changes: 57 additions & 0 deletions test/rendering/GeoJsonFeaturesRendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import { GeoPointLike } from "@here/harp-geoutils";
import * as turf from "@turf/turf";

import { GeoJsonStore } from "./utils/GeoJsonStore";
import { GeoJsonTest } from "./utils/GeoJsonTest";
import { ThemeBuilder } from "./utils/ThemeBuilder";

Expand Down Expand Up @@ -155,4 +156,60 @@ describe("GeoJson features", function () {
});
});
});

describe("extruded-polygon technique", async function () {
it("Polygon touching tile border", async function () {
const polygon: turf.Feature = {
type: "Feature",
properties: {},
geometry: {
type: "Polygon",
coordinates: [
[
[0.00671649362467299, 51.49353450058163, 0],
[0.006598810705050831, 51.48737650885326, 0],
[0.015169103358567556, 51.48731300784492, 0],
[0.015286786278189713, 51.49347100814989, 0],
[0.006716493624672999, 51.49353450058163, 0],
[0.00671649362467299, 51.49353450058163, 0]
]
]
}
};

const dataProvider = new GeoJsonStore();

dataProvider.features.insert(polygon);

const geoJson = turf.featureCollection([polygon]);

const [longitude, latitude] = turf.center(geoJson).geometry!.coordinates;

await geoJsonTest.run({
mochaTest: this,
dataProvider,
testImageName: `geojson-extruded-polygon-touching-tile-bounds`,
lookAt: {
target: [longitude, latitude],
zoomLevel: 15,
tilt: 55,
heading: 45
},
theme: {
lights,
styles: [
{
styleSet: "geojson",
technique: "extruded-polygon",
color: "#0335a2",
lineWidth: 1,
lineColor: "red",
constantHeight: true,
height: 300
}
]
}
});
});
});
});
50 changes: 50 additions & 0 deletions test/rendering/utils/GeoJsonStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (C) 2021 HERE Europe B.V.
* Licensed under Apache 2.0, see full license in LICENSE
* SPDX-License-Identifier: Apache-2.0
*/

import { TileKey, webMercatorTilingScheme } from "@here/harp-geoutils";
import { DataProvider } from "@here/harp-mapview-decoder";
import RBush from "geojson-rbush";

/**
* A simple {@link @here/harp-mapview-decoder/DataProvider} that organizes GeoJson features using an rtree.
*
* The `GeoJsonStore` can be used as a {@link @here/harp-mapview-decoder/DataProvider}
* of {@link @here/harp-vectortile-datasource/VectorTileDataSource}s.
*
* @example
* ```typescript
* const geoJsonStore = new GeoJsonStore();
*
* const dataSource = new VectorTileDataSource({
* dataProvider: geoJsonStore,
* // ...
* });
*
* geoJsonStore.features.insert(polygonFeature);
* geoJsonStore.features.insert(lineStringFeature);
* // ...
* ```
*/
export class GeoJsonStore extends DataProvider {
/**
* The set of GeoJson features organized by this this `GeoJsonStore`.
*/
readonly features = RBush();

ready(): boolean {
return true;
}

async getTile(tileKey: TileKey) {
const { west, south, east, north } = webMercatorTilingScheme.getGeoBox(tileKey);
const features = this.features.search([west, south, east, north]);
return features;
}

protected async connect(): Promise<void> {}

protected dispose(): void {}
}

0 comments on commit 4e82235

Please sign in to comment.