@cercalia/sdk
    Preparing search index...

    Class IsochroneService

    IsochroneService - Calculates service areas (isochrones) using Cercalia API

    An isochrone is a polygon representing the area reachable from a center point within a given time or distance constraint.

    Cercalia API documentation: cmd=isochrone

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    Configuration for the Cercalia API connection.

    Methods

    • Calculate a single isochrone (service area) from a center point

      Parameters

      • center: Coordinate

        Center coordinate for the isochrone (WGS84)

      • options: IsochroneOptions

        Isochrone calculation options (value, weight, method)

      Returns Promise<IsochroneResult>

      IsochroneResult with WKT polygon geometry

      const service = new IsochroneService(config);

      // 10-minute driving time isochrone
      const result = await service.calculate(
      { lat: 41.9723144, lng: 2.8260807 },
      { value: 10, weight: 'time' }
      );

      // 1000-meter distance isochrone
      const result2 = await service.calculate(
      { lat: 41.9723144, lng: 2.8260807 },
      { value: 1000, weight: 'distance' }
      );
    • Calculate multiple isochrones (concentric service areas)

      This method allows you to calculate multiple isochrone levels in a single API request. For example, 5, 10, and 15-minute travel time isochrones.

      Parameters

      • center: Coordinate

        Center coordinate (WGS84)

      • values: number[]

        Array of values (e.g., [5, 10, 15] for 5, 10, 15 minutes)

      • Optionaloptions: Omit<IsochroneOptions, "value">

        Base options (weight, method) - value is taken from the values array

      Returns Promise<IsochroneResult[]>

      Array of IsochroneResult, one for each value

      const service = new IsochroneService(config);

      // Multiple time-based isochrones
      const results = await service.calculateMultiple(
      { lat: 41.9723144, lng: 2.8260807 },
      [5, 10, 15],
      { weight: 'time' }
      );

      // Multiple distance-based isochrones
      const results2 = await service.calculateMultiple(
      { lat: 41.9723144, lng: 2.8260807 },
      [500, 1000, 2000],
      { weight: 'distance', method: 'convexhull' }
      );
    • Executes a generic request to the Cercalia API.

      Type Parameters

      • T

      Parameters

      • params: Record<string, string>

        Query parameters for the API request.

      • operationName: string = 'Cercalia Request'

        Human-readable name for logging and debugging.

      • OptionalbaseUrl: string

        Optional override for the base API URL.

      Returns Promise<T>

      A promise resolving to the parsed API response.

      Error with code '30006' when no results are found.

      Error for HTTP errors or invalid JSON responses.

      const response = await this.request<MyResponse>(
      { cmd: 'cand', adr: 'Gran Via 1' },
      'Geocoding'
      );