Skip to main content
edited tags
Link
Peilonrayz
  • 43.5k
  • 7
  • 76
  • 155
Spelling
Source Link

The calculates arecalculator is in a file called GenGeo, as this is where I keep lots of little modules like this that may be called again in other programs.

The calculates are in a file called GenGeo, as this is where I keep lots of little modules like this that may be called again in other programs.

The calculator is in a file called GenGeo, as this is where I keep lots of little modules like this that may be called again in other programs.

Updated GenGeo code to have optional Origin Easting and Northing
Source Link
class CmO:
    """
    This class will contain specific code that is required to run a C-O calculation
    This includes range and bearing calc
    """

    def __init__(self, *args, **kwargs):
        """
        :param a_e: initial easting
        :param a_n: initial northing
        """
        self.a_e = kwargs.get('a_e', None)
        self.a_n = kwargs.get('a_n', None)

    def complex_randb(self, r, b):
        """
        An equation that using imaginary numbers to calculate the coordinates of a new
        point from a range and bearing of an old point
 
        :param r: range from original coordinate to new coordinate
        :param b: bearing from original coordinate to new coordinate
        """

        # -b is required as geodetic bearings are opposite to mathematical bearings
        t = complex(cos(radians(-b)), sin(radians(-b))) * complex(0, r)
        delta_easting = t.real
        delta_northing = t.imag

        if self.a_e and self.a_n is not False:

            new_easting = self.a_e + delta_easting
            new_northing = self.a_n + delta_northing

            return new_easting, new_northing

        else:
            return delta_easting, delta_northing
class CmO:
    """
    This class will contain specific code that is required to run a C-O calculation
    This includes range and bearing calc
    """

    def __init__(self, *args, **kwargs):
        """
        :param a_e: initial easting
        :param a_n: initial northing
        """
        self.a_e = kwargs.get('a_e', None)
        self.a_n = kwargs.get('a_n', None)

    def complex_randb(self, r, b):
        """
        An equation that using imaginary numbers to calculate the coordinates of a new
        point from a range and bearing of an old point
 
        :param r: range from original coordinate to new coordinate
        :param b: bearing from original coordinate to new coordinate
        """

        # -b is required as geodetic bearings are opposite to mathematical bearings
        t = complex(cos(radians(-b)), sin(radians(-b))) * complex(0, r)
        delta_easting = t.real
        delta_northing = t.imag

        new_easting = self.a_e + delta_easting
        new_northing = self.a_n + delta_northing

        return new_easting, new_northing
class CmO:
    """
    This class will contain specific code that is required to run a C-O calculation
    This includes range and bearing calc
    """

    def __init__(self, *args, **kwargs):
        """
        :param a_e: initial easting
        :param a_n: initial northing
        """
        self.a_e = kwargs.get('a_e', None)
        self.a_n = kwargs.get('a_n', None)

    def complex_randb(self, r, b):
        """
        An equation that using imaginary numbers to calculate the coordinates of a new
        point from a range and bearing of an old point
        :param r: range from original coordinate to new coordinate
        :param b: bearing from original coordinate to new coordinate
        """

        # -b is required as geodetic bearings are opposite to mathematical bearings
        t = complex(cos(radians(-b)), sin(radians(-b))) * complex(0, r)
        delta_easting = t.real
        delta_northing = t.imag

        if self.a_e and self.a_n is not False:

            new_easting = self.a_e + delta_easting
            new_northing = self.a_n + delta_northing

            return new_easting, new_northing

        else:
            return delta_easting, delta_northing
Source Link
Loading