-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Multipoint support with useGeometry composable #189
- Loading branch information
Showing
2 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { MultiPoint } from 'geojson' | ||
import type { MapPoi } from '~/lib/mapPois' | ||
|
||
export default function () { | ||
const flattenMultipoint = (features: MapPoi[]): MapPoi[] => { | ||
const explodedPointFeatures: MapPoi[] = [] | ||
features.forEach((f: MapPoi) => { | ||
if (f.geometry.type === 'MultiPoint') { | ||
const { coordinates } = f.geometry as MultiPoint | ||
|
||
coordinates.forEach((coords: number[]) => { | ||
explodedPointFeatures.push({ | ||
...f, | ||
geometry: { | ||
type: 'Point', | ||
coordinates: coords, | ||
}, | ||
}) | ||
}) | ||
} | ||
|
||
return f | ||
}) | ||
|
||
features = features.filter(f => f.geometry.type !== 'MultiPoint') | ||
|
||
return [...features, ...explodedPointFeatures] | ||
} | ||
|
||
return { | ||
flattenMultipoint, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters