GenericMappingTools / GMT.jl

Generic Mapping Tools Library Wrapper for Julia
Other
193 stars 28 forks source link

wmsread fails on wms=wmsinfo("http://ows.mundialis.de/services/service") #1500

Open robot144 opened 3 weeks ago

robot144 commented 3 weeks ago

Hi,

When trying the following code: `wms=wmsinfo("http://ows.mundialis.de/services/service") img = wmsread(wms, layer="OSM-WMS", region=(0.0,2.0,50.0,52.0), size=(800,800)); imshow(img)

` The image is mostly blue. After some searching this seems to result from wmsinfo setting the wms.layer[i].srs to the wrong values. When I overrule the srs by "EPSG:4326" then it does work. Not that the struct for a layer is not mutable, so I used:

#  struct GMT.WMSlayer
#  name          :: String
#  title         :: String
#  srs           :: String
#  crs           :: String
#  bbox          :: NTuple{4, Float64}
#  imgformat     :: String
#  tilesize      :: Int64
#  overviewcount :: Int64
#  resolution    :: Float64
#  tiled         :: Bool
#  transparent   :: Bool
l1_new=GMT.WMSlayer(l1.name,l1.title,"EPSG:4326",l1.crs,l1.bbox,l1.imgformat,l1.tilesize,l1.overviewcount,l1.resolution,l1.tiled,l1.transparent)
wms.layer[1]=l1_new

I guess that the parsing of the variable f fails in function wmsinfo in file webmapserver.jl around line 51 fails. It would be nice if this could be fixed, but I don't dare to try this myself, since I am new to GMT.jl

Many thanks for the nice package, Martin

joa-quim commented 3 weeks ago

Hi Martin, thanks for looking for the error. I’m on mobile so can’t check it right now. But don’t be afraid to screw anything in the code. You can’t. If you fork the project and install it locally you can do all experiments you want and if you manage to fix it than you can submit a PR (Pull Request).

joa-quim commented 3 weeks ago

OK, found things. There is no parsing error. What happens is that the data is in Spherical Mercator and you are asking a region in geographic. Apparently the server also accepts that wee pass in a SRS on geographics and that is why your patch worked. Don't know if this is a general rule but I added a option to wmsread that forces setting the SRS to EPSG:4326. In master you can now do

img = wmsread(wms, layer="OSM-WMS", region=(0.0,2.0,50.0,52.0), size=(800,800), forcegeog=true);    # or geog=true