Hello,
Probably a very basic beginner question. But I’m trying to create a new minimalistic routing profile for trains. First I did a copy of the CarFlagEncoder and adjusted it to simply stay on the railtracks. The code compiles successfull but whenever I send an API request I get the message: “Cannot find point …”.
When running graphhopper I have the following output in the messages:
2017-10-11 13:23:58,729 [main] INFO com.graphhopper.routing.subnetwork.PrepareRoutingSubnetworks - 37732 subnetworks found for rail, totalMB:976, usedMB:176
2017-10-11 13:23:58,761 [main] INFO com.graphhopper.routing.subnetwork.PrepareRoutingSubnetworks - optimize to remove subnetworks (37732), unvisited-dead-end-nodes (43238), maxEdges/node (4)
2017-10-11 13:23:58,763 [main] WARN com.graphhopper.storage.BaseGraph - More than a half of the network should be removed!? Nodes:39430, remove:37730
2017-10-11 13:23:58,815 [main] INFO com.graphhopper.reader.osm.GraphHopperOSM - edges: 45498, nodes 1700, there were 37732 subnetworks. removed them => 37730 less nodes
Could it be that for some reason most edges are removed and therefore no point can be found? Who is removing these edges and how can I debug this?
This is my code (very minimalistic approach):
package com.graphhopper.routing.util;
import com.graphhopper.reader.ReaderRelation;
import com.graphhopper.reader.ReaderWay;
import com.graphhopper.util.Helper;
import com.graphhopper.util.PMap;
import java.util.*;
public class RailFlagEncoder extends AbstractFlagEncoder {
protected final Map<String, Integer> trackTypeSpeedMap = new HashMap<String, Integer>();
public RailFlagEncoder() {
this(5, 5, 0);
}
public RailFlagEncoder(PMap properties) {
this((int) properties.getLong("speed_bits", 5),
properties.getDouble("speed_factor", 5),
properties.getBool("turn_costs", false) ? 1 : 0);
this.properties = properties;
}
public RailFlagEncoder(String propertiesStr) {
this(new PMap(propertiesStr));
}
public RailFlagEncoder(int speedBits, double speedFactor, int maxTurnCosts) {
super(speedBits, speedFactor, maxTurnCosts);
maxPossibleSpeed = 140;
init();
}
@Override
public int getVersion() {
return 1;
}
/**
* Define the place of the speedBits in the edge flags for car.
*/
@Override
public int defineWayBits(int index, int shift) {
shift = super.defineWayBits(index, shift);
speedEncoder = new EncodedDoubleValue("Speed", shift, speedBits, speedFactor, 60, maxPossibleSpeed);
return shift + speedEncoder.getBits();
}
protected double getSpeed(ReaderWay way) {
return 60;
}
@Override
public long acceptWay(ReaderWay way) {
String railwayValue = way.getTag("railway");
if ("rail".equals(railwayValue)) {
return acceptBit;
}
return 0;
}
@Override
public long handleRelationTags(ReaderRelation relation, long oldRelationFlags) {
return oldRelationFlags;
}
@Override
public long handleWayTags(ReaderWay way, long allowed, long relationFlags) {
return 1;
}
@Override
public String toString() {
return "rail";
}
}
Thanks!