Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14215

Python dynmic procession of Oracle SDO_GEOMETRY objects

$
0
0

There are some situations where the WKT format does not work (3D,4D geometries, arc in a geodetic).These are handled in Postgis EWKT format.

I have an out converter

def SDOOutConverter(DBobj):  if DBobj.SDO_ELEM_INFO:    sdo_elem = DBobj.SDO_ELEM_INFO.aslist()  else:    sdo_elem = None  if DBobj.SDO_ORDINATES:    sdo_ord = DBobj.SDO_ORDINATES.aslist()  else:    sdo_ord = None   return lSDO(     int(DBobj.SDO_GTYPE)    ,DBobj.SDO_SRID    ,sdo_elem    ,sdo_ord  ) 

and the object definition.

class lSDO(object):  def __init__(self, gtype, srid, elemInfo, ordinates):    self.gtype = gtype    self.srid = int(srid or 0)    self.elemInfo = elemInfo    self.ordinates = ordinates

I have an example of returning the object information from a fixed query

cur.execute('select  mkt_id, name, shape from hamster.cola_markets t')for time_id, name, obj in cur:      sdo_type = obj.gtype      sdo_srid = obj.srid      sdo_elem = obj.elemInfo      sdo_ord = obj.ordinates

This takes the geometry column (shape) then in the for loop access the object.

Question:How would i do this dynamically.There are several tables with differing structures.

how would I write a dynamicfor time_id, name, obj in cur:?

bonus question, How would one handle a table with multiple GEOMETRY columns?

I can crate a column list and tried using the string in the for loop

for '{}'.format(objcol) in cur: 

results in:for '{}'.format(objcol) in cur:^^^^^^^^^^^^^^^^^^^SyntaxError: cannot assign to function call


Viewing all articles
Browse latest Browse all 14215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>