@@ -91,13 +91,17 @@ def get_tile_wms(tile, imagery, folder, imagery_offset):
9191 """
9292 Read a WMS endpoint with query parameters corresponding to a TMS tile
9393
94- Converts the tile boundaries to the spatial reference system (SRS) specified
95- by the WMS query parameter.
94+ Converts the tile boundaries to the spatial/coordinate reference system
95+ (SRS or CRS) specified by the WMS query parameter.
9696 """
9797 # retrieve the necessary parameters from the query string
9898 query_dict = parse_qs (imagery .lower ())
99- image_format = query_dict ['format' ][0 ].split ('/' )[1 ]
100- wms_srs = query_dict ['srs' ][0 ]
99+ image_format = query_dict .get ('format' )[0 ].split ('/' )[1 ]
100+ wms_version = query_dict .get ('version' )[0 ]
101+ if wms_version == '1.3.0' :
102+ wms_srs = query_dict .get ('crs' )[0 ]
103+ else :
104+ wms_srs = query_dict .get ('srs' )[0 ]
101105
102106 # find our tile bounding box
103107 bound = bounds (* [int (t ) for t in tile .split ('-' )])
@@ -107,7 +111,10 @@ def get_tile_wms(tile, imagery, folder, imagery_offset):
107111 # project the tile bounding box from lat/lng to WMS SRS
108112 tile_ll_proj = transform (p1 , p2 , bound .west , bound .south )
109113 tile_ur_proj = transform (p1 , p2 , bound .east , bound .north )
110- bbox = tile_ll_proj + tile_ur_proj
114+ if wms_version == '1.3.0' :
115+ bbox = tile_ll_proj [::- 1 ] + tile_ur_proj [::- 1 ]
116+ else :
117+ bbox = tile_ll_proj + tile_ur_proj
111118
112119 # request the image with the transformed bounding box and save
113120 wms_url = imagery .replace ('{bbox}' , ',' .join ([str (b ) for b in bbox ]))
0 commit comments