internal override void WriteWPTDetails(XmlWriter writer, GPXWriter gpx) { base.WriteWPTDetails (writer,gpx); if (!gpx.IncludeGroundSpeakExtensions) return; writer.WriteStartElement(CACHE_PREFIX, "cache", GPXWriter.NS_CACHE); if (Symbol == "TerraCache" || Symbol == "Default") writer.WriteAttributeString("id", gpx.GetNextGUID().ToString()); else writer.WriteAttributeString("id", CacheID); writer.WriteAttributeString("available", Available.ToString()); writer.WriteAttributeString("archived", Archived.ToString()); // Temp until smart-tag like support if (HasCorrected) writer.WriteElementString(CACHE_PREFIX,"name", GPXWriter.NS_CACHE, "(*) " + CacheName); else writer.WriteElementString(CACHE_PREFIX,"name", GPXWriter.NS_CACHE, CacheName); writer.WriteElementString(CACHE_PREFIX,"placed_by", GPXWriter.NS_CACHE, PlacedBy); writer.WriteStartElement(CACHE_PREFIX,"owner", GPXWriter.NS_CACHE); writer.WriteAttributeString("id", OwnerID); writer.WriteString(CacheOwner); writer.WriteEndElement(); writer.WriteElementString(CACHE_PREFIX,"type", GPXWriter.NS_CACHE, GetCTypeString(TypeOfCache)); writer.WriteElementString(CACHE_PREFIX,"container", GPXWriter.NS_CACHE, Container); List<CacheAttribute> attrs = gpx.GetAttributes(this.Name); writer.WriteStartElement(CACHE_PREFIX, "attributes", GPXWriter.NS_CACHE); foreach(CacheAttribute curr in attrs) { writer.WriteStartElement(CACHE_PREFIX, "attribute", GPXWriter.NS_CACHE); if (!String.IsNullOrEmpty(curr.ID)) writer.WriteAttributeString("id", curr.ID); if (curr.Include) writer.WriteAttributeString("inc", "1"); else writer.WriteAttributeString("inc", "0"); writer.WriteString(curr.AttrValue); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteElementString(CACHE_PREFIX,"difficulty", GPXWriter.NS_CACHE, Difficulty.ToString("0.#", CultureInfo.InvariantCulture)); writer.WriteElementString(CACHE_PREFIX,"terrain", GPXWriter.NS_CACHE, Terrain.ToString("0.#", CultureInfo.InvariantCulture)); writer.WriteElementString(CACHE_PREFIX,"country", GPXWriter.NS_CACHE, Country); writer.WriteElementString(CACHE_PREFIX,"state", GPXWriter.NS_CACHE, State); StringBuilder shortDescription = new StringBuilder(); if (HasCorrected) { shortDescription.Append(Catalog.GetString("Original Coordinate:")); shortDescription.Append(Utilities.getCoordString(OrigLat, OrigLon)); shortDescription.Append("<br/>"); } if (gpx.WriteAttributes) { attrs = gpx.GetAttributes(this.Name); foreach(CacheAttribute curr in attrs) { if (curr.Include) { shortDescription.Append(Catalog.GetString("Y:")); } else { shortDescription.Append(Catalog.GetString("N:")); } shortDescription.Append(curr.AttrValue); shortDescription.Append("<br/>"); } if (attrs.Count > 0) shortDescription.Append("<hr noshade/>"); } if (!String.IsNullOrEmpty(Notes)) { shortDescription.Append(Notes); shortDescription.Append("<hr noshade/>"); } shortDescription.Append(ShortDesc); writer.WriteStartElement(CACHE_PREFIX,"short_description", GPXWriter.NS_CACHE); writer.WriteAttributeString("html", "True"); if (gpx.HTMLOutput == HTMLMode.GARMIN) writer.WriteCData(Utilities.HTMLtoGarmin(shortDescription.ToString())); else if (gpx.HTMLOutput == HTMLMode.PLAINTEXT) writer.WriteCData(Utilities.HTMLtoText(shortDescription.ToString())); else writer.WriteCData(shortDescription.ToString()); writer.WriteEndElement(); writer.WriteStartElement(CACHE_PREFIX,"long_description", GPXWriter.NS_CACHE); writer.WriteAttributeString("html", "True"); if (gpx.HTMLOutput == HTMLMode.GARMIN) writer.WriteCData(Utilities.HTMLtoGarmin(LongDesc)); else if (gpx.HTMLOutput == HTMLMode.PLAINTEXT) writer.WriteCData(Utilities.HTMLtoText(LongDesc)); else writer.WriteCData(LongDesc); writer.WriteEndElement(); writer.WriteStartElement(CACHE_PREFIX,"encoded_hints", GPXWriter.NS_CACHE); writer.WriteAttributeString("html", "True"); if (gpx.HTMLOutput == HTMLMode.GARMIN || gpx.HTMLOutput == HTMLMode.PLAINTEXT) writer.WriteCData(Utilities.HTMLtoText(Hint)); else writer.WriteCData(Hint); writer.WriteEndElement(); writer.WriteStartElement(CACHE_PREFIX,"logs", GPXWriter.NS_CACHE); if (gpx.IsMyFinds) { CacheLog log = gpx.CacheStore.GetLastFindLogBy(this.Name, gpx.MyFindsOwner); if (log.LogStatus == "find") log.LogStatus = "Found it"; log.WriteToGPX(writer); } else { List<CacheLog> logs = gpx.GetCacheLogs(this.Name); int iCount = 0; foreach(CacheLog log in logs) { if ((iCount >= gpx.LogLimit) && (gpx.LogLimit != -1)) break; else log.WriteToGPX(writer); iCount++; } } writer.WriteEndElement(); writer.WriteStartElement(CACHE_PREFIX,"travelbugs", GPXWriter.NS_CACHE); List<TravelBug> bugs = gpx.GetTravelBugs(this.Name); foreach (TravelBug bug in bugs) { bug.WriteToGPX(writer); } writer.WriteEndElement(); writer.WriteEndElement(); }
internal override void WriteWPTDetails(XmlWriter writer, GPXWriter gpx) { base.WriteWPTDetails(writer, gpx); if (!gpx.IncludeGroundSpeakExtensions) { return; } writer.WriteStartElement(CACHE_PREFIX, "cache", GPXWriter.NS_CACHE); if (String.IsNullOrEmpty(CacheID)) { writer.WriteAttributeString("id", gpx.GetNextGUID().ToString()); } else { writer.WriteAttributeString("id", CacheID); } writer.WriteAttributeString("available", Available.ToString()); writer.WriteAttributeString("archived", Archived.ToString()); // Temp until smart-tag like support if (HasCorrected) { writer.WriteElementString(CACHE_PREFIX, "name", GPXWriter.NS_CACHE, "(*) " + CacheName); } else { writer.WriteElementString(CACHE_PREFIX, "name", GPXWriter.NS_CACHE, CacheName); } writer.WriteElementString(CACHE_PREFIX, "placed_by", GPXWriter.NS_CACHE, PlacedBy); writer.WriteStartElement(CACHE_PREFIX, "owner", GPXWriter.NS_CACHE); writer.WriteAttributeString("id", OwnerID); writer.WriteString(CacheOwner); writer.WriteEndElement(); writer.WriteElementString(CACHE_PREFIX, "type", GPXWriter.NS_CACHE, GetCTypeString(TypeOfCache)); writer.WriteElementString(CACHE_PREFIX, "container", GPXWriter.NS_CACHE, Container); List <CacheAttribute> attrs = gpx.GetAttributes(this.Name); writer.WriteStartElement(CACHE_PREFIX, "attributes", GPXWriter.NS_CACHE); foreach (CacheAttribute curr in attrs) { writer.WriteStartElement(CACHE_PREFIX, "attribute", GPXWriter.NS_CACHE); if (!String.IsNullOrEmpty(curr.ID)) { writer.WriteAttributeString("id", curr.ID); } if (curr.Include) { writer.WriteAttributeString("inc", "1"); } else { writer.WriteAttributeString("inc", "0"); } writer.WriteString(curr.AttrValue); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteElementString(CACHE_PREFIX, "difficulty", GPXWriter.NS_CACHE, Difficulty.ToString("0.#", CultureInfo.InvariantCulture)); writer.WriteElementString(CACHE_PREFIX, "terrain", GPXWriter.NS_CACHE, Terrain.ToString("0.#", CultureInfo.InvariantCulture)); writer.WriteElementString(CACHE_PREFIX, "country", GPXWriter.NS_CACHE, Country); writer.WriteElementString(CACHE_PREFIX, "state", GPXWriter.NS_CACHE, State); StringBuilder shortDescription = new StringBuilder(); if (HasCorrected) { shortDescription.Append(Catalog.GetString("Original Coordinate:")); shortDescription.Append(Utilities.getCoordString(OrigLat, OrigLon)); shortDescription.Append("<br/>"); } if (gpx.WriteAttributes) { attrs = gpx.GetAttributes(this.Name); foreach (CacheAttribute curr in attrs) { if (curr.Include) { shortDescription.Append(Catalog.GetString("Y:")); } else { shortDescription.Append(Catalog.GetString("N:")); } shortDescription.Append(curr.AttrValue); shortDescription.Append("<br/>"); } if (attrs.Count > 0) { shortDescription.Append("<hr noshade/>"); } } if (!String.IsNullOrEmpty(Notes)) { shortDescription.Append(Notes); shortDescription.Append("<hr noshade/>"); } shortDescription.Append(ShortDesc); writer.WriteStartElement(CACHE_PREFIX, "short_description", GPXWriter.NS_CACHE); writer.WriteAttributeString("html", "True"); if (gpx.HTMLOutput == HTMLMode.GARMIN) { writer.WriteCData(Utilities.HTMLtoGarmin(shortDescription.ToString())); } else if (gpx.HTMLOutput == HTMLMode.PLAINTEXT) { writer.WriteCData(Utilities.HTMLtoText(shortDescription.ToString())); } else { writer.WriteCData(shortDescription.ToString()); } writer.WriteEndElement(); writer.WriteStartElement(CACHE_PREFIX, "long_description", GPXWriter.NS_CACHE); writer.WriteAttributeString("html", "True"); if (gpx.HTMLOutput == HTMLMode.GARMIN) { writer.WriteCData(Utilities.HTMLtoGarmin(LongDesc)); } else if (gpx.HTMLOutput == HTMLMode.PLAINTEXT) { writer.WriteCData(Utilities.HTMLtoText(LongDesc)); } else { writer.WriteCData(LongDesc); } writer.WriteEndElement(); writer.WriteStartElement(CACHE_PREFIX, "encoded_hints", GPXWriter.NS_CACHE); writer.WriteAttributeString("html", "True"); if (gpx.HTMLOutput == HTMLMode.GARMIN || gpx.HTMLOutput == HTMLMode.PLAINTEXT) { writer.WriteCData(Utilities.HTMLtoText(Hint)); } else { writer.WriteCData(Hint); } writer.WriteEndElement(); writer.WriteStartElement(CACHE_PREFIX, "logs", GPXWriter.NS_CACHE); if (gpx.IsMyFinds) { CacheLog log = gpx.CacheStore.GetLastFindLogBy(this.Name, gpx.MyFindsOwner); if (log.LogStatus == "find") { log.LogStatus = "Found it"; } log.WriteToGPX(writer); } else { List <CacheLog> logs = gpx.GetCacheLogs(this.Name); int iCount = 0; foreach (CacheLog log in logs) { if ((iCount >= gpx.LogLimit) && (gpx.LogLimit != -1)) { break; } else { log.WriteToGPX(writer); } iCount++; } } writer.WriteEndElement(); writer.WriteStartElement(CACHE_PREFIX, "travelbugs", GPXWriter.NS_CACHE); List <TravelBug> bugs = gpx.GetTravelBugs(this.Name); foreach (TravelBug bug in bugs) { bug.WriteToGPX(writer); } writer.WriteEndElement(); writer.WriteEndElement(); }
internal virtual void WriteWPTDetails(XmlWriter writer, GPXWriter gpx) { Geocache cache = null; if (this is Geocache) { cache = this as Geocache; } writer.WriteAttributeString("lat", this.Lat.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("lon", this.Lon.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("time", this.Time.ToString("o")); if (cache != null && gpx.NameMode == WaypointNameMode.NAME) { writer.WriteElementString("name", cache.CacheName); } else if (cache != null && gpx.NameMode == WaypointNameMode.SHORTCODE) { writer.WriteElementString("name", this.Name.Substring(2)); } else { writer.WriteElementString("name", this.Name); } if (cache != null && gpx.DescriptionMode == WaypointDescMode.CODESIZEANDHINT) { if (!String.IsNullOrEmpty(cache.Container)) { writer.WriteElementString("desc", cache.Name + "/" + cache.Container.Substring(0, 3) + "/" + cache.Hint); } else { writer.WriteElementString("desc", cache.Name); } } else if (cache != null && gpx.DescriptionMode == WaypointDescMode.CODESIZETYPE) { if (!String.IsNullOrEmpty(cache.Container)) { writer.WriteElementString("desc", cache.Name + "/" + cache.Container.Substring(0, 3) + "/" + cache.TypeOfCache.ToString()); } else { writer.WriteElementString("desc", cache.Name + "/" + cache.TypeOfCache.ToString()); } } else if (cache != null && gpx.DescriptionMode == WaypointDescMode.FULL) { StringBuilder builder = new StringBuilder(); builder.Append("<br/><br/>" + cache.ShortDesc); builder.Append("<br/>" + cache.LongDesc); if (!String.IsNullOrEmpty(cache.Hint)) { builder.Append("<br/><br/>Hint: " + cache.Hint); } builder.Append("<br/><br/>Logs:<br/>"); List <CacheLog> logs = gpx.GetCacheLogs(cache.Name); int iCount = 0; foreach (CacheLog log in logs) { if (iCount >= gpx.LogLimit && gpx.LogLimit >= 0) { break; } builder.Append(log.toHTML()); iCount++; } writer.WriteStartElement("desc"); if (gpx.HTMLOutput == HTMLMode.GARMIN) { writer.WriteCData(Utilities.HTMLtoGarmin(builder.ToString())); } else if (gpx.HTMLOutput == HTMLMode.PLAINTEXT) { writer.WriteCData(Utilities.HTMLtoText(builder.ToString())); } else { writer.WriteCData(builder.ToString()); } writer.WriteEndElement(); } else { writer.WriteElementString("desc", this.Desc); writer.WriteElementString("cmt", this.Desc); } if (this.URL != null) { writer.WriteElementString("url", this.URL.ToString()); } if (!String.IsNullOrEmpty(this.URLName)) { writer.WriteElementString("urlname", this.URLName); } if (gpx.DescriptionMode == WaypointDescMode.FULL) { writer.WriteElementString("sym", "Information"); } else if (!gpx.UseOCMPtTypes) { writer.WriteElementString("sym", this.Symbol); } else { System.Console.WriteLine(this.Name); if (cache != null && cache.Symbol == "Geocache Found") { writer.WriteElementString("sym", gpx.Mappings[this.Symbol]); } else if (cache != null && cache.TypeOfCache != Geocache.CacheType.GENERIC) { string key = "Geocache|" + Geocache.GetCTypeString(cache.TypeOfCache); writer.WriteElementString("sym", gpx.Mappings[key]); } else if (gpx.Mappings.ContainsKey(this.Type)) { writer.WriteElementString("sym", gpx.Mappings[this.Type]); } else { writer.WriteElementString("sym", this.Symbol); } } writer.WriteElementString("type", this.Type); if (this.Parent != null) { writer.WriteElementString("parent", "http://opencachemanage.sourceforge.net/schema1", this.Parent); } if (cache != null && gpx.DescriptionMode == WaypointDescMode.FULL) { writer.WriteStartElement("extensions"); writer.WriteStartElement("gpxx", "WaypointExtension", "http://www.garmin.com/xmlschemas/GpxExtensions/v3"); writer.WriteElementString("gpxx:DisplayMode", "SymbolAndName"); writer.WriteStartElement("gpxx:Address"); StringBuilder builder = new StringBuilder(); builder.Append(Geocache.GetCTypeString(cache.TypeOfCache) + "\nBy: " + cache.PlacedBy); builder.Append("\n" + cache.Name + ":" + cache.CacheName); builder.Append("\n" + Utilities.getCoordString(cache.Lat, cache.Lon)); builder.Append("\nT:" + cache.Terrain.ToString() + " D:" + cache.Difficulty.ToString() + " S:" + cache.Container); writer.WriteElementString("gpxx:PostalCode", builder.ToString()); writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteEndElement(); } else if (gpx.DescriptionMode == WaypointDescMode.FULL) { writer.WriteStartElement("extensions"); writer.WriteStartElement("gpxx", "WaypointExtension", "http://www.garmin.com/xmlschemas/GpxExtensions/v3"); writer.WriteElementString("gpxx:DisplayMode", "SymbolAndName"); writer.WriteStartElement("gpxx:Address"); StringBuilder builder = new StringBuilder(); builder.Append(this.Symbol + " for " + this.Parent); builder.Append("\n" + Utilities.getCoordString(this.Lat, this.Lon)); writer.WriteElementString("gpxx:PostalCode", builder.ToString()); writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteEndElement(); } }
internal virtual void WriteWPTDetails(XmlWriter writer, GPXWriter gpx) { Geocache cache = null; if (this is Geocache) { cache = this as Geocache; } writer.WriteAttributeString("lat", this.Lat.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("lon", this.Lon.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("time", this.Time.ToString("o")); if (cache != null && gpx.NameMode == WaypointNameMode.NAME) writer.WriteElementString("name", cache.CacheName); else if (cache != null && gpx.NameMode == WaypointNameMode.SHORTCODE) writer.WriteElementString("name", this.Name.Substring(2)); else writer.WriteElementString("name", this.Name); if (cache != null && gpx.DescriptionMode == WaypointDescMode.CODESIZEANDHINT) { if (!String.IsNullOrEmpty(cache.Container)) writer.WriteElementString("desc", cache.Name + "/" + cache.Container.Substring(0, 3) + "/" + cache.Hint); else writer.WriteElementString("desc", cache.Name); } else if (cache != null && gpx.DescriptionMode == WaypointDescMode.CODESIZETYPE) { if (!String.IsNullOrEmpty(cache.Container)) writer.WriteElementString("desc", cache.Name + "/" + cache.Container.Substring(0, 3) + "/" + cache.TypeOfCache.ToString()); else writer.WriteElementString("desc", cache.Name + "/" + cache.TypeOfCache.ToString()); } else if (cache != null && gpx.DescriptionMode == WaypointDescMode.FULL) { StringBuilder builder = new StringBuilder(); builder.Append("<br/><br/>" + cache.ShortDesc); builder.Append("<br/>" + cache.LongDesc); if (!String.IsNullOrEmpty(cache.Hint)) builder.Append("<br/><br/>Hint: " + cache.Hint); builder.Append("<br/><br/>Logs:<br/>"); List<CacheLog> logs = gpx.GetCacheLogs(cache.Name); int iCount = 0; foreach(CacheLog log in logs) { if (iCount >= gpx.LogLimit && gpx.LogLimit >= 0) break; builder.Append(log.toHTML()); iCount++; } writer.WriteStartElement("desc"); if (gpx.HTMLOutput == HTMLMode.GARMIN) writer.WriteCData(Utilities.HTMLtoGarmin(builder.ToString())); else if (gpx.HTMLOutput == HTMLMode.PLAINTEXT) writer.WriteCData(Utilities.HTMLtoText(builder.ToString())); else writer.WriteCData(builder.ToString()); writer.WriteEndElement(); } else { writer.WriteElementString("desc", this.Desc); writer.WriteElementString("cmt", this.Desc); } if (this.URL != null) writer.WriteElementString("url", this.URL.ToString()); if (!String.IsNullOrEmpty(this.URLName)) writer.WriteElementString("urlname", this.URLName); if (gpx.DescriptionMode == WaypointDescMode.FULL) writer.WriteElementString("sym", "Information"); else if (!gpx.UseOCMPtTypes) writer.WriteElementString("sym", this.Symbol); else { System.Console.WriteLine(this.Name); if (cache != null && cache.Symbol == "Geocache Found") writer.WriteElementString("sym", gpx.Mappings[this.Symbol]); else if (cache != null && cache.TypeOfCache != Geocache.CacheType.GENERIC) { string key = "Geocache|" + Geocache.GetCTypeString(cache.TypeOfCache); writer.WriteElementString("sym", gpx.Mappings[key]); } else if (gpx.Mappings.ContainsKey(this.Type)) writer.WriteElementString("sym", gpx.Mappings[this.Type]); else writer.WriteElementString("sym", this.Symbol); } writer.WriteElementString("type", this.Type); if (this.Parent != null) writer.WriteElementString("parent", "http://opencachemanage.sourceforge.net/schema1", this.Parent); if (cache != null && gpx.DescriptionMode == WaypointDescMode.FULL) { writer.WriteStartElement("extensions"); writer.WriteStartElement("gpxx", "WaypointExtension", "http://www.garmin.com/xmlschemas/GpxExtensions/v3"); writer.WriteElementString("gpxx:DisplayMode","SymbolAndName"); writer.WriteStartElement("gpxx:Address"); StringBuilder builder = new StringBuilder(); builder.Append(Geocache.GetCTypeString(cache.TypeOfCache) + "\nBy: " + cache.PlacedBy); builder.Append("\n" + cache.Name + ":" + cache.CacheName); builder.Append("\n" + Utilities.getCoordString(cache.Lat, cache.Lon)); builder.Append("\nT:" + cache.Terrain.ToString() + " D:" + cache.Difficulty.ToString() + " S:" + cache.Container); writer.WriteElementString("gpxx:PostalCode",builder.ToString()); writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteEndElement(); } else if (gpx.DescriptionMode == WaypointDescMode.FULL) { writer.WriteStartElement("extensions"); writer.WriteStartElement("gpxx", "WaypointExtension", "http://www.garmin.com/xmlschemas/GpxExtensions/v3"); writer.WriteElementString("gpxx:DisplayMode","SymbolAndName"); writer.WriteStartElement("gpxx:Address"); StringBuilder builder = new StringBuilder(); builder.Append(this.Symbol + " for " + this.Parent); builder.Append("\n" + Utilities.getCoordString(this.Lat, this.Lon)); writer.WriteElementString("gpxx:PostalCode",builder.ToString()); writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteEndElement(); } }