ForHosting KIT · Travel & geography

Circular geofence check

A point 6283.257836 m from the centre of a 10000 m geofence is inside, with 3716.742164 m to spare. Enter the point, the centre and the radius to get the haversine distance and a signed margin that turns negative outside. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Point lat
40.73061
Point lon
-73.935242
Center lat
40.7128
Center lon
-74.006
Radius m
10,000
You get
Distance m
6,283.257836
Margin m
3,716.742164

This circular geofence checker determines whether a latitude and longitude point falls inside, exactly on, or outside a radius around a center coordinate. It calculates the great-circle distance with the haversine formula, compares that distance with the radius in meters, and returns a signed margin that shows how much room remains. A positive margin means the point is inside, zero marks the boundary, and a negative margin reports how far outside the point lies. The calculation is deterministic and needs no map service, device lookup, or network request.

Define the point, center, and radius clearly

A circular geofence has three essential parts: a center latitude, a center longitude, and a non-negative radius measured in meters. The separate point latitude and point longitude identify the location you want to test. Supply every coordinate in decimal degrees using the familiar WGS84 geographic ranges: latitude from minus ninety to ninety and longitude from minus one hundred eighty to one hundred eighty.

Do not send projected map coordinates, degree-minute-second strings, or a radius in kilometers without converting it first. The checker accepts zero as a useful radius; in that case only a point at precisely the same coordinates as the center is inside. It rejects missing values, non-finite numbers, coordinates outside their legal ranges, and negative radii instead of silently correcting a likely integration error.

Longitudes on opposite sides of the antimeridian work without special client logic because the trigonometric distance formula naturally uses the shortest spherical separation.

Use the result safely in real geofence workflows

Circular checks are a practical fit for arrival detection, delivery eligibility, nearby equipment alerts, and coarse access zones. They are not legal property boundaries and they do not account for roads, walls, elevation, building floors, or GPS uncertainty. A phone location can wander by several meters or more, so production applications commonly require repeated readings, an accuracy limit, or hysteresis before triggering an irreversible action.

The spherical haversine model is consistent and fast across the globe, including near the poles and antimeridian, but it is an approximation rather than an ellipsoidal survey calculation. Run the same inputs again and the output is identical because the solver uses no network, current time, random number, or external map database. Store the original coordinates alongside the result if later audits must explain which reading produced a decision.

Delivery eligibility

Check whether a customer coordinate falls within a store's circular service radius and use the margin to explain how close it is to the limit.

Arrival and departure logic

Evaluate device readings against a site geofence and apply a positive or negative margin threshold to reduce boundary jitter.

Asset proximity alerts

Determine whether a reported asset location has entered a monitoring zone without calling an external maps provider.

Does a boundary point count as inside?

Yes. Membership uses distance less than or equal to radius, so an exact boundary point returns inside true and a zero margin.

Which units are used?

The radius, computed distance, and margin are all in meters. Latitude and longitude are decimal degrees.

Which distance formula is used?

The solver uses the haversine great-circle formula on a mean-Earth sphere with a radius of 6,371,000 meters.

What does the margin tell me?

It is the radius minus the distance. A positive margin such as 240 means the point is inside with about 240 m to spare, zero means it sits on the edge, and minus 85 means it is about 85 m outside.

Can the radius be zero?

Yes. With a radius of zero, only a point at exactly the same coordinates as the centre counts as inside; any other point is outside by its full distance.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/geo/geofence-circle-check

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/geo/geofence-circle-check \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"point_lat":40.73061,"point_lon":-73.935242,"center_lat":40.7128,"center_lon":-74.006,"radius_m":10000}'
{
  "point_lat": 40.73061,
  "point_lon": -73.935242,
  "center_lat": 40.7128,
  "center_lon": -74.006,
  "radius_m": 10000
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "geo.geofence_circle_check",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Define the point, center, and radius clearly

For example, a delivery area with a five-kilometer reach needs a radius_m value of 5000.

Interpret membership, distance, and signed margin

Output distances are rounded to six decimal places for stable serialization, but the inside decision uses the full unrounded calculation. This avoids a displayed rounded value changing the true comparison. For routing or billing policies, choose any operational buffer before calling or compare the returned margin with your own safety threshold. The response contains four compact fields. The inside boolean is true when the computed distance is less than or equal to the radius, so a point exactly on the boundary belongs to the geofence. The distance_m field is the great-circle distance between the center and point on a mean-Earth sphere with radius 6,371,000 meters. The radius_m field echoes the validated fence radius, while margin_m subtracts distance from radius. That signed margin is often more useful than a boolean alone: a value of 240 means the point is inside with about 240 meters to spare, a value of zero means it is on the edge, and a value of minus 85 means it is about 85 meters outside.

Use the result safely in real geofence workflows

For example, an arrival workflow might enter only when margin_m exceeds twenty meters and exit only when it falls below minus twenty meters, preventing rapid state changes near the edge. Browser execution is available for interactive checks, while automated API requests cost $0.002 each.

What does a positive margin mean?

The point is inside the geofence, and margin_m is the remaining distance to the circular boundary.

How much does an API check cost?

Each successful API request costs $0.002. The deterministic browser runner can also perform interactive checks.

Read the full KIT documentation →