Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eric Duminil
RegionChooser
Commits
213236e1
Commit
213236e1
authored
Mar 16, 2018
by
Eric Duminil
Browse files
RegionChooser: Trying to group features by project.
parent
698470f3
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/eu/simstadt/regionchooser/website/script/simstadt_openlayers.js
View file @
213236e1
...
@@ -11,11 +11,13 @@ proj4.defs("EPSG:2263", "+proj=lcc +lat_1=41.03333333333333 +lat_2=40.6666666666
...
@@ -11,11 +11,13 @@ proj4.defs("EPSG:2263", "+proj=lcc +lat_1=41.03333333333333 +lat_2=40.6666666666
proj4
.
defs
(
"
EPSG:25832
"
,
"
+proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs
"
);
// http://spatialreference.org/ref/epsg/etrs89-utm-zone-32n/proj4/
proj4
.
defs
(
"
EPSG:25832
"
,
"
+proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs
"
);
// http://spatialreference.org/ref/epsg/etrs89-utm-zone-32n/proj4/
proj4
.
defs
(
"
EPSG:28992
"
,
"
+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.999908 +x_0=155000 +y_0=463000 +ellps=bessel +units=m +towgs84=565.2369,50.0087,465.658,-0.406857330322398,0.350732676542563,-1.8703473836068,4.0812 +no_defs <>
"
);
//
proj4
.
defs
(
"
EPSG:28992
"
,
"
+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.999908 +x_0=155000 +y_0=463000 +ellps=bessel +units=m +towgs84=565.2369,50.0087,465.658,-0.406857330322398,0.350732676542563,-1.8703473836068,4.0812 +no_defs <>
"
);
//
var
regionChooser
=
(
function
(){
//
var regionChooser = (function(){
var
publicScope
=
{};
var
publicScope
=
{};
var
fromJavaFX
=
navigator
.
userAgent
.
indexOf
(
'
JavaFX
'
)
!==
-
1
;
var
fromJavaFX
=
navigator
.
userAgent
.
indexOf
(
'
JavaFX
'
)
!==
-
1
;
var
dataPanel
=
$
(
'
#dataPanel
'
);
var
dataPanel
=
$
(
'
#dataPanel
'
);
var
wgs84Sphere
=
new
ol
.
Sphere
(
6378137
);
var
wgs84Sphere
=
new
ol
.
Sphere
(
6378137
);
var
gmlId
=
0
;
var
novaFactoryId
=
0
;
if
(
fromJavaFX
){
if
(
fromJavaFX
){
$
(
"
html
"
).
addClass
(
"
wait
"
);
$
(
"
html
"
).
addClass
(
"
wait
"
);
...
@@ -72,6 +74,7 @@ var regionChooser = (function(){
...
@@ -72,6 +74,7 @@ var regionChooser = (function(){
publicScope
.
addCityGmlHull
=
function
(
kmlString
)
{
publicScope
.
addCityGmlHull
=
function
(
kmlString
)
{
options
=
{
featureProjection
:
ol
.
proj
.
get
(
'
EPSG:3857
'
)};
options
=
{
featureProjection
:
ol
.
proj
.
get
(
'
EPSG:3857
'
)};
feature
=
kmlFormat
.
readFeature
(
kmlString
,
options
);
feature
=
kmlFormat
.
readFeature
(
kmlString
,
options
);
feature
.
setId
(
gmlId
++
);
kml_source
.
addFeature
(
feature
);
kml_source
.
addFeature
(
feature
);
dataPanel
.
append
(
'
.
'
);
dataPanel
.
append
(
'
.
'
);
srsName
=
feature
.
get
(
"
srsName
"
)
||
"
EPSG:31467
"
;
srsName
=
feature
.
get
(
"
srsName
"
)
||
"
EPSG:31467
"
;
...
@@ -90,8 +93,10 @@ var regionChooser = (function(){
...
@@ -90,8 +93,10 @@ var regionChooser = (function(){
});
});
feature
[
"
geoJSON
"
]
=
geoJsonFormat
.
writeFeatureObject
(
feature
);
feature
[
"
geoJSON
"
]
=
geoJsonFormat
.
writeFeatureObject
(
feature
);
feature
[
"
area
"
]
=
feature
.
getGeometry
().
getArea
();
feature
[
"
area
"
]
=
feature
.
getGeometry
().
getArea
();
feature
[
"
description
"
]
=
"
novaFACTORY>
"
+
name
;
feature
[
"
project
"
]
=
"
novaFACTORY
"
;
feature
[
"
name
"
]
=
name
;
feature
[
"
source
"
]
=
"
NovaFACTORY
"
;
feature
[
"
source
"
]
=
"
NovaFACTORY
"
;
feature
.
setId
(
novaFactoryId
++
);
novafactory_vectors
.
addFeature
(
feature
);
novafactory_vectors
.
addFeature
(
feature
);
};
};
...
@@ -122,7 +127,8 @@ var regionChooser = (function(){
...
@@ -122,7 +127,8 @@ var regionChooser = (function(){
feature
[
"
area
"
]
=
feature
.
getGeometry
().
getArea
();
feature
[
"
area
"
]
=
feature
.
getGeometry
().
getArea
();
var
project
=
feature
.
get
(
"
project
"
);
var
project
=
feature
.
get
(
"
project
"
);
var
name
=
feature
.
get
(
"
name
"
);
var
name
=
feature
.
get
(
"
name
"
);
feature
[
"
description
"
]
=
project
+
"
>
"
+
name
;
feature
[
"
project
"
]
=
project
;
feature
[
"
name
"
]
=
name
;
feature
[
"
source
"
]
=
"
CityGML
"
;
feature
[
"
source
"
]
=
"
CityGML
"
;
});
});
}
}
...
@@ -189,13 +195,12 @@ var regionChooser = (function(){
...
@@ -189,13 +195,12 @@ var regionChooser = (function(){
var
intersection_found
=
false
;
var
intersection_found
=
false
;
intersections
.
clear
();
intersections
.
clear
();
//TODO: Refactor. Smaller functions
//TODO: Refactor. Smaller functions
//TODO: No global i. feature["id"]
function
findIntersection
(
feature
)
{
function
findIntersection
(
feature
)
{
try
{
try
{
var
jsonIntersection
=
turf
.
intersect
(
poly1
,
feature
[
"
geoJSON
"
]);
var
jsonIntersection
=
turf
.
intersect
(
poly1
,
feature
[
"
geoJSON
"
]);
if
(
undefined
!==
jsonIntersection
)
{
if
(
undefined
!==
jsonIntersection
)
{
if
(
!
intersection_found
)
{
if
(
!
intersection_found
)
{
dataPanel
.
append
(
"
Intersection found with :<br/>
\n
"
);
//
dataPanel.append("Intersection found with :<br/>\n");
intersection_found
=
true
;
intersection_found
=
true
;
}
}
var
intersection
=
geoJsonFormat
.
readFeature
(
jsonIntersection
);
var
intersection
=
geoJsonFormat
.
readFeature
(
jsonIntersection
);
...
@@ -204,13 +209,11 @@ var regionChooser = (function(){
...
@@ -204,13 +209,11 @@ var regionChooser = (function(){
var
sketch_percentage
=
Math
.
round
(
intersectionArea
/
sketch_area
*
100
);
var
sketch_percentage
=
Math
.
round
(
intersectionArea
/
sketch_area
*
100
);
intersections
.
addFeature
(
intersection
);
intersections
.
addFeature
(
intersection
);
var
link
=
'
<li>
'
var
link
=
'
<li>
'
var
description
;
if
(
fromJavaFX
)
{
if
(
fromJavaFX
)
{
link
+=
"
<a href=
\"
#
\"
onclick=
\"
regionChooser.downloadRegionFrom
"
+
feature
[
"
source
"
]
+
"
(
"
+
i
link
+=
"
<a href=
\"
#
\"
onclick=
\"
regionChooser.downloadRegionFrom
"
+
feature
[
"
source
"
]
+
"
(
"
+
feature
.
getId
()
+
"
);return false;
\"
>
"
+
feature
[
"
description
"
]
+
"
</a>
"
;
+
"
);return false;
\"
>
"
+
feature
[
"
name
"
]
+
"
</a>
"
;
}
else
{
}
else
{
link
+=
feature
[
'
description
'
];
link
+=
feature
[
'
name
'
];
}
}
link
+=
"
(
"
+
citygml_percentage
+
"
%
"
;
link
+=
"
(
"
+
citygml_percentage
+
"
%
"
;
...
@@ -221,14 +224,20 @@ var regionChooser = (function(){
...
@@ -221,14 +224,20 @@ var regionChooser = (function(){
}
}
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
feature
.
get
(
'
description
'
)
+
"
-
"
+
err
);
console
.
log
(
feature
.
get
(
'
name
'
)
+
"
-
"
+
err
);
}
}
i
++
;
}
}
var
i
=
0
;
features_by_project
=
groupBy
(
kml_source
.
getFeatures
(),
"
project
"
);
Object
.
keys
(
features_by_project
).
forEach
(
function
(
project
)
{
dataPanel
.
append
(
"
<h2>
"
+
project
);
features
=
features_by_project
[
project
];
for
(
var
i
=
0
;
i
<
features
.
length
;
i
++
)
{
findIntersection
(
features
[
i
]);
}
});
dataPanel
.
append
(
"
<h2>
"
+
"
NovaFactory
"
);
novafactory_vectors
.
forEachFeature
(
findIntersection
);
novafactory_vectors
.
forEachFeature
(
findIntersection
);
i
=
0
;
// kml_source.forEachFeature(findIntersection);
kml_source
.
forEachFeature
(
findIntersection
);
if
(
!
intersection_found
)
{
if
(
!
intersection_found
)
{
dataPanel
.
append
(
"
No intersection found with any CityGML or NovaFactory product<br/>
\n
"
);
dataPanel
.
append
(
"
No intersection found with any CityGML or NovaFactory product<br/>
\n
"
);
}
}
...
@@ -241,7 +250,7 @@ var regionChooser = (function(){
...
@@ -241,7 +250,7 @@ var regionChooser = (function(){
publicScope
.
downloadRegionFromCityGML
=
function
(
i
)
{
publicScope
.
downloadRegionFromCityGML
=
function
(
i
)
{
// TODO: Disable all links
// TODO: Disable all links
// TODO: DRY
// TODO: DRY
var
feature
=
kml_source
.
getFeature
s
()[
i
]
;
var
feature
=
kml_source
.
getFeature
ById
(
i
)
;
// Waiting 100ms in order to let the cursor change
// Waiting 100ms in order to let the cursor change
setTimeout
(
function
()
{
setTimeout
(
function
()
{
var
start
=
new
Date
().
getTime
();
var
start
=
new
Date
().
getTime
();
...
@@ -252,7 +261,7 @@ var regionChooser = (function(){
...
@@ -252,7 +261,7 @@ var regionChooser = (function(){
fxapp
.
downloadRegionFromCityGML
(
sketchAsWKT
(
srsName
),
feature
.
get
(
"
project
"
),
feature
.
get
(
"
name
"
),
srsName
);
fxapp
.
downloadRegionFromCityGML
(
sketchAsWKT
(
srsName
),
feature
.
get
(
"
project
"
),
feature
.
get
(
"
name
"
),
srsName
);
var
end
=
new
Date
().
getTime
();
var
end
=
new
Date
().
getTime
();
var
time
=
end
-
start
;
var
time
=
end
-
start
;
console
.
log
(
'
D
L
Execution time:
'
+
time
);
console
.
log
(
'
D
ownload
Execution time:
'
+
(
time
/
1000.0
).
toFixed
(
3
)
+
'
s
'
);
setTimeout
(
function
()
{
setTimeout
(
function
()
{
$
(
"
html
"
).
removeClass
(
"
wait
"
);
$
(
"
html
"
).
removeClass
(
"
wait
"
);
dataPanel
.
append
(
"
Done<br/>
\n
"
);
dataPanel
.
append
(
"
Done<br/>
\n
"
);
...
@@ -340,7 +349,7 @@ var regionChooser = (function(){
...
@@ -340,7 +349,7 @@ var regionChooser = (function(){
publicScope
.
downloadRegionFromNovaFACTORY
=
function
(
i
)
{
publicScope
.
downloadRegionFromNovaFACTORY
=
function
(
i
)
{
$
(
"
html
"
).
addClass
(
"
wait
"
);
$
(
"
html
"
).
addClass
(
"
wait
"
);
var
feature
=
novafactory_vectors
.
getFeature
s
()[
i
]
;
var
feature
=
novafactory_vectors
.
getFeature
ById
(
i
)
;
// Waiting 100ms in order to let the cursor change
// Waiting 100ms in order to let the cursor change
setTimeout
(
function
()
{
setTimeout
(
function
()
{
fxapp
.
downloadRegion
(
sketchAsWKT
(),
feature
.
get
(
'
name
'
),
novafactory_layer
);
fxapp
.
downloadRegion
(
sketchAsWKT
(),
feature
.
get
(
'
name
'
),
novafactory_layer
);
...
@@ -374,6 +383,13 @@ var regionChooser = (function(){
...
@@ -374,6 +383,13 @@ var regionChooser = (function(){
}
}
}
}
groupBy
=
function
(
xs
,
key
)
{
return
xs
.
reduce
(
function
(
rv
,
x
)
{
(
rv
[
x
[
key
]]
=
rv
[
x
[
key
]]
||
[]).
push
(
x
);
return
rv
;
},
{});
};
function
displayHelp
(){
function
displayHelp
(){
dataPanel
.
empty
();
dataPanel
.
empty
();
dataPanel
.
append
(
"
Welcome to Region Chooser!<br><br>
\n
"
);
dataPanel
.
append
(
"
Welcome to Region Chooser!<br><br>
\n
"
);
...
@@ -393,6 +409,6 @@ var regionChooser = (function(){
...
@@ -393,6 +409,6 @@ var regionChooser = (function(){
}
}
focusOnMap
();
focusOnMap
();
//var regionChooser = publicScope; //NOTE: In order to open closure. For debugging
var
regionChooser
=
publicScope
;
//NOTE: In order to open closure. For debugging
return
publicScope
;
// return publicScope;
})();
//})();
\ No newline at end of file
\ No newline at end of file
src/eu/simstadt/regionchooser/website/style/style.css
View file @
213236e1
...
@@ -117,8 +117,11 @@ div#dataPanel{
...
@@ -117,8 +117,11 @@ div#dataPanel{
word-wrap
:
break-word
;
word-wrap
:
break-word
;
}
}
div
#dataPanel
h2
{
font-size
:
16px
;
}
div
#dataPanel
li
{
div
#dataPanel
li
{
list-style-type
:
none
;
padding
:
2px
0
0
0
;
padding
:
2px
0
0
0
;
margin
:
5px
0
;
margin
:
5px
0
;
line-height
:
1
;
line-height
:
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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