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
e6e7fe28
Commit
e6e7fe28
authored
2 years ago
by
Eric Duminil
Browse files
Options
Download
Email Patches
Plain Diff
Proof-of-concept : extract from multiple citygmls.
parent
b74173c0
master
develop
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/eu/simstadt/regionchooser/RegionChooserBrowser.java
+9
-4
.../java/eu/simstadt/regionchooser/RegionChooserBrowser.java
src/main/resources/eu/simstadt/regionchooser/website/script/simstadt_openlayers.js
+19
-9
...stadt/regionchooser/website/script/simstadt_openlayers.js
with
28 additions
and
13 deletions
+28
-13
src/main/java/eu/simstadt/regionchooser/RegionChooserBrowser.java
+
9
-
4
View file @
e6e7fe28
...
...
@@ -8,6 +8,7 @@
import
java.nio.file.Paths
;
import
java.util.logging.Logger
;
import
java.util.prefs.Preferences
;
import
java.util.stream.Stream
;
import
org.locationtech.jts.io.ParseException
;
import
com.ximpleware.NavException
;
import
com.ximpleware.XPathParseException
;
...
...
@@ -69,12 +70,16 @@ public Void call() throws IOException {
new
Thread
(
task
).
start
();
}
public
void
downloadRegionFromCityGML
(
String
wktPolygon
,
String
project
,
String
citygml
,
String
srsName
)
public
void
downloadRegionFromCityGML
(
String
wktPolygon
,
String
project
,
String
c
svC
itygml
s
,
String
srsName
)
throws
IOException
,
ParseException
,
XPathParseException
,
NavException
{
StringBuilder
sb
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
wktPolygon
,
srsName
,
citygmlPath
(
project
,
citygml
));
File
buildingIdsFile
=
selectSaveFileWithDialog
(
project
,
citygml
,
"selected_region"
);
System
.
out
.
println
(
"BEEN HERE?"
);
Path
[]
paths
=
Stream
.
of
(
csvCitygmls
.
split
(
";"
)).
map
(
s
->
citygmlPath
(
project
,
s
)).
toArray
(
Path
[]::
new
);
StringBuilder
sb
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
wktPolygon
,
srsName
,
paths
);
File
buildingIdsFile
=
selectSaveFileWithDialog
(
project
,
csvCitygmls
.
replace
(
";"
,
"_"
),
"selected_region"
);
if
(
buildingIdsFile
!=
null
)
{
try
(
BufferedWriter
writer
=
Files
.
newBufferedWriter
(
buildingIdsFile
.
toPath
()))
{
char
[]
chars
=
new
char
[
BUFFER
];
...
...
This diff is collapsed.
Click to expand it.
src/main/resources/eu/simstadt/regionchooser/website/script/simstadt_openlayers.js
+
19
-
9
View file @
e6e7fe28
...
...
@@ -177,10 +177,10 @@ var regionChooser = (function(){
console
.
log
(
"
Feature name :
"
+
feature
[
"
name
"
]);
console
.
log
(
"
Feature ID :
"
+
feature
.
getId
());
if
(
fromJavaFX
)
{
link
+=
'
<input type="checkbox" id="c
heck
_
'
+
feature
.
getId
()
+
'
" class="select_citygml"><label for="c
heck
_
'
+
feature
.
getId
()
+
'
">
'
+
feature
[
'
name
'
]
+
'
</label>
'
;
link
+=
'
<input type="checkbox" id="c
itygml
_
'
+
feature
.
getId
()
+
'
" class="select_citygml"><label for="c
itygml
_
'
+
feature
.
getId
()
+
'
">
'
+
feature
[
'
name
'
]
+
'
</label>
'
;
}
else
{
h
=
cyrb53
(
feature
[
'
name
'
]);
link
+=
'
<input type="checkbox" id="c
heck
_
'
+
h
+
'
" class="select_citygml"><label for="c
heck
_
'
+
h
+
'
">
'
+
feature
[
'
name
'
]
+
'
</label>
'
;
link
+=
'
<input type="checkbox" id="c
itygml
_
'
+
h
+
'
" class="select_citygml"><label for="c
itygml
_
'
+
h
+
'
">
'
+
feature
[
'
name
'
]
+
'
</label>
'
;
}
link
+=
"
(
"
+
citygml_percentage
+
"
%
"
;
...
...
@@ -229,21 +229,30 @@ var regionChooser = (function(){
dataPanel
.
append
(
text
+
"
<br/>
\n
"
);
}
publicScope
.
downloadRegionFromCityGML
=
function
(
i
)
{
publicScope
.
downloadRegionFromCityGML
=
function
(
checkbox_ids
)
{
// TODO: Disable all links
// TODO: DRY
var
feature
=
kml_source
.
getFeatureById
(
i
);
var
features
=
checkbox_ids
.
map
(
checkbox_id
=>
{
var
i
=
Number
(
checkbox_id
.
replace
(
"
citygml_
"
,
""
));
return
kml_source
.
getFeatureById
(
i
);
})
var
project
=
features
[
0
].
get
(
"
project
"
);
//TODO: Check all the same
var
srsName
=
features
[
0
].
get
(
"
srsName
"
)
||
"
EPSG:31467
"
;
//TODO: Check all the same
var
citygmlNames
=
features
.
map
(
f
=>
f
.
get
(
"
name
"
));
// Waiting 100ms in order to let the cursor change
setTimeout
(
function
()
{
var
start
=
new
Date
().
getTime
();
var
srsName
=
feature
.
get
(
"
srsName
"
)
||
"
EPSG:31467
"
;
if
(
proj4
.
defs
(
srsName
)){
$
(
"
html
"
).
addClass
(
"
wait
"
);
console
.
log
(
"
Selected region is written in
"
+
srsName
+
"
coordinate system.
"
);
try
{
fxapp
.
downloadRegionFromCityGML
(
sketchAsWKT
(
srsName
),
feature
.
get
(
"
project
"
),
feature
.
get
(
"
name
"
),
srsName
);
console
.
log
(
"
Before JAVA
"
);
fxapp
.
downloadRegionFromCityGML
(
sketchAsWKT
(
srsName
),
project
,
citygmlNames
.
join
(
"
;
"
),
srsName
);
console
.
log
(
"
After JAVA
"
);
dataPanel
.
append
(
"
<h2 class='ok'>Done!</h2><br/>
\n
"
);
}
catch
(
e
)
{
console
.
log
(
"
ERROR
"
+
e
);
dataPanel
.
append
(
"
<h2 class='error'>Some problem occured!</h2><br/>
\n
"
);
}
var
end
=
new
Date
().
getTime
();
...
...
@@ -364,13 +373,14 @@ var regionChooser = (function(){
publicScope
.
clickety_click
=
function
()
{
console
.
log
(
"
You clicked pretty well
"
);
var
checkedBoxes
=
Array
.
from
(
document
.
querySelectorAll
(
"
input.select_citygml
"
)).
filter
(
x
=>
x
.
checked
);
var
checkedBoxes
=
Array
.
from
(
document
.
querySelectorAll
(
"
input.select_citygml
"
)).
filter
(
c
=>
c
.
checked
);
if
(
checkedBoxes
.
length
===
0
){
console
.
log
(
"
You should select at least one citygml, though.
"
);
}
else
{
checkedBoxes
.
forEach
(
x
=>
{
console
.
log
(
"
Nice! You checked Citygml
"
+
x
.
id
)
checkedBoxes
.
forEach
(
c
=>
{
console
.
log
(
"
Nice! You checked Citygml
"
+
c
.
id
)
});
publicScope
.
downloadRegionFromCityGML
(
checkedBoxes
.
map
(
c
=>
c
.
id
));
}
}
...
...
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