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
fd01ac43
Commit
fd01ac43
authored
1 year ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
update: get valid markers or all markers
parent
f489dd9c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/lib/pages/marker_handler/get_markers.dart
+1
-3
1 addition, 3 deletions
app/lib/pages/marker_handler/get_markers.dart
server/main.py
+4
-2
4 additions, 2 deletions
server/main.py
server/map/get_markers.py
+24
-11
24 additions, 11 deletions
server/map/get_markers.py
with
29 additions
and
16 deletions
app/lib/pages/marker_handler/get_markers.dart
+
1
−
3
View file @
fd01ac43
...
...
@@ -22,12 +22,10 @@ Future<List<Measurement>> fetchMarkerData() async {
}
else
{
print
(
'Request failed with status:
${response.statusCode}
'
);
// Throw an exception or return null if the request fails
throw
Exception
(
'Failed to fetch marker template'
);
throw
Exception
(
'Failed to parse marker data'
);
}
}
catch
(
e
)
{
print
(
'Error:
$e
'
);
// Throw an exception or return null if there's an error
throw
Exception
(
'Failed to connect to the server. Please check your network connection'
);
}
}
This diff is collapsed.
Click to expand it.
server/main.py
+
4
−
2
View file @
fd01ac43
...
...
@@ -48,9 +48,11 @@ class IceHTTP(BaseHTTPRequestHandler):
self
.
wfile
.
write
(
b
"
Root path hit!
"
)
# Update_map endpoint
elif
self
.
path
==
'
/update_map
'
:
# NB: should be POST?
get_all_markers
(
self
,
self
.
cursor
)
# Accessing cursor from self
get_all_markers
(
self
,
self
.
cursor
,
False
)
# Get all markers
elif
self
.
path
==
'
/get_valid_markers
'
:
# NB: should be POST?
get_all_markers
(
self
,
self
.
cursor
,
True
)
# Get only valid markers
# Listen for pressing of q key to terminate server
def
on_key_press
(
server
,
event
,
cursor
,
conn
):
...
...
This diff is collapsed.
Click to expand it.
server/map/get_markers.py
+
24
−
11
View file @
fd01ac43
...
...
@@ -2,18 +2,31 @@ import json
# get_markers requests all marker data from mongoDB
def
get_all_markers
(
self
,
cursor
):
def
get_all_markers
(
self
,
cursor
,
valid
:
bool
):
try
:
# Fetch all data
cursor
.
execute
(
'''
SELECT m.MeasurementID, m.SensorID, m.TimeMeasured, d.Latitude, d.Longitude,
d.IceTop, d.IceBottom, d.CalculatedThickness, d.Accuracy, s.SensorType, s.Active,
c.CornerID, c.CornerLatitude, c.CornerLongitude
FROM Measurement m
INNER JOIN Sensor s ON m.SensorID = s.SensorID
INNER JOIN Data d ON m.MeasurementID = d.MeasurementID
INNER JOIN Corner c ON m.MeasurementID = c.MeasurementID
'''
)
# NB: interval temporarily hard coded to 5 days
if
valid
==
True
:
# Fetch only valid markers (taken within last 5 days)
cursor
.
execute
(
'''
SELECT m.MeasurementID, m.SensorID, m.TimeMeasured, d.Latitude, d.Longitude,
d.IceTop, d.IceBottom, d.CalculatedThickness, d.Accuracy, s.SensorType, s.Active,
c.CornerID, c.CornerLatitude, c.CornerLongitude
FROM Measurement m
INNER JOIN Sensor s ON m.SensorID = s.SensorID
INNER JOIN Data d ON m.MeasurementID = d.MeasurementID
INNER JOIN Corner c ON m.MeasurementID = c.MeasurementID
WHERE m.TimeMeasured > DATE_SUB(NOW(), INTERVAL 5 DAY);
'''
)
else
:
# Fetch all markers
cursor
.
execute
(
'''
SELECT m.MeasurementID, m.SensorID, m.TimeMeasured, d.Latitude, d.Longitude,
d.IceTop, d.IceBottom, d.CalculatedThickness, d.Accuracy, s.SensorType, s.Active,
c.CornerID, c.CornerLatitude, c.CornerLongitude
FROM Measurement m
INNER JOIN Sensor s ON m.SensorID = s.SensorID
INNER JOIN Data d ON m.MeasurementID = d.MeasurementID
INNER JOIN Corner c ON m.MeasurementID = c.MeasurementID
'''
)
rows
=
cursor
.
fetchall
()
...
...
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