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
395f34dd
Commit
395f34dd
authored
May 16, 2015
by
duminil
Browse files
RegionChooser js refactoring.
new Java methods.
parent
7b5a7cea
Changes
2
Show whitespace changes
Inline
Side-by-side
src/eu/simstadt/regionchooser/RegionChooserFX.java
View file @
395f34dd
...
@@ -25,7 +25,6 @@ public void start(Stage stage) {
...
@@ -25,7 +25,6 @@ public void start(Stage stage) {
stage
.
setTitle
(
"RegionChooserJavaFX"
);
stage
.
setTitle
(
"RegionChooserJavaFX"
);
scene
=
new
Scene
(
new
Browser
(),
1024
,
768
,
Color
.
web
(
"#666970"
));
scene
=
new
Scene
(
new
Browser
(),
1024
,
768
,
Color
.
web
(
"#666970"
));
stage
.
setScene
(
scene
);
stage
.
setScene
(
scene
);
scene
.
getStylesheets
().
add
(
"webviewsample/BrowserToolbar.css"
);
stage
.
show
();
stage
.
show
();
}
}
...
@@ -42,6 +41,15 @@ class Browser extends Region
...
@@ -42,6 +41,15 @@ class Browser extends Region
public
void
downloadRegion
(
String
wktPolygon
)
{
public
void
downloadRegion
(
String
wktPolygon
)
{
System
.
out
.
println
(
"FROM JAVA : DO SOMETHING with "
+
wktPolygon
);
System
.
out
.
println
(
"FROM JAVA : DO SOMETHING with "
+
wktPolygon
);
}
}
public
void
downloadRegionFromCityGML
(
String
wktPolygon
,
String
citygmlDescription
)
{
System
.
out
.
println
(
"FROM JAVA : DO SOMETHING with "
+
wktPolygon
+
" from \n"
+
citygmlDescription
);
}
public
boolean
checkIfCityGMLSAreAvailable
(
String
citygmlDescription
)
{
//TODO: IMPLEMENT ME
return
true
;
}
}
}
final
WebView
browser
=
new
WebView
();
final
WebView
browser
=
new
WebView
();
...
...
website/script/simstadt_openlayers.js
View file @
395f34dd
...
@@ -36,10 +36,6 @@ var kml_layer = new ol.layer.Vector({
...
@@ -36,10 +36,6 @@ var kml_layer = new ol.layer.Vector({
})
})
});
});
kml_layer
.
addEventListener
(
"
change
"
,
function
(
event
)
{
map
.
getView
().
fitExtent
(
kml_source
.
getExtent
(),
(
map
.
getSize
()));
});
var
intersections
=
new
ol
.
source
.
Vector
();
var
intersections
=
new
ol
.
source
.
Vector
();
var
intersections_layer
=
new
ol
.
layer
.
Vector
({
var
intersections_layer
=
new
ol
.
layer
.
Vector
({
...
@@ -59,6 +55,21 @@ var map = new ol.Map({
...
@@ -59,6 +55,21 @@ var map = new ol.Map({
})
})
});
});
var
geoJSONformat
=
new
ol
.
format
.
GeoJSON
();
kml_layer
.
addEventListener
(
"
change
"
,
function
(
event
)
{
var
fromJavaFX
=
(
typeof
fxapp
!==
'
undefined
'
);
map
.
getView
().
fitExtent
(
kml_source
.
getExtent
(),
(
map
.
getSize
()));
kml_source
.
forEachFeature
(
function
(
feature
)
{
feature
[
"
geoJSON
"
]
=
geoJSONformat
.
writeFeatureObject
(
feature
);
feature
[
"
area
"
]
=
feature
.
getGeometry
().
getArea
();
var
citygmlHere
;
if
(
fromJavaFX
)
{
citygmlHere
=
fxapp
.
checkIfCityGMLSAreAvailable
(
feature
.
get
(
"
description
"
));
}
feature
[
"
available
"
]
=
citygmlHere
;
});
});
// The features are not added to a regular vector layer/source,
// The features are not added to a regular vector layer/source,
// but to a feature overlay which holds a collection of features.
// but to a feature overlay which holds a collection of features.
// This collection is passed to the modify and also the draw
// This collection is passed to the modify and also the draw
...
@@ -113,19 +124,16 @@ draw.on('drawstart', function(evt) {
...
@@ -113,19 +124,16 @@ draw.on('drawstart', function(evt) {
reset_btn
.
disabled
=
false
;
reset_btn
.
disabled
=
false
;
});
});
var
sourceProj
=
map
.
getView
().
getProjection
();
var
sourceProj
=
map
.
getView
().
getProjection
();
var
geoJSONformat
=
new
ol
.
format
.
GeoJSON
();
function
findIntersections
()
{
function
findIntersections
()
{
var
features
=
kml_source
.
getFeatures
();
var
sketch_area
=
sketch
.
getGeometry
().
getArea
();
var
sketch_area
=
sketch
.
getGeometry
().
getArea
();
var
poly1
=
geoJSONformat
.
writeFeatureObject
(
sketch
);
var
poly1
=
geoJSONformat
.
writeFeatureObject
(
sketch
);
var
intersection_found
=
false
;
var
intersection_found
=
false
;
intersections
.
clear
();
intersections
.
clear
();
for
(
var
i
=
0
;
i
<
features
.
length
;
i
++
)
{
var
i
=
0
;
var
feature
=
features
[
i
];
kml_source
.
forEachFeature
(
function
(
feature
)
{
var
poly2
=
geoJSONformat
.
writeFeatureObject
(
feature
);
try
{
try
{
var
jsonIntersection
=
turf
.
intersect
(
poly1
,
poly2
);
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
"
);
...
@@ -133,12 +141,19 @@ function findIntersections() {
...
@@ -133,12 +141,19 @@ function findIntersections() {
}
}
var
intersection
=
geoJSONformat
.
readFeature
(
jsonIntersection
);
var
intersection
=
geoJSONformat
.
readFeature
(
jsonIntersection
);
var
intersectionArea
=
intersection
.
getGeometry
().
getArea
();
var
intersectionArea
=
intersection
.
getGeometry
().
getArea
();
var
citygmlArea
=
feature
.
getGeometry
().
getArea
();
var
citygml_percentage
=
Math
.
round
(
intersectionArea
/
feature
[
"
area
"
]
*
100
);
var
citygml_percentage
=
Math
.
round
(
intersectionArea
/
citygmlArea
*
100
);
var
sketch_percentage
=
Math
.
round
(
intersectionArea
/
sketch_area
*
100
);
var
sketch_percentage
=
Math
.
round
(
intersectionArea
/
sketch_area
*
100
);
intersections
.
addFeature
(
intersection
);
intersections
.
addFeature
(
intersection
);
$
(
'
#dataPanel
'
).
append
(
feature
.
get
(
'
description
'
)
+
"
(
"
+
citygml_percentage
+
"
%
"
);
var
description
;
if
(
feature
[
"
available
"
])
{
description
=
"
<a href=
\"
#
\"
onclick=
\"
downloadRegionFromCityGML(
"
+
i
+
"
);return false;
\"
>
"
+
feature
.
get
(
'
description
'
)
+
"
</a>
"
;
}
else
{
description
=
feature
.
get
(
'
description
'
);
}
$
(
'
#dataPanel
'
).
append
(
description
+
"
(
"
+
citygml_percentage
+
"
%
"
);
if
(
sketch_percentage
==
100
)
{
if
(
sketch_percentage
==
100
)
{
$
(
'
#dataPanel
'
).
append
(
"
, all inside
"
);
$
(
'
#dataPanel
'
).
append
(
"
, all inside
"
);
}
}
...
@@ -148,11 +163,18 @@ function findIntersections() {
...
@@ -148,11 +163,18 @@ function findIntersections() {
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
feature
.
get
(
'
description
'
)
+
"
-
"
+
err
);
console
.
log
(
feature
.
get
(
'
description
'
)
+
"
-
"
+
err
);
}
}
}
i
++
;
})
if
(
!
intersection_found
)
{
if
(
!
intersection_found
)
{
$
(
'
#dataPanel
'
).
append
(
"
No intersection found with any CityGML<br/>
\n
"
);
$
(
'
#dataPanel
'
).
append
(
"
No intersection found with any CityGML<br/>
\n
"
);
}
}
}
}
function
downloadRegionFromCityGML
(
i
)
{
$
(
'
#dataPanel
'
).
append
(
"
COMING FROM
"
+
i
);
fxapp
.
downloadRegionFromCityGML
(
sketchAsWKT
(),
kml_source
.
getFeatures
()[
i
].
get
(
"
description
"
));
}
function
displayInfo
()
{
function
displayInfo
()
{
var
start
=
new
Date
().
getTime
();
var
start
=
new
Date
().
getTime
();
$
(
'
#dataPanel
'
).
empty
();
$
(
'
#dataPanel
'
).
empty
();
...
@@ -201,17 +223,21 @@ $('#reset').click(function() {
...
@@ -201,17 +223,21 @@ $('#reset').click(function() {
});
});
$
(
'
#send
'
).
click
(
function
()
{
$
(
'
#send
'
).
click
(
function
()
{
focusOnMap
();
fxapp
.
downloadRegion
(
sketchAsWKT
());
});
function
sketchAsWKT
()
{
var
wktFormat
=
new
ol
.
format
.
WKT
();
var
wktFormat
=
new
ol
.
format
.
WKT
();
fxapp
.
downloadRegion
(
wktFormat
.
writeFeature
(
sketch
,
{
return
wktFormat
.
writeFeature
(
sketch
,
{
dataProjection
:
ol
.
proj
.
get
(
'
EPSG:4326
'
),
dataProjection
:
ol
.
proj
.
get
(
'
EPSG:4326
'
),
featureProjection
:
ol
.
proj
.
get
(
'
EPSG:3857
'
)
featureProjection
:
ol
.
proj
.
get
(
'
EPSG:3857
'
)
}));
})
focusOnMap
();
}
});
function
focusOnMap
()
{
function
focusOnMap
()
{
$
(
'
#map
'
).
focus
();
$
(
'
#map
'
).
focus
();
$
(
'
#map
'
).
scrollIntoView
();
//
$('#map').scrollIntoView();
}
}
focusOnMap
();
focusOnMap
();
\ 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