Last active
August 29, 2015 14:03
-
-
Save aidenprice/b6c2f364c02ed8a38321 to your computer and use it in GitHub Desktop.
A class to describe a point in latitude, longitude and elevation. __eq__ and __repr__ methods excluded. This class was created for my Curtin University, Masters of Geospatial Science, Spatial Computations 100, second assignment, BoreholeWrangler V3.0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LocationObject: | |
# Class properties | |
fLatitude = None | |
fLongitude = None | |
fElevation = None | |
# Class hidden properties | |
# Minimum and maximum values to validate location inputs. | |
_MIN_LATITUDE = -90.0 | |
_MAX_LATITUDE = 90.0 | |
_MIN_LONGITUDE = -180.0 | |
_MAX_LONGITUDE = 180.0 | |
_MIN_ELEVATION = -16.0 | |
_MAX_ELEVATION = 8848.0 | |
def __init__(self, fLatitudeInput, fLongitudeInput, fElevationInput=0.0): | |
try: # Exception handling for invalid latitude input | |
if self._MIN_LATITUDE <= fLatitudeInput <= self._MAX_LATITUDE: | |
self.fLatitude = float(fLatitudeInput) | |
else: | |
raise ValueError("Latitude input not on planet Earth") | |
except ValueError: | |
raise ValueError("Non-numerical input to latitude value") | |
try: # Exception handling for invalid longitude input | |
if self._MIN_LONGITUDE <= fLongitudeInput <= self._MAX_LONGITUDE: | |
self.fLongitude = float(fLongitudeInput) | |
else: | |
raise ValueError("Longitude input not on planet Earth") | |
except ValueError: | |
raise ValueError("Non-numerical input to longitude value") | |
try: # Exception handling for invalid elevation input | |
if self._MIN_ELEVATION <= fElevationInput <= self._MAX_ELEVATION: | |
self.fElevation = float(fElevationInput) | |
else: | |
raise ValueError("Elevation input not on the surface of the Earth") | |
except ValueError: | |
raise ValueError("Non-numerical input to elevation value") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment