zeroomega / omnidroid

Automatically exported from code.google.com/p/omnidroid
Apache License 2.0
0 stars 0 forks source link

wrong orders of longitude and latitude when constructing a new OmniArea object in the LocationMonitor #189

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a rule that uses the location data, i.e. register the GPS
2. User enters a special area where the longitude is greater than 90 or less 
than -90
3. Receive a location update

After this steps, OmniDroid throws an exception and consumes the energy very 
quickly but do nothing.

The code snippet is as follows:

At line 70 and 71 of 
edu.nyu.cs.omnidroid.app.controller.external.attributes.LocationMonitor.java:

newLocation = new OmniArea(null, location.getLatitude(), 
location.getLongitude(), location
            .getAccuracy());

At line 106 of edu.nyu.cs.omnidroid.app.controller.datatypes.OmniArea.java

public OmniArea(String userInput, double longitude, double latitude, double 
proximityDistance)

Longitude and latitude are disordered when new OmniArea in the LocationMonitor. 
Therefore, if the longitude is greater than 90 or less than -90, the 
constructor of OmniArea will throw an exception (because the latitude range is 
-90 to 90) and just return. Because the exception will be caught so that the 
application may repeat this useless process for many times if it continuously 
receives location updates, this error causes that OmniDroid cannot run 
correctly and waste a large mount of energy. Therefore, this leads to a 
function bug as well as an energy bug.

And the correction version of the lines 70 and 71 of LocationMonitor may be 
like this:

newLocation = new OmniArea(null, location.getLongitude(), 
location.getLatitude(), location
            .getAccuracy());

Original issue reported on code.google.com by liqiwei1...@gmail.com on 10 Nov 2014 at 12:54