Skip to content

Commit

Permalink
Update geojson-utils.ts
Browse files Browse the repository at this point in the history
Make it fit `GeometryCollection`, previously all the `GeometryCollection` will be dropped.

Here is a valid geojson exmaple:
```json
{
  "type": "Feature",
  "geometry": {
    "type": "GeometryCollection",
    "geometries": [
      {
        "type": "MultiPoint",
        "coordinates": [
          [-100, 30],
          [-100, 33]
        ]
      }
    ]
  }
}
```

Signed-off-by: Yalei Du <yaleidu93@gmail.com>
  • Loading branch information
badbye committed Dec 20, 2022
1 parent 3de7799 commit 1c53c95
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/layers/src/geojson-layer/geojson-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ export function getGeojsonBounds(features: GeojsonDataMaps = []): BBox | null {
const maxCount = 10000;
const samples = features.length > maxCount ? getSampleData(features, maxCount) : features;

const validSingleGeometry = geom => geom.coordinates && geom.coordinates.length;
const validGeometryCollection = geom => geom.geometries && geom.geometries.length && geom.geometries.every(validSingleGeometry);
const nonEmpty = samples.filter(
d => d && d.geometry && d.geometry.coordinates && d.geometry.coordinates.length
d => d && d.geometry && (validSingleGeometry(d.geometry) || validGeometryCollection(d.geometry))
);

try {
Expand Down

0 comments on commit 1c53c95

Please sign in to comment.