Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eric Duminil
RegionChooser
Commits
a8a25c44
Commit
a8a25c44
authored
Oct 14, 2022
by
Eric Duminil
Browse files
refactor
parent
582f24aa
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/resources/eu/simstadt/regionchooser/website/script/simstadt_openlayers.js
View file @
a8a25c44
...
...
@@ -22,33 +22,11 @@ var regionChooser = (function(){
source
:
new
ol
.
source
.
OSM
()
});
function
read_kml
(
url
){
return
new
ol
.
source
.
KML
({
projection
:
ol
.
proj
.
get
(
'
EPSG:3857
'
),
url
:
url
,
extractAttributes
:
false
,
extractStyles
:
false
});
}
var
kml_source
=
read_kml
(
fromJavaFX
?
undefined
:
'
data/citygml_hulls.kml
'
);
function
polygon_style
(
color
,
alpha
)
{
return
new
ol
.
style
.
Style
({
fill
:
new
ol
.
style
.
Fill
({
color
:
'
rgba(255, 255, 255,
'
+
alpha
+
'
)
'
}),
stroke
:
new
ol
.
style
.
Stroke
({
color
:
color
,
width
:
2
,
lineDash
:
[
5
,
10
]
}),
});
}
var
kml_source
=
utils
.
read_kml
(
fromJavaFX
?
undefined
:
'
data/citygml_hulls.kml
'
);
var
kml_layer
=
new
ol
.
layer
.
Vector
({
source
:
kml_source
,
style
:
polygon_style
(
'
#447744
'
,
0.2
)
style
:
utils
.
polygon_style
(
'
#447744
'
,
0.2
)
});
var
intersections
=
new
ol
.
source
.
Vector
();
...
...
@@ -184,7 +162,7 @@ var regionChooser = (function(){
publicScope
.
highlightPolygon
=
function
(
i
)
{
var
feature
=
kml_source
.
getFeatureById
(
i
);
feature
.
setStyle
(
polygon_style
(
"
#ff44a2
"
,
0.7
));
feature
.
setStyle
(
utils
.
polygon_style
(
"
#ff44a2
"
,
0.7
));
}
publicScope
.
resetHighlight
=
function
(
i
)
{
...
...
@@ -199,7 +177,7 @@ var regionChooser = (function(){
var
checkedBoxes
=
Array
.
from
(
document
.
querySelectorAll
(
"
input.select_citygml
"
)).
filter
(
c
=>
c
.
checked
);
var
checkbox_ids
=
checkedBoxes
.
map
(
c
=>
c
.
id
);
var
features
=
getCheckedPolygons
(
checkbox_ids
);
features
.
forEach
(
f
=>
f
.
setStyle
(
polygon_style
(
"
#ffff00
"
,
0.8
)));
features
.
forEach
(
f
=>
f
.
setStyle
(
utils
.
polygon_style
(
"
#ffff00
"
,
0.8
)));
document
.
getElementById
(
"
download_region_button
"
).
disabled
=
(
checkedBoxes
.
length
==
0
);
}
...
...
@@ -401,7 +379,7 @@ var regionChooser = (function(){
var
checkbox_ids
=
checkedBoxes
.
map
(
c
=>
c
.
id
);
var
features
=
getCheckedPolygons
(
checkbox_ids
);
features
.
forEach
(
f
=>
f
.
setStyle
(
polygon_style
(
"
#ffff00
"
,
0.8
)));
features
.
forEach
(
f
=>
f
.
setStyle
(
utils
.
polygon_style
(
"
#ffff00
"
,
0.8
)));
publicScope
.
downloadRegionFromCityGMLs
(
checkedBoxes
.
map
(
c
=>
c
.
id
));
}
...
...
src/main/resources/eu/simstadt/regionchooser/website/script/utils.js
View file @
a8a25c44
...
...
@@ -38,5 +38,27 @@ var utils = {
document
.
body
.
removeChild
(
textarea
);
}
}
},
read_kml
:
function
(
url
){
return
new
ol
.
source
.
KML
({
projection
:
ol
.
proj
.
get
(
'
EPSG:3857
'
),
url
:
url
,
extractAttributes
:
false
,
extractStyles
:
false
});
},
polygon_style
:
function
(
color
,
alpha
)
{
return
new
ol
.
style
.
Style
({
fill
:
new
ol
.
style
.
Fill
({
color
:
'
rgba(255, 255, 255,
'
+
alpha
+
'
)
'
}),
stroke
:
new
ol
.
style
.
Stroke
({
color
:
color
,
width
:
2
,
lineDash
:
[
5
,
10
]
}),
});
}
};
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment