Skip to content

Commit

Permalink
Fix incorrect PyProj useage. [per Ronak]
Browse files Browse the repository at this point in the history
  • Loading branch information
Feroz Abdul-Kadar committed May 4, 2015
1 parent 60bcd9f commit 05d7b41
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions functions/utils.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
__all__ = ['isProductVersionOK',
'computePixelBlockExtents',
__all__ = ['isProductVersionOK',
'computePixelBlockExtents',
'computeCellSize',
'Projection',
'Trace']

## ----- ## ----- ## ----- ## ----- ## ----- ## ----- ## ----- ## ----- ##
# ----- ## ----- ## ----- ## ----- ## ----- ## ----- ## ----- ## ----- #


def isProductVersionOK(productInfo, major, minor, build):
def isProductVersionOK(productInfo, major, minor, build):
v = productInfo['major']*1.e+10 + int(0.5+productInfo['minor']*10)*1.e+6 + productInfo['build']
return v >= major*1e+10 + minor*1e+7 + build

Expand All @@ -18,19 +18,22 @@ def computePixelBlockExtents(tlc, shape, props):
dX, dY = (e[2]-e[0])/w, (e[3]-e[1])/h # cell size of parent raster
xMin, yMax = e[0]+tlc[0]*dX, e[3]-tlc[1]*dY # top-left corner of request on map
return (xMin, yMax-nRows*dY, xMin+nCols*dX, yMax) # extents of request on map


def computeCellSize(props, sr=None, proj=None):
e, w, h = props['extent'], props['width'], props['height'] # dimensions of parent raster
if sr is None:
return (e[2]-e[0])/w, (e[3]-e[1])/h # cell size of parent raster

if proj is None: proj = Projection() # reproject extents
(xMin, xMax), (yMin, yMax) = proj.transform(props['spatialReference'], sr, (e[0], e[2]), (e[1], e[3]))

if proj is None:
proj = Projection() # reproject extents

(xMin, xMax) = proj.transform(props['spatialReference'], sr, e[0], e[2])
(yMin, yMax) = proj.transform(props['spatialReference'], sr, e[1], e[3])
return (xMax-xMin)/w, (yMax-yMin)/h # cell size of parent raster


## ----- ## ----- ## ----- ## ----- ## ----- ## ----- ## ----- ## ----- ##

# ----- ## ----- ## ----- ## ----- ## ----- ## ----- ## ----- ## ----- #

class Projection():
def __init__(self):
Expand All @@ -52,7 +55,8 @@ def transform(self, inEPSG, outEPSG, x, y):

return self._transformFunc(self._inProj, self._outProj, x, y)

## ----- ## ----- ## ----- ## ----- ## ----- ## ----- ## ----- ## ----- ##
# ----- ## ----- ## ----- ## ----- ## ----- ## ----- ## ----- ## ----- #


class Trace():
def __init__(self):
Expand All @@ -65,5 +69,4 @@ def log(self, s):
self.trace(self.c_char_p(s.encode('utf-8')))
return s

## ----- ## ----- ## ----- ## ----- ## ----- ## ----- ## ----- ## ----- ##

# ----- ## ----- ## ----- ## ----- ## ----- ## ----- ## ----- ## ----- #

0 comments on commit 05d7b41

Please sign in to comment.