Пример #1
0
 def offset(self,
            azimuth,
            dist_hor,
            dist_vert=0.0,
            ellipse="WGS84",
            **kwargs):
     """Returns new GeoPoint at offset position
     
     Parameters
     -----------
     azimuth : float
         azimuth direction angle (in decimal degrees, e.g. 90 for E 
         direction, -90 or 270 for west)
     dist_hor : float 
         horizontal offset to this point in km 
     dist_vert : float 
         vertical offset to this point in m (positive if point is higher, 
         negative, if it is lower)
     ellipse : float 
         geodetic system (ellipsoid), default is "WGS84", i.e. 
         `World Geodetic System <https://confluence.qps.nl/pages/view page.
         action?pageId=29855173>`__
     **kwargs : 
         additional keyword arguments passed to init of new 
         :class:`GeoPoint` object
     
     Returns
     -------
     GeoPoint
         new location at offset position
     """
     p = LatLon(self.lat.decimal_degree, self.lon.decimal_degree)
     p1 = p.offset(azimuth, dist_hor, ellipse)
     return GeoPoint(p1.lat.decimal_degree, p1.lon.decimal_degree,
                     self.altitude + dist_vert, **kwargs)
Пример #2
0
def test_LatLon_offset():
    '''
    Test LatLon method offset
    '''
    palmyra, honolulu = LatLon(5.8833, -162.0833), LatLon(21.3, -157.8167) # locations: Palmyra Atoll and Honolulu, HI
    distance = palmyra.distance(honolulu) # WGS84 distance is 1766.69130376 km
    initial_heading = palmyra.heading_initial(honolulu) # Initial heading to Honolulu on WGS84 ellipsoid
    offset_hnl = palmyra.offset(initial_heading, distance) # Reconstruct lat/lon for Honolulu based on offset from Palmyra
    # Equality could also be tested with honolulu == offset_hnl, but would be subject to float errors
    assert honolulu.almost_equal(offset_hnl)
    vector = honolulu - palmyra # Same process with GeoVectors
    vector_hnl = palmyra + vector # Reconstruct lat/lon for Honolulu based on offset from Palmyra
    assert honolulu.almost_equal(vector_hnl)
Пример #3
0
def move_vector(fix, vector):
    """
    accepts a starting fix in lat lon
    determines destination after travelling a certain distance for
    a particular start heading
    """
    distance = vector[1] * 1.852  # convert NM to KM
    heading = vector[0]  # is this radians or degrees?
    # print "**********\ndebugging travel\n*********"
    # print "Checking on the start_point"
    # print start_point
    # print type(start_point)
    lat1 = fix[0]
    lon1 = fix[1]
    origin = LatLon(lat1, lon1)
    destination_obj = origin.offset(heading, distance)
    destination_tup = destination_obj.to_string()
    lat2 = round(float(destination_tup[0]), 2)
    lon2 = round(float(destination_tup[1]), 2)
    return ((lat2, lon2))
Пример #4
0
def move_vector(fix, vector):
    """
    accepts a starting fix in lat lon
    determines destination after travelling a certain distance for
    a particular start heading
    """
    distance = vector[1] * 1.852  # convert NM to KM
    heading = vector[0]  # is this radians or degrees?
    # print "**********\ndebugging travel\n*********"
    # print "Checking on the start_point"
    # print start_point
    # print type(start_point)
    lat1 = fix[0]
    lon1 = fix[1]
    origin = LatLon(lat1, lon1)
    destination_obj = origin.offset(heading, distance)
    destination_tup = destination_obj.to_string()
    lat2 = round(float(destination_tup[0]), 2)
    lon2 = round(float(destination_tup[1]), 2)
    return((lat2, lon2))
Пример #5
0
class Location:
    """
    Parameters
    ----------
    lat : LatLon.lat
    lon : LatLon.lon

    Attributes
    ----------
    latlon : LatLon
    """

    def __init__(self, lat, lon):
        self.latlon = LatLon(Latitude(lat), Longitude(lon))

    def get_distance_in_km(self, snd_location):
        """
        Parameters
        ----------
        snd_location : Location

        Returns
        -------
        int
        """
        return self.latlon.distance(snd_location.latlon)

    def get_distance_in_m(self, snd_location):
        """
        Parameters
        ----------
        snd_location : Location

        Returns
        -------
        int
        """
        return self.get_distance_in_km(snd_location) * 1000

    def get_heading(self, snd_location):
        """
        Parameters
        ----------
        snd_location : Location

        Returns
        -------
        LatLon.heading
        """
        return self.latlon.heading_initial(snd_location.latlon)

    def get_lat_lon(self):
        """
        Returns
        -------
        LatLon
        """
        return self.latlon

    def lat_lon_to_string(self):
        """
        Returns
        -------
        String
        """
        return self.latlon.to_string('D')

    def offset_in_m(self, heading, distance):
        """
        Parameters
        ----------
        heading : LatLon.heading
        distance : int

        Returns
        -------
        Location
        """
        latlon = self.latlon.offset(heading, distance / 1000)
        return Location(latlon.to_string('D')[0], latlon.to_string('D')[1])