def getLayerConfig(lyrid): """ Return layermeta.LayerInfo readed from ini file and layer metadata file Args: lyrid: string, ini section name """ ini = mfslib.getIniData(APP) tabname = ini.get(lyrid, 'layer.table') geomfield = ini.get(lyrid, 'layer.geomfield') oidfield = ini.get(lyrid, 'layer.oidfield') res = layermeta.LayerInfo(tabname, geomfield, oidfield) stordir = APP.config['DATA_FILES_ROOTDIR'] text = layermeta.layerMeta(lyrid, stordir) res.setAGInfo(text) return res
def layersList(): """ Layers index page processor. Returns JSON text with FeatureServer description, include layers list. Spec: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Feature_Service/02r3000000z2000000/ """ ini = mfslib.getIniData(APP) lyrs = mfslib.getLyrsList(ini) layers = [] for lid in lyrs: name = ini.get(lid, 'layer.name') layers.append({'id': int(lid), 'name': name}) stordir = APP.config['DATA_FILES_ROOTDIR'] text = layermeta.layerMeta(0, stordir, fname='mfs.index.js') resp = simplejson.loads(text) resp['layers'] = layers return makeResponce(resp)
def layerController(layerid=0): """ Esri API, process requests to layer by Layer ID http://resources.arcgis.com/en/help/rest/apiref/fslayer.html Known requests example .../FeatureServer/0?f=pjson f=json by default """ # layer metadata .../FeatureServer/0?f=pjson ini = mfslib.getIniData(APP) lyrs = mfslib.getLyrsList(ini) if not (str(layerid) in lyrs): resp = esri.errorObject( details=u"Invalid query parameters: layerid %s not in %s" % (layerid, lyrs)) return makeResponce(resp) stordir = APP.config['DATA_FILES_ROOTDIR'] text = layermeta.layerMeta(layerid, stordir) resp = make_response(text) resp.headers['Content-Type'] = 'text/plain;charset=utf-8' return resp