Commit 1ef35568 authored by duminil's avatar duminil
Browse files

RegionChooser : Find out which buildings are inside polygon.

parent e218f4b4
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.fx.ide.jdt.core.JAVAFX_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="lib/GMapsFX-1.1.1.jar" sourcepath="C:/Users/Kai Brassel/Desktop/rterp-GMapsFX-71adc3c/GMapsFX/src/main/java">
<attributes>
<attribute name="javadoc_location" value="http://rterp.github.io/GMapsFX/apidocs/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/Proj4J.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/SimStadtRepository"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.fx.ide.jdt.core.JAVAFX_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="lib/GMapsFX-1.1.1.jar" sourcepath="C:/Users/Kai Brassel/Desktop/rterp-GMapsFX-71adc3c/GMapsFX/src/main/java">
<attributes>
<attribute name="javadoc_location" value="http://rterp.github.io/GMapsFX/apidocs/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/Proj4J.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/SimStadtRepository"/>
<classpathentry kind="lib" path="lib/jts-1.13.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -3,6 +3,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import javafx.application.Application;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Worker.State;
......@@ -16,7 +17,18 @@
import javafx.stage.Stage;
import javax.xml.stream.XMLStreamException;
import netscape.javascript.JSObject;
import org.citygml4j.model.gml.feature.BoundingShape;
import org.citygml4j.model.gml.geometry.primitives.DirectPosition;
import org.citygml4j.model.gml.geometry.primitives.Envelope;
import org.xml.sax.SAXParseException;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.io.ParseException;
import com.vividsolutions.jts.io.WKTReader;
import de.hft.stuttgart.citydoctor.datastructure.Building;
import eu.simstadt.admin.SimStadtBuilding;
import eu.simstadt.admin.SimStadtModel;
import eu.simstadt.admin.SimStadtProject;
......@@ -45,6 +57,7 @@ class Browser extends Region
public class JavaScriptFXBridge
{
private Path repo;
private WKTReader wktReader = new WKTReader();
public JavaScriptFXBridge() {
repo = Paths.get("../TestRepository");
......@@ -55,10 +68,32 @@ public void downloadRegion(String wktPolygon) {
}
public int downloadRegionFromCityGML(String wktPolygon, String project, String citygml)
throws SAXParseException, XMLStreamException {
throws SAXParseException, XMLStreamException, ParseException {
//Browser.this.getScene().getRoot().setCursor(Cursor.WAIT);
System.out.println("FROM JAVA : DO SOMETHING with " + wktPolygon + " from \n" + project + ">" + citygml);
SimStadtModel model = SimStadtProject.loadModelWithoutSchemaValidation(citygmlPath(project, citygml).toFile());
Geometry poly = wktReader.read(wktPolygon);
final GeometryFactory gf = new GeometryFactory();
System.out.println(poly);
//TODO: What's the easiest way to get WGS84 coordinates of building center?
for (Building building : model.getCityDoctorBuildings()) {
BoundingShape boundedBy = building.getCitygmlBuilding().getBoundedBy();
if (boundedBy != null) {
Envelope envelope = boundedBy.getEnvelope();
if (envelope != null) {
List<Double> l = envelope.getLowerCorner().getValue();
List<Double> h = envelope.getUpperCorner().getValue();
double x = (l.get(0) + h.get(0)) * 0.5;
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)) {
System.out.println(building.getGmlId());
}
}
}
}
return model.getCityDoctorBuildings().size();
}
......
......@@ -174,6 +174,7 @@ function findIntersections() {
}
function downloadRegionFromCityGML(i) {
//TODO: Disable all links
$("html").addClass("wait");
var feature = kml_source.getFeatures()[i];
// Waiting 100ms in order to let the cursor change
......@@ -228,6 +229,7 @@ $('#reset').click(function() {
draw.finishDrawing();
} finally {
$('#dataPanel').empty();
$("html").removeClass("wait");
featureOverlay.getFeatures().clear();
intersections.clear();
reset_btn.disabled = true;
......@@ -244,7 +246,7 @@ $('#send').click(function() {
function sketchAsWKT() {
var wktFormat = new ol.format.WKT();
return wktFormat.writeFeature(sketch, {
dataProjection : ol.proj.get('EPSG:4326'),
dataProjection : ol.proj.get('EPSG:31467'),
featureProjection : ol.proj.get('EPSG:3857')
})
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment