Пример #1
0
    def transform(source_cordinate: CrsCoordinate,
                  target_crs_projection: CrsProjection) -> CrsCoordinate:
        if (source_cordinate.get_crs_projection() == target_crs_projection):
            return source_cordinate

        _transFormStrategy: _TransformStrategy = None

        # Transform FROM wgs84:
        if (source_cordinate.get_crs_projection().is_wgs84()
                and (target_crs_projection.is_sweref99()
                     or target_crs_projection.is_rt90())):
            _transFormStrategy = _Transformer.transformStrategy_From_WGS84_to_SWEREF99_or_RT90

        # Transform TO wgs84:
        elif (target_crs_projection.is_wgs84()
              and (source_cordinate.get_crs_projection().is_sweref99()
                   or source_cordinate.get_crs_projection().is_rt90())):
            _transFormStrategy = _Transformer.transformStrategy_From_SWEREF99_or_RT90_to_WGS84

        # Transform between two non-wgs84:
        elif ((source_cordinate.get_crs_projection().is_sweref99()
               or source_cordinate.get_crs_projection().is_rt90())
              and (target_crs_projection.is_sweref99()
                   or target_crs_projection.is_rt90())):
            # the only direct transform supported is to/from WGS84, so therefore first transform to wgs84
            _transFormStrategy = _Transformer.transFormStrategy_From_Sweref99OrRT90_to_WGS84_andThenToRealTarget

        return _Transformer._transform_with_explicit_strategy(
            _transFormStrategy, source_cordinate, target_crs_projection)
Пример #2
0
    def transform(self,
                  source_coordinate: CrsCoordinate,
                  final_target_crs_projection: CrsProjection
                  ) -> CrsCoordinate:
        from sweden_crs_transformations.transformation._transformer import _Transformer
        source_coordinate_projection: CrsProjection = source_coordinate.get_crs_projection()
        if (not (
            (source_coordinate_projection.is_sweref99() or source_coordinate_projection.is_rt90())
            and
            (final_target_crs_projection.is_sweref99() or final_target_crs_projection.is_rt90())
        )):
            _Transformer._throwExceptionMessage(source_coordinate.get_crs_projection(), final_target_crs_projection)

        intermediate_crs_projection = CrsProjection.WGS84
        intermediate_wgs84_coordinate = _Transformer.transform(source_coordinate, intermediate_crs_projection)
        return _Transformer.transform(intermediate_wgs84_coordinate, final_target_crs_projection)
    def transform(self, source_coordinate: CrsCoordinate,
                  target_crs_projection: CrsProjection) -> CrsCoordinate:
        source_coordinate_projection: CrsProjection = source_coordinate.get_crs_projection(
        )
        if (not ((source_coordinate_projection.is_wgs84()) and
                 (target_crs_projection.is_sweref99()
                  or target_crs_projection.is_rt90()))):
            from sweden_crs_transformations.transformation._transformer import _Transformer
            _Transformer._throwExceptionMessage(
                source_coordinate.get_crs_projection(), target_crs_projection)

        gaussKreugerParameterObject = _GaussKreugerParameterObject(
            target_crs_projection)
        gaussKreuger = _GaussKreuger(gaussKreugerParameterObject)
        lat_lon: _LatLon = gaussKreuger.geodetic_to_grid(
            source_coordinate.get_latitude_y(),
            source_coordinate.get_longitude_x())
        return CrsCoordinate.create_coordinate(target_crs_projection,
                                               lat_lon.latitude_y,
                                               lat_lon.longitude_x)