Point in polygon classify
point-in-polygon-classify · version 1.0.0 · Geometry, location & color · free, no key needed
Classifies a rational-coordinate point as inside, outside, or boundary using an exact half-open ray rule.
Use when you need to: classify point in polygon · test rational point against polygon · detect point on polygon boundary.
Decide before calling
Read the versioned contract and the supported scope below. Reuse point-in-polygon-classify@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use point-in-polygon-classify@1.0.0 for classify point in polygon. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
Supported
- classify point in polygon
- test rational point against polygon
- detect point on polygon boundary
- exact even odd polygon containment
- point inside outside or boundary
- half open ray casting classification
Not supported
- repair a self-intersecting polygon
- compute polygon area or distance
Behavior
- Coordinates are canonical reduced rational strings and all predicates use exact integer arithmetic.
- Boundary is checked first; otherwise a positive-x ray counts crossings with the lower endpoint included and upper endpoint excluded.
- Odd crossings are inside and even crossings are outside; the input polygon must be bounded and simple.
Input
point(object, required)polygon(array of object, required): min items 3; max items 256
Output
classification(one of "inside", "outside", "boundary", required)crossings(integer, required): min 0; max 256rule(constant "even-odd-positive-x-half-open", required)
Limits
- max input bytes: 32768
- max vertices: 256
- max coordinate chars: 38
- max integer digits: 18
- max pair checks: 32640
- max output bytes: 128
Example
Request input:
{
"point": {
"x": "1/2",
"y": "1/2"
},
"polygon": [
{
"x": "0",
"y": "0"
},
{
"x": "2",
"y": "0"
},
{
"x": "0",
"y": "2"
}
]
}
Response:
{
"result": {
"classification": "inside",
"crossings": 1,
"rule": "even-odd-positive-x-half-open"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "point-in-polygon-classify",
"version": "1.0.0",
"input": {
"point": {
"x": "1/2",
"y": "1/2"
},
"polygon": [
{
"x": "0",
"y": "0"
},
{
"x": "2",
"y": "0"
},
{
"x": "0",
"y": "2"
}
]
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/point-in-polygon-classify/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"point":{"x":"1/2","y":"1/2"},"polygon":[{"x":"0","y":"0"},{"x":"2","y":"0"},{"x":"0","y":"2"}]}'
The machine-readable contract is at /v1/tools/point-in-polygon-classify/versions/1.0.0.
CLI
node cli.mjs run point-in-polygon-classify 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Color contrast wcag: Compute WCAG 2.x relative luminance, contrast ratio, and AA/AAA pass flags for two opaque sRGB colors.