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
b8437c3c
Commit
b8437c3c
authored
10 years ago
by
duminil
Browse files
Options
Download
Email Patches
Plain Diff
Save selected building IDs as a txt file.
parent
4f424697
master
develop
migrate_to_Java11
0.2.2
0.1.0
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/eu/simstadt/regionchooser/RegionChooserFX.java
+40
-17
src/eu/simstadt/regionchooser/RegionChooserFX.java
website/script/simstadt_openlayers.js
+5
-5
website/script/simstadt_openlayers.js
with
45 additions
and
22 deletions
+45
-22
src/eu/simstadt/regionchooser/RegionChooserFX.java
+
40
-
17
View file @
b8437c3c
package
eu.simstadt.regionchooser
;
package
eu.simstadt.regionchooser
;
import
java.io.BufferedWriter
;
import
java.io.File
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.Paths
;
...
@@ -14,6 +17,7 @@
...
@@ -14,6 +17,7 @@
import
javafx.scene.paint.Color
;
import
javafx.scene.paint.Color
;
import
javafx.scene.web.WebEngine
;
import
javafx.scene.web.WebEngine
;
import
javafx.scene.web.WebView
;
import
javafx.scene.web.WebView
;
import
javafx.stage.FileChooser
;
import
javafx.stage.Stage
;
import
javafx.stage.Stage
;
import
javax.xml.stream.XMLStreamException
;
import
javax.xml.stream.XMLStreamException
;
import
netscape.javascript.JSObject
;
import
netscape.javascript.JSObject
;
...
@@ -66,34 +70,53 @@ public void downloadRegion(String wktPolygon) {
...
@@ -66,34 +70,53 @@ public void downloadRegion(String wktPolygon) {
}
}
public
int
downloadRegionFromCityGML
(
String
wktPolygon
,
String
project
,
String
citygml
,
JSObject
featureOverlay
)
public
int
downloadRegionFromCityGML
(
String
wktPolygon
,
String
project
,
String
citygml
,
JSObject
featureOverlay
)
throws
SAXParseException
,
XMLStreamException
,
ParseException
{
throws
SAXParseException
,
XMLStreamException
,
ParseException
,
IOException
{
//
System.out.println("FROM JAVA : DO SOMETHING with " + wktPolygon + " from \n" + project + ">" + citygml);
//
FIXME: Why is this so slow?
SimStadtModel
model
=
SimStadtProject
.
loadModelWithoutSchemaValidation
(
citygmlPath
(
project
,
citygml
).
toFile
());
SimStadtModel
model
=
SimStadtProject
.
loadModelWithoutSchemaValidation
(
citygmlPath
(
project
,
citygml
).
toFile
());
Geometry
poly
=
wktReader
.
read
(
wktPolygon
);
Geometry
poly
=
wktReader
.
read
(
wktPolygon
);
final
GeometryFactory
gf
=
new
GeometryFactory
();
final
GeometryFactory
gf
=
new
GeometryFactory
();
//TODO: What's the easiest way to get WGS84 coordinates of building center?
for
(
Building
building
:
model
.
getCityDoctorBuildings
())
{
File
buildingIdsFile
=
selectSaveFileWithDialog
(
project
,
citygml
);
BoundingShape
boundedBy
=
building
.
getCitygmlBuilding
().
getBoundedBy
();
if
(
buildingIdsFile
!=
null
)
{
if
(
boundedBy
!=
null
)
{
BufferedWriter
writer
=
Files
.
newBufferedWriter
(
buildingIdsFile
.
toPath
());
Envelope
envelope
=
boundedBy
.
getEnvelope
();
if
(
envelope
!=
null
)
{
//TODO: What's the easiest way to get WGS84 coordinates of building center?
List
<
Double
>
l
=
envelope
.
getLowerCorner
().
getValue
();
for
(
Building
building
:
model
.
getCityDoctorBuildings
())
{
List
<
Double
>
h
=
envelope
.
getUpperCorner
().
getValue
();
BoundingShape
boundedBy
=
building
.
getCitygmlBuilding
().
getBoundedBy
();
double
x
=
(
l
.
get
(
0
)
+
h
.
get
(
0
))
*
0.5
;
if
(
boundedBy
!=
null
)
{
double
y
=
(
l
.
get
(
1
)
+
h
.
get
(
1
))
*
0.5
;
Envelope
envelope
=
boundedBy
.
getEnvelope
();
Coordinate
coord
=
new
Coordinate
(
x
,
y
);
if
(
envelope
!=
null
)
{
Point
point
=
gf
.
createPoint
(
coord
);
List
<
Double
>
l
=
envelope
.
getLowerCorner
().
getValue
();
if
(
point
.
within
(
poly
))
{
List
<
Double
>
h
=
envelope
.
getUpperCorner
().
getValue
();
featureOverlay
.
call
(
"addMarker"
,
x
,
y
,
building
.
getGmlId
());
double
x
=
(
l
.
get
(
0
)
+
h
.
get
(
0
))
*
0.5
;
System
.
out
.
println
(
building
.
getGmlId
());
double
y
=
(
l
.
get
(
1
)
+
h
.
get
(
1
))
*
0.5
;
Coordinate
coord
=
new
Coordinate
(
x
,
y
);
Point
point
=
gf
.
createPoint
(
coord
);
if
(
point
.
within
(
poly
))
{
//featureOverlay.call("addMarker", x, y, building.getGmlId());
writer
.
write
(
building
.
getGmlId
()
+
"\r\n"
);
System
.
out
.
println
(
building
.
getGmlId
());
}
}
}
}
}
}
}
writer
.
close
();
}
}
return
model
.
getCityDoctorBuildings
().
size
();
return
model
.
getCityDoctorBuildings
().
size
();
}
}
private
File
selectSaveFileWithDialog
(
String
project
,
String
citygml
)
{
Stage
mainStage
=
(
Stage
)
Browser
.
this
.
getScene
().
getWindow
();
FileChooser
fileChooser
=
new
FileChooser
();
fileChooser
.
setTitle
(
"Save CITYGML ids"
);
fileChooser
.
setInitialDirectory
(
repo
.
resolve
(
project
+
".simstadt"
).
toFile
());
fileChooser
.
setInitialFileName
(
citygml
.
split
(
"\\."
)[
0
]
+
"_selected_region"
);
FileChooser
.
ExtensionFilter
extFilter
=
new
FileChooser
.
ExtensionFilter
(
"TXT files (*.txt)"
,
"*.txt"
);
fileChooser
.
getExtensionFilters
().
add
(
extFilter
);
return
fileChooser
.
showSaveDialog
(
mainStage
);
}
public
boolean
checkIfCityGMLSAreAvailable
(
String
project
,
String
citygml
)
{
public
boolean
checkIfCityGMLSAreAvailable
(
String
project
,
String
citygml
)
{
return
Files
.
isReadable
(
citygmlPath
(
project
,
citygml
));
return
Files
.
isReadable
(
citygmlPath
(
project
,
citygml
));
}
}
...
...
This diff is collapsed.
Click to expand it.
website/script/simstadt_openlayers.js
+
5
-
5
View file @
b8437c3c
...
@@ -245,7 +245,7 @@ function downloadRegionFromCityGML(i) {
...
@@ -245,7 +245,7 @@ function downloadRegionFromCityGML(i) {
var
end
=
new
Date
().
getTime
();
var
end
=
new
Date
().
getTime
();
var
time
=
end
-
start
;
var
time
=
end
-
start
;
console
.
log
(
'
DL Execution time:
'
+
time
);
console
.
log
(
'
DL Execution time:
'
+
time
);
$
(
'
#dataPanel
'
).
append
(
"
Imported buildings :
"
+
buildings_count
);
//
$('#dataPanel').append("Imported buildings : " + buildings_count);
$
(
"
html
"
).
removeClass
(
"
wait
"
);
$
(
"
html
"
).
removeClass
(
"
wait
"
);
},
100
);
},
100
);
}
}
...
@@ -267,10 +267,10 @@ function displayInfo() {
...
@@ -267,10 +267,10 @@ function displayInfo() {
var
gsk3_coord
=
ol
.
proj
.
transform
(
coords
[
i
],
ol
.
proj
.
get
(
'
EPSG:4326
'
),
ol
.
proj
.
get
(
'
EPSG:31467
'
))
var
gsk3_coord
=
ol
.
proj
.
transform
(
coords
[
i
],
ol
.
proj
.
get
(
'
EPSG:4326
'
),
ol
.
proj
.
get
(
'
EPSG:31467
'
))
gsk3_coords
+=
"
(
"
+
gsk3_coord
[
0
]
+
"
,
"
+
gsk3_coord
[
1
]
+
"
)<br/>
"
;
gsk3_coords
+=
"
(
"
+
gsk3_coord
[
0
]
+
"
,
"
+
gsk3_coord
[
1
]
+
"
)<br/>
"
;
}
}
$
(
'
#dataPanel
'
).
append
(
"
WGS84 Coordinates<br/>
"
);
//
$('#dataPanel').append("WGS84 Coordinates<br/>");
$
(
'
#dataPanel
'
).
append
(
wgs84_coords
+
"
<br/>
\n
"
);
//
$('#dataPanel').append(wgs84_coords + "<br/>\n");
$
(
'
#dataPanel
'
).
append
(
"
GSK3 Coordinates<br/>
"
);
//
$('#dataPanel').append("GSK3 Coordinates<br/>");
$
(
'
#dataPanel
'
).
append
(
gsk3_coords
+
"
<br/>
\n
"
);
//
$('#dataPanel').append(gsk3_coords + "<br/>\n");
$
(
'
#dataPanel
'
).
append
(
"
Area
"
+
"
<br/>
\n
"
);
$
(
'
#dataPanel
'
).
append
(
"
Area
"
+
"
<br/>
\n
"
);
$
(
'
#dataPanel
'
).
append
((
Math
.
round
(
area
/
1000
)
/
10
).
toString
()
+
"
ha<br/><br/>
\n
"
);
$
(
'
#dataPanel
'
).
append
((
Math
.
round
(
area
/
1000
)
/
10
).
toString
()
+
"
ha<br/><br/>
\n
"
);
findIntersections
();
findIntersections
();
...
...
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