Move utilitiy binary inspector from android

This commit is contained in:
Victor Shcherb 2018-06-16 11:19:21 +02:00
parent e7b10df10f
commit e2456709dc
4 changed files with 22 additions and 1318 deletions

View file

@ -12,11 +12,8 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import net.osmand.PlatformUtil;
import net.osmand.binary.BinaryInspector;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
import net.osmand.binary.RouteDataObject;
@ -24,8 +21,8 @@ import net.osmand.data.LatLon;
import net.osmand.osm.MapRenderingTypes;
import net.osmand.router.BinaryRoutePlanner.FinalRouteSegment;
import net.osmand.router.BinaryRoutePlanner.RouteSegment;
import net.osmand.router.RoutePlannerFrontEnd.RouteCalculationMode;
import net.osmand.router.GeneralRouter.GeneralRouterProfile;
import net.osmand.router.RoutePlannerFrontEnd.RouteCalculationMode;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
@ -36,6 +33,7 @@ public class RouteResultPreparation {
public static boolean PRINT_TO_CONSOLE_ROUTE_INFORMATION_TO_TEST = false;
public static String PRINT_TO_GPX_FILE = null;
private static final float TURN_DEGREE_MIN = 45;
public static final int SHIFT_ID = 6;
private Log log = PlatformUtil.getLog(RouteResultPreparation.class);
/**
* Helper method to prepare final result
@ -418,7 +416,7 @@ public class RouteResultPreparation {
additional.append("height = \"").append(Arrays.toString(res.getHeightValues())).append("\" ");
additional.append("description = \"").append(res.getDescription()).append("\" ");
println(MessageFormat.format("\t<segment id=\"{0}\" oid=\"{1}\" start=\"{2}\" end=\"{3}\" {4}/>",
(res.getObject().getId() >> (BinaryInspector.SHIFT_ID )) + "", res.getObject().getId() + "",
(res.getObject().getId() >> (SHIFT_ID )) + "", res.getObject().getId() + "",
res.getStartPointIndex() + "", res.getEndPointIndex() + "", additional.toString()));
int inc = res.getStartPointIndex() < res.getEndPointIndex() ? 1 : -1;
int indexnext = res.getStartPointIndex();
@ -451,7 +449,7 @@ public class RouteResultPreparation {
serializer.endTag("","slope");
}
serializer.startTag("","desc");
serializer.text((res.getObject().getId() >> (BinaryInspector.SHIFT_ID )) + " " + index);
serializer.text((res.getObject().getId() >> (SHIFT_ID )) + " " + index);
serializer.endTag("","desc");
lastHeight = h;
} else if(lastHeight != -180){

View file

@ -1,10 +1,19 @@
package net.osmand.router;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.RandomAccessFile;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import net.osmand.PlatformUtil;
import net.osmand.binary.BinaryInspector;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.data.LatLon;
import net.osmand.util.Algorithms;
@ -16,8 +25,8 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.*;
import java.util.*;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
/**
* Created by yurkiss on 04.03.16.
@ -96,7 +105,7 @@ public class RouteResultPreparationTest {
String turnLanes = turn +":" +lanes;
String name = routeSegments.get(prevSegment).getDescription();
long segmentId = routeSegments.get(prevSegment).getObject().getId() >> (BinaryInspector.SHIFT_ID );
long segmentId = routeSegments.get(prevSegment).getObject().getId() >> (RouteResultPreparation.SHIFT_ID );
String expectedResult = expectedResults.get(segmentId);
if (expectedResult != null) {
if(!Algorithms.objectEquals(expectedResult, turnLanes) &&
@ -113,7 +122,7 @@ public class RouteResultPreparationTest {
}
if (i < routeSegments.size()) {
reachedSegments.add(routeSegments.get(i).getObject().getId() >> (BinaryInspector.SHIFT_ID ));
reachedSegments.add(routeSegments.get(i).getObject().getId() >> (RouteResultPreparation.SHIFT_ID ));
}
}

View file

@ -6,22 +6,17 @@ import java.io.InputStreamReader;
import java.io.RandomAccessFile;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeSet;
import net.osmand.binary.BinaryInspector;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.data.LatLon;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@ -83,13 +78,13 @@ public class RouteTestingTest {
if (i == routeSegments.size() || routeSegments.get(i).getTurnType() != null) {
if (prevSegment >= 0) {
String name = routeSegments.get(prevSegment).getDescription();
long segmentId = routeSegments.get(prevSegment).getObject().getId() >> (BinaryInspector.SHIFT_ID);
long segmentId = routeSegments.get(prevSegment).getObject().getId() >> (RouteResultPreparation.SHIFT_ID);
System.out.println("segmentId: " + segmentId + " description: " + name);
}
prevSegment = i;
}
if (i < routeSegments.size()) {
reachedSegments.add(routeSegments.get(i).getObject().getId() >> (BinaryInspector.SHIFT_ID));
reachedSegments.add(routeSegments.get(i).getObject().getId() >> (RouteResultPreparation.SHIFT_ID));
}
}
Map<Long, String> expectedResults = te.getExpectedResults();