Exemplo n.º 1
0
    def testDeprecated(self, LatLon):

        c = HeightIDW  # == HeightIDWeuclidean in Python 3.7+
        self.test(c.__name__, issubclass(c, HeightIDWeuclidean), True)
        c = HeightIDW2  # == HeightIDWequirectangular in Python 3.7+
        self.test(c.__name__, issubclass(c, HeightIDWequirectangular), True)
        c = HeightIDW3  # == HeightIDWhaversine in Python 3.7+
        self.test(c.__name__, issubclass(c, HeightIDWhaversine), True)

        p = LatLon(0, 0), LatLon(1, 0), LatLon(0, 1)
        self.test('areaof', areaof(p, radius=R_MA), '7.086883e+09', fmt='%.6e')

        p = LatLon(85, 90), LatLon(-85, 0), LatLon(85, -90), LatLon(85, -180)
        b = map2(float, bounds(p))
        self.test('bounds', b, '(-85.0, -180.0, 85.0, 90.0)')

        self.test('decodeEPSG2', decodeEPSG2(32712), "(12, 'S')")
        self.test('encodeEPSG', encodeEPSG(12, hemipole='S'), '32712')

        t = equirectangular3(0, 2, 3, 4)
        self.test('equirectangular3', len(t), 3)
        self.test('equirectangular3', t[0], 12.997, fmt='%.3f')

        h = hypot3(3000, 200, 10)
        s = sqrt(3000**2 + 200**2 + 10**2)
        self.test('hypot3', h, s, fmt='%.6f')

        b = LatLon(45, 1), LatLon(45, 2), LatLon(46, 2), LatLon(46, 1)
        self.test('isenclosedby', isenclosedby(LatLon(45.5, 1.5), b), True)

        p = LatLon(45, 2)
        b = LatLon(45, 1), LatLon(47, 3)
        t = nearestOn3(p, b, adjust=False)
        self.test('nearestOn3', len(t), 3)
        self.test('nearestOn3', t[:2], (45.5, 1.5))
        t = nearestOn4(p, b, adjust=False)
        self.test('nearestOn4', len(t), 4)
        self.test('nearestOn4', t[:2], (45.5, 1.5))

        t = parseUTM('18 N 516620 4574500', Utm=None)  # Milford, PA
        self.test('parseUTM', t, "(18, 'N', 516620.0, 4574500.0)")

        p = LatLon(0, 0), LatLon(1, 0), LatLon(0, 1)
        self.test('perimeterof', perimeterof(p, radius=R_MA), '2.687460e+05', fmt='%.6e')

        p = LatLon(0, 0), LatLon(1, 0), LatLon(0, 1)
        self.test('polygon', polygon(p)[0], 3)

        t = simplify2(RdpFFI, 16, adjust=True, shortest=False)
        self.test('simplify2', len(t), 4)

        t = toUtm('50°52′10″N', '115°39′03″W', Utm=None, name='Mt Assiniboine')
        self.test('toUtm', len(t), 6)

        t = utmZoneBand2('50°52′10″N', '115°39′03″W')
        self.test('utmZoneBand2', t, "(11, 'U')")
Exemplo n.º 2
0
 def testUtmTMcoord(self, coord, line, fmt='%.4f', eps=1.5e-4):
     # format: lat lon easting northing convergence scale
     lat, lon, e1, n1, c1, s1 = map(float, coord.split())
     # skip tests with "out of range" lon
     if lon > 70.0:
         self.skip(line + repr(coord))
     else:
         try:
             _, e2, n2, _, c2, s2 = toUtm(lat, lon, cmoff=False)
             self.test(line + 'easting',
                       e2,
                       e1,
                       fmt=fmt,
                       known=abs(e2 - e1) < eps)
             self.test(line + 'northing',
                       n2,
                       n1,
                       fmt=fmt,
                       known=abs(e2 - e1) < eps)
             self.test(line + 'convergence', c2, c1, fmt=fmt)
             self.test(line + 'scale', s2, s1, fmt=fmt)
         except RangeError as x:
             self.test(line + 'RangeError', x, None, known=True)
Exemplo n.º 3
0
 elif get_distance(old_location, location) > max_dist:
     status = 2
 elif utc - max_pause > old_utc:
     status = 1
 elif (data.get("pressure") is not None
       and np.abs(np.diff([data["pressure"], old_pressure])) > 10):
     status = 4
 else:
     status = 0
 if status >= status_threshold:
     old_utc = utc
     old_location = location
     old_pressure = data.get("pressure")
     gps_altitude = data.get("alt")
     if location is not None:
         utm = pygeodesy.toUtm(*location)
         data["utm"] = utm.toStr()
         data["mgrs"] = utm.toMgrs().toStr()
     data["rpi_temperature"] = get_cpu_temperature()
     data["my_status"] = status
     data["localtime"] = str(strftime("%Y-%m-%d %H:%M:%S", localtime()))
     if error is not None:
         data["pos_error"] = round(error, 2)
     else:
         data["pos_error"] = float("nan")
     redis_connection.publish("transfer_data", json.dumps(data))
     if dump_ignore_keys is not None:
         for key in dump_ignore_keys:
             data.pop(key, None)
     key = "tracking:{}:{}".format(data["hostname"], strftime("%Y%m%d"))
     redis_connection.lpush(key, json.dumps(data))
Exemplo n.º 4
0
def ll_to_utm(latitude, longitude):
    _utm = pygeodesy.toUtm(latitude, longitude)
    _utm_32 = _utm.toUtm(32)
    return _utm_32.easting, _utm_32.northing