Skip to content

Commit

Permalink
#4. Respect vertical axis first in zoom_factor.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Armstrong committed Jun 15, 2018
1 parent a45a553 commit 78bdeaa
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions datacube_wms/wms_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,17 @@ def wms_exception(e, traceback=[]):
{"Content-Type": "application/xml"})


def _get_geobox(args, crs):
width = int(args['width'])
height = int(args['height'])
def _get_geobox_xy(args, crs):
if service_cfg["published_CRSs"][crs.crs_str].get("vertical_coord_first"):
miny, minx, maxy, maxx = map(float, args['bbox'].split(','))
else:
minx, miny, maxx, maxy = map(float, args['bbox'].split(','))
return minx, miny, maxx, maxy

def _get_geobox(args, crs):
width = int(args['width'])
height = int(args['height'])
minx, miny, maxx, maxy = _get_geobox_xy(args, crs)

# miny-maxy for negative scale factor and maxy in the translation, includes inversion of Y axis.
affine = Affine.translation(minx, maxy) * Affine.scale((maxx - minx) / width, (miny - maxy) / height)
Expand All @@ -73,7 +77,7 @@ def zoom_factor(args, crs):
# Extract request bbox and crs
width = int(args['width'])
height = int(args['height'])
minx, miny, maxx, maxy = map(float, args['bbox'].split(','))
minx, miny, maxx, maxy = _get_geobox_xy(args, crs)
p1 = geometry.point(minx, maxy, crs)
p2 = geometry.point(minx, miny, crs)
p3 = geometry.point(maxx, maxy, crs)
Expand Down

0 comments on commit 78bdeaa

Please sign in to comment.