-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
1,586 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
.. _ogr_base_vect_ops: | ||
|
||
Building blocks presentation | ||
========================================================================== | ||
|
||
.. contents:: Table of Contents | ||
:depth: 5 | ||
:backlinks: top | ||
|
||
Introduction | ||
--------------------------------------------------- | ||
|
||
In this section, you will use the basic ZOO-Services : ``Buffer``, | ||
``Intersection`` and ``Difference`` which use OGR and psycopg Python | ||
modules by using a User Interface using the ZOO-Client to invoke WPS | ||
requests. | ||
The intended goal of this section is to present and interact with your | ||
new building blocks before chaining them in the next section. | ||
|
||
As seen earlier, once you have setup the ZOO-Project, you have | ||
multiple demonstration UI available from `http://localhost | ||
<http//localhost/>`__. | ||
|
||
Services Provider and configuration files | ||
--------------------------------------------------- | ||
|
||
First you may verify if the ZOO-Services are available from your current setup. | ||
You can take a look at the ``Buffer.zcfg``, ``Intersection.zcfg`` and | ||
``Difference.zcfg`` to get details about parameters. | ||
As you can see from the ZCFG files, you will use ZOO-Services provided by the | ||
``ogr_service.zo`` C service provider. So if you want to modify the Python code | ||
you will have to edit the corresponding file (so ``service.py``). | ||
You are invited to use similar requests as the one used in previous | ||
sections to learn about each services individually. | ||
|
||
The Buffer Service | ||
--------------------------------------------------- | ||
|
||
|
||
First click on a street then once the street is displayed in blue, click the | ||
'Buffer' button on top, you should get similar result as displayed in the following. | ||
|
||
.. image:: ./images/Buffer_Level_15.png | ||
:width: 650px | ||
:align: center | ||
|
||
The Intersection Service | ||
--------------------------------------------------- | ||
|
||
Using the same client interface as before, once you get a Buffer, you can then | ||
select a street intersecting the Buffer geometry to compute intersection by clicking on the Intersection button. | ||
|
||
|
||
.. image:: ./images/Intersection_Level_15.png | ||
:width: 650px | ||
:align: center | ||
|
||
|
||
The Difference Service | ||
--------------------------------------------------- | ||
|
||
Using the same instructions as for Intersetion, you can get the following result. | ||
|
||
.. image:: ./images/Difference_Level_15.png | ||
:width: 650px | ||
:align: center | ||
|
||
|
||
Buffer service ZCFG tweeks | ||
--------------------------------------------------- | ||
|
||
You will edit the file: ``/usr/lib/cgi-bin/Buffer.zcfg`` and add the | ||
block below in the ``Result`` from the ``DataOutputs`` block. | ||
|
||
.. code-block:: guess | ||
<Supported> | ||
mimeType = image/png | ||
useMapServer = true | ||
extension = json | ||
</Supported> | ||
The ``mimeType`` is defined as ``image/png`` and there is a new | ||
optional parameter: ``useMapServer``. It makes you able to inform | ||
the ZOO-Kernel that it has to use MapServer to publish the result the | ||
service returned as WMS / WFS or WCS (this last won't be used in this | ||
workshop) rather than simply storing the result as a file, in case you | ||
ask it to do so, using ``@Reference=true`` for output. | ||
|
||
Note that you also can define ``msStyle`` which let you define your | ||
own MapServer ``STYLE`` block definition. | ||
|
||
When you need to access a result many time or for different purpose | ||
accross other services then it is really useful to ask ZOO-Kernel to | ||
publish your result as WMS, WFS or WCS. | ||
|
||
Note that no modification of the code of the ``Buffer`` service was | ||
required to handle automatic pubilcation of the result as it is a | ||
vector format supported by OGR, only modification of the zcfg was | ||
required. | ||
|
||
For more informations about the MapServer support, please refer to `the | ||
official ZOO-Project Documentation <http://zoo-project.org/docs/kernel/mapserver.html>`_. | ||
|
||
Conclusion | ||
--------------------------------------------------- | ||
|
||
Now you know this three services, and you get a simple interface to interact | ||
with your MapServer WFS and your ZOO-Project WPS Servers, you are ready to use | ||
the Services in a different way, by chaining them using the JavaScript ZOO-API to build | ||
more complexe and powerfull services. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[BufferMask] | ||
Title = Compute buffer mask | ||
Abstract = Compute buffer mask around a geometry | ||
processVersion = 1 | ||
storeSupported = true | ||
statusSupported = true | ||
serviceProvider = foss4gws.js | ||
serviceType = JS | ||
<DataInputs> | ||
[InputData] | ||
Title = The feature | ||
Abstract = The feature to run the service with | ||
minOccurs = 1 | ||
maxOccurs = 1 | ||
<ComplexData> | ||
<Default> | ||
mimeType = text/xml | ||
encoding = utf-8 | ||
</Default> | ||
</ComplexData> | ||
</DataInputs> | ||
<DataOutputs> | ||
[Result] | ||
Title = The resulting feature | ||
Abstract = The feature created by the service. | ||
<ComplexOutput> | ||
<Default> | ||
mimeType = application/json | ||
</Default> | ||
</ComplexOutput> | ||
</DataOutputs> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[BufferRequest] | ||
Title = Compute buffer request | ||
Abstract = Compute buffer request around a geometry | ||
processVersion = 1 | ||
storeSupported = true | ||
statusSupported = true | ||
serviceProvider = foss4gws.js | ||
serviceType = JS | ||
<DataInputs> | ||
[InputData] | ||
Title = The feature | ||
Abstract = The feature to run the service with | ||
minOccurs = 1 | ||
maxOccurs = 1 | ||
<ComplexData> | ||
<Default> | ||
mimeType = text/xml | ||
encoding = utf-8 | ||
</Default> | ||
</ComplexData> | ||
</DataInputs> | ||
<DataOutputs> | ||
[Result] | ||
Title = The resulting feature | ||
Abstract = The feature created by the service. | ||
<ComplexOutput> | ||
<Default> | ||
mimeType = application/json | ||
</Default> | ||
</ComplexOutput> | ||
</DataOutputs> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[Mask] | ||
Title = Compute mask | ||
Abstract = Compute mask around a geometry | ||
processVersion = 1 | ||
storeSupported = true | ||
statusSupported = true | ||
serviceProvider = foss4gws.js | ||
serviceType = JS | ||
<DataInputs> | ||
[InputData] | ||
Title = The feature | ||
Abstract = The feature to run the service with | ||
minOccurs = 1 | ||
maxOccurs = 1 | ||
<ComplexData> | ||
<Default> | ||
mimeType = text/xml | ||
encoding = utf-8 | ||
</Default> | ||
</ComplexData> | ||
</DataInputs> | ||
<DataOutputs> | ||
[Result] | ||
Title = The resulting feature | ||
Abstract = The feature created by the service. | ||
<ComplexOutput> | ||
<Default> | ||
mimeType = application/json | ||
</Default> | ||
</ComplexOutput> | ||
</DataOutputs> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
var zoo_url='http://localhost/cgi-bin/zoo_loader.cgi'; | ||
var mapfile="/var/data/maps/project_WS2024.map"; | ||
|
||
function Buffer(inputData,bDist){ | ||
|
||
// Create all required ZOO.formats | ||
var fGJ=new ZOO.Format.GeoJSON(); | ||
|
||
// Call the Buffer service | ||
var myInputs = { | ||
InputPolygon: { | ||
type: 'complex', | ||
value: fGJ.write(inputData), | ||
mimeType: "application/json"}, | ||
BufferDistance: { | ||
type: 'float', | ||
"value": bDist | ||
} | ||
}; | ||
var myOutputs= { | ||
Result: { | ||
type: 'RawDataOutput', | ||
"mimeType": "application/json" | ||
} | ||
}; | ||
var myProcess = new ZOO.Process(zoo_url,'Buffer'); | ||
var myExecuteResult=myProcess.Execute(myInputs,myOutputs); | ||
return fGJ.read(myExecuteResult); | ||
|
||
} | ||
|
||
function BufferToBBOX(inputs,dist){ | ||
// Create all required ZOO.formats | ||
var fGJ=new ZOO.Format.GeoJSON(); | ||
var fGML=new ZOO.Format.GML(); | ||
if(inputs["InputData"]["mimeType"]=="application/json") | ||
fGML=new ZOO.Format.GeoJSON(); | ||
|
||
// Read the input GML | ||
var inputData=fGML.read(inputs["InputData"]["value"]); | ||
alert(inputData); | ||
|
||
// Compute Buffer | ||
var bufferResultAsJSON=Buffer(inputData,dist); | ||
alert(bufferResultAsJSON); | ||
|
||
// Create the Buffer result BBOX | ||
var bbox = new ZOO.Bounds(); | ||
var bounds=bufferResultAsJSON[0].geometry.getVertices(); | ||
for(var t in bounds){ | ||
bbox.extend(bounds[t]); | ||
} | ||
return [bbox,bufferResultAsJSON,inputData]; | ||
} | ||
|
||
function Mask(conf,inputs,outputs){ | ||
var fGJ=new ZOO.Format.GeoJSON(); | ||
var bbox = BufferToBBOX(inputs,0.15); | ||
var finalG=bbox[0].toGeometry(); | ||
var result=new ZOO.Feature(finalG,{"name": "Result1000"}); | ||
outputs["Result"]["value"]=fGJ.write(result); | ||
return {result: ZOO.SERVICE_SUCCEEDED, outputs: outputs }; | ||
} | ||
|
||
function BufferMask(conf,inputs,outputs){ | ||
|
||
// Compute big Buffer | ||
var bbox = BufferToBBOX(inputs,0.15); | ||
var finalG=bbox[0].toGeometry(); | ||
var fGJ=new ZOO.Format.GeoJSON(); | ||
|
||
// Compute Buffer standard buffer | ||
var bufferResultAsJSON=Buffer(bbox[2],0.0015); | ||
|
||
// Request Difference service using Buffer result and features in the BBOX | ||
var result=new ZOO.Feature(finalG,{"fid": "1","name": "Result1000"}); | ||
var myProcess2 = new ZOO.Process(zoo_url,'Difference'); | ||
var myInputs2 = { | ||
InputEntity1: { | ||
type: 'complex', | ||
value: fGJ.write(finalG), | ||
mimeType: "application/json" | ||
}, | ||
InputEntity2: { | ||
type: 'complex', | ||
value: fGJ.write(bufferResultAsJSON), | ||
mimeType: "application/json" | ||
} | ||
}; | ||
var myOutputs2= { | ||
Result: { | ||
type: 'RawDataOutput', | ||
"mimeType": "application/json" | ||
} | ||
}; | ||
var myExecuteResult4=myProcess2.Execute(myInputs2,myOutputs2); | ||
|
||
outputs["Result"]["value"]=myExecuteResult4; | ||
return {result: ZOO.SERVICE_SUCCEEDED, outputs: outputs }; | ||
|
||
} | ||
|
||
function BufferRequest(conf,inputs,outputs){ | ||
|
||
var fGJ=new ZOO.Format.GeoJSON(); | ||
var bbox=BufferToBBOX(inputs,0.0015); | ||
var myProcess2 = new ZOO.Process(zoo_url,'Intersection'); | ||
var myInputs2 = { | ||
InputEntity1: { | ||
type: 'complex', | ||
value: fGJ.write(bbox[1]), | ||
mimeType: "application/json" | ||
}, | ||
InputEntity2: { | ||
type: 'complex', | ||
xlink: "http://localhost/cgi-bin/mapserv?map="+mapfile+ | ||
"&SERVICE=WFS&version=1.0.0&request=GetFeature&"+ | ||
"typename=points&SRS=EPSG:4326&BBOX="+ | ||
bbox[0].left+","+bbox[0].bottom+","+bbox[0].right+","+bbox[0].top, | ||
mimeType: "text/xml" | ||
} | ||
}; | ||
var myOutputs2= { | ||
Result: { | ||
type: 'RawDataOutput', | ||
"mimeType": outputs["Result"]["mimeType"] | ||
} | ||
}; | ||
var myExecuteResult4=myProcess2.Execute(myInputs2,myOutputs2); | ||
outputs["Result"]["value"]=myExecuteResult4; | ||
return {result: ZOO.SERVICE_SUCCEEDED, outputs: outputs }; | ||
|
||
} | ||
|
Oops, something went wrong.