web / lib/services/geocoding/types
lib/services/geocoding/types
Defines the core TypeScript types, interfaces, and constants for the geocoding service.
This file serves as a central repository for the data structures and contracts used throughout the geocoding system. It ensures type safety and consistency across different modules, including the main service, provider manager, cache manager, and operations.
It defines:
- The structure of a geocoding result.
- The shape of batch geocoding results.
- A custom
GeocodingErrorclass for standardized error handling. - Configuration interfaces for providers and the overall service settings.
- Shared constants like collection slugs and default URLs.
Classes
GeocodingError
Extends
Error
Constructors
Constructor
new GeocodingError(
message,code,retryable):GeocodingError
Parameters
message
string
code
string
retryable
boolean = false
Returns
Overrides
Error.constructor
Properties
prepareStackTrace()?
staticoptionalprepareStackTrace: (err,stackTraces) =>any
Optional override for formatting stack traces
Parameters
err
Error
stackTraces
CallSite[]
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Error.prepareStackTrace
stackTraceLimit
staticstackTraceLimit:number
Inherited from
Error.stackTraceLimit
cause?
optionalcause:unknown
Inherited from
Error.cause
name
name:
string
Inherited from
Error.name
message
message:
string
Inherited from
Error.message
stack?
optionalstack:string
Inherited from
Error.stack
code
code:
string
retryable
retryable:
boolean=false
Methods
captureStackTrace()
staticcaptureStackTrace(targetObject,constructorOpt?):void
Create .stack property on a target object
Parameters
targetObject
object
constructorOpt?
Function
Returns
void
Inherited from
Error.captureStackTrace
Interfaces
GeocodingResult
Extends
Pick<LocationCache,"latitude"|"longitude"|"confidence"|"provider"|"normalizedAddress">
Properties
components
components:
undefined| {streetNumber?:null|string;streetName?:null|string;city?:null|string;region?:null|string;postalCode?:null|string;country?:null|string; }
Type declaration
undefined
{ streetNumber?: null | string; streetName?: null | string; city?: null | string; region?: null | string; postalCode?: null | string; country?: null | string; }
streetNumber?
optionalstreetNumber:null|string
Street number
streetName?
optionalstreetName:null|string
Street name
city?
optionalcity:null|string
City name
region?
optionalregion:null|string
State/Region/Province
postalCode?
optionalpostalCode:null|string
Postal/ZIP code
country?
optionalcountry:null|string
Country name
metadata
metadata:
undefined|null|string|number|boolean|unknown[] | {[k:string]:unknown; }
fromCache?
optionalfromCache:boolean
normalizedAddress
normalizedAddress:
string
Normalized address for better matching
Inherited from
Pick.normalizedAddress
latitude
latitude:
number
Latitude coordinate (WGS84)
Inherited from
Pick.latitude
longitude
longitude:
number
Longitude coordinate (WGS84)
Inherited from
Pick.longitude
provider
provider:
string
Name of the geocoding provider used
Inherited from
Pick.provider
confidence?
optionalconfidence:null|number
Confidence score (0-1)
Inherited from
Pick.confidence
BatchGeocodingResult
Properties
results
results:
Map<string,GeocodingResult|GeocodingError>
summary
summary:
object
total
total:
number
successful
successful:
number
failed
failed:
number
cached
cached:
number
ProviderConfig
Properties
name
name:
string
geocoder
geocoder:
Geocoder
priority
priority:
number
enabled
enabled:
boolean
GeocodingSettings
Properties
enabled
enabled:
boolean
fallbackEnabled
fallbackEnabled:
boolean
providerSelection
providerSelection:
object
strategy
strategy:
string
requiredTags
requiredTags:
string[]
caching
caching:
object
enabled
enabled:
boolean
ttlDays
ttlDays:
number
Variables
LOCATION_CACHE_COLLECTION
constLOCATION_CACHE_COLLECTION:"location-cache"="location-cache"
NOMINATIM_BASE_URL
constNOMINATIM_BASE_URL:"https://nominatim.openstreetmap.org"="https://nominatim.openstreetmap.org"
TIMETILES_USER_AGENT
constTIMETILES_USER_AGENT:"TimeTiles-Test/1.0"="TimeTiles-Test/1.0"