Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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;
}
}
projection: Projection,
styleSetEvaluator: StyleSetEvaluator,
buffers: GeometryDataBuffers
): void {
// Skip features without geometries.
if (feature.geometry === null) {
return;
}
let techniqueIndices: number[] = [];
switch (feature.geometry.type) {
case "Point":
techniqueIndices = this.findTechniqueIndices(feature, "point", styleSetEvaluator);
for (const techniqueIndex of techniqueIndices) {
const technique = styleSetEvaluator.techniques[techniqueIndex];
if (isPoiTechnique(technique)) {
this.processPois(
[feature.geometry.coordinates],
center,
projection,
techniqueIndex,
buffers.poiGeometryBuffer,
feature.properties
);
} else if (isTextTechnique(technique)) {
this.processPointLabels(
[feature.geometry.coordinates],
center,
projection,
techniqueIndex,
technique.label!,
buffers.textGeometryBuffer,
const lineType = isLineTechnique(technique) ? LineType.Simple : LineType.Complex;
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,
}
const techniqueIndex = technique._index;
const meshBuffers = this.findOrCreateMeshBuffers(techniqueIndex, GeometryType.Point);
if (meshBuffers === undefined) {
continue;
}
const { positions, texts, imageTextures, objInfos } = meshBuffers;
const shouldCreateTextGeometries =
isTextTechnique(technique) || isPoiTechnique(technique);
let imageTexture: string | undefined;
const wantsPoi = isPoiTechnique(technique);
if (wantsPoi) {
const poiTechnique = technique as PoiTechnique;
imageTexture = evaluateTechniqueAttr(context, poiTechnique.imageTexture);
// TODO: Move to decoder independent parts of code.
if (poiTechnique.poiName !== undefined) {
imageTexture = evaluateTechniqueAttr(context, poiTechnique.poiName);
} else if (typeof poiTechnique.poiNameField === "string") {
const poiNameFieldValue = env.lookup(poiTechnique.poiNameField) as string;
imageTexture = poiNameFieldValue;
} else if (typeof poiTechnique.imageTextureField === "string") {
const imageTextureValue = env.lookup(poiTechnique.imageTextureField) as string;
imageTexture = composeTechniqueTextureName(imageTextureValue, poiTechnique);
}
}
[feature.geometry.coordinates],
center,
projection,
techniqueIndex,
buffers.geometryBuffer,
feature.properties
);
}
}
break;
case "MultiPoint":
techniqueIndices = this.findTechniqueIndices(feature, "point", styleSetEvaluator);
for (const techniqueIndex of techniqueIndices) {
const technique = styleSetEvaluator.techniques[techniqueIndex];
if (isPoiTechnique(technique)) {
this.processPois(
feature.geometry.coordinates,
center,
projection,
techniqueIndex,
buffers.poiGeometryBuffer,
feature.properties
);
} else if (isTextTechnique(technique)) {
this.processPointLabels(
feature.geometry.coordinates,
center,
projection,
techniqueIndex,
technique.label!,
buffers.textGeometryBuffer,
const textFilter = (technique: Technique): boolean => {
if (
!isPoiTechnique(technique) &&
!isLineMarkerTechnique(technique) &&
!isTextTechnique(technique)
) {
return false;
}
return filter(technique);
};
createTextElements(decodedTile: DecodedTile, zoomLevel: number) {
const tileGeometryCreator = TileGeometryCreator.instance;
const worldOffsetX = this.computeWorldOffsetX();
if (decodedTile.poiGeometries !== undefined) {
for (const geometry of decodedTile.poiGeometries) {
const techniqueIndex = geometry.technique!;
const technique = decodedTile.techniques[techniqueIndex];
if (isPoiTechnique(technique)) {
this.addPois(geometry, technique, zoomLevel, worldOffsetX);
}
}
}
if (decodedTile.textGeometries !== undefined) {
for (const geometry of decodedTile.textGeometries) {
const techniqueIndex = geometry.technique!;
const technique = decodedTile.techniques[techniqueIndex];
if (isTextTechnique(technique)) {
this.addTexts(geometry, technique, worldOffsetX);
}
}
}
if (decodedTile.textPathGeometries !== undefined) {
this.preparedTextPaths = tileGeometryCreator.prepareTextPaths(
const textFilter = (technique: Technique): boolean => {
if (
!isPoiTechnique(technique) &&
!isLineMarkerTechnique(technique) &&
!isTextTechnique(technique)
) {
return false;
}
return filter(technique);
};
this.createTextElements(tile, decodedTile, textFilter);