Change classpath for GPX Utilitites and basic refactoring
This commit is contained in:
parent
7dd22ddd94
commit
a196c4b11c
80 changed files with 496 additions and 436 deletions
|
@ -1,28 +1,7 @@
|
|||
|
||||
package net.osmand.plus;
|
||||
package net.osmand;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.LocationPoint;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.routing.RouteCalculationResult;
|
||||
import net.osmand.plus.views.Renderable;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.xmlpull.v1.XmlSerializer;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
|
@ -54,7 +33,13 @@ import java.util.Set;
|
|||
import java.util.Stack;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import static net.osmand.binary.RouteDataObject.HEIGHT_UNDEFINED;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import org.xmlpull.v1.XmlSerializer;
|
||||
|
||||
public class GPXUtilities {
|
||||
public final static Log log = PlatformUtil.getLog(GPXUtilities.class);
|
||||
|
@ -67,6 +52,46 @@ public class GPXUtilities {
|
|||
private final static NumberFormat decimalFormat = new DecimalFormat("#.###", new DecimalFormatSymbols(
|
||||
new Locale("EN", "US")));
|
||||
|
||||
public enum GPXColor {
|
||||
BLACK(0xFF000000),
|
||||
DARKGRAY(0xFF444444),
|
||||
GRAY(0xFF888888),
|
||||
LIGHTGRAY(0xFFCCCCCC),
|
||||
WHITE(0xFFFFFFFF),
|
||||
RED(0xFFFF0000),
|
||||
GREEN(0xFF00FF00),
|
||||
BLUE(0xFF0000FF),
|
||||
YELLOW(0xFFFFFF00),
|
||||
CYAN(0xFF00FFFF),
|
||||
MAGENTA(0xFFFF00FF),
|
||||
AQUA(0xFF00FFFF),
|
||||
FUCHSIA(0xFFFF00FF),
|
||||
DARKGREY(0xFF444444),
|
||||
GREY(0xFF888888),
|
||||
LIGHTGREY(0xFFCCCCCC),
|
||||
LIME(0xFF00FF00),
|
||||
MAROON(0xFF800000),
|
||||
NAVY(0xFF000080),
|
||||
OLIVE(0xFF808000),
|
||||
PURPLE(0xFF800080),
|
||||
SILVER(0xFFC0C0C0),
|
||||
TEAL(0xFF008080);
|
||||
|
||||
int color;
|
||||
GPXColor(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public static GPXColor getColorFromName(String s) {
|
||||
for(GPXColor c : values()) {
|
||||
if(c.name().equalsIgnoreCase(s)) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class GPXExtensions {
|
||||
Map<String, String> extensions = null;
|
||||
|
||||
|
@ -77,8 +102,7 @@ public class GPXUtilities {
|
|||
return extensions;
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
public int getColor(@ColorInt int defColor) {
|
||||
public int getColor(int defColor) {
|
||||
String clrValue = null;
|
||||
if (extensions != null) {
|
||||
clrValue = extensions.get("color");
|
||||
|
@ -88,12 +112,14 @@ public class GPXUtilities {
|
|||
if (clrValue == null) {
|
||||
clrValue = extensions.get("displaycolor");
|
||||
}
|
||||
if (clrValue == null) {
|
||||
clrValue = extensions.get("displaycolour");
|
||||
}
|
||||
}
|
||||
if (clrValue != null && clrValue.length() > 0) {
|
||||
try {
|
||||
return Color.parseColor(clrValue.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
GPXColor c = GPXColor.getColorFromName(clrValue);
|
||||
if(c != null) {
|
||||
return c.color;
|
||||
}
|
||||
}
|
||||
return defColor;
|
||||
|
@ -128,7 +154,7 @@ public class GPXUtilities {
|
|||
public float speed;
|
||||
}
|
||||
|
||||
public static class WptPt extends GPXExtensions implements LocationPoint {
|
||||
public static class WptPt extends GPXExtensions {
|
||||
public boolean firstPoint = false;
|
||||
public boolean lastPoint = false;
|
||||
public double lat;
|
||||
|
@ -178,27 +204,19 @@ public class GPXUtilities {
|
|||
return distance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return getColor(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getLatitude() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getLongitude() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PointDescription getPointDescription(Context ctx) {
|
||||
return new PointDescription(PointDescription.POINT_TYPE_WPT, name);
|
||||
}
|
||||
|
||||
public WptPt(double lat, double lon, long time, double ele, double speed, double hdop) {
|
||||
this.lat = lat;
|
||||
this.lon = lon;
|
||||
|
@ -208,7 +226,6 @@ public class GPXUtilities {
|
|||
this.hdop = hdop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return true;
|
||||
}
|
||||
|
@ -246,7 +263,8 @@ public class GPXUtilities {
|
|||
|
||||
public List<WptPt> points = new ArrayList<>();
|
||||
|
||||
public List<Renderable.RenderableSegment> renders = new ArrayList<>();
|
||||
public Object renderer;
|
||||
|
||||
|
||||
public List<GPXTrackAnalysis> splitByDistance(double meters) {
|
||||
return split(getDistanceMetric(), getTimeSplit(), meters);
|
||||
|
@ -262,11 +280,6 @@ public class GPXUtilities {
|
|||
return convert(splitSegments);
|
||||
}
|
||||
|
||||
public void drawRenderers(double zoom, Paint p, Canvas c, RotatedTileBox tb) {
|
||||
for (Renderable.RenderableSegment rs : renders) {
|
||||
rs.drawSegment(zoom, p, c, tb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Track extends GPXExtensions {
|
||||
|
@ -287,12 +300,10 @@ public class GPXUtilities {
|
|||
public static class Metadata extends GPXExtensions {
|
||||
public String desc;
|
||||
|
||||
@Nullable
|
||||
public String getArticleTitle() {
|
||||
return getExtensionsToRead().get("article_title");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getArticleLang() {
|
||||
return getExtensionsToRead().get("article_lang");
|
||||
}
|
||||
|
@ -814,7 +825,7 @@ public class GPXUtilities {
|
|||
private List<WptPt> points = new ArrayList<>();
|
||||
public List<Route> routes = new ArrayList<>();
|
||||
|
||||
public String warning = null;
|
||||
public Exception error = null;
|
||||
public String path = "";
|
||||
public boolean showCurrentTrack;
|
||||
public boolean hasAltitude;
|
||||
|
@ -823,6 +834,10 @@ public class GPXUtilities {
|
|||
private Track generalTrack;
|
||||
private TrkSegment generalSegment;
|
||||
|
||||
public GPXFile(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public List<WptPt> getPoints() {
|
||||
return Collections.unmodifiableList(points);
|
||||
}
|
||||
|
@ -851,11 +866,11 @@ public class GPXUtilities {
|
|||
return points.size();
|
||||
}
|
||||
|
||||
boolean containsPoint(WptPt point) {
|
||||
public boolean containsPoint(WptPt point) {
|
||||
return points.contains(point);
|
||||
}
|
||||
|
||||
void clearPoints() {
|
||||
public void clearPoints() {
|
||||
points.clear();
|
||||
modifiedTime = System.currentTimeMillis();
|
||||
}
|
||||
|
@ -870,7 +885,7 @@ public class GPXUtilities {
|
|||
modifiedTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
void addPoints(Collection<? extends WptPt> collection) {
|
||||
public void addPoints(Collection<? extends WptPt> collection) {
|
||||
points.addAll(collection);
|
||||
modifiedTime = System.currentTimeMillis();
|
||||
}
|
||||
|
@ -1228,7 +1243,7 @@ public class GPXUtilities {
|
|||
Set<String> categories = new HashSet<>();
|
||||
for (WptPt pt : points) {
|
||||
String category = pt.category == null ? "" : pt.category;
|
||||
if (withDefaultCategory || !TextUtils.isEmpty(category)) {
|
||||
if (withDefaultCategory || !Algorithms.isEmpty(category)) {
|
||||
categories.add(category);
|
||||
}
|
||||
}
|
||||
|
@ -1240,7 +1255,7 @@ public class GPXUtilities {
|
|||
for (WptPt pt : points) {
|
||||
String category = pt.category == null ? "" : pt.category;
|
||||
int color = pt.category == null ? 0 : pt.getColor();
|
||||
boolean emptyCategory = TextUtils.isEmpty(category);
|
||||
boolean emptyCategory = Algorithms.isEmpty(category);
|
||||
if (!emptyCategory) {
|
||||
Integer existingColor = categories.get(category);
|
||||
if (existingColor == null || (existingColor == 0 && color != 0)) {
|
||||
|
@ -1305,13 +1320,13 @@ public class GPXUtilities {
|
|||
}
|
||||
}
|
||||
|
||||
public static String asString(GPXFile file, OsmandApplication ctx) {
|
||||
public static String asString(GPXFile file) {
|
||||
final Writer writer = new StringWriter();
|
||||
GPXUtilities.writeGpx(writer, file, ctx);
|
||||
GPXUtilities.writeGpx(writer, file);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
public static String writeGpxFile(File fout, GPXFile file, OsmandApplication ctx) {
|
||||
public static Exception writeGpxFile(File fout, GPXFile file) {
|
||||
Writer output = null;
|
||||
try {
|
||||
if(fout.getParentFile() != null) {
|
||||
|
@ -1321,11 +1336,10 @@ public class GPXUtilities {
|
|||
if(Algorithms.isEmpty(file.path)) {
|
||||
file.path = fout.getAbsolutePath();
|
||||
}
|
||||
String msg = writeGpx(output, file, ctx);
|
||||
return msg;
|
||||
} catch (IOException e) {
|
||||
return writeGpx(output, file);
|
||||
} catch (Exception e) {
|
||||
log.error("Error saving gpx", e); //$NON-NLS-1$
|
||||
return ctx.getString(R.string.error_occurred_saving_gpx);
|
||||
return e;
|
||||
} finally {
|
||||
if (output != null) {
|
||||
try {
|
||||
|
@ -1337,7 +1351,7 @@ public class GPXUtilities {
|
|||
}
|
||||
}
|
||||
|
||||
public static String writeGpx(Writer output, GPXFile file, OsmandApplication ctx) {
|
||||
public static Exception writeGpx(Writer output, GPXFile file) {
|
||||
try {
|
||||
SimpleDateFormat format = new SimpleDateFormat(GPX_TIME_FORMAT, Locale.US);
|
||||
format.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
|
@ -1347,9 +1361,7 @@ public class GPXUtilities {
|
|||
serializer.startDocument("UTF-8", true); //$NON-NLS-1$
|
||||
serializer.startTag(null, "gpx"); //$NON-NLS-1$
|
||||
serializer.attribute(null, "version", "1.1"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if (file.author == null) {
|
||||
serializer.attribute(null, "creator", Version.getAppName(ctx)); //$NON-NLS-1$
|
||||
} else {
|
||||
if (file.author != null) {
|
||||
serializer.attribute(null, "creator", file.author); //$NON-NLS-1$
|
||||
}
|
||||
serializer.attribute(null, "xmlns", "http://www.topografix.com/GPX/1/1"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
@ -1409,14 +1421,9 @@ public class GPXUtilities {
|
|||
serializer.endTag(null, "gpx"); //$NON-NLS-1$
|
||||
serializer.endDocument();
|
||||
serializer.flush();
|
||||
|
||||
|
||||
} catch (RuntimeException e) {
|
||||
} catch (Exception e) {
|
||||
log.error("Error saving gpx", e); //$NON-NLS-1$
|
||||
return ctx.getString(R.string.error_occurred_saving_gpx);
|
||||
} catch (IOException e) {
|
||||
log.error("Error saving gpx", e); //$NON-NLS-1$
|
||||
return ctx.getString(R.string.error_occurred_saving_gpx);
|
||||
return e;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -1522,11 +1529,11 @@ public class GPXUtilities {
|
|||
return text;
|
||||
}
|
||||
|
||||
public static GPXFile loadGPXFile(Context ctx, File f) {
|
||||
public static GPXFile loadGPXFile(File f) {
|
||||
FileInputStream fis = null;
|
||||
try {
|
||||
fis = new FileInputStream(f);
|
||||
GPXFile file = loadGPXFile(ctx, fis);
|
||||
GPXFile file = loadGPXFile(fis);
|
||||
file.path = f.getAbsolutePath();
|
||||
try {
|
||||
fis.close();
|
||||
|
@ -1534,10 +1541,10 @@ public class GPXUtilities {
|
|||
}
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
GPXFile res = new GPXFile();
|
||||
GPXFile res = new GPXFile(null);
|
||||
res.path = f.getAbsolutePath();
|
||||
log.error("Error reading gpx " + res.path, e); //$NON-NLS-1$
|
||||
res.warning = ctx.getString(R.string.error_reading_gpx);
|
||||
res.error = e;
|
||||
return res;
|
||||
} finally {
|
||||
try {
|
||||
|
@ -1549,8 +1556,8 @@ public class GPXUtilities {
|
|||
}
|
||||
}
|
||||
|
||||
public static GPXFile loadGPXFile(Context ctx, InputStream f) {
|
||||
GPXFile res = new GPXFile();
|
||||
public static GPXFile loadGPXFile(InputStream f) {
|
||||
GPXFile res = new GPXFile(null);
|
||||
SimpleDateFormat format = new SimpleDateFormat(GPX_TIME_FORMAT, Locale.US);
|
||||
format.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
SimpleDateFormat formatMillis = new SimpleDateFormat(GPX_TIME_FORMAT_MILLIS, Locale.US);
|
||||
|
@ -1744,15 +1751,9 @@ public class GPXUtilities {
|
|||
}
|
||||
}
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
} catch (Exception e) {
|
||||
res.error = e;
|
||||
log.error("Error reading gpx", e); //$NON-NLS-1$
|
||||
res.warning = ctx.getString(R.string.error_reading_gpx) + " " + e.getMessage();
|
||||
} catch (XmlPullParserException e) {
|
||||
log.error("Error reading gpx", e); //$NON-NLS-1$
|
||||
res.warning = ctx.getString(R.string.error_reading_gpx) + " " + e.getMessage();
|
||||
} catch (IOException e) {
|
||||
log.error("Error reading gpx", e); //$NON-NLS-1$
|
||||
res.warning = ctx.getString(R.string.error_reading_gpx) + " " + e.getMessage();
|
||||
}
|
||||
|
||||
return res;
|
||||
|
@ -1800,40 +1801,9 @@ public class GPXUtilities {
|
|||
if (from.routes != null) {
|
||||
to.routes.addAll(from.routes);
|
||||
}
|
||||
if (from.warning != null) {
|
||||
to.warning = from.warning;
|
||||
if (from.error != null) {
|
||||
to.error = from.error;
|
||||
}
|
||||
}
|
||||
|
||||
public static GPXFile makeGpxFromRoute(RouteCalculationResult route) {
|
||||
double lastHeight = HEIGHT_UNDEFINED;
|
||||
GPXFile gpx = new GPXUtilities.GPXFile();
|
||||
List<Location> locations = route.getRouteLocations();
|
||||
if (locations != null) {
|
||||
GPXUtilities.Track track = new GPXUtilities.Track();
|
||||
GPXUtilities.TrkSegment seg = new GPXUtilities.TrkSegment();
|
||||
for (Location l : locations) {
|
||||
GPXUtilities.WptPt point = new GPXUtilities.WptPt();
|
||||
point.lat = l.getLatitude();
|
||||
point.lon = l.getLongitude();
|
||||
if (l.hasAltitude()) {
|
||||
gpx.hasAltitude = true;
|
||||
float h = (float) l.getAltitude();
|
||||
point.ele = h;
|
||||
if (lastHeight == HEIGHT_UNDEFINED && seg.points.size() > 0) {
|
||||
for (GPXUtilities.WptPt pt : seg.points) {
|
||||
if (Double.isNaN(pt.ele)) {
|
||||
pt.ele = h;
|
||||
}
|
||||
}
|
||||
}
|
||||
lastHeight = h;
|
||||
}
|
||||
seg.points.add(point);
|
||||
}
|
||||
track.segments.add(seg);
|
||||
gpx.tracks.add(track);
|
||||
}
|
||||
return gpx;
|
||||
}
|
||||
}
|
|
@ -56,9 +56,9 @@ import net.osmand.plus.ContextMenuAdapter;
|
|||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
|
@ -634,7 +634,7 @@ public class OsmandAidlApi {
|
|||
if (intent.getStringExtra(AIDL_DATA) != null) {
|
||||
String gpxStr = intent.getStringExtra(AIDL_DATA);
|
||||
if (!Algorithms.isEmpty(gpxStr)) {
|
||||
gpx = GPXUtilities.loadGPXFile(mapActivity, new ByteArrayInputStream(gpxStr.getBytes()));
|
||||
gpx = GPXUtilities.loadGPXFile(new ByteArrayInputStream(gpxStr.getBytes()));
|
||||
}
|
||||
} else if (intent.getParcelableExtra(AIDL_URI) != null) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
|
@ -648,7 +648,7 @@ public class OsmandAidlApi {
|
|||
}
|
||||
if (gpxParcelDescriptor != null) {
|
||||
FileDescriptor fileDescriptor = gpxParcelDescriptor.getFileDescriptor();
|
||||
gpx = GPXUtilities.loadGPXFile(mapActivity, new FileInputStream(fileDescriptor));
|
||||
gpx = GPXUtilities.loadGPXFile(new FileInputStream(fileDescriptor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1199,12 +1199,12 @@ public class OsmandAidlApi {
|
|||
|
||||
@Override
|
||||
protected GPXFile doInBackground(File... files) {
|
||||
return GPXUtilities.loadGPXFile(app, files[0]);
|
||||
return GPXUtilities.loadGPXFile(files[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(GPXFile gpx) {
|
||||
if (gpx.warning == null) {
|
||||
if (gpx.error == null) {
|
||||
selectedGpx.setGpxFile(gpx);
|
||||
refreshMap();
|
||||
}
|
||||
|
@ -1220,12 +1220,12 @@ public class OsmandAidlApi {
|
|||
|
||||
@Override
|
||||
protected GPXFile doInBackground(File... files) {
|
||||
return GPXUtilities.loadGPXFile(app, files[0]);
|
||||
return GPXUtilities.loadGPXFile(files[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(GPXFile gpx) {
|
||||
if (gpx.warning == null) {
|
||||
if (gpx.error == null) {
|
||||
helper.selectGpxFile(gpx, true, false);
|
||||
refreshMap();
|
||||
}
|
||||
|
@ -1328,12 +1328,12 @@ public class OsmandAidlApi {
|
|||
|
||||
@Override
|
||||
protected GPXFile doInBackground(File... files) {
|
||||
return GPXUtilities.loadGPXFile(app, files[0]);
|
||||
return GPXUtilities.loadGPXFile(files[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(GPXFile gpx) {
|
||||
if (gpx.warning == null) {
|
||||
if (gpx.error == null) {
|
||||
app.getSelectedGpxHelper().selectGpxFile(gpx, true, false);
|
||||
refreshMap();
|
||||
}
|
||||
|
@ -2082,7 +2082,7 @@ public class OsmandAidlApi {
|
|||
|
||||
@Override
|
||||
protected void onPostExecute(GPXFile gpxFile) {
|
||||
if (gpxFile.warning == null && callback != null) {
|
||||
if (gpxFile.error == null && callback != null) {
|
||||
callback.processResult(gpxFile);
|
||||
}
|
||||
}
|
||||
|
@ -2097,7 +2097,7 @@ public class OsmandAidlApi {
|
|||
}
|
||||
if (gpxParcelDescriptor != null) {
|
||||
final FileDescriptor fileDescriptor = gpxParcelDescriptor.getFileDescriptor();
|
||||
return GPXUtilities.loadGPXFile(app, new FileInputStream(fileDescriptor));
|
||||
return GPXUtilities.loadGPXFile(new FileInputStream(fileDescriptor));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ package net.osmand.data;
|
|||
|
||||
import android.content.Context;
|
||||
|
||||
import net.osmand.GPXUtilities;
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -12,13 +14,10 @@ public interface LocationPoint {
|
|||
public double getLongitude();
|
||||
|
||||
public int getColor();
|
||||
|
||||
|
||||
public boolean isVisible();
|
||||
|
||||
|
||||
public PointDescription getPointDescription(Context ctx);
|
||||
|
||||
// public String getSpeakableName();
|
||||
|
||||
//public void prepareCommandPlayer(CommandBuilder cmd, String names);
|
||||
|
||||
|
||||
}
|
||||
|
|
39
OsmAnd/src/net/osmand/data/WptLocationPoint.java
Normal file
39
OsmAnd/src/net/osmand/data/WptLocationPoint.java
Normal file
|
@ -0,0 +1,39 @@
|
|||
package net.osmand.data;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import net.osmand.GPXUtilities;
|
||||
|
||||
public class WptLocationPoint implements LocationPoint {
|
||||
|
||||
GPXUtilities.WptPt pt;
|
||||
|
||||
public WptLocationPoint(GPXUtilities.WptPt p) {
|
||||
this.pt = p;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double getLatitude() {
|
||||
return pt.lat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getLongitude() {
|
||||
return pt.lon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return pt.getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return pt.isVisible();
|
||||
}
|
||||
|
||||
public PointDescription getPointDescription(Context ctx) {
|
||||
return new PointDescription(PointDescription.POINT_TYPE_WPT, pt.name);
|
||||
}
|
||||
}
|
|
@ -4,11 +4,13 @@ import android.content.Context;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
|
||||
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
||||
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;
|
||||
|
@ -351,12 +353,12 @@ public class FavouritesDbHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public String exportFavorites() {
|
||||
public Exception exportFavorites() {
|
||||
return saveExternalFile(null);
|
||||
}
|
||||
|
||||
|
||||
private String saveExternalFile(Set<String> deleted) {
|
||||
private Exception saveExternalFile(Set<String> deleted) {
|
||||
Map<String, FavouritePoint> all = new LinkedHashMap<String, FavouritePoint>();
|
||||
loadGPXFile(getExternalFile(), all);
|
||||
List<FavouritePoint> favoritePoints = new ArrayList<FavouritePoint>(cachedFavoritePoints);
|
||||
|
@ -420,9 +422,9 @@ public class FavouritesDbHelper {
|
|||
return firstModified;
|
||||
}
|
||||
|
||||
public String saveFile(List<FavouritePoint> favoritePoints, File f) {
|
||||
public Exception saveFile(List<FavouritePoint> favoritePoints, File f) {
|
||||
GPXFile gpx = asGpxFile(favoritePoints);
|
||||
return GPXUtilities.writeGpxFile(f, gpx, context);
|
||||
return GPXUtilities.writeGpxFile(f, gpx);
|
||||
}
|
||||
|
||||
|
||||
|
@ -431,7 +433,7 @@ public class FavouritesDbHelper {
|
|||
}
|
||||
|
||||
private GPXFile asGpxFile(List<FavouritePoint> favoritePoints) {
|
||||
GPXFile gpx = new GPXFile();
|
||||
GPXFile gpx = new GPXFile(Version.getFullVersion(context));
|
||||
for (FavouritePoint p : favoritePoints) {
|
||||
WptPt pt = new WptPt();
|
||||
pt.lat = p.getLatitude();
|
||||
|
@ -606,8 +608,8 @@ public class FavouritesDbHelper {
|
|||
if (!file.exists()) {
|
||||
return false;
|
||||
}
|
||||
GPXFile res = GPXUtilities.loadGPXFile(context, file);
|
||||
if (res.warning != null) {
|
||||
GPXFile res = GPXUtilities.loadGPXFile(file);
|
||||
if (res.error != null) {
|
||||
return false;
|
||||
}
|
||||
for (WptPt p : res.getPoints()) {
|
||||
|
|
|
@ -4,7 +4,7 @@ import android.support.annotation.NonNull;
|
|||
import android.support.annotation.Nullable;
|
||||
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
||||
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
|
|
@ -6,15 +6,16 @@ import android.support.annotation.NonNull;
|
|||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.IProgress;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.plus.GPXUtilities.Route;
|
||||
import net.osmand.plus.GPXUtilities.Track;
|
||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.GPXUtilities.Route;
|
||||
import net.osmand.GPXUtilities.Track;
|
||||
import net.osmand.GPXUtilities.TrkSegment;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
|
||||
import net.osmand.plus.OsmandSettings.MetricsConstants;
|
||||
import net.osmand.plus.activities.SavingTrackHelper;
|
||||
|
@ -431,12 +432,12 @@ public class GpxSelectionHelper {
|
|||
if (p != null) {
|
||||
p.startTask(getString(R.string.loading_smth, fl.getName()), -1);
|
||||
}
|
||||
GPXFile gpx = GPXUtilities.loadGPXFile(app, fl);
|
||||
GPXFile gpx = GPXUtilities.loadGPXFile(fl);
|
||||
if (obj.has(COLOR)) {
|
||||
int clr = Algorithms.parseColor(obj.getString(COLOR));
|
||||
gpx.setColor(clr);
|
||||
}
|
||||
if (gpx.warning != null) {
|
||||
if (gpx.error != null) {
|
||||
save = true;
|
||||
} else {
|
||||
selectGpxFile(gpx, true, false, true, selectedByUser, false);
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.support.annotation.Nullable;
|
|||
import android.support.v4.content.ContextCompat;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
|
@ -15,8 +16,8 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.data.LocationPoint;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GeocodingLookupService.AddressLookupRequest;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
|
||||
|
@ -1019,7 +1020,7 @@ public class MapMarkersHelper {
|
|||
while (fout.exists()) {
|
||||
fout = new File(dir, fileName + "_" + (++ind) + ".gpx");
|
||||
}
|
||||
GPXFile file = new GPXFile();
|
||||
GPXFile file = new GPXFile(Version.getFullVersion(ctx));
|
||||
for (MapMarker marker : mapMarkers) {
|
||||
WptPt wpt = new WptPt();
|
||||
wpt.lat = marker.getLatitude();
|
||||
|
@ -1028,7 +1029,7 @@ public class MapMarkersHelper {
|
|||
wpt.name = marker.getOnlyName();
|
||||
file.addPoint(wpt);
|
||||
}
|
||||
GPXUtilities.writeGpxFile(fout, file, ctx);
|
||||
GPXUtilities.writeGpxFile(fout, file);
|
||||
return fout.getAbsolutePath();
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import android.widget.TextView;
|
|||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
|
||||
|
|
|
@ -622,9 +622,9 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
|||
} else if (!tosave.getParentFile().exists()) {
|
||||
Toast.makeText(getActivity(), R.string.sd_dir_not_accessible, Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
final AsyncTask<Void, Void, String> exportTask = new AsyncTask<Void, Void, String>() {
|
||||
final AsyncTask<Void, Void, Exception > exportTask = new AsyncTask<Void, Void, Exception >() {
|
||||
@Override
|
||||
protected String doInBackground(Void... params) {
|
||||
protected Exception doInBackground(Void... params) {
|
||||
return helper.exportFavorites();
|
||||
}
|
||||
|
||||
|
@ -634,7 +634,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String warning) {
|
||||
protected void onPostExecute(Exception warning) {
|
||||
hideProgressBar();
|
||||
if (warning == null) {
|
||||
Toast.makeText(
|
||||
|
@ -642,7 +642,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
|||
MessageFormat.format(getString(R.string.fav_saved_sucessfully),
|
||||
tosave.getAbsolutePath()), Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
Toast.makeText(getActivity(), warning, Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(getActivity(), warning.getMessage(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@ package net.osmand.plus.activities;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.activities.LocalIndexHelper.LocalIndexType;
|
||||
import android.os.Parcel;
|
||||
|
|
|
@ -38,9 +38,9 @@ import net.osmand.plus.ContextMenuAdapter;
|
|||
import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.ContextMenuItem.ItemBuilder;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.OsmAndLocationProvider;
|
||||
|
@ -307,7 +307,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
File file = params[0];
|
||||
String fileName = file.getName();
|
||||
GPXFile gpx = app.getRoutingHelper().generateGPXFileWithRoute(fileName.substring(0,fileName.length()-GPX_SUFFIX.length()));
|
||||
GPXUtilities.writeGpxFile(file, gpx, app);
|
||||
GPXUtilities.writeGpxFile(file, gpx);
|
||||
return app.getString(R.string.route_successfully_saved_at, file.getName());
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -19,8 +19,8 @@ import net.osmand.map.ITileSource;
|
|||
import net.osmand.map.TileSourceManager.TileSourceTemplate;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
|
|
@ -8,17 +8,18 @@ import android.text.format.DateFormat;
|
|||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.plus.GPXUtilities.Track;
|
||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.GPXUtilities.Track;
|
||||
import net.osmand.GPXUtilities.TrkSegment;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.OsmAndLocationProvider;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||
import net.osmand.plus.notifications.OsmandNotification.NotificationType;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
@ -75,7 +76,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
this.ctx = ctx;
|
||||
this.currentTrack = new SelectedGpxFile();
|
||||
this.currentTrack.setShowCurrentTrack(true);
|
||||
GPXFile gx = new GPXFile();
|
||||
GPXFile gx = new GPXFile(Version.getFullVersion(ctx));
|
||||
gx.showCurrentTrack = true;
|
||||
this.currentTrack.setGpxFile(gx);
|
||||
prepareCurrentTrackForRecording();
|
||||
|
@ -218,9 +219,9 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
}
|
||||
}
|
||||
|
||||
String warn = GPXUtilities.writeGpxFile(fout, data.get(f), ctx);
|
||||
Exception warn = GPXUtilities.writeGpxFile(fout, data.get(f));
|
||||
if (warn != null) {
|
||||
warnings.add(warn);
|
||||
warnings.add(warn.getMessage());
|
||||
return warnings;
|
||||
}
|
||||
|
||||
|
@ -298,7 +299,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
if (dataTracks.containsKey(date)) {
|
||||
gpx = dataTracks.get(date);
|
||||
} else {
|
||||
gpx = new GPXFile();
|
||||
gpx = new GPXFile(Version.getFullVersion(ctx));
|
||||
dataTracks.put(date, gpx);
|
||||
}
|
||||
ctx.getSelectedGpxHelper().addPoint(pt, gpx);
|
||||
|
@ -351,7 +352,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
GPXFile gpx = dataTracks.get(date);
|
||||
gpx.tracks.add(track);
|
||||
} else {
|
||||
GPXFile file = new GPXFile();
|
||||
GPXFile file = new GPXFile(Version.getFullVersion(ctx));
|
||||
file.tracks.add(track);
|
||||
dataTracks.put(date, file);
|
||||
}
|
||||
|
|
|
@ -48,11 +48,11 @@ import net.osmand.AndroidUtils;
|
|||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.GPXUtilities.TrkSegment;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
|
@ -318,7 +318,7 @@ public class ShowRouteInfoDialogFragment extends DialogFragment {
|
|||
}
|
||||
|
||||
private void makeGpx() {
|
||||
gpx = GPXUtilities.makeGpxFromRoute(helper.getRoute());
|
||||
gpx = GpxUiHelper.makeGpxFromRoute(helper.getRoute(), getMyApplication());
|
||||
String groupName = getMyApplication().getString(R.string.current_route);
|
||||
GpxDisplayGroup group = getMyApplication().getSelectedGpxHelper().buildGpxDisplayGroup(gpx, 0, groupName);
|
||||
if (group != null && group.getModifiableList().size() > 0) {
|
||||
|
@ -544,7 +544,7 @@ public class ShowRouteInfoDialogFragment extends DialogFragment {
|
|||
File dst = new File(dir, "route.gpx");
|
||||
try {
|
||||
FileWriter fw = new FileWriter(dst);
|
||||
GPXUtilities.writeGpx(fw, gpx, getMyApplication());
|
||||
GPXUtilities.writeGpx(fw, gpx);
|
||||
fw.close();
|
||||
final Intent sendIntent = new Intent();
|
||||
sendIntent.setAction(Intent.ACTION_SEND);
|
||||
|
|
|
@ -21,10 +21,10 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.TrkSegment;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
|
@ -452,7 +452,7 @@ public class TrackActivity extends TabActivity {
|
|||
if (selectedGpxFile != null && selectedGpxFile.getGpxFile() != null) {
|
||||
result = selectedGpxFile.getGpxFile();
|
||||
} else {
|
||||
result = GPXUtilities.loadGPXFile(app, file);
|
||||
result = GPXUtilities.loadGPXFile(file);
|
||||
}
|
||||
}
|
||||
if (result != null) {
|
||||
|
|
|
@ -29,12 +29,13 @@ import android.widget.Toast;
|
|||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings.NotesSortByMode;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.ActionBarProgressActivity;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.OsmandActionBarActivity;
|
||||
|
@ -487,7 +488,7 @@ public class NotesFragment extends OsmAndListFragment {
|
|||
private File generateGPXForRecordings(Set<Recording> selected) {
|
||||
File tmpFile = new File(getActivity().getCacheDir(), "share/noteLocations.gpx");
|
||||
tmpFile.getParentFile().mkdirs();
|
||||
GPXFile file = new GPXFile();
|
||||
GPXFile file = new GPXFile(Version.getFullVersion(getMyApplication()));
|
||||
for (Recording r : getRecordingsForGpx(selected)) {
|
||||
if (r != SHARE_LOCATION_FILE) {
|
||||
String desc = r.getDescriptionName(r.getFileName());
|
||||
|
@ -505,7 +506,7 @@ public class NotesFragment extends OsmAndListFragment {
|
|||
getMyApplication().getSelectedGpxHelper().addPoint(wpt, file);
|
||||
}
|
||||
}
|
||||
GPXUtilities.writeGpxFile(tmpFile, file, getMyApplication());
|
||||
GPXUtilities.writeGpxFile(tmpFile, file);
|
||||
return tmpFile;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ import android.widget.TextView;
|
|||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -112,8 +112,8 @@ public class FailSafeFuntions {
|
|||
protected GPXFile doInBackground(String... params) {
|
||||
if (gpxPath != null) {
|
||||
// Reverse also should be stored ?
|
||||
GPXFile f = GPXUtilities.loadGPXFile(app, new File(gpxPath));
|
||||
if (f.warning != null) {
|
||||
GPXFile f = GPXUtilities.loadGPXFile(new File(gpxPath));
|
||||
if (f.error != null) {
|
||||
return null;
|
||||
}
|
||||
return f;
|
||||
|
|
|
@ -22,8 +22,8 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -188,12 +188,12 @@ public class ExternalApiHelper {
|
|||
if (path != null) {
|
||||
File f = new File(path);
|
||||
if (f.exists()) {
|
||||
gpx = GPXUtilities.loadGPXFile(mapActivity, f);
|
||||
gpx = GPXUtilities.loadGPXFile(f);
|
||||
}
|
||||
} else if (intent.getStringExtra(PARAM_DATA) != null) {
|
||||
String gpxStr = intent.getStringExtra(PARAM_DATA);
|
||||
if (!Algorithms.isEmpty(gpxStr)) {
|
||||
gpx = GPXUtilities.loadGPXFile(mapActivity, new ByteArrayInputStream(gpxStr.getBytes()));
|
||||
gpx = GPXUtilities.loadGPXFile(new ByteArrayInputStream(gpxStr.getBytes()));
|
||||
}
|
||||
} else if (uri.getBooleanQueryParameter(PARAM_URI, false)) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
|
@ -204,7 +204,7 @@ public class ExternalApiHelper {
|
|||
.openFileDescriptor(gpxUri, "r");
|
||||
if (gpxParcelDescriptor != null) {
|
||||
FileDescriptor fileDescriptor = gpxParcelDescriptor.getFileDescriptor();
|
||||
gpx = GPXUtilities.loadGPXFile(mapActivity, new FileInputStream(fileDescriptor));
|
||||
gpx = GPXUtilities.loadGPXFile(new FileInputStream(fileDescriptor));
|
||||
} else {
|
||||
finish = true;
|
||||
resultCode = RESULT_CODE_ERROR_GPX_NOT_FOUND;
|
||||
|
|
|
@ -57,15 +57,16 @@ import com.github.mikephil.charting.utils.MPPointF;
|
|||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.Elevation;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.plus.GPXUtilities.Speed;
|
||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.Elevation;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.GPXUtilities.Speed;
|
||||
import net.osmand.GPXUtilities.TrkSegment;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -73,6 +74,7 @@ import net.osmand.plus.OsmandPlugin;
|
|||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.ActivityResultListener;
|
||||
import net.osmand.plus.activities.ActivityResultListener.OnActivityResultListener;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
@ -82,6 +84,7 @@ import net.osmand.plus.dialogs.ConfigureMapMenu;
|
|||
import net.osmand.plus.dialogs.ConfigureMapMenu.AppearanceListItem;
|
||||
import net.osmand.plus.dialogs.ConfigureMapMenu.GpxAppearanceAdapter;
|
||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||
import net.osmand.plus.routing.RouteCalculationResult;
|
||||
import net.osmand.render.RenderingRuleProperty;
|
||||
import net.osmand.render.RenderingRulesStorage;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -99,6 +102,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import static com.github.mikephil.charting.components.XAxis.XAxisPosition.BOTTOM;
|
||||
import static net.osmand.binary.RouteDataObject.HEIGHT_UNDEFINED;
|
||||
import static net.osmand.plus.OsmAndFormatter.FEET_IN_ONE_METER;
|
||||
import static net.osmand.plus.OsmAndFormatter.METERS_IN_KILOMETER;
|
||||
import static net.osmand.plus.OsmAndFormatter.METERS_IN_ONE_MILE;
|
||||
|
@ -941,9 +945,9 @@ public class GpxUiHelper {
|
|||
}
|
||||
for (String fname : filename) {
|
||||
final File f = new File(dir, fname);
|
||||
GPXFile res = GPXUtilities.loadGPXFile(activity.getApplication(), f);
|
||||
if (res.warning != null && res.warning.length() > 0) {
|
||||
w += res.warning + "\n";
|
||||
GPXFile res = GPXUtilities.loadGPXFile(f);
|
||||
if (res.error != null && res.error.getMessage().length() > 0) {
|
||||
w += res.error.getMessage() + "\n";
|
||||
}
|
||||
result[k++] = res;
|
||||
}
|
||||
|
@ -1863,6 +1867,41 @@ public class GpxUiHelper {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public static GPXFile makeGpxFromRoute(RouteCalculationResult route, OsmandApplication app) {
|
||||
double lastHeight = HEIGHT_UNDEFINED;
|
||||
GPXFile gpx = new GPXUtilities.GPXFile(Version.getFullVersion(app));
|
||||
List<Location> locations = route.getRouteLocations();
|
||||
if (locations != null) {
|
||||
GPXUtilities.Track track = new GPXUtilities.Track();
|
||||
GPXUtilities.TrkSegment seg = new GPXUtilities.TrkSegment();
|
||||
for (Location l : locations) {
|
||||
GPXUtilities.WptPt point = new GPXUtilities.WptPt();
|
||||
point.lat = l.getLatitude();
|
||||
point.lon = l.getLongitude();
|
||||
if (l.hasAltitude()) {
|
||||
gpx.hasAltitude = true;
|
||||
float h = (float) l.getAltitude();
|
||||
point.ele = h;
|
||||
if (lastHeight == HEIGHT_UNDEFINED && seg.points.size() > 0) {
|
||||
for (GPXUtilities.WptPt pt : seg.points) {
|
||||
if (Double.isNaN(pt.ele)) {
|
||||
pt.ele = h;
|
||||
}
|
||||
}
|
||||
}
|
||||
lastHeight = h;
|
||||
}
|
||||
seg.points.add(point);
|
||||
}
|
||||
track.segments.add(seg);
|
||||
gpx.tracks.add(track);
|
||||
}
|
||||
return gpx;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static class GPXInfo {
|
||||
private String fileName;
|
||||
private long lastModified;
|
||||
|
|
|
@ -31,8 +31,8 @@ import net.osmand.plus.AppInitializer;
|
|||
import net.osmand.plus.AppInitializer.AppInitializeListener;
|
||||
import net.osmand.plus.AppInitializer.InitEvents;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -187,7 +187,7 @@ public class ImportHelper {
|
|||
|
||||
if (pFD != null) {
|
||||
is = new FileInputStream(pFD.getFileDescriptor());
|
||||
return GPXUtilities.loadGPXFile(app, is);
|
||||
return GPXUtilities.loadGPXFile(is);
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
//
|
||||
|
@ -228,7 +228,7 @@ public class ImportHelper {
|
|||
|
||||
if (pFD != null) {
|
||||
is = new FileInputStream(pFD.getFileDescriptor());
|
||||
return GPXUtilities.loadGPXFile(app, is);
|
||||
return GPXUtilities.loadGPXFile(is);
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
//
|
||||
|
@ -329,7 +329,7 @@ public class ImportHelper {
|
|||
final String result = Kml2Gpx.toGpx(zis);
|
||||
if (result != null) {
|
||||
try {
|
||||
return GPXUtilities.loadGPXFile(app, new ByteArrayInputStream(result.getBytes("UTF-8")));
|
||||
return GPXUtilities.loadGPXFile(new ByteArrayInputStream(result.getBytes("UTF-8")));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
return null;
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ public class ImportHelper {
|
|||
final String result = Kml2Gpx.toGpx(is);
|
||||
if (result != null) {
|
||||
try {
|
||||
return GPXUtilities.loadGPXFile(app, new ByteArrayInputStream(result.getBytes("UTF-8")));
|
||||
return GPXUtilities.loadGPXFile(new ByteArrayInputStream(result.getBytes("UTF-8")));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
return null;
|
||||
}
|
||||
|
@ -544,8 +544,8 @@ public class ImportHelper {
|
|||
private void handleResult(final GPXFile result, final String name, final boolean save,
|
||||
final boolean useImportDir, boolean forceImportFavourites) {
|
||||
if (result != null) {
|
||||
if (result.warning != null) {
|
||||
Toast.makeText(activity, result.warning, Toast.LENGTH_LONG).show();
|
||||
if (result.error != null) {
|
||||
Toast.makeText(activity, result.error.getMessage(), Toast.LENGTH_LONG).show();
|
||||
if (gpxImportCompleteListener != null) {
|
||||
gpxImportCompleteListener.onComplete(false);
|
||||
}
|
||||
|
@ -611,9 +611,12 @@ public class ImportHelper {
|
|||
if (importDir.exists() && importDir.isDirectory() && importDir.canWrite()) {
|
||||
final GPXUtilities.WptPt pt = gpxFile.findPointToShow();
|
||||
final File toWrite = getFileToSave(fileName, importDir, pt);
|
||||
warning = GPXUtilities.writeGpxFile(toWrite, gpxFile, app);
|
||||
if (warning == null) {
|
||||
Exception e = GPXUtilities.writeGpxFile(toWrite, gpxFile);
|
||||
if(e == null) {
|
||||
gpxFile.path = toWrite.getAbsolutePath();
|
||||
warning = null;
|
||||
} else {
|
||||
warning = app.getString(R.string.error_reading_gpx);
|
||||
}
|
||||
} else {
|
||||
warning = app.getString(R.string.sd_dir_not_accessible);
|
||||
|
|
|
@ -20,8 +20,8 @@ import net.osmand.data.PointDescription;
|
|||
import net.osmand.data.TransportStop;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
|
||||
|
|
|
@ -30,7 +30,7 @@ import net.osmand.data.PointDescription;
|
|||
import net.osmand.data.TransportStop;
|
||||
import net.osmand.map.OsmandRegions;
|
||||
import net.osmand.map.WorldRegion;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
|
|
|
@ -10,8 +10,8 @@ import android.widget.LinearLayout;
|
|||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.OsmAndAppCustomization;
|
||||
|
|
|
@ -6,7 +6,7 @@ import android.support.v4.content.ContextCompat;
|
|||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
|
|
|
@ -2,7 +2,7 @@ package net.osmand.plus.mapcontextmenu.editors;
|
|||
|
||||
import android.support.v4.app.DialogFragment;
|
||||
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ import android.widget.LinearLayout;
|
|||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
|
|
@ -2,8 +2,8 @@ package net.osmand.plus.mapcontextmenu.editors;
|
|||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
||||
|
|
|
@ -12,9 +12,10 @@ import android.support.v4.app.DialogFragment;
|
|||
import android.view.View;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.data.WptLocationPoint;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarkersGroup;
|
||||
|
@ -158,7 +159,7 @@ public class WptPtEditorFragment extends PointEditorFragment {
|
|||
LatLon latLon = new LatLon(wpt.getLatitude(), wpt.getLongitude());
|
||||
|
||||
if (menu.getLatLon().equals(latLon)) {
|
||||
menu.update(latLon, wpt.getPointDescription(getMapActivity()), wpt);
|
||||
menu.update(latLon, new WptLocationPoint(wpt).getPointDescription(getMapActivity()), wpt);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -316,7 +317,7 @@ public class WptPtEditorFragment extends PointEditorFragment {
|
|||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
GPXUtilities.writeGpxFile(new File(gpx.path), gpx, app);
|
||||
GPXUtilities.writeGpxFile(new File(gpx.path), gpx);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import net.osmand.CallbackWithObject;
|
|||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
|
|
|
@ -24,11 +24,11 @@ import net.osmand.AndroidUtils;
|
|||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.GPXUtilities.TrkSegment;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
|
|
@ -12,9 +12,9 @@ import android.widget.TextView;
|
|||
import net.osmand.IndexConstants;
|
||||
import net.osmand.plus.GPXDatabase;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -72,7 +72,7 @@ public class AddTracksGroupBottomSheetDialogFragment extends AddGroupBottomSheet
|
|||
GpxSelectionHelper selectionHelper = app.getSelectedGpxHelper();
|
||||
File gpx = dataItem.getFile();
|
||||
if (selectionHelper.getSelectedFileByPath(gpx.getAbsolutePath()) == null) {
|
||||
GPXFile res = GPXUtilities.loadGPXFile(app, gpx);
|
||||
GPXFile res = GPXUtilities.loadGPXFile(gpx);
|
||||
selectionHelper.selectGpxFile(res, true, false, false, false, false);
|
||||
}
|
||||
app.getMapMarkersHelper().addOrEnableGpxGroup(gpx);
|
||||
|
@ -134,7 +134,7 @@ public class AddTracksGroupBottomSheetDialogFragment extends AddGroupBottomSheet
|
|||
if (item == null
|
||||
|| item.getFileLastModifiedTime() != gpxFile.lastModified()
|
||||
|| item.getAnalysis().wptCategoryNames == null) {
|
||||
GPXFile f = GPXUtilities.loadGPXFile(app, gpxFile);
|
||||
GPXFile f = GPXUtilities.loadGPXFile(gpxFile);
|
||||
GPXTrackAnalysis analysis = f.getAnalysis(gpxFile.lastModified());
|
||||
if (item == null) {
|
||||
item = new GpxDataItem(gpxFile, analysis);
|
||||
|
|
|
@ -55,9 +55,9 @@ import android.widget.Toast;
|
|||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
|
||||
|
@ -65,6 +65,7 @@ import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.SavingTrackHelper;
|
||||
import net.osmand.plus.activities.TrackActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
|
@ -136,7 +137,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
|
||||
lightTheme = app.getSettings().isLightContent();
|
||||
setStyle(STYLE_NO_FRAME, lightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme);
|
||||
newGpxFile = new GPXFile();
|
||||
newGpxFile = new GPXFile(Version.getFullVersion(app));
|
||||
savingTrackHelper = app.getSavingTrackHelper();
|
||||
selectedGpxHelper = app.getSelectedGpxHelper();
|
||||
}
|
||||
|
@ -1499,10 +1500,10 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
|
|||
while (fout.exists()) {
|
||||
fout = new File(dir, fileName + "_" + (++ind) + ".gpx");
|
||||
}
|
||||
GPXUtilities.writeGpxFile(fout, gpx, app);
|
||||
GPXUtilities.writeGpxFile(fout, gpx);
|
||||
}
|
||||
} else {
|
||||
GPXUtilities.writeGpxFile(new File(gpx.path), gpx, app);
|
||||
GPXUtilities.writeGpxFile(new File(gpx.path), gpx);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -17,8 +17,10 @@ import net.osmand.Location;
|
|||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.LocationPoint;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.data.WptLocationPoint;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
|
||||
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
|
||||
|
@ -82,7 +84,7 @@ public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassL
|
|||
? app.getSelectedGpxHelper().getVisibleWayPointByLatLon(marker.point)
|
||||
: marker.wptPt;
|
||||
if (pt != null) {
|
||||
showMap(marker.point, pt.getPointDescription(mapActivity), pt);
|
||||
showMap(marker.point, new WptLocationPoint(pt).getPointDescription(mapActivity), pt);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@ import net.osmand.data.Amenity;
|
|||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.data.WptLocationPoint;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
|
||||
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
|
||||
|
@ -242,7 +243,7 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL
|
|||
? app.getSelectedGpxHelper().getVisibleWayPointByLatLon(marker.point)
|
||||
: marker.wptPt;
|
||||
if (pt != null) {
|
||||
showMap(marker.point, pt.getPointDescription(mapActivity), pt);
|
||||
showMap(marker.point, new WptLocationPoint(pt).getPointDescription(mapActivity), pt);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ import android.util.Pair;
|
|||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.TrkSegment;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.routing.RouteCalculationParams;
|
||||
|
|
|
@ -35,8 +35,8 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.TrkSegment;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
|
|
|
@ -6,9 +6,9 @@ import android.view.View;
|
|||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
|
@ -171,7 +171,7 @@ public class SelectWptCategoriesBottomSheetDialogFragment extends MenuBottomShee
|
|||
if (selectedGpx != null && selectedGpx.getGpxFile() != null) {
|
||||
return selectedGpx.getGpxFile();
|
||||
}
|
||||
return GPXUtilities.loadGPXFile(app, new File(filePath));
|
||||
return GPXUtilities.loadGPXFile(new File(filePath));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -12,8 +12,8 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
|
|
|
@ -15,8 +15,8 @@ import android.widget.ImageView;
|
|||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
|
@ -187,7 +187,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
|
|||
if (selectedGpx != null && selectedGpx.getGpxFile() != null) {
|
||||
return selectedGpx.getGpxFile();
|
||||
}
|
||||
return GPXUtilities.loadGPXFile(app, new File(filePath));
|
||||
return GPXUtilities.loadGPXFile(new File(filePath));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -467,7 +467,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
|
|||
gpxFile[0] = selectedGpxFile.getGpxFile();
|
||||
} else {
|
||||
// TODO IO load in another thread ?
|
||||
gpxFile[0] = GPXUtilities.loadGPXFile(app, new File(gpxPath));
|
||||
gpxFile[0] = GPXUtilities.loadGPXFile(new File(gpxPath));
|
||||
}
|
||||
switchGpxVisibility(gpxFile[0], selectedGpxFile, !disabled);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import android.view.ViewGroup;
|
|||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GeocodingLookupService.AddressLookupRequest;
|
||||
import net.osmand.plus.GeocodingLookupService.OnAddressLookupResult;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
|
|
|
@ -5,8 +5,8 @@ import android.util.Pair;
|
|||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.TrkSegment;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.measurementtool.command.MeasurementCommandManager;
|
||||
import net.osmand.plus.routing.RouteCalculationParams;
|
||||
|
|
|
@ -38,16 +38,17 @@ import net.osmand.CallbackWithObject;
|
|||
import net.osmand.IndexConstants;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.Route;
|
||||
import net.osmand.plus.GPXUtilities.Track;
|
||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.Route;
|
||||
import net.osmand.GPXUtilities.Track;
|
||||
import net.osmand.GPXUtilities.TrkSegment;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.TrackActivity;
|
||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||
|
@ -1209,7 +1210,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
final SaveType saveType,
|
||||
final boolean close) {
|
||||
|
||||
new AsyncTask<Void, Void, String>() {
|
||||
new AsyncTask<Void, Void, Exception>() {
|
||||
|
||||
private ProgressDialog progressDialog;
|
||||
private File toSave;
|
||||
|
@ -1226,7 +1227,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected String doInBackground(Void... voids) {
|
||||
protected Exception doInBackground(Void... voids) {
|
||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||
MapActivity activity = getMapActivity();
|
||||
List<WptPt> points = editingCtx.getPoints();
|
||||
|
@ -1235,7 +1236,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
if (gpx == null) {
|
||||
toSave = new File(dir, fileName);
|
||||
String trackName = fileName.substring(0,fileName.length()-GPX_SUFFIX.length());
|
||||
GPXFile gpx = new GPXFile();
|
||||
GPXFile gpx = new GPXFile(Version.getFullVersion(activity.getMyApplication()));
|
||||
if (measurementLayer != null) {
|
||||
if (saveType == SaveType.LINE) {
|
||||
TrkSegment segment = new TrkSegment();
|
||||
|
@ -1266,7 +1267,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
}
|
||||
}
|
||||
if (activity != null) {
|
||||
String res = GPXUtilities.writeGpxFile(toSave, gpx, activity.getMyApplication());
|
||||
Exception res = GPXUtilities.writeGpxFile(toSave, gpx);
|
||||
gpx.path = toSave.getAbsolutePath();
|
||||
if (showOnMap) {
|
||||
activity.getMyApplication().getSelectedGpxHelper().selectGpxFile(gpx, true, false);
|
||||
|
@ -1302,7 +1303,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
}
|
||||
}
|
||||
if (activity != null) {
|
||||
String res = GPXUtilities.writeGpxFile(toSave, gpx, activity.getMyApplication());
|
||||
Exception res = GPXUtilities.writeGpxFile(toSave, gpx);
|
||||
if (showOnMap) {
|
||||
SelectedGpxFile sf = activity.getMyApplication().getSelectedGpxHelper().selectGpxFile(gpx, true, false);
|
||||
if (sf != null) {
|
||||
|
@ -1318,7 +1319,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String warning) {
|
||||
protected void onPostExecute(Exception warning) {
|
||||
MapActivity activity = getMapActivity();
|
||||
if (progressDialog != null && progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
|
@ -1338,7 +1339,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(activity, warning, Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(activity, warning.getMessage(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadPoint;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.TrkSegment;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.views.ContextMenuLayer;
|
||||
|
@ -182,14 +182,13 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
|||
lineAttrs.updatePaints(view.getApplication(), settings, tb);
|
||||
|
||||
TrkSegment before = editingCtx.getBeforeTrkSegmentLine();
|
||||
before.renders.clear();
|
||||
before.renders.add(new Renderable.StandardTrack(new ArrayList<>(before.points), 17.2));
|
||||
before.drawRenderers(view.getZoom(), lineAttrs.paint, canvas, tb);
|
||||
new Renderable.StandardTrack(new ArrayList<>(before.points), 17.2).
|
||||
drawSegment(view.getZoom(), lineAttrs.paint, canvas, tb);
|
||||
|
||||
TrkSegment after = editingCtx.getAfterTrkSegmentLine();
|
||||
after.renders.clear();
|
||||
after.renders.add(new Renderable.StandardTrack(new ArrayList<>(after.points), 17.2));
|
||||
after.drawRenderers(view.getZoom(), lineAttrs.paint, canvas, tb);
|
||||
new Renderable.StandardTrack(new ArrayList<>(after.points), 17.2).
|
||||
drawSegment(view.getZoom(), lineAttrs.paint, canvas, tb);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package net.osmand.plus.measurementtool;
|
||||
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.GPXUtilities;
|
||||
|
||||
public class NewGpxData {
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import android.support.annotation.Nullable;
|
|||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
|
|
@ -12,7 +12,7 @@ import android.widget.ImageButton;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.R;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package net.osmand.plus.measurementtool.command;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.measurementtool.MeasurementToolLayer;
|
||||
|
||||
public class AddPointCommand extends MeasurementModeCommand {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package net.osmand.plus.measurementtool.command;
|
||||
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.measurementtool.MeasurementToolLayer;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package net.osmand.plus.measurementtool.command;
|
||||
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.measurementtool.MeasurementToolLayer;
|
||||
|
||||
public class MovePointCommand extends MeasurementModeCommand {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package net.osmand.plus.measurementtool.command;
|
||||
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.measurementtool.MeasurementToolLayer;
|
||||
|
||||
public class RemovePointCommand extends MeasurementModeCommand {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package net.osmand.plus.measurementtool.command;
|
||||
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.measurementtool.MeasurementToolLayer;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -14,8 +14,8 @@ import android.widget.TextView;
|
|||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.OsmAndAppCustomization;
|
||||
|
@ -271,7 +271,7 @@ public class DashTrackFragment extends DashBaseFragment {
|
|||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showOnMap(GPXUtilities.loadGPXFile(app, f));
|
||||
showOnMap(GPXUtilities.loadGPXFile(f));
|
||||
}
|
||||
};
|
||||
run.run();
|
||||
|
|
|
@ -51,11 +51,11 @@ import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
|
|||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.GPXDatabase;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.plus.GPXUtilities.Track;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.GPXUtilities.Track;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
|
@ -704,7 +704,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
}
|
||||
|
||||
private void showGpxOnMap(GpxInfo info) {
|
||||
info.setGpx(GPXUtilities.loadGPXFile(app, info.file));
|
||||
info.setGpx(GPXUtilities.loadGPXFile(info.file));
|
||||
boolean e = true;
|
||||
if (info.gpx != null) {
|
||||
WptPt loc = info.gpx.findPointToShow();
|
||||
|
@ -1316,7 +1316,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
Track generalTrack = null;
|
||||
if (gpxInfo.gpx == null) {
|
||||
if (gpxInfo.file != null) {
|
||||
gpxFile = GPXUtilities.loadGPXFile(getActivity(), gpxInfo.file);
|
||||
gpxFile = GPXUtilities.loadGPXFile(gpxInfo.file);
|
||||
}
|
||||
} else {
|
||||
gpxFile = gpxInfo.gpx;
|
||||
|
@ -1532,7 +1532,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
for (GpxInfo info : params) {
|
||||
if (!isCancelled()) {
|
||||
if (!info.currentlyRecordingTrack) {
|
||||
info.setGpx(GPXUtilities.loadGPXFile(app, info.file));
|
||||
info.setGpx(GPXUtilities.loadGPXFile(info.file));
|
||||
}
|
||||
publishProgress(info);
|
||||
}
|
||||
|
@ -1612,7 +1612,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
if (item == null
|
||||
|| item.getFileLastModifiedTime() != gpxFile.lastModified()
|
||||
|| item.getAnalysis().wptCategoryNames == null) {
|
||||
GPXFile f = GPXUtilities.loadGPXFile(app, gpxFile);
|
||||
GPXFile f = GPXUtilities.loadGPXFile(gpxFile);
|
||||
GPXTrackAnalysis analysis = f.getAnalysis(gpxFile.lastModified());
|
||||
if (item == null) {
|
||||
item = new GpxDataItem(gpxFile, analysis);
|
||||
|
|
|
@ -23,9 +23,9 @@ import android.widget.ImageView;
|
|||
import android.widget.LinearLayout;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
|
@ -276,7 +276,7 @@ public class EditTrackGroupDialogFragment extends MenuBottomSheetDialogFragment
|
|||
protected Void doInBackground(Void... voids) {
|
||||
GPXFile gpxFile = group.getGpx();
|
||||
if (gpxFile != null && !gpxFile.showCurrentTrack && wasUpdated) {
|
||||
GPXUtilities.writeGpxFile(new File(gpxFile.path), gpxFile, app);
|
||||
GPXUtilities.writeGpxFile(new File(gpxFile.path), gpxFile);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ import android.widget.ProgressBar;
|
|||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
|
|
|
@ -38,9 +38,9 @@ import net.osmand.data.PointDescription;
|
|||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.plus.GPXDatabase;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
|
||||
|
|
|
@ -16,9 +16,9 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.TrkSegment;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -238,16 +238,17 @@ public class TrackBitmapDrawer {
|
|||
if (color == 0) {
|
||||
color = ts.getColor(trackColor);
|
||||
}
|
||||
if (ts.renders.isEmpty() // only do once (CODE HERE NEEDS TO BE UI INSTEAD)
|
||||
&& !ts.points.isEmpty()) { // hmmm. 0-point tracks happen, but.... how?
|
||||
if (ts.renderer == null && !ts.points.isEmpty()) {
|
||||
if (g.isShowCurrentTrack()) {
|
||||
ts.renders.add(new Renderable.CurrentTrack(ts.points));
|
||||
ts.renderer = new Renderable.CurrentTrack(ts.points);
|
||||
} else {
|
||||
ts.renders.add(new Renderable.StandardTrack(ts.points, 17.2));
|
||||
ts.renderer = new Renderable.StandardTrack(ts.points, 17.2);
|
||||
}
|
||||
}
|
||||
paint.setColor(color == 0 ? trackColor : color);
|
||||
ts.drawRenderers(tileBox.getZoom(), paint, canvas, tileBox);
|
||||
if(ts.renderer instanceof Renderable.RenderableSegment) {
|
||||
((Renderable.RenderableSegment)ts.renderer).drawSegment(tileBox.getZoom(), paint, canvas, tileBox);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,9 +47,9 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
|
||||
|
@ -1269,7 +1269,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
|
|||
}
|
||||
for (final String f : files.keySet()) {
|
||||
File fout = new File(dir, f + ".gpx");
|
||||
GPXUtilities.writeGpxFile(fout, gpx, app);
|
||||
GPXUtilities.writeGpxFile(fout, gpx);
|
||||
}
|
||||
return shouldClearPath;
|
||||
}
|
||||
|
@ -1327,7 +1327,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
|
|||
}
|
||||
}
|
||||
if (!gpx.showCurrentTrack) {
|
||||
GPXUtilities.writeGpxFile(new File(gpx.path), gpx, app);
|
||||
GPXUtilities.writeGpxFile(new File(gpx.path), gpx);
|
||||
boolean selected = app.getSelectedGpxHelper().getSelectedFileByPath(gpx.path) != null;
|
||||
if (selected) {
|
||||
app.getSelectedGpxHelper().setGpxFileToDisplay(gpx);
|
||||
|
|
|
@ -41,12 +41,12 @@ import net.osmand.AndroidUtils;
|
|||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.plus.GPXUtilities.Track;
|
||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.GPXUtilities.Track;
|
||||
import net.osmand.GPXUtilities.TrkSegment;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
|
||||
|
@ -1220,7 +1220,7 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit
|
|||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
GPXUtilities.writeGpxFile(new File(gpx.path), gpx, app);
|
||||
GPXUtilities.writeGpxFile(new File(gpx.path), gpx);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,13 +34,14 @@ import net.osmand.data.PointDescription;
|
|||
import net.osmand.osm.edit.Entity;
|
||||
import net.osmand.osm.edit.Node;
|
||||
import net.osmand.osm.edit.Way;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.ActionBarProgressActivity;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.OsmandActionBarActivity;
|
||||
|
@ -755,7 +756,7 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
|
|||
}
|
||||
}
|
||||
} else {
|
||||
GPXFile gpx = new GPXFile();
|
||||
GPXFile gpx = new GPXFile(Version.getFullVersion(getMyApplication()));
|
||||
for (OsmPoint point : points) {
|
||||
if (point.getGroup() == Group.POI) {
|
||||
OpenstreetmapPoint p = (OpenstreetmapPoint) point;
|
||||
|
@ -777,7 +778,7 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
|
|||
gpx.addPoint(wpt);
|
||||
}
|
||||
}
|
||||
GPXUtilities.writeGpxFile(osmchange, gpx, getMyApplication());
|
||||
GPXUtilities.writeGpxFile(osmchange, gpx);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -33,7 +33,7 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.plus.GeocodingLookupService;
|
||||
import net.osmand.plus.GeocodingLookupService.AddressLookupRequest;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
|
@ -50,6 +50,7 @@ import net.osmand.plus.activities.SettingsBaseActivity;
|
|||
import net.osmand.plus.activities.actions.AppModeDialog;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.helpers.AvoidSpecificRoads;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.plus.helpers.MapMarkerDialogHelper;
|
||||
import net.osmand.plus.helpers.WaypointHelper;
|
||||
import net.osmand.plus.mapcontextmenu.other.FavouritesBottomSheetMenuFragment;
|
||||
|
@ -367,7 +368,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
routeCards.clear();
|
||||
|
||||
if (isBasicRouteCalculated()) {
|
||||
GPXUtilities.GPXFile gpx = GPXUtilities.makeGpxFromRoute(routingHelper.getRoute());
|
||||
GPXUtilities.GPXFile gpx = GpxUiHelper.makeGpxFromRoute(routingHelper.getRoute(), mapActivity.getMyApplication());
|
||||
if (gpx != null) {
|
||||
routeCards.add(new SimpleRouteCard(mapActivity, gpx));
|
||||
LinearLayout cardsContainer = (LinearLayout) mainView.findViewById(R.id.route_menu_cards_container);
|
||||
|
|
|
@ -14,7 +14,7 @@ import android.widget.TextView;
|
|||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.plus.OsmAndLocationProvider;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
|
|
|
@ -20,7 +20,7 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
|
|
|
@ -12,7 +12,7 @@ import com.github.mikephil.charting.data.LineData;
|
|||
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
|
|
@ -10,14 +10,15 @@ import net.osmand.PlatformUtil;
|
|||
import net.osmand.binary.BinaryMapIndexReader;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.LocationPoint;
|
||||
import net.osmand.data.WptLocationPoint;
|
||||
import net.osmand.osm.io.NetworkUtils;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.Route;
|
||||
import net.osmand.plus.GPXUtilities.Track;
|
||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.Route;
|
||||
import net.osmand.GPXUtilities.Track;
|
||||
import net.osmand.GPXUtilities.TrkSegment;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||
|
@ -235,7 +236,10 @@ public class RouteProvider {
|
|||
useIntermediatePointsRTE = builder.useIntermediatePointsRTE;
|
||||
builder.calculateOsmAndRoute = false; // Disabled temporary builder.calculateOsmAndRoute;
|
||||
if (!file.isPointsEmpty()) {
|
||||
wpt = new ArrayList<LocationPoint>(file.getPoints());
|
||||
wpt = new ArrayList<LocationPoint>(file.getPoints().size());
|
||||
for(WptPt w : file.getPoints()) {
|
||||
wpt.add(new WptLocationPoint(w));
|
||||
}
|
||||
}
|
||||
if (file.isCloudmadeRouteFile() || OSMAND_ROUTER.equals(file.author)) {
|
||||
directions = parseOsmAndGPXRoute(points, file, OSMAND_ROUTER.equals(file.author), builder.leftSide, 10);
|
||||
|
@ -948,7 +952,7 @@ public class RouteProvider {
|
|||
List<RouteDirectionInfo> directionInfo = srcRoute.getImmutableAllDirections();
|
||||
int currentDirectionInfo = srcRoute.currentDirectionInfo;
|
||||
|
||||
GPXFile gpx = new GPXFile();
|
||||
GPXFile gpx = new GPXFile(Version.getFullVersion(ctx));
|
||||
gpx.author = OSMAND_ROUTER;
|
||||
Track track = new Track();
|
||||
track.name = name;
|
||||
|
@ -1176,8 +1180,7 @@ public class RouteProvider {
|
|||
return new RouteCalculationResult(gpxMessage);
|
||||
}
|
||||
|
||||
GPXFile gpxFile = GPXUtilities.loadGPXFile(
|
||||
ctx, new ByteArrayInputStream(gpxMessage.getBytes("UTF-8")));
|
||||
GPXFile gpxFile = GPXUtilities.loadGPXFile(new ByteArrayInputStream(gpxMessage.getBytes("UTF-8")));
|
||||
|
||||
for (Track track : gpxFile.tracks) {
|
||||
for (TrkSegment ts : track.segments) {
|
||||
|
|
|
@ -6,7 +6,7 @@ import net.osmand.PlatformUtil;
|
|||
import net.osmand.ValueHolder;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.NavigationService;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
|
|
@ -60,9 +60,9 @@ import net.osmand.osm.PoiType;
|
|||
import net.osmand.plus.AppInitializer;
|
||||
import net.osmand.plus.AppInitializer.AppInitializeListener;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.LockableViewPager;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
|
||||
|
@ -70,6 +70,7 @@ import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.MapActivity.ShowQuickSearchMode;
|
||||
import net.osmand.plus.helpers.SearchHistoryHelper;
|
||||
|
@ -2123,7 +2124,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
final AsyncTask<Void, Void, GPXFile> exportTask = new AsyncTask<Void, Void, GPXFile>() {
|
||||
@Override
|
||||
protected GPXFile doInBackground(Void... params) {
|
||||
GPXFile gpx = new GPXFile();
|
||||
GPXFile gpx = new GPXFile(Version.getFullVersion(getMyApplication()));
|
||||
for (HistoryEntry h : historyEntries) {
|
||||
WptPt pt = new WptPt();
|
||||
pt.lat = h.getLat();
|
||||
|
@ -2151,11 +2152,11 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
dir.mkdir();
|
||||
}
|
||||
File dst = new File(dir, "History.gpx");
|
||||
GPXUtilities.writeGpxFile(dst, gpxFile, app);
|
||||
GPXUtilities.writeGpxFile(dst, gpxFile);
|
||||
|
||||
final Intent sendIntent = new Intent();
|
||||
sendIntent.setAction(Intent.ACTION_SEND);
|
||||
sendIntent.putExtra(Intent.EXTRA_TEXT, "History.gpx:\n\n\n" + GPXUtilities.asString(gpxFile, app));
|
||||
sendIntent.putExtra(Intent.EXTRA_TEXT, "History.gpx:\n\n\n" + GPXUtilities.asString(gpxFile));
|
||||
sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_history_subject));
|
||||
sendIntent.putExtra(Intent.EXTRA_STREAM, AndroidUtils.getUriForFile(getMapActivity(), dst));
|
||||
sendIntent.setType("text/plain");
|
||||
|
|
|
@ -11,12 +11,13 @@ import net.osmand.data.FavouritePoint;
|
|||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.WptLocationPoint;
|
||||
import net.osmand.osm.AbstractPoiType;
|
||||
import net.osmand.osm.MapPoiTypes;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -186,7 +187,7 @@ public class QuickSearchHelper implements ResourceListener {
|
|||
if (selectedGpx != null) {
|
||||
for (GPXUtilities.WptPt point : selectedGpx.getGpxFile().getPoints()) {
|
||||
SearchResult sr = new SearchResult(phrase);
|
||||
sr.localeName = point.getPointDescription(app).getName();
|
||||
sr.localeName = point.name;
|
||||
sr.object = point;
|
||||
sr.priority = SEARCH_WPT_OBJECT_PRIORITY;
|
||||
sr.objectType = ObjectType.WPT;
|
||||
|
|
|
@ -18,7 +18,8 @@ import net.osmand.data.FavouritePoint;
|
|||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.Street;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.data.WptLocationPoint;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -281,7 +282,7 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
|||
break;
|
||||
case WPT:
|
||||
GPXUtilities.WptPt wpt = (GPXUtilities.WptPt) object;
|
||||
pointDescription = wpt.getPointDescription(getMyApplication());
|
||||
pointDescription = new WptLocationPoint(wpt).getPointDescription(app);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ import net.osmand.osm.PoiCategory;
|
|||
import net.osmand.osm.PoiFilter;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
|
|
@ -10,7 +10,7 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
|
|
@ -2,7 +2,7 @@ package net.osmand.plus.views;
|
|||
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -27,10 +27,10 @@ import net.osmand.data.QuadRect;
|
|||
import net.osmand.data.QuadTree;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.TrkSegment;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
|
@ -98,7 +98,6 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
|
||||
private OsmandRenderer osmandRenderer;
|
||||
|
||||
private List<TrkSegment> points;
|
||||
private GPXFile gpx;
|
||||
|
||||
private ContextMenuLayer contextMenuLayer;
|
||||
|
@ -194,27 +193,22 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
|
||||
@Override
|
||||
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
||||
if (points != null) {
|
||||
updatePaints(0, false, false, settings, tileBox);
|
||||
for (TrkSegment ts : points)
|
||||
ts.drawRenderers(view.getZoom(), paint, canvas, tileBox);
|
||||
} else {
|
||||
List<SelectedGpxFile> selectedGPXFiles = selectedGpxHelper.getSelectedGPXFiles();
|
||||
cache.clear();
|
||||
currentTrackColor = view.getSettings().CURRENT_TRACK_COLOR.get();
|
||||
if (!selectedGPXFiles.isEmpty()) {
|
||||
drawSelectedFilesSegments(canvas, tileBox, selectedGPXFiles, settings);
|
||||
canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
|
||||
if (trackChartPoints != null) {
|
||||
drawXAxisPoints(canvas, tileBox);
|
||||
}
|
||||
drawSelectedFilesSplits(canvas, tileBox, selectedGPXFiles, settings);
|
||||
drawSelectedFilesPoints(canvas, tileBox, selectedGPXFiles);
|
||||
}
|
||||
if (textLayer != null && isTextVisible()) {
|
||||
textLayer.putData(this, cache);
|
||||
List<SelectedGpxFile> selectedGPXFiles = selectedGpxHelper.getSelectedGPXFiles();
|
||||
cache.clear();
|
||||
currentTrackColor = view.getSettings().CURRENT_TRACK_COLOR.get();
|
||||
if (!selectedGPXFiles.isEmpty()) {
|
||||
drawSelectedFilesSegments(canvas, tileBox, selectedGPXFiles, settings);
|
||||
canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
|
||||
if (trackChartPoints != null) {
|
||||
drawXAxisPoints(canvas, tileBox);
|
||||
}
|
||||
drawSelectedFilesSplits(canvas, tileBox, selectedGPXFiles, settings);
|
||||
drawSelectedFilesPoints(canvas, tileBox, selectedGPXFiles);
|
||||
}
|
||||
if (textLayer != null && isTextVisible()) {
|
||||
textLayer.putData(this, cache);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private int updatePaints(int color, boolean routePoints, boolean currentTrack, DrawSettings nightMode, RotatedTileBox tileBox) {
|
||||
|
@ -519,16 +513,17 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
if (color == 0) {
|
||||
color = ts.getColor(cachedColor);
|
||||
}
|
||||
if (ts.renders.isEmpty() // only do once (CODE HERE NEEDS TO BE UI INSTEAD)
|
||||
&& !ts.points.isEmpty()) { // hmmm. 0-point tracks happen, but.... how?
|
||||
if (ts.renderer == null && !ts.points.isEmpty()) {
|
||||
if (currentTrack) {
|
||||
ts.renders.add(new Renderable.CurrentTrack(ts.points));
|
||||
ts.renderer = new Renderable.CurrentTrack(ts.points);
|
||||
} else {
|
||||
ts.renders.add(new Renderable.StandardTrack(ts.points, 17.2));
|
||||
ts.renderer = new Renderable.StandardTrack(ts.points, 17.2);
|
||||
}
|
||||
}
|
||||
updatePaints(color, selectedGpxFile.isRoutePoints(), currentTrack, settings, tileBox);
|
||||
ts.drawRenderers(view.getZoom(), paint, canvas, tileBox);
|
||||
if(ts.renderer instanceof Renderable.RenderableSegment) {
|
||||
((Renderable.RenderableSegment) ts.renderer).drawSegment(view.getZoom(), paint, canvas, tileBox);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -653,12 +648,6 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
}
|
||||
|
||||
|
||||
public void setGivenGpx(GPXFile gpx) {
|
||||
this.gpx = gpx;
|
||||
this.points = (gpx == null ? null : gpx.proccessPoints());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isObjectMovable(Object o) {
|
||||
return o instanceof WptPt;
|
||||
|
@ -695,7 +684,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
}
|
||||
}
|
||||
|
||||
static class SaveGpxFileAsyncTask extends AsyncTask<GPXFile, Void, String> {
|
||||
static class SaveGpxFileAsyncTask extends AsyncTask<GPXFile, Void, Exception> {
|
||||
private final OsmandApplication app;
|
||||
@Nullable
|
||||
private final ContextMenuLayer.ApplyMovedObjectCallback callback;
|
||||
|
@ -711,13 +700,13 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
}
|
||||
|
||||
@Override
|
||||
protected String doInBackground(GPXFile... params) {
|
||||
protected Exception doInBackground(GPXFile... params) {
|
||||
GPXFile gpxFile = params[0];
|
||||
return GPXUtilities.writeGpxFile(new File(gpxFile.path), gpxFile, app);
|
||||
return GPXUtilities.writeGpxFile(new File(gpxFile.path), gpxFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String errorMessage) {
|
||||
protected void onPostExecute(Exception errorMessage) {
|
||||
if (callback != null) {
|
||||
callback.onApplyMovedObject(errorMessage == null, point);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadPoint;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
import net.osmand.GPXUtilities.TrkSegment;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmAndConstants;
|
||||
|
@ -251,9 +251,8 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
|
||||
if (route != null && route.points.size() > 0) {
|
||||
planRouteAttrs.updatePaints(app, nightMode, tileBox);
|
||||
route.renders.clear();
|
||||
route.renders.add(new Renderable.StandardTrack(new ArrayList<>(route.points), 17.2));
|
||||
route.drawRenderers(view.getZoom(), defaultAppMode ? planRouteAttrs.paint : planRouteAttrs.paint2, canvas, tileBox);
|
||||
new Renderable.StandardTrack(new ArrayList<>(route.points), 17.2).
|
||||
drawSegment(view.getZoom(), defaultAppMode ? planRouteAttrs.paint : planRouteAttrs.paint2, canvas, tileBox);
|
||||
}
|
||||
|
||||
if (settings.SHOW_LINES_TO_FIRST_MARKERS.get() && myLoc != null) {
|
||||
|
|
|
@ -6,7 +6,7 @@ import android.os.AsyncTask;
|
|||
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -47,6 +47,7 @@ public class Renderable {
|
|||
|
||||
protected void drawSingleSegment(double zoom, Paint p, Canvas canvas, RotatedTileBox tileBox) {}
|
||||
|
||||
|
||||
public void drawSegment(double zoom, Paint p, Canvas canvas, RotatedTileBox tileBox) {
|
||||
if (QuadRect.trivialOverlap(tileBox.getLatLonBounds(), trackBounds)) { // is visible?
|
||||
startCuller(zoom);
|
||||
|
|
|
@ -26,7 +26,7 @@ import net.osmand.data.TransportStop;
|
|||
import net.osmand.osm.edit.Node;
|
||||
import net.osmand.osm.edit.OSMSettings;
|
||||
import net.osmand.osm.edit.Way;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
|
|
|
@ -13,7 +13,7 @@ import android.webkit.WebViewClient;
|
|||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
|
|
@ -8,7 +8,7 @@ import android.support.annotation.NonNull;
|
|||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.Size;
|
||||
import android.text.TextUtils;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
|
|
|
@ -12,8 +12,8 @@ import net.osmand.Location;
|
|||
import net.osmand.OsmAndCollator;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
||||
|
@ -615,7 +615,7 @@ public class TravelDbHelper {
|
|||
res.aggregatedPartOf = cursor.getString(11);
|
||||
try {
|
||||
String gpxContent = Algorithms.gzipToString(cursor.getBlob(6));
|
||||
res.gpxFile = GPXUtilities.loadGPXFile(application, new ByteArrayInputStream(gpxContent.getBytes("UTF-8")));
|
||||
res.gpxFile = GPXUtilities.loadGPXFile(new ByteArrayInputStream(gpxContent.getBytes("UTF-8")));
|
||||
} catch (IOException e) {
|
||||
LOG.error(e.getMessage(), e);
|
||||
}
|
||||
|
@ -639,7 +639,7 @@ public class TravelDbHelper {
|
|||
final GPXFile gpx = article.getGpxFile();
|
||||
File file = application.getAppPath(IndexConstants.GPX_TRAVEL_DIR + getGPXName(article));
|
||||
if (!file.exists()) {
|
||||
GPXUtilities.writeGpxFile(file, gpx, application);
|
||||
GPXUtilities.writeGpxFile(file, gpx);
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue