Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
dc6f4f7ecb
3 changed files with 78 additions and 79 deletions
|
@ -68,7 +68,7 @@ public class GPXUtilities {
|
|||
|
||||
@ColorInt
|
||||
public int getColor(@ColorInt int defColor) {
|
||||
if(extensions != null && extensions.containsKey("color")) {
|
||||
if (extensions != null && extensions.containsKey("color")) {
|
||||
try {
|
||||
return Color.parseColor(extensions.get("color").toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
@ -105,8 +105,8 @@ public class GPXUtilities {
|
|||
public double speed = 0;
|
||||
public double hdop = Double.NaN;
|
||||
public boolean deleted = false;
|
||||
public int colourARGB = 0; // point colour (used for altitude/speed colouring)
|
||||
public double distance = 0.0; // cumulative distance, if in a track
|
||||
public int colourARGB = 0; // point colour (used for altitude/speed colouring)
|
||||
public double distance = 0.0; // cumulative distance, if in a track
|
||||
|
||||
public WptPt() {
|
||||
}
|
||||
|
@ -319,10 +319,10 @@ public class GPXUtilities {
|
|||
points += numberOfPoints;
|
||||
for (int j = 0; j < numberOfPoints; j++) {
|
||||
WptPt point = s.get(j);
|
||||
if(j == 0 && locationStart == null) {
|
||||
if (j == 0 && locationStart == null) {
|
||||
locationStart = point;
|
||||
}
|
||||
if(j == numberOfPoints - 1) {
|
||||
if (j == numberOfPoints - 1) {
|
||||
locationEnd = point;
|
||||
}
|
||||
long time = point.time;
|
||||
|
@ -360,12 +360,12 @@ public class GPXUtilities {
|
|||
if (point.ele > channelTop) {
|
||||
channelTop = point.ele;
|
||||
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) {
|
||||
channelBottom = point.ele;
|
||||
if (!Double.isNaN(point.hdop)) {
|
||||
channelThres = Math.max(channelThres, 2.0*point.hdop);
|
||||
channelThres = Math.max(channelThres, 2.0 * point.hdop);
|
||||
}
|
||||
}
|
||||
// Turnaround (breakout) detection
|
||||
|
@ -387,7 +387,7 @@ public class GPXUtilities {
|
|||
channelThres = channelThresMin;
|
||||
}
|
||||
// End detection without breakout
|
||||
if (j == (numberOfPoints -1)) {
|
||||
if (j == (numberOfPoints - 1)) {
|
||||
if ((channelTop - channelBase) >= channelThres) {
|
||||
diffElevationUp += channelTop - channelBase;
|
||||
}
|
||||
|
@ -424,7 +424,7 @@ public class GPXUtilities {
|
|||
}
|
||||
}
|
||||
}
|
||||
if(!isTimeSpecified()){
|
||||
if (!isTimeSpecified()) {
|
||||
startTime = filestamp;
|
||||
endTime = filestamp;
|
||||
}
|
||||
|
@ -437,17 +437,16 @@ public class GPXUtilities {
|
|||
// 3. Time moving, if any
|
||||
// 4. Elevation, eleUp, eleDown, if recorded
|
||||
if (elevationPoints > 0) {
|
||||
avgElevation = totalElevation / elevationPoints;
|
||||
avgElevation = totalElevation / elevationPoints;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 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(timeMoving > 0){
|
||||
avgSpeed = (float)totalDistanceMoving / (float)timeMoving * 1000f;
|
||||
if (speedCount > 0) {
|
||||
if (timeMoving > 0) {
|
||||
avgSpeed = (float) totalDistanceMoving / (float) timeMoving * 1000f;
|
||||
} else {
|
||||
avgSpeed = (float)totalSpeedSum / (float)speedCount;
|
||||
avgSpeed = (float) totalSpeedSum / (float) speedCount;
|
||||
}
|
||||
} else {
|
||||
avgSpeed = -1;
|
||||
|
@ -458,7 +457,7 @@ public class GPXUtilities {
|
|||
}
|
||||
|
||||
private static class SplitSegment {
|
||||
TrkSegment segment;
|
||||
TrkSegment segment;
|
||||
double startCoeff = 0;
|
||||
int startPointInd;
|
||||
double endCoeff = 0;
|
||||
|
@ -487,14 +486,14 @@ public class GPXUtilities {
|
|||
|
||||
public WptPt get(int j) {
|
||||
final int ind = j + startPointInd;
|
||||
if(j == 0) {
|
||||
if(startCoeff == 0) {
|
||||
if (j == 0) {
|
||||
if (startCoeff == 0) {
|
||||
return segment.points.get(ind);
|
||||
}
|
||||
return approx(segment.points.get(ind), segment.points.get(ind + 1), startCoeff);
|
||||
}
|
||||
if(j == getNumberOfPoints() - 1) {
|
||||
if(endCoeff == 1) {
|
||||
if (j == getNumberOfPoints() - 1) {
|
||||
if (endCoeff == 1) {
|
||||
return segment.points.get(ind);
|
||||
}
|
||||
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) {
|
||||
if(vl == none || Double.isNaN(vl)) {
|
||||
if (vl == none || Double.isNaN(vl)) {
|
||||
return vl2;
|
||||
} else if (vl2 == none || Double.isNaN(vl2)) {
|
||||
return vl;
|
||||
|
@ -523,9 +522,9 @@ public class GPXUtilities {
|
|||
}
|
||||
|
||||
private long value(long vl, long vl2, long none, double cf) {
|
||||
if(vl == none) {
|
||||
if (vl == none) {
|
||||
return vl2;
|
||||
} else if(vl2 == none) {
|
||||
} else if (vl2 == none) {
|
||||
return vl;
|
||||
}
|
||||
return vl + ((long) (cf * (vl2 - vl)));
|
||||
|
@ -558,7 +557,7 @@ public class GPXUtilities {
|
|||
|
||||
@Override
|
||||
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 0;
|
||||
|
@ -579,7 +578,7 @@ public class GPXUtilities {
|
|||
double secondaryMetricEnd = 0;
|
||||
SplitSegment sp = new SplitSegment(segment, 0, 0);
|
||||
double total = 0;
|
||||
WptPt prev = null ;
|
||||
WptPt prev = null;
|
||||
for (int k = 0; k < segment.points.size(); k++) {
|
||||
WptPt point = segment.points.get(k);
|
||||
if (k > 0) {
|
||||
|
@ -612,7 +611,7 @@ public class GPXUtilities {
|
|||
|
||||
private static List<GPXTrackAnalysis> convert(List<SplitSegment> splitSegments) {
|
||||
List<GPXTrackAnalysis> ls = new ArrayList<GPXUtilities.GPXTrackAnalysis>();
|
||||
for(SplitSegment s : splitSegments) {
|
||||
for (SplitSegment s : splitSegments) {
|
||||
GPXTrackAnalysis a = new GPXTrackAnalysis();
|
||||
a.prepareInformation(0, s);
|
||||
ls.add(a);
|
||||
|
@ -640,23 +639,23 @@ public class GPXUtilities {
|
|||
GPXTrackAnalysis g = new GPXTrackAnalysis();
|
||||
g.wptPoints = points.size();
|
||||
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);
|
||||
for(TrkSegment segment : subtrack.segments){
|
||||
g.totalTracks ++;
|
||||
if(segment.points.size() > 1) {
|
||||
for (TrkSegment segment : subtrack.segments) {
|
||||
g.totalTracks++;
|
||||
if (segment.points.size() > 1) {
|
||||
splitSegments.add(new SplitSegment(segment));
|
||||
}
|
||||
}
|
||||
}
|
||||
g.prepareInformation(fileTimestamp, splitSegments.toArray(new SplitSegment[splitSegments.size()]));
|
||||
return g ;
|
||||
return g;
|
||||
}
|
||||
|
||||
|
||||
public boolean hasRtePt() {
|
||||
for(Route r : routes) {
|
||||
if(r.points.size() > 0) {
|
||||
for (Route r : routes) {
|
||||
if (r.points.size() > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -668,7 +667,7 @@ public class GPXUtilities {
|
|||
}
|
||||
|
||||
public boolean hasTrkPt() {
|
||||
for(Track t : tracks) {
|
||||
for (Track t : tracks) {
|
||||
for (TrkSegment ts : t.segments) {
|
||||
if (ts.points.size() > 0) {
|
||||
return true;
|
||||
|
@ -926,7 +925,7 @@ public class GPXUtilities {
|
|||
}
|
||||
writeNotNullText(serializer, "name", p.name);
|
||||
writeNotNullText(serializer, "desc", p.desc);
|
||||
if(p.link != null) {
|
||||
if (p.link != null) {
|
||||
serializer.startTag(null, "link");
|
||||
serializer.attribute(null, "href", p.link);
|
||||
serializer.endTag(null, "link");
|
||||
|
@ -1097,7 +1096,7 @@ public class GPXUtilities {
|
|||
} else if (tag.equals("category")) {
|
||||
((WptPt) parse).category = readText(parser, "category");
|
||||
} else if (tag.equals("type")) {
|
||||
if(((WptPt) parse).category == null) {
|
||||
if (((WptPt) parse).category == null) {
|
||||
((WptPt) parse).category = readText(parser, "type");
|
||||
}
|
||||
} else if (parser.getName().equals("ele")) {
|
||||
|
|
|
@ -539,7 +539,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
gpxImportHelper.handleFileImport(data, new File(data.getPath()).getName());
|
||||
setIntent(null);
|
||||
} else if ("content".equals(scheme)) {
|
||||
gpxImportHelper.handleContenImport(data);
|
||||
gpxImportHelper.handleContentImport(data);
|
||||
setIntent(null);
|
||||
} else if ("google.navigation".equals(scheme) || "osmand.navigation".equals(scheme)) {
|
||||
parseNavigationIntent(data);
|
||||
|
|
|
@ -52,7 +52,7 @@ public class GpxImportHelper {
|
|||
this.mapView = mapView;
|
||||
}
|
||||
|
||||
public void handleContenImport(final Uri contentUri) {
|
||||
public void handleContentImport(final Uri contentUri) {
|
||||
final String name = getNameFromContentUri(contentUri);
|
||||
|
||||
handleFileImport(contentUri, name);
|
||||
|
|
Loading…
Reference in a new issue