4
4
class WFSExporter :
5
5
6
6
@staticmethod
7
- def generateWFSPages (outpath ,deploypath , featurecollectionspaths ,license ):
8
- #os.mkdir(outpath+"/wfs")
9
- apihtml = "<!DOCTYPE html><html lang=\" en\" ><head><meta charset=\" utf-8\" /><meta name=\" viewport\" content=\" width=device-width, initial-scale=1\" /><metaname=\" description\" content=\" SwaggerUI\" /><title>SwaggerUI</title><link rel=\" stylesheet\" href=\" https://unpkg.com/swagger-ui-dist/swagger-ui.css\" /></head><body><div id=\" swagger-ui\" ></div><script src=\" https://unpkg.com/swagger-ui-dist/swagger-ui-bundle.js\" crossorigin></script><script>const swaggerUrl = \" " + str (
10
- deploypath ) + "/api/index.json\" ; const apiUrl = \" " + str (deploypath ) + "/\" ; window.onload = () => {let swaggerJson = fetch(swaggerUrl).then(r => r.json().then(j => {j.servers[0].url = apiUrl; window.ui = SwaggerUIBundle({spec: j,dom_id: '#swagger-ui'});}));};</script></body></html>"
11
- apijson = {"openapi" : "3.0.1" , "info" : {"title" : str (deploypath ) + " Feature Collections" ,
12
- "description" : "Feature Collections of " + str (deploypath )},
13
- "servers" : [{"url" : str (deploypath )}], "paths" : {}}
14
- getcapabilities = f"""<?xml version="1.0" encoding="UTF-8" ?>
15
- <wfs:WFS_Capabilities xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-capabilities.xsd https://www.baysis.bayern.de/gis/admin/services/BAYSIS_Strassennetz/MapServer/WFSServer https://www.baysis.bayern.de/gis/services/wfs/BAYSIS_Strassennetz/MapServer/WFSServer?service=wfs%26version=1.0.0%26request=DescribeFeatureType" version="1.0.0">
16
- <wfs:Service>
17
- <wfs:Name>Static WFS</wfs:Name>
18
- <wfs:Title>Static WFS for { deploypath } </wfs:Title>
19
- <wfs:Abstract>This Static WFS exposes geodata included in the knowledge grap for the inclusion into GIS applications.</wfs:Abstract>
20
- <wfs:Keywords>{ deploypath } </wfs:Keywords>
21
- <wfs:OnlineResource>{ deploypath } </wfs:OnlineResource>
22
- <wfs:Fees>none</wfs:Fees>
23
- <wfs:AccessConstraints>{ license } </wfs:AccessConstraints>
24
- </wfs:Service>
25
- <wfs:Capability>
26
- <wfs:Request>
27
- <wfs:GetCapabilities>
28
- <wfs:DCPType><wfs:HTTP><wfs:Get onlineResource="{ deploypath } /wfs?"/></wfs:HTTP></wfs:DCPType>
29
- <wfs:DCPType><wfs:HTTP><wfs:Post onlineResource="{ deploypath } /wfs?"/></wfs:HTTP></wfs:DCPType>
30
- </wfs:GetCapabilities>
31
- <wfs:DescribeFeatureType>
32
- <wfs:SchemaDescriptionLanguage><wfs:XMLSCHEMA/></wfs:SchemaDescriptionLanguage>
33
- <wfs:DCPType><wfs:HTTP><wfs:Get onlineResource="{ deploypath } /wfs?"/></wfs:HTTP></wfs:DCPType>
34
- <wfs:DCPType><wfs:HTTP><wfs:Post onlineResource="{ deploypath } /wfs"/></wfs:HTTP></wfs:DCPType>
35
- </wfs:DescribeFeatureType>
36
- <wfs:GetFeature>
37
- <wfs:ResultFormat><wfs:JSON/></wfs:ResultFormat>
38
- <wfs:DCPType><wfs:HTTP><wfs:Get onlineResource="{ deploypath } /wfs?"/></wfs:HTTP></wfs:DCPType>
39
- <wfs:DCPType><wfs:HTTP><wfs:Post onlineResource="{ deploypath } /wfs"/></wfs:HTTP></wfs:DCPType>
40
- </wfs:GetFeature>
41
- </wfs:Request>
42
- </wfs:Capability>
43
- <wfs:FeatureTypeList><wfs:Operations><wfs:Query/></wfs:Operations>
44
- """
7
+ def generateWFSPages10 (outpath ,deploypath ,featurecollectionspaths ,license ):
8
+ getcapabilities = f"""<?xml version="1.0" encoding="UTF-8" ?>
9
+ <wfs:WFS_Capabilities xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-capabilities.xsd https://www.baysis.bayern.de/gis/admin/services/BAYSIS_Strassennetz/MapServer/WFSServer https://www.baysis.bayern.de/gis/services/wfs/BAYSIS_Strassennetz/MapServer/WFSServer?service=wfs%26version=1.0.0%26request=DescribeFeatureType" version="1.0.0">
10
+ <wfs:Service>
11
+ <wfs:Name>Static WFS</wfs:Name>
12
+ <wfs:Title>Static WFS for { deploypath } </wfs:Title>
13
+ <wfs:Abstract>This Static WFS exposes geodata included in the knowledge grap for the inclusion into GIS applications.</wfs:Abstract>
14
+ <wfs:Keywords>{ deploypath } </wfs:Keywords>
15
+ <wfs:OnlineResource>{ deploypath } </wfs:OnlineResource>
16
+ <wfs:Fees>none</wfs:Fees>
17
+ <wfs:AccessConstraints>{ license } </wfs:AccessConstraints>
18
+ </wfs:Service>
19
+ <wfs:Capability>
20
+ <wfs:Request>
21
+ <wfs:GetCapabilities>
22
+ <wfs:DCPType><wfs:HTTP><wfs:Get onlineResource="{ deploypath } /wfs?"/></wfs:HTTP></wfs:DCPType>
23
+ <wfs:DCPType><wfs:HTTP><wfs:Post onlineResource="{ deploypath } /wfs?"/></wfs:HTTP></wfs:DCPType>
24
+ </wfs:GetCapabilities>
25
+ <wfs:DescribeFeatureType>
26
+ <wfs:SchemaDescriptionLanguage><wfs:XMLSCHEMA/></wfs:SchemaDescriptionLanguage>
27
+ <wfs:DCPType><wfs:HTTP><wfs:Get onlineResource="{ deploypath } /wfs?"/></wfs:HTTP></wfs:DCPType>
28
+ <wfs:DCPType><wfs:HTTP><wfs:Post onlineResource="{ deploypath } /wfs"/></wfs:HTTP></wfs:DCPType>
29
+ </wfs:DescribeFeatureType>
30
+ <wfs:GetFeature>
31
+ <wfs:ResultFormat><wfs:JSON/></wfs:ResultFormat>
32
+ <wfs:DCPType><wfs:HTTP><wfs:Get onlineResource="{ deploypath } /wfs?"/></wfs:HTTP></wfs:DCPType>
33
+ <wfs:DCPType><wfs:HTTP><wfs:Post onlineResource="{ deploypath } /wfs"/></wfs:HTTP></wfs:DCPType>
34
+ </wfs:GetFeature>
35
+ </wfs:Request>
36
+ </wfs:Capability>
37
+ <wfs:FeatureTypeList><wfs:Operations><wfs:Query/></wfs:Operations>
38
+ """
45
39
for coll in featurecollectionspaths :
46
40
curcoll = None
47
41
if os .path .exists (coll ):
48
42
with open (coll , 'r' , encoding = "utf-8" ) as infile :
49
43
curcoll = json .load (infile )
50
- curftype = f"""
51
- <wfs:FeatureType>
52
- <wfs:Name>{ str (coll .replace (outpath ,"" ).replace ("index.geojson" , "" ).replace (".geojson" , "" )).rstrip ("/" )} </wfs:Name>
53
- <wfs:Title>{ str (coll .replace (outpath ,"" ).replace ("index.geojson" , "" ).replace (".geojson" , "" )).rstrip ("/" )} </wfs:Title>
54
- <wfs:Abstract>FeatureCollection { str (coll .replace (outpath ,"" ).replace ("index.geojson" , "" ).replace (".geojson" , "" )).rstrip ("/" )} </wfs:Abstract>
55
- """
44
+ curftype = f"""
45
+ <wfs:FeatureType>
46
+ <wfs:Name>{ str (coll .replace (outpath , "" ).replace ("index.geojson" , "" ).replace (".geojson" , "" )).rstrip ("/" )} </wfs:Name>
47
+ <wfs:Title>{ str (coll .replace (outpath , "" ).replace ("index.geojson" , "" ).replace (".geojson" , "" )).rstrip ("/" )} </wfs:Title>
48
+ <wfs:Abstract>FeatureCollection { str (coll .replace (outpath , "" ).replace ("index.geojson" , "" ).replace (".geojson" , "" )).rstrip ("/" )} </wfs:Abstract>
49
+ """
56
50
if "crs" in curcoll :
57
- curftype += f"""<wfs:SRS>{ curcoll ["crs" ]} </wfs:SRS>"""
51
+ curftype += f"""<wfs:SRS>{ curcoll ["crs" ]} </wfs:SRS>"""
58
52
else :
59
- curftype += "<wfs:SRS>EPSG:4326</wfs:SRS>"
53
+ curftype += "<wfs:SRS>EPSG:4326</wfs:SRS>"
60
54
if "extent" in curcoll :
61
- bboxcoords = curcoll ["extent" ]["spatial" ]["bbox" ][0 ]
62
- curftype += f"""<wfs:LatLongBoundingBox minx="{ bboxcoords [0 ]} " miny="{ bboxcoords [1 ]} " maxx="{ bboxcoords [2 ]} " maxy="{ bboxcoords [3 ]} "/>"""
63
- curftype += "</wfs:FeatureType>"
64
- getcapabilities += curftype + "\n "
55
+ bboxcoords = curcoll ["extent" ]["spatial" ]["bbox" ][0 ]
56
+ curftype += f"""<wfs:LatLongBoundingBox minx="{ bboxcoords [0 ]} " miny="{ bboxcoords [1 ]} " maxx="{ bboxcoords [2 ]} " maxy="{ bboxcoords [3 ]} "/>"""
57
+ curftype += "</wfs:FeatureType>"
58
+ getcapabilities += curftype + "\n "
65
59
getcapabilities += f"""</wfs:FeatureTypeList>
66
- <ogc:Filter_Capabilities></ogc:Filter_Capabilities>
67
- </wfs:WFS_Capabilities>"""
68
- print ("SAVE WFS GETCAPABILITIES: " + str (outpath + "/wfs?request=GetCapabilities&service=WFS&version=1.0.0" ))
60
+ <ogc:Filter_Capabilities></ogc:Filter_Capabilities>
61
+ </wfs:WFS_Capabilities>"""
62
+ print ("SAVE WFS GETCAPABILITIES: " + str (outpath + "/wfs?request=GetCapabilities&service=WFS&version=1.0.0" ))
69
63
f = open (outpath + "/wfs?request=GetCapabilities&service=WFS&version=1.0.0" , "w" , encoding = "utf-8" )
70
64
f .write (getcapabilities )
71
- f .close ()
65
+ f .close ()
66
+
67
+ @staticmethod
68
+ def generateWFSPages (outpath ,deploypath , featurecollectionspaths ,license ,wfsversion = "1.0.0" ):
69
+ #os.mkdir(outpath+"/wfs")
70
+ apihtml = "<!DOCTYPE html><html lang=\" en\" ><head><meta charset=\" utf-8\" /><meta name=\" viewport\" content=\" width=device-width, initial-scale=1\" /><metaname=\" description\" content=\" SwaggerUI\" /><title>SwaggerUI</title><link rel=\" stylesheet\" href=\" https://unpkg.com/swagger-ui-dist/swagger-ui.css\" /></head><body><div id=\" swagger-ui\" ></div><script src=\" https://unpkg.com/swagger-ui-dist/swagger-ui-bundle.js\" crossorigin></script><script>const swaggerUrl = \" " + str (
71
+ deploypath ) + "/api/index.json\" ; const apiUrl = \" " + str (deploypath ) + "/\" ; window.onload = () => {let swaggerJson = fetch(swaggerUrl).then(r => r.json().then(j => {j.servers[0].url = apiUrl; window.ui = SwaggerUIBundle({spec: j,dom_id: '#swagger-ui'});}));};</script></body></html>"
72
+ apijson = {"openapi" : "3.0.1" , "info" : {"title" : str (deploypath ) + " Feature Collections" ,
73
+ "description" : "Feature Collections of " + str (deploypath )},
74
+ "servers" : [{"url" : str (deploypath )}], "paths" : {}}
75
+ if wfsversion == "1.0.0" :
76
+ WFSExporter .generateWFSPages10 ()
0 commit comments