Changeset 106 for trunk/zoo-services/ogr/base-vect-ops-py
- Timestamp:
- Feb 1, 2011, 9:48:16 PM (14 years ago)
- 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 23 23 mimeType = text/xml 24 24 encoding = UTF-8 25 schema = http:// fooa/gml/3.1.0/polygon.xsd25 schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd 26 26 </Default> 27 27 <Supported> … … 40 40 <ComplexData> 41 41 <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> 42 47 mimeType = application/json 43 48 encoding = UTF-8 44 </Default>45 <Supported>46 mimeType = text/xml47 encoding = UTF-848 schema = http://fooa/gml/3.1.0/polygon.xsd49 49 </Supported> 50 50 <Supported> 51 51 mimeType = text/xml 52 52 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 55 54 </Supported> 56 55 </ComplexData> -
trunk/zoo-services/ogr/base-vect-ops-py/cgi-env/BufferPy.zcfg
r80 r106 24 24 mimeType = text/xml 25 25 encoding = UTF-8 26 schema = http:// fooa/gml/3.1.0/polygon.xsd26 schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd 27 27 asReference = true 28 28 </Default> 29 29 <Supported> 30 mimeType = ap lication/json30 mimeType = application/json 31 31 encoding = UTF-8 32 32 </Supported> … … 57 57 <ComplexData> 58 58 <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> 59 64 mimeType = application/json 60 65 encoding = UTF-8 61 </Default>62 <Supported>63 mimeType = text/xml64 encoding = UTF-865 schema = http://fooa/gml/3.1.0/polygon.xsd66 asReference = true67 66 </Supported> 68 67 </ComplexData> -
trunk/zoo-services/ogr/base-vect-ops-py/cgi-env/CentroidPy.zcfg
r80 r106 24 24 mimeType = text/xml 25 25 encoding = UTF-8 26 schema = http:// fooa/gml/3.1.0/polygon.xsd26 schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd 27 27 </Default> 28 28 <Supported> 29 29 mimeType = text/xml 30 30 encoding = base64 31 schema = http:// fooa/gml/3.1.0/polygon.xsd31 schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd 32 32 </Supported> 33 33 </ComplexData> … … 42 42 <ComplexData> 43 43 <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> 44 49 mimeType = application/json 45 50 encoding = UTF-8 46 </Default>47 <Supported>48 mimeType = text/xml49 encoding = UTF-850 schema = http://fooa/gml/3.1.0/point.xsd51 asReference = true52 51 </Supported> 53 52 </ComplexData> -
trunk/zoo-services/ogr/base-vect-ops-py/cgi-env/ConvexHullPy.zcfg
r80 r106 23 23 mimeType = text/xml 24 24 encoding = UTF-8 25 schema = http:// fooa/gml/3.1.0/polygon.xsd25 schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd 26 26 </Default> 27 27 <Supported> … … 40 40 <ComplexData> 41 41 <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> 42 47 mimeType = application/json 43 48 encoding = UTF-8 44 </Default>45 <Supported>46 mimeType = text/xml47 encoding = UTF-848 schema = http://fooa/gml/3.1.0/polygon.xsd49 49 </Supported> 50 50 </ComplexData> -
trunk/zoo-services/ogr/base-vect-ops-py/cgi-env/DifferencePy.zcfg
r80 r106 24 24 mimeType = text/xml 25 25 encoding = UTF-8 26 schema = http:// fooa/gml/3.1.0/polygon.xsd26 schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd 27 27 </Default> 28 28 <Supported> 29 29 mimeType = text/xml 30 30 encoding = base64 31 schema = http:// fooa/gml/3.1.0/polygon.xsd31 schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd 32 32 </Supported> 33 33 </ComplexData> … … 43 43 <Default> 44 44 mimeType = text/xml 45 schema = http:// fooa/gml/3.1.0/polygon.xsd45 schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd 46 46 encoding = UTF-8 47 47 </Default> … … 49 49 mimeType = text/xml 50 50 encoding = base64 51 schema = http:// fooa/gml/3.1.0/polygon.xsd51 schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd 52 52 </Supported> 53 53 </ComplexData> … … 62 62 <ComplexData> 63 63 <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 67 68 </Default> 68 69 <Supported> 69 mimeType = text/xml 70 schema = http://fooa/gml/3.1.0/polygon.xsd 70 mimeType = application/json 71 71 encoding = UTF-8 72 extension = xml72 extension = js 73 73 </Supported> 74 74 </ComplexData> -
trunk/zoo-services/ogr/base-vect-ops-py/cgi-env/IntersectionPy.zcfg
r80 r106 24 24 mimeType = text/xml 25 25 encoding = UTF-8 26 schema = http:// fooa/gml/3.1.0/polygon.xsd26 schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd 27 27 </Default> 28 28 <Supported> 29 29 mimeType = text/xml 30 30 encoding = base64 31 schema = http:// fooa/gml/3.1.0/polygon.xsd31 schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd 32 32 </Supported> 33 33 </ComplexData> … … 43 43 <Default> 44 44 mimeType = text/xml 45 schema = http:// fooa/gml/3.1.0/polygon.xsd45 schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd 46 46 encoding = UTF-8 47 47 </Default> … … 49 49 mimeType = text/xml 50 50 encoding = base64 51 schema = http:// fooa/gml/3.1.0/polygon.xsd51 schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd 52 52 </Supported> 53 53 </ComplexData> … … 62 62 <ComplexData> 63 63 <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 67 68 </Default> 68 69 <Supported> 69 mimeType = text/xml 70 schema = http://fooa/gml/3.1.0/polygon.xsd 70 mimeType = application/json 71 71 encoding = UTF-8 72 extension = xml72 extension = js 73 73 </Supported> 74 74 </ComplexData> -
trunk/zoo-services/ogr/base-vect-ops-py/cgi-env/SymDifferencePy.zcfg
r80 r106 24 24 mimeType = text/xml 25 25 encoding = UTF-8 26 schema = http:// fooa/gml/3.1.0/polygon.xsd26 schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd 27 27 </Default> 28 28 <Supported> 29 29 mimeType = text/xml 30 30 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 32 36 </Supported> 33 37 </ComplexData> … … 43 47 <Default> 44 48 mimeType = text/xml 45 schema = http:// fooa/gml/3.1.0/polygon.xsd49 schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd 46 50 encoding = UTF-8 47 51 </Default> … … 49 53 mimeType = text/xml 50 54 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 52 60 </Supported> 53 61 </ComplexData> … … 62 70 <ComplexData> 63 71 <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 67 76 </Default> 68 77 <Supported> 69 mimeType = text/xml 70 schema = http://fooa/gml/3.1.0/polygon.xsd 78 mimeType = application/json 71 79 encoding = UTF-8 72 extension = xml80 extension = js 73 81 </Supported> 74 82 </ComplexData> -
trunk/zoo-services/ogr/base-vect-ops-py/cgi-env/UnionPy.zcfg
r80 r106 24 24 mimeType = text/xml 25 25 encoding = UTF-8 26 schema = http:// fooa/gml/3.1.0/polygon.xsd26 schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd 27 27 </Default> 28 28 <Supported> … … 42 42 <Default> 43 43 mimeType = text/xml 44 schema = http:// fooa/gml/3.1.0/polygon.xsd44 schema = http://schemas.opengis.net/gml/3.1.0/base/feature.xsd 45 45 encoding = UTF-8 46 46 </Default> … … 60 60 <ComplexData> 61 61 <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 65 66 </Default> 66 67 <Supported> 67 mimeType = text/xml 68 schema = http://fooa/gml/3.1.0/polygon.xsd 68 mimeType = application/json 69 69 encoding = UTF-8 70 extension = xml70 extension = js 71 71 </Supported> 72 72 </ComplexData> -
trunk/zoo-services/ogr/base-vect-ops-py/cgi-env/ogr_sp.py
r9 r106 1 1 import osgeo.ogr 2 2 import libxml2 3 import os 4 import sys 3 5 4 6 def createGeometryFromWFS(my_wfs_response): 5 7 doc=libxml2.parseMemory(my_wfs_response,len(my_wfs_response)) 6 8 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" 12 17 return geometry 13 18 14 19 def extractInputs(obj): 15 20 if obj["mimeType"]=="application/json": 16 return osgeo.ogr.CreateGeometryFromJson(obj["value"])21 return [osgeo.ogr.CreateGeometryFromJson(obj["value"])] 17 22 else: 18 23 try: 19 24 return createGeometryFromWFS(obj["value"]) 20 25 except: 21 return osgeo.ogr.CreateGeometryFromJson(obj["value"])26 return [osgeo.ogr.CreateGeometryFromJson(obj["value"])] 22 27 return null 23 28 24 def outputResult(obj,geom): 29 def outputResult(conf,obj,geom): 30 driverName = "GML" 31 extension = [ ".xml" , ".xsd" ] 25 32 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]) 30 55 31 56 def BoundaryPy(conf,inputs,outputs): 32 57 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) 39 65 return 3 40 66 41 67 def CentroidPy(conf,inputs,outputs): 42 68 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) 47 78 return 3 48 79 49 80 def ConvexHullPy(conf,inputs,outputs): 50 81 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) 53 89 return 3 54 90 55 91 def BufferPy(conf,inputs,outputs): 56 geometry=createGeometryFromWFS(inputs["InputPolygon"]["value"])57 92 try: 58 93 bdist=int(inputs["BufferDistance"]["value"]) 59 94 except: 60 95 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 67 105 return 3 68 106 … … 70 108 geometry1=extractInputs(inputs["InputEntity1"]) 71 109 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) 74 126 return 3 75 127 … … 77 129 geometry1=extractInputs(inputs["InputEntity1"]) 78 130 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) 81 147 return 3 82 148 … … 84 150 geometry1=extractInputs(inputs["InputEntity1"]) 85 151 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) 88 168 return 3 89 169 … … 91 171 geometry1=extractInputs(inputs["InputEntity1"]) 92 172 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) 95 187 return 3
Note: See TracChangeset
for help on using the changeset viewer.