Skip to main content

Geo Utils API Reference

The Geo Utils provide location detection, geographic calculations, and location-based routing.

LocationDetector

Automatic user location detection.

Constructor

Parameters:
  • options (object): Location detection options

Methods

detect(request)

Detect location from request.
Parameters:
  • request (Request): HTTP request
Returns: Promise resolving to location object

detectByIP(ip)

Detect location from IP address.
Parameters:
  • ip (string): IP address
Returns: Promise resolving to location object

enhance(location)

Enhance location data.
Parameters:
  • location (object): Location object
Returns: Promise resolving to enhanced location

DistanceCalculator

Geographic distance calculations.

Constructor

Parameters:
  • options (object): Distance calculation options

Methods

haversine(point1, point2)

Calculate haversine distance.
Parameters:
  • point1 (object): First point
  • point2 (object): Second point
Returns: Distance in kilometers

batchCalculate(origin, points)

Calculate distances to multiple points.
Parameters:
  • origin (object): Origin point
  • points (array): Array of points
Returns: Array of distances

NearestEndpointRouter

Route to nearest endpoints.

Constructor

Parameters:
  • endpointManager (EndpointManager): Endpoint manager
  • options (object): Router options

Methods

findNearest(coordinates)

Find nearest endpoint.
Parameters:
  • coordinates (object): Geographic coordinates
Returns: Promise resolving to nearest endpoint

findNearestHealthy(coordinates)

Find nearest healthy endpoint.
Parameters:
  • coordinates (object): Geographic coordinates
Returns: Promise resolving to nearest healthy endpoint

Geocoder

Address geocoding and reverse geocoding.

Constructor

Parameters:
  • options (object): Geocoding options

Methods

geocode(address)

Convert address to coordinates.
Parameters:
  • address (string): Address string
Returns: Promise resolving to location object

reverseGeocode(coordinates)

Convert coordinates to address.
Parameters:
  • coordinates (object): Geographic coordinates
Returns: Promise resolving to address object

Type Definitions

Location

Endpoint

GeocodeResult