Reorganization of GPX code.
This commit is contained in:
parent
2dd8f75822
commit
c25fb43434
|
|
@ -28,7 +28,6 @@ public class ImportGpx extends Gpx {
|
||||||
|
|
||||||
private String traceName = "";
|
private String traceName = "";
|
||||||
|
|
||||||
|
|
||||||
public ImportGpx(File filePath) {
|
public ImportGpx(File filePath) {
|
||||||
super(filePath);
|
super(filePath);
|
||||||
}
|
}
|
||||||
|
|
@ -37,10 +36,9 @@ public class ImportGpx extends Gpx {
|
||||||
return this.traceName;
|
return this.traceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List parse() throws XmlPullParserException, IOException {
|
public List<MyLocation> parse() throws XmlPullParserException, IOException {
|
||||||
InputStream in = new FileInputStream(filePath);
|
InputStream in = new FileInputStream(filePath);
|
||||||
try {
|
try {
|
||||||
|
|
||||||
XmlPullParser parser = Xml.newPullParser();
|
XmlPullParser parser = Xml.newPullParser();
|
||||||
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
|
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
|
||||||
parser.setInput(in, null);
|
parser.setInput(in, null);
|
||||||
|
|
@ -52,8 +50,8 @@ public class ImportGpx extends Gpx {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private List readGpx(XmlPullParser parser) throws XmlPullParserException, IOException {
|
private List<MyLocation> readGpx(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||||
List entries = new ArrayList();
|
List<MyLocation> entries = new ArrayList<>();
|
||||||
|
|
||||||
parser.require(XmlPullParser.START_TAG, null, "gpx");
|
parser.require(XmlPullParser.START_TAG, null, "gpx");
|
||||||
while (parser.next() != XmlPullParser.END_TAG) {
|
while (parser.next() != XmlPullParser.END_TAG) {
|
||||||
|
|
@ -72,8 +70,8 @@ public class ImportGpx extends Gpx {
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List readTrk(XmlPullParser parser) throws XmlPullParserException, IOException {
|
private List<MyLocation> readTrk(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||||
List entries = new ArrayList();
|
List<MyLocation> entries = new ArrayList<>();
|
||||||
|
|
||||||
parser.require(XmlPullParser.START_TAG, null, "trk");
|
parser.require(XmlPullParser.START_TAG, null, "trk");
|
||||||
while (parser.next() != XmlPullParser.END_TAG) {
|
while (parser.next() != XmlPullParser.END_TAG) {
|
||||||
|
|
@ -90,8 +88,8 @@ public class ImportGpx extends Gpx {
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List readTrkseq(XmlPullParser parser) throws XmlPullParserException, IOException {
|
private List<MyLocation> readTrkseq(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||||
List entries = new ArrayList();
|
List<MyLocation> entries = new ArrayList<>();
|
||||||
|
|
||||||
parser.require(XmlPullParser.START_TAG, null, "trkseg");
|
parser.require(XmlPullParser.START_TAG, null, "trkseg");
|
||||||
while (parser.next() != XmlPullParser.END_TAG) {
|
while (parser.next() != XmlPullParser.END_TAG) {
|
||||||
|
|
@ -205,7 +203,7 @@ public class ImportGpx extends Gpx {
|
||||||
|
|
||||||
|
|
||||||
private boolean readFound(XmlPullParser parser) throws XmlPullParserException, IOException {
|
private boolean readFound(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||||
boolean ret = false;
|
boolean ret;
|
||||||
parser.require(XmlPullParser.START_TAG, null, "found");
|
parser.require(XmlPullParser.START_TAG, null, "found");
|
||||||
ret = Boolean.parseBoolean(readText(parser));
|
ret = Boolean.parseBoolean(readText(parser));
|
||||||
parser.require(XmlPullParser.END_TAG, null, "found");
|
parser.require(XmlPullParser.END_TAG, null, "found");
|
||||||
|
|
|
||||||
|
|
@ -305,13 +305,13 @@ public class ServiceGps extends Observable implements LocationListener {
|
||||||
public void importGpxTrace(File file) {
|
public void importGpxTrace(File file) {
|
||||||
ImportGpx importGpx = new ImportGpx(file);
|
ImportGpx importGpx = new ImportGpx(file);
|
||||||
try {
|
try {
|
||||||
List list = importGpx.parse();
|
List<MyLocation> list = importGpx.parse();
|
||||||
String traceName = importGpx.getTraceName();
|
String traceName = importGpx.getTraceName();
|
||||||
if (traceName.equals(Gpx.TRAIL_TRACE_NAME)) {
|
if (traceName.equals(Gpx.TRAIL_TRACE_NAME)) {
|
||||||
lastExportedTrailFile = file;
|
lastExportedTrailFile = file;
|
||||||
}
|
}
|
||||||
for (int i=0; i<list.size(); i++) {
|
for (int i=0; i<list.size(); i++) {
|
||||||
Object o = list.get(i);
|
MyLocation o = list.get(i);
|
||||||
if (o instanceof WayPointLocation) {
|
if (o instanceof WayPointLocation) {
|
||||||
if (traceName.equals(Gpx.DOG_TRACE_NAME)) {
|
if (traceName.equals(Gpx.DOG_TRACE_NAME)) {
|
||||||
traces.addPointObjectDog((WayPointLocation) o);
|
traces.addPointObjectDog((WayPointLocation) o);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue