Skip to content
Snippets Groups Projects
Commit 5958db90 authored by kraleva's avatar kraleva
Browse files

Merge branch 'main' of...

parents 268d39ba 8433bbe1
No related branches found
No related tags found
1 merge request!29IterativeSCC
FROM eclipse-temurin:19-jdk-alpine FROM eclipse-temurin:19-jdk-alpine
ADD target/*-jar-with-dependencies.jar app.jar ADD target/*-jar-with-dependencies.jar app.jar
COPY src/main/resources/config.properties /data/configuration/config.properties
# Add the cron job # Add the cron job
# Calculate the map each day at 00:00 # Calculate the map each day at 00:00
......
...@@ -16,6 +16,11 @@ import map.builder.utilities.Config; ...@@ -16,6 +16,11 @@ import map.builder.utilities.Config;
import map.builder.utilities.ConnectedComponentGraph; import map.builder.utilities.ConnectedComponentGraph;
import map.builder.utilities.FileHandler; import map.builder.utilities.FileHandler;
import java.io.IOException;
import java.util.List;
import static map.builder.utilities.Config.*;
public class App { public class App {
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
System.out.println("Map builder started!"); System.out.println("Map builder started!");
...@@ -24,29 +29,7 @@ public class App { ...@@ -24,29 +29,7 @@ public class App {
RoadNetwork.Builder roadNetworkBuilder = RoadNetwork.newBuilder(); RoadNetwork.Builder roadNetworkBuilder = RoadNetwork.newBuilder();
OSMParser parser = new OSMParser(); OSMParser parser = new OSMParser();
// A small BBox inside Cottbus BoundingBox bbox = new BoundingBox(BOUNDING_BOX_MIN_LAT, BOUNDING_BOX_MIN_LON, BOUNDING_BOX_MAX_LAT, BOUNDING_BOX_MAX_LON);
/*
* float minLat = 51.765120241998865f;
* float minLon = 14.32669617537409f;
* float maxLat = 51.77116774623326f;
* float maxLon = 14.330334220133722f;
*/
// smaller BBox inside Cottbus, better for the debug tool
float minLat = 51.754092326645475f;
float minLon = 14.300615062713623f;
float maxLat = 51.766591637718435f;
float maxLon = 14.314413070678711f;
// BBox around Cottbus
/*
* float minLat = 51.714692361306376f;
* float minLon = 14.26197052001953f;
* float maxLat = 51.79290380494767f;
* float maxLon = 14.415779113769531f;
*/
BoundingBox bbox = new BoundingBox(minLat, minLon, maxLat, maxLon);
List<OSMJsonDto> restrictions = OSMFetcher.fetchTurnRestrictions(bbox); List<OSMJsonDto> restrictions = OSMFetcher.fetchTurnRestrictions(bbox);
List<OSMJsonDto> roads = OSMFetcher.fetchNodesAndWays(bbox); List<OSMJsonDto> roads = OSMFetcher.fetchNodesAndWays(bbox);
......
...@@ -41,7 +41,7 @@ public class OSMParser { ...@@ -41,7 +41,7 @@ public class OSMParser {
if (OSMJsonUtils.isWay(dto)) { if (OSMJsonUtils.isWay(dto)) {
OSMJsonWayDto wayDto = (OSMJsonWayDto) dto; OSMJsonWayDto wayDto = (OSMJsonWayDto) dto;
if (SegmentUtils.isSegmentDrivable(wayDto)) { if (SegmentUtils.isSegmentDrivable(wayDto)) {
SegmentUtils.markEndNodes(wayDto); SegmentUtils.noteNodeOccurrences(wayDto);
} }
} }
} }
...@@ -72,6 +72,11 @@ public class OSMParser { ...@@ -72,6 +72,11 @@ public class OSMParser {
} }
} }
/**
* Creates a segment based on the OSM data, however, it ignores the original geometry, if the segment has been split
* @param dto
* @param geometry
*/
private void createSegment(OSMJsonWayDto dto, ArrayList<Long> geometry) { private void createSegment(OSMJsonWayDto dto, ArrayList<Long> geometry) {
long osmId = dto.getOsmId(); long osmId = dto.getOsmId();
ArrayList<Coordinates> line = null; ArrayList<Coordinates> line = null;
......
...@@ -12,7 +12,8 @@ import static de.fuberlin.navigator.protos.map_builder.RoadCategory.*; ...@@ -12,7 +12,8 @@ import static de.fuberlin.navigator.protos.map_builder.RoadCategory.*;
public class SegmentUtils { public class SegmentUtils {
// this is a hash-map to allow us to check if a node is a start/end node in linear time // this is a hash-map to allow us to check if a node is a start/end node in linear time
private SegmentUtils() {} private SegmentUtils() {}
private static final HashMap<Long, Boolean> endNodes = new HashMap<>(); // associated each node ID to the segment IDs of the segments that have this node in their geometry
private static final HashMap<Long, Integer> nodeOccurrenceCount = new HashMap<>();
private static final List<String> drivableRoads = Arrays.asList( private static final List<String> drivableRoads = Arrays.asList(
"motorway", "motorway",
"trunk", "trunk",
...@@ -85,35 +86,39 @@ public class SegmentUtils { ...@@ -85,35 +86,39 @@ public class SegmentUtils {
return SegmentUtils.speedMap.get(roadCategory); return SegmentUtils.speedMap.get(roadCategory);
} }
public static void markEndNodes(OSMJsonWayDto element) { public static void noteNodeOccurrences(OSMJsonWayDto element) {
long[] nodes = element.getNodes(); long[] nodes = element.getNodes();
long segmentId = element.getOsmId();
long startNodeId = nodes[0]; for (long nodeId : nodes) {
long endNodeId = nodes[nodes.length - 1]; addNodeToNodeMap(nodeId, segmentId);
}
}
System.out.println("marking " + startNodeId + " and " + endNodeId); private static void addNodeToNodeMap(long nodeId, long segmentId) {
if (!nodeOccurrenceCount.containsKey(nodeId)) {
nodeOccurrenceCount.put(nodeId, 0);
}
SegmentUtils.endNodes.put(startNodeId, true); int nodeIdOccurrences = nodeOccurrenceCount.get(nodeId);
SegmentUtils.endNodes.put(endNodeId, true); nodeOccurrenceCount.put(nodeId, nodeIdOccurrences + 1);
} }
public static boolean isNodeAnEndNode(long osmId) { public static boolean isNodeContainedInMultipleSegments(long osmId) {
return SegmentUtils.endNodes.containsKey(osmId); return nodeOccurrenceCount.containsKey(osmId) && nodeOccurrenceCount.get(osmId) > 1;
} }
public static ArrayList<ArrayList<Long>> splitGeometry(long[] nodes) { public static ArrayList<ArrayList<Long>> splitGeometry(long[] nodes) {
ArrayList<ArrayList<Long>> geometry = new ArrayList<>(); ArrayList<ArrayList<Long>> geometry = new ArrayList<>();
int from = -1; int from = 0;
for (int i = 0; i < nodes.length; i++) { for (int i = 0; i < nodes.length; i++) {
long nodeId = nodes[i]; long nodeId = nodes[i];
if (isNodeAnEndNode(nodeId)) { // extract node IDs only if the node occurs multiple times and is NOT an end-node
if (from == -1) { if ((isNodeContainedInMultipleSegments(nodeId) && i != 0)
from = i; || i == (nodes.length - 1)) {
}
else {
// extract node ids // extract node ids
ArrayList<Long> geometryNodeIds = extractIdsFromTo(nodes, from, i); ArrayList<Long> geometryNodeIds = extractIdsFromTo(nodes, from, i);
geometry.add(geometryNodeIds); geometry.add(geometryNodeIds);
...@@ -125,7 +130,6 @@ public class SegmentUtils { ...@@ -125,7 +130,6 @@ public class SegmentUtils {
from = i; from = i;
} }
} }
}
return geometry; return geometry;
} }
......
...@@ -14,6 +14,14 @@ public class Config { ...@@ -14,6 +14,14 @@ public class Config {
public static String ROAD_NETWORK_OUTPUT_PATH = "roadnetwork.proto"; public static String ROAD_NETWORK_OUTPUT_PATH = "roadnetwork.proto";
/**
* Bounding box, default small box inside Cottbus
*/
public static float BOUNDING_BOX_MIN_LAT = 51.754092326645475f;
public static float BOUNDING_BOX_MIN_LON = 14.300615062713623f;
public static float BOUNDING_BOX_MAX_LAT = 51.766591637718435f;
public static float BOUNDING_BOX_MAX_LON = 14.314413070678711f;
public static void load() { public static void load() {
//The config is used for running the application in a Docker container //The config is used for running the application in a Docker container
String configFilePath = "/data/configuration/config.properties"; String configFilePath = "/data/configuration/config.properties";
...@@ -21,7 +29,12 @@ public class Config { ...@@ -21,7 +29,12 @@ public class Config {
try (FileInputStream is = new FileInputStream(configFilePath)){ try (FileInputStream is = new FileInputStream(configFilePath)){
props.load(is); props.load(is);
ROAD_NETWORK_OUTPUT_PATH = props.getProperty("ROAD_NETWORK_OUTPUT_PATH", ROAD_NETWORK_OUTPUT_PATH); ROAD_NETWORK_OUTPUT_PATH = props.getProperty("MAP_BUILDER_ROAD_NETWORK_OUTPUT_PATH", ROAD_NETWORK_OUTPUT_PATH);
BOUNDING_BOX_MIN_LAT = Float.parseFloat(props.getProperty("BOUNDING_BOX_MIN_LAT", String.valueOf(BOUNDING_BOX_MIN_LAT)));
BOUNDING_BOX_MIN_LON = Float.parseFloat(props.getProperty("BOUNDING_BOX_MIN_LON", String.valueOf(BOUNDING_BOX_MIN_LON)));
BOUNDING_BOX_MAX_LAT = Float.parseFloat(props.getProperty("BOUNDING_BOX_MAX_LAT", String.valueOf(BOUNDING_BOX_MAX_LAT)));
BOUNDING_BOX_MAX_LON = Float.parseFloat(props.getProperty("BOUNDING_BOX_MAX_LON", String.valueOf(BOUNDING_BOX_MAX_LON)));
System.out.println("Config loaded."); System.out.println("Config loaded.");
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
// Either way the Docker image was build wrong or this is not // Either way the Docker image was build wrong or this is not
......
# Standard config for Docker
ROAD_NETWORK_OUTPUT_PATH = /data/road_network/roadnetwork.proto
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment