Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-06-08 10:55:32 +02:00
commit dc6f4f7ecb
3 changed files with 78 additions and 79 deletions

View file

@ -68,7 +68,7 @@ public class GPXUtilities {
@ColorInt @ColorInt
public int getColor(@ColorInt int defColor) { public int getColor(@ColorInt int defColor) {
if(extensions != null && extensions.containsKey("color")) { if (extensions != null && extensions.containsKey("color")) {
try { try {
return Color.parseColor(extensions.get("color").toUpperCase()); return Color.parseColor(extensions.get("color").toUpperCase());
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
@ -319,10 +319,10 @@ public class GPXUtilities {
points += numberOfPoints; points += numberOfPoints;
for (int j = 0; j < numberOfPoints; j++) { for (int j = 0; j < numberOfPoints; j++) {
WptPt point = s.get(j); WptPt point = s.get(j);
if(j == 0 && locationStart == null) { if (j == 0 && locationStart == null) {
locationStart = point; locationStart = point;
} }
if(j == numberOfPoints - 1) { if (j == numberOfPoints - 1) {
locationEnd = point; locationEnd = point;
} }
long time = point.time; long time = point.time;
@ -360,12 +360,12 @@ public class GPXUtilities {
if (point.ele > channelTop) { if (point.ele > channelTop) {
channelTop = point.ele; channelTop = point.ele;
if (!Double.isNaN(point.hdop)) { if (!Double.isNaN(point.hdop)) {
channelThres = Math.max(channelThres, 2.0*point.hdop); //Try empirical 2*hdop, may better serve very flat tracks, or high dop tracks channelThres = Math.max(channelThres, 2.0 * point.hdop); //Try empirical 2*hdop, may better serve very flat tracks, or high dop tracks
} }
} else if (point.ele < channelBottom) { } else if (point.ele < channelBottom) {
channelBottom = point.ele; channelBottom = point.ele;
if (!Double.isNaN(point.hdop)) { if (!Double.isNaN(point.hdop)) {
channelThres = Math.max(channelThres, 2.0*point.hdop); channelThres = Math.max(channelThres, 2.0 * point.hdop);
} }
} }
// Turnaround (breakout) detection // Turnaround (breakout) detection
@ -387,7 +387,7 @@ public class GPXUtilities {
channelThres = channelThresMin; channelThres = channelThresMin;
} }
// End detection without breakout // End detection without breakout
if (j == (numberOfPoints -1)) { if (j == (numberOfPoints - 1)) {
if ((channelTop - channelBase) >= channelThres) { if ((channelTop - channelBase) >= channelThres) {
diffElevationUp += channelTop - channelBase; diffElevationUp += channelTop - channelBase;
} }
@ -424,7 +424,7 @@ public class GPXUtilities {
} }
} }
} }
if(!isTimeSpecified()){ if (!isTimeSpecified()) {
startTime = filestamp; startTime = filestamp;
endTime = filestamp; endTime = filestamp;
} }
@ -441,13 +441,12 @@ public class GPXUtilities {
} }
// 5. Max speed and Average speed, if any. Average speed is NOT overall (effective) speed, but only calculated for "moving" periods. // 5. Max speed and Average speed, if any. Average speed is NOT overall (effective) speed, but only calculated for "moving" periods.
if(speedCount > 0) { if (speedCount > 0) {
if(timeMoving > 0){ if (timeMoving > 0) {
avgSpeed = (float)totalDistanceMoving / (float)timeMoving * 1000f; avgSpeed = (float) totalDistanceMoving / (float) timeMoving * 1000f;
} else { } else {
avgSpeed = (float)totalSpeedSum / (float)speedCount; avgSpeed = (float) totalSpeedSum / (float) speedCount;
} }
} else { } else {
avgSpeed = -1; avgSpeed = -1;
@ -487,14 +486,14 @@ public class GPXUtilities {
public WptPt get(int j) { public WptPt get(int j) {
final int ind = j + startPointInd; final int ind = j + startPointInd;
if(j == 0) { if (j == 0) {
if(startCoeff == 0) { if (startCoeff == 0) {
return segment.points.get(ind); return segment.points.get(ind);
} }
return approx(segment.points.get(ind), segment.points.get(ind + 1), startCoeff); return approx(segment.points.get(ind), segment.points.get(ind + 1), startCoeff);
} }
if(j == getNumberOfPoints() - 1) { if (j == getNumberOfPoints() - 1) {
if(endCoeff == 1) { if (endCoeff == 1) {
return segment.points.get(ind); return segment.points.get(ind);
} }
return approx(segment.points.get(ind - 1), segment.points.get(ind), endCoeff); return approx(segment.points.get(ind - 1), segment.points.get(ind), endCoeff);
@ -514,7 +513,7 @@ public class GPXUtilities {
} }
private double value(double vl, double vl2, double none, double cf) { private double value(double vl, double vl2, double none, double cf) {
if(vl == none || Double.isNaN(vl)) { if (vl == none || Double.isNaN(vl)) {
return vl2; return vl2;
} else if (vl2 == none || Double.isNaN(vl2)) { } else if (vl2 == none || Double.isNaN(vl2)) {
return vl; return vl;
@ -523,9 +522,9 @@ public class GPXUtilities {
} }
private long value(long vl, long vl2, long none, double cf) { private long value(long vl, long vl2, long none, double cf) {
if(vl == none) { if (vl == none) {
return vl2; return vl2;
} else if(vl2 == none) { } else if (vl2 == none) {
return vl; return vl;
} }
return vl + ((long) (cf * (vl2 - vl))); return vl + ((long) (cf * (vl2 - vl)));
@ -558,7 +557,7 @@ public class GPXUtilities {
@Override @Override
public double metric(WptPt p1, WptPt p2) { public double metric(WptPt p1, WptPt p2) {
if(p1.time != 0 && p2.time != 0) { if (p1.time != 0 && p2.time != 0) {
return (int) Math.abs((p2.time - p1.time) / 1000l); return (int) Math.abs((p2.time - p1.time) / 1000l);
} }
return 0; return 0;
@ -579,7 +578,7 @@ public class GPXUtilities {
double secondaryMetricEnd = 0; double secondaryMetricEnd = 0;
SplitSegment sp = new SplitSegment(segment, 0, 0); SplitSegment sp = new SplitSegment(segment, 0, 0);
double total = 0; double total = 0;
WptPt prev = null ; WptPt prev = null;
for (int k = 0; k < segment.points.size(); k++) { for (int k = 0; k < segment.points.size(); k++) {
WptPt point = segment.points.get(k); WptPt point = segment.points.get(k);
if (k > 0) { if (k > 0) {
@ -612,7 +611,7 @@ public class GPXUtilities {
private static List<GPXTrackAnalysis> convert(List<SplitSegment> splitSegments) { private static List<GPXTrackAnalysis> convert(List<SplitSegment> splitSegments) {
List<GPXTrackAnalysis> ls = new ArrayList<GPXUtilities.GPXTrackAnalysis>(); List<GPXTrackAnalysis> ls = new ArrayList<GPXUtilities.GPXTrackAnalysis>();
for(SplitSegment s : splitSegments) { for (SplitSegment s : splitSegments) {
GPXTrackAnalysis a = new GPXTrackAnalysis(); GPXTrackAnalysis a = new GPXTrackAnalysis();
a.prepareInformation(0, s); a.prepareInformation(0, s);
ls.add(a); ls.add(a);
@ -640,23 +639,23 @@ public class GPXUtilities {
GPXTrackAnalysis g = new GPXTrackAnalysis(); GPXTrackAnalysis g = new GPXTrackAnalysis();
g.wptPoints = points.size(); g.wptPoints = points.size();
List<SplitSegment> splitSegments = new ArrayList<GPXUtilities.SplitSegment>(); List<SplitSegment> splitSegments = new ArrayList<GPXUtilities.SplitSegment>();
for(int i = 0; i< tracks.size() ; i++){ for (int i = 0; i < tracks.size(); i++) {
Track subtrack = tracks.get(i); Track subtrack = tracks.get(i);
for(TrkSegment segment : subtrack.segments){ for (TrkSegment segment : subtrack.segments) {
g.totalTracks ++; g.totalTracks++;
if(segment.points.size() > 1) { if (segment.points.size() > 1) {
splitSegments.add(new SplitSegment(segment)); splitSegments.add(new SplitSegment(segment));
} }
} }
} }
g.prepareInformation(fileTimestamp, splitSegments.toArray(new SplitSegment[splitSegments.size()])); g.prepareInformation(fileTimestamp, splitSegments.toArray(new SplitSegment[splitSegments.size()]));
return g ; return g;
} }
public boolean hasRtePt() { public boolean hasRtePt() {
for(Route r : routes) { for (Route r : routes) {
if(r.points.size() > 0) { if (r.points.size() > 0) {
return true; return true;
} }
} }
@ -668,7 +667,7 @@ public class GPXUtilities {
} }
public boolean hasTrkPt() { public boolean hasTrkPt() {
for(Track t : tracks) { for (Track t : tracks) {
for (TrkSegment ts : t.segments) { for (TrkSegment ts : t.segments) {
if (ts.points.size() > 0) { if (ts.points.size() > 0) {
return true; return true;
@ -926,7 +925,7 @@ public class GPXUtilities {
} }
writeNotNullText(serializer, "name", p.name); writeNotNullText(serializer, "name", p.name);
writeNotNullText(serializer, "desc", p.desc); writeNotNullText(serializer, "desc", p.desc);
if(p.link != null) { if (p.link != null) {
serializer.startTag(null, "link"); serializer.startTag(null, "link");
serializer.attribute(null, "href", p.link); serializer.attribute(null, "href", p.link);
serializer.endTag(null, "link"); serializer.endTag(null, "link");
@ -1097,7 +1096,7 @@ public class GPXUtilities {
} else if (tag.equals("category")) { } else if (tag.equals("category")) {
((WptPt) parse).category = readText(parser, "category"); ((WptPt) parse).category = readText(parser, "category");
} else if (tag.equals("type")) { } else if (tag.equals("type")) {
if(((WptPt) parse).category == null) { if (((WptPt) parse).category == null) {
((WptPt) parse).category = readText(parser, "type"); ((WptPt) parse).category = readText(parser, "type");
} }
} else if (parser.getName().equals("ele")) { } else if (parser.getName().equals("ele")) {

View file

@ -539,7 +539,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
gpxImportHelper.handleFileImport(data, new File(data.getPath()).getName()); gpxImportHelper.handleFileImport(data, new File(data.getPath()).getName());
setIntent(null); setIntent(null);
} else if ("content".equals(scheme)) { } else if ("content".equals(scheme)) {
gpxImportHelper.handleContenImport(data); gpxImportHelper.handleContentImport(data);
setIntent(null); setIntent(null);
} else if ("google.navigation".equals(scheme) || "osmand.navigation".equals(scheme)) { } else if ("google.navigation".equals(scheme) || "osmand.navigation".equals(scheme)) {
parseNavigationIntent(data); parseNavigationIntent(data);

View file

@ -52,7 +52,7 @@ public class GpxImportHelper {
this.mapView = mapView; this.mapView = mapView;
} }
public void handleContenImport(final Uri contentUri) { public void handleContentImport(final Uri contentUri) {
final String name = getNameFromContentUri(contentUri); final String name = getNameFromContentUri(contentUri);
handleFileImport(contentUri, name); handleFileImport(contentUri, name);