[443] | 1 | .. _ogr_base_vect_ops: |
---|
| 2 | |
---|
| 3 | ********************************************************* |
---|
| 4 | Building blocks presentation - Using OGR and PgRouting based Web Services |
---|
| 5 | ********************************************************* |
---|
| 6 | |
---|
| 7 | .. contents:: Table of Contents |
---|
| 8 | :depth: 5 |
---|
| 9 | :backlinks: top |
---|
| 10 | |
---|
| 11 | Introduction |
---|
| 12 | ============ |
---|
| 13 | |
---|
| 14 | In this section, you will use basic ZOO-Services : ``Buffer``, |
---|
| 15 | ``Intersection`` and ``DifferencePy`` which use OGR and psycopg Python modules. |
---|
| 16 | The intended goal of this section is to present and interact with your new building blocks before chaining them in the next section. |
---|
| 17 | |
---|
| 18 | First of all, you should use the following links to access the user |
---|
| 19 | interfaces and interact with your services, the first one is used to |
---|
| 20 | access basic spatial-tools demo client interface and the second to |
---|
| 21 | access the routing application : |
---|
| 22 | * `http://localhost/zoows2013-demo/spatialtools-py.html <http://localhost/zoows2013-demo/spatialtools-py.html>`__ |
---|
| 23 | * `http://localhost/zoo-ws2013/ <http://localhost/zoo-ws2013/>`__ |
---|
| 24 | |
---|
| 25 | Services Provider and configuration files |
---|
| 26 | ========================================= |
---|
| 27 | |
---|
| 28 | First you may verify if the ZOO-Services are available from your current setup. |
---|
| 29 | You can take a look at the ``Buffer.zcfg``, ``Intersection.zcfg`` and |
---|
| 30 | ``DifferencePy.zcfg`` to get details about parameters. |
---|
| 31 | As you can see from the ZCFG files, you will use ZOO-Services provided by the |
---|
| 32 | ``service`` Python service provider. So if you want to modify the Python code |
---|
| 33 | you will have to edit the corresponding file (so ``service.py``). |
---|
| 34 | You are invited to use similar requests as the one used in previous |
---|
| 35 | sections to learn about each services individually. |
---|
| 36 | |
---|
| 37 | The Buffer Service |
---|
| 38 | ========================= |
---|
| 39 | |
---|
| 40 | First click on a street then once the street is displayed in blue, click the |
---|
| 41 | 'Buffer' button on top, you should get similar result as displayed in the following. |
---|
| 42 | |
---|
| 43 | .. image:: ./images/Buffer_Level_15.png |
---|
| 44 | :width: 650px |
---|
| 45 | :align: center |
---|
| 46 | |
---|
| 47 | Since version ZOO-Project 1.2.0, you can run automatically some basic tests to |
---|
| 48 | make sure that you wrote a correct ZCFG file and your service is validating. |
---|
| 49 | |
---|
| 50 | .. note:: the current testing is really simple and should be adapted to each Services |
---|
| 51 | Provider, mainly to define input names. |
---|
| 52 | |
---|
| 53 | You can use the following command: |
---|
| 54 | |
---|
| 55 | .. code-block:: bash |
---|
| 56 | |
---|
| 57 | cd /home/user/zoo/testing |
---|
| 58 | ./run.sh http://localhost/cgi-bin/zoo_loader.cgi Buffer |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | .. note:: During or after the test run, you can take a look inside the ``tmp`` directory |
---|
| 62 | which contains both the XML requests send to the ZOO Kernel (``*1.xml``) and the |
---|
| 63 | responses it gave (``output*.xml``). |
---|
| 64 | |
---|
| 65 | The Intersection Service |
---|
| 66 | ========================= |
---|
| 67 | |
---|
| 68 | Using the same client interface as before, once you get a Buffer, you can then |
---|
| 69 | select a street intersecting the Buffer geometry to compute intersection by clicking on the Intersection button. |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | .. image:: ./images/Intersection_Level_15.png |
---|
| 73 | :width: 650px |
---|
| 74 | :align: center |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | The DifferencePy Service |
---|
| 78 | ========================= |
---|
| 79 | |
---|
| 80 | Using the same instructions as for Intersetion, you can get the following result. |
---|
| 81 | |
---|
| 82 | .. image:: ./images/Difference_Level_15.png |
---|
| 83 | :width: 650px |
---|
| 84 | :align: center |
---|
| 85 | |
---|
| 86 | |
---|
| 87 | The Routing and Profile Services |
---|
| 88 | ========================= |
---|
| 89 | |
---|
| 90 | First click on the blue flag then place your starting point on the |
---|
| 91 | map, do the same with the red flag to get the shortest path computed |
---|
| 92 | by the dedicated service and then display its profile. Note that when |
---|
| 93 | you pass the mouse over the profile display then you will see its |
---|
| 94 | corresponding position displayed on the map. You can also click on a |
---|
| 95 | specific step in your path to get the corresponding line displayed. |
---|
| 96 | |
---|
| 97 | .. image:: ./images/Routing_Basic.png |
---|
| 98 | :width: 650px |
---|
| 99 | :align: center |
---|
| 100 | |
---|
| 101 | If you take a look in the file: ``/usr/lib/cgi-bin/routing/do.zcfg`` |
---|
| 102 | you may notice something new in the supported format which is |
---|
| 103 | reproduced here after. |
---|
| 104 | |
---|
| 105 | .. code-block:: guess |
---|
| 106 | |
---|
| 107 | <Supported> |
---|
| 108 | mimeType = image/png |
---|
| 109 | asReference = true |
---|
| 110 | msStyle = STYLE COLOR 125 0 105 OUTLINECOLOR 0 0 0 WIDTH 3 END |
---|
| 111 | useMapServer = true |
---|
| 112 | extension = json |
---|
| 113 | </Supported> |
---|
| 114 | |
---|
| 115 | The ``mimeType`` is defined as ``image/png`` and there is two new |
---|
| 116 | parameter which are both optional: |
---|
| 117 | * ``useMapServer``: which make you able to inform the ZOO-Kernel |
---|
| 118 | that it have to use MapServer to publish your result as WMS / WFS or WCS (this last |
---|
| 119 | won't be used in this workshop) rather than simply storing the |
---|
| 120 | result as a file. |
---|
| 121 | * ``msStyle``: which let you define your own MapServer ``STYLE`` block definition. |
---|
| 122 | |
---|
| 123 | When you need to access a result many time or for different purpose |
---|
| 124 | accross other services then it is really useful to ask ZOO-Kernel to |
---|
| 125 | publish your result as WMS, WFS or WCS. |
---|
| 126 | |
---|
| 127 | Note that no modification of the code of the do service was required |
---|
| 128 | to handle automatic pubilcation of the result as it is a vector format |
---|
| 129 | supported by OGR, only modification of the zcfg was required. |
---|
| 130 | |
---|
| 131 | This routing example is here to illustrate how easy it is to publish |
---|
| 132 | your result as WMS, WFS or WCS ressource. Indeed, when your routing |
---|
| 133 | service was called, ZOO-Kernel published the result as WMS and WFS |
---|
| 134 | ressources which was both used first for the UI purpose, the WMS to |
---|
| 135 | display the resulting path on the map, the WFS for displaying details |
---|
| 136 | about each steps. The WFS protocol is also used as the input value |
---|
| 137 | for the profile computation. So, the computation was run once |
---|
| 138 | and accessed three times for different purposes and from different |
---|
| 139 | clients. |
---|
| 140 | |
---|
| 141 | For more informations about the MapServer support, please refer to `the |
---|
| 142 | official ZOO-Project Documentation <http://zoo-project.org/docs/kernel/mapserver.html>`_. |
---|
| 143 | |
---|
| 144 | Conclusion |
---|
| 145 | ======== |
---|
| 146 | |
---|
| 147 | Now you know this three services, and you get a simple interface to interact |
---|
| 148 | with your MapServer WFS and your ZOO-Project WPS Servers, you are ready to use |
---|
| 149 | the Services in a different way, by chaining them using the JavaScript ZOO-API to build |
---|
| 150 | more complexe and powerfull services. |
---|