예제 #1
0
class Projection:

    def __init__(self, params, units):
        self.units = units
        self.units_factor = units_factor(units)

        if params.type == ProjectionParams.TYPE_LC:
            self._projection = ProjectionLambertConic(params)
        elif params.type == ProjectionParams.TYPE_TM:
            self._projection = ProjectionTransverseMercator(params)
        else:
            raise ProjectionTypeError('Bad projection type: {0}'.format(params.type))

    def to_geographic(self, x, y):
        return self._projection.to_geographic(x * self.units_factor, y * self.units_factor)

    def theta(self, x, y):
        return self._projection.theta(x * self.units_factor, y * self.units_factor)

    def k(self, x, y):
        return self._projection.k(x * self.units_factor, y * self.units_factor)

    def to_grid(self, lat, lon):
        x, y = self._projection.to_grid(lat, lon)
        return x / self.units_factor, y / self.units_factor
예제 #2
0
    def __init__(self, params, units):
        self.units = units
        self.units_factor = units_factor(units)

        if params.type == ProjectionParams.TYPE_LC:
            self._projection = ProjectionLambertConic(params)
        elif params.type == ProjectionParams.TYPE_TM:
            self._projection = ProjectionTransverseMercator(params)
        else:
            raise ProjectionTypeError('Bad projection type: {0}'.format(params.type))