elf) method that will return a tuple or list with self.lat, self.lon. 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. 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. A SetDescription(self, description) method that will set the objects self.description attribute (variable). A GetDescription(self) method that will return the objects self.description attribute. 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
elf) method that will return a tuple or list with self.lat, self.lon. 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. 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. A SetDescription(self, description) method that will set the objects self.description attribute (variable). A GetDescription(self) method that will return the objects self.description attribute. 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
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
Related questions
Question
I am creating a class using python, I am stuck with inserting the functions as I have run across some errors. I will attach my program and 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]
self.lon =point[1]
- A GetPoint(self) method that will return a tuple or list with self.lat, self.lon.
- 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.
- 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.
- A SetDescription(self, description) method that will set the objects self.description attribute (variable).
- A GetDescription(self) method that will return the objects self.description attribute.
- 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.
- 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.
- In the main part of your program do the following:
- Include the class.
- Instantiate three points.
- 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')
- 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'
- 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”)
- Inside a “Do another (y/n)?” loop do the following:
- 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.
- 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)
- 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)
- 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>
- Ask “Do another (y/n)?” and loop if they respond with ‘y’
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 4 images
Knowledge Booster
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.Recommended textbooks for you
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education