Ignore:
Timestamp:
Feb 1, 2011, 9:48:16 PM (14 years ago)
Author:
djay
Message:

Correct the zcfg files and add the Python Services Provider base-vect-ops-py to run with QGIS WPS Client.

Location:
trunk/zoo-services/ogr/base-vect-ops-py/cgi-env
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-services/ogr/base-vect-ops-py/cgi-env/BoundaryPy.zcfg

    r80 r106  
    2323     mimeType = text/xml
    2424     encoding = UTF-8
    25      schema = http://fooa/gml/3.1.0/polygon.xsd
     25     schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
    2626    </Default>
    2727    <Supported>
     
    4040   <ComplexData>
    4141    <Default>
     42     mimeType = text/xml
     43     encoding = UTF-8
     44     schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
     45    </Default>
     46    <Supported>
    4247     mimeType = application/json
    4348     encoding = UTF-8
    44     </Default>
    45     <Supported>
    46      mimeType = text/xml
    47      encoding = UTF-8
    48      schema = http://fooa/gml/3.1.0/polygon.xsd
    4949    </Supported>
    5050    <Supported>
    5151     mimeType = text/xml
    5252     encoding = base64
    53      schema = http://fooa/gml/3.1.0/polygon.xsd
    54      asReference = true
     53     schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
    5554    </Supported>
    5655   </ComplexData>
  • trunk/zoo-services/ogr/base-vect-ops-py/cgi-env/BufferPy.zcfg

    r80 r106  
    2424     mimeType = text/xml
    2525     encoding = UTF-8
    26      schema = http://fooa/gml/3.1.0/polygon.xsd
     26     schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
    2727     asReference = true
    2828    </Default>
    2929    <Supported>
    30      mimeType = aplication/json
     30     mimeType = application/json
    3131     encoding = UTF-8
    3232    </Supported>
     
    5757   <ComplexData>
    5858    <Default>
     59     mimeType = text/xml
     60     encoding = UTF-8
     61     schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
     62    </Default>
     63    <Supported>
    5964     mimeType = application/json
    6065     encoding = UTF-8
    61     </Default>
    62     <Supported>
    63      mimeType = text/xml
    64      encoding = UTF-8
    65      schema = http://fooa/gml/3.1.0/polygon.xsd
    66      asReference = true
    6766    </Supported>
    6867   </ComplexData>
  • trunk/zoo-services/ogr/base-vect-ops-py/cgi-env/CentroidPy.zcfg

    r80 r106  
    2424     mimeType = text/xml
    2525     encoding = UTF-8
    26      schema = http://fooa/gml/3.1.0/polygon.xsd
     26     schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
    2727    </Default>
    2828    <Supported>
    2929     mimeType = text/xml
    3030     encoding = base64
    31      schema = http://fooa/gml/3.1.0/polygon.xsd
     31     schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
    3232    </Supported>
    3333   </ComplexData>
     
    4242   <ComplexData>
    4343    <Default>
     44     mimeType = text/xml
     45     encoding = UTF-8
     46     schema = http://schemas.opengis.net/gml/3.1.0/point.xsd
     47    </Default>
     48    <Supported>
    4449     mimeType = application/json
    4550     encoding = UTF-8
    46     </Default>
    47     <Supported>
    48      mimeType = text/xml
    49      encoding = UTF-8
    50      schema = http://fooa/gml/3.1.0/point.xsd
    51      asReference = true
    5251    </Supported>
    5352   </ComplexData>
  • trunk/zoo-services/ogr/base-vect-ops-py/cgi-env/ConvexHullPy.zcfg

    r80 r106  
    2323     mimeType = text/xml
    2424     encoding = UTF-8
    25      schema = http://fooa/gml/3.1.0/polygon.xsd
     25     schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
    2626    </Default>
    2727    <Supported>
     
    4040   <ComplexData>
    4141    <Default>
     42     mimeType = text/xml
     43     encoding = UTF-8
     44     schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
     45    </Default>
     46    <Supported>
    4247     mimeType = application/json
    4348     encoding = UTF-8
    44     </Default>
    45     <Supported>
    46      mimeType = text/xml
    47      encoding = UTF-8
    48      schema = http://fooa/gml/3.1.0/polygon.xsd
    4949    </Supported>
    5050   </ComplexData>
  • trunk/zoo-services/ogr/base-vect-ops-py/cgi-env/DifferencePy.zcfg

    r80 r106  
    2424     mimeType = text/xml
    2525     encoding = UTF-8
    26      schema = http://fooa/gml/3.1.0/polygon.xsd
     26     schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
    2727    </Default>
    2828    <Supported>
    2929     mimeType = text/xml
    3030     encoding = base64
    31      schema = http://fooa/gml/3.1.0/polygon.xsd
     31     schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
    3232    </Supported>
    3333   </ComplexData>
     
    4343    <Default>
    4444     mimeType = text/xml
    45      schema = http://fooa/gml/3.1.0/polygon.xsd
     45     schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
    4646     encoding = UTF-8
    4747    </Default>
     
    4949     mimeType = text/xml
    5050     encoding = base64
    51      schema = http://fooa/gml/3.1.0/polygon.xsd
     51     schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
    5252    </Supported>
    5353   </ComplexData>
     
    6262    <ComplexData>
    6363     <Default>
    64        mimeType = application/json
    65        encoding = UTF-8
    66        extension = js
     64      mimeType = text/xml
     65      schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
     66      encoding = UTF-8
     67      extension = xml
    6768     </Default>
    6869     <Supported>
    69       mimeType = text/xml
    70       schema = http://fooa/gml/3.1.0/polygon.xsd
     70      mimeType = application/json
    7171      encoding = UTF-8
    72       extension = xml
     72      extension = js
    7373     </Supported>
    7474    </ComplexData>
  • trunk/zoo-services/ogr/base-vect-ops-py/cgi-env/IntersectionPy.zcfg

    r80 r106  
    2424     mimeType = text/xml
    2525     encoding = UTF-8
    26      schema = http://fooa/gml/3.1.0/polygon.xsd
     26     schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
    2727    </Default>
    2828    <Supported>
    2929     mimeType = text/xml
    3030     encoding = base64
    31      schema = http://fooa/gml/3.1.0/polygon.xsd
     31     schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
    3232    </Supported>
    3333   </ComplexData>
     
    4343    <Default>
    4444     mimeType = text/xml
    45      schema = http://fooa/gml/3.1.0/polygon.xsd
     45     schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
    4646     encoding = UTF-8
    4747    </Default>
     
    4949     mimeType = text/xml
    5050     encoding = base64
    51      schema = http://fooa/gml/3.1.0/polygon.xsd
     51     schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
    5252    </Supported>
    5353   </ComplexData>
     
    6262    <ComplexData>
    6363     <Default>
    64        mimeType = application/json
    65        encoding = UTF-8
    66        extension = js
     64      mimeType = text/xml
     65      schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
     66      encoding = UTF-8
     67      extension = xml
    6768     </Default>
    6869     <Supported>
    69       mimeType = text/xml
    70       schema = http://fooa/gml/3.1.0/polygon.xsd
     70      mimeType = application/json
    7171      encoding = UTF-8
    72       extension = xml
     72      extension = js
    7373     </Supported>
    7474    </ComplexData>
  • trunk/zoo-services/ogr/base-vect-ops-py/cgi-env/SymDifferencePy.zcfg

    r80 r106  
    2424     mimeType = text/xml
    2525     encoding = UTF-8
    26      schema = http://fooa/gml/3.1.0/polygon.xsd
     26     schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
    2727    </Default>
    2828    <Supported>
    2929     mimeType = text/xml
    3030     encoding = base64
    31      schema = http://fooa/gml/3.1.0/polygon.xsd
     31     schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
     32    </Supported>
     33    <Supported>
     34     mimeType = application/json
     35     encoding = UTF-8
    3236    </Supported>
    3337   </ComplexData>
     
    4347    <Default>
    4448     mimeType = text/xml
    45      schema = http://fooa/gml/3.1.0/polygon.xsd
     49     schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
    4650     encoding = UTF-8
    4751    </Default>
     
    4953     mimeType = text/xml
    5054     encoding = base64
    51      schema = http://fooa/gml/3.1.0/polygon.xsd
     55     schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
     56    </Supported>
     57    <Supported>
     58     mimeType = application/json
     59     encoding = UTF-8
    5260    </Supported>
    5361   </ComplexData>
     
    6270    <ComplexData>
    6371     <Default>
    64        mimeType = application/json
    65        encoding = UTF-8
    66        extension = js
     72      mimeType = text/xml
     73      schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
     74      encoding = UTF-8
     75      extension = xml
    6776     </Default>
    6877     <Supported>
    69       mimeType = text/xml
    70       schema = http://fooa/gml/3.1.0/polygon.xsd
     78      mimeType = application/json
    7179      encoding = UTF-8
    72       extension = xml
     80      extension = js
    7381     </Supported>
    7482    </ComplexData>
  • trunk/zoo-services/ogr/base-vect-ops-py/cgi-env/UnionPy.zcfg

    r80 r106  
    2424     mimeType = text/xml
    2525     encoding = UTF-8
    26      schema = http://fooa/gml/3.1.0/polygon.xsd
     26     schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
    2727    </Default>
    2828    <Supported>
     
    4242    <Default>
    4343     mimeType = text/xml
    44      schema = http://fooa/gml/3.1.0/polygon.xsd
     44     schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
    4545     encoding = UTF-8
    4646    </Default>
     
    6060    <ComplexData>
    6161     <Default>
    62        mimeType = application/json
    63        encoding = UTF-8
    64        extension = js
     62      mimeType = text/xml
     63      schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd
     64      encoding = UTF-8
     65      extension = xml
    6566     </Default>
    6667     <Supported>
    67       mimeType = text/xml
    68       schema = http://fooa/gml/3.1.0/polygon.xsd
     68      mimeType = application/json
    6969      encoding = UTF-8
    70       extension = xml
     70      extension = js
    7171     </Supported>
    7272    </ComplexData>
  • trunk/zoo-services/ogr/base-vect-ops-py/cgi-env/ogr_sp.py

    r9 r106  
    11import osgeo.ogr
    22import libxml2
     3import os
     4import sys
    35
    46def createGeometryFromWFS(my_wfs_response):
    57    doc=libxml2.parseMemory(my_wfs_response,len(my_wfs_response))
    68    ctxt = doc.xpathNewContext()
    7     res=ctxt.xpathEval("/*/*/*/*/*[local-name()='Polygon' or local-name()='MultiPolygon']")
    8     for node in res:
    9         geometry_as_string=node.serialize()
    10         geometry=osgeo.ogr.CreateGeometryFromGML(geometry_as_string)
    11         return geometry
     9    res=ctxt.xpathEval("/*/*/*/*/*[local-name()='Polygon' or local-name()='MultiPolygon' or local-name()='Point' or local-name()='MultiPoint' or local-name()='MultiLinestring' or local-name()='MultiLinestring' ]")
     10    geometry=[]
     11    try:
     12        for node in res:
     13            geometry_as_string=node.serialize()
     14            geometry+=[osgeo.ogr.CreateGeometryFromGML(geometry_as_string)]
     15    except:
     16        print >> sys.stderr,"Error"
    1217    return geometry
    1318
    1419def extractInputs(obj):
    1520    if obj["mimeType"]=="application/json":
    16         return osgeo.ogr.CreateGeometryFromJson(obj["value"])
     21        return [osgeo.ogr.CreateGeometryFromJson(obj["value"])]
    1722    else:
    1823        try:
    1924                return createGeometryFromWFS(obj["value"])
    2025        except:
    21                 return osgeo.ogr.CreateGeometryFromJson(obj["value"])
     26                return [osgeo.ogr.CreateGeometryFromJson(obj["value"])]
    2227    return null
    2328   
    24 def outputResult(obj,geom):
     29def outputResult(conf,obj,geom):
     30    driverName = "GML"
     31    extension = [ ".xml" , ".xsd" ]
    2532    if obj["mimeType"]=="application/json":
    26         obj["value"]=geom.ExportToJson()
    27         obj["mimeType"]="text/plain"
    28     else:
    29         obj["value"]=geom.ExportToGML()
     33        driverName = "GeoJSON"
     34        extension = [ ".js" ]
     35    drv = osgeo.ogr.GetDriverByName( driverName )
     36    ds = drv.CreateDataSource( conf["main"]["tmpPath"]+"/store"+conf["lenv"]["sid"]+extension[0] )
     37    lyr = ds.CreateLayer( "Result", None, osgeo.ogr.wkbUnknown )
     38    field_defn = osgeo.ogr.FieldDefn( "Name", osgeo.ogr.OFTString )
     39    field_defn.SetWidth( len("Result10000") )
     40    lyr.CreateField ( field_defn )
     41    i=0
     42    while i < len(geom):
     43        feat = osgeo.ogr.Feature( lyr.GetLayerDefn())
     44        feat.SetField( "Name", "Result"+str(i) )
     45        feat.SetGeometry(geom[i])
     46        lyr.CreateFeature(feat)
     47        feat.Destroy()
     48        geom[i].Destroy()
     49        i+=1
     50    ds.Destroy()
     51    obj["value"]=open(conf["main"]["tmpPath"]+"/store"+conf["lenv"]["sid"]+extension[0],"r").read()
     52    os.unlink(conf["main"]["tmpPath"]+"/store"+conf["lenv"]["sid"]+extension[0])
     53    if len(extension)>1:
     54        os.unlink(conf["main"]["tmpPath"]+"/store"+conf["lenv"]["sid"]+extension[1])
    3055
    3156def BoundaryPy(conf,inputs,outputs):
    3257    geometry=extractInputs(inputs["InputPolygon"])
    33     rgeom=geometry.GetBoundary()
    34     if outputs["Result"]["mimeType"]=="application/json":
    35         outputs["Result"]["value"]=rgeom.ExportToJson()
    36         outputs["Result"]["mimeType"]="text/plain"
    37     else:
    38         outputs["Result"]["value"]=rgeom.ExportToGML()
     58    i=0
     59    rgeometries=[]
     60    while i < len(geometry):
     61        rgeometries+=[geometry[i].GetBoundary()]
     62        geometry[i].Destroy()
     63        i+=1
     64    outputResult(conf,outputs["Result"],rgeometries)
    3965    return 3
    4066
    4167def CentroidPy(conf,inputs,outputs):
    4268    geometry=extractInputs(inputs["InputPolygon"])
    43     if geometry.GetGeometryType()!=3:
    44         geometry=geometry.ConvexHull()
    45     rgeom=geometry.Centroid()
    46     outputResult(outputs["Result"],rgeom)
     69    i=0
     70    rgeometries=[]
     71    while i < len(geometry):
     72        if geometry[i].GetGeometryType()!=3:
     73            geometry[i]=geometry[i].ConvexHull()
     74        rgeometries+=[geometry[i].Centroid()]
     75        geometry[i].Destroy()
     76        i+=1
     77    outputResult(conf,outputs["Result"],rgeometries)
    4778    return 3
    4879
    4980def ConvexHullPy(conf,inputs,outputs):
    5081    geometry=extractInputs(inputs["InputPolygon"])
    51     rgeom=geometry.ConvexHull()
    52     outputResult(outputs["Result"],rgeom)
     82    i=0
     83    rgeometries=[]
     84    while i < len(geometry):
     85        rgeometries+=[geometry[i].ConvexHull()]
     86        geometry[i].Destroy()
     87        i+=1
     88    outputResult(conf,outputs["Result"],rgeometries)
    5389    return 3
    5490
    5591def BufferPy(conf,inputs,outputs):
    56     geometry=createGeometryFromWFS(inputs["InputPolygon"]["value"])
    5792    try:
    5893        bdist=int(inputs["BufferDistance"]["value"])
    5994    except:
    6095        bdist=10
    61     rgeom=geometry.Buffer(bdist)
    62     if outputs["Result"]["mimeType"]=="application/json":
    63         outputs["Result"]["value"]=rgeom.ExportToJson()
    64         outputs["Result"]["mimeType"]="text/plain"
    65     else:
    66         outputs["Result"]["value"]=rgeom.ExportToGML()
     96    geometry=extractInputs(inputs["InputPolygon"])
     97    i=0
     98    rgeometries=[]
     99    while i < len(geometry):
     100        rgeometries+=[geometry[i].Buffer(bdist)]
     101        geometry[i].Destroy()
     102        i+=1
     103    outputResult(conf,outputs["Result"],rgeometries)
     104    i=0
    67105    return 3
    68106
     
    70108    geometry1=extractInputs(inputs["InputEntity1"])
    71109    geometry2=extractInputs(inputs["InputEntity2"])
    72     rgeom=geometry1.Union(geometry2)
    73     outputResult(outputs["Result"],rgeom)
     110    rgeometries=[]
     111    i=0
     112    while i < len(geometry1):
     113        j=0
     114        while j < len(geometry2):
     115            tres=geometry1[i].Union(geometry2[j])
     116            if not(tres.IsEmpty()):
     117                rgeometries+=[tres]
     118            j+=1
     119        geometry1[i].Destroy()
     120        i+=1
     121    i=0
     122    while i < len(geometry2):
     123        geometry2[i].Destroy()
     124        i+=1
     125    outputResult(conf,outputs["Result"],rgeometries)
    74126    return 3
    75127
     
    77129    geometry1=extractInputs(inputs["InputEntity1"])
    78130    geometry2=extractInputs(inputs["InputEntity2"])
    79     rgeom=geometry1.Intersection(geometry2)
    80     outputResult(outputs["Result"],rgeom)
     131    rgeometries=[]
     132    i=0
     133    while i < len(geometry1):
     134        j=0
     135        while j < len(geometry2):
     136            tres=geometry1[i].Intersection(geometry2[j])
     137            if not(tres.IsEmpty()):
     138                rgeometries+=[tres]
     139            j+=1
     140        geometry1[i].Destroy()
     141        i+=1
     142    i=0
     143    while i < len(geometry2):
     144        geometry2[i].Destroy()
     145        i+=1
     146    outputResult(conf,outputs["Result"],rgeometries)
    81147    return 3
    82148
     
    84150    geometry1=extractInputs(inputs["InputEntity1"])
    85151    geometry2=extractInputs(inputs["InputEntity2"])
    86     rgeom=geometry1.Difference(geometry2)
    87     outputResult(outputs["Result"],rgeom)
     152    rgeometries=[]
     153    i=0
     154    while i < len(geometry1):
     155        j=0
     156        while j < len(geometry2):
     157            tres=geometry1[i].Difference(geometry2[j])
     158            if not(tres.IsEmpty()):
     159                rgeometries+=[tres]
     160            j+=1
     161        geometry1[i].Destroy()
     162        i+=1
     163    i=0
     164    while i < len(geometry2):
     165        geometry2[i].Destroy()
     166        i+=1
     167    outputResult(conf,outputs["Result"],rgeometries)
    88168    return 3
    89169
     
    91171    geometry1=extractInputs(inputs["InputEntity1"])
    92172    geometry2=extractInputs(inputs["InputEntity2"])
    93     rgeom=geometry1.SymmetricDifference(geometry2)
    94     outputResult(outputs["Result"],rgeom)
     173    rgeometries=[]
     174    i=0
     175    while i < len(geometry1):
     176        j=0
     177        while j < len(geometry2):
     178            rgeometries+=[geometry1[i].SymmetricDifference(geometry2[j])]
     179            j+=1
     180        geometry1[i].Destroy()
     181        i+=1
     182    i=0
     183    while i < len(geometry2):
     184        geometry2[i].Destroy()
     185        i+=1
     186    outputResult(conf,outputs["Result"],rgeometries)
    95187    return 3
Note: See TracChangeset for help on using the changeset viewer.

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