Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
addPois(tile: Tile, decodedTile: DecodedTile): void {
const poiGeometries = assertExists(decodedTile.poiGeometries);
const worldOffsetX = tile.computeWorldOffsetX();
for (const poiGeometry of poiGeometries) {
assert(poiGeometry.technique !== undefined);
const techniqueIndex = assertExists(poiGeometry.technique);
const technique = decodedTile.techniques[techniqueIndex];
if (
technique.enabled === false ||
(!isLineMarkerTechnique(technique) && !isPoiTechnique(technique))
) {
continue;
}
// The POI may be in the data, and there may be a Technique, but the technique may
// specify to not show it.
if (technique.showOnMap === false) {
continue;
}
const positions = new THREE.BufferAttribute(
new Float32Array(poiGeometry.positions.buffer),
poiGeometry.positions.itemCount
);
if (isLineMarkerTechnique(technique) && positions.count > 0) {
// Set default kind based on technique.
if (geometryKind === undefined) {
if (isFillTechnique(technique)) {
geometryKind = GeometryKind.Area;
} else if (
isLineTechnique(technique) ||
isSolidLineTechnique(technique) ||
isSegmentsTechnique(technique) ||
isExtrudedLineTechnique(technique)
) {
geometryKind = GeometryKind.Line;
} else if (isExtrudedPolygonTechnique(technique)) {
geometryKind = GeometryKind.Building;
} else if (
isPoiTechnique(technique) ||
isLineMarkerTechnique(technique) ||
isTextTechnique(technique)
) {
geometryKind = GeometryKind.Label;
} else {
geometryKind = GeometryKind.All;
}
technique.kind = geometryKind;
}
return geometryKind;
}
}
) {
continue;
}
// The POI may be in the data, and there may be a Technique, but the technique may
// specify to not show it.
if (technique.showOnMap === false) {
continue;
}
const positions = new THREE.BufferAttribute(
new Float32Array(poiGeometry.positions.buffer),
poiGeometry.positions.itemCount
);
if (isLineMarkerTechnique(technique) && positions.count > 0) {
this.addLineMarker(tile, poiGeometry, technique, positions, worldOffsetX);
} else if (isPoiTechnique(technique)) {
this.addPoi(tile, poiGeometry, technique, positions, worldOffsetX);
}
}
}
this.applyLineTechnique(
lineGeometry,
technique,
techniqueIndex,
lineType,
env.entries,
localLines,
context,
this.getTextureCoordinateType(technique) ? uvs : undefined,
hasUntiledLines ? offsets : undefined
);
} else if (
isTextTechnique(technique) ||
isPoiTechnique(technique) ||
isLineMarkerTechnique(technique)
) {
const textTechnique = technique as TextTechnique;
const text = ExtendedTileInfo.getFeatureText(
context,
textTechnique,
this.m_languages
);
if (text === undefined || text.length === 0) {
continue;
}
let validLines: number[][] = [];
if (this.m_skipShortLabels) {
// Filter the lines, keep only those that are long enough for labelling. Also,
// split jagged label paths to keep processing and rendering only those that
const textFilter = (technique: Technique): boolean => {
if (
!isPoiTechnique(technique) &&
!isLineMarkerTechnique(technique) &&
!isTextTechnique(technique)
) {
return false;
}
return filter(technique);
};
const textFilter = (technique: Technique): boolean => {
if (
!isPoiTechnique(technique) &&
!isLineMarkerTechnique(technique) &&
!isTextTechnique(technique)
) {
return false;
}
return filter(technique);
};
this.createTextElements(tile, decodedTile, textFilter);