0

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()
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
user3308780
  • 45
  • 1
  • 3
  • You can use a while True in the store_as_lat_dep() function and ask the user if they want to input more data at the end of each cycle. When they answer "no", return from the function (see http://stackoverflow.com/questions/8114355/loop-until-a-specific-user-input ). Note that you will have to return the corDict if you want to access it after the function returns. –  Aug 09 '15 at 22:58
  • @Curly Joe I'll try though not sure how to append the dictionary with new results. Thank you – user3308780 Aug 10 '15 at 02:53
  • @jonrsharpe thank you as always from those of us 'not in the know'. Your edit cut to the chase – user3308780 Aug 10 '15 at 02:57

0 Answers0