Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a system that can alert staff by email if their device goes into/out of a geo-zone

However, we now need to create a route, and then email if someone goes off this route

Technically, how would i do this? I have no idea! Do you just check their GPS location and see if it exists within the GPS co-ordinates of a route?

I'm using openlayers framework afterthought Is a route a really narrow geozone?

share|improve this question
From your description, it is currently unclear for me what defines a route in your application and where it comes from. Then you will also need to define what "off the route" means in your special setting. There can be no clear answers without detail. – underdark Sep 19 '12 at 11:43
Is your route made up many points, a line, or a narrow polygon? – CaptDragon Sep 19 '12 at 13:51
sorry for the lack of clarity, we get the GPS co-ords that the vehicle has travelled (so i guees this is many points) So on each point we must draw a line, and i guess we need to give it some margin either side (10 meters each side i guess) – user8297 Sep 20 '12 at 13:06
You have to give more information about current technical solution - there's "device" (laptop? tablet? cell phone?) with GPS receiver. How do you collect GPS data - do you read it directly with OpenLayers? Is there any database involved? Are those coordinates sent also to some kind of server? – user1702401 Dec 17 '12 at 7:13

I assume that you have the route as a connected sequence of line segments.

The easiest way would just be to calculate the length of the distance from the current position (i.e. a point) to the route (linestring). OpenLayers distanceto should be sufficient. You'll need to "tune" the distance alert based on reality (e.g. poor GPS performance in some areas, quality of GPS, policy).

The other option is to define a geozone around the route (e.g. with a buffer). I don't think there is direct support for this in openlayers, but an add-on like JSTS might be able to help. Then you can re-use your existing geozone alerting code.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.