Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
lixun910 committed Sep 18, 2023
1 parent 8ed140b commit 491ea9b
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/layers/src/geojson-layer/geojson-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,7 @@ type FeatureTypeMap = {
export function parseGeoJsonRawFeature(
rawFeature: string | Feature | RawArrowFeature | number[][] | null
): Feature | null {
if (typeof rawFeature === 'object') {
if (rawFeature && 'encoding' in rawFeature && rawFeature.encoding) {
// Support GeoArrow data
return parseGeometryFromArrow(rawFeature);
}
// Support GeoJson feature as object
// probably need to normalize it as well
const normalized = normalize(rawFeature);
if (!normalized || !Array.isArray(normalized.features)) {
// fail to normalize GeoJson
return null;
}

return normalized.features[0];
} else if (typeof rawFeature === 'string') {
if (typeof rawFeature === 'string') {
return parseGeometryFromString(rawFeature);
} else if (Array.isArray(rawFeature)) {
// Support GeoJson LineString as an array of points
Expand All @@ -76,8 +62,20 @@ export function parseGeoJsonRawFeature(
},
properties: {}
};
} else if (typeof rawFeature === 'object') {
if (rawFeature && 'encoding' in rawFeature && rawFeature.encoding) {
// Support GeoArrow data
return parseGeometryFromArrow(rawFeature);
}
// Support GeoJson feature as object
// probably need to normalize it as well
const normalized = normalize(rawFeature);
if (!normalized || !Array.isArray(normalized.features)) {
// fail to normalize GeoJson
return null;
}
return normalized.features[0];
}

return null;
}
/**
Expand Down

0 comments on commit 491ea9b

Please sign in to comment.