Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private processLineFeatures(
data: ArrayBufferLike | {},
tileKey: TileKey,
styleSetEvaluator: StyleSetEvaluator,
projection: Projection,
geometries: Geometry[]
) {
// Setup an environment for this "layer". This does normaly come from the data and should
// contain all the attributes of a specific feature, so that it can be styled properly.
const env = new MapEnv({ layer: "line-layer" });
const techniques = styleSetEvaluator.getMatchingTechniques(env);
const geoCenter = webMercatorTilingScheme.getGeoBox(tileKey).center;
const worldCenter = projection.projectPoint(geoCenter, new Vector3());
// Convert the input coordinates to local world coord coordinates (i.e. projected world
// coordinates relative to the tile center in world coordinates)
const worldPoints = this.convertToLocalWorldCoordinates(
data,
geoCenter,
projection,
worldCenter
);
// Create actual line-geometry out of the data.
private processMeshFeatures(
tileKey: TileKey,
styleSetEvaluator: StyleSetEvaluator,
geometries: Geometry[]
) {
const env = new MapEnv({ layer: "mesh-layer" });
const techniques = styleSetEvaluator.getMatchingTechniques(env);
// Scale the mesh so that its size is relative to the tile size.
// tslint:disable-next-line: no-bitwise
const scale = (1 << 20) / (1 << tileKey.level);
const boxGeometry = new BoxBufferGeometry(1.0 * scale, 5.0 * scale, 5.0 * scale);
const matrix = new Matrix4();
matrix.makeTranslation(2.0 * scale, 1.0 * scale, 0);
boxGeometry.applyMatrix(matrix);
for (const technique of techniques) {
const geometry = ThreeBufferUtils.fromThreeBufferGeometry(
boxGeometry,
technique._index
);
geometries.push(geometry);
$level: storageLevel,
$zoom: Math.max(0, storageLevel - (storageLevelOffset || 0)),
$geometryType: geometryType
};
// Some sources serve `id` directly as `IFeature` property ...
if (feature.id !== undefined) {
const featureId = decodeFeatureId(feature, logger);
if (featureId !== undefined) {
attributes.$id = featureId;
}
}
readAttributes(layer, feature, attributes);
return new MapEnv(attributes, parent);
}
private static findTechniqueIndices(
feature: Feature,
envType: Value,
styleSetEvaluator: StyleSetEvaluator
): number[] {
const featureDetails: FeatureDetails = Flattener.flatten(feature.properties, "properties");
featureDetails.featureId = feature.id;
const env = new MapEnv({ type: envType, ...(featureDetails as ValueMap) });
const techniques = styleSetEvaluator.getMatchingTechniques(env);
return techniques.map(technique => {
return technique._index;
});
}
createMaterial(kind: string, styleSetEvaluator: StyleSetEvaluator): THREE.Material | undefined {
const env = new MapEnv({
$geometryType: "polygon",
$layer: "earth",
kind
});
const techniques = styleSetEvaluator.getMatchingTechniques(env);
return techniques.length !== 0
? createMaterial({ technique: techniques[0], level: 1 })
: undefined;
}
process(tile: VTJsonTileInterface, tileKey: TileKey, geoBox: GeoBox) {
for (const feature of tile.features) {
const env = new MapEnv({
$layer: tile.layer,
$geometryType: this.convertGeometryType(feature.type),
$level: tileKey.level,
$zoom: Math.max(0, tileKey.level - (this.m_processor.storageLevelOffset || 0)),
$id: feature.id,
...feature.tags
});
switch (feature.type) {
case VTJsonGeometryType.Point: {
for (const pointGeometry of feature.geometry) {
const x = (pointGeometry as VTJsonPosition)[0];
const y = (pointGeometry as VTJsonPosition)[1];
const position = new Vector2(x, y);