ogram and here are the instructions:  In your program define a class called GeoPoint that will have the following: A constructor __init__(self, lat=0, lon=0,description=’TBD’) that will initialize the class variables called: self.lat, self.lon, and self.description. A SetPoint(self, point) method that takes an individual points coordinates as a single sequence and sets them to self.lat, self.long. E.g:  self.lat = point[0]

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

I have to show a program that demonstrates a class using geo points. I have attached a previous program that I think can help with this. I don't know where to begin with inserting functions. I will attach a screenshot of my program and here are the instructions: 

  1. In your program define a class called GeoPoint that will have the following:
    1. A constructor __init__(self, lat=0, lon=0,description=’TBD’) that will initialize the class variables called: self.lat, self.lon, and self.description.
    2. A SetPoint(self, point) method that takes an individual points coordinates as a single sequence and sets them to self.lat, self.long. E.g: 

self.lat = point[0]

self.lon =point[1]

    1. A GetPoint(self) method that will return a tuple or list with self.lat, self.lon. 
    2. A CalcDistance(self, lat, lon) method that will figure out the distance between the object’s self.lat, self.lon and lat, lon parameters passed in.
    3. A CalcDistancePoint(self, point) method that takes in a point (both coordinates at once, a data sequence, or GeoPoint object) that will figure out the distance between the object’s self.lat, self.lon and the lat and lon from the point.
    4. A SetDescription(self, description) method that will set the objects self.description attribute (variable).
    5. A GetDescription(self) method that will return the objects self.description attribute.
    6. Add a property: Point = property(GetPoint,SetPoint). Make sure GetPoint and SetPoint are the names you used for the get and set methods you already wrote for points.
    7. Add another property: Description = property(GetDescription, SetDescription). Make sure GetDescription and SetDescription are the names you used for the get and set methods you already wrote.
  1. In the main part of your program do the following:
    1. Include the class.
    2. Instantiate three points.
      1. Use the constructor to set point1 coordinates and description. It should look something like the following but with your own coordinates and description:

point1 = GeoPoint(12.3456,-123.4567,'Loc1')

      1. Use a constructor without any arguments to instantiate the second point and use its properties to set its values. It should look something like the following but with your own coordinates and description:

point2 = GeoPoint()

point2.Point = 23.4567, -213.456

point2.Description = 'Loc2'

 

      1. For point3 use the SetPoint and SetDescription methods to set the points location and description. Make sure they have different coordinates and different descriptions. It should look something like the following but with your own coordinates and description:

 

point3 = GeoPoint()

point3.SetPoint((25.25,52.52))

point3.SetDescription(“Loc3”)

 

    1. Inside a “Do another (y/n)?” loop do the following:
      1. Create a fourth point by asking the user for their location. You can ask for coordinates in three inputs or ask them for their coordinates in one input with each element separated by a coma.
      2. Use the CalcDistance method to find the distance between point1 and a new latitude and longitude of your choosing. Then tell the user the coordinates for point1, the new latitude and longitude that was entered, and the distance between those coordinates. For example:

 

distanceToPoint1 = point1.CalcDistance(lat, lon)

 

      1. Use point2 and point3’s CalcDistancePoint method to find the distance from each point to the user’s location. Notice we are passing in the users point rather than the separate coordinates:

 

distanceToTwo = point2.CalcDistancePoint(userPoint)

distanceToThree = point3.CalcDistancePoint(userPoint)

 

      1. Tell the user which point they are closest to in this format:

 

You are closest to <description> which is located at <point’s lat and lon coordinates>

 

      1. Ask “Do another (y/n)?” and loop if they respond with ‘y’
