Merge pull request #484 from naoliv/master

Some misc fixes
This commit is contained in:
vshcherb 2013-08-01 15:22:38 -07:00
commit 7f4c2883cc
20 changed files with 53 additions and 77 deletions

View file

@ -545,7 +545,7 @@ public final class DescriptorProtos {
.computeStringSizeNoTag(element);
}
size += dataSize;
size += 1 * getDependencyList().size();
size += getDependencyList().size();
}
for (com.google.protobuf.DescriptorProtos.DescriptorProto element : getMessageTypeList()) {
size += com.google.protobuf.CodedOutputStream

View file

@ -72,6 +72,6 @@ public class GeoidAltitudeCorrection {
rf.read(b);
int ch1 = b[0] < 0 ? b[0] + 256 : b[0];
int ch2 = b[1] < 0 ? b[1] + 256 : b[1];
return (short)((ch1 << 8) + (ch2 << 0));
return (short)((ch1 << 8) + ch2);
}
}

View file

@ -263,7 +263,7 @@ public class TspAnt {
}
public static String tourToString(int tour[]) {
String t = new String();
String t = "";
for (int i : tour)
t = t + " " + i;
return t;

View file

@ -190,7 +190,7 @@ public class BinaryInspector {
ous.writeRawByte((v >>> 24) & 0xFF);
ous.writeRawByte((v >>> 16) & 0xFF);
ous.writeRawByte((v >>> 8) & 0xFF);
ous.writeRawByte((v >>> 0) & 0xFF);
ous.writeRawByte(v & 0xFF);
//written += 4;
}
@ -227,13 +227,13 @@ public class BinaryInspector {
String pattern = partsToExtractFrom.get(f);
boolean minus = true;
for (int i = 0; i < indexes[c].getIndexes().size(); i++) {
partsSet[c].add(new Float(i + 1f));
partsSet[c].add(i + 1f);
BinaryIndexPart part = indexes[c].getIndexes().get(i);
if(part instanceof MapIndex){
List<MapRoot> roots = ((MapIndex) part).getRoots();
int rsize = roots.size();
for(int j=0; j<rsize; j++){
partsSet[c].add(new Float((i+1f)+(j+1)/10f));
partsSet[c].add((i + 1f) + (j + 1) / 10f);
}
}
}
@ -280,7 +280,7 @@ public class BinaryInspector {
if (!partSet.contains(Float.valueOf(i + 1f))) {
continue;
}
list.add(new Float(i + 1f));
list.add(i + 1f);
BinaryIndexPart part = index.getIndexes().get(i);
String map;
@ -388,7 +388,7 @@ public class BinaryInspector {
}
String name = p.getName() == null ? "" : p.getName();
println(MessageFormat.format("{0} {1} data {3} - {2,number,#} bytes",
new Object[]{Integer.valueOf(i), partname, p.getLength(), name}));
new Object[]{i, partname, p.getLength(), name}));
if(p instanceof TransportIndex){
TransportIndex ti = ((TransportIndex) p);
int sh = (31 - BinaryMapIndexReader.TRANSPORT_STOP_ZOOM);
@ -449,7 +449,7 @@ public class BinaryInspector {
int type = cityType[j];
final List<City> cities = index.getCities(region, null, type);
print(MessageFormat.format("\t{0}, {1,number,#} group(s)", new Object[]{cityType_String[j], Integer.valueOf(cities.size())}));
print(MessageFormat.format("\t{0}, {1,number,#} group(s)", new Object[]{cityType_String[j], cities.size()}));
if (BinaryMapAddressReaderAdapter.CITY_TOWN_TYPE == type) {
if (!verbose.vstreetgroups && !verbose.vcities) {
println("");
@ -465,7 +465,7 @@ public class BinaryInspector {
int size = index.preloadStreets(c, null);
List<Street> streets = new ArrayList<Street>(c.getStreets());
print(MessageFormat.format("\t\t''{0}'' [{1,number,#}], {2,number,#} street(s) size {3,number,#} bytes",
new Object[]{c.getEnName(), Long.valueOf(c.getId()), Integer.valueOf(streets.size()), Integer.valueOf(size)}));
new Object[]{c.getEnName(), c.getId(), Integer.valueOf(streets.size()), Integer.valueOf(size)}));
if(!verbose.vstreets)
{
println("");
@ -483,13 +483,13 @@ public class BinaryInspector {
final List<Street> intersections = t.getIntersectedStreets();
println(MessageFormat.format("\t\t\t''{0}'' [{1,number,#}], {2,number,#} building(s), {3,number,#} intersections(s)",
new Object[]{t.getEnName(), Long.valueOf(t.getId()), Integer.valueOf(buildings.size()), Integer.valueOf(intersections.size())}));
new Object[]{t.getEnName(), t.getId(), Integer.valueOf(buildings.size()), Integer.valueOf(intersections.size())}));
if (buildings != null && !buildings.isEmpty() && verbose.vbuildings) {
println("\t\t\t\tBuildings:");
for (Building b : buildings) {
println(MessageFormat.format("\t\t\t\t{0} [{1,number,#}]",
new Object[]{b.getName(true), Long.valueOf(b.getId())}));
new Object[]{b.getName(true), b.getId()}));
}
}

View file

@ -2,6 +2,7 @@ package net.osmand.binary;
import java.io.IOException;
import java.util.Collections;
import net.osmand.NativeLibrary;
import net.osmand.bridge.ObfInspector;
@ -21,9 +22,7 @@ public class BinaryInspectorNative {
// test cases show info
NativeLibrary.loadAllLibs(null);
StringVector vector = new StringVector();
for(int i = 0; i < args.length; i++) {
vector.add(args[i]);
}
Collections.addAll(vector, args);
ObfInspector.inspector(vector);
}

View file

@ -339,7 +339,7 @@ public class BinaryMapIndexReader {
int ch2 = readByte();
int ch3 = readByte();
int ch4 = readByte();
return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + ch4);
}
@ -2013,7 +2013,7 @@ public class BinaryMapIndexReader {
if(pair == null) {
throw new NullPointerException("Type " + types[j] + "was not found");
}
b.append(pair.toSimpleString()+"("+types[j]+")");
b.append(pair.toSimpleString()).append("(").append(types[j]).append(")");
}
b.append("]");
if(obj.getAdditionalTypes() != null && obj.getAdditionalTypes().length > 0){
@ -2026,7 +2026,7 @@ public class BinaryMapIndexReader {
if(pair == null) {
throw new NullPointerException("Type " + obj.getAdditionalTypes()[j] + "was not found");
}
b.append(pair.toSimpleString()+"("+obj.getAdditionalTypes()[j]+")");
b.append(pair.toSimpleString()).append("(").append(obj.getAdditionalTypes()[j]).append(")");
}
b.append("]");
@ -2043,7 +2043,7 @@ public class BinaryMapIndexReader {
if(pair == null) {
throw new NullPointerException("Type " + keys[j] + "was not found");
}
b.append(pair.toSimpleString()+"("+keys[j]+")");
b.append(pair.toSimpleString()).append("(").append(keys[j]).append(")");
b.append(" - ").append(names.get(keys[j]));
}
b.append("]");

View file

@ -1329,7 +1329,7 @@ public final class OsmandOdb {
.computeStringSizeNoTag(element);
}
size += dataSize;
size += 1 * getSList().size();
size += getSList().size();
}
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
@ -1713,13 +1713,13 @@ public final class OsmandOdb {
.computeStringSizeNoTag(element);
}
size += dataSize;
size += 1 * getKeyList().size();
size += getKeyList().size();
}
{
int dataSize = 0;
dataSize = 4 * getValList().size();
size += dataSize;
size += 1 * getValList().size();
size += getValList().size();
}
for (net.osmand.binary.OsmandOdb.IndexedStringTable element : getSubtablesList()) {
size += com.google.protobuf.CodedOutputStream
@ -4965,7 +4965,7 @@ public final class OsmandOdb {
.computeBytesSizeNoTag(element);
}
size += dataSize;
size += 1 * getPolygonInnerCoordinatesList().size();
size += getPolygonInnerCoordinatesList().size();
}
if (hasAdditionalTypes()) {
size += com.google.protobuf.CodedOutputStream
@ -7393,7 +7393,7 @@ public final class OsmandOdb {
.computeInt32SizeNoTag(element);
}
size += dataSize;
size += 1 * getShiftToIndexList().size();
size += getShiftToIndexList().size();
}
{
int dataSize = 0;
@ -7402,7 +7402,7 @@ public final class OsmandOdb {
.computeInt32SizeNoTag(element);
}
size += dataSize;
size += 1 * getShiftToCityIndexList().size();
size += getShiftToCityIndexList().size();
}
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
@ -15798,7 +15798,7 @@ public final class OsmandOdb {
.computeStringSizeNoTag(element);
}
size += dataSize;
size += 1 * getSubcategoriesList().size();
size += getSubcategoriesList().size();
}
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
@ -16740,7 +16740,7 @@ public final class OsmandOdb {
.computeUInt32SizeNoTag(element);
}
size += dataSize;
size += 1 * getCategoriesList().size();
size += getCategoriesList().size();
}
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
@ -17651,7 +17651,7 @@ public final class OsmandOdb {
.computeUInt32SizeNoTag(element);
}
size += dataSize;
size += 1 * getCategoriesList().size();
size += getCategoriesList().size();
}
if (hasName()) {
size += com.google.protobuf.CodedOutputStream
@ -18265,7 +18265,7 @@ public final class OsmandOdb {
.computeSInt64SizeNoTag(element);
}
size += dataSize;
size += 1 * getRouteIdList().size();
size += getRouteIdList().size();
}
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;

