summaryrefslogtreecommitdiffstats
path: root/telephony
diff options
context:
space:
mode:
authorSean Barbeau <sjbarbeau@gmail.com>2012-01-12 23:37:47 -0500
committerJean-Baptiste Queru <jbq@google.com>2012-05-02 16:22:16 -0700
commit67662767d98c42c34519767956aebe9d90f31c3a (patch)
tree674f1aec632983cd7f7113271451bbd1d042dac5 /telephony
parent1b34c1bc240e6c2e085eee2b03c728b56b049e23 (diff)
downloadframeworks_base-67662767d98c42c34519767956aebe9d90f31c3a.zip
frameworks_base-67662767d98c42c34519767956aebe9d90f31c3a.tar.gz
frameworks_base-67662767d98c42c34519767956aebe9d90f31c3a.tar.bz2
Adds utility method to convert 0.25 secs to decimal degrees
This patch adds a utility method that converts latitude and longitude in quarter seconds units to decimal degrees units. The Telephony API returns CDMA base station latitude and longitude in quarter seconds due to a 3GPP telecom standard, while the Android Location API, and the vast majority of application-level code, uses decimal degrees. For example, to measure the distance from the user's current location to the base station using the Location API Location.distanceBetween() method (http://goo.gl/YjO8O), the base station lat and long would need to be converted to decimal degrees first. Since most application developers will likely never use lat/long information in quarter seconds units, and instead will need this information in decimal degrees, this utility method will frequently be used by anyone querying base station location data from CdmaCellLocation. Sample values to test conversion: 0.25 seconds: lat = 399491, long = -1189145 is equivalent to decimal degrees: lat = 27.742430555555554, long = -82.57951388888888 Change-Id: If03e741f5035a37519f50d4fb2fb3e3eef2505da Signed-off-by: Sean Barbeau <sjbarbeau@gmail.com>
Diffstat (limited to 'telephony')
-rw-r--r--telephony/java/android/telephony/cdma/CdmaCellLocation.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/telephony/java/android/telephony/cdma/CdmaCellLocation.java b/telephony/java/android/telephony/cdma/CdmaCellLocation.java
index 84db830..4fea793 100644
--- a/telephony/java/android/telephony/cdma/CdmaCellLocation.java
+++ b/telephony/java/android/telephony/cdma/CdmaCellLocation.java
@@ -215,6 +215,22 @@ public class CdmaCellLocation extends CellLocation {
this.mNetworkId == -1);
}
+ /**
+ * Converts latitude or longitude from 0.25 seconds (as defined in the
+ * 3GPP2 C.S0005-A v6.0 standard) to decimal degrees
+ *
+ * @param quartSec latitude or longitude in 0.25 seconds units
+ * @return latitude or longitude in decimal degrees units
+ * @throws IllegalArgumentException if value is less than -2592000,
+ * greater than 2592000, or is not a number.
+ */
+ public static double convertQuartSecToDecDegrees(int quartSec) {
+ if(Double.isNaN(quartSec) || quartSec < -2592000 || quartSec > 2592000){
+ // Invalid value
+ throw new IllegalArgumentException("Invalid coordiante value:" + quartSec);
+ }
+ return ((double)quartSec) / (3600 * 4);
+ }
}