Skip to content

Commit

Permalink
Merge 70af0d6 into ade9ca3
Browse files Browse the repository at this point in the history
  • Loading branch information
supersonicclay committed Sep 24, 2020
2 parents ade9ca3 + 70af0d6 commit a7747f2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions modules/editor/src/lib/importer.ts
Expand Up @@ -53,9 +53,11 @@ function getCleanedFeatures(geojson: AnyGeoJson): Feature[] {
}

function getCleanedFeature(feature: Feature): Feature {
let geometry = feature.geometry;
const { id } = feature;
// reduce null-checking
const properties = feature.properties || {};

let geometry = feature.geometry;
// @ts-ignore
if (geometry.type === 'GeometryCollection' && geometry.geometries.length === 1) {
// There's only one geometry
Expand All @@ -69,14 +71,14 @@ function getCleanedFeature(feature: Feature): Feature {
// See if it can be combined into a Multi* geometry
const type = types.values().next().value;
if (type === 'Polygon') {
// Combine all the polygons into a single MultiPolygon
// Combine all the Polygons into a single MultiPolygon
geometry = {
type: 'MultiPolygon',
// @ts-ignore
coordinates: geometry.geometries.map((g) => g.coordinates),
};
} else if (type === 'LineString') {
// Combine all the polygons into a single MultiPolygon
// Combine all the LineStrings into a single MultiLineString
geometry = {
type: 'MultiLineString',
// @ts-ignore
Expand All @@ -88,9 +90,11 @@ function getCleanedFeature(feature: Feature): Feature {
throw Error('GeometryCollection geometry type not yet supported');
}
}

// @ts-ignore
return {
type: 'Feature',
id,
geometry,
properties,
};
Expand Down

0 comments on commit a7747f2

Please sign in to comment.