Merge pull request #9866 from osmandapp/9844_oneway_is_not_respected
Issue 9844 oneway is not respected
This commit is contained in:
commit
5a880e3956
2 changed files with 38 additions and 28 deletions
|
@ -289,7 +289,8 @@ public class RoutingContext {
|
||||||
if(excludeNotAllowed != null && !excludeNotAllowed.contains(ro.getId())) {
|
if(excludeNotAllowed != null && !excludeNotAllowed.contains(ro.getId())) {
|
||||||
ts.add(ro);
|
ts.add(ro);
|
||||||
}
|
}
|
||||||
} else if(excludeNotAllowed != null && ro.getId() > 0){
|
}
|
||||||
|
if(excludeNotAllowed != null && ro.getId() > 0){
|
||||||
excludeNotAllowed.add(ro.getId());
|
excludeNotAllowed.add(ro.getId());
|
||||||
if(ts.excludedIds == null ){
|
if(ts.excludedIds == null ){
|
||||||
ts.excludedIds = new TLongHashSet();
|
ts.excludedIds = new TLongHashSet();
|
||||||
|
|
|
@ -15,6 +15,7 @@ import java.util.TreeSet;
|
||||||
|
|
||||||
import net.osmand.binary.BinaryMapIndexReader;
|
import net.osmand.binary.BinaryMapIndexReader;
|
||||||
|
|
||||||
|
import net.osmand.data.LatLon;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -29,42 +30,52 @@ public class RouteTestingTest {
|
||||||
private TestEntry te;
|
private TestEntry te;
|
||||||
|
|
||||||
|
|
||||||
public RouteTestingTest(String name, TestEntry te) {
|
public RouteTestingTest(String name, TestEntry te) {
|
||||||
this.te = te;
|
this.te = te;
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
RouteResultPreparation.PRINT_TO_CONSOLE_ROUTE_INFORMATION_TO_TEST = true;
|
RouteResultPreparation.PRINT_TO_CONSOLE_ROUTE_INFORMATION_TO_TEST = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameters(name = "{index}: {0}")
|
@Parameterized.Parameters(name = "{index}: {0}")
|
||||||
public static Iterable<Object[]> data() throws IOException {
|
public static Iterable<Object[]> data() throws IOException {
|
||||||
String fileName = "/test_routing.json";
|
String fileName = "/test_routing.json";
|
||||||
Reader reader = new InputStreamReader(RouteTestingTest.class.getResourceAsStream(fileName));
|
Reader reader = new InputStreamReader(RouteTestingTest.class.getResourceAsStream(fileName));
|
||||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||||
TestEntry[] testEntries = gson.fromJson(reader, TestEntry[].class);
|
TestEntry[] testEntries = gson.fromJson(reader, TestEntry[].class);
|
||||||
ArrayList<Object[]> arrayList = new ArrayList<>();
|
ArrayList<Object[]> arrayList = new ArrayList<>();
|
||||||
for(TestEntry te : testEntries) {
|
for (TestEntry te : testEntries) {
|
||||||
if(te.isIgnore()) {
|
if (te.isIgnore()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
arrayList.add(new Object[] {te.getTestName(), te});
|
arrayList.add(new Object[]{te.getTestName(), te});
|
||||||
}
|
}
|
||||||
reader.close();
|
reader.close();
|
||||||
return arrayList;
|
return arrayList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRouting() throws Exception {
|
public void testRouting() throws Exception {
|
||||||
String fl = "src/test/resources/Routing_test.obf";
|
String fl = "src/test/resources/Routing_test.obf";
|
||||||
RandomAccessFile raf = new RandomAccessFile(fl, "r");
|
RandomAccessFile raf = new RandomAccessFile(fl, "r");
|
||||||
RoutePlannerFrontEnd fe = new RoutePlannerFrontEnd();
|
RoutePlannerFrontEnd fe = new RoutePlannerFrontEnd();
|
||||||
|
|
||||||
BinaryMapIndexReader[] binaryMapIndexReaders = { new BinaryMapIndexReader(raf, new File(fl)) };
|
BinaryMapIndexReader[] binaryMapIndexReaders;// = { new BinaryMapIndexReader(raf, new File(fl)) };
|
||||||
RoutingConfiguration.Builder builder = RoutingConfiguration.getDefault();
|
RoutingConfiguration.Builder builder = RoutingConfiguration.getDefault();
|
||||||
Map<String, String> params = te.getParams();
|
Map<String, String> params = te.getParams();
|
||||||
|
if (params.containsKey("map")) {
|
||||||
|
String fl1 = "src/test/resources/" + params.get("map");
|
||||||
|
RandomAccessFile raf1 = new RandomAccessFile(fl1, "r");
|
||||||
|
binaryMapIndexReaders = new BinaryMapIndexReader[]{
|
||||||
|
new BinaryMapIndexReader(raf1, new File(fl1)),
|
||||||
|
new BinaryMapIndexReader(raf, new File(fl))
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
binaryMapIndexReaders = new BinaryMapIndexReader[]{new BinaryMapIndexReader(raf, new File(fl))};
|
||||||
|
}
|
||||||
RoutingConfiguration config = builder.build(params.containsKey("vehicle") ? params.get("vehicle") : "car",
|
RoutingConfiguration config = builder.build(params.containsKey("vehicle") ? params.get("vehicle") : "car",
|
||||||
RoutingConfiguration.DEFAULT_MEMORY_LIMIT * 3, params);
|
RoutingConfiguration.DEFAULT_MEMORY_LIMIT * 3, params);
|
||||||
RoutingContext ctx = fe.buildRoutingContext(config, null, binaryMapIndexReaders,
|
RoutingContext ctx = fe.buildRoutingContext(config, null, binaryMapIndexReaders,
|
||||||
|
@ -102,6 +113,4 @@ public class RouteTestingTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue