mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
fix: center named places on their own location
A place's bounds can reach far from the place itself; Tokyo's include remote Pacific islands, so the middle of its box is open ocean. Keep the geocoder's point for a named place and use it as the area's center, while bounds still decide what lies inside the area.
This commit is contained in:
1 parent
469b1e8d89
commit
0dbd6375fc
3 files changed
+38
-5
No files matched your search
+10
-2
@@ -13,7 +13,11 @@ import { ToolError } from './catalog.js';
|
||||
|
||||
const POINT_RADIUS_DEGREES = 0.25;
|
||||
|
||||
/** Resolve place names to `{ name, bounds: { west, south, east, north } }` or null. */
|
||||
/**
|
||||
* Resolve place names to `{ name, bounds: { west, south, east, north }, point }`
|
||||
* or null. `point` is the place's own location, which can lie far from the
|
||||
* middle of its bounds (a region with remote islands, for example).
|
||||
*/
|
||||
export function createGeocodePlaceService({
|
||||
fetchImpl = (...args) => globalThis.fetch(...args),
|
||||
} = {}) {
|
||||
@@ -54,7 +58,11 @@ export function placeFromGeocodeResult(result) {
|
||||
east: Math.min(180, location.lng + POINT_RADIUS_DEGREES),
|
||||
north: Math.min(90, location.lat + POINT_RADIUS_DEGREES),
|
||||
};
|
||||
return { name: result.formatted_address || null, bounds };
|
||||
return {
|
||||
name: result.formatted_address || null,
|
||||
bounds,
|
||||
point: { lat: location.lat, lon: location.lng },
|
||||
};
|
||||
}
|
||||
|
||||
/** Search points of interest; `configured` is false when the server has no search key. */
|
||||
|
||||
Reference in new issue
Block a user