use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class DecimalEncodedValueImplTest method testInfinityWithMinValue.
@Test
public void testInfinityWithMinValue() {
DecimalEncodedValueImpl testEnc = new DecimalEncodedValueImpl("test", 3, -6, 0.1, false, false, false, true);
testEnc.init(new EncodedValue.InitializerConfig());
IntsRef intsRef = new IntsRef(1);
testEnc.setDecimal(false, intsRef, Double.POSITIVE_INFINITY);
assertEquals(Double.POSITIVE_INFINITY, testEnc.getDecimal(false, intsRef), .1);
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class DecimalEncodedValueImplTest method testNegateReverse.
@Test
public void testNegateReverse() {
DecimalEncodedValueImpl testEnc = new DecimalEncodedValueImpl("test", 4, 0, 0.5, false, true, false, false);
testEnc.init(new EncodedValue.InitializerConfig());
IntsRef intsRef = new IntsRef(1);
testEnc.setDecimal(false, intsRef, 5.5);
assertEquals(5.5, testEnc.getDecimal(false, intsRef), .1);
assertEquals(-5.5, testEnc.getDecimal(true, intsRef), .1);
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class DecimalEncodedValueImplTest method setMaxToInfinity.
@Test
public void setMaxToInfinity() {
DecimalEncodedValueImpl testEnc = new DecimalEncodedValueImpl("test", 3, 0, 1, false, false, false, true);
testEnc.init(new EncodedValue.InitializerConfig());
IntsRef intsRef = new IntsRef(1);
assertEquals(0, testEnc.getDecimal(false, intsRef), .1);
testEnc.setDecimal(false, intsRef, Double.POSITIVE_INFINITY);
assertEquals(Double.POSITIVE_INFINITY, testEnc.getDecimal(false, intsRef), .1);
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class OSMReader method preprocessRelations.
/**
* This method is called for each relation during the first pass of {@link WaySegmentParser}
*/
protected void preprocessRelations(ReaderRelation relation) {
if (!relation.isMetaRelation() && relation.hasTag("type", "route")) {
// we keep track of all route relations, so they are available when we create edges later
for (ReaderRelation.Member member : relation.getMembers()) {
if (member.getType() != ReaderRelation.Member.WAY)
continue;
IntsRef oldRelationFlags = getRelFlagsMap(member.getRef());
IntsRef newRelationFlags = encodingManager.handleRelationTags(relation, oldRelationFlags);
putRelFlagsMap(member.getRef(), newRelationFlags);
}
}
if (relation.hasTag("type", "restriction")) {
// we keep the osm way ids that occur in turn relations, because this way we know for which GH edges
// we need to remember the associated osm way id. this is just an optimization that is supposed to save
// memory compared to simply storing the osm way ids in a long array where the array index is the GH edge
// id.
List<OSMTurnRelation> turnRelations = createTurnRelations(relation);
for (OSMTurnRelation turnRelation : turnRelations) {
osmWayIdSet.add(turnRelation.getOsmIdFrom());
osmWayIdSet.add(turnRelation.getOsmIdTo());
}
}
}
use of com.graphhopper.storage.IntsRef in project graphhopper by graphhopper.
the class GraphHopperTest method testSRTMWithTunnelInterpolation.
@ParameterizedTest
@ValueSource(booleans = { true, false })
public void testSRTMWithTunnelInterpolation(boolean withTunnelInterpolation) {
final String profile = "profile";
final String vehicle = "foot";
final String weighting = "shortest";
GraphHopper hopper = new GraphHopper().setGraphHopperLocation(GH_LOCATION).setOSMFile(MONACO).setProfiles(new Profile(profile).setVehicle(vehicle).setWeighting(weighting)).setStoreOnFlush(true);
if (!withTunnelInterpolation) {
hopper.getEncodingManagerBuilder().add(new OSMRoadEnvironmentParser() {
@Override
public IntsRef handleWayTags(IntsRef edgeFlags, ReaderWay readerWay, IntsRef relationFlags) {
// do not change RoadEnvironment to avoid triggering tunnel interpolation
return edgeFlags;
}
}).addIfAbsent(new DefaultFlagEncoderFactory(), vehicle);
}
hopper.setElevationProvider(new SRTMProvider(DIR));
hopper.importOrLoad();
GHPoint from = new GHPoint(43.7405647, 7.4299266);
GHPoint to = new GHPoint(43.7378990, 7.4279780);
// make sure we hit tower nodes, because all we really want is test the elevation interpolation
assertEquals(Snap.Position.TOWER, hopper.getLocationIndex().findClosest(from.lat, from.lon, EdgeFilter.ALL_EDGES).getSnappedPosition());
assertEquals(Snap.Position.TOWER, hopper.getLocationIndex().findClosest(to.lat, to.lon, EdgeFilter.ALL_EDGES).getSnappedPosition());
GHResponse rsp = hopper.route(new GHRequest(from, to).setProfile(profile));
ResponsePath res = rsp.getBest();
PointList pointList = res.getPoints();
assertEquals(6, pointList.size());
assertTrue(pointList.is3D());
if (withTunnelInterpolation) {
assertEquals(351.8, res.getDistance(), .1);
assertEquals(17, pointList.getEle(0), .1);
assertEquals(19.04, pointList.getEle(1), .1);
assertEquals(21.67, pointList.getEle(2), .1);
assertEquals(25.03, pointList.getEle(3), .1);
assertEquals(28.65, pointList.getEle(4), .1);
assertEquals(34.00, pointList.getEle(5), .1);
} else {
assertEquals(358.3, res.getDistance(), .1);
assertEquals(17.0, pointList.getEle(0), .1);
assertEquals(23.0, pointList.getEle(1), .1);
assertEquals(23.0, pointList.getEle(2), .1);
assertEquals(41.0, pointList.getEle(3), .1);
assertEquals(19.0, pointList.getEle(4), .1);
assertEquals(34.0, pointList.getEle(5), .1);
}
}
Aggregations