Commit 9b0603a3 authored by hengwen's avatar hengwen
Browse files

Add waterway

parent f36d97ba
......@@ -134,11 +134,11 @@ public class MapModel {
}
public static class Building{
public static class EnvironmentObject{
private List<Node> nodes;
private String type;
public Building(List<Node> nodes, String type) {
public EnvironmentObject(List<Node> nodes, String type) {
this.nodes = nodes;
this.type = type;
}
......@@ -152,11 +152,25 @@ public class MapModel {
}
}
public static class Building extends EnvironmentObject {
public Building(List<Node> nodes, String type) {
super(nodes, type);
}
}
public static class Waterway extends Building{
public Waterway(List<Node> nodes, String type) {
super(nodes, type);
}
}
private int id;
private String name;
private String path;
private List<Street> streets;
private List<Building> buildings;
private List<Waterway> waterways;
private Bound bounds;
public int getId() {
......@@ -199,6 +213,14 @@ public class MapModel {
this.buildings = buildings;
}
public List<Waterway> getWaterways() {
return waterways;
}
public void setWaterways(List<Waterway> waterways) {
this.waterways = waterways;
}
public Bound getBounds() {
return bounds;
}
......@@ -206,6 +228,4 @@ public class MapModel {
public void setBounds(Bound bounds) {
this.bounds = bounds;
}
}
......@@ -5,10 +5,7 @@ import simulation.environment.World;
import simulation.environment.WorldModel;
import simulation.environment.osm.ApproximateConverter;
import simulation.environment.osm.ParserSettings;
import simulation.environment.visualisationadapter.interfaces.Building;
import simulation.environment.visualisationadapter.interfaces.EnvBounds;
import simulation.environment.visualisationadapter.interfaces.EnvNode;
import simulation.environment.visualisationadapter.interfaces.EnvStreet;
import simulation.environment.visualisationadapter.interfaces.*;
import simulation.environment.weather.WeatherSettings;
import java.io.FileInputStream;
......@@ -34,6 +31,8 @@ public class WorldBuilderService {
addStreets();
addBuildings();
addBound();
addWaterWays();
// addHeightMap();
} catch (Exception e) {
e.printStackTrace();
}
......@@ -101,4 +100,16 @@ public class WorldBuilderService {
}
mapModel.setBuildings(buildings);
}
private void addWaterWays() throws Exception {
List<MapModel.Waterway> waterways = new ArrayList<>();
for (Waterway waterway: world.getContainer().getWaterway()){
Waterway.WaterTypes waterwayTypes = waterway.getWaterType();
waterways.add(new MapModel.Waterway(
getLonLatNodesFromXYNodes(waterway.getNodes()),
waterwayTypes == null ? "" : waterwayTypes.toString()
));
}
mapModel.setWaterways(waterways);
}
}
......@@ -12,6 +12,7 @@ public class WorldBuilderServiceTest {
MapModel result = wb.buildWorld();
assertTrue(result.getStreets().size() > 0);
assertTrue(result.getBuildings().size() > 0);
assertTrue(result.getWaterways().size() >= 0); // Aachen.osm has no waterway
assertTrue(result.getBounds() != null);
}
}
\ No newline at end of file
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