Question: Problem 1. (Geo Location) Define a data type Location in location.py that represents a location on Earth using its latitude and longitude. The data type


Problem 1. (Geo Location) Define a data type Location in location.py that represents a location on Earth using its latitude and longitude. The data type must support the following API: method Location(lat, lon) 1.distanceTo Cm) str(1) description a new location I from the given latitude and longitude values the great-circle distance between l and m the string representation of 1 as '(lat, lon' See Problem 7 from Project 2 for the great-circle distance formula. $python3 location.py 48.87 -2.33 37.8 -122.4 loc1-(48.87,-2.33) loc2(37.8, -122.4) d (loc1, loc2) 8701.38954324 import math import stdio import sys class Location: Represents a location on Earth. 11 def __init__(self, lat, lon): Constructs a newlocation given its latitude and longitude values. self. lat = self._lon .. . def distanceTo (self, other): Returns the great-circle distance between self and other. def _str__(self): Returns a string representation of self. # Test client [DO NOT EDIT]. Reads floats lat, 1on1, lat2, 18n. from command # representing two locations on Earth, constructs two Location objects from # them, and writes them along with the great-circle distance between the two. def main): lati, IRRI, lat2, 9n2. = map( float, SXE,arayl 1 :1) loc1 -Location(latl, lon1) loc2 = Location( lat2, lon2) stdig.writeln'loc1'str(loc1)) stdig.writeln( 'd(loc1, loc2) 'str(loc1.distanceTo(loc2))) if name main -main ()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
