owsproxy.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. Proxy4OWS
  2. #########
  3. *Proxy4OWS [http://redmine.ccss.cz/projects/owsproxy] is Open Source server
  4. program, which enables to visualize and work with large vector data and
  5. raster data in the web environment. It basically transforms OGC Web Feature
  6. Service and OGC Web Coverage service to OGC Web Mapping service calls. It
  7. can be also used for transformation of the original data into
  8. server-unsupported coordinate reference system, including OGC WMS*
  9. The problem of displaying large GIS datasets
  10. ============================================
  11. When working with large vector datasets, we are usually facing limits of
  12. nowadays browsers. Google Maps [#]_ for example are limiting number of
  13. displaying vector features to 1000. In OpenLayers [#]_, no limit for number
  14. of features is used, but displaying e.g. cadastral map makes browsers often
  15. freeze. Advantage of working with vector data directly is (among others),
  16. direct possibility of vector data editing, more interactive way of user
  17. experience, speed (when dealing with reasonable amount of data).
  18. While vector data can be displayed using todays technologies, some popular
  19. raster data formats, such as GeoTIFF, can be not. According to W3C [#]_,
  20. only few formats for raster data are supported, none of them is really used
  21. or usable in GIS, usually because of compression method, they are using. In
  22. the internet, raster graphics format are focusing on possibly low amount of
  23. data transfered from the server to the client, while loosing the accuracy
  24. of the data being transfered. In GIS, we are focusing on data quality,
  25. regardless on file size.
  26. Raster and vector data are usually distributed using OGC OWS standards.
  27. Vector and raster data are distributed via OGC Web Feature and Raster
  28. Service respectively. Both services are offering list of datasets and
  29. metadata.
  30. Another problem might occur, when some OGC Web Mapping Service does not
  31. offer coordinate reference system, in which the web mapping application is
  32. configured. Some middle-ware have to be setuped between the map application
  33. and the server, which will transform the images from server coordinate
  34. reference system to the one, accepted by the client.
  35. Proxy4OWS
  36. =========
  37. Proxy4OWS is server script, which is between the client mapping application
  38. and OGC OWS server (WCS, WFS or WMS). It is transforming OGC WMS request
  39. types from the client, into WCS or WFS requests, so that the target server
  40. can accept them. On the way back, it downloads the data distributed by the
  41. server (raster or vector), creates image and sends it back to the client.
  42. Features
  43. --------
  44. It also transforms GetCapabilities request-response pair, so that the
  45. (WMS) client can deal with it.
  46. As result, data are processed on the server, into the form, common
  47. web browser mapping application are able to display without big demands on
  48. system resources.
  49. .. figure:: imgs/owsproxy_sequence_diagram.png
  50. HSlayers.Layer.WCS and WFS are derived from Layer WMS. As proxy
  51. between the client (the map) and the WFS|WCS server, Proxy4OWS is
  52. placed. Proxy4OWS transforms WMS requests comming from the client
  53. into WFS|WCS calls and also responses are transformed to WMS
  54. responses or images, displayable in the web browser.
  55. Proxy4OWS also can deal with OGC WMS service in the way, that it is
  56. transforming the coordinate reference system of the original service into
  57. the client-preferred one in the case, server does not support coordinate
  58. system of the client. The resulting image is usually a bit distorted, yet
  59. displayable.
  60. Technology
  61. ----------
  62. Proxy4OWS is written in Python programming language. Following libraries are
  63. used:
  64. MapServer [#]_
  65. MapServer is the core of Proxy4OWS. Proxy4OWS generates the Map object
  66. configration and after that dispatch method of MapServer is used, which
  67. will deal with the request, download all necessary data from servers
  68. and generate resulting image.
  69. From the client-point of view, it is used for working with vector data
  70. directlya (deals as OGC WFS client).
  71. GDAL/OGR [#]_
  72. GDAL is used for reading OGC WFS and OGC WCS service metadata, so that
  73. the WMS response from Proxy4OWS to the client, has all necessary
  74. informations.
  75. While for OGC WFS service, MapServer directly is acting as client, OGC
  76. WCS is configured as GDAL data source.
  77. Also for WMS transformation service, WMS interface of GDAL is used,
  78. because of, it is able to deal with tiled requests, preserving the
  79. large dataset exceptions issue.
  80. OWSLib [#]_
  81. OWSLib is Python library, which acts as OWS client. With help of
  82. OWSLib, metadata of particular target services are being collected
  83. easy.
  84. Architecture
  85. ------------
  86. Once again: Proxy4OWS acts as WMS server to the client and acts as WFS, WCS
  87. or even WMS client to the target server.
  88. GetCapabilities
  89. When GetCapabilities request arrives from the client, Proxy4OWS
  90. Checks for existing cached directory with mapfile, creates new, if not existing
  91. GetMap
  92. When GetMap request arrives, image is generated based on previously
  93. generated mapfile, using `OWSDispatch` method. At this point, WFS
  94. filter is applied, if target server is WFS.
  95. In both cases, Proxy4OWS is looking for existing MapServer MapFile (it
  96. creates one, if it does not exist) and let MapServer do the work. Proxy4OWS
  97. is takes care about proper MapFile configuration.
  98. .. figure:: imgs/getcapabilities.png
  99. When WMS GetCapabilities request arrives, Proxy4OWS generates MapFile
  100. with list of layers, corresponding to either feature types (WFS) or
  101. coverages (WCS) of the target service. For configuring the MapFile
  102. properly, GDAL, OGR and OWSLib libraries are used.
  103. WFS Layers are configured, using MapServer as WFS Client, while WCS
  104. layers are using GDAL as WCS Client.
  105. Then MapFile is generated, `OWSDispatch` method is called and
  106. Capabilities response does arrive.
  107. .. figure:: imgs/getmap.png
  108. When WMS GetMap request arrives, Proxy4OWS find existing MapFile
  109. (creates new, if it does not exist) and performs `OWSDispatch` function
  110. of MapServer, which generates the output image and sends it back to the
  111. server.
  112. Invocation
  113. ----------
  114. Proxy4OWS is originally designed as WMS server. But it can also be used as
  115. WFS or WCS server, so that it can only transform original data into
  116. coordinate system unsupported by the target server.
  117. Therefore, the client can use basically any type of OWS request using
  118. proper parameters. In addition to this, two more parameters will have to be
  119. appended to the request URL:
  120. * `owsservice` says, what is the target server service type (WCS, WFS
  121. or WMS)
  122. * `owsurl` is the URL of original server
  123. .. figure:: imgs/crwfs.png
  124. Image based on OGC WFS service, as result of following WMS GetMap
  125. request. Note `owsurl` and `owsservice` parameters in the URL:
  126. `http://localhost/cgi-bin/owsproxy.cgi?map=/var/www/localhost/htdocs/tmp/WFS-8066ca5a58f48c499f919d45529596c0xeWyOF/mapfile.map&owsService=WFS&owsUrl=http://bnhelp.cz/ows/crwfs&LAYERS=kraje&TRANSPARENT=TRUE&FORMAT=image/png&EXCEPTIONS=XML&VERSION=1.3.0&INFO_FORMAT=application/vnd.ogc.gml&CRS=EPSG:3035&SERVICE=WMS&REQUEST=GetMap&STYLES=&BBOX=2844318.7336584,4288032.8774186,3211207.4244274,5053560.2418116&WIDTH=1085&HEIGHT=520 <http://localhost/cgi-bin/owsproxy.cgi?map=/var/www/localhost/htdocs/tmp/WFS-8066ca5a58f48c499f919d45529596c0xeWyOF/mapfile.map&owsService=WFS&owsUrl=http://bnhelp.cz/ows/crwfs&LAYERS=kraje&TRANSPARENT=TRUE&FORMAT=image/png&EXCEPTIONS=XML&VERSION=1.3.0&INFO_FORMAT=application/vnd.ogc.gml&CRS=EPSG:3035&SERVICE=WMS&REQUEST=GetMap&STYLES=&BBOX=2844318.7336584,4288032.8774186,3211207.4244274,5053560.2418116&WIDTH=1085&HEIGHT=520>`_
  127. WMS Transformation
  128. ------------------
  129. Implementation of transformation of OGC WMS services is done in little bit
  130. different way. Since it is assumed, that Capabilities document is already
  131. parsed, it is expecting GetMap request from the client to Proxy4OWS
  132. directly. The GetMap request is expected to have - next to original WMS paramters - also
  133. three add-on options:
  134. * owsService - this is going to be WMS
  135. * owsUrl - URL of the original service, which is expecting to handle
  136. the GetMap request
  137. * fromCRS - CRS of the original coordinate system, from which shall the
  138. result of GetMap be transformed to.
  139. The MapServer's mapfile is generated on-the-fly. Only one layer is attached
  140. to the mapfile - layer of type WMS. MapServer then formulates the necessary
  141. request, fetches the data from remote server and provides image
  142. transformation on them. Result is always little bit distorted, because the
  143. resolution is not always fine enough, but the it can be used and displayed
  144. in the mapping application.
  145. .. figure:: imgs/wms_sequence.png
  146. WMS Sequence diagram.
  147. .. figure:: imgs/wms_transformace.png
  148. WMS transformation result - left map coordinate system, right -
  149. transformed result from EPSG:4326 source.
  150. Thanks to Proxy4OWS, we can now display seam-less data from several WMS
  151. resources, which do not support coordinate system of the map, displayed in
  152. user's browser.
  153. Further development
  154. ===================
  155. Currently, when full featured Capabilities response is send back from the
  156. server to the client, for some servers, with hight amount of data, this
  157. takes long time.
  158. For WFS for example, GetCapabilities, DescribeFeatureType and sometimes
  159. even GetFeature requests are to be called, before all necessary metadata
  160. are filled to MapFile. This certainly makes the Capabilities response come
  161. back after long time. In the future, we would like to eliminate this,
  162. calls, so that only smallest amount of requests (GetCapabilities) would
  163. have to be requested, and WMS Capabilities response could be returned
  164. possibly fast. Of course, when users chooses the particular layer to be
  165. displayed, additional non-standard call would have to be done, for getting
  166. addition attributes, so that the client has all necessary informations
  167. (which can be normally taken from Capabilities document).
  168. Also now, virtually no configuration caching is created. For each
  169. GetCapabilities request, new temporary MapFile configuration is setuped.
  170. Proper way would be to use already existing MapFile for particular service,
  171. if already generated and evaluate the difference between cashed version and
  172. potentially upgraded service.
  173. Proxy4OWS is not cashing any data. It would be the option for further
  174. investigation, if it would make sense, to pre-cache some original data at
  175. Proxy4OWS side, and make the performance higher.
  176. .. [#] http://code.google.com/intl/cs-CZ/apis/kml/documentation/mapsSupport.html
  177. .. [#] http://openlayers.org
  178. .. [#] http://www.w3.org/Graphics/
  179. .. [#] http://mapserver.org
  180. .. [#] http://gdal.org
  181. .. [#] http://sourceforge.net/apps/trac/owslib/wiki