From 34d6ad8e6a3280119e3317a58aadfb62923d63fd Mon Sep 17 00:00:00 2001 From: "Val E. Schmidt" Date: Fri, 4 Aug 2017 11:36:56 -0400 Subject: [PATCH 1/3] Modified fromLatLong() to accept optional UTM zone and band, which when specified converts the geographic coordinates to the specified zone regardless of location. This facilitates robot navigation across UTM boundaries with a complete change of reference frame. --- geodesy/src/geodesy/utm.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/geodesy/src/geodesy/utm.py b/geodesy/src/geodesy/utm.py index 6648337..234ac80 100644 --- a/geodesy/src/geodesy/utm.py +++ b/geodesy/src/geodesy/utm.py @@ -128,19 +128,36 @@ def valid(self): and self.northing == self.northing and self.band != ' ') -def fromLatLong(latitude, longitude, altitude=float('nan')): +def fromLatLong(latitude, longitude, altitude=float('nan'),zone=None,band=None): """Generate :class:`UTMPoint` from latitude, longitude and (optional) altitude. Latitude and longitude are expressed in degrees, relative to the WGS84 ellipsoid. + Optionally a UTM zone and band may be specified (e.g. zone = '19T' or + zone = 19, band = 'T'), which returns the UTM coordinates relative to + the specified zone/band combination regardless of location. This + facilitates robot movement across UTM zones. Users should generally + not apply this method beyond 2 UTM zones lest the projection error + exceed typical GPS uncertainty. + :param latitude: [degrees], negative is South. :param longitude: [degrees], negative is West. :param altitude: [meters], negative is below the ellipsoid. - + :param zone: either string of combined zone and band ('19T') or interger value (1-60) of zone alone. + :param band: capital letter, (C-X), may be omitted if zone is in combined form. + :returns: :class:`UTMPoint` object. """ - z, b = gridZone(latitude, longitude) + + if zone and not band: + z = zone[:2] + b = zone[-1] + else if zone and band: + z = str(zone) + b = band + else: + z, b = gridZone(latitude, longitude) utm_proj = pyproj.Proj(proj='utm', zone=z, datum='WGS84') e, n = utm_proj(longitude, latitude) return UTMPoint(easting=e, northing=n, altitude=altitude, zone=z, band=b) From 00f84fcaa63e4a3412cf54ed5cc94683d67afeb5 Mon Sep 17 00:00:00 2001 From: "Val E. Schmidt" Date: Fri, 25 Aug 2017 06:40:39 -0400 Subject: [PATCH 2/3] Fixed typo in if/than/elif statement. --- geodesy/src/geodesy/utm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geodesy/src/geodesy/utm.py b/geodesy/src/geodesy/utm.py index 234ac80..1a4fd82 100644 --- a/geodesy/src/geodesy/utm.py +++ b/geodesy/src/geodesy/utm.py @@ -153,7 +153,7 @@ def fromLatLong(latitude, longitude, altitude=float('nan'),zone=None,band=None): if zone and not band: z = zone[:2] b = zone[-1] - else if zone and band: + elif zone and band: z = str(zone) b = band else: From f3c3bde5d9f9ed3c45256c7bb34a5e931abb4bb4 Mon Sep 17 00:00:00 2001 From: valschmdt Date: Thu, 17 May 2018 07:58:00 -0700 Subject: [PATCH 3/3] Fixed bug in zone checking. --- geodesy/src/geodesy/utm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geodesy/src/geodesy/utm.py b/geodesy/src/geodesy/utm.py index 234ac80..1a4fd82 100644 --- a/geodesy/src/geodesy/utm.py +++ b/geodesy/src/geodesy/utm.py @@ -153,7 +153,7 @@ def fromLatLong(latitude, longitude, altitude=float('nan'),zone=None,band=None): if zone and not band: z = zone[:2] b = zone[-1] - else if zone and band: + elif zone and band: z = str(zone) b = band else: