Tuesday, January 24, 2012

[android-developers] Android GPS within a rectangular area

This is my code objective: I want an android application to start to
trigger connecting to server and sending the latitude and longitude
only when the phone (being used in a car) is within a road area ( say
an area 1km x 30m ). It is continuously listening to its location but
will start sending to server once it enters the area and will
continuously send and will stop only once it exit the area.


A good answer i received for this: "create two location, a NorthWest
location and a SouthEast location that represent your box. In your
onLocationChanged method, compare the new location with the corners,
such that (l.lat > se.lat && l.lat < nw.lat) and (l.lon < se.lon &&
l.lon > nw.lon) where "l" is the newest location from the callback,
"se" is the south east corner of your boundary and "nw" is the north
west corner of your bounder. If it meets the 4 above conditions, then
you send to your server"


I think this is applicable when a pair of the sides of the
rectangular area are parallel to the latitude(equator) and the other
pair of the sides parallel to the longitude lines (meridian). What if
the rectangular area's sides are not parallel to the latitude and
longitude lines . How can I meet my objective? Proximity alert will
form a circle. Should a mathematical formula do it sir?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate