Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(18)  |  Call(14)  |  Derive(0)  |  Import(4)

        def transform_geometry(from_srs, to_srs, geometry):
    transf = partial(transform_xy, from_srs, to_srs)

    if geometry.type == 'Polygon':
        return transform_polygon(transf, geometry)

    if geometry.type == 'MultiPolygon':
        return transform_multipolygon(transf, geometry)

    raise ValueError('cannot transform %s' % geometry.type)
        


src/m/a/MapProxy-1.6.0/mapproxy/util/coverage.py   MapProxy(Download)
from mapproxy.grid import bbox_intersects, bbox_contains
from mapproxy.util.py import cached_property
from mapproxy.util.geom import (
    require_geom_support,
    load_polygon_lines,
    def _geom_in_coverage_srs(self, geom, srs):
        if isinstance(geom, shapely.geometry.base.BaseGeometry):
            if srs != self.srs:
                geom = transform_geometry(srs, self.srs, geom)
        elif len(geom) == 2:
    def transform_to(self, srs):
        if srs == self.srs:
            return self
 
        geom = transform_geometry(self.srs, srs, self.geom)

src/m/a/mapproxy-HEAD/mapproxy/util/coverage.py   mapproxy(Download)
from mapproxy.grid import bbox_intersects, bbox_contains
from mapproxy.util.py import cached_property
from mapproxy.util.geom import (
    require_geom_support,
    load_polygon_lines,
    def _geom_in_coverage_srs(self, geom, srs):
        if isinstance(geom, shapely.geometry.base.BaseGeometry):
            if srs != self.srs:
                geom = transform_geometry(srs, self.srs, geom)
        elif len(geom) == 2:
    def transform_to(self, srs):
        if srs == self.srs:
            return self
 
        geom = transform_geometry(self.srs, srs, self.geom)

src/m/a/MapProxy-1.6.0/mapproxy/test/unit/test_geom.py   MapProxy(Download)
 
from mapproxy.srs import SRS, bbox_equals
from mapproxy.util.geom import (
    load_polygons,
    transform_geometry,
    def test_polygon_transf(self):
        p1 = shapely.geometry.Polygon([(0, 0), (10, 0), (10, 10), (0, 10)])
 
        p2 = transform_geometry(SRS(4326), SRS(900913), p1)
        assert p2.contains(shapely.geometry.Point((1000000, 1000000)))
        p3 = transform_geometry(SRS(900913), SRS(4326), p2)
        mp1 = shapely.geometry.MultiPolygon([p1, p2])
 
        mp2 = transform_geometry(SRS(4326), SRS(900913), mp1)
        assert mp2.contains(shapely.geometry.Point((1000000, 1000000)))
        assert not mp2.contains(shapely.geometry.Point((2000000, 2000000)))
        assert mp2.contains(shapely.geometry.Point((3000000, 3000000)))
 
        mp3 = transform_geometry(SRS(900913), SRS(4326), mp2)

src/m/a/mapproxy-HEAD/mapproxy/test/unit/test_geom.py   mapproxy(Download)
 
from mapproxy.srs import SRS, bbox_equals
from mapproxy.util.geom import (
    load_polygons,
    transform_geometry,
    def test_polygon_transf(self):
        p1 = shapely.geometry.Polygon([(0, 0), (10, 0), (10, 10), (0, 10)])
 
        p2 = transform_geometry(SRS(4326), SRS(900913), p1)
        assert p2.contains(shapely.geometry.Point((1000000, 1000000)))
        p3 = transform_geometry(SRS(900913), SRS(4326), p2)
        mp1 = shapely.geometry.MultiPolygon([p1, p2])
 
        mp2 = transform_geometry(SRS(4326), SRS(900913), mp1)
        assert mp2.contains(shapely.geometry.Point((1000000, 1000000)))
        assert not mp2.contains(shapely.geometry.Point((2000000, 2000000)))
        assert mp2.contains(shapely.geometry.Point((3000000, 3000000)))
 
        mp3 = transform_geometry(SRS(900913), SRS(4326), mp2)