Add show arrows and show start finish gpx params
This commit is contained in:
parent
5dc3a5a484
commit
08a8281a8c
4 changed files with 138 additions and 10 deletions
|
@ -160,6 +160,30 @@ public class GPXUtilities {
|
||||||
getExtensionsToWrite().put("width", width);
|
getExtensionsToWrite().put("width", width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isShowArrows() {
|
||||||
|
String showArrows = null;
|
||||||
|
if (extensions != null) {
|
||||||
|
showArrows = extensions.get("showArrows");
|
||||||
|
}
|
||||||
|
return Boolean.parseBoolean(showArrows);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowArrows(boolean showArrows) {
|
||||||
|
getExtensionsToWrite().put("showArrows", String.valueOf(showArrows));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isShowStartFinish() {
|
||||||
|
String showStartFinish = null;
|
||||||
|
if (extensions != null) {
|
||||||
|
showStartFinish = extensions.get("showStartFinish");
|
||||||
|
}
|
||||||
|
return Boolean.parseBoolean(showStartFinish);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowStartFinish(boolean showStartFinish) {
|
||||||
|
getExtensionsToWrite().put("showStartFinish", String.valueOf(showStartFinish));
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, String> getExtensionsToWrite() {
|
public Map<String, String> getExtensionsToWrite() {
|
||||||
if (extensions == null) {
|
if (extensions == null) {
|
||||||
extensions = new LinkedHashMap<>();
|
extensions = new LinkedHashMap<>();
|
||||||
|
|
|
@ -57,6 +57,10 @@ public class GPXDatabase {
|
||||||
|
|
||||||
private static final String GPX_COL_JOIN_SEGMENTS = "joinSegments";
|
private static final String GPX_COL_JOIN_SEGMENTS = "joinSegments";
|
||||||
|
|
||||||
|
private static final String GPX_COL_SHOW_ARROWS = "showArrows";
|
||||||
|
|
||||||
|
private static final String GPX_COL_SHOW_START_FINISH = "showStartFinish";
|
||||||
|
|
||||||
private static final String GPX_COL_WIDTH = "width";
|
private static final String GPX_COL_WIDTH = "width";
|
||||||
|
|
||||||
public static final int GPX_SPLIT_TYPE_NO_SPLIT = -1;
|
public static final int GPX_SPLIT_TYPE_NO_SPLIT = -1;
|
||||||
|
@ -93,6 +97,8 @@ public class GPXDatabase {
|
||||||
GPX_COL_WPT_CATEGORY_NAMES + " TEXT, " +
|
GPX_COL_WPT_CATEGORY_NAMES + " TEXT, " +
|
||||||
GPX_COL_SHOW_AS_MARKERS + " int, " + // 1 = true, 0 = false
|
GPX_COL_SHOW_AS_MARKERS + " int, " + // 1 = true, 0 = false
|
||||||
GPX_COL_JOIN_SEGMENTS + " int, " + // 1 = true, 0 = false
|
GPX_COL_JOIN_SEGMENTS + " int, " + // 1 = true, 0 = false
|
||||||
|
GPX_COL_SHOW_ARROWS + " int, " + // 1 = true, 0 = false
|
||||||
|
GPX_COL_SHOW_START_FINISH + " int, " + // 1 = true, 0 = false
|
||||||
GPX_COL_WIDTH + " TEXT);";
|
GPX_COL_WIDTH + " TEXT);";
|
||||||
|
|
||||||
private static final String GPX_TABLE_SELECT = "SELECT " +
|
private static final String GPX_TABLE_SELECT = "SELECT " +
|
||||||
|
@ -122,6 +128,8 @@ public class GPXDatabase {
|
||||||
GPX_COL_WPT_CATEGORY_NAMES + ", " +
|
GPX_COL_WPT_CATEGORY_NAMES + ", " +
|
||||||
GPX_COL_SHOW_AS_MARKERS + ", " +
|
GPX_COL_SHOW_AS_MARKERS + ", " +
|
||||||
GPX_COL_JOIN_SEGMENTS + ", " +
|
GPX_COL_JOIN_SEGMENTS + ", " +
|
||||||
|
GPX_COL_SHOW_ARROWS + ", " +
|
||||||
|
GPX_COL_SHOW_START_FINISH + ", " +
|
||||||
GPX_COL_WIDTH +
|
GPX_COL_WIDTH +
|
||||||
" FROM " + GPX_TABLE_NAME;
|
" FROM " + GPX_TABLE_NAME;
|
||||||
|
|
||||||
|
@ -160,6 +168,8 @@ public class GPXDatabase {
|
||||||
private boolean apiImported;
|
private boolean apiImported;
|
||||||
private boolean showAsMarkers;
|
private boolean showAsMarkers;
|
||||||
private boolean joinSegments;
|
private boolean joinSegments;
|
||||||
|
private boolean showArrows;
|
||||||
|
private boolean showStartFinish;
|
||||||
|
|
||||||
public GpxDataItem(File file, GPXTrackAnalysis analysis) {
|
public GpxDataItem(File file, GPXTrackAnalysis analysis) {
|
||||||
this.file = file;
|
this.file = file;
|
||||||
|
@ -228,6 +238,22 @@ public class GPXDatabase {
|
||||||
this.joinSegments = joinSegments;
|
this.joinSegments = joinSegments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isShowArrows() {
|
||||||
|
return showArrows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowArrows(boolean showArrows) {
|
||||||
|
this.showArrows = showArrows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isShowStartFinish() {
|
||||||
|
return showStartFinish;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowStartFinish(boolean showStartFinish) {
|
||||||
|
this.showStartFinish = showStartFinish;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return file != null ? file.hashCode() : 0;
|
return file != null ? file.hashCode() : 0;
|
||||||
|
@ -357,7 +383,14 @@ public class GPXDatabase {
|
||||||
"WHERE " + GPX_COL_JOIN_SEGMENTS + " IS NULL", new Object[]{0});
|
"WHERE " + GPX_COL_JOIN_SEGMENTS + " IS NULL", new Object[]{0});
|
||||||
}
|
}
|
||||||
if (oldVersion < 11) {
|
if (oldVersion < 11) {
|
||||||
|
db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_SHOW_ARROWS + " int");
|
||||||
|
db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_SHOW_START_FINISH + " int");
|
||||||
db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_WIDTH + " TEXT");
|
db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_WIDTH + " TEXT");
|
||||||
|
|
||||||
|
db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_SHOW_ARROWS + " = ? " +
|
||||||
|
"WHERE " + GPX_COL_SHOW_ARROWS + " IS NULL", new Object[]{0});
|
||||||
|
db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_SHOW_START_FINISH + " = ? " +
|
||||||
|
"WHERE " + GPX_COL_SHOW_START_FINISH + " IS NULL", new Object[]{0});
|
||||||
}
|
}
|
||||||
db.execSQL("CREATE INDEX IF NOT EXISTS " + GPX_INDEX_NAME_DIR + " ON " + GPX_TABLE_NAME + " (" + GPX_COL_NAME + ", " + GPX_COL_DIR + ");");
|
db.execSQL("CREATE INDEX IF NOT EXISTS " + GPX_INDEX_NAME_DIR + " ON " + GPX_TABLE_NAME + " (" + GPX_COL_NAME + ", " + GPX_COL_DIR + ");");
|
||||||
}
|
}
|
||||||
|
@ -421,6 +454,42 @@ public class GPXDatabase {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean updateShowArrows(GpxDataItem item, boolean showArrows) {
|
||||||
|
SQLiteConnection db = openConnection(false);
|
||||||
|
if (db != null) {
|
||||||
|
try {
|
||||||
|
String fileName = getFileName(item.file);
|
||||||
|
String fileDir = getFileDir(item.file);
|
||||||
|
db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_SHOW_ARROWS + " = ? " +
|
||||||
|
" WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?",
|
||||||
|
new Object[] {showArrows ? 1 : 0, fileName, fileDir});
|
||||||
|
item.setShowArrows(showArrows);
|
||||||
|
} finally {
|
||||||
|
db.close();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean updateShowStartFinish(GpxDataItem item, boolean showStartFinish) {
|
||||||
|
SQLiteConnection db = openConnection(false);
|
||||||
|
if (db != null) {
|
||||||
|
try {
|
||||||
|
String fileName = getFileName(item.file);
|
||||||
|
String fileDir = getFileDir(item.file);
|
||||||
|
db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " + GPX_COL_SHOW_START_FINISH + " = ? " +
|
||||||
|
" WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?",
|
||||||
|
new Object[] {showStartFinish ? 1 : 0, fileName, fileDir});
|
||||||
|
item.setShowStartFinish(showStartFinish);
|
||||||
|
} finally {
|
||||||
|
db.close();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean updateWidth(GpxDataItem item, String width) {
|
public boolean updateWidth(GpxDataItem item, String width) {
|
||||||
SQLiteConnection db = openConnection(false);
|
SQLiteConnection db = openConnection(false);
|
||||||
if (db != null) {
|
if (db != null) {
|
||||||
|
@ -553,12 +622,13 @@ public class GPXDatabase {
|
||||||
}
|
}
|
||||||
if (a != null) {
|
if (a != null) {
|
||||||
db.execSQL(
|
db.execSQL(
|
||||||
"INSERT INTO " + GPX_TABLE_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
"INSERT INTO " + GPX_TABLE_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||||
new Object[] {fileName, fileDir, a.totalDistance, a.totalTracks, a.startTime, a.endTime,
|
new Object[] {fileName, fileDir, a.totalDistance, a.totalTracks, a.startTime, a.endTime,
|
||||||
a.timeSpan, a.timeMoving, a.totalDistanceMoving, a.diffElevationUp, a.diffElevationDown,
|
a.timeSpan, a.timeMoving, a.totalDistanceMoving, a.diffElevationUp, a.diffElevationDown,
|
||||||
a.avgElevation, a.minElevation, a.maxElevation, a.maxSpeed, a.avgSpeed, a.points, a.wptPoints,
|
a.avgElevation, a.minElevation, a.maxElevation, a.maxSpeed, a.avgSpeed, a.points, a.wptPoints,
|
||||||
color, item.file.lastModified(), item.splitType, item.splitInterval, item.apiImported ? 1 : 0,
|
color, item.file.lastModified(), item.splitType, item.splitInterval, item.apiImported ? 1 : 0,
|
||||||
Algorithms.encodeStringSet(item.analysis.wptCategoryNames), item.showAsMarkers ? 1 : 0, item.joinSegments ? 1 : 0, item.width});
|
Algorithms.encodeStringSet(item.analysis.wptCategoryNames), item.showAsMarkers ? 1 : 0,
|
||||||
|
item.joinSegments ? 1 : 0, item.showArrows ? 1 : 0, item.showStartFinish ? 1 : 0, item.width});
|
||||||
} else {
|
} else {
|
||||||
db.execSQL("INSERT INTO " + GPX_TABLE_NAME + "(" +
|
db.execSQL("INSERT INTO " + GPX_TABLE_NAME + "(" +
|
||||||
GPX_COL_NAME + ", " +
|
GPX_COL_NAME + ", " +
|
||||||
|
@ -570,9 +640,13 @@ public class GPXDatabase {
|
||||||
GPX_COL_API_IMPORTED + ", " +
|
GPX_COL_API_IMPORTED + ", " +
|
||||||
GPX_COL_SHOW_AS_MARKERS + ", " +
|
GPX_COL_SHOW_AS_MARKERS + ", " +
|
||||||
GPX_COL_JOIN_SEGMENTS + ", " +
|
GPX_COL_JOIN_SEGMENTS + ", " +
|
||||||
|
GPX_COL_SHOW_ARROWS + ", " +
|
||||||
|
GPX_COL_SHOW_START_FINISH + ", " +
|
||||||
GPX_COL_WIDTH +
|
GPX_COL_WIDTH +
|
||||||
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||||
new Object[] {fileName, fileDir, color, 0, item.splitType, item.splitInterval, item.apiImported ? 1 : 0, item.showAsMarkers ? 1 : 0, item.joinSegments ? 1 : 0, item.width});
|
new Object[] {fileName, fileDir, color, 0, item.splitType, item.splitInterval,
|
||||||
|
item.apiImported ? 1 : 0, item.showAsMarkers ? 1 : 0, item.joinSegments ? 1 : 0,
|
||||||
|
item.showArrows ? 1 : 0, item.showStartFinish ? 1 : 0, item.width});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -653,7 +727,9 @@ public class GPXDatabase {
|
||||||
String wptCategoryNames = query.getString(23);
|
String wptCategoryNames = query.getString(23);
|
||||||
boolean showAsMarkers = query.getInt(24) == 1;
|
boolean showAsMarkers = query.getInt(24) == 1;
|
||||||
boolean joinSegments = query.getInt(25) == 1;
|
boolean joinSegments = query.getInt(25) == 1;
|
||||||
String width = query.getString(26);
|
boolean showArrows = query.getInt(26) == 1;
|
||||||
|
boolean showStartFinish = query.getInt(27) == 1;
|
||||||
|
String width = query.getString(28);
|
||||||
|
|
||||||
GPXTrackAnalysis a = new GPXTrackAnalysis();
|
GPXTrackAnalysis a = new GPXTrackAnalysis();
|
||||||
a.totalDistance = totalDistance;
|
a.totalDistance = totalDistance;
|
||||||
|
@ -695,6 +771,8 @@ public class GPXDatabase {
|
||||||
item.apiImported = apiImported;
|
item.apiImported = apiImported;
|
||||||
item.showAsMarkers = showAsMarkers;
|
item.showAsMarkers = showAsMarkers;
|
||||||
item.joinSegments = joinSegments;
|
item.joinSegments = joinSegments;
|
||||||
|
item.showArrows = showArrows;
|
||||||
|
item.showStartFinish = showStartFinish;
|
||||||
item.width = width;
|
item.width = width;
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,14 +77,26 @@ public class GpxDbHelper {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateWidth(GpxDataItem item, String width) {
|
public boolean updateShowAsMarkers(GpxDataItem item, boolean showAsMarkers) {
|
||||||
boolean res = db.updateWidth(item, width);
|
boolean res = db.updateShowAsMarkers(item, showAsMarkers);
|
||||||
putToCache(item);
|
putToCache(item);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateShowAsMarkers(GpxDataItem item, boolean showAsMarkers) {
|
public boolean updateShowArrows(GpxDataItem item, boolean showArrows) {
|
||||||
boolean res = db.updateShowAsMarkers(item, showAsMarkers);
|
boolean res = db.updateShowArrows(item, showArrows);
|
||||||
|
putToCache(item);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean updateShowStartFinish(GpxDataItem item, boolean showStartFinish) {
|
||||||
|
boolean res = db.updateShowStartFinish(item, showStartFinish);
|
||||||
|
putToCache(item);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean updateWidth(GpxDataItem item, String width) {
|
||||||
|
boolean res = db.updateWidth(item, width);
|
||||||
putToCache(item);
|
putToCache(item);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,8 @@ public class GpxSelectionHelper {
|
||||||
private static final String COLOR = "color";
|
private static final String COLOR = "color";
|
||||||
private static final String WIDTH = "width";
|
private static final String WIDTH = "width";
|
||||||
private static final String SELECTED_BY_USER = "selected_by_user";
|
private static final String SELECTED_BY_USER = "selected_by_user";
|
||||||
|
private static final String SHOW_ARROWS = "showArrows";
|
||||||
|
private static final String SHOW_START_FINISH = "showStartFinish";
|
||||||
|
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -516,6 +518,14 @@ public class GpxSelectionHelper {
|
||||||
int clr = Algorithms.parseColor(obj.getString(COLOR));
|
int clr = Algorithms.parseColor(obj.getString(COLOR));
|
||||||
gpx.setColor(clr);
|
gpx.setColor(clr);
|
||||||
}
|
}
|
||||||
|
if (obj.has(SHOW_ARROWS)) {
|
||||||
|
boolean showArrows = obj.optBoolean(SHOW_ARROWS, false);
|
||||||
|
gpx.setShowArrows(showArrows);
|
||||||
|
}
|
||||||
|
if (obj.has(SHOW_START_FINISH)) {
|
||||||
|
boolean showStartFinish = obj.optBoolean(SHOW_START_FINISH, false);
|
||||||
|
gpx.setShowStartFinish(showStartFinish);
|
||||||
|
}
|
||||||
if (obj.has(WIDTH)) {
|
if (obj.has(WIDTH)) {
|
||||||
gpx.setWidth(obj.getString(WIDTH));
|
gpx.setWidth(obj.getString(WIDTH));
|
||||||
}
|
}
|
||||||
|
@ -561,6 +571,8 @@ public class GpxSelectionHelper {
|
||||||
if (s.gpxFile.getWidth(null) != null) {
|
if (s.gpxFile.getWidth(null) != null) {
|
||||||
obj.put(WIDTH, s.gpxFile.getWidth(null));
|
obj.put(WIDTH, s.gpxFile.getWidth(null));
|
||||||
}
|
}
|
||||||
|
obj.put(SHOW_ARROWS, s.gpxFile.isShowArrows());
|
||||||
|
obj.put(SHOW_START_FINISH, s.gpxFile.isShowStartFinish());
|
||||||
}
|
}
|
||||||
obj.put(SELECTED_BY_USER, s.selectedByUser);
|
obj.put(SELECTED_BY_USER, s.selectedByUser);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
@ -616,6 +628,8 @@ public class GpxSelectionHelper {
|
||||||
if (dataItem.getWidth() != null) {
|
if (dataItem.getWidth() != null) {
|
||||||
gpx.setWidth(dataItem.getWidth());
|
gpx.setWidth(dataItem.getWidth());
|
||||||
}
|
}
|
||||||
|
gpx.setShowArrows(dataItem.isShowArrows());
|
||||||
|
gpx.setShowStartFinish(dataItem.isShowStartFinish());
|
||||||
sf.setJoinSegments(dataItem.isJoinSegments());
|
sf.setJoinSegments(dataItem.isJoinSegments());
|
||||||
}
|
}
|
||||||
sf.setGpxFile(gpx, app);
|
sf.setGpxFile(gpx, app);
|
||||||
|
|
Loading…
Reference in a new issue