-
Notifications
You must be signed in to change notification settings - Fork 0
WMS Specifications
There are many different ways to view and share geographic data. One of the ways is through a web map service or a WMS.
A WMS is read-only so you can't download or interact with the data short of what the service allows. There are tools for downloading raster tiles from Web Map Services but they don't encode attribute data short of what is symbolised on the map. There is a GetFeatureInfo option that if included will return attributes defined by the service. The specification says "From the spatial context information (BBOX, SRS, WIDTH, HEIGHT) in that GetMap request, along with the X,Y position the user chose, the WMS can (possibly) return additional information about that position." It doesn't explicitly state how the attributes are encoded and/or by what mechanism they are linked to the features in the feature service. I imagine that when features are published as a web map service perhaps the attribute table is encoded to JSON and then each feature has a bounding box generated linked to it's attributes so when anywhere inside the bounding box of the feature is queried it returns those encoded JSON values.
Generally speaking the main idea of a WMS is to look and not touch, so if someone wants their data to be more flexible they'll either host it with a different map service such as a WFS or just provide their data directly as a shapefile or geodatabase.
If one wants to have more flexibility with WMS data their best course of action is to contact the data provider directly. If that isn't possible and it isn't against the terms of service I image there are ways to generate features based on web map services.
You'll first have to check if GetFeatureInfo is enabled. If so then an idea (albeit a very costly idea) would be to get the bounding box for the map, then generate a script to request attributes on a pixel by pixel basis, compare the results for unique values and then convert that raster grid to a vector and join the unique attributes to the features based on the encoded objectid. I imagine it would be taxing on some people's servers to send thousands/millions of requests so this really is a terrible idea but an interesting one nonetheless as a proof of concept. The other idea would be to delve further into the WMS specification and see if there is a way to pull out encoded values for features/layers based on their bounding boxes or vector values so you aren't querying every single pixel in the tiles.
This is essentially the crux of my question:
https://gis.stackexchange.com/questions/212313/how-does-getfeatureinfo-work-on-a-wms
and I'm thinking there may be a more direct function than querying every pixel. assuming get featureinfo works, using the identify function, it will not only include the attributes but it also highlights/flashes the feature queried. If there is a way we could create a plugin or find a way to manipulate the client to pull both the bounding info and attribute info into an edit session to create features from that query, as long as you had a grid to query each feature you could have the map drawn for you.
The other idea is to just include a web based script in order to scrape data. Assuming the frontend for the request is some flex based knickknackery looking into the debugging tools sends a request based on an xy value. which in this projection is represented in units of meters but I imagine there is some sort of backend code that converts the x y pixel value on your screen to the x y pixel/meter value on the map. The server receives this requests, finds out where you selected, runs an intersect of sorts with the data and then sends back the attributes for the feature you clicked... in the form of an AMF file which is thanks to our lovely dead software flex. there is a package that may help with decoding it:
http://blog.dornea.nu/2015/06/22/decode-adobe-flex-amf-protocol/
Otherwise it yields a 6000 character hash which is not useful. This might also be a solution https://www.jamesward.com/2010/07/07/amf-js-a-pure-javascript-amf-implementation/
or.. you could just go straight to the source and query it directly: eg
Or even simpler:
http://65.183.210.212:6080/arcgis/rest/services/LiveMaps/AssessorMap/MapServer/0/1?f=pjson
just loop through the object id field 1
and then merge the json files as the server limits requests to 1000 results.