6
7
8
9
10
11
12
IDLE File Edit Format
D2L Program 5 - Geo Points & Exceptions
Run
3. The
Hints
The code will lo
doAnother = 'y
while doAnother
try
Get homey def
Get connecte def get_location ():
while True:
Receive answe
try:
"Son
...your code
except TypeE
print("Wron
Next
except ...exce
print(...your
except Excep
print("Some
doAnother =İ
O
Drag and
Options Window Help
import math
class Location:
def
_init__(self, latitude, longitude):
self. latitude = latitude
self. longitude = longitude
if
def _str__(self):
S = f" ({abs (self. latitude)}{'S' if self. latitude < 0 else 'N'},
return s + f" {abs (self. longitude)} {'W' if self. longitude < 0else 'E'})"
print("\nWelcome!\nThis program lets you find the distance between to geographical points\n")
header():
YazzieTP4.py - /Users/tishenayazzie/Documents/YazzieTP4.py (3.7.9)
latitude = float(input('Enter Latitude (degree): '))
break
except ValueError:
print('-> Please provide only numeric input!\n')
while True:
try:
longitude = float(input('Enter Longitude (degree): '))
break
except ValueError:
print('-> Please provide only numeric input!\n')
return Location (latitude, longitude)
def distance (location1, location2):
earth_radius = 6371e3
# to radians
lat1 = location1.latitude * math.pi / 180
lat2 = location2. latitude * math.pi / 180
name
del_lat= (location2. latitude - location1. latitude) * math.pi / 180
del_long= (location 2. longitude - location1. longitude) * math.pi/180
a = math.sin(del_lat / 2) **2 + math.cos(lat1) * math.cos(lat2) * math.sin(del_long / 2) ** 2
c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
return earth_radius * c
== _main__':
try_again = 'y'
while try again == 'y':
header()
"I
loc1 = get_location ()
loc2 = get_location ()
print (f"The distance between {loc1} and {loc2} is {distance(loc1, loc2):.2f} km.")
try_again input('\nWant to try again with different input? (y/n) : ').strip()
print('\nGood Bye!')
Oct 1
24
الم
tv
I
Ln: 54 Col: 0
ZA
★Dashboard
Ơ
00
7.9 Shell*
tween to geographical points
y/n) :
e/Documents/Yazzie TP4.py
('S' if self. latitude < 0 else 'N') ((a
< 0 else 'E') and ((abs(self. latitude
(self. longitude)) (('W' if self. longitu
tween to geographical points
+
e/Documents/YazzieTP4.py
zieTP4.py", line 61, in <module>
d {loc2} is {distance (loc1, loc2):.2f}
tween to geographical points
y/n) :
W
Mon Oct 24 7:25 PM
00
00
81W) and (35.687N, 105.9378E) is 11450
Ln: 221
Col: 49
DOCX
Screen Shot
2-10 6 45 PM
to
: from
il
iction.
Collab
Transcribed Image Text:6 7 8 9 10 11 12 IDLE File Edit Format D2L Program 5 - Geo Points & Exceptions Run 3. The Hints The code will lo doAnother = 'y while doAnother try Get homey def Get connecte def get_location (): while True: Receive answe try: "Son ...your code except TypeE print("Wron Next except ...exce print(...your except Excep print("Some doAnother =İ O Drag and Options Window Help import math class Location: def _init__(self, latitude, longitude): self. latitude = latitude self. longitude = longitude if def _str__(self): S = f" ({abs (self. latitude)}{'S' if self. latitude < 0 else 'N'}, return s + f" {abs (self. longitude)} {'W' if self. longitude < 0else 'E'})" print("\nWelcome!\nThis program lets you find the distance between to geographical points\n") header(): YazzieTP4.py - /Users/tishenayazzie/Documents/YazzieTP4.py (3.7.9) latitude = float(input('Enter Latitude (degree): ')) break except ValueError: print('-> Please provide only numeric input!\n') while True: try: longitude = float(input('Enter Longitude (degree): ')) break except ValueError: print('-> Please provide only numeric input!\n') return Location (latitude, longitude) def distance (location1, location2): earth_radius = 6371e3 # to radians lat1 = location1.latitude * math.pi / 180 lat2 = location2. latitude * math.pi / 180 name del_lat= (location2. latitude - location1. latitude) * math.pi / 180 del_long= (location 2. longitude - location1. longitude) * math.pi/180 a = math.sin(del_lat / 2) **2 + math.cos(lat1) * math.cos(lat2) * math.sin(del_long / 2) ** 2 c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a)) return earth_radius * c == _main__': try_again = 'y' while try again == 'y': header() "I loc1 = get_location () loc2 = get_location () print (f"The distance between {loc1} and {loc2} is {distance(loc1, loc2):.2f} km.") try_again input('\nWant to try again with different input? (y/n) : ').strip() print('\nGood Bye!') Oct 1 24 الم tv I Ln: 54 Col: 0 ZA ★Dashboard Ơ 00 7.9 Shell* tween to geographical points y/n) : e/Documents/Yazzie TP4.py ('S' if self. latitude < 0 else 'N') ((a < 0 else 'E') and ((abs(self. latitude (self. longitude)) (('W' if self. longitu tween to geographical points + e/Documents/YazzieTP4.py zieTP4.py", line 61, in <module> d {loc2} is {distance (loc1, loc2):.2f} tween to geographical points y/n) : W Mon Oct 24 7:25 PM 00 00 81W) and (35.687N, 105.9378E) is 11450 Ln: 221 Col: 49 DOCX Screen Shot 2-10 6 45 PM to : from il iction. Collab
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education