[geocode-glib] lib: Do validation of lat/long when creating the location



commit 545c36f54493255d476faee2e27f063edc2caa67
Author: Bastien Nocera <hadess hadess net>
Date:   Sun Nov 25 18:30:26 2012 +0100

    lib: Do validation of lat/long when creating the location

 geocode-glib/geocode-location.c |    9 +++++++++
 geocode-glib/geocode-reverse.c  |    9 ---------
 2 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/geocode-glib/geocode-location.c b/geocode-glib/geocode-location.c
index b5a5ab4..abf31b8 100644
--- a/geocode-glib/geocode-location.c
+++ b/geocode-glib/geocode-location.c
@@ -75,6 +75,15 @@ geocode_location_new (gdouble latitude,
 	GeocodeLocation *ret;
 	GTimeVal tv;
 
+	if (longitude < -180.0 || longitude > 180.0) {
+		g_warning ("Invalid longitude %lf passed, using 0.0 instead", longitude);
+		longitude = 0.0;
+	}
+	if (latitude < -90.0 || latitude > 90.0) {
+		g_warning ("Invalid latitude %lf passed, using 0.0 instead", latitude);
+		latitude = 0.0;
+	}
+
 	ret = g_new0 (GeocodeLocation, 1);
 	ret->longitude = longitude;
 	ret->latitude = latitude;
diff --git a/geocode-glib/geocode-reverse.c b/geocode-glib/geocode-reverse.c
index a726054..31badd6 100644
--- a/geocode-glib/geocode-reverse.c
+++ b/geocode-glib/geocode-reverse.c
@@ -90,15 +90,6 @@ geocode_reverse_new_for_location (GeocodeLocation *location)
 	GeocodeReverse *object;
 	char buf[16], buf2[16];
 
-	if (location->longitude < -180.0 || location->longitude > 180.0) {
-		g_warning ("Invalid longitude %lf passed, using 0.0 instead", location->longitude);
-		location->longitude = 0.0;
-	}
-	if (location->latitude < -90.0 || location->latitude > 90.0) {
-		g_warning ("Invalid latitude %lf passed, using 0.0 instead", location->latitude);
-		location->latitude = 0.0;
-	}
-
 	object = g_object_new (GEOCODE_TYPE_REVERSE, NULL);
 
 	g_hash_table_insert (object->priv->ht,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]