/// <summary>
 /// add a new location to the cache
 /// </summary>
 public void addToCache(Address address)
 {
     //if the location's zone matches a cache file name
     //then store it in the cache
     //else create a new cache
     if (address.AddressString == "")
         return;
     if (_currentCache != null
         && address.GpxLocation.Zone == _currentCache.Name)
         _currentCache.write(address.GpxLocation.Key, address);
     else {
         bool foundCache = false;
         foreach (Cache c in _caches) {
             if (address.GpxLocation.Zone == c.Name) {
                 _currentCache = c;
                 foundCache = true;
                 c.write(address.GpxLocation.Key, address);
             }
         }
         //create the cache and store the location
         if (!foundCache) {
             Cache c = new Cache(address.GpxLocation.Zone);
             _currentCache = c;
             c.write(address.GpxLocation.Key, address);
             _caches.Add(c);
         }
     }
 }
 /// <summary>
 /// constructor called when a deep copy is required
 /// </summary>
 public Address(Address a)
 {
     _address = a._address;
     _geocodedLocation = a._geocodedLocation;
     _gpxLocation = a._gpxLocation;
     _status = a._status;
     _streetName = a._streetName;
     _xml = a._xml;
 }
 /// <summary>
 /// constructor for the turn object
 /// </summary>
 public Turn(Address one,
     Address two,
     Address three)
 {
     _locs = new Address[3];
     _locs[0] = one;
     _locs[1] = two;
     _locs[2] = three;
 }
 public PointOfInterest(Location loc, Address one, Address two, Address three)
     : base(one, two, three)
 {
     _locationFromMouse = loc;
 }
 /// <summary>
 /// given a filename, return a chache from disk
 /// </summary>
 Cache readCache(string fileName)
 {
     //read index, street name, and full street address
     StreamReader sr = new StreamReader(fileName);
     Address address = null;
     Cache c = null;
     //use windows or unix file paths
     if (_win) c = new Cache(fileName.Remove(0, fileName.LastIndexOf("\\") + 1));
     else c = new Cache(fileName.Remove(0, fileName.LastIndexOf("/") + 1));
     string key, addressString, streetName, s;
     while (!sr.EndOfStream) {
         s = sr.ReadLine();
         key = s.Substring(0, s.IndexOf("\t"));
         s = s.Remove(0, s.IndexOf("\t") + 1);
         streetName = s.Substring(0, s.IndexOf("\t"));
         s = s.Remove(0, s.IndexOf("\t") + 1);
         addressString = s;
         address = new Address(addressString, streetName);
         c.Tree.insert(long.Parse(key), address);
     }
     sr.Close();
     return c;
 }
 /// <summary>
 /// looks up a location in the cache given an input location
 /// </summary>
 public Address lookup(Location wpt)
 {
     _cacheHit = false;
     //lookup the location in a cache
     //if it is not present, return null
     if (_currentCache == null) return null;
     if (wpt.Zone != _currentCache.Name) {
         foreach (Cache c in _caches) {
             if (wpt.Zone == c.Name)
                 _currentCache = c;
         }
     }
     _tempLocation = (Address)_currentCache.read(wpt.Key);
     if (_tempLocation != null) {
         _cacheHit = true;
         _tempLocation.GpxLocation = wpt;
     }
     return _tempLocation;
 }