Ejemplo n.º 1
0
        public void AutoGenerateChildren(MatchCollection matches)
        {
            int count = 0;
            foreach (Match match in matches)
            {
                m_mon.SetProgress((double) count, (double) matches.Count, Catalog.GetString("Processing Children..."), false);
                DegreeMinutes[] coord =  Utilities.ParseCoordString(match.Captures[0].Value);
                System.Console.WriteLine(Utilities.getCoordString(coord[0], coord[1]));

                Waypoint newPoint = new Waypoint ();
                Geocache parent = m_mon.SelectedCache;
                newPoint.Symbol = "Reference Point";
                newPoint.Parent = parent.Name;
                newPoint.Lat = coord[0].GetDecimalDegrees();
                newPoint.Lon = coord[1].GetDecimalDegrees();
                newPoint.Desc = Catalog.GetString("Grabbed Waypoint");
                String name = "RP" + parent.Name.Substring (2);
                if (m_mon.Configuration.IgnoreWaypointPrefixes)
                {
                    name = parent.Name;
                }
                name = Engine.getInstance().Store.GenerateNewName(name);
                newPoint.Name = name;
                CacheStore store = Engine.getInstance ().Store;
                store.AddWaypointAtomic (newPoint);
                count++;
            }
        }
Ejemplo n.º 2
0
        public void AutoGenerateChildren(MatchCollection matches)
        {
            int count = 0;
            m_App.CacheStore.StartUpdate();
            foreach (Match match in matches)
            {
                DegreeMinutes[] coord = Utilities.ParseCoordString (match.Captures[0].Value);
                System.Console.WriteLine (Utilities.getCoordString (coord[0], coord[1]));

                Waypoint newPoint = new Waypoint ();
                Geocache parent = m_Cache;
                newPoint.Symbol = "Reference Point";
                newPoint.Parent = parent.Name;
                newPoint.Lat = coord[0].GetDecimalDegrees ();
                newPoint.Lon = coord[1].GetDecimalDegrees ();
                newPoint.Desc = Catalog.GetString ("Grabbed Waypoint");
                String name = "RP" + parent.Name.Substring (2);
                if (m_App.AppConfig.IgnoreWaypointPrefixes)
                {
                    name = parent.Name;
                }
                name = m_App.CacheStore.GetUniqueName(name);
                newPoint.Name = name;
                m_App.CacheStore.AddWaypointOrCache(newPoint, false, false);
                count++;
            }
            m_App.CacheStore.CompleteUpdate();
            m_App.RefreshAll();
        }
Ejemplo n.º 3
0
 public void SetPoint(ocmengine.Waypoint pnt)
 {
     m_point = pnt;
     descriptionEntry.Buffer.Text = pnt.Desc;
     flagEntry.Active = GetPTTypeCode(pnt.Symbol);
     nameEntry.Text = pnt.Name;
     locationWidget.Latitude = pnt.Lat;
     locationWidget.Longitude = pnt.Lon;
 }
Ejemplo n.º 4
0
 public void SetPoint(ocmengine.Waypoint pnt)
 {
     m_point = pnt;
     descriptionEntry.Buffer.Text = pnt.Desc;
     flagEntry.Active             = GetPTTypeCode(pnt.Symbol);
     nameEntry.Text           = pnt.Name;
     locationWidget.Latitude  = pnt.Lat;
     locationWidget.Longitude = pnt.Lon;
 }