View file

@ -146,9 +146,7 @@ public class DataTileManager<T> {
}
private long evTile(int tileX, int tileY){
long tx = tileX;
long ty = tileY;
return ((tx) << zoom) + ty;
return ((tileX) << zoom) + tileY;
}

View file

@ -18,9 +18,9 @@ public class QuadTree<T> {
bounds = new QuadRect(b.left, b.top, b.right, b.bottom);
children = new Node[4];
}
};
}
private float ratio;
private float ratio;
private int maxDepth;
private Node<T> root;

View file

@ -47,7 +47,7 @@ public class Base64 {
// store the octets
bits24 = (octetString[i++] & 0xFF) << 16;
bits24 |= (octetString[i++] & 0xFF) << 8;
bits24 |= (octetString[i++] & 0xFF) << 0;
bits24 |= (octetString[i++] & 0xFF);
bits6 = (bits24 & 0x00FC0000) >> 18;
out[outIndex++] = alphabet[bits6];

View file

@ -139,9 +139,9 @@ public class RenderingRule {
public StringBuilder toString(String indent, StringBuilder bls ) {
bls.append("RenderingRule [");
for(RenderingRuleProperty p : getProperties()){
bls.append(" " + p.getAttrName() + "= ");
bls.append(" ").append(p.getAttrName()).append("= ");
if(p.isString()){
bls.append("\"" + getStringPropertyValue(p.getAttrName()) + "\"");
bls.append("\"").append(getStringPropertyValue(p.getAttrName())).append("\"");
} else if(p.isFloat()){
bls.append(getFloatPropertyValue(p.getAttrName()));
} else if(p.isColor()){
@ -153,7 +153,7 @@ public class RenderingRule {
bls.append("]");
indent += " ";
for(RenderingRule rc : getIfElseChildren()){
bls.append("\n"+indent);
bls.append("\n").append(indent);
rc.toString(indent, bls);
}

View file

@ -544,10 +544,7 @@ public class BinaryRoutePlanner {
if(speed > ctx.getRouter().getMaxDefaultSpeed()) {
speed = ctx.getRouter().getMaxDefaultSpeed();
}
float distStartObstacles = obstaclesTime +
distOnRoadToPass / speed;
return distStartObstacles;
return obstaclesTime + distOnRoadToPass / speed;
}
private long calculateRoutePointId(final RouteDataObject road, int intervalId, boolean positive) {

View file

@ -207,8 +207,7 @@ public class BinaryRoutePlannerOld {
}
protected static double h(RoutingContext ctx, double distToFinalPoint, RouteSegment next) {
double result = distToFinalPoint / ctx.getRouter().getMaxDefaultSpeed();
return result;
return distToFinalPoint / ctx.getRouter().getMaxDefaultSpeed();
}
private static void println(String logMsg) {
@ -530,8 +529,7 @@ public class BinaryRoutePlannerOld {
// already in queue remove it
if (!graphSegments.remove(next)) {
// exist in different queue!
RouteSegment cpy = new RouteSegment(next.getRoad(), next.getSegmentStart());
next = cpy;
next = new RouteSegment(next.getRoad(), next.getSegmentStart());
}
}
next.distanceFromStart = distFromStart;

View file

@ -113,7 +113,7 @@ public class GeneralRouter extends VehicleRouter {
RouteTypeRule r = reg.quickGetEncodingRule(types[i]);
Float sp = highwaySpeed.get(r.getTag()+"$"+r.getValue());
if(sp != null){
if(sp.floatValue() > 0) {
if(sp > 0) {
accepted = true;
}
break;

View file

@ -336,7 +336,7 @@ public class NewGeneralRouter extends VehicleRouter {
boolean val = false;
if(defParams.containsKey(p)) {
RoutingParameter t = defParams.get(p);
val = t.type == RoutingParameterType.BOOLEAN && t.value != null && ((Boolean)t.value).booleanValue();
val = t.type == RoutingParameterType.BOOLEAN && t.value != null && (Boolean) t.value;
}
if(not && val){
parameterValue = false;

View file

@ -213,15 +213,9 @@ public class RouteResultPreparation {
double startLon = start.getLongitude();
double endLat = end.getLatitude();
double endLon = end.getLongitude();
StringBuilder add = new StringBuilder();
add.append("loadedTiles = \"").append(ctx.loadedTiles).append("\" ");
add.append("visitedSegments = \"").append(ctx.visitedSegments).append("\" ");
add.append("complete_distance = \"").append(completeDistance).append("\" ");
add.append("complete_time = \"").append(completeTime).append("\" ");
add.append("routing_time = \"").append(ctx.routingTime).append("\" ");
println(MessageFormat.format("<test regions=\"\" description=\"\" best_percent=\"\" vehicle=\"{4}\" \n"
println(MessageFormat.format("<test regions=\"\" description=\"\" best_percent=\"\" vehicle=\"{4}\" \n"
+ " start_lat=\"{0}\" start_lon=\"{1}\" target_lat=\"{2}\" target_lon=\"{3}\" {5} >", startLat
+ "", startLon + "", endLat + "", endLon + "", ctx.config.routerName, add.toString()));
+ "", startLon + "", endLat + "", endLon + "", ctx.config.routerName, "loadedTiles = \"" + ctx.loadedTiles + "\" " + "visitedSegments = \"" + ctx.visitedSegments + "\" " + "complete_distance = \"" + completeDistance + "\" " + "complete_time = \"" + completeTime + "\" " + "routing_time = \"" + ctx.routingTime + "\" "));
if (PRINT_TO_CONSOLE_ROUTE_INFORMATION_TO_TEST) {
for (RouteSegmentResult res : result) {
String name = res.getObject().getName();

View file

@ -144,8 +144,7 @@ public class TestRouting {
public static void info() {
println("Run router tests is console utility to test route calculation for osmand. It is also possible to calculate one route from -start to -end.");
println("\nUsage for run tests : runTestsSuite [-routingXmlPath=PATH] [-verbose] [-obfDir=PATH] [-start=lat;lon] [-end=lat;lon] [-testDir=PATH] {individualTestPath}");
return;
}
}
private static void println(String string) {

View file

@ -54,7 +54,7 @@ public class Algorithms {
int ch4 = in.read();
if ((ch1 | ch2 | ch3 | ch4) < 0)
throw new EOFException();
return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + ch4);
}
public static String capitalizeFirstLetterAndLowercase(String s) {
@ -162,7 +162,7 @@ public class Algorithms {
o = o << 8 | (0xff & bytes[offset + 3]);
o = o << 8 | (0xff & bytes[offset + 2]);
o = o << 8 | (0xff & bytes[offset + 1]);
o = o << 8 | (0xff & bytes[offset + 0]);
o = o << 8 | (0xff & bytes[offset]);
return o;
}
@ -191,7 +191,7 @@ public class Algorithms {
int o = (0xff & bytes[offset + 3]) << 24;
o |= (0xff & bytes[offset + 2]) << 16;
o |= (0xff & bytes[offset + 1]) << 8;
o |= (0xff & bytes[offset + 0]);
o |= (0xff & bytes[offset]);
return o;
}
@ -244,7 +244,7 @@ public class Algorithms {
public static int parseSmallIntFromBytes(byte[] bytes, int offset) {
int s = (0xff & bytes[offset + 1]) << 8;
s |= (0xff & bytes[offset + 0]);
s |= (0xff & bytes[offset]);
return s;
}

View file

@ -40,8 +40,7 @@ public class MapUtils {
private static double scalarMultiplication(double xA, double yA, double xB, double yB, double xC, double yC) {
// Scalar multiplication between (AB, AC)
double multiple = (xB - xA) * (xC - xA) + (yB- yA) * (yC -yA);
return multiple;
return (xB - xA) * (xC - xA) + (yB- yA) * (yC -yA);
}
public static double getOrthogonalDistance(double lat, double lon, double fromLat, double fromLon, double toLat, double toLon) {
@ -85,8 +84,7 @@ public class MapUtils {
//double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
//return R * c * 1000;
// simplyfy haversine:
double c = 2 * R * 1000 * Math.asin(Math.sqrt(a));
return c;
return (2 * R * 1000 * Math.asin(Math.sqrt(a)));
}
@ -171,8 +169,7 @@ public class MapUtils {
latitude = latitude < 0 ? - 89.9 : 89.9;
eval = Math.log( Math.tan(toRadians(latitude)) + 1/Math.cos(toRadians(latitude)) );
}
double result = (1 - eval / Math.PI) / 2 * getPowZoom(zoom);
return result;
return (1 - eval / Math.PI) / 2 * getPowZoom(zoom);
}
public static double getTileEllipsoidNumberY(float zoom, double latitude){
@ -238,8 +235,7 @@ public class MapUtils {
public static double getLatitudeFromTile(float zoom, double y){
int sign = y < 0 ? -1 : 1;
double result = Math.atan(sign*Math.sinh(Math.PI * (1 - 2 * y / getPowZoom(zoom)))) * 180d / Math.PI;
return result;
return Math.atan(sign*Math.sinh(Math.PI * (1 - 2 * y / getPowZoom(zoom)))) * 180d / Math.PI;
}
@ -270,11 +266,7 @@ public class MapUtils {
// System.out.println(buildShortOsmUrl(52.30103d, 4.862927d, 18)); // http://osm.org/go/0E4_JiVhs
// System.out.println(buildShortOsmUrl(40.59d, -115.213d, 9)); // http://osm.org/go/TelHTB--
public static String buildShortOsmUrl(double latitude, double longitude, int zoom){
StringBuilder str = new StringBuilder(10);
str.append(BASE_SHORT_OSM_URL);
str.append(createShortLocString(latitude, longitude, zoom));
str.append("?m");
return str.toString();
return BASE_SHORT_OSM_URL + createShortLocString(latitude, longitude, zoom) + "?m";
}
public static String createShortLocString(double latitude, double longitude, int zoom) {

View file

@ -477,8 +477,7 @@ public class OpeningHoursParser {
break;
}
if(Character.isWhitespace(ch) || ch == ','){
continue;
} else if (ch == '-') {
} else if (ch == '-') {
if(previousDay != -1){
startDay = previousDay;
} else if (previousMonth != -1) {