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