Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
skais
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Raphael Sturgis
skais
Commits
4257ce4a
Commit
4257ce4a
authored
3 years ago
by
Raphael
Browse files
Options
Downloads
Patches
Plain Diff
generate image with lines
parent
50c2165f
Branches
Branches containing commit
Tags
Tags containing commit
3 merge requests
!12
version 0.2a
,
!10
Resolve "Image creation bugs with 0 size windows"
,
!9
Resolve "Creation of images from AIS"
This commit is part of merge request
!9
. Comments created here will be created in the context of that merge request.
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
skais/ais/ais_trajectory.py
+11
-2
11 additions, 2 deletions
skais/ais/ais_trajectory.py
skais/tests/ais/test_ais_trajectory.py
+25
-0
25 additions, 0 deletions
skais/tests/ais/test_ais_trajectory.py
skais/utils/geometry.py
+16
-10
16 additions, 10 deletions
skais/utils/geometry.py
with
52 additions
and
12 deletions
skais/ais/ais_trajectory.py
+
11
−
2
Edit
View file @
4257ce4a
...
...
@@ -7,6 +7,7 @@ from scipy.interpolate import interp1d
from
skais.utils.geography
import
great_circle
,
position_from_distance
,
get_coord
from
skais.ais.ais_points
import
AISPoints
from
skais.utils.geometry
import
bresenham
@jit
(
nopython
=
True
)
...
...
@@ -224,7 +225,8 @@ class AISTrajectory(AISPoints):
result
.
append
((
row
[
'
ts_sec
'
],
current_label
))
return
result
def
generate_array_from_positions
(
self
,
height
=
256
,
width
=
256
,
link
=
True
,
bounding_box
=
'
fit
'
,
features
=
None
,
node_size
=
0
):
def
generate_array_from_positions
(
self
,
height
=
256
,
width
=
256
,
link
=
True
,
bounding_box
=
'
fit
'
,
features
=
None
,
node_size
=
0
):
nb_channels
=
1
if
features
is
not
None
:
nb_channels
=
len
(
features
)
...
...
@@ -248,5 +250,12 @@ class AISTrajectory(AISPoints):
data
[
x
,
y
]
=
[
1
]
if
link
:
raise
ValueError
(
"
feature not implemented
"
)
lon
,
lat
=
positions
[
0
,
0
],
positions
[
0
,
1
]
for
longitude
,
latitude
in
positions
[
1
:]:
x_prv
,
y_prev
=
get_coord
(
lat
,
lon
,
height
,
width
,
min_lat
,
max_lat
,
min_lon
,
max_lon
)
x_nxt
,
y_nxt
=
get_coord
(
latitude
,
longitude
,
height
,
width
,
min_lat
,
max_lat
,
min_lon
,
max_lon
)
lon
,
lat
=
longitude
,
latitude
for
x
,
y
in
bresenham
(
x_prv
,
y_prev
,
x_nxt
,
y_nxt
):
data
[
x
,
y
]
=
[
1
]
return
data
This diff is collapsed.
Click to expand it.
skais/tests/ais/test_ais_trajectory.py
+
25
−
0
Edit
View file @
4257ce4a
...
...
@@ -429,3 +429,28 @@ class TestAISTrajectory(unittest.TestCase):
[
1
,
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
]])
np
.
testing
.
assert_array_equal
(
result
,
expected
)
def
test_generate_array_from_positions_with_line
(
self
):
trajectory
=
AISTrajectory
(
pd
.
DataFrame
(
{
"
latitude
"
:
[
0
,
10
,
0
,
20
],
"
longitude
"
:
[
0
,
10
,
20
,
20
],
"
ts_sec
"
:
[
i
for
i
in
range
(
4
)]
}
)
)
result
=
trajectory
.
generate_array_from_positions
(
height
=
9
,
width
=
18
,
link
=
True
,
bounding_box
=
'
fit
'
,
features
=
None
,
node_size
=
0
).
reshape
((
9
,
18
))
expected
=
np
.
array
([[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
],
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
],
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
],
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
],
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
,
1
,
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
],
[
0
,
0
,
0
,
0
,
0
,
1
,
1
,
0
,
0
,
0
,
1
,
1
,
0
,
0
,
0
,
0
,
0
,
1
],
[
0
,
0
,
0
,
1
,
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
,
1
,
0
,
0
,
0
,
1
],
[
0
,
1
,
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
,
1
,
0
,
1
],
[
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
,
1
]])
np
.
testing
.
assert_array_equal
(
result
,
expected
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
skais/utils/geometry.py
+
16
−
10
Edit
View file @
4257ce4a
def
bresenham
(
x1
,
y1
,
x2
,
y2
):
if
x1
>
x2
:
tmp
=
x2
x2
=
x1
x1
=
tmp
tmp
=
y2
y2
=
y1
y1
=
tmp
dx
=
int
(
x2
-
x1
)
dy
=
int
(
y2
-
y1
)
...
...
@@ -23,6 +13,14 @@ def bresenham(x1, y1, x2, y2):
pixels
=
[(
x1
,
y1
)]
if
abs
(
dx
)
>
abs
(
dy
):
# slope < 1
if
x1
>
x2
:
tmp
=
x2
x2
=
x1
x1
=
tmp
tmp
=
y2
y2
=
y1
y1
=
tmp
p
=
(
2
*
abs
(
dy
))
-
abs
(
dx
)
for
x
in
range
(
x1
+
1
,
x2
+
1
):
...
...
@@ -33,6 +31,14 @@ def bresenham(x1, y1, x2, y2):
p
+=
(
2
*
abs
(
dy
))
-
(
2
*
abs
(
dx
))
pixels
.
append
((
x
,
y
))
else
:
# slope >= 1
if
y1
>
y2
:
tmp
=
x2
x2
=
x1
x1
=
tmp
tmp
=
y2
y2
=
y1
y1
=
tmp
p
=
(
2
*
abs
(
dx
))
-
abs
(
dy
)
for
y
in
range
(
y1
+
1
,
y2
+
1
):
if
p
<
0
:
...
...
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