← All procedures

geo.geocode

Find the coordinates of an address or a place name (OpenStreetMap Nominatim)

CLI
Package
@procedures/geo · README
Path
["geo","geocode"]
CLI
mark geo geocode --query <string> --userAgent <string>
As data
{"$proc":["geo","geocode"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/geo/register"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["geo","geocode"], { query: "<query>", userAgent: "<userAgent>" });
console.log(JSON.stringify(result));

From the command line

$ mark geo geocode --query <string> --userAgent <string>

As data, in a program

{
  "$proc": ["geo", "geocode"],
  "input": { "query": "<query>", "userAgent": "<userAgent>" }
}

Input

FieldTypeRequiredDefaultDescription
querystringyesAn address or a place name
userAgentstringyesThe User-Agent that names your application. The Nominatim policy requires it, and it limits each application by it.
countryCodesstringnoFind only in these countries (ISO 3166-1 codes, for example us,ca)
baseUrlstringnoAnother Nominatim server (default: the public server)
timeoutMsintegerno20000The time limit, in milliseconds (default: 20000)

Output

FieldTypeRequiredDefaultDescription
foundbooleanyes
resultobjectno
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "query": {
        "type": "string",
        "minLength": 1,
        "description": "An address or a place name"
      },
      "userAgent": {
        "type": "string",
        "minLength": 3,
        "description": "The User-Agent that names your application. The Nominatim policy requires it, and it limits each application by it."
      },
      "countryCodes": {
        "description": "Find only in these countries (ISO 3166-1 codes, for example us,ca)",
        "type": "string",
        "pattern": "^[a-z]{2}(,[a-z]{2})*$"
      },
      "baseUrl": {
        "description": "Another Nominatim server (default: the public server)",
        "type": "string",
        "format": "uri"
      },
      "timeoutMs": {
        "default": 20000,
        "description": "The time limit, in milliseconds (default: 20000)",
        "type": "integer",
        "exclusiveMinimum": 0,
        "maximum": 120000
      }
    },
    "required": [
      "query",
      "userAgent"
    ]
  },
  "output": {
    "type": "object",
    "properties": {
      "found": {
        "type": "boolean"
      },
      "result": {
        "type": "object",
        "properties": {
          "lat": {
            "type": "number"
          },
          "lon": {
            "type": "number"
          },
          "displayName": {
            "type": "string"
          }
        },
        "required": [
          "lat",
          "lon",
          "displayName"
        ],
        "additionalProperties": false
      }
    },
    "required": [
      "found"
    ],
    "additionalProperties": false
  }
}