Ignore:
Timestamp:
27/06/12 16:41:44 (7 years ago)
Author:
mnagni
Message:

Incomplete - # 22488: CEDA Observation Collection - Geographical Extent
 http://team.ceda.ac.uk/trac/ceda/ticket/22488

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/MolesManager/trunk/src/libs/postgisutil.py

    r8392 r8416  
    5656    return _processGeometries(bboxes, epb, 'ST_Union') 
    5757 
     58def unifyGeometriesAsBBox(bboxes, epb): 
     59    union = _processGeometries(bboxes, epb, 'ST_Union') 
     60    return getBox2D(union, epb) 
     61 
    5862def intersectGeometries(bboxes, epb): 
    5963    return _processGeometries(bboxes, epb, 'ST_Intersection') 
     64 
     65def getBox2D(geometry, epb): 
     66    cmdString = 'SELECT ST_Box2D(st_setSRID(\'%s\', 4326));' % (geometry) 
     67    bbox = normalizeUnicode(epb.executeNative(cmdString).first()[0]) 
     68    return bbox 
    6069         
    6170def _processGeometries(bboxes, epb, function): 
     
    8695 
    8796def normalizeUnicode(text): 
    88     return unicodedata.normalize('NFKD', text).encode('ascii','ignore') 
     97    if isinstance(text, unicode): 
     98        return unicodedata.normalize('NFKD', text).encode('ascii','ignore') 
     99    return text 
Note: See TracChangeset for help on using the changeset viewer.