Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Andrew Davie 2016-04-02 22:07:21 +11:00
commit 66128c8c66
264 changed files with 1818 additions and 1511 deletions

View file

@ -2,6 +2,7 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test/java"/>
<classpathentry kind="src" path="test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="libs/bsh-core-2.0b4.jar"/>
<classpathentry kind="lib" path="libs/bzip2-20090327.jar"/>
@ -12,8 +13,8 @@
<classpathentry kind="lib" path="libs/tuprolog.jar"/>
<classpathentry kind="lib" path="libs/icu4j-49_1_patched.jar"/>
<classpathentry kind="lib" path="libs/gnu-trove-osmand.jar"/>
<classpathentry kind="lib" path="test-libs/gson-2.6.2.jar"/>
<classpathentry kind="lib" path="test-libs/hamcrest-core-1.3.jar"/>
<classpathentry kind="lib" path="test-libs/junit-4.12.jar"/>
<classpathentry kind="lib" path="test/libs/gson-2.6.2.jar"/>
<classpathentry kind="lib" path="test/libs/hamcrest-core-1.3.jar"/>
<classpathentry kind="lib" path="test/libs/junit-4.12.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -12,9 +12,10 @@
<property name="lib.absolute.dir" location="${lib.dir}" />
<property name="unit.dir" value="test/java" />
<property name="unit.absolute.dir" location="${unit.dir}" />
<property name="test.lib.dir" value="test-libs" />
<property name="test.lib.dir" value="test/libs" />
<property name="test.lib.absolute.dir" location="${test.lib.dir}" />
<property name="reports.tests" value="test-results" />
<property name="srctests.dir" value="test/java"/>
<property name="java.encoding" value="UTF-8" />
<path id="build.path">
@ -52,23 +53,27 @@
</classpath>
</javac>
<copy todir="${bin.absolute.dir}">
<fileset dir="test/java">
<include name="**/*.json" />
<fileset dir="test/resources">
<include name="**/*" />
</fileset>
</copy>
</target>
<target name="run-turn-lanes-test" >
<junit printsummary="yes" haltonfailure="yes" showoutput="yes">
<target name="junits" >
<junit printsummary="yes" showoutput="yes">
<classpath>
<pathelement path="bin"/>
<path refid="build.path"/>
<path refid="test-lib.path" />
</classpath>
<test name="net.osmand.router.RouteResultPreparationTest" haltonfailure="no" outfile="result">
<formatter type="plain"/>
<formatter type="xml"/>
</test>
<formatter type="xml" />
<batchtest fork="false" todir="${reports.tests}" >
<fileset dir="${srctests.dir}" >
<include name="**/*Test.java" />
<exclude name="**/AllTests.java" />
<exclude name="**/*Suite*.java" />
</fileset>
</batchtest>
</junit>
</target>

View file

@ -6,5 +6,5 @@ if [ ! -d bin ];
ant build
fi
echo "Starting tests..."
ant run-turn-lanes-test
ant junits
echo "Results can be found in result.txt file."

View file

