From 9248630d79b27ebe2e75679feec8b7b3f8bf07bc Mon Sep 17 00:00:00 2001 From: Timo Date: Mon, 13 Jan 2025 12:53:58 +0100 Subject: [PATCH] wfs test --- .../export/api/wfsexporter.py | 113 +++++++++--------- 1 file changed, 59 insertions(+), 54 deletions(-) diff --git a/src/sparqlunicorn_ontdoc/export/api/wfsexporter.py b/src/sparqlunicorn_ontdoc/export/api/wfsexporter.py index 942488c3..fcd72d7b 100644 --- a/src/sparqlunicorn_ontdoc/export/api/wfsexporter.py +++ b/src/sparqlunicorn_ontdoc/export/api/wfsexporter.py @@ -4,68 +4,73 @@ class WFSExporter: @staticmethod - def generateWFSPages(outpath,deploypath, featurecollectionspaths,license): - #os.mkdir(outpath+"/wfs") - apihtml = "SwaggerUI
" - apijson = {"openapi": "3.0.1", "info": {"title": str(deploypath) + " Feature Collections", - "description": "Feature Collections of " + str(deploypath)}, - "servers": [{"url": str(deploypath)}], "paths": {}} - getcapabilities=f""" - - - Static WFS - Static WFS for {deploypath} - This Static WFS exposes geodata included in the knowledge grap for the inclusion into GIS applications. - {deploypath} - {deploypath} - none - {license} - - - - - - - - - - - - - - - - - - - - - """ + def generateWFSPages10(outpath,deploypath,featurecollectionspaths,license): + getcapabilities = f""" + + + Static WFS + Static WFS for {deploypath} + This Static WFS exposes geodata included in the knowledge grap for the inclusion into GIS applications. + {deploypath} + {deploypath} + none + {license} + + + + + + + + + + + + + + + + + + + + + """ for coll in featurecollectionspaths: curcoll = None if os.path.exists(coll): with open(coll, 'r', encoding="utf-8") as infile: curcoll = json.load(infile) - curftype=f""" - - {str(coll.replace(outpath,"").replace("index.geojson", "").replace(".geojson", "")).rstrip("/")} - {str(coll.replace(outpath,"").replace("index.geojson", "").replace(".geojson", "")).rstrip("/")} - FeatureCollection {str(coll.replace(outpath,"").replace("index.geojson", "").replace(".geojson", "")).rstrip("/")} - """ + curftype = f""" + + {str(coll.replace(outpath, "").replace("index.geojson", "").replace(".geojson", "")).rstrip("/")} + {str(coll.replace(outpath, "").replace("index.geojson", "").replace(".geojson", "")).rstrip("/")} + FeatureCollection {str(coll.replace(outpath, "").replace("index.geojson", "").replace(".geojson", "")).rstrip("/")} + """ if "crs" in curcoll: - curftype+=f"""{curcoll["crs"]}""" + curftype += f"""{curcoll["crs"]}""" else: - curftype+="EPSG:4326" + curftype += "EPSG:4326" if "extent" in curcoll: - bboxcoords=curcoll["extent"]["spatial"]["bbox"][0] - curftype+=f"""""" - curftype+="" - getcapabilities+=curftype+"\n" + bboxcoords = curcoll["extent"]["spatial"]["bbox"][0] + curftype += f"""""" + curftype += "" + getcapabilities += curftype + "\n" getcapabilities += f""" - -""" - print("SAVE WFS GETCAPABILITIES: "+str(outpath + "/wfs?request=GetCapabilities&service=WFS&version=1.0.0")) + + """ + print("SAVE WFS GETCAPABILITIES: " + str(outpath + "/wfs?request=GetCapabilities&service=WFS&version=1.0.0")) f = open(outpath + "/wfs?request=GetCapabilities&service=WFS&version=1.0.0", "w", encoding="utf-8") f.write(getcapabilities) - f.close() \ No newline at end of file + f.close() + + @staticmethod + def generateWFSPages(outpath,deploypath, featurecollectionspaths,license,wfsversion="1.0.0"): + #os.mkdir(outpath+"/wfs") + apihtml = "SwaggerUI
" + apijson = {"openapi": "3.0.1", "info": {"title": str(deploypath) + " Feature Collections", + "description": "Feature Collections of " + str(deploypath)}, + "servers": [{"url": str(deploypath)}], "paths": {}} + if wfsversion=="1.0.0": + WFSExporter.generateWFSPages10()