Question: Python coding, shortened question! Please help. I'm having trouble with the code for the position class. The intro to the assignment is added below the

Python coding, shortened question! Please help. I'm having trouble with the code for the position class. The intro to the assignment is added below the question I need answered for reference

7. The Position class (in position.py of Package1). It should contain the methods required to perform the necessary actions, which includes:

a. An __init__() method, which takes four arguments: latitude, latitude cardinal direction string, longitude, and longitude cardinal direction string, then initializes the attributes latitude, longitude, and geometry. The latitude and longitude attributes designate latitude and longitude angle values of the position. You must determine if they are positive or negative, given the cardinal direction strings (i.e., S and W relate to negative latitude and longitude angles, respectively). The geometry attribute is a reference to an instance of a Geometry type or subtype object.

b. A method (named set_latitude) that takes a floating-point number as a parameter and sets the attribute latitude. This method must make sure the latitude value is in the range [-90, 90] c. A method (named get_latitude) that takes no parameter and gets the value of latitude.

d. A method (named set_longitude) that takes a floating-point number as a parameter and sets the attribute longitude. This method must make sure the longitude is in the range [-180, 180].

e. A method (named get_longitude) that takes no parameter and gets the value of longitude.

f. A method (named set_geometry) that takes a Geometry based reference as a parameter and sets the attribute geometry.

g. A method (named get_geometry) that takes no parameter and gets the value of geometry.

h. A method (named distance) that takes a position as a parameter, delegates the calculation to the Geometry class, i.e., the curry_distance() method, and finally returns the value obtained from a curry_distance() call from the this positions geometry.

You are to write a Python program that will compute distance and between two coordinates based on longitude and latitude angles in three contexts geometric and unit of distance contexts. Three versions will be given in three different packages: Package1, Package2 and Package3. In the first version, i.e., Package1, two files exist: Application.py and position.py. The Application file will contain a method to call a method in Position object to compute distance between coordinates in the three contexts. The position.py file gives the classes necessary to compute coordinate distance in the first context as follows: Given two coordinates, given by latitude and longitude, and the radius of the Earth, determine distance between the coordinates in statute miles and planar geometry (equirectangular flatEarth approximation). The formula to compute this distance is shown here: = 2 + 2 where R is the radius of the Earth, x is the term given by the formula = (2 1) cos((1 + 2)/2) and y is given by the formula = (2 1). It should be noted that latitude and longitude for position 1 and position 2, (latitude1, longitude1) and (latitude2, longitude2) respectively, must be converted into radians in the computation of d. The Position Class has the latitude and longitude attributes that converted from an input (latitude, N/S, longitude, W/E) such as such as (42.917, N, 85.5872, E) to (42.917, S, 85.5872 W). Namely, the valid value for latitude is [-90, 90] where the negative represents a position south of the equator and the positive a position north of the equator. The range for longitude is [-180, 180] where the negative represents a position west of the meridian line while the positive a position east of the meridian line. Last, the Unit Class has the radius attribute for the Earth in miles, whose value is 3959 miles (mean volumetric radius). CS 1120 (Python) - Spring 2021 LA3 OOP distance calculator Next, to test the information hiding of the calculation to the Application file/class, you are asked to change the Position class, with the new one in Package2, has a file postion.py, where the distance computed between two coordinates is in statue miles and through spherical coordinates and so the haversine calculation is based on the theta and phi, which are: = , where R is Earths radius, c is given by the formula = 2 atan2( , 1 ) , and a is given by the formula = (sin ( (21) 2 )) 2 + cos(1) cos(2) (sin( 21 2 )) 2 ) . Here, the latitudes and longitudes must be converted to radians as well. In fact, latitude converted to radians is the angle phi and longitude converted to radians is the angle theta. Last, you are asked to consider the distance output in kilometers instead of status miles without modifying the current implementation, i.e., increasing the reusability. Package3 has a file kilometer.py which expands into the third context, in which the distance between two coordinates must be determined in kilometers and in spherical geometry. Here, you must consider the Earths mean volumetric radius as 6371 kilometers

** and here's a reference for curry distance

A method (named curry_distance) that takes two positions as parameters and computes the distance between them based on equirectangular (flat-Earth approximation) coordinate system and the Earths radius in units

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!