Skip to content

Commit

Permalink
fix(Parser): detect if original source have elevation data with multi…
Browse files Browse the repository at this point in the history
…-features.
  • Loading branch information
gchoqueux committed Mar 27, 2023
1 parent b5123f5 commit 9d509da
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Parser/GeoJsonParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,15 @@ function toFeatureType(jsonType) {

const keyProperties = ['type', 'geometry', 'properties'];

const firstCoordinates = a => (Array.isArray(a) && !isNaN(a[0]) ? a : firstCoordinates(a[0]));

function jsonFeatureToFeature(crsIn, json, collection) {
const jsonType = json.geometry.type.toLowerCase();
const featureType = toFeatureType(jsonType);
const feature = collection.requestFeatureByType(featureType);
const coordinates = jsonType != 'point' ? json.geometry.coordinates : [json.geometry.coordinates];
const properties = json.properties || {};
feature.hasRawElevationData = coordinates[0]?.length === 3;
feature.hasRawElevationData = firstCoordinates(coordinates)?.length === 3;

// copy other properties
for (const key of Object.keys(json)) {
Expand Down

0 comments on commit 9d509da

Please sign in to comment.