forked from upstream-mirrors/OpenTracks
@@ -23,9 +23,9 @@ import androidx.annotation.NonNull;
|
||||
|
||||
import java.io.OutputStream;
|
||||
|
||||
import de.dennisguse.opentracks.content.data.Marker;
|
||||
import de.dennisguse.opentracks.content.data.Track;
|
||||
import de.dennisguse.opentracks.content.data.TrackPoint;
|
||||
import de.dennisguse.opentracks.content.data.Waypoint;
|
||||
import de.dennisguse.opentracks.content.provider.ContentProviderUtils;
|
||||
import de.dennisguse.opentracks.content.provider.TrackPointIterator;
|
||||
import de.dennisguse.opentracks.util.LocationUtils;
|
||||
@@ -98,7 +98,7 @@ public class FileTrackExporter implements TrackExporter {
|
||||
* I am leaving the number of waypoints very high which should not be a problem, because we don't try to load them into objects all at the same time.
|
||||
*/
|
||||
boolean hasWaypoints = false;
|
||||
try (Cursor cursor = contentProviderUtils.getWaypointCursor(track.getId(), null, ContentProviderUtils.MAX_LOADED_WAYPOINTS_POINTS)) {
|
||||
try (Cursor cursor = contentProviderUtils.getMarkerCursor(track.getId(), null, ContentProviderUtils.MAX_LOADED_MARKERS)) {
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
for (int i = 0; i < cursor.getCount(); i++) {
|
||||
if (Thread.interrupted()) {
|
||||
@@ -108,7 +108,7 @@ public class FileTrackExporter implements TrackExporter {
|
||||
trackWriter.writeBeginWaypoints(track);
|
||||
hasWaypoints = true;
|
||||
}
|
||||
Waypoint waypoint = contentProviderUtils.createWaypoint(cursor);
|
||||
Marker waypoint = contentProviderUtils.createMarker(cursor);
|
||||
trackWriter.writeWaypoint(waypoint);
|
||||
|
||||
cursor.moveToNext();
|
||||
|
||||
@@ -23,9 +23,9 @@ import java.io.PrintWriter;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
import de.dennisguse.opentracks.content.data.Marker;
|
||||
import de.dennisguse.opentracks.content.data.Track;
|
||||
import de.dennisguse.opentracks.content.data.TrackPoint;
|
||||
import de.dennisguse.opentracks.content.data.Waypoint;
|
||||
import de.dennisguse.opentracks.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -130,7 +130,7 @@ public class GpxTrackWriter implements TrackWriter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeWaypoint(Waypoint waypoint) {
|
||||
public void writeWaypoint(Marker waypoint) {
|
||||
if (printWriter != null) {
|
||||
Location location = waypoint.getLocation();
|
||||
printWriter.println("<wpt " + formatLocation(location) + ">");
|
||||
|
||||
@@ -26,9 +26,9 @@ import java.util.List;
|
||||
|
||||
import de.dennisguse.opentracks.R;
|
||||
import de.dennisguse.opentracks.content.DescriptionGenerator;
|
||||
import de.dennisguse.opentracks.content.data.Marker;
|
||||
import de.dennisguse.opentracks.content.data.Track;
|
||||
import de.dennisguse.opentracks.content.data.TrackPoint;
|
||||
import de.dennisguse.opentracks.content.data.Waypoint;
|
||||
import de.dennisguse.opentracks.content.provider.ContentProviderUtils;
|
||||
import de.dennisguse.opentracks.util.FileUtils;
|
||||
import de.dennisguse.opentracks.util.StringUtils;
|
||||
@@ -163,7 +163,7 @@ public class KmlTrackWriter implements TrackWriter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeWaypoint(Waypoint waypoint) {
|
||||
public void writeWaypoint(Marker waypoint) {
|
||||
if (printWriter != null && exportTrackDetail) {
|
||||
boolean existsPhoto = FileUtils.getPhotoFileIfExists(context, waypoint.getTrackId(), waypoint.getPhotoURI()) != null;
|
||||
if (waypoint.hasPhoto() && exportPhotos && existsPhoto) {
|
||||
@@ -335,7 +335,7 @@ public class KmlTrackWriter implements TrackWriter {
|
||||
* @param waypoint Waypoint object.
|
||||
* @param heading the heading.
|
||||
*/
|
||||
private void writePhotoOverlay(Waypoint waypoint, float heading) {
|
||||
private void writePhotoOverlay(Marker waypoint, float heading) {
|
||||
if (exportTrackDetail) {
|
||||
printWriter.println("<PhotoOverlay>");
|
||||
printWriter.println("<name>" + StringUtils.formatCData(waypoint.getName()) + "</name>");
|
||||
|
||||
@@ -31,8 +31,8 @@ import java.io.OutputStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import de.dennisguse.opentracks.content.data.Marker;
|
||||
import de.dennisguse.opentracks.content.data.Track;
|
||||
import de.dennisguse.opentracks.content.data.Waypoint;
|
||||
import de.dennisguse.opentracks.content.provider.ContentProviderUtils;
|
||||
import de.dennisguse.opentracks.util.FileUtils;
|
||||
|
||||
@@ -99,13 +99,13 @@ public class KmzTrackExporter implements TrackExporter {
|
||||
|
||||
private void addImages(Context context, Track[] tracks, ZipOutputStream zipOutputStream) throws InterruptedException, IOException {
|
||||
for (Track track : tracks) {
|
||||
try (Cursor cursor = contentProviderUtils.getWaypointCursor(track.getId(), null, -1)) {
|
||||
try (Cursor cursor = contentProviderUtils.getMarkerCursor(track.getId(), null, -1)) {
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
for (int i = 0; i < cursor.getCount(); i++) {
|
||||
if (Thread.interrupted()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
Waypoint waypoint = contentProviderUtils.createWaypoint(cursor);
|
||||
Marker waypoint = contentProviderUtils.createMarker(cursor);
|
||||
if (waypoint.hasPhoto()) {
|
||||
Uri uriPhoto = waypoint.getPhotoURI();
|
||||
boolean existsPhoto = FileUtils.getPhotoFileIfExists(context, track.getId(), uriPhoto) != null;
|
||||
@@ -121,7 +121,7 @@ public class KmzTrackExporter implements TrackExporter {
|
||||
}
|
||||
}
|
||||
|
||||
private void addImage(Context context, ZipOutputStream zipOutputStream, Uri uri, Waypoint waypoint) throws IOException {
|
||||
private void addImage(Context context, ZipOutputStream zipOutputStream, Uri uri, Marker waypoint) throws IOException {
|
||||
try (InputStream inputStream = context.getContentResolver().openInputStream(uri)) {
|
||||
ZipEntry zipEntry = new ZipEntry(buildKmzImageFilePath(waypoint));
|
||||
zipOutputStream.putNextEntry(zipEntry);
|
||||
@@ -150,7 +150,7 @@ public class KmzTrackExporter implements TrackExporter {
|
||||
*
|
||||
* @param waypoint Waypoint object.
|
||||
*/
|
||||
public static String buildKmzImageFilePath(Waypoint waypoint) {
|
||||
public static String buildKmzImageFilePath(Marker waypoint) {
|
||||
String ext = FileUtils.getExtension(waypoint.getPhotoUrl());
|
||||
ext = ext == null ? "" : "." + ext;
|
||||
return KMZ_IMAGES_DIR + File.separatorChar + FileUtils.sanitizeFileName(waypoint.getId() + ext);
|
||||
|
||||
@@ -17,9 +17,9 @@ package de.dennisguse.opentracks.io.file.exporter;
|
||||
|
||||
import java.io.OutputStream;
|
||||
|
||||
import de.dennisguse.opentracks.content.data.Marker;
|
||||
import de.dennisguse.opentracks.content.data.Track;
|
||||
import de.dennisguse.opentracks.content.data.TrackPoint;
|
||||
import de.dennisguse.opentracks.content.data.Waypoint;
|
||||
|
||||
/**
|
||||
* Interface for writing tracks to a file. The expected sequence of calls is:
|
||||
@@ -30,7 +30,7 @@ import de.dennisguse.opentracks.content.data.Waypoint;
|
||||
* For each track:
|
||||
* {@link #writeBeginWaypoints(Track)}
|
||||
* For each waypoint:
|
||||
* {@link #writeWaypoint(Waypoint)}
|
||||
* {@link #writeWaypoint(Marker)}
|
||||
* {@link #writeEndWaypoints()}
|
||||
* {@link #writeMultiTrackBegin()}
|
||||
* For each track:
|
||||
@@ -91,7 +91,7 @@ public interface TrackWriter {
|
||||
*
|
||||
* @param waypoint the waypoint
|
||||
*/
|
||||
void writeWaypoint(Waypoint waypoint);
|
||||
void writeWaypoint(Marker waypoint);
|
||||
|
||||
/**
|
||||
* Writes the beginning of the tracks.
|
||||
|
||||
+6
-6
@@ -39,9 +39,9 @@ import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
|
||||
import de.dennisguse.opentracks.R;
|
||||
import de.dennisguse.opentracks.content.data.Marker;
|
||||
import de.dennisguse.opentracks.content.data.Track;
|
||||
import de.dennisguse.opentracks.content.data.TrackPoint;
|
||||
import de.dennisguse.opentracks.content.data.Waypoint;
|
||||
import de.dennisguse.opentracks.content.provider.ContentProviderUtils;
|
||||
import de.dennisguse.opentracks.content.provider.TrackPointIterator;
|
||||
import de.dennisguse.opentracks.stats.TrackStatisticsUpdater;
|
||||
@@ -70,7 +70,7 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
||||
|
||||
private Track.Id importTrackId;
|
||||
private final List<Track.Id> trackIds = new ArrayList<>();
|
||||
private final List<Waypoint> waypoints = new ArrayList<>();
|
||||
private final List<Marker> waypoints = new ArrayList<>();
|
||||
|
||||
// The current element content
|
||||
//TODO Should be made private and getter be used by child classes.
|
||||
@@ -160,7 +160,7 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
||||
}
|
||||
|
||||
int waypointPosition = -1;
|
||||
Waypoint waypoint = null;
|
||||
Marker waypoint = null;
|
||||
TrackPoint trackPoint = null;
|
||||
TrackStatisticsUpdater trackStatisticsUpdater = new TrackStatisticsUpdater(track.getTrackStatistics().getStartTime_ms());
|
||||
// TODO Should not be necessary anymore?
|
||||
@@ -209,8 +209,8 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
||||
long duration = trackStatisticsUpdater.getTrackStatistics().getTotalTime();
|
||||
|
||||
// Insert waypoint
|
||||
Waypoint newWaypoint = new Waypoint(waypoint.getName(), waypointDescription, waypoint.getCategory(), icon, track.getId(), length, duration, trackPoint.getLocation(), waypoint.getPhotoUrl());
|
||||
contentProviderUtils.insertWaypoint(newWaypoint);
|
||||
Marker newWaypoint = new Marker(waypoint.getName(), waypointDescription, waypoint.getCategory(), icon, track.getId(), length, duration, trackPoint.getLocation(), waypoint.getPhotoUrl());
|
||||
contentProviderUtils.insertMarker(newWaypoint);
|
||||
}
|
||||
|
||||
// Load the next waypoint
|
||||
@@ -314,7 +314,7 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
||||
if (!LocationUtils.isValidLocation(trackPoint.getLocation())) {
|
||||
throw new SAXException(createErrorMessage("Invalid location detected: " + trackPoint));
|
||||
}
|
||||
Waypoint waypoint = new Waypoint(trackPoint.getLocation());
|
||||
Marker waypoint = new Marker(trackPoint.getLocation());
|
||||
|
||||
if (name != null) {
|
||||
waypoint.setName(name);
|
||||
|
||||
@@ -32,8 +32,8 @@ import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import de.dennisguse.opentracks.content.data.Marker;
|
||||
import de.dennisguse.opentracks.content.data.Track;
|
||||
import de.dennisguse.opentracks.content.data.Waypoint;
|
||||
import de.dennisguse.opentracks.content.provider.ContentProviderUtils;
|
||||
import de.dennisguse.opentracks.io.file.exporter.KmzTrackExporter;
|
||||
import de.dennisguse.opentracks.util.FileUtils;
|
||||
@@ -200,9 +200,9 @@ public class KmzTrackImporter implements TrackImporter {
|
||||
if (!trackId.isValid()) {
|
||||
// 1.- Gets all photo names in the waypoints of the track identified by id.
|
||||
ContentProviderUtils contentProviderUtils = new ContentProviderUtils(context);
|
||||
List<Waypoint> waypoints = contentProviderUtils.getWaypoints(trackId);
|
||||
List<Marker> waypoints = contentProviderUtils.getMarkers(trackId);
|
||||
List<String> photosName = new ArrayList<>();
|
||||
for (Waypoint w : waypoints) {
|
||||
for (Marker w : waypoints) {
|
||||
if (w.hasPhoto()) {
|
||||
String photoUrl = Uri.decode(w.getPhotoUrl());
|
||||
photosName.add(photoUrl.substring(photoUrl.lastIndexOf(File.separatorChar) + 1));
|
||||
|
||||
Reference in New Issue
Block a user