示例#1
0
def main():
    """Main entrypoint"""

    parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
    parser.add_argument('first_lat', type=float, help="first point latitude, ex: 43.561725")
    parser.add_argument('first_long', type=float, help="first point longitude, ex: 1.444796")
    parser.add_argument('second_lat', type=float, help="second point latitude, ex: 43.671348")
    parser.add_argument('second_long', type=float, help="second point longitude, ex: 1.225619")
    args = parser.parse_args()

    distance = geometry.distance_between_wgs84_coordinates(args.first_lat, args.first_long,
                                                           args.second_lat, args.second_long)

    print "distance is: %fm" % distance
示例#2
0
def main():
    """Main entrypoint"""

    parser = argparse.ArgumentParser(
        description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter)
    parser.add_argument('first_lat',
                        type=float,
                        help="first point latitude, ex: 43.561725")
    parser.add_argument('first_long',
                        type=float,
                        help="first point longitude, ex: 1.444796")
    parser.add_argument('second_lat',
                        type=float,
                        help="second point latitude, ex: 43.671348")
    parser.add_argument('second_long',
                        type=float,
                        help="second point longitude, ex: 1.225619")
    args = parser.parse_args()

    distance = geometry.distance_between_wgs84_coordinates(
        args.first_lat, args.first_long, args.second_lat, args.second_long)

    print "distance is: %fm" % distance
示例#3
0
def profile(data_source, wgs84_lat1, wgs84_long1, wgs84_lat2, wgs84_long2, height1=0, height2=0, above_ground1=True,
            above_ground2=True, definition=512):
    """
    Generates a profile with the given parameters and elevation data source.

    :param data_source: the data_source to read elevation data from
    :param wgs84_lat1: the latitude of the starting point
    :param wgs84_long1: the longitude of the starting point
    :param wgs84_lat2: the latitude of the ending point
    :param wgs84_long2: the longitude of the ending point
    :param height1: the sight height for the starting point, defaults to 0
    :param height2: the sight height for the ending point, defaults to 0
    :param above_ground1: is sight height fir the starting point above the ground (True) or above the sea (False),
                          defaults to True
    :param above_ground2: is sight height fir the ending point above the ground (True) or above the sea (False),
                          defaults to True
    :param definition: the number of points to sample including the starting point and the ending point
    :return: the profile data composed of numpy arrays for latitudes, longitudes, sights, elevations, distances and
             overheads (correction of the rounded earth profile)
    """
    profile_data = {}
    profile_data['latitudes'] = latitudes = np.linspace(wgs84_lat1, wgs84_lat2, definition)
    profile_data['longitudes'] = longitudes = np.linspace(wgs84_long1, wgs84_long2, definition)
    profile_data['elevations'] = geods.read_ds_value_from_wgs84(data_source, latitudes, longitudes)
    start_sight = float(height1)
    if above_ground1:
        start_sight += float(profile_data['elevations'][0])
    end_sight = float(height2)
    if above_ground2:
        end_sight += float(profile_data['elevations'][-1])
    profile_data['sights'] = np.linspace(start_sight, end_sight, definition)
    profile_data['distances'] = geometry.distance_between_wgs84_coordinates(wgs84_lat1, wgs84_long1, latitudes,
                                                                            longitudes)
    profile_data['overheads'] = compute_curved_earth_correction(wgs84_lat1, wgs84_long1, wgs84_lat2, wgs84_long2,
                                                                latitudes, longitudes)
    return profile_data
示例#4
0
def test_distance_between_wgs84_coordinates():
    expected = 21433.388831
    actual = geometry.distance_between_wgs84_coordinates(43.561725, 1.444796, 43.671348, 1.225619)
    assert abs(expected - actual) <= EPSILON
示例#5
0
def test_distance_between_wgs84_coordinates():
    expected = 21433.388831
    actual = geometry.distance_between_wgs84_coordinates(
        43.561725, 1.444796, 43.671348, 1.225619)
    assert abs(expected - actual) <= EPSILON