Skip to content

Commit

Permalink
v1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
bionicl authored Jul 15, 2018
2 parents 39e2b06 + cf599e6 commit 0ee126a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Arc-app-export-converter/PlacesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public PlacesSave(List<Place> places, int currentId) {
public class PlacesManager {
static bool loaded;
static string placesFileName = "places.json";
static float distanceTolerance = 0.07f;
static float distanceTolerance = 0.4f;

static List<Place> places = new List<Place>();
static int currentId;
Expand Down
52 changes: 38 additions & 14 deletions Arc-app-export-converter/XmlReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public class Place {
public Coordinates position;
public DateTime? startTime;
public DateTime? endTime;
public string ele;
public int Duration {
get {
if (!startTime.HasValue || !endTime.HasValue) {
Expand All @@ -107,7 +108,7 @@ public int Duration {
}
}

public Place(Coordinates position, string name, DateTime? startTime = null) {
public Place(Coordinates position, string name, DateTime? startTime = null, string ele = null) {
this.position = position;
this.startTime = startTime;
this.name = name;
Expand Down Expand Up @@ -284,31 +285,54 @@ public void LoadFile(string path) {
}
void GetPlace(string line, StreamReader sr) {
XmlTimeline.Coordinates location = HelpMethods.GetLatLon(line);

// time
DateTime startTime = new DateTime();
startTime = HelpMethods.ParseIso8601(
HelpMethods.LeaveCenterFromString(
sr.ReadLine().Replace("\t", ""),
"<time>",
"</time>"));

// ele
string ele = HelpMethods.LeaveCenterFromString(sr.ReadLine().Replace("\t", ""), "<ele>", "</ele>");

// name (if exist)
string name = "";
if (!line.EndsWith("/>", StringComparison.Ordinal)) {
string nameLine = sr.ReadLine().Replace("\t", "");
name = HelpMethods.LeaveCenterFromString(nameLine, "<name>", "</name>");
string tempLine = sr.ReadLine().Replace("\t", "");
if (tempLine.StartsWith("<name>")) {
name = HelpMethods.LeaveCenterFromString(tempLine, "<name>", "</name>");
sr.ReadLine();
}
DateTime? startTime = null;
if (timelineItems.Count >= 1 && timelineItems.Last().type == XmlTimeline.TimelineItemType.activity)
startTime = timelineItems.Last().activity.endTime;
timelineItems.Add(new XmlTimeline.TimelineItem(new XmlTimeline.Place(location, name, startTime)));

// If previous is place
if (timelineItems.Count >= 1 && timelineItems.Last().type == XmlTimeline.TimelineItemType.place)
timelineItems.Last().place.endTime = startTime;

//if (timelineItems.Count >= 1 && timelineItems.Last().type == XmlTimeline.TimelineItemType.activity)
// startTime = timelineItems.Last().activity.endTime;
timelineItems.Add(new XmlTimeline.TimelineItem(new XmlTimeline.Place(location, name, startTime, ele)));

}
void GetMove(StreamReader sr) {
// Type
string typeLine = sr.ReadLine().Replace("\t", "");
if (typeLine == "<trkseg />") {
string line = sr.ReadLine().Replace("\t", "");
if (line == "<trkseg />") {
sr.ReadLine();
return;
}
typeLine = HelpMethods.LeaveCenterFromString(typeLine, "<type>", "</type>");
ActivityType type = ActivityType.walking;
Enum.TryParse(typeLine, out type);
if (line.StartsWith("<type>", StringComparison.CurrentCulture)) {
line = HelpMethods.LeaveCenterFromString(line, "<type>", "</type>");
Enum.TryParse(line, out type);

// Track points
string line = sr.ReadLine().Replace("\t", "");
// Track points
line = sr.ReadLine().Replace("\t", "");
}
if (line == "<trkseg />") {
sr.ReadLine();
return;
}
List<XmlTimeline.Coordinates> coords = new List<XmlTimeline.Coordinates>();
while (true) {
line = sr.ReadLine().Replace("\t", "");
Expand Down

0 comments on commit 0ee126a

Please sign in to comment.