Ignore:
Timestamp:
Apr 23, 2014, 3:05:01 AM (11 years ago)
Author:
djay
Message:

Add the optional YAML ZCFG support #4 and the zcfg2yaml converter. Return error messages that enable the service provider to quickly identify the root cause of errors due to configuration file syntax #90. Fix logic in addMapToMap #91. Enable multiple range definition using default and supported blocks. Add the lastest revision number in version.h (available from Python ZOO-API as zoo.VERSION).

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

Legend:

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

    r106 r465  
    1 [CentroidPy]
    2  Title = Get the centroid of a polygon.
    3  Abstract = Compute the geometry centroid.
    4  Profile = urn:ogc:wps:1.0.0:centroid
    5  processVersion = 2
     1[Clean]
     2 Title = Extract the feature that have a valid geometry field.
     3 Abstract = Extract the feature that have a valid geometry field.
     4 processVersion = 1
    65 storeSupported = true
    76 statusSupported = true
    87 serviceProvider = ogr_sp
    98 serviceType = Python
    10  <MetaData>
    11    title = Demo
    12  </MetaData>
    139 <DataInputs>
    14   [InputPolygon]
     10  [InputData]
    1511   Title = Polygon to get the centroid
    1612   Abstract = The centroid which is not necessarily within the geometry.
    1713   minOccurs = 1
    1814   maxOccurs = 1
    19    <MetaData>
    20     title = Mon test 
    21    </MetaData>   
    2215   <ComplexData>
    2316    <Default>
     
    3730   Title = The Centroid
    3831   Abstract = JSON String / GML Entity of the centroid
    39    <MetaData>
    40     title = Mon test 
    41    </MetaData>   
    4232   <ComplexData>
    4333    <Default>
  • trunk/zoo-project/zoo-services/ogr/base-vect-ops-py/cgi-env/ogr_sp.py

    r447 r465  
    5252        print >> sys.stderr,e
    5353        return []
    54 
     54   
    5555def buildFeatureFromGeomtry(conf,geom,driverName,ext):
    5656    drv = osgeo.ogr.GetDriverByName( driverName )
     
    6969def createGeometryFromWFS(conf,my_wfs_response):
    7070    try:
    71         geom=osgeo.ogr.CreateGeometryFromGML(my_wfs_response.replace('<?xml version="1.0" encoding="utf-8"?>\n',''))
    72     except:
     71        geom=osgeo.ogr.CreateGeometryFromGML(my_wfs_response.replace('<?xml version="1.0" encoding="utf-8"?>\n','').replace('<?xml version=\'1.0\' encoding="utf-8"?>\n',''))
     72    except Exception,e:
     73        print >> sys.stderr,"**"
     74        print >> sys.stderr,e
    7375        geom=None
    7476    try:
     77        print >> sys.stderr,geom is None
    7578        if geom is None:
    7679            if not(conf["lenv"].has_key("cnt")):
     
    98101   
    99102def outputResult(conf,obj,geom):
    100     driverName = "GML"
    101     extension = [ ".xml" , ".xsd" ]
     103    if obj["mimeType"].count("text/xml")>0:
     104        driverName = "GML"
     105        extension = [ ".xml" , ".xsd" ]
     106        format_list = { "2.": 'GML2', "3.1.1": 'GML3', "3.1": 'GML3Deegree', "3.2": 'GML3.2' }
     107        opts=['FORMAT=%s,GML3_LONGSRS=YES',format_list["3.2"]]
     108        for i in format_list:
     109            if obj["mimeType"].count(i)>0:
     110                opts=['FORMAT=%s,GML3_LONGSRS=YES',format_list[i]]
    102111    if obj["mimeType"]=="application/json":
    103112        driverName = "GeoJSON"
    104113        extension = [ ".js" ]
     114        opts=None
    105115    if obj.keys().count("schema")>0 and \
    106116            obj["schema"]=="http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd":
    107117        driverName = "KML"
    108118        extension = [ ".kml" ]
     119        opts=None
    109120    drv = osgeo.ogr.GetDriverByName( driverName )
    110     # Create virtual file
    111     ds = drv.CreateDataSource( "/vsimem/store"+conf["lenv"]["sid"]+extension[0] )
     121    print >> sys.stderr,drv
     122    # Create virtual file
     123    ds = drv.CreateDataSource( "/vsimem/store"+conf["lenv"]["sid"]+extension[0],options = opts)
     124    print >> sys.stderr,ds
    112125    lyr = ds.CreateLayer( "Result", None, osgeo.ogr.wkbUnknown )
    113     i=0
     126    print >> sys.stderr,lyr
     127    i=0
     128    print >> sys.stderr,driverName
     129    print >> sys.stderr,extension
    114130    while i < len(geom):
    115131        if i==0 and driverName!="GeoJSON":
     
    123139                    oFieldDefn.SetPrecision( poSrcFieldDefn.GetPrecision() )
    124140                    lyr.CreateField( oFieldDefn )
    125         lyr.CreateFeature(geom[i])
     141        try:
     142            lyr.CreateFeature(geom[i])
     143        except:
     144            pass
    126145        geom[i].Destroy()
    127146        i+=1
     
    157176    outputResult(conf,outputs["Result"],rgeometries)
    158177    i=0
     178    return zoo.SERVICE_SUCCEEDED
     179
     180def Clean(conf,inputs,outputs):
     181    from shapely.wkb import loads
     182    print >> sys.stderr, "Starting service ..."
     183    features=extractInputs(conf,inputs["InputData"])
     184    i=0
     185    rgeometries=[]
     186    while i < len(features):
     187        tmp=features[i].Clone()
     188        resg=features[i].GetGeometryRef()
     189        if resg is not None:
     190            geom = loads(resg.ExportToWkb())
     191            if geom.is_valid:
     192                tmp.SetGeometryDirectly(resg)
     193                rgeometries+=[tmp]
     194                print >> sys.stderr,"valid !"
     195            else:
     196                print >> sys.stderr,"invalid !"
     197                print >> sys.stderr,geom.wkt[0:50]
     198        features[i].Destroy()
     199        resg.thisown=False
     200        tmp.thisown=False
     201        i+=1
     202    outputResult(conf,outputs["Result"],rgeometries)
     203    i=0
     204    print >> sys.stderr,"Return"
     205    return zoo.SERVICE_SUCCEEDED
     206
     207def TransformService(conf,inputs,outputs):
     208    from osgeo import osr
     209    geometry=extractInputs(conf,inputs["InputData"])
     210    sourceRef = osr.SpatialReference()
     211    tmp=inputs["SourceCRS"]["value"].split(":")
     212    sourceRef.ImportFromEPSG(int(tmp[len(tmp)-1]))
     213    targetRef = osr.SpatialReference()   
     214    tmp=inputs["TargetCRS"]["value"].split(":")
     215    targetRef.ImportFromEPSG(int(tmp[len(tmp)-1]))
     216    transform = osr.CoordinateTransformation(sourceRef, targetRef)
     217    i=0
     218    rgeometries=[]
     219    while i < len(geometry):
     220        tmp=geometry[i].Clone()
     221        resg=geometry[i].GetGeometryRef()
     222        resg.Transform(transform)
     223        tmp.SetGeometryDirectly(resg.Clone())
     224        rgeometries+=[tmp]
     225        geometry[i].Destroy()
     226        i+=1
     227    outputResult(conf,outputs["TransformedData"],rgeometries)
    159228    return zoo.SERVICE_SUCCEEDED
    160229
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