Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PROG2900
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Sara Savanovic Djordjevic
PROG2900
Commits
bbffbf38
Commit
bbffbf38
authored
11 months ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
update: maybe fix loadRelation()
parent
7946b488
No related branches found
No related tags found
1 merge request
!11
Clhp map
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/lib/server_requests/fetch_relation.dart
+7
-9
7 additions, 9 deletions
app/lib/server_requests/fetch_relation.dart
app/lib/server_requests/init_state.dart
+2
-4
2 additions, 4 deletions
app/lib/server_requests/init_state.dart
server/main.py
+3
-1
3 additions, 1 deletion
server/main.py
with
12 additions
and
14 deletions
app/lib/server_requests/fetch_relation.dart
+
7
−
9
View file @
bbffbf38
...
@@ -45,25 +45,23 @@ Future<Uint8List> fetchRelation() async {
...
@@ -45,25 +45,23 @@ Future<Uint8List> fetchRelation() async {
}
}
}
}
/// Load last saved relation data form last_relation.json
Future
<
Uint8List
>
loadSavedRelation
()
async
{
Future
<
Uint8List
>
loadSavedRelation
()
async
{
try
{
try
{
// Get latest saved relation from file if the server does not respond
// Get latest saved relation from file if the server does not respond
Directory
appDocumentsDirectory
=
await
getApplicationDocumentsDirectory
();
Directory
appDocumentsDirectory
=
await
getApplicationDocumentsDirectory
();
String
filePath
=
'
${appDocumentsDirectory.path}
/last_relation.json'
;
String
filePath
=
'
${appDocumentsDirectory.path}
/last_relation.json'
;
// Read file contents
// Read file contents
as bytes
File
file
=
File
(
filePath
);
File
file
=
File
(
filePath
);
if
(
await
file
.
exists
())
{
if
(
await
file
.
exists
())
{
String
contents
=
await
file
.
readAsString
();
Uint8List
bytes
=
await
file
.
readAsBytes
();
List
<
dynamic
>
jsonData
=
json
.
decode
(
contents
);
// Parse JSON string from file
return
bytes
;
Uint8List
relation
=
Uint8List
.
fromList
(
utf8
.
encode
(
jsonData
.
toString
()));
return
relation
;
}
else
{
}
else
{
throw
Exception
(
'
F
ile does not exist'
);
throw
Exception
(
'
Relation f
ile does not exist'
);
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
print
(
'Error in reading relation from file:
$error
'
);
print
(
'Error in reading relation from file:
$error
'
);
return
Uint8List
(
0
);
return
Uint8List
(
0
);
}
}
}
}
This diff is collapsed.
Click to expand it.
app/lib/server_requests/init_state.dart
+
2
−
4
View file @
bbffbf38
...
@@ -20,10 +20,8 @@ Future<void> initialiseState() async {
...
@@ -20,10 +20,8 @@ Future<void> initialiseState() async {
late
Future
<
Uint8List
>
relationFuture
;
late
Future
<
Uint8List
>
relationFuture
;
try
{
try
{
if
(
!
internetConnection
)
{
// Read data from files if no internet connection
// Read data from files if no internet connection
selectedRelation
=
await
loadSavedRelation
();
if
(
!
internetConnection
)
{
selectedRelation
=
Uint8List
(
0
);
// NB update once fixed
FetchResult
fetchResult
=
await
loadSavedData
();
FetchResult
fetchResult
=
await
loadSavedData
();
List
<
Measurement
>
measurements
=
fetchResult
.
measurements
;
List
<
Measurement
>
measurements
=
fetchResult
.
measurements
;
...
...
This diff is collapsed.
Click to expand it.
server/main.py
+
3
−
1
View file @
bbffbf38
...
@@ -13,6 +13,7 @@ import sqlite3
...
@@ -13,6 +13,7 @@ import sqlite3
app
=
Flask
(
__name__
)
app
=
Flask
(
__name__
)
terminate_server
=
0
terminate_server
=
0
class
IceHTTPServer
(
HTTPServer
):
class
IceHTTPServer
(
HTTPServer
):
def
__init__
(
self
,
server_address
,
handler_class
,
cursor
):
def
__init__
(
self
,
server_address
,
handler_class
,
cursor
):
super
().
__init__
(
server_address
,
handler_class
)
super
().
__init__
(
server_address
,
handler_class
)
...
@@ -65,7 +66,8 @@ class IceHTTP(BaseHTTPRequestHandler):
...
@@ -65,7 +66,8 @@ class IceHTTP(BaseHTTPRequestHandler):
def
do_POST
(
self
):
def
do_POST
(
self
):
if
self
.
path
==
'
/new_lidar_data
'
:
if
self
.
path
==
'
/new_lidar_data
'
:
input_new_Lidar_data
(
self
,
self
.
cursor
,
1
,
'
Mjosa
'
)
# hardcoded body of water must change later
input_new_Lidar_data
(
self
,
self
.
cursor
,
1
,
'
Mjosa
'
)
# hardcoded body of water must change later
# Start a server on port 8443 using self defined HTTP class
# Start a server on port 8443 using self defined HTTP class
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
...
...
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