Commit ebe1fdf0 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Implemented XY-getters for boxObj.

updated __version__ and __versionalias__
parent 559dc601
Pipeline #276 passed with stages
in 41 seconds
......@@ -8,8 +8,8 @@ from . import similarity
from . import web
from .io.raster.GeoArray import GeoArray
__version__ = '0.2.0'
__versionalias__ = '20170626_01'
__version__ = '0.3.0'
__versionalias__ = '20170630_01'
__author__='Daniel Scheffler'
# Validate GDAL version
......
......@@ -90,6 +90,19 @@ class boxObj(object):
xmin, xmax, ymin, ymax = corner_coord_to_minmax(mapBoxXY)
self.mapPoly = box(xmin, ymin, xmax, ymax)
@property
def boxMapXY(self):
"""Returns a list of XY coordinate tuples for all corners in the order UL_XY, UR_XY, LR_XY, LL_XY.
:return: UL_XY, UR_XY, LR_XY, LL_XY
"""
return tuple((x,y) for y,x in self.boxMapYX)
@boxMapXY.setter
def boxMapXY(self, mapBoxXY):
xmin, xmax, ymin, ymax = corner_coord_to_minmax(mapBoxXY)
self.mapPoly = box(xmin, ymin, xmax, ymax)
@property
def boxImYX(self):
temp_imPoly = round_shapelyPoly_coords(self.imPoly, precision=0, out_dtype=int)
......@@ -102,6 +115,15 @@ class boxObj(object):
xmin, xmax, ymin, ymax = corner_coord_to_minmax(imBoxXY)
self.imPoly = box(xmin, ymin, xmax, ymax)
@property
def boxImXY(self):
return tuple((x,y) for y,x in self.boxImYX)
@boxImXY.setter
def boxImXY(self, imBoxXY):
xmin, xmax, ymin, ymax = corner_coord_to_minmax(imBoxXY)
self.imPoly = box(xmin, ymin, xmax, ymax)
@property
def boundsMap(self):
"""Returns xmin,xmax,ymin,ymax in map coordinates."""
......@@ -120,11 +142,19 @@ class boxObj(object):
xmin, xmax, ymin, ymax = self.boundsIm
return (ymax-ymin),(xmax-xmin)
@property
def imDimsXY(self):
return self.imDimsYX[1], self.imDimsYX[0]
@property
def mapDimsYX(self):
xmin, xmax, ymin, ymax = self.boundsMap
return (ymax-ymin),(xmax-xmin)
@property
def mapDimsXY(self):
return self.mapDimsXY[1], self.mapDimsXY[0]
def buffer_imXY(self, buffImX=0, buffImY=0):
# type: (float, float) -> None
"""Buffer the box in X- and/or Y-direction.
......@@ -179,4 +209,4 @@ def get_winPoly(wp_imYX, ws, gt, match_grid=0):
box_YX = (ymax, xmin), (ymax, xmax), (ymin, xmax), (ymin, xmin) # UL,UR,LR,LL
UL, UR, LR, LL = [imYX2mapYX(imYX, gt) for imYX in box_YX]
box_mapYX = UL, UR, LR, LL
return Polygon([(UL[1], UL[0]), (UR[1], UR[0]), (LR[1], LR[0]), (LL[1], LR[0])]), box_mapYX, box_YX
\ No newline at end of file
return Polygon([(UL[1], UL[0]), (UR[1], UR[0]), (LR[1], LR[0]), (LL[1], LR[0])]), box_mapYX, box_YX
......@@ -17,7 +17,7 @@ test_requirements = requirements + ['coverage']
setup(
name='py_tools_ds',
version='0.2.0',
version='0.3.0',
description="A collection of Python tools by Daniel Scheffler.",
long_description=readme + '\n\n' + history,
author="Daniel Scheffler",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment