def rescale0(self, lat, scale0=_K0): '''Set the central scale factor for this UPS projection. @param lat: Northern latitude (C{degrees}). @param scale0: UPS k0 scale at B{C{lat}} latitude (C{scalar}). @raise RangeError: If B{C{lat}} outside the valid range and L{rangerrors} set to C{True}. @raise ValueError: Invalid B{C{scale}}. ''' try: s0 = float(scale0) if not 0 < s0: # <= 1.003 or 1.0016? raise ValueError except (TypeError, ValueError): raise ValueError('%s invalid: %r' % ('scale', scale0)) lat = clipDMS(lat, 90) # clip and force N u = toUps8(abs(lat), 0, datum=self.datum, Ups=_UpsK1) k = s0 / u.scale if self.scale0 != k: self._band = '' # force re-compute self._latlon = self._epsg = self._mgrs = self._utm = None self._scale0 = k
def toWm(latlon, lon=None, radius=R_MA, Wm=Wm, name=''): '''Convert a lat-/longitude point to a WM coordinate. @param latlon: Latitude (C{degrees}) or an (ellipsoidal or spherical) geodetic C{LatLon} point. @keyword lon: Optional longitude (C{degrees} or C{None}). @keyword radius: Optional earth radius (C{meter}). @keyword Wm: Optional (sub-)class to return the WM coordinate (L{Wm}) or C{None}. @keyword name: Optional name (C{str}). @return: The WM coordinate (B{C{Wm}}) or an L{EasNorRadius3Tuple}C{(easting, northing, radius)} if B{C{Wm}} is C{None}. @raise ValueError: If B{C{lon}} value is missing, if B{C{latlon}} is not scalar, if B{C{latlon}} is beyond the valid WM range and L{rangerrors} is set to C{True} or if B{C{radius}} is invalid. @example: >>> p = LatLon(48.8582, 2.2945) # 448251.8 5411932.7 >>> w = toWm(p) # 448252 5411933 >>> p = LatLon(13.4125, 103.8667) # 377302.4 1483034.8 >>> w = toWm(p) # 377302 1483035 ''' r, e = radius, None try: lat, lon = latlon.lat, latlon.lon if isinstance(latlon, _LLEB): r = latlon.datum.ellipsoid.a e = latlon.datum.ellipsoid.e if not name: # use latlon.name name = nameof(latlon) lat = clipDMS(lat, _LatLimit) except AttributeError: lat, lon = parseDMS2(latlon, lon, clipLat=_LatLimit) s = sin(radians(lat)) y = atanh(s) # == log(tan((90 + lat) / 2)) == log(tanPI_2_2(radians(lat))) if e: y -= e * atanh(e * s) e, n = r * radians(lon), r * y r = EasNorRadius3Tuple(e, n, r) if Wm is None else \ Wm(e, n, radius=r) return _xnamed(r, name)
def degrees2m(deg, radius=R_M, lat=0): '''Convert angle to distance along the equator or along a parallel at an other latitude. @param deg: Angle (C{degrees}). @keyword radius: Mean earth radius (C{meter}). @keyword lat: Parallel latitude (C{degrees90}). @return: Distance (C{meter}, same units as B{C{radius}}). @raise RangeError: Latitude B{C{lat}} outside valid range and L{rangerrors} set to C{True}. ''' m = radians(deg) * radius if lat: from pygeodesy.dms import clipDMS m *= cos(radians(clipDMS(lat, 90))) return m