Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
public_projects
aisdb
Commits
e45ca681
Commit
e45ca681
authored
Jan 21, 2022
by
matt24smith
Browse files
fix bug with decoding ship_type properly
parent
3ed83b99
Pipeline
#4974
passed with stages
in 2 minutes and 30 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
aisdb/database/create_tables.py
View file @
e45ca681
...
...
@@ -43,6 +43,7 @@ def sqlite_createtable_staticreport(cur, month):
mmsi INTEGER,
time INTEGER,
vessel_name TEXT,
ship_type INT,
call_sign TEXT,
imo INTEGER,
dim_bow INTEGER,
...
...
@@ -103,11 +104,8 @@ def aggregate_static_msgs(dbpath, months_str):
for
mmsi
in
mmsis
:
_
=
cur
.
execute
(
f
"""
SELECT s.mmsi, s.vessel_name,
--s.ship_type,
0 as ship_type,
s.dim_bow,
s.dim_stern, s.dim_port, s.dim_star, s.imo
SELECT s.mmsi, s.vessel_name, s.ship_type,
s.dim_bow, s.dim_stern, s.dim_port, s.dim_star, s.imo
FROM ais_
{
month
}
_static AS s
WHERE s.mmsi = ?
"""
,
[
mmsi
])
...
...
aisdb/version.py
View file @
e45ca681
__version__
=
"1.0.
19
"
__version__
=
"1.0.
20
"
aisdb_rust/src/bin.rs
View file @
e45ca681
...
...
@@ -88,15 +88,16 @@ pub async fn main() -> Result<(), Error> {
// same thing but iterating over files in rawdata_dir
// uses different futures aggregation method ??
if
args
.rawdata_dir
.is_some
()
{
let
fpaths
=
std
::
fs
::
read_dir
(
&
args
.rawdata_dir
.unwrap
())
let
mut
fpaths
:
Vec
<
_
>
=
std
::
fs
::
read_dir
(
&
args
.rawdata_dir
.unwrap
())
.unwrap
()
.map
(|
f
|
(
std
::
path
::
PathBuf
::
from
(
&
args
.dbpath
),
f
));
.map
(|
p
|
(
std
::
path
::
PathBuf
::
from
(
&
args
.dbpath
),
p
.unwrap
()))
.collect
();
fpaths
.sort_by_key
(|
t
|
t
.1
.path
());
iter
(
fpaths
)
.for_each_concurrent
(
2
,
|(
d
,
f
)|
async
move
{
decode_insert_msgs
(
&
d
,
&
f
.unwrap
()
.path
())
.await
.expect
(
"decoding"
)
decode_insert_msgs
(
&
d
,
&
f
.path
())
.await
.expect
(
"decoding"
)
})
.await
;
}
...
...
aisdb_rust/src/db.rs
View file @
e45ca681
...
...
@@ -35,6 +35,7 @@ pub fn sqlite_createtable_staticreport(
mmsi INTEGER,
time INTEGER,
vessel_name TEXT,
ship_type INT,
call_sign TEXT,
imo INTEGER,
dim_bow INTEGER,
...
...
@@ -163,7 +164,7 @@ pub fn sqlite_insert_static(tx: &Transaction, msgs: Vec<VesselData>, mstr: &str)
mmsi,
time,
vessel_name,
--
ship_type,
ship_type,
call_sign,
imo,
dim_bow,
...
...
@@ -179,7 +180,7 @@ pub fn sqlite_insert_static(tx: &Transaction, msgs: Vec<VesselData>, mstr: &str)
eta_hour,
eta_minute
)
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?
,?
)
"
,
mstr
);
...
...
@@ -187,15 +188,15 @@ pub fn sqlite_insert_static(tx: &Transaction, msgs: Vec<VesselData>, mstr: &str)
let
mut
stmt
=
tx
.prepare_cached
(
&
sql
)
?
;
for
msg
in
msgs
{
let
(
p
,
e
)
=
msg
.staticdata
();
//let _ = stmt
let
eta
=
p
.eta
.unwrap_or
(
MIN_DATETIME
);
stmt
.execute
(
params!
[
p
.mmsi
,
e
,
p
.name
.unwrap_or_else
(||
""
.to_string
()),
p
.ship_type
as
i32
,
p
.call_sign
.unwrap_or_else
(||
""
.to_string
()),
p
.imo_number
.unwrap_or
(
0
),
//p.ship_type,
p
.dimension_to_bow
.unwrap_or
(
0
),
p
.dimension_to_stern
.unwrap_or
(
0
),
p
.dimension_to_port
.unwrap_or
(
0
),
...
...
aisdb_rust/src/decode.rs
View file @
e45ca681
...
...
@@ -211,7 +211,7 @@ pub async fn decode_insert_msgs(
//let t1 = c.transaction().expect("create tx");
let
t1
=
c
.transaction
()
.unwrap
();
let
_d1
=
sqlite_insert_dynamic
(
&
t1
,
positions
,
&
mstr1
)
.expect
(
"inserting chunk"
);
let
_c1
=
sqlite_createtable_staticreport
(
&
t1
,
&
mstr1
);
let
_c1
=
sqlite_createtable_staticreport
(
&
t1
,
&
mstr1
)
.expect
(
"create static table"
)
;
let
_s1
=
sqlite_insert_static
(
&
t1
,
stat_msgs
,
&
mstr1
)
.expect
(
"insert"
);
let
_
=
t1
.commit
();
...
...
changelog.rst
View file @
e45ca681
...
...
@@ -2,6 +2,12 @@
Changelog
=========
v1.0.20
-------
fix bug with decoding ship_type properly
v1.0.19
-------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment