Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Navigation App
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
SWP Datenverwaltung Navigation 2023
Navigation App
Commits
79ff9e29
Commit
79ff9e29
authored
2 years ago
by
theilen
Browse files
Options
Downloads
Patches
Plain Diff
Include day and weather information
parent
d986b2ca
Branches
Branches containing commit
No related tags found
1 merge request
!6
final project merge into main
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/main.dart
+37
-19
37 additions, 19 deletions
lib/main.dart
with
37 additions
and
19 deletions
lib/main.dart
+
37
−
19
View file @
79ff9e29
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_map/flutter_map.dart'
;
import
'package:flutter_map/flutter_map.dart'
;
import
'package:intl/intl.dart'
;
import
'package:intl/intl.dart'
;
import
'package:tuple/tuple.dart'
;
import
'widgets/returnOrigin.dart'
;
import
'widgets/returnOrigin.dart'
;
import
'widgets/returnDestination.dart'
;
import
'widgets/returnDestination.dart'
;
import
'package:geocoding/geocoding.dart'
;
import
'package:geocoding/geocoding.dart'
;
...
@@ -212,28 +213,19 @@ class _MyHomePageState extends State<MyHomePage> {
...
@@ -212,28 +213,19 @@ class _MyHomePageState extends State<MyHomePage> {
var
originlon
=
_originCoordinates
.
longitude
;
var
originlon
=
_originCoordinates
.
longitude
;
var
destlat
=
_destCoordinates
.
latitude
;
var
destlat
=
_destCoordinates
.
latitude
;
var
destlon
=
_destCoordinates
.
longitude
;
var
destlon
=
_destCoordinates
.
longitude
;
var
dateTup
=
getDayOffset
();
// Get direction data
// Get direction data
// No weather or days included for now
// No weather or days included for now
final
response
=
await
http
.
post
(
final
response
=
await
http
.
post
(
Uri
.
parse
(
'http://10.0.2.2:8080/route'
),
Uri
.
parse
(
'http://10.0.2.2:8080/route'
),
body:
jsonEncode
({
body:
jsonEncode
(
"start_node"
:
{
"lat"
:
originlat
,
"lon"
:
originlon
},
{
"end_node"
:
{
"lat"
:
destlat
,
"lon"
:
destlon
},
"start_node"
:
{
"forbidden"
:
getForbidden
(),
"lat"
:
originlat
,
"start_after_today"
:
dateTup
.
item1
,
"lon"
:
originlon
"end_after_today"
:
dateTup
.
item2
},
}),
"end_node"
:
{
headers:
<
String
,
String
>{
"Content-Type"
:
"application/json"
});
"lat"
:
destlat
,
"lon"
:
destlon
},
"forbidden"
:
[],
"start_after_today"
:
0
,
"end_after_today"
:
0
}
),
headers:
<
String
,
String
>{
"Content-Type"
:
"application/json"
}
);
_data
=
jsonDecode
(
response
.
body
);
_data
=
jsonDecode
(
response
.
body
);
var
coordinates
=
_data
[
'route'
];
var
coordinates
=
_data
[
'route'
];
int
duration
=
_data
[
'duration'
];
int
duration
=
_data
[
'duration'
];
...
@@ -293,6 +285,32 @@ class _MyHomePageState extends State<MyHomePage> {
...
@@ -293,6 +285,32 @@ class _MyHomePageState extends State<MyHomePage> {
return
'
$distanceInKm
km'
;
return
'
$distanceInKm
km'
;
}
}
List
<
String
>
getForbidden
()
{
List
<
String
>
forbidden
=
[];
for
(
var
option
in
_selectedOptions
)
{
switch
(
option
)
{
case
'Rain'
:
forbidden
.
add
(
'rain'
);
break
;
case
'Frost'
:
forbidden
.
add
(
'ice'
);
break
;
case
'Wind'
:
forbidden
.
add
(
'wind'
);
break
;
case
'Snow'
:
forbidden
.
add
(
'snow'
);
}
}
return
forbidden
;
}
Tuple2
<
int
,
int
>
getDayOffset
()
{
return
Tuple2
<
int
,
int
>(
_dateRange
.
start
.
difference
(
DateTime
.
now
())
.
inDays
,
_dateRange
.
end
.
difference
(
DateTime
.
now
())
.
inDays
);
}
// Get coords between origin/dest points corresponding to shortest path and update _info.
// Get coords between origin/dest points corresponding to shortest path and update _info.
// This part is going to be updated to take directions from backend instead of Direction API.
// This part is going to be updated to take directions from backend instead of Direction API.
// Future<Directions> _getDirections() async {
// Future<Directions> _getDirections() async {
...
...
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