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
2ffc83c1
Commit
2ffc83c1
authored
10 years ago
by
duminil
Browse files
Options
Download
Email Patches
Plain Diff
No need for nF button anymore, automatic product selection.
parent
71e88cba
master
develop
migrate_to_Java11
0.2.2
0.1.0
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/eu/simstadt/nf4j/ExportJobFromJavaFXRegionChooser.java
+11
-12
src/eu/simstadt/nf4j/ExportJobFromJavaFXRegionChooser.java
src/eu/simstadt/regionchooser/RegionChooserFX.java
+4
-3
src/eu/simstadt/regionchooser/RegionChooserFX.java
website/index.html
+0
-1
website/index.html
website/script/simstadt_openlayers.js
+41
-33
website/script/simstadt_openlayers.js
with
56 additions
and
49 deletions
+56
-49
src/eu/simstadt/nf4j/ExportJobFromJavaFXRegionChooser.java
+
11
-
12
View file @
2ffc83c1
...
...
@@ -27,11 +27,10 @@ public class ExportJobFromJavaFXRegionChooser implements JobStatusListener
{
public
AsyncExportJob
job
;
private
JSObject
n
fButton
;
private
JSObject
n
ovaFactoryOpenLayer
;
public
void
processJob
(
Geometry
poly
,
JSObject
nfButton
)
throws
InterruptedException
{
this
.
nfButton
=
nfButton
;
String
productName
=
"WU3"
;
//NOTE: Others are LB,LBTEST, WU3
public
void
processJob
(
Geometry
poly
,
String
productName
,
JSObject
novaFactoryOpenLayer
)
throws
InterruptedException
{
this
.
novaFactoryOpenLayer
=
novaFactoryOpenLayer
;
ExportJobDescription
description
=
ExportJobDescription
.
getDefaultDescriptor
();
description
.
setInitiator
(
"2758"
);
description
.
setAccount
(
"Bruse"
);
...
...
@@ -71,16 +70,16 @@ public void jobStatusChanged(JobStatusEvent event) {
JobStatus
status
=
(
JobStatus
)
event
.
getSource
();
System
.
out
.
println
(
status
);
if
(
status
==
JobStatus
.
LOCAL
)
{
n
fButton
.
call
(
"updateStatus"
,
"REQUEST HAS BEEN PREPARED"
);
n
ovaFactoryOpenLayer
.
call
(
"updateStatus"
,
"REQUEST HAS BEEN PREPARED"
);
}
else
if
(
status
==
JobStatus
.
SENT
)
{
n
fButton
.
call
(
"updateStatus"
,
"REQUEST HAS BEEN SENT"
);
n
ovaFactoryOpenLayer
.
call
(
"updateStatus"
,
"REQUEST HAS BEEN SENT"
);
}
else
if
(
status
==
JobStatus
.
PENDING
)
{
n
fButton
.
call
(
"updateStatus"
,
"PENDING"
);
n
ovaFactoryOpenLayer
.
call
(
"updateStatus"
,
"PENDING"
);
}
else
if
(
status
==
JobStatus
.
RUNNING
)
{
n
fButton
.
call
(
"updateStatus"
,
"SERVER IS BUSY"
);
n
ovaFactoryOpenLayer
.
call
(
"updateStatus"
,
"SERVER IS BUSY"
);
}
else
if
(
status
==
JobStatus
.
FINISHED
)
{
try
{
n
fButton
.
call
(
"updateStatus"
,
"SERVER IS DONE"
);
n
ovaFactoryOpenLayer
.
call
(
"updateStatus"
,
"SERVER IS DONE"
);
job
.
downloadResult
();
}
catch
(
FailedTransmissionException
ex
)
{
ex
.
printStackTrace
();
...
...
@@ -88,12 +87,12 @@ public void jobStatusChanged(JobStatusEvent event) {
}
else
if
(
status
==
JobStatus
.
DOWNLOAD
)
{
try
{
File
file
=
job
.
getResult
();
n
fButton
.
call
(
"updateStatus"
,
"DOWNLOADED AS ZIP"
);
n
fButton
.
call
(
"selectSaveFile"
,
file
.
toString
());
n
ovaFactoryOpenLayer
.
call
(
"updateStatus"
,
"DOWNLOADED AS ZIP"
);
n
ovaFactoryOpenLayer
.
call
(
"selectSaveFile"
,
file
.
toString
());
// System.out.println("CityGML at " + file.getAbsolutePath());
System
.
out
.
println
(
"STILL HERE"
);
//TODO: Call downloadFinished if FAILED
n
fButton
.
call
(
"downloadFinished"
);
n
ovaFactoryOpenLayer
.
call
(
"downloadFinished"
);
}
catch
(
FailedTransmissionException
ex
)
{
ex
.
printStackTrace
();
}
...
...
This diff is collapsed.
Click to expand it.
src/eu/simstadt/regionchooser/RegionChooserFX.java
+
4
-
3
View file @
2ffc83c1
...
...
@@ -74,14 +74,15 @@ public JavaScriptFXBridge() {
}
}
public
void
downloadRegion
(
String
wktPolygon
,
JSObject
nfButton
)
throws
InterruptedException
{
public
void
downloadRegion
(
String
wktPolygon
,
String
productName
,
JSObject
novaFactoryLayer
)
throws
InterruptedException
{
//TODO: Ask nf Server about available regions
Task
<
Integer
>
task
=
new
Task
<
Integer
>()
{
@Override
protected
Integer
call
()
throws
Exception
{
ExportJobFromJavaFXRegionChooser
nfJob
=
new
ExportJobFromJavaFXRegionChooser
();
Geometry
poly
=
wktReader
.
read
(
wktPolygon
);
nfJob
.
processJob
(
poly
,
nfButton
);
nfJob
.
processJob
(
poly
,
productName
,
novaFactoryLayer
);
return
0
;
}
};
...
...
@@ -185,7 +186,7 @@ public void importNovaFactoryBoundingBoxes() throws IOException {
// String description = values[2];
String
[]
srs
=
values
[
3
].
split
(
" "
);
String
epsgId
=
srs
[
srs
.
length
-
1
];
System
.
out
.
println
(
product
);
//
System.out.println(product);
novafactoryVectors
.
call
(
"addNovaFactoryProduct"
,
values
[
8
],
values
[
9
],
values
[
10
],
values
[
11
],
product
,
epsgId
);
}
...
...
This diff is collapsed.
Click to expand it.
website/index.html
+
0
-
1
View file @
2ffc83c1
...
...
@@ -35,7 +35,6 @@
<div
id=
"map"
class=
"map"
tabindex=
"0"
></div>
<div
id=
"side"
>
<input
id=
"reset"
value=
"Reset"
type=
"button"
class=
"navi"
disabled
/>
<input
id=
"nfDownload"
value=
"NovaFactory download"
type=
"button"
class=
"navi"
disabled
/>
<div
id=
"dataPanel"
>
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
website/script/simstadt_openlayers.js
+
41
-
33
View file @
2ffc83c1
...
...
@@ -2,7 +2,6 @@
//TODO: Try to leave everything in 4326
var
reset_btn
=
$
(
'
#reset
'
)[
0
];
var
novafactory_btn
=
$
(
'
#nfDownload
'
)[
0
];
var
dataPanel
=
$
(
'
#dataPanel
'
);
var
br
=
document
.
createElement
(
'
br
'
);
...
...
@@ -22,13 +21,12 @@ var kml_source = new ol.source.KML({
extractStyles
:
false
})
function
polygon_style
(
color
,
alpha
){
function
polygon_style
(
color
,
alpha
)
{
return
new
ol
.
style
.
Style
({
fill
:
new
ol
.
style
.
Fill
({
color
:
'
rgba(255, 255, 255,
'
+
alpha
+
'
)
'
color
:
'
rgba(255, 255, 255,
'
+
alpha
+
'
)
'
}),
stroke
:
new
ol
.
style
.
Stroke
({
// color : '#777777',
color
:
color
,
width
:
2
,
lineDash
:
[
5
,
10
]
...
...
@@ -38,7 +36,7 @@ function polygon_style(color,alpha){
var
kml_layer
=
new
ol
.
layer
.
Vector
({
source
:
kml_source
,
style
:
polygon_style
(
'
#777777
'
,
0.2
)
style
:
polygon_style
(
'
#777777
'
,
0.2
)
});
var
intersections
=
new
ol
.
source
.
Vector
();
...
...
@@ -47,7 +45,7 @@ var intersections_layer = new ol.layer.Vector({
source
:
intersections
,
style
:
new
ol
.
style
.
Style
({
fill
:
new
ol
.
style
.
Fill
({
color
:
'
rgba(255, 155, 51, 0.
5
)
'
color
:
'
rgba(255, 155, 51, 0.
2
)
'
})
})
});
...
...
@@ -57,31 +55,36 @@ var novafactory_vectors = new ol.source.Vector({
});
novafactory_vectors
.
addNovaFactoryProduct
=
function
(
xmin
,
ymin
,
xmax
,
ymax
,
name
,
epsgId
)
{
var
box
=
new
ol
.
geom
.
Polygon
([[[
xmin
,
ymin
],[
xmin
,
ymax
],[
xmax
,
ymax
],[
xmax
,
ymin
],[
xmin
,
ymin
]]]);
box
.
transform
(
'
EPSG:
'
+
epsgId
,
'
EPSG:3857
'
);
this
.
addFeature
(
new
ol
.
Feature
({
var
box
=
new
ol
.
geom
.
Polygon
(
[
[
[
xmin
,
ymin
],
[
xmin
,
ymax
],
[
xmax
,
ymax
],
[
xmax
,
ymin
],
[
xmin
,
ymin
]
]
]);
box
.
transform
(
'
EPSG:
'
+
epsgId
,
'
EPSG:3857
'
);
var
feature
=
new
ol
.
Feature
({
geometry
:
box
,
name
:
name
,
}));
});
feature
[
"
geoJSON
"
]
=
geoJSONformat
.
writeFeatureObject
(
feature
);
feature
[
"
area
"
]
=
feature
.
getGeometry
().
getArea
();
feature
[
"
description
"
]
=
"
novaFACTORY>
"
+
name
;
feature
[
"
available
"
]
=
true
;
feature
[
"
source
"
]
=
"
NovaFACTORY
"
;
this
.
addFeature
(
feature
);
}
//novafactory_vectors.addNovaFactoryProduct(3530000,5434300,3538800,5445010,"WU");
//novafactory_vectors.addNovaFactoryProduct(3510000,5415000,3523100,5422000,"LB");
var
novafactory_layer
=
new
ol
.
layer
.
Vector
({
source
:
novafactory_vectors
,
style
:
polygon_style
(
'
#ff7700
'
,
0.1
)
style
:
polygon_style
(
'
#ff7700
'
,
0.1
)
});
var
map
=
new
ol
.
Map
({
target
:
'
map
'
,
layers
:
[
osm_layer
,
kml_layer
,
novafactory_layer
,
intersections_layer
],
layers
:
[
osm_layer
,
kml_layer
,
novafactory_layer
,
intersections_layer
],
interactions
:
ol
.
interaction
.
defaults
({
keyboard
:
true
})
});
var
geoJSONformat
=
new
ol
.
format
.
GeoJSON
();
kml_layer
.
addEventListener
(
"
change
"
,
function
(
event
)
{
map
.
getView
().
fitExtent
(
kml_source
.
getExtent
(),
(
map
.
getSize
()));
});
...
...
@@ -93,6 +96,7 @@ function updateGMLPolygons() {
var
project
=
feature
.
get
(
"
project
"
);
var
name
=
feature
.
get
(
"
name
"
);
feature
[
"
description
"
]
=
project
+
"
>
"
+
name
;
feature
[
"
source
"
]
=
"
CityGML
"
;
var
citygmlHere
;
if
(
fromJavaFX
)
{
citygmlHere
=
fxapp
.
checkIfCityGMLSAreAvailable
(
project
,
name
);
...
...
@@ -165,8 +169,7 @@ function findIntersections() {
var
poly1
=
geoJSONformat
.
writeFeatureObject
(
sketch
);
var
intersection_found
=
false
;
intersections
.
clear
();
var
i
=
0
;
kml_source
.
forEachFeature
(
function
(
feature
)
{
function
findIntersection
(
feature
)
{
try
{
var
jsonIntersection
=
turf
.
intersect
(
poly1
,
feature
[
"
geoJSON
"
]);
if
(
undefined
!=
jsonIntersection
)
{
...
...
@@ -182,8 +185,9 @@ function findIntersections() {
var
description
;
if
(
feature
[
"
available
"
])
{
description
=
"
<a href=
\"
#
\"
onclick=
\"
downloadRegionFromCityGML(
"
+
i
+
"
);return false;
\"
>
"
+
feature
[
"
description
"
]
+
"
</a>
"
;
description
=
"
<a href=
\"
#
\"
onclick=
\"
downloadRegionFrom
"
+
feature
[
"
source
"
]
+
"
(
"
+
i
+
"
);return false;
\"
>
"
+
feature
[
"
description
"
]
+
"
</a>
"
;
console
.
log
(
description
);
}
else
{
description
=
feature
[
'
description
'
];
}
...
...
@@ -199,9 +203,13 @@ function findIntersections() {
console
.
log
(
feature
.
get
(
'
description
'
)
+
"
-
"
+
err
);
}
i
++
;
})
}
var
i
=
0
;
novafactory_vectors
.
forEachFeature
(
findIntersection
)
var
i
=
0
;
kml_source
.
forEachFeature
(
findIntersection
)
if
(
!
intersection_found
)
{
dataPanel
.
append
(
"
No intersection found with any CityGML<br/>
\n
"
);
dataPanel
.
append
(
"
No intersection found with any CityGML
or NovaFactory product
<br/>
\n
"
);
}
}
...
...
@@ -260,9 +268,6 @@ function displayInfo() {
draw
.
on
(
'
drawend
'
,
function
(
e
)
{
displayInfo
();
if
(
fromJavaFX
)
{
novafactory_btn
.
disabled
=
false
;
}
draw
.
setActive
(
false
);
});
...
...
@@ -276,12 +281,11 @@ $('#reset').click(function() {
featureOverlay
.
getFeatures
().
clear
();
intersections
.
clear
();
reset_btn
.
disabled
=
true
;
novafactory_btn
.
disabled
=
true
;
focusOnMap
();
}
});
novafactory_
btn
.
downloadFinished
=
function
()
{
novafactory_
layer
.
downloadFinished
=
function
()
{
// FIXME: Weird <br>s are inserted between lines
dataPanel
.
append
(
"
NovaFactory : DONE <br/>
\n
"
);
this
.
disabled
=
false
;
...
...
@@ -289,22 +293,26 @@ novafactory_btn.downloadFinished = function() {
$
(
"
html
"
).
removeClass
(
"
wait
"
);
}
novafactory_
btn
.
updateStatus
=
function
(
status
)
{
novafactory_
layer
.
updateStatus
=
function
(
status
)
{
dataPanel
.
append
(
"
NovaFactory :
"
+
status
+
"
<br/>
\n
"
);
}
novafactory_
btn
.
selectSaveFile
=
function
(
zipFilename
)
{
novafactory_
layer
.
selectSaveFile
=
function
(
zipFilename
)
{
fxapp
.
doSomethingWithThisZIP
(
zipFilename
);
}
$
(
'
#nfDownload
'
).
click
(
function
(
)
{
function
downloadRegionFromNovaFACTORY
(
i
)
{
$
(
"
html
"
).
addClass
(
"
wait
"
);
novafactory_btn
.
disabled
=
true
;
//
dataPanel.append("NovaFactory BEGIN <br/>\n");
var
feature
=
novafactory_vectors
.
getFeatures
()[
i
]
;
//
Waiting 100ms in order to let the cursor change
setTimeout
(
function
()
{
fxapp
.
downloadRegion
(
sketchAsWKT
(
'
4326
'
),
novafactory_btn
);
fxapp
.
downloadRegion
(
sketchAsWKT
(
'
4326
'
),
feature
.
get
(
'
name
'
),
novafactory_layer
);
setTimeout
(
function
()
{
$
(
"
html
"
).
removeClass
(
"
wait
"
);
dataPanel
.
append
(
"
Done<br/>
\n
"
);
},
100
);
},
100
);
}
);
}
function
sketchAsWKT
(
epsgId
)
{
var
epsgId
=
(
typeof
epsgId
===
'
undefined
'
)
?
'
31467
'
:
epsgId
;
...
...
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