Changes between Initial Version and Version 1 of ZooWorkshop2010/Files


Ignore:
Timestamp:
Sep 5, 2010, 4:15:57 PM (10 years ago)
Author:
djay
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ZooWorkshop2010/Files

    v1 v1  
     1= ZOO Workshop 2010 Files =
     2
     3As some files cause many trouble when we use copy and paste, we've put the examples in this page.
     4
     5
     6== ogr_ws_service_provider.py File ==
     7
     8{{{
     9#!python
     10import osgeo.ogr
     11import libxml2
     12
     13def createGeometryFromWFS(my_wfs_response):
     14        doc=libxml2.parseMemory(my_wfs_response,len(my_wfs_response))
     15        ctxt = doc.xpathNewContext()
     16        res=ctxt.xpathEval("/*/*/*/*/*[local-name()='Polygon' or local- name()='MultiPolygon']")
     17        for node in res:
     18                geometry_as_string=node.serialize()
     19                geometry=osgeo.ogr.CreateGeometryFromGML(geometry_as_string)
     20                return geometry
     21        return geometry
     22
     23def Boundary(conf,inputs,outputs):
     24        if inputs["InputPolygon"]["mimeType"]=="application/json":
     25                geometry=osgeo.ogr.CreateGeometryFromJson(inputs["InputPolygon"]["value"])
     26        else:
     27                geometry=createGeometryFromWFS(inputs["InputPolygon"]["value"])
     28        rgeom=geometry.GetBoundary()
     29        if outputs["Result"]["mimeType"]=="application/json":
     30                outputs["Result"]["value"]=rgeom.ExportToJson()
     31                outputs["Result"]["mimeType"]="text/plain"
     32        else:
     33                outputs["Result"]["value"]=rgeom.ExportToGML()
     34        geometry.Destroy()
     35        rgeom.Destroy()
     36        return 3
     37}}}
     38
     39== Second code block on page 26 ==
     40
     41{{{
     42#!python
     43def extractInputs(obj):
     44        if obj["mimeType"]=="application/json":
     45                return osgeo.ogr.CreateGeometryFromJson(obj["value"])
     46        else:
     47                return createGeometryFromWFS(obj["value"])
     48        return null
     49
     50def outputResult(obj,geom):
     51        if obj["mimeType"]=="application/json":
     52                obj["value"]=geom.ExportToJson()
     53                obj["mimeType"]="text/plain"
     54        else:
     55                obj["value"]=geom.ExportToGML()
     56}}}
     57
     58== Third code block on page 26 ==
     59
     60{{{
     61#!python
     62def Boundary(conf,inputs,outputs):
     63        geometry=extractInputs(inputs["InputPolygon"])
     64        rgeom=geometry.GetBoundary()
     65        outputResult(outputs["Result"],rgeom)
     66        geometry.Destroy()
     67        rgeom.Destroy()
     68        return 3
     69}}}
     70
     71== Code block on page 27 ==
     72
     73{{{
     74#!python
     75def ConvexHull(conf,inputs,outputs):
     76        geometry=extractInputs(inputs["InputPolygon"])
     77        rgeom=geometry.ConvexHull()
     78        outputResult(outputs["Result"],rgeom)
     79        geometry.Destroy()
     80        rgeom.Destroy()
     81        return 3
     82
     83def Centroid(conf,inputs,outputs):
     84        geometry=extractInputs(inputs["InputPolygon"])
     85        if geometry.GetGeometryType()!=3:
     86                geometry=geometry.ConvexHull()
     87        rgeom=geometry.Centroid()
     88        outputResult(outputs["Result"],rgeom)
     89        geometry.Destroy()
     90        rgeom.Destroy()
     91        return 3
     92}}}
     93
     94== zoo-ogr.html File ==
     95
     96
     97{{{
     98<h3>Single geometry processing</h3>
     99<ul>
     100  <li>
     101   <input type="button" onclick="simpleProcessing(this.value);" value="Buffer"/>
     102   Distance:
     103   <input id="bufferDist" value="1"/>
     104  </li>
     105  <li>
     106   <input type="button" onclick="simpleProcessing(this.value);" value="ConvexHull"/>
     107  </li>
     108  <li>
     109   <input type="button" onclick="simpleProcessing(this.value);" value="Boundary"/>
     110  </li>
     111  <li>
     112   <input type="button" onclick="simpleProcessing(this.value);" value="Centroid"/>
     113  </li>
     114</ul>
     115}}}

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png