Skip to content

Commit

Permalink
Add 2024 workshop material
Browse files Browse the repository at this point in the history
  • Loading branch information
gfenoy committed Jul 1, 2024
1 parent 0b3cef1 commit 69408e6
Show file tree
Hide file tree
Showing 44 changed files with 1,586 additions and 11 deletions.
8 changes: 3 additions & 5 deletions 2010/building_wps_client_using_ol.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@ The following JavaScript code must then be added in a ``<script></script>`` sect

.. code-block:: guess
var map, layer, select, hover, multi, control;
var map, layer, select, hover, multi, control;
var typename="regions";
var main_url="http://localhost/cgi-bin/mapserv?map=/var/www/wfs.map";
var main_url="http://localhost/cgi-bin/mapserv?map=/var/www/wfs.map";
function init(){
map = new OpenLayers.Map('map', {
controls: [
Expand All @@ -64,7 +62,7 @@ The following JavaScript code must then be added in a ``<script></script>`` sect
buffer: 0,
singleTile: true
}
);
);
map.addLayers([layer]);
map.setCenter(new OpenLayers.LonLat(138,33.5),5);
}
Expand Down
2 changes: 1 addition & 1 deletion 2023/foss4g/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ZOO-Project – Introduction to OGC API - Processes - Part 1: Core
:Author: Gérald Fenoy, Nicolas Bozon, Venkatesh Raghavan
:Contact: gerald.fenoy at geolabs.fr, nicolas.bozon at gmail.com, venka at osgeo.org
:Last Updated: $Date$
:Events: FOSS4G 2022 Firenze
:Events: FOSS4G 2023 Prizren

.. image:: https://2023.foss4g.org/img/logos/FOSS4G%202023%20-%20Logo%20Main.png
:target: http://2023.foss4g.org/
Expand Down
2 changes: 1 addition & 1 deletion 2023/foss4g/solutions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ he demo UI working with your services.
docker compose exec zookernel bash
# From the container run the following commands:
curl -o /usr/lib/cgi-bin/foss4ws.js https://raw.githubusercontent.com/ZOO-Project/workshops/master/2023/foss4g/files/foss4ws.js
curl -o /usr/lib/cgi-bin/foss4gws.js https://raw.githubusercontent.com/ZOO-Project/workshops/master/2023/foss4g/files/foss4gws.js
curl -o /usr/lib/cgi-bin/Mask.zcfg https://raw.githubusercontent.com/ZOO-Project/workshops/master/2023/foss4g/files/Mask.zcfg
curl -o /usr/lib/cgi-bin/BufferMask.zcfg https://raw.githubusercontent.com/ZOO-Project/workshops/master/2023/foss4g/files/BufferMask.zcfg
curl -o /usr/lib/cgi-bin/BufferRequest.zcfg https://raw.githubusercontent.com/ZOO-Project/workshops/master/2023/foss4g/files/BufferRequest.zcfg
Expand Down
2 changes: 1 addition & 1 deletion 2023/ogc-member-meeting/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ZOO-Project introduction to OGC API - Processes - Part 1: Core secutiy
:Last Updated: $Date$
:Events: OGC 125th members meeting Frascati

.. image:: https://camo.githubusercontent.com/cef0191706f7699d98b3378519afc920890e87e6be5a92ef37673e6595affbe7/68747470733a2f2f7777772e6f67632e6f72672f77702d636f6e74656e742f75706c6f6164732f323032322f31302f66726173636174692d7765622d62616e6e65722d31303234783533362e706e67
.. image:: https://www.ogc.org/wp-content/uploads/2022/10/frascati-web-banner-1024x536.png
:target: https://eo4society.esa.int/event/125th-ogc-member-meeting-europe/
:align: center
:width: 50%
Expand Down
Binary file added 2024/.DS_Store
Binary file not shown.
Binary file added 2024/foss4g-europe/.DS_Store
Binary file not shown.
111 changes: 111 additions & 0 deletions 2024/foss4g-europe/building_blocks_presentation.rst
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.
31 changes: 31 additions & 0 deletions 2024/foss4g-europe/files/BufferMask.zcfg
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>
31 changes: 31 additions & 0 deletions 2024/foss4g-europe/files/BufferRequest.zcfg
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>
31 changes: 31 additions & 0 deletions 2024/foss4g-europe/files/Mask.zcfg
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>
134 changes: 134 additions & 0 deletions 2024/foss4g-europe/files/foss4gws.js
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+
"&amp;SERVICE=WFS&amp;version=1.0.0&amp;request=GetFeature&amp;"+
"typename=points&amp;SRS=EPSG:4326&amp;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 };

}

Loading

0 comments on commit 69408e6

Please sign in to comment.