Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EO Time Series Viewer
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Benjamin Jakimow
EO Time Series Viewer
Commits
0cf03cb4
Commit
0cf03cb4
authored
7 years ago
by
benjamin.jakimow@geo.hu-berlin.de
Browse files
Options
Downloads
Patches
Plain Diff
made SpatialPoint and SpatialExtent hashable
parent
07ca22e4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/test_utils.py
+10
-1
10 additions, 1 deletion
test/test_utils.py
timeseriesviewer/utils.py
+15
-7
15 additions, 7 deletions
timeseriesviewer/utils.py
with
25 additions
and
8 deletions
test/test_utils.py
+
10
−
1
View file @
0cf03cb4
...
...
@@ -31,7 +31,8 @@ class testclassUtilityTests(unittest.TestCase):
pass
def
test_spatialObjection
(
self
):
def
test_spatialObjects
(
self
):
"""
Test we can click OK.
"""
import
example
pathRE
=
file_search
(
os
.
path
.
dirname
(
example
.
__file__
),
'
re*
'
,
recursive
=
True
)[
0
]
...
...
@@ -45,6 +46,14 @@ class testclassUtilityTests(unittest.TestCase):
self
.
assertIsInstance
(
pt1
,
SpatialPoint
)
d
=
{}
for
t
in
[
pt1
,
se
]:
try
:
d
[
t
]
=
'
{}
'
.
format
(
t
)
except
:
self
.
fail
(
'
Unable to use {} as dictionary key.
'
.
format
(
type
(
t
)))
if
__name__
==
"
__main__
"
:
unittest
.
main
()
...
...
This diff is collapsed.
Click to expand it.
timeseriesviewer/utils.py
+
15
−
7
View file @
0cf03cb4
...
...
@@ -99,7 +99,7 @@ def scaledUnitString(num, infix=' ', suffix='B', div=1000):
return
"
{:.1f}{}{}{}
"
.
format
(
num
,
infix
,
unit
,
suffix
)
class
SpatialPoint
(
QgsPoint
):
class
SpatialPoint
(
QgsPoint
XY
):
"""
Object to keep QgsPoint and QgsCoordinateReferenceSystem together
"""
...
...
@@ -123,6 +123,9 @@ class SpatialPoint(QgsPoint):
super
(
SpatialPoint
,
self
).
__init__
(
*
args
)
self
.
mCrs
=
crs
def
__hash__
(
self
):
return
hash
(
str
(
self
))
def
setCrs
(
self
,
crs
):
assert
isinstance
(
crs
,
QgsCoordinateReferenceSystem
)
self
.
mCrs
=
crs
...
...
@@ -155,7 +158,7 @@ class SpatialPoint(QgsPoint):
def
toCrs
(
self
,
crs
):
assert
isinstance
(
crs
,
QgsCoordinateReferenceSystem
)
pt
=
QgsPoint
(
self
)
pt
=
QgsPoint
XY
(
self
)
if
self
.
mCrs
!=
crs
:
pt
=
saveTransform
(
pt
,
self
.
mCrs
,
crs
)
...
...
@@ -291,7 +294,7 @@ def px2geo(px, gt):
#see http://www.gdal.org/gdal_datamodel.html
gx
=
gt
[
0
]
+
px
.
x
()
*
gt
[
1
]
+
px
.
y
()
*
gt
[
2
]
gy
=
gt
[
3
]
+
px
.
x
()
*
gt
[
4
]
+
px
.
y
()
*
gt
[
5
]
return
QgsPoint
(
gx
,
gy
)
return
QgsPoint
XY
(
gx
,
gy
)
class
SpatialExtent
(
QgsRectangle
):
...
...
@@ -400,16 +403,16 @@ class SpatialExtent(QgsRectangle):
s
=
""
def
upperRightPt
(
self
):
return
QgsPoint
(
*
self
.
upperRight
())
return
QgsPoint
XY
(
*
self
.
upperRight
())
def
upperLeftPt
(
self
):
return
QgsPoint
(
*
self
.
upperLeft
())
return
QgsPoint
XY
(
*
self
.
upperLeft
())
def
lowerRightPt
(
self
):
return
QgsPoint
(
*
self
.
lowerRight
())
return
QgsPoint
XY
(
*
self
.
lowerRight
())
def
lowerLeftPt
(
self
):
return
QgsPoint
(
*
self
.
lowerLeft
())
return
QgsPoint
XY
(
*
self
.
lowerLeft
())
def
upperRight
(
self
):
...
...
@@ -442,6 +445,11 @@ class SpatialExtent(QgsRectangle):
self
.
xMinimum
(),
self
.
yMinimum
(),
self
.
xMaximum
(),
self
.
yMaximum
()
),
{}
def
__hash__
(
self
):
return
hash
(
str
(
self
))
def
__str__
(
self
):
return
self
.
__repr__
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment