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
5cbaddee
Commit
5cbaddee
authored
1 year ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
update: add Measurement objects to map
parent
a8e9d14b
No related branches found
No related tags found
2 merge requests
!9
Clhp map
,
!8
Clhp map
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/lib/data_classes.dart
+5
-5
5 additions, 5 deletions
app/lib/data_classes.dart
app/lib/widgets/choropleth_map.dart
+13
-22
13 additions, 22 deletions
app/lib/widgets/choropleth_map.dart
with
18 additions
and
27 deletions
app/lib/data_classes.dart
+
5
−
5
View file @
5cbaddee
...
@@ -8,7 +8,7 @@ class Measurement {
...
@@ -8,7 +8,7 @@ class Measurement {
Sensor
sensor
;
Sensor
sensor
;
String
bodyOfWater
;
String
bodyOfWater
;
LatLng
center
;
LatLng
center
;
List
<
SubDiv
>
subDiv
;
List
<
SubDiv
>
subDiv
s
;
List
<
LatLng
>
corners
;
List
<
LatLng
>
corners
;
Measurement
({
Measurement
({
...
@@ -17,7 +17,7 @@ class Measurement {
...
@@ -17,7 +17,7 @@ class Measurement {
required
this
.
sensor
,
required
this
.
sensor
,
required
this
.
bodyOfWater
,
required
this
.
bodyOfWater
,
required
this
.
center
,
required
this
.
center
,
required
this
.
subDiv
,
required
this
.
subDiv
s
,
required
this
.
corners
,
required
this
.
corners
,
});
});
...
@@ -28,14 +28,14 @@ class Measurement {
...
@@ -28,14 +28,14 @@ class Measurement {
sensor:
Sensor
.
fromJson
(
json
[
'Sensor'
]),
sensor:
Sensor
.
fromJson
(
json
[
'Sensor'
]),
bodyOfWater:
json
[
'BodyOfWater'
]
??
'nil'
,
bodyOfWater:
json
[
'BodyOfWater'
]
??
'nil'
,
center:
LatLng
(
json
[
'CenterLat'
],
json
[
'CenterLon'
]),
center:
LatLng
(
json
[
'CenterLat'
],
json
[
'CenterLon'
]),
subDiv:
(
json
[
'Subdivisions'
]
as
List
<
dynamic
>)
.
map
((
data
)
=
>
SubDiv
.
fromJson
(
data
))
.
toList
(),
subDiv
s
:
(
json
[
'Subdivisions'
]
as
List
<
dynamic
>)
.
map
((
data
)
=
>
SubDiv
.
fromJson
(
data
))
.
toList
(),
corners:
(
json
[
'Corners'
]
as
List
<
dynamic
>)
.
map
((
corner
)
=
>
LatLng
(
corner
[
0
],
corner
[
1
]))
.
toList
(),
corners:
(
json
[
'Corners'
]
as
List
<
dynamic
>)
.
map
((
corner
)
=
>
LatLng
(
corner
[
0
],
corner
[
1
]))
.
toList
(),
);
);
}
}
}
}
class
SubDiv
{
class
SubDiv
{
in
t
sub_div_id
;
Str
in
g
sub_div_id
;
int
groupID
;
int
groupID
;
double
minThickness
;
double
minThickness
;
double
avgThickness
;
double
avgThickness
;
...
@@ -57,7 +57,7 @@ class SubDiv {
...
@@ -57,7 +57,7 @@ class SubDiv {
factory
SubDiv
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
factory
SubDiv
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
return
SubDiv
(
return
SubDiv
(
sub_div_id:
json
[
'SubdivID'
],
sub_div_id:
json
[
'SubdivID'
]
.
toString
()
,
groupID:
json
[
'GroupID'
],
groupID:
json
[
'GroupID'
],
minThickness:
json
[
'MinThickness'
],
minThickness:
json
[
'MinThickness'
],
avgThickness:
json
[
'AvgThickness'
],
avgThickness:
json
[
'AvgThickness'
],
...
...
This diff is collapsed.
Click to expand it.
app/lib/widgets/choropleth_map.dart
+
13
−
22
View file @
5cbaddee
...
@@ -37,27 +37,18 @@ class _ChoroplethMapState extends State<ChoroplethMap> {
...
@@ -37,27 +37,18 @@ class _ChoroplethMapState extends State<ChoroplethMap> {
int
selectedIndex
=
-
1
;
int
selectedIndex
=
-
1
;
late
MapShapeSource
mapShapeSource
;
late
MapShapeSource
mapShapeSource
;
late
final
MapZoomPanBehavior
_zoomPanBehavior
=
MapZoomPanBehavior
();
late
final
MapZoomPanBehavior
_zoomPanBehavior
=
MapZoomPanBehavior
();
List
<
IceThicknessModel
>
iceThicknessList
=
<
IceThicknessModel
>[];
List
<
SubDiv
>
subdivisions
=
<
SubDiv
>[];
List
<
Color
>
testColors
=
[
// NB test color
const
Color
(
0xff8a003b
),
const
Color
(
0xff8a4300
),
const
Color
(
0xff8a7a00
),
const
Color
(
0xff538a00
),
const
Color
(
0xff007b8a
),
];
@override
@override
void
initState
()
{
void
initState
()
{
super
.
initState
();
super
.
initState
();
// Create list of all subdivisions
final
Random
random
=
Random
();
for
(
Measurement
measurement
in
widget
.
measurements
)
{
for
(
int
i
=
0
;
i
<
=
120
;
i
++
)
{
for
(
SubDiv
subdivision
in
measurement
.
subDivs
)
{
int
ran
=
random
.
nextInt
(
5
);
// NB test color
subdivisions
.
add
(
subdivision
);
Color
randomColor
=
testColors
[
ran
];
}
};
int
randomNumber
=
random
.
nextInt
(
21
);
// 0 -> 20, NB: temp test data
iceThicknessList
.
add
(
IceThicknessModel
(
i
.
toString
(),
randomNumber
,
randomColor
,
randomColor
));
}
}
}
@override
@override
...
@@ -70,9 +61,9 @@ class _ChoroplethMapState extends State<ChoroplethMap> {
...
@@ -70,9 +61,9 @@ class _ChoroplethMapState extends State<ChoroplethMap> {
source
:
MapShapeSource
.
memory
(
// Map polygon
source
:
MapShapeSource
.
memory
(
// Map polygon
widget
.
relation
,
// JSON coordinates from server
widget
.
relation
,
// JSON coordinates from server
shapeDataField:
'sub_div_id'
,
shapeDataField:
'sub_div_id'
,
dataCount:
iceThicknessList
.
length
,
dataCount:
widget
.
measurements
.
length
,
primaryValueMapper:
(
int
index
)
=
>
iceThicknessList
[
index
]
.
sub_div_id
,
primaryValueMapper:
(
int
index
)
=
>
subdivisions
[
index
]
.
sub_div_id
,
shapeColorValueMapper:
(
int
index
)
=
>
iceThicknessList
[
index
]
.
color
,
shapeColorValueMapper:
(
int
index
)
=
>
subdivisions
[
index
]
.
color
,
),
),
//color: Colors.blue.shade400, // Map color
//color: Colors.blue.shade400, // Map color
zoomPanBehavior:
_zoomPanBehavior
,
zoomPanBehavior:
_zoomPanBehavior
,
...
@@ -82,8 +73,8 @@ class _ChoroplethMapState extends State<ChoroplethMap> {
...
@@ -82,8 +73,8 @@ class _ChoroplethMapState extends State<ChoroplethMap> {
onSelectionChanged:
(
int
index
)
{
onSelectionChanged:
(
int
index
)
{
setState
(()
{
setState
(()
{
selectedIndex
=
index
;
selectedIndex
=
index
;
for
(
int
i
=
0
;
i
<
iceThicknessList
.
length
;
i
++
)
{
for
(
int
i
=
0
;
i
<
subdivisions
.
length
;
i
++
)
{
iceThicknessList
[
i
]
.
color
=
i
==
index
?
Colors
.
red
:
iceThicknessList
[
i
]
.
savedColor
;
subdivisions
[
i
]
.
color
=
i
==
index
?
Colors
.
red
:
subdivisions
[
i
]
.
savedColor
;
}
}
});
});
widget
.
onSelectionChanged
(
selectedIndex
);
widget
.
onSelectionChanged
(
selectedIndex
);
...
...
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