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

Commit

Permalink
MINOR: Make constantHeight technique property dynamic. (#2108)
Browse files Browse the repository at this point in the history
* MINOR: Make constantHeight technique property dynamic.

* MINOR: Add unit tests.
  • Loading branch information
atomicsulfate committed Feb 17, 2021
1 parent f070f1b commit cf0ea3f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion @here/harp-datasource-protocol/lib/TechniqueParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ export interface BaseTechniqueParams {
*
* @defaultValue `true` for geometries stored at level less than `12`.
*/
constantHeight?: boolean;
constantHeight?: DynamicProperty<boolean>;
}

export enum TextureCoordinateType {
Expand Down
16 changes: 11 additions & 5 deletions @here/harp-vectortile-datasource/test/OmvDecodedTileEmitterTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ describe("OmvDecodedTileEmitter", function () {
{ level: 12, constantHeight: undefined, expectScaledHeight: true },
{ level: 10, constantHeight: undefined, expectScaledHeight: false },
{ level: 12, constantHeight: true, expectScaledHeight: false },
{ level: 10, constantHeight: false, expectScaledHeight: true }
{ level: 10, constantHeight: false, expectScaledHeight: true },
{ level: 12, constantHeight: ["get", "constantHeight"], expectScaledHeight: false },
{ level: 10, constantHeight: ["get", "constantHeight"], expectScaledHeight: true }
]) {
const result = expectScaledHeight ? "scaled" : "not scaled";
const tileKey = TileKey.fromRowColumnLevel(0, 0, level);
Expand All @@ -130,7 +132,9 @@ describe("OmvDecodedTileEmitter", function () {
return new Float32Array([geoAltitude * scaleFactor])[0];
}

it(`Point Height at level ${level} with constantHeight ${constantHeight} is ${result}`, function () {
it(`Point Height at level ${level} with constantHeight ${
Array.isArray(constantHeight) ? "true object property" : constantHeight
} is ${result}`, function () {
const geoCoords = decodeInfo.geoBox.center.clone();
geoCoords.altitude = 100;
const tileLocalCoords = world2tile(
Expand All @@ -153,7 +157,7 @@ describe("OmvDecodedTileEmitter", function () {
]);

const mockContext = {
env: new MapEnv({ layer }),
env: new MapEnv({ layer, constantHeight: !expectScaledHeight }),
storageLevel: tileKey.level,
zoomLevel: tileKey.level
};
Expand Down Expand Up @@ -181,7 +185,9 @@ describe("OmvDecodedTileEmitter", function () {
);
});

it(`Extruded polygon height at level ${level} with constantHeight ${constantHeight} is ${result}`, function () {
it(`Extruded polygon height at level ${level} with constantHeight ${
Array.isArray(constantHeight) ? "true object property" : constantHeight
} is ${result}`, function () {
const polygons = tileGeoBoxToPolygonGeometry(decodeInfo);
const height = 100;
const { tileEmitter, styleSetEvaluator } = createTileEmitter(decodeInfo, [
Expand All @@ -197,7 +203,7 @@ describe("OmvDecodedTileEmitter", function () {
]);

const mockContext = {
env: new MapEnv({ layer }),
env: new MapEnv({ layer, constantHeight: !expectScaledHeight }),
storageLevel: level,
zoomLevel: level
};
Expand Down

0 comments on commit cf0ea3f

Please sign in to comment.