Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/layers/src/geojson-layer/geojson-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function parseGeoJsonRawFeature(rawFeature: unknown): Feature | null {
// Support GeoJson feature as object
// probably need to normalize it as well
const normalized = normalize(rawFeature);
if (!normalized || !Array.isArray(normalized.features)) {
if (!normalized || !Array.isArray(normalized.features) || !normalized.features.length) {
// fail to normalize GeoJson
return null;
}
Expand Down Expand Up @@ -140,7 +140,7 @@ export function getGeojsonLayerMeta({
try {
// TODO: use line interpolate to get center of line for LineString
const cent = center(feature as AllGeoJSON);
meanCenters.push(cent.geometry.coordinates);
meanCenters.push(cent?.geometry?.coordinates ?? null);
} catch (e) {
meanCenters.push(null);
}
Expand Down Expand Up @@ -469,11 +469,15 @@ export function applyFiltersToTableColumns(
const filteredIndexSet = new Set(filteredIndex);
const filteredFeatures: GeojsonDataMaps = [];
for (const feature of dataToFeature) {
// @ts-expect-error geometry.coordinates not available for BinaryFeatureCollection
if (!feature || !feature.geometry || !feature.geometry.coordinates) {
continue;
}
// @ts-expect-error geometry.coordinates not available for GeometryCollection
const filteredCoords = feature.geometry.coordinates.filter(c =>
filteredIndexSet.has(c.datumIndex)
);
if (filteredCoords.length > 0 && feature) {
if (filteredCoords.length > 0) {
filteredFeatures.push({
...feature,
geometry: {
Expand Down