Some tips for WMS users who want to try out the GetFeatureInfo request capability... You can try out WMS requests in your browser. I'll use the demo site at https://manifold.net/ims9 for examples. Start by visiting that site in your browser to see what it's about, and try visiting the location for the Egypt eclipse. A WMS GetMap request creates an image of a specified size that covers the specified bounding box. You can do a GetMap request to generate an image using standard WMS parameters to construct the URL that you enter into the browser, all on one line: https://manifold.net/ims9/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&CRS=EPSG:3857&BBOX=2950000,2620000,4000000,3700000&WIDTH=800&HEIGHT=600&FORMAT=image/png& Click [here] to launch that link. That creates an image roughly the same as the Egypt eclipse location in the HTTP site. Things to note: 1. the image is a PNG that has transparency as a background, not the blue virtual background layer. That's so you can use the layers together with other layers from other sources. If you right click on the image and save it to a PNG file, you can open that file in photoshop or other editor and see how the ocean regions between country areas are transparent. 2. This is using WMS 1.3.0, in which OGC changed some of the parameter names. For example, in 1.3.0 the coordinate system is specified using the CRS parameter and not an SRS parameter. 3. The demo site is in Pseudo Mercator, which is EPSG:3857. The bounding box coords as minx, miny, maxx, maxy numbers are coordinates in Pseudo Mercator. The way I got those in the example was to draw a rectangular area in a Pseudo Mercator drawing as a layer in map with a Bing streets background layer (also in Pseudo Mercator) and then looked at the coordinates of the area's corners in the Info pane. If your map is in a lat lon projection like EPSG EPSG:4326 you can use lat/lon coords, like a bounding box of BBOX=-104,22,-100,26 for a region in Mexico. 4. You don't have to bother specifying the name of the map or layers. GetFeatureInfo Here's a minimum URL to get the attributes for what's under a spot located in the middle of the image created by the GetMap URL cited above (all on the same line): https://manifold.net/ims9/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetFeatureInfo&CRS=EPSG:3857&BBOX=2950000,2620000,4000000,3700000&WIDTH=800&HEIGHT=600&i=400&j=300& INFO_FORMAT=application/json& Click [here] to launch that link. It's the same URL but with a different REQUEST value, dropping the FORMAT parameter and instead specifying an INFO_FORMAT, and also specifying i and j parameters. WMS 1.3.0 uses "i" and "j" instead of "x" and "y" to denote the spot in the image of interest by numbers of pixels. If you're creating an image that's 800 by 600 pixels in size, a spot that's 400 pixels from the left margin and 300 pixels down from the top margin will be right in the middle of the image, where there is an eclipse path, so it reports the field values for that path at that spot. The eclipses demo map has attribute data only for the eclipses and not for the countries or labels, so if you don't pick a bounding box for your image that includes an eclipse path and then specify a spot in that image that is within an eclipse path, there won't be any data to return and you'll get a blank return. Why do they use pixel coordinates? That's because GetFeatureInfo is supposed to be used with tools that generate an image within some user interface and then people can click on a spot on the image and the app figures out where they clicked and then sends a GetFeatureInfo request to get the data that it uses to populate whatever info pane pops open to report the attributes for that spot. When you're authoring maps to publish, read the server topic to learn how the Info tool gets data from whatever spot is clicked, so you know how to configure your layers and pick status for those layers so that attribute (field values) for objects will be returned for the layers you want, without anything being returned for layers you don't want to return data on a click.
|