1

I'm trying to setup a process using PyWPS. I've been able to send geometry and receive them in GML with this code :

     self.vectorin = self.addComplexInput(identifier="vectorin",
                                              title="Geometrie 1",
                                              formats=[{"mimeType":"text/xml"},{"mimeType":"application/xml"}])
     self.vectorin2 = self.addComplexInput(identifier="vectorin2",
                                              title="Geometrie 2",
                                              formats=[{"mimeType":"text/xml"},{"mimeType":"application/xml"}])
     self.vectorout = self.addComplexOutput(identifier="vectorout",
                                              title="Vector file",
                                              formats = [{"mimeType":"text/xml"}])

 def execute(self):
    self.vectorout.setValue(self.vectorin.getValue())
    return

This operation is useless but it is the only exemple with PyWPS 3.2.x using ComplexData. I'm trying to extract the geometry from both of my inputs to execute operations with GDAL/OGR.

Is there anyway I can do it and then send it back in GML as the output?

Update :

Exemple : when I'm trying to run

def execute(self): 
  geometry1 = Osgeo.ogr.CreateGeometryFromGML(self.vectorin.getValue()).Ge‌​tGeometryRef()          
  geometry2 = osgeo.ogr.CreateGeometryFromGML(self.vectorin2.getValue()).G‌​etGeometryRef() 
  geometry3 = geometry1.Intersection(geometry2)
  geometry3.SetGeometryDirectly(geometry3) 
  self.vectorout.setValue(geometry3.ExportToGML()) 
  return 

I get "Failed to execute WPS process [testPerfoPy]: 'NoneType' object has no attribute 'GetGeometryRef'" So I'm presuming that I can't use CreateGeometryFromGML ? I can't stop the code while it executes so I'm not even sure if the value in self.vectorin.getValue() is really the GML.

5
  • 1
    PyWPS 3.2.x supports GML both as complex input and complex output. What is exactly the issue you are facing? – Luís de Sousa Feb 16 '17 at 13:49
  • I wan't to extract the geometries from the GML and use them with GDAL/OGr to compute their union and send the result back to the client. Right now, I can take the geometries and send them back but I am not able to make operations on them. – Miguel Sanchez Feb 16 '17 at 13:51
  • Do you have an error message you can post? Is there anything out of the ordinary in the log? – Luís de Sousa Feb 16 '17 at 14:41
  • With the code : code def execute(self): geometry1 = osgeo.ogr.CreateGeometryFromGML(self.vectorin.getValue()).GetGeometryRef() geometry2 = osgeo.ogr.CreateGeometryFromGML(self.vectorin2.getValue()).GetGeometryRef() geometry3 = geometry1.Intersection(geometry2) geometry3.SetGeometryDirectly(geometry3) self.vectorout.setValue(geometry3.ExportToGML()) return code I get "Failed to execute WPS process [testPerfoPy]: 'NoneType' object has no attribute 'GetGeometryRef'" So I'm presuming that I can't use CreateGeometryFromGML? Formating is hard sorry – Miguel Sanchez Feb 16 '17 at 15:11
  • This is hard to interpret in the comments, could you please add that code to the question? In any case, that seems to be something with the way you are using OGR. Have you checked if the type you are passing to the CreateGeometryFomGML() method is correct? – Luís de Sousa Feb 17 '17 at 7:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.