@cobuildlab/american-arbor-shared
v4.2.1
Published
Downloads
31
Keywords
Readme
test
Documentation for the provided code:
Types:
GeoJsonPoint:
- Represents a GeoJSON point.
- Extends the GeoJsonGeometryInterface and GeoJsonInterface interfaces.
- Properties:
- __typename?: 'GeoJSONPoint' (optional)
- bbox?: Maybe<Array<Maybe<Scalars['Float']>>> (optional, bounding box)
- coordinates?: Maybe<Scalars['GeoJSONCoordinates']> (optional, coordinates)
- type: GeoJsonType (geometry type, always 'Point' for this type)
GetLocationFromGeoJSONPointReturnType:
- Return type of the getLocationFromGeoJSONPoint function.
- Properties:
- latitude: number (latitude)
- longitude: number (longitude)
Functions:
- getLocationFromGeoJSONPoint(data):
- Extracts the latitude and longitude from a GeoJSON point.
- Parameters:
- data: A partial GeoJsonPoint object or null/undefined.
- Returns:
- A GetLocationFromGeoJSONPointReturnType object with latitude and longitude if the data is valid, otherwise undefined.
Example usage:
const geojsonPoint = {
type: "Point",
coordinates: [-74.0060, 40.7128],
};
const location = getLocationFromGeoJSONPoint(geojsonPoint);
if (location) {
console.log(f"Latitude: {location.latitude}, Longitude: {location.longitude}");
} else {
console.log("Invalid GeoJSON point.");
}