def testLayerFields(self): """ postgis.tableFields4esri(ds, tabname, oidfname) returns "fields" JSON """ import postgis ds = postgis.DataSource(self.conn) tabname = 'patching' oidfname = 'gid' res = postgis.tableFields4esri(ds, tabname, oidfname) self.assertIn('type": "esriFieldTypeOID', res) self.assertIn('name": "ptchlenght', res) tabname = 'seisprof' oidfname = 'gid' res = postgis.tableFields4esri(ds, tabname, oidfname) self.assertIn('type": "esriFieldTypeOID', res) tabname = 'flyzone' oidfname = 'gid' res = postgis.tableFields4esri(ds, tabname, oidfname) self.assertIn('type": "esriFieldTypeOID', res) self.assertIn('"objectIdField": "gid"', res)
def getFields(ds, tabname, oidfname): """ Bridge to PostGIS. Extract fields spec in JSON format Args: ds: postgis.DataSource with db connection.cursor; tabname: db table name; oidfname: OBJECTID field name. Returns: JSON text with 'fields' structure according ArcGIS spec http://resources.arcgis.com/en/help/rest/apiref/fslayer.html """ #if 0: ds = postgis.DataSource('') if isinstance(ds, postgis.DataSource): return postgis.tableFields4esri(ds, tabname, oidfname) raise TypeError('Unknown datasource type')