Esempio n. 1
0
    def testBounds(self):
        p = proj.Projection('epsg:3005')
        b = p.bounds
        assertClose(self, 34758, int(b.west))
        assertClose(self, 359549, int(b.south))
        assertClose(self, 1883159, int(b.east))
        assertClose(self, 1735541, int(b.north))
        assert p == b.proj

        b = p.geobounds
        assertClose(self, -139, int(b.west))
        assertClose(self, 48, int(b.south))
        assertClose(self, -114, int(b.east))
        assertClose(self, 60, int(b.north))
        assert proj.Projection('epsg:4326') == b.proj
Esempio n. 2
0
    def __init__(self,
                 west=None,
                 south=None,
                 east=None,
                 north=None,
                 prj=None,
                 env=None):
        if prj:
            prj = proj.Projection(prj)

        if env:
            if isinstance(env, GeneralEnvelope):
                env = ReferencedEnvelope(env)

            if prj:
                ReferencedEnvelope.__init__(self, env, prj._crs)
            elif hasattr(env, 'crs') and env.crs():
                ReferencedEnvelope.__init__(self, env, env.crs())
            else:
                ReferencedEnvelope.__init__(self, env, None)
        else:
            if west != None:
                ReferencedEnvelope.__init__(self, west, east, south, north,
                                            prj._crs if prj else None)
            elif prj:
                ReferencedEnvelope.__init__(self, prj._crs)
            else:
                ReferencedEnvelope.__init__(self)
Esempio n. 3
0
    def reproject(self, prj, name=None):
        """
    Reprojects a layer.

    *prj* is the destination :class:`Projection <geoscript.proj.Projection>` 

    *name* is the optional name as a ``str`` to assign to the resulting reprojected layer.

    This method returns a newly reprojected layer. The new layer is create within the containing workspace of the original layer.

    >>> from geoscript import geom
    >>> l = Layer()
    >>> l.proj = 'epsg:4326'
    >>> l.add([geom.Point(-111, 45.7)])
    >>> 
    >>> l2 = l.reproject('epsg:26912')
    >>> l2.proj.id
    'EPSG:26912'

    >>> [f.geom for f in l2.features()]
    [POINT (499999.42501775385 5060716.092032814)]
    """

        prj = proj.Projection(prj)
        name = name or Layer._newname()

        # reproject the schema
        rschema = self.schema.reproject(prj, name)

        # create the reprojected layer
        rlayer = self.workspace.create(schema=rschema)

        # create a query specifying that feautres should be reproje`cted
        q = DefaultQuery(self.name, Filter.PASS._filter)
        if self.proj:
            q.coordinateSystem = self.proj._crs
        q.coordinateSystemReproject = prj._crs

        fc = self._source.getFeatures(q)
        i = fc.features()

        # loop through features and add to new reprojeced layer
        while i.hasNext():
            f = feature.Feature(schema=rschema, f=i.next())
            rlayer.add(f)

        fc.close(i)
        return rlayer
Esempio n. 4
0
    def __init__(self,
                 west=None,
                 south=None,
                 east=None,
                 north=None,
                 prj=None,
                 env=None):
        if prj:
            prj = proj.Projection(prj)

        if env:
            if prj:
                ReferencedEnvelope.__init__(self, env, prj._crs)
            else:
                ReferencedEnvelope.__init__(self, env, None)
        else:
            if west != None:
                ReferencedEnvelope.__init__(self, west, east, south, north,
                                            prj._crs if prj else None)
            elif prj:
                ReferencedEnvelope.__init__(self, prj._crs)
            else:
                ReferencedEnvelope.__init__(self)
Esempio n. 5
0
 def setUp(self):
     ws = H2('work/states')
     self.l = ws.get('states')
     self.l.proj = proj.Projection('epsg:4326')