def __init__(self, system, code): # Get the zone constants. self.const = get_projection(system, code) if self.const['TYPE'] != 'TM': raise TypeError('Expected Transverse Mercator, found \'{0}\''.format(self.const['TYPE'])) # Coordinate system constants a = 6378137.0 # semi-major radius of ellipsoid, meters (WGS84) # f = 1.0 / 298.257223563 # flattening (WGS84) f = 1.0 / 298.25722210088 # flattening (GRS80) e2 = 2.0*f - f*f # first eccentricity squared e12 = e2 / (1.0 - e2) # second eccentricity squared n = f / (2.0 - f) n2 = n * n n3 = n2 * n n4 = n3 * n r = a * (1.0 - n) * (1.0 - n2) * (1.0 + 9.0 * n2 / 4.0 + 225.0 * n4 / 64.0) # Defining coordinate system constants for the zone P0 = dms_radians(self.const['P0']) # Latitude of origin, radians (Bb) M0 = dms_radians(self.const['M0']) # Central meridian, radians (Lo) X0 = float(self.const['X0']) # False northing of latitude of origin, meters (No) Y0 = float(self.const['Y0']) # False easting of central meridian, meters (Eo) K0 = 1.0 - 1.0/float(self.const['SF']) # Grid scale factor assigned to central meridian # Calculate the derived coordinate system constants. u2 = -3.0 * n / 2.0 + 9.0 * n3 / 16.0 u4 = 15.0 * n2 / 16.0 - 15.0 * n4 / 32.0 u6 = -35.0 * n3 / 48.0 u8 = 315.0 * n4 / 512.0 u0 = 2.0 * (u2 - 2.0 * u4 + 3.0 * u6 - 4.0 * u8) u2 = 8.0 * (u4 - 4.0 * u6 + 10.0 * u8) u4 = 32.0 * (u6 - 6.0 * u8) u6 = 128.0 * u8 v2 = 3.0 * n / 2.0 - 27.0 * n3 / 32.0 v4 = 21.0 * n2 / 16.0 - 55.0 * n4 / 32.0 v6 = 151.0 * n3 / 96.0 v8 = 1097.0 * n4 / 512.0 v0 = 2.0 * (v2 - 2.0 * v4 + 3.0 * v6 - 4.0 * v8) v2 = 8.0 * (v4 - 4.0 * v6 + 10.0 * v8) v4 = 32.0 * (v6 - 6.0 * v8) v6 = 128.0 * v8 sinp = math.sin(P0) cosp = math.cos(P0) cosp2 = cosp * cosp S0 = K0 * (P0 + sinp * cosp * (u0 + cosp2 * (u2 + cosp2 * (u4 + u6 * cosp2)))) * r # Save off the locals. self._locals = [P0, M0, X0, Y0, K0, a, e2, e12, r, u0, u2, u4, u6, v0, v2, v4, v6, S0]
def __init__(self, system, code): # Get the zone constants. self.const = get_projection(system, code) if self.const['TYPE'] != 'LC': raise TypeError('Expected Lambert, found \'{0}\''.format(self.const['TYPE'])) # Coordinate system constants # A = 6378206.4 # major radius of ellipsoid, meters (NAD27) # E = 0.08227185422 # eccentricity of ellipsoid (NAD27) A = 6378137.0 # major radius of ellipsoid, meters (NAD83) E = 0.08181922146 # eccentricity of ellipsoid (NAD83) PI4 = math.pi / 4.0 PI2 = math.pi / 2.0 # Defining coordinate system constants for the zone P0 = dms_radians(self.const['P0']) # latitude of origin, radians (Bb) M0 = dms_radians(self.const['M0']) # central meridian, radians (Lo) X0 = float(self.const['X0']) # False northing of latitude of origin, meters (Nb) Y0 = float(self.const['Y0']) # False easting of central meridian, meters (Eo) P1 = dms_radians(self.const['P1']) # latitude of first standard parallel, radians (Bs) P2 = dms_radians(self.const['P2']) # latitude of second standard parallel, radians (Bn) # Calculate the derived coordinate system constants. m1 = math.cos(P1) / math.sqrt(1.0 - math.pow(E * math.sin(P1), 2.0)) m2 = math.cos(P2) / math.sqrt(1.0 - math.pow(E * math.sin(P2), 2.0)) t1 = (math.tan(PI4 - P1 / 2.0) / math.pow((1.0 - E * math.sin(P1)) / (1.0 + E * math.sin(P1)), E / 2.0)) t2 = (math.tan(PI4 - P2 / 2.0) / math.pow( (1.0 - E * math.sin(P2)) / (1.0 + E * math.sin(P2)), E / 2.0)) t0 = (math.tan(PI4 - P0 / 2.0) / math.pow((1.0 - E * math.sin(P0)) / (1.0 + E * math.sin(P0)), E / 2.0)) n = math.log(m1 / m2) / math.log(t1 / t2) F = m1 / (n * math.pow(t1, n)) rho0 = A * F * math.pow(t0, n) # Save off the locals. self._locals = [A, E, PI4, PI2, P0, M0, X0, Y0, P1, P2, m1, m2, t1, t2, t0, n, F, rho0]