From 9c91af0057705632e6a42f1006e20a7c5fe9b15e Mon Sep 17 00:00:00 2001 From: Timo Date: Tue, 14 Jan 2025 00:22:58 +0100 Subject: [PATCH] fixes --- .../export/api/wfsexporter.py | 50 ++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/src/sparqlunicorn_ontdoc/export/api/wfsexporter.py b/src/sparqlunicorn_ontdoc/export/api/wfsexporter.py index c192fe4..e134168 100644 --- a/src/sparqlunicorn_ontdoc/export/api/wfsexporter.py +++ b/src/sparqlunicorn_ontdoc/export/api/wfsexporter.py @@ -3,6 +3,54 @@ class WFSExporter: + @staticmethod + def generateFeatureDescriptions(outpath,deploypath,featurecollectionspaths,version,fsresult): + result=""" +""" + for coll in featurecollectionspaths: + curcoll = None + os.mkdir(outpath + "/wfs/DescribedFeatureType") + if os.path.exists(coll): + with open(coll, 'r', encoding="utf-8") as infile: + curcoll = json.load(infile) + op = outpath + "wfs/DescribeFeatureType/request=DescribedFeatureType&version="+version+"&typeName=" + coll.replace(outpath, "").replace("index.geojson", "") + os.mkdir(op) + op = op.replace(".geojson", "") + op = op.replace("//", "/") + if not os.path.exists(op): + os.makedirs(op) + opweb = op.replace(outpath, deploypath) + opwebcoll = opweb + if opwebcoll.endswith("/"): + opwebcoll = opwebcoll[0:-1] + opwebcoll = opwebcoll.replace("//", "/") + collid=coll.replace(outpath, "").replace("index.geojson", "").replace(".geojson", "")[1:] + currentcollection = {"title": featurecollectionspaths[coll]["name"], + "id": collid, + "links": [], "itemType": "feature"} + if "bbox" in curcoll: + currentcollection["extent"] = {"spatial": {"bbox": curcoll["bbox"]}} + if "crs" in curcoll: + currentcollection["crs"] = curcoll["crs"] + if "extent" in currentcollection: + currentcollection["extent"]["spatial"]["crs"] = curcoll["crs"] + if "features" in curcoll and len(curcoll["features"])>0: + firstfeat=curcoll["features"][0] + if "properties" in firstfeat: + result+="" + for prop in firstfeat["properties"]: + result+=f"""""" + result+="" + f = open(op + "/index.json", "w", encoding="utf-8") + f.write(json.dumps(currentcollection)) + f.close() + f = open(op + "/index.html", "w", encoding="utf-8") + f.write("

" + featurecollectionspaths[coll][ + "name"] + "

" #+ str(curcollrow) + + "
CollectionLinks
") + f.close() + + @staticmethod def generateFeatureList(outpath,deploypath,featurecollectionspaths,version,fsresult): apijson={} @@ -156,7 +204,7 @@ def generateWFSPages11(outpath,deploypath,featurecollectionspaths,license): - + results hits