Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eric Duminil
RegionChooser
Commits
b6d2a5d8
Commit
b6d2a5d8
authored
2 years ago
by
Eric Duminil
Browse files
Options
Download
Email Patches
Plain Diff
Trying many stuff. Checklist instead of single link.
parent
eb1c4870
master
develop
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/resources/eu/simstadt/regionchooser/website/script/simstadt_openlayers.js
+34
-20
...stadt/regionchooser/website/script/simstadt_openlayers.js
with
34 additions
and
20 deletions
+34
-20
src/main/resources/eu/simstadt/regionchooser/website/script/simstadt_openlayers.js
+
34
-
20
View file @
b6d2a5d8
var
regionChooser
=
(
function
(){
var
publicScope
=
{};
var
fromJavaFX
=
navigator
.
userAgent
.
indexOf
(
'
JavaFX
'
)
!==
-
1
;
//NOTE: Could do without jQuery
var
dataPanel
=
$
(
'
#dataPanel
'
);
var
wgs84Sphere
=
new
ol
.
Sphere
(
6378137
);
var
gmlId
=
0
;
...
...
@@ -9,8 +10,8 @@ var regionChooser = (function(){
$
(
"
html
"
).
addClass
(
"
wait
"
);
}
// Hash function
const
cyrb53
=
(
str
,
seed
=
0
)
=>
{
// Hash function
. For testing purposes in browser (no Feature ID is available)
const
cyrb53
=
(
str
,
seed
=
0
)
=>
{
let
h1
=
0xdeadbeef
^
seed
,
h2
=
0x41c6ce57
^
seed
;
for
(
let
i
=
0
,
ch
;
i
<
str
.
length
;
i
++
)
{
...
...
@@ -23,7 +24,7 @@ const cyrb53 = (str, seed = 0) => {
h2
=
Math
.
imul
(
h2
^
(
h2
>>>
16
),
2246822507
)
^
Math
.
imul
(
h1
^
(
h1
>>>
13
),
3266489909
);
return
4294967296
*
(
2097151
&
h2
)
+
(
h1
>>>
0
);
};
};
var
osm_layer
=
new
ol
.
layer
.
Tile
({
source
:
new
ol
.
source
.
OSM
()
...
...
@@ -173,12 +174,13 @@ const cyrb53 = (str, seed = 0) => {
// TODO: Add checkbox + label +
// TODO: Add submit.
// TODO: If possible, highlight the corresponding polygon when hovering above a name.
console
.
log
(
"
Feature name :
"
+
feature
[
"
name
"
]);
console
.
log
(
"
Feature ID :
"
+
feature
.
getId
());
if
(
fromJavaFX
)
{
link
+=
"
<a href=
\"
#
\"
onclick=
\"
regionChooser.downloadRegionFrom
"
+
feature
[
"
source
"
]
+
"
(
"
+
feature
.
getId
()
+
"
);return false;
\"
>
"
+
feature
[
"
name
"
]
+
"
</a>
"
;
link
+=
'
<input type="checkbox" id="check_
'
+
feature
.
getId
()
+
'
" class="select_citygml"><label for="check_
'
+
feature
.
getId
()
+
'
">
'
+
feature
[
'
name
'
]
+
'
</label>
'
;
}
else
{
h
=
cyrb53
(
feature
[
'
name
'
]);
link
+=
'
<input type="checkbox" id="check
'
+
h
+
'
"><label for="check
'
+
h
+
'
">
'
+
feature
[
'
name
'
]
+
'
</label>
'
;
link
+=
'
<input type="checkbox" id="check
_
'
+
h
+
'
"
class="select_citygml"
><label for="check
_
'
+
h
+
'
">
'
+
feature
[
'
name
'
]
+
'
</label>
'
;
}
link
+=
"
(
"
+
citygml_percentage
+
"
%
"
;
...
...
@@ -201,9 +203,10 @@ const cyrb53 = (str, seed = 0) => {
var
polygonArea
=
sketch
.
getGeometry
().
getArea
();
var
intersection_found
=
false
;
intersections
.
clear
();
//NOTE: getFeatures seems to not be sorted anymore. :-/
features_by_project
=
groupBy
(
kml_source
.
getFeatures
(),
"
project
"
);
Object
.
keys
(
features_by_project
).
sort
().
forEach
(
function
(
project
)
{
Object
.
keys
(
features_by_project
).
forEach
(
function
(
project
)
{
features
=
features_by_project
[
project
];
features_and_intersections
=
features
.
map
(
f
=>
[
f
,
findIntersection
(
f
,
polygon
)]).
filter
(
l
=>
l
[
1
]
!==
undefined
);
if
(
features_and_intersections
.
length
>
0
){
...
...
@@ -213,7 +216,11 @@ const cyrb53 = (str, seed = 0) => {
}
});
if
(
!
intersection_found
)
{
if
(
intersection_found
)
{
document
.
getElementById
(
"
download
"
).
style
.
visibility
=
'
visible
'
;
}
else
{
document
.
getElementById
(
"
download
"
).
style
.
visibility
=
'
hidden
'
;
dataPanel
.
append
(
"
No intersection found with any CityGML file.<br/>
\n
"
);
}
}
...
...
@@ -272,6 +279,8 @@ const cyrb53 = (str, seed = 0) => {
dataPanel
.
append
(
wgs84_coords
+
"
<br/>
\n
"
);
}
dataPanel
.
append
(
"
<h3 class='clean'>Area :
"
+
(
area
/
10000
).
toFixed
(
1
)
+
"
ha
\n
"
);
dataPanel
.
append
(
'
<button type="button" onclick="regionChooser.clickety_click()" id="download" style="visibility:hidden">Download Region</button>
'
);
dataPanel
.
append
(
'
<br/>
\n
'
);
findIntersections
();
}
...
...
@@ -353,6 +362,11 @@ const cyrb53 = (str, seed = 0) => {
console
.
log
(
"
READY!
"
);
}
publicScope
.
clickety_click
=
function
()
{
console
.
log
(
"
You clicked pretty well
"
);
document
.
querySelectorAll
(
"
input.select_citygml
"
).
forEach
(
x
=>
console
.
log
(
x
));
}
focusOnMap
();
//var regionChooser = publicScope; //NOTE: In order to open closure. For debugging
return
publicScope
;
...
...
This diff is collapsed.
Click to expand it.
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
Menu
Explore
Projects
Groups
Snippets