Example #1
0
    def testLayerExtent(self):
        """ postgis.layerRealExtent(ds, tabname, fname) returns "extent" JSON
        """
        import postgis
        ds = postgis.DataSource(self.conn)
        tabname = 'patching'
        fname = 'geog'
        txt1 = u'ymax": 52.99648148'
        txt2 = u'wkid": 4326'
        res = postgis.layerRealExtent(ds, tabname, fname)
        self.assertIn(txt1, res)
        self.assertIn(txt2, res)

        tabname = 'seisprof'
        fname = 'geom'
        txt1 = u'ymax": 81.59710856'
        txt2 = u'wkid": 4326'
        res = postgis.layerRealExtent(ds, tabname, fname)
        self.assertIn(txt1, res)
        self.assertIn(txt2, res)

        tabname = 'flyzone'
        fname = 'geom'
        txt1 = u'"xmax": 158.29704000000001'
        txt2 = u'wkid": 4326'
        res = postgis.layerRealExtent(ds, tabname, fname)
        self.assertIn(txt1, res)
        self.assertIn(txt2, res)
Example #2
0
    def testLayerExtent(self):
        """ postgis.layerRealExtent(ds, tabname, fname) returns "extent" JSON
        """
        import postgis
        ds = postgis.DataSource(self.conn)
        tabname = 'patching'
        fname = 'geog'
        txt1 = u'ymax": 52.99648148'
        txt2 = u'wkid": 4326'
        res = postgis.layerRealExtent(ds, tabname, fname)
        self.assertIn(txt1, res)
        self.assertIn(txt2, res)

        tabname = 'seisprof'
        fname = 'geom'
        txt1 = u'ymax": 81.59710856'
        txt2 = u'wkid": 4326'
        res = postgis.layerRealExtent(ds, tabname, fname)
        self.assertIn(txt1, res)
        self.assertIn(txt2, res)

        tabname = 'flyzone'
        fname = 'geom'
        txt1 = u'"xmax": 158.29704000000001'
        txt2 = u'wkid": 4326'
        res = postgis.layerRealExtent(ds, tabname, fname)
        self.assertIn(txt1, res)
        self.assertIn(txt2, res)
Example #3
0
def getExtent(ds, tabname, fname):
    """ Bridge to PostGIS.
    Extract layer extent in JSON format.

    Args:
        ds: postgis.DataSource with db connection.cursor;
        tabname: db table name;
        fname: geometry field name.

    Returns:
        JSON text with 'extent' structure according ArcGIS spec
        http://resources.arcgis.com/en/help/rest/apiref/geometry.html#envelope
    """
    #if 0: ds = postgis.DataSource('')
    #assert isinstance(ds, postgis.DataSource)
    if isinstance(ds, postgis.DataSource):
        return postgis.layerRealExtent(ds, tabname, fname)
    raise TypeError('Unknown datasource type')
Example #4
0
def getExtent(ds, tabname, fname):
    """ Bridge to PostGIS.
    Extract layer extent in JSON format.

    Args:
        ds: postgis.DataSource with db connection.cursor;
        tabname: db table name;
        fname: geometry field name.

    Returns:
        JSON text with 'extent' structure according ArcGIS spec
        http://resources.arcgis.com/en/help/rest/apiref/geometry.html#envelope
    """
    #if 0: ds = postgis.DataSource('')
    #assert isinstance(ds, postgis.DataSource)
    if isinstance(ds, postgis.DataSource):
        return postgis.layerRealExtent(ds, tabname, fname)
    raise TypeError('Unknown datasource type')