@ -392,6 +392,10 @@ public class RouteResultPreparation {
if (st != 0) {
s += ";" + TurnType.valueOf(st, false).toXmlString();
}
int tt = TurnType.getTertiaryTurn(lns[h]);
if (tt != 0) {
s += ";" + TurnType.valueOf(tt, false).toXmlString();
}
}
s += "]";
@ -648,11 +652,13 @@ public class RouteResultPreparation {
boolean leftTurn = TurnType.isLeftTurn(mainTurnType);
int ind = leftTurn? 0 : lanesArray.length - 1;
final int tt = TurnType.getPrimaryTurn(lanesArray[ind]);
final int st = TurnType.getSecondaryTurn(lanesArray[ind]);
if (leftTurn) {
if (!TurnType.isLeftTurn(tt)) {
// This was just to make sure that there's no bad data.
TurnType.setPrimaryTurnAndReset(lanesArray, ind, TurnType.TL);
TurnType.setSecondaryTurn(lanesArray, ind, tt);
TurnType.setTertiaryTurn(lanesArray, ind, st);
lanesArray[ind] |= 1;
}
} else {
@ -660,6 +666,7 @@ public class RouteResultPreparation {
// This was just to make sure that there's no bad data.
TurnType.setPrimaryTurnAndReset(lanesArray, ind, TurnType.TR);
TurnType.setSecondaryTurn(lanesArray, ind, tt);
TurnType.setTertiaryTurn(lanesArray, ind, st);
lanesArray[ind] |= 1;
}
}
@ -1031,10 +1038,9 @@ public class RouteResultPreparation {
(TurnType.isRightTurn(calcTurnType) && TurnType.isRightTurn(turn)) ||
(TurnType.isLeftTurn(calcTurnType) && TurnType.isLeftTurn(turn))
) {
TurnType.setPrimaryTurnAndReset(lanes, i, turn);
TurnType.setSecondaryTurn(lanes, i, primary);
TurnType.setPrimaryTurnShiftOthers(lanes, i, turn);
} else {
TurnType.setSecondaryTurn(lanes, i, turn);
TurnType.setSecondaryTurnShiftOthers(lanes, i, turn);
}
break; // Move on to the next lane
}
@ -1055,12 +1061,18 @@ public class RouteResultPreparation {
if (TurnType.getSecondaryTurn(oLanes[i]) != 0) {
possibleTurns.add(TurnType.getSecondaryTurn(oLanes[i]));
}
if (TurnType.getTertiaryTurn(oLanes[i]) != 0) {
possibleTurns.add(TurnType.getTertiaryTurn(oLanes[i]));
}
} else {
TIntArrayList laneTurns = new TIntArrayList();
laneTurns.add(TurnType.getPrimaryTurn(oLanes[i]));
if (TurnType.getSecondaryTurn(oLanes[i]) != 0) {
laneTurns.add(TurnType.getSecondaryTurn(oLanes[i]));
}
if (TurnType.getTertiaryTurn(oLanes[i]) != 0) {
laneTurns.add(TurnType.getTertiaryTurn(oLanes[i]));
}
possibleTurns.retainAll(laneTurns);
if (possibleTurns.isEmpty()) {
// No common turns, so can't determine anything.
@ -1076,6 +1088,9 @@ public class RouteResultPreparation {
if (TurnType.getSecondaryTurn(oLanes[i]) != 0) {
possibleTurns.remove((Integer) TurnType.getSecondaryTurn(oLanes[i]));
}
if (TurnType.getTertiaryTurn(oLanes[i]) != 0) {
possibleTurns.remove((Integer) TurnType.getTertiaryTurn(oLanes[i]));
}
}
}

View file

@ -158,6 +158,7 @@ public class TurnType {
// 0 bit - 0/1 - to use or not
// 1-5 bits - additional turn info
// 6-10 bits - secondary turn
// 11-15 bits - tertiary turn
public void setLanes(int[] lanes) {
this.lanes = lanes;
}
@ -182,6 +183,32 @@ public class TurnType {
// Get the primary turn modifier for the lane
return (laneValue >> 5);
}
public static void setPrimaryTurnShiftOthers(int[] lanes, int lane, int turnType) {
int pt = getPrimaryTurn(lanes[lane]);
int st = getSecondaryTurn(lanes[lane]);
//int tt = getTertiaryTurn(lanes[lane]);
setPrimaryTurnAndReset(lanes, lane, turnType);
setSecondaryTurn(lanes, lane, pt);
setTertiaryTurn(lanes, lane, st);
}
public static void setSecondaryTurnShiftOthers(int[] lanes, int lane, int turnType) {
int st = getSecondaryTurn(lanes[lane]);
//int tt = getTertiaryTurn(lanes[lane]);
setSecondaryTurn(lanes, lane, turnType);
setTertiaryTurn(lanes, lane, st);
}
public static void setTertiaryTurn(int[] lanes, int lane, int turnType) {
lanes[lane] &= ~(15 << 10);
lanes[lane] |= (turnType << 10);
}
public static int getTertiaryTurn(int laneValue) {
// Get the primary turn modifier for the lane
return (laneValue >> 10);
}
public int[] getLanes() {
@ -241,11 +268,11 @@ public class TurnType {
}
public static boolean isLeftTurn(int type) {
return type == TL || type == TSHL || type == TSLL || type == TRU;
return type == TL || type == TSHL || type == TSLL || type == TU || type == KL;
}
public static boolean isRightTurn(int type) {
return type == TR || type == TSHR || type == TSLR || type == TU;
return type == TR || type == TSHR || type == TSLR || type == TRU || type == KR;
}
public static boolean isSlightTurn(int type) {

1
OsmAnd-java/test-results/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.xml

View file

@ -2,9 +2,11 @@ package net.osmand.router;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import net.osmand.PlatformUtil;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.data.LatLon;
import org.apache.commons.logging.Log;
import org.junit.Assert;
import org.junit.BeforeClass;
@ -63,10 +65,8 @@ public class RouteResultPreparationTest {
@Parameterized.Parameters(name = "{index}: {0}")
public static Collection<Object[]> data() throws IOException {
String fileName = "test_turn_lanes.json";
Reader reader = new FileReader(fileName);
String fileName = "/test_turn_lanes.json";
Reader reader = new InputStreamReader(RouteResultPreparationTest.class.getResourceAsStream(fileName));
Gson gson = new GsonBuilder().setPrettyPrinting().create();
TestEntry[] testEntries = gson.fromJson(reader, TestEntry[].class);
ArrayList<Object[]> twoDArray = new ArrayList<Object[]>();
@ -101,8 +101,6 @@ public class RouteResultPreparationTest {
String expectedResult = expectedResults.get(segmentId);
if (expectedResult != null) {
Assert.assertEquals("Segment " + segmentId, expectedResult, lanes);
} else {
//TODO: action if needed when expectedResults is null
}
System.out.println("segmentId: " + segmentId + " description: " + name);
@ -125,7 +123,6 @@ public class RouteResultPreparationTest {
private String getLanesString(RouteSegmentResult segment) {
String turn = segment.getTurnType().toString();
final int[] lns = segment.getTurnType().getLanes();
if (lns != null) {
String s = "";
@ -145,10 +142,13 @@ public class RouteResultPreparationTest {
if (st != 0) {
s += ";" + TurnType.valueOf(st, false).toXmlString();
}
int tt = TurnType.getTertiaryTurn(lns[h]);
if (tt != 0) {
s += ";" + TurnType.valueOf(tt, false).toXmlString();
}
}
s += "";
turn += s;
return s;
}
return null;

View file

@ -202,6 +202,20 @@
"expectedResults": {
"27611": "+C;TL, +C, TR"
}
},
{
"testName": "10.Ringweg Oost u-turn",
"startPoint": {
"latitude": 45.69722318654911,
"longitude": 35.62708438868003
},
"endPoint": {
"latitude": 45.69793506976422,
"longitude": 35.624509468025735
},
"expectedResults": {
"14418": "TL, +TL, C, C, TR"
}
}
]

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Some files were not shown because too many files have changed in this diff Show more