Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { Phase, PhasedTileGeometryLoader } from "./PhasedTileGeometryLoader";
import { TileGeometryManagerBase } from "./TileGeometryManager";
/**
* The default phases to load geometry.
*/
const DefaultPhases: Phase[] = [
[GeometryKind.Background, GeometryKind.Terrain, GeometryKind.Area, GeometryKind.Border],
[GeometryKind.Line],
[GeometryKind.Building],
[GeometryKind.Label],
[GeometryKind.All]
];
// FIXME: This should (always) be the first phase, no?
const DefaultBasicGeometryKinds: GeometryKindSet = new GeometryKindSet(DefaultPhases[0]);
/**
* Manages the loading of [[Tile]] geometry in phases.
*/
export class PhasedTileGeometryManager extends TileGeometryManagerBase {
private m_maxUpdatedTilePerFrame = 5;
private m_loadPhaseDefinitions: Phase[] = DefaultPhases;
private m_basicGeometryKinds: GeometryKindSet = DefaultBasicGeometryKinds;
/**
* Creates an instance of PhasedTileGeometryManager. Keeps the reference to the [[MapView]].
*
* @param {MapView} mapView
*/
constructor(mapView: MapView) {
super(mapView);
initDecodedTile(
decodedTile: DecodedTile,
enabledKinds?: GeometryKindSet | undefined,
disabledKinds?: GeometryKindSet | undefined
) {
for (const technique of decodedTile.techniques) {
// Already processed
if (technique.enabled !== undefined) {
continue;
}
// Turn technique.kind from the style, which may be a string or an array of strings,
// into a GeometryKindSet.
if (technique.kind !== undefined) {
if (Array.isArray(technique.kind)) {
technique.kind = new GeometryKindSet(technique.kind);
} else if (typeof technique.kind !== "string") {
logger.warn("Technique has unknown type of kind:", technique);
technique.kind = undefined;
}
}
// No info about kind, no way to filter it.
if (
technique.kind === undefined ||
(technique.kind instanceof Set && (technique.kind as GeometryKindSet).size === 0)
) {
technique.enabled = true;
continue;
}
technique.enabled =
export function prepareDecodedTile(decodedTile: DecodedTile): GeometryKindSet {
const foundSet: GeometryKindSet = new GeometryKindSet();
for (const technique of decodedTile.techniques) {
let geometryKind = technique.kind;
// Set default kind based on technique.
if (geometryKind === undefined) {
geometryKind = setDefaultGeometryKind(technique);
}
if (Array.isArray(geometryKind)) {
geometryKind = new GeometryKindSet(geometryKind);
}
if (geometryKind instanceof Set) {
for (const kind of geometryKind) {
foundSet.add(kind);
}
} else {
foundSet.add(geometryKind);
}
}
return foundSet;
}
export function prepareDecodedTile(decodedTile: DecodedTile): GeometryKindSet {
const foundSet: GeometryKindSet = new GeometryKindSet();
for (const technique of decodedTile.techniques) {
let geometryKind = technique.kind;
// Set default kind based on technique.
if (geometryKind === undefined) {
geometryKind = setDefaultGeometryKind(technique);
}
if (Array.isArray(geometryKind)) {
geometryKind = new GeometryKindSet(geometryKind);
}
if (geometryKind instanceof Set) {
for (const kind of geometryKind) {
foundSet.add(kind);
constructor(private description: OmvFeatureFilterDescription) {
if (this.description.kindsToProcess.length > 0) {
this.enabledKinds = new GeometryKindSet(
this.description.kindsToProcess as GeometryKind[]
);
}
if (this.description.kindsToIgnore.length > 0) {
this.disabledKinds = new GeometryKindSet(
this.description.kindsToIgnore as GeometryKind[]
);
}
}
constructor(private description: OmvFeatureFilterDescription) {
if (this.description.kindsToProcess.length > 0) {
this.enabledKinds = new GeometryKindSet(
this.description.kindsToProcess as GeometryKind[]
);
}
if (this.description.kindsToIgnore.length > 0) {
this.disabledKinds = new GeometryKindSet(
this.description.kindsToIgnore as GeometryKind[]
);
}
}