?
Solved

Geofencing

Posted on 2005-03-29
4
Medium Priority
?
1,726 Views
Last Modified: 2012-05-05
Ok I need to figure out how to write an effective and efficient geofence.  Here is my situation....I am writing a vehicle tracking application for my final project in undergrad.  This application is going to be used to track our area transit system for the school.  Obviously we have bus stops...so...I have gotten a lat/long for the stops (an approximation atleast).  Now I can add these to the database where I have all the stops information.  We also have a database that is keeping the NMEA strings for the buses locations.  

Now what I want to be able to do is...when I query to see where bus "123" currently is I would like to then have an efficient means to compare the busses current location to the coordinates I have for the stops to tell where the bus is.  I am not asking for anyone to help me with the database part (I can take care of all the myself)...what I am asking for is an idea/algorithym/psuedo code (any of the 3 would be good) to do the comparison for the buses location against the stops on the route.

I appreciate your help.

r2
0
Comment
Question by:r270ba
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 13657517
I think the simples method for your specific application is a pitagorical calculus. Just this

distance (in feets) = sqrt ( pow(lat_bus-lat_stop, 2) + (lon_bus-lon_stop) ) * 364500

so, you define your threshold in feets and compare if it has been raised. Of couse, to apply formula you will need to convert all latitude/longitude to unique values (with decimals, without minutes and seconds)
0
 

Author Comment

by:r270ba
ID: 13658446
Ok I have already written a class to parse my degrees and convert them to decimals from the NMEA string...

I am not sure what you mean with the above equation..could you explain it a little more???

I was thinking more along the lines of a select statement for the database which would do the logic for picking the correct stop....

Ex:  I take the current bus lat and long and then compare it to a stops lat/long, but with the stop lat/long I create a geofence around it...

So it would be something like

Select * from tableName WHERE 'the buses lat/long is within the geofence'

and I guess I could create a geofence by taking the stops latitude and adding a max/min lat and the stops longitude and adding a max/min long...then taking the current position of the bus and checking to see if it was...

max long > bus long < min long AND max lat > bus lat < min lat

Does this make since?  If so, then how do I determine how big my fence is?  Say my decimals are 34.655332, -82.839392...then how can I create a 20 foot box around those coordinates?

If this does not make since then what other ideas do you have?

Thanks

r2
0
 
LVL 13

Accepted Solution

by:
imarshad earned 2000 total points
ID: 13659209
>>Select * from tableName WHERE 'the buses lat/long is within the geofence'

Yes you are on the right track...... Here is a link where I have helped another user with a similar problem.....
http://www.experts-exchange.com/Databases/GIS_GPS/Q_21053014.html

If you find the question too difficult to handle then I will try to explain it here.....

The query will be somethin like this..... (I have extracted this from a working example of mine in VB6)

strSql="Select * from tableName where (LONGITUDE  between " & (long1 + 0.47) & " and " & (long1 - 0.47) & ") AND (LATITUDE between " & (lat1 + 0.45) & " and " & (lat1 - 0.45) & " ) "

Note that this example will create a fence of 50x50 km where the Latitude is between 20-30 degrees..... Now changing the value 0.45 and 0.47 you can define your own fence round long1 and lat1.......

http://www.zodiacal.com/tools/lat_table.htm    will explain you how to calculate this value for your area and the fence rectangle around your area of interest....

Imran
0
 

Author Comment

by:r270ba
ID: 13664315
Perfect...thanks a lot!!!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I feel like more and more people want to know how to programmatically convert addresses into geospatial locations. So in this article, I will show you how you can do it with Bing Maps. I'm going to use PowerShell, which is a nice scripting language,…
Introduction This article is designed to assist GIS (Geographic Information System) and GPS (Global Positioning System) developers using ESRI ArcGIS and other spatial information management systems.   For the uninitiated the concept of projectio…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question