Skip to content

Commit

Permalink
fix(geo type): use raw geopoint for invalid or "null island" coordina…
Browse files Browse the repository at this point in the history
…tes (#396)
  • Loading branch information
yassinrais authored Sep 2, 2024
1 parent 4057dda commit b48f5c6
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/components/DataTable/datatypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,27 @@ function ObjectCell(props: { value: any }) {

function GeographyPointCell({ value }: { value: GeometryPoint; }) {
const [long, lat] = value.point;
const converted = convert(`${lat} ${long}`);

return <GeographyLink value={value} text={converted.toCoordinateFormat("DMS")} />;
try {
const converted = convert(`${lat} ${long}`);
return (
<GeographyLink
value={value}
text={converted.toCoordinateFormat("DMS")}
/>
);
} catch (err) {
console.error(err);
return (
<GeographyLink
value={value}
text={
lat == 0 && long == 0
? "0° N, 0° E (Null Island)"
: `(${lat}, ${long})`
}
/>
);
}
}

function GeographyLineStringCell({ value }: { value: GeometryLine; }) {
Expand Down

0 comments on commit b48f5c6

Please sign in to comment.