← All procedures

geo.locatePoint

This function gives the location of a point against a Polygon or a MultiPolygon: `inside`, `boundary` or `outside`. The rules are in the description of this module. A point on the boundary of one part and inside another part is `inside`. A closed polygon contains the point when the result is not `outside`.

CLI
Package
@procedures/geo · README
Path
["geo","locatePoint"]
CLI
mark geo locatePoint --point <object> --polygon <object | object>
As data
{"$proc":["geo","locatePoint"],"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","locatePoint"], { point: {}, polygon: "<polygon>" });
console.log(JSON.stringify(result));

From the command line

$ mark geo locatePoint --point <object> --polygon <object | object>

As data, in a program

{
  "$proc": ["geo", "locatePoint"],
  "input": { "point": {}, "polygon": "<polygon>" }
}

Input

FieldTypeRequiredDefaultDescription
pointobjectyes
polygonobject | objectyes

Output

The schema does not list fields ("boundary" | "inside" | "outside").

JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "point": {
        "type": "object",
        "properties": {
          "lat": {
            "type": "number",
            "description": "The latitude in degrees, from -90 to 90."
          },
          "lon": {
            "type": "number",
            "description": "The longitude in degrees. A normalized longitude is from -180 to less than 180."
          }
        },
        "required": [
          "lat",
          "lon"
        ],
        "additionalProperties": {}
      },
      "polygon": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "Polygon"
              },
              "coordinates": {
                "type": "array",
                "items": {
                  "type": "array",
                  "items": {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 2
                  }
                }
              },
              "bbox": {
                "anyOf": [
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 4,
                    "maxItems": 4
                  },
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 6,
                    "maxItems": 6
                  }
                ],
                "description": "The bounding box of the object (RFC 7946, section 5)."
              }
            },
            "required": [
              "type",
              "coordinates"
            ],
            "additionalProperties": {}
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "MultiPolygon"
              },
              "coordinates": {
                "type": "array",
                "items": {
                  "type": "array",
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "array",
                      "items": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "number"
                        }
                      ],
                      "additionalItems": {},
                      "minItems": 2
                    }
                  }
                }
              },
              "bbox": {
                "anyOf": [
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 4,
                    "maxItems": 4
                  },
                  {
                    "type": "array",
                    "items": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "additionalItems": {},
                    "minItems": 6,
                    "maxItems": 6
                  }
                ],
                "description": "The bounding box of the object (RFC 7946, section 5)."
              }
            },
            "required": [
              "type",
              "coordinates"
            ],
            "additionalProperties": {}
          }
        ]
      }
    },
    "required": [
      "point",
      "polygon"
    ],
    "additionalProperties": false
  },
  "output": {
    "type": "string",
    "enum": [
      "boundary",
      "inside",
      "outside"
    ]
  }
}