Ejemplo n.º 5
0
        public void WriteToGPX(XmlWriter writer, GPXWriter gpx)
        {
            writer.WriteStartElement("wpt", GPXWriter.NS_GPX);
            WriteWPTDetails(writer, gpx);
            writer.WriteEndElement();
            if (!gpx.IncludeChildWaypoints)
                return;
            IEnumerator<Waypoint> itr = Engine.getInstance().GetChildWaypoints(this.Name);
            while (itr.MoveNext())
            {
                itr.Current.WriteToGPX(writer, gpx);
            }

            if ((this is Geocache) && ((this as Geocache).HasCorrected))
            {
                Geocache cache = this as Geocache;
                Waypoint orig = new Waypoint();
                orig.Name = cache.Name + "-ORIG";
                orig.Lat = cache.OrigLat;
                orig.Lon = cache.OrigLon;
                orig.Symbol = "Reference Point";
                orig.Type = "Waypoint|Reference Point";
                orig.Desc = Catalog.GetString("Original Location") + " - " + cache.CacheName;
                orig.WriteToGPX(writer, gpx);
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Adds a waypoint to the store. If a waypoint already exists with this name, the entry is replaced
 /// </summary>
 /// <param name="point">
 /// The waypoint to add <see cref="Waypoint"/>
 /// </param>
 public abstract void AddWaypointOrCache(Waypoint point, bool lockSymbol, bool partialUpdate);
Ejemplo n.º 7
0
 public void AddWaypoint(Waypoint point)
 {
     AddWaypoint(point, false);
 }
Ejemplo n.º 8
0
 protected virtual void doAdd(object sender, System.EventArgs e)
 {
     try {
         Waypoint newPoint = new Waypoint ();
         Geocache parent = m_mon.SelectedCache;
         newPoint.Symbol = "Final Location";
         newPoint.Parent = parent.Name;
         newPoint.Lat = parent.Lat;
         newPoint.Lon = parent.Lon;
         String name = "FL" + parent.Name.Substring (2);
         WaypointDialog dlg = new WaypointDialog ();
         if (m_mon.Configuration.IgnoreWaypointPrefixes)
         {
             name = parent.Name;
             dlg.IgnorePrefix = true;
         }
         name = Engine.getInstance().Store.GenerateNewName(name);
         newPoint.Name = name;
         dlg.SetPoint (newPoint);
         if ((int)ResponseType.Ok == dlg.Run ()) {
             newPoint = dlg.GetPoint ();
             if (newPoint.Symbol == "Final Location")
                 parent.HasFinal = true;
             CacheStore store = Engine.getInstance ().Store;
             store.AddWaypointAtomic (newPoint);
             dlg.Dispose ();
             UpdateCacheInfo ();
         }
     } catch (Exception ex) {
         UIMonitor.ShowException (ex);
     }
 }
Ejemplo n.º 9
0
 public void AddWaypointAtomic(Waypoint point)
 {
     IDbTransaction trans = StartUpdate();
     AddWaypoint(point);
     EndUpdate(trans);
 }
Ejemplo n.º 10
0
 private void parseGeocacheElement(ref Waypoint pt, XmlReader reader)
 {
     Geocache cache = pt as Geocache;
     if (m_source == "opencaching")
     {
         cache = ParseOpenCache(reader, ref cache);
     }
     else if (reader.NamespaceURI.StartsWith("http://www.groundspeak.com/cache")
              || reader.NamespaceURI.StartsWith("http://www.gsak.net/xmlv1/5"))
     {
         cache = ParseGroundSpeakCache (reader, ref cache);
     }
     else if (reader.NamespaceURI.StartsWith("http://www.TerraCaching.com"))
     {
         cache = ParseTerraCache (reader, ref cache);
     }
 }
Ejemplo n.º 11
0
        private void ParseNaviCache(Waypoint pt)
        {
            Geocache cache = pt as Geocache;
            cache.Symbol = "NaviCache";
            String[] lines = pt.Desc.Split('\n');
            for (int i=0; i < lines.Length; i++)
            {
                if (i ==0 )
                {
                    cache.CacheName = lines[0];
                }
                else if (i == 1)
                    continue;
                else
                {
                    String[] details = lines[i].Split(':');
                    String detail = details[1].Trim();
                    if (i == 2)
                    {
                        ParseCacheType(detail, ref cache);
                    }
                    else if (i == 3)
                    {
                        if (detail == "Normal")
                            cache.Container = "Regular";
                        else if (detail == "Virtual" || detail == "Unknown")
                            cache.Container = "Not chosen";
                        else
                            cache.Container = detail;
                    }
                    else if (i == 4)
                    {
                        cache.Difficulty = float.Parse(detail, CultureInfo.InvariantCulture);
                    }
                    else if (i == 5)
                    {
                        cache.Terrain = float.Parse(detail, CultureInfo.InvariantCulture);
                    }

                }
            }
            cache.Desc = cache.CacheName + " ("  + cache.Difficulty + "/" + cache.Terrain + ")";
        }
Ejemplo n.º 12
0
 public void EditChildWaypoint(Waypoint pt)
 {
     Geocache parent = m_Window.CacheList.SelectedCache;
     WaypointDialog dlg = new WaypointDialog ();
     string origname = pt.Name;
     dlg.App = this;
     dlg.IgnorePrefix = m_Config.IgnoreWaypointPrefixes;
     dlg.SetPoint (pt);
     if ((int)ResponseType.Ok == dlg.Run ()) {
         pt = dlg.GetPoint ();
         if (pt.Symbol == "Final Location")
             parent.HasFinal = true;
         if (!parent.Children)
             parent.Children = true;
         m_Store.AddWaypointOrCache (pt, false, false);
         if (pt.Name != origname)
             m_Store.DeleteWaypoint(origname);
         m_Window.Refresh();
         m_Window.CacheInfo.SelectChildByName(pt.Name);
     }
     dlg.Hide();
 }
Ejemplo n.º 13
0
 public void processLocWpt(ref Waypoint pt, XmlReader reader)
 {
     if (reader.Name == "name")
     {
         pt.Name = reader.GetAttribute("id");
         pt.Desc = reader.ReadElementContentAsString().Trim();
         this.ParseWaypoint(this, new ParseEventArgs(String.Format("Processing Waypoint {0}", pt.Name)));
     }
     else if (reader.Name == "coord")
     {
         pt.Lat = double.Parse(reader.GetAttribute("lat"), CultureInfo.InvariantCulture);
         pt.Lon = double.Parse(reader.GetAttribute("lon"), CultureInfo.InvariantCulture);
     }
     else if (reader.Name == "terrain")
     {
         (pt as Geocache).Terrain = float.Parse(reader.ReadString());
     }
     else if (reader.Name == "difficulty")
     {
         (pt as Geocache).Difficulty = float.Parse(reader.ReadString());
     }
     else if (reader.Name == "container")
     {
         string val = reader.ReadString().Trim();
         if (val == "2")
             (pt as Geocache).Container = "Micro";
         else if (val == "8")
             (pt as Geocache).Container = "Small";
         else if (val == "3")
             (pt as Geocache).Container = "Regular";
         else if (val == "4")
             (pt as Geocache).Container = "Large";
         else if (val == "5")
             (pt as Geocache).Container = "Virtual";
         else
             (pt as Geocache).Container = "Not Chosen";
     }
     else if (reader.Name == "type")
     {
         pt.Symbol = reader.ReadElementContentAsString();
         pt.Type = pt.Symbol;
         if (pt.Type == "Geocache")
         {
             if (pt.URL == null)
                 pt.URL = new Uri("http://geocaching.com");
             pt  = Geocache.convertFromWaypoint(pt);
             if (m_source == "NaviCache")
             {
                 ParseNaviCache (pt);
             }
         }
     }
     else if (reader.Name == "link")
     {
         pt.URLName = reader.GetAttribute("text");
         pt.URL = new Uri(reader.ReadElementContentAsString());
         ((Geocache) pt).LongDesc = "<a href=\"" + pt.URL.ToString() + "\">View Online</a>";
     }
 }
Ejemplo n.º 14
0
 public void AddChildWaypoint(double lat, double lon)
 {
     Waypoint newPoint = new Waypoint ();
     Geocache parent = m_Window.CacheList.SelectedCache;
     newPoint.Symbol = "Final Location";
     newPoint.Parent = parent.Name;
     newPoint.Lat = lat;
     newPoint.Lon = lon;
     String name = "FL" + parent.Name.Substring (2);
     WaypointDialog dlg = new WaypointDialog ();
     dlg.IgnorePrefix = m_Config.IgnoreWaypointPrefixes;
     dlg.App = this;
     if (m_Config.IgnoreWaypointPrefixes)
     {
         name = parent.Name;
         dlg.IgnorePrefix = true;
     }
     name = m_Store.GetUniqueName(name);
     newPoint.Name = name;
     dlg.SetPoint (newPoint);
     if ((int)ResponseType.Ok == dlg.Run ()) {
         newPoint = dlg.GetPoint ();
         if (newPoint.Symbol == "Final Location")
             parent.HasFinal = true;
         if (!parent.Children)
             parent.Children = true;
         m_Store.AddWaypointOrCache (newPoint, false, false);
         m_Window.Refresh();
         m_Window.CacheInfo.SelectChildByName(newPoint.Name);
     }
     dlg.Hide();
 }
Ejemplo n.º 15
0
        internal void UpdateWaypoint(Waypoint pt, bool noOverwrite)
        {
            if (m_conn == null)
                throw new Exception("DB NOT OPEN");
            double lat = pt.Lat;
            double lon = pt.Lon;
            if (pt is Geocache)
            {
                lat = (pt as Geocache).OrigLat;
                lon = (pt as Geocache).OrigLon;
            }

            IDbCommand cmd = m_conn.CreateCommand();
            string insert = String.Format(INSERT_WPT, SQLEscape(pt.Name), lat.ToString(CultureInfo.InvariantCulture), lon.ToString(CultureInfo.InvariantCulture), pt.URL,
                                            SQLEscape(pt.URLName), SQLEscape(pt.Desc), pt.Symbol, pt.Type,
                                            pt.Time.ToString("o"), pt.Parent, pt.Updated.ToString("o"));
            string update;
            if (noOverwrite)
                update = String.Format(UPDATE_WPT_NO_SYM, SQLEscape(pt.Name), lat.ToString(CultureInfo.InvariantCulture), lon.ToString(CultureInfo.InvariantCulture), pt.URL,
                                            SQLEscape(pt.URLName), SQLEscape(pt.Desc), pt.Type,
                                            pt.Time.ToString("o"), pt.Parent, pt.Updated.ToString("o"));
            else
                update = String.Format(UPDATE_WPT, SQLEscape(pt.Name), lat.ToString(CultureInfo.InvariantCulture), lon.ToString(CultureInfo.InvariantCulture), pt.URL,
                                            SQLEscape(pt.URLName), SQLEscape(pt.Desc), pt.Symbol, pt.Type,
                                            pt.Time.ToString("o"), pt.Parent, pt.Updated.ToString("o"));
            InsertOrUpdate (update, insert, cmd);
        }
Ejemplo n.º 16
0
 public void UpdateWaypointAtomic(Waypoint pt)
 {
     IDbTransaction trans = StartUpdate();
     UpdateWaypoint(pt, false);
     EndUpdate(trans);
 }
Ejemplo n.º 17
0
 protected virtual void OnAddClick(object sender, System.EventArgs e)
 {
     ocmengine.Waypoint pt = reviewWidget.GetPoint();
     m_App.CacheStore.AddWaypointOrCache(pt, false, false);
     NextMatch();
 }
Ejemplo n.º 18
0
 public double GetDistanceFromParent(Waypoint pt)
 {
     if (pt == null)
         return 0;
     return Utilities.calculateDistance (m_Cache.Lat, pt.Lat, m_Cache.Lon, pt.Lon);
 }
Ejemplo n.º 19
0
 public void UpdateCacheInfo()
 {
     Geocache cache = m_mon.SelectedCache;
     m_childPoints.Clear ();
     m_mon.ClearMarkers ();
     if (cache == null)
     {
         addButton.Sensitive = false;
         grabButton.Sensitive = false;
         return;
     }
     else
     {
         addButton.Sensitive = true;
         grabButton.Sensitive = true;
     }
     ShowChildWaypoints (cache);
     if (cache.HasCorrected)
     {
         Waypoint Orig = new Waypoint();
         Orig.Name = cache.Name + "-ORIG";
         Orig.Lat = cache.OrigLat;
         Orig.Lon = cache.OrigLon;
         Orig.Symbol = "Geocache";
         Orig.Type = "Geocache - Original";
         Orig.Desc = Catalog.GetString("Original Location");
         m_mon.AddMapWayPoint (Orig, cache);
         m_childPoints.AppendValues(Orig);
     }
     m_mon.SetProgressDone(false);
     m_ListSort.SetSortColumnId (1, SortType.Ascending);
     m_mon.Main.QueueDraw();
     if (m_mon.ShowNearby)
         m_mon.GetNearByCaches();
 }
Ejemplo n.º 20
0
 public static Geocache convertFromWaypoint(Waypoint original)
 {
     Geocache cache = new Geocache();
     cache.Name = original.Name;
     cache.Time = original.Time;
     cache.Lat = original.Lat;
     cache.Lon = original.Lon;
     cache.Desc = original.Desc;
     cache.Symbol = original.Symbol;
     cache.URL = original.URL;
     cache.URLName = original.URLName;
     cache.Type = original.Type;
     cache.Updated = original.Updated;
     cache.CacheName = original.Desc;
     cache.Available = true;
     cache.Archived = false;
     cache.TypeOfCache = Geocache.CacheType.GENERIC;
     cache.ShortDesc = "";
     if (cache.URL != null)
         cache.LongDesc = "<a href=\"" + cache.URL.ToString() + "\">View Online</a>";
     return cache;
 }
Ejemplo n.º 21
0
 private Waypoint processLocWaypoint(XmlReader reader)
 {
     Waypoint newPoint = new Waypoint();
     bool breakLoop = false;
     while (!breakLoop && reader.Read())
     {
         switch (reader.NodeType)
         {
             case XmlNodeType.Element:
                 processLocWpt(ref newPoint, reader);
                 break;
             case XmlNodeType.EndElement:
                 if (reader.Name == "waypoint")
                     breakLoop = true;
             break;
         }
     }
     return newPoint;
 }
Ejemplo n.º 22
0
 public void AddWaypoint(Waypoint point, bool noOverwrite)
 {
     if (point is Geocache)
         AddCache(point as Geocache);
     UpdateWaypoint(point, noOverwrite);
 }
Ejemplo n.º 23
0
        private Waypoint processWaypoint(XmlReader reader)
        {
            Waypoint newPoint = new Waypoint();

            String lat = reader.GetAttribute("lat");
            String lon = reader.GetAttribute("lon");

            newPoint.Lat = float.Parse(lat, CultureInfo.InvariantCulture);
            newPoint.Lon = float.Parse(lon, CultureInfo.InvariantCulture);

            bool breakLoop = false;

            while (!breakLoop && reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        processWptElement(ref newPoint, reader);
                        break;
                    case XmlNodeType.EndElement:
                        if (reader.Name == "wpt")
                            breakLoop = true;
                        break;
                }
            }
            return newPoint;
        }
Ejemplo n.º 24
0
        private void processWptElement(ref Waypoint pt, XmlReader reader)
        {
            System.Console.WriteLine("Processing: " + reader.LocalName);
            if (pt is Geocache)
            {
                parseGeocacheElement(ref pt, reader);
            }
            else if (reader.LocalName == "name")
            {
                pt.Name = reader.ReadString();
                System.Console.WriteLine("Name is : " + pt.Name);
                this.ParseWaypoint(this, new ParseEventArgs(String.Format("Processing Waypoint {0}", pt.Name)));
                pt.Parent = "GC" +  pt.Name.Substring(2);
            }
            else if (reader.LocalName == "url")
            {
                String url = reader.ReadString().Trim();
                if (!String.IsNullOrEmpty(url))
                    pt.URL = new Uri(url);
            }
            else if (reader.LocalName == "parent")
            {
                pt.Parent = reader.ReadString();
            }
            else if (reader.LocalName == "desc")
            {
                pt.Desc = reader.ReadElementContentAsString();
            }
            else if (reader.LocalName == "time")
            {
                string strVal = reader.ReadString();
                pt.Time = DateTime.Parse(strVal);
            }
            else if (reader.LocalName == "link")
            {
                pt.URL = new Uri(reader.GetAttribute("href"));
                pt.URLName = pt.Name;
            }
            else if (reader.LocalName == "urlname")
            {
                pt.URLName = reader.ReadString();
            }
            else if (reader.LocalName == "sym")
            {
                pt.Symbol = reader.ReadString();

            }
            else if (reader.LocalName == "type")
            {
                pt.Type = reader.ReadString();
                if (pt.Type.StartsWith("Geocache") || pt.Type.StartsWith("TerraCache"))
                {
                    pt = Geocache.convertFromWaypoint(pt);
                }
                else if (pt.Symbol == "Waymark")
                {
                    // TEMP: For now, convert Waymark into a virtual cache
                    pt = Geocache.convertFromWaypoint(pt);
                    Geocache cache = pt as Geocache;
                    cache.ShortDesc = pt.Type + "\n\n";
                    cache.CacheName = pt.Type + ":  " + pt.URLName;
                    // Need to give it a unique ID for Oregon/Colorado.
                    Random rand = new Random();
                    cache.CacheID = rand.Next(50000000).ToString();
                    cache.TypeOfCache = Geocache.CacheType.VIRTUAL;
                    cache.Type = "Geocache";
                    cache.LongDesc = cache.Desc;
                    cache.Container = "Virtual";
                    cache.Difficulty = 1.0f;
                    cache.Terrain = 1.0f;
                    pt.Desc = cache.CacheName;
                    pt.Symbol = "Geocache";
                    pt.Type = "Geocache|Virtual Cache";
                    cache.PlacedBy = "Unknown";
                }
            }
        }
 public ocmengine.Waypoint GetPoint()
 {
     Waypoint pt = new Waypoint();
     pt.Name = nameEntry.Text;
     pt.Lat = m_lat.GetDecimalDegrees();
     pt.Lon = m_lon.GetDecimalDegrees();
     pt.Parent = m_parent.Name;
     pt.Symbol = GetPTType(flagEntry.Active);
     pt.Desc = descriptionText.Buffer.Text;
     return pt;
 }
Ejemplo n.º 26
0
 private Waypoint BuildWaypoint(IDataReader reader)
 {
     Waypoint pt = new Waypoint();
     pt.Name = reader.GetString(0);
     pt.Lat = double.Parse(reader.GetString(1), CultureInfo.InvariantCulture);
     pt.Lon = double.Parse(reader.GetString(2), CultureInfo.InvariantCulture);
     string url = reader.GetString(3);
     if (!String.IsNullOrEmpty(url))
         pt.URL = new Uri(url);
     pt.URLName = reader.GetString(4);
     pt.Desc = reader.GetString(5);
     pt.Symbol = reader.GetString(6);
     pt.Type = reader.GetString(7);
     pt.Time = DateTime.Parse(reader.GetString(8));
     pt.Parent = reader.GetString(9);
     pt.Updated = DateTime.Parse(reader.GetString(10));
     return pt;
 }