I'm trying to write a simple land surveying program in Python. For each traverse leg, I want the azimuth and the changes in both the north-south and east-west positions to be stored in a dictionary called corDict
for later retrieval and analysis (point numbers would be great, too).
I've gotten this far but am stumped on how to iterate the process and continually add to the data storage dictionary.
import ui
import math
class Survey:
def __init__(self, brng, dist,lat,dep): #bearing to be entered like this:
self.brng = brng. # 'S45.2341E'
self.dist = dist
self.lat = lat
self.dep = dep
def course(self):
b = self.brng
quad = b[0] + b[-1]
decpoint = b.find('.') #find the decimal point
deg = int(b[1:decpoint]) #convert dms to decimal degrees
mins = int(b[decpoint+1:-3])/60.
sec = int(b[-3:-1])/3600.
az = (deg+mins+sec)
if quad == 'NE':
az = az
elif quad == 'SE':
az = 180 - az
elif quad == 'SW':
az = 180 + az
elif quad == 'NW':
az = 360 - az #need to convert to radians
lat = math.cos(az*math.pi/180)*self.dist #lat - change in north-south
dep = math.sin(az*math.pi/180)*self.dist #dep - change in east-west
return az, lat, dep
def store_az_lat_dep():
#brng = input('Input bearing: ')
#dist = input('Input distance: ') #--> eventually for user input
#xy = Survey(brng, dist, 10000, 10000) #ignore the 10000,10000
xy = Survey('45.0000E', 100, 10000, 10000) #-->for example
corDict = {xy.course()[0] : xy.course()[1:]}
print corDict
store_az_lat_dep()