Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 2497 → Rev 2498

/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/AccessMode.cs
0,0 → 1,24

namespace GMap.NET
{
/// <summary>
/// tile access mode
/// </summary>
public enum AccessMode
{
/// <summary>
/// access only server
/// </summary>
ServerOnly,
 
/// <summary>
/// access first server and caches localy
/// </summary>
ServerAndCache,
 
/// <summary>
/// access only cache
/// </summary>
CacheOnly,
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/Delegates.cs
0,0 → 1,20

namespace GMap.NET
{
using GMap.NET.MapProviders;
 
public delegate void PositionChanged(PointLatLng point);
 
public delegate void TileLoadComplete(long ElapsedMilliseconds);
public delegate void TileLoadStart();
 
public delegate void TileCacheComplete();
public delegate void TileCacheStart();
public delegate void TileCacheProgress(int tilesLeft);
 
public delegate void MapDrag();
public delegate void MapZoomChanged();
public delegate void MapTypeChanged(GMapProvider type);
 
public delegate void EmptyTileError(int zoom, GPoint pos);
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/DirectionsProvider.cs
0,0 → 1,47

namespace GMap.NET
{
using System.Collections.Generic;
 
/// <summary>
/// directions interface
/// </summary>
interface DirectionsProvider
{
DirectionsStatusCode GetDirections(out GDirections direction, PointLatLng start, PointLatLng end, bool avoidHighways, bool avoidTolls, bool walkingMode, bool sensor, bool metric);
 
DirectionsStatusCode GetDirections(out GDirections direction, string start, string end, bool avoidHighways, bool avoidTolls, bool walkingMode, bool sensor, bool metric);
 
/// <summary>
/// service may provide more than one route alternative in the response
/// </summary>
/// <param name="status"></param>
/// <param name="start"></param>
/// <param name="end"></param>
/// <param name="avoidHighways"></param>
/// <param name="avoidTolls"></param>
/// <param name="walkingMode"></param>
/// <param name="sensor"></param>
/// <param name="metric"></param>
/// <returns></returns>
IEnumerable<GDirections> GetDirections(out DirectionsStatusCode status, string start, string end, bool avoidHighways, bool avoidTolls, bool walkingMode, bool sensor, bool metric);
 
/// <summary>
/// service may provide more than one route alternative in the response
/// </summary>
/// <param name="status"></param>
/// <param name="start"></param>
/// <param name="end"></param>
/// <param name="avoidHighways"></param>
/// <param name="avoidTolls"></param>
/// <param name="walkingMode"></param>
/// <param name="sensor"></param>
/// <param name="metric"></param>
/// <returns></returns>
IEnumerable<GDirections> GetDirections(out DirectionsStatusCode status, PointLatLng start, PointLatLng end, bool avoidHighways, bool avoidTolls, bool walkingMode, bool sensor, bool metric);
 
DirectionsStatusCode GetDirections(out GDirections direction, PointLatLng start, IEnumerable<PointLatLng> wayPoints, PointLatLng end, bool avoidHighways, bool avoidTolls, bool walkingMode, bool sensor, bool metric);
 
DirectionsStatusCode GetDirections(out GDirections direction, string start, IEnumerable<string> wayPoints, string end, bool avoidHighways, bool avoidTolls, bool walkingMode, bool sensor, bool metric);
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/Extensions.cs
0,0 → 1,92

namespace GMap.NET
{
using System;
using System.Runtime.Serialization;
using System.Diagnostics;
 
public static class Extensions
{
/// <summary>
/// Retrieves a value from the SerializationInfo of the given type.
/// </summary>
/// <typeparam name="T">The Type that we are attempting to de-serialize.</typeparam>
/// <param name="info">The SerializationInfo.</param>
/// <param name="key">The key of the value we wish to retrieve.</param>
/// <returns>The value if found, otherwise null.</returns>
public static T GetValue<T>(SerializationInfo info, string key) where T : class
{
try
{
// Return the value from the SerializationInfo, casting it to type T.
return info.GetValue(key, typeof(T)) as T;
}
catch(Exception ex)
{
Debug.WriteLine("Extensions.GetValue: " + ex.Message);
return null;
}
}
 
/// <summary>
/// Retrieves a value from the SerializationInfo of the given type.
/// </summary>
/// <typeparam name="T">The Type that we are attempting to de-serialize.</typeparam>
/// <param name="info">The SerializationInfo.</param>
/// <param name="key">The key of the value we wish to retrieve.</param>
/// <param name="defaultValue">The default value if the de-serialized value was null.</param>
/// <returns>The value if found, otherwise the default value.</returns>
public static T GetValue<T>(SerializationInfo info, string key, T defaultValue) where T : class
{
T deserializedValue = GetValue<T>(info, key);
if(deserializedValue != null)
{
return deserializedValue;
}
 
return defaultValue;
}
 
/// <summary>
/// Retrieves a value from the SerializationInfo of the given type for structs.
/// </summary>
/// <typeparam name="T">The Type that we are attempting to de-serialize.</typeparam>
/// <param name="info">The SerializationInfo.</param>
/// <param name="key">The key of the value we wish to retrieve.</param>
/// <param name="defaultValue">The default value if the de-serialized value was null.</param>
/// <returns>The value if found, otherwise the default value.</returns>
public static T GetStruct<T>(SerializationInfo info, string key, T defaultValue) where T : struct
{
try
{
return (T)info.GetValue(key, typeof(T));
}
catch(Exception ex)
{
Debug.WriteLine("Extensions.GetStruct: " + ex.Message);
return defaultValue;
}
}
 
/// <summary>
/// Retrieves a value from the SerializationInfo of the given type for structs.
/// </summary>
/// <typeparam name="T">The Type that we are attempting to de-serialize.</typeparam>
/// <param name="info">The SerializationInfo.</param>
/// <param name="key">The key of the value we wish to retrieve.</param>
/// <param name="defaultValue">The default value if the de-serialized value was null.</param>
/// <returns>The value if found, otherwise the default value.</returns>
public static Nullable<T> GetStruct<T>(SerializationInfo info, string key, Nullable<T> defaultValue) where T : struct
{
try
{
return (Nullable<T>)info.GetValue(key, typeof(Nullable<T>));
}
catch(Exception ex)
{
Debug.WriteLine("Extensions.GetStruct: " + ex.Message);
return defaultValue;
}
}
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/GDirections.cs
0,0 → 1,121

namespace GMap.NET
{
using System.Collections.Generic;
 
public class GDirections
{
/// <summary>
/// contains a short textual description for the route, suitable for naming and disambiguating the route from alternatives.
/// </summary>
public string Summary;
 
/// <summary>
/// contains a human-readable representation of the duration.
/// </summary>
public string Duration;
 
/// <summary>
/// contains a value of the duration.
/// </summary>
public uint DurationValue;
 
/// <summary>
/// contains a human-readable representation of the distance, displayed in units as used at the origin
/// (or as overridden within the units parameter in the request), in the language specified in the request.
/// (For example, miles and feet will be used for any origin within the United States.)
/// </summary>
public string Distance;
 
/// <summary>
/// contains a value of the distance.
/// </summary>
public uint DistanceValue;
 
/// <summary>
/// contains the latitude/longitude coordinates of the origin of this leg. Because the Directions API
/// calculates directions between locations by using the nearest transportation option (usually a road)
/// at the start and end points, start_location may be different than the provided origin of this leg if,
/// for example, a road is not near the origin.
/// </summary>
public PointLatLng StartLocation;
 
/// <summary>
/// contains the latitude/longitude coordinates of the given destination of this leg. Because the Directions
/// API calculates directions between locations by using the nearest transportation option (usually a road)
/// at the start and end points, end_location may be different than the provided destination of this leg if,
/// for example, a road is not near the destination.
/// </summary>
public PointLatLng EndLocation;
 
/// <summary>
/// contains the human-readable address (typically a street address) reflecting the start_location of this leg.
/// </summary>
public string StartAddress;
 
/// <summary>
/// contains the human-readable address (typically a street address) reflecting the end_location of this leg.
/// </summary>
public string EndAddress;
 
/// <summary>
/// contains the copyrights text to be displayed for this route. You must handle and display this information yourself.
/// </summary>
public string Copyrights;
 
/// <summary>
/// contains an array of steps denoting information about each separate step of the leg of the journey.
/// </summary>
public List<GDirectionStep> Steps;
 
/// <summary>
/// contains all points of the route
/// </summary>
public List<PointLatLng> Route;
 
public override string ToString()
{
return Summary + " | " + Distance + " | " + Duration;
}
}
 
public struct GDirectionStep
{
public string TravelMode;
 
/// <summary>
/// contains the location of the starting point of this step, as a single set of lat and lng fields.
/// </summary>
public PointLatLng StartLocation;
 
/// <summary>
/// contains the location of the ending point of this step, as a single set of lat and lng fields.
/// </summary>
public PointLatLng EndLocation;
 
/// <summary>
/// contains the typical time required to perform the step, until the next step. This field may be undefined if the duration is unknown.
/// </summary>
public string Duration;
 
/// <summary>
/// contains the distance covered by this step until the next step. This field may be undefined if the distance is unknown.
/// </summary>
public string Distance;
 
/// <summary>
/// contains formatted instructions for this step, presented as an HTML text string.
/// </summary>
public string HtmlInstructions;
 
/// <summary>
/// points of the step
/// </summary>
public List<PointLatLng> Points;
 
public override string ToString()
{
return TravelMode + " | " + Distance + " | " + Duration + " | " + HtmlInstructions;
}
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/GMaps.cs
0,0 → 1,849

namespace GMap.NET
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Net;
using System.Text;
using System.Threading;
using System.Xml;
using System.Xml.Serialization;
using GMap.NET.CacheProviders;
using GMap.NET.Internals;
using GMap.NET.MapProviders;
using System.Reflection;
 
#if PocketPC
using OpenNETCF.ComponentModel;
using OpenNETCF.Threading;
using Thread=OpenNETCF.Threading.Thread2;
#endif
 
/// <summary>
/// maps manager
/// </summary>
public class GMaps : Singleton<GMaps>
{
/// <summary>
/// tile access mode
/// </summary>
public AccessMode Mode = AccessMode.ServerAndCache;
 
/// <summary>
/// is map ussing cache for routing
/// </summary>
public bool UseRouteCache = true;
 
/// <summary>
/// is map using cache for geocoder
/// </summary>
public bool UseGeocoderCache = true;
 
/// <summary>
/// is map using cache for directions
/// </summary>
public bool UseDirectionsCache = true;
 
/// <summary>
/// is map using cache for placemarks
/// </summary>
public bool UsePlacemarkCache = true;
 
/// <summary>
/// is map ussing cache for other url
/// </summary>
public bool UseUrlCache = true;
 
/// <summary>
/// is map using memory cache for tiles
/// </summary>
public bool UseMemoryCache = true;
 
/// <summary>
/// primary cache provider, by default: ultra fast SQLite!
/// </summary>
public PureImageCache PrimaryCache
{
get
{
return Cache.Instance.ImageCache;
}
set
{
Cache.Instance.ImageCache = value;
}
}
 
/// <summary>
/// secondary cache provider, by default: none,
/// use it if you have server in your local network
/// </summary>
public PureImageCache SecondaryCache
{
get
{
return Cache.Instance.ImageCacheSecond;
}
set
{
Cache.Instance.ImageCacheSecond = value;
}
}
 
/// <summary>
/// MemoryCache provider
/// </summary>
public readonly MemoryCache MemoryCache = new MemoryCache();
 
/// <summary>
/// load tiles in random sequence
/// </summary>
public bool ShuffleTilesOnLoad = false;
 
/// <summary>
/// tile queue to cache
/// </summary>
readonly Queue<CacheQueueItem> tileCacheQueue = new Queue<CacheQueueItem>();
 
bool? isRunningOnMono;
 
/// <summary>
/// return true if running on mono
/// </summary>
/// <returns></returns>
public bool IsRunningOnMono
{
get
{
if(!isRunningOnMono.HasValue)
{
try
{
isRunningOnMono = (Type.GetType("Mono.Runtime") != null);
return isRunningOnMono.Value;
}
catch
{
}
}
else
{
return isRunningOnMono.Value;
}
return false;
}
}
 
/// <summary>
/// cache worker
/// </summary>
Thread CacheEngine;
 
internal readonly AutoResetEvent WaitForCache = new AutoResetEvent(false);
 
#if !PocketPC
static GMaps()
{
if (GMapProvider.TileImageProxy == null)
{
try
{
AppDomain d = AppDomain.CurrentDomain;
var AssembliesLoaded = d.GetAssemblies();
 
Assembly l = null;
 
foreach (var a in AssembliesLoaded)
{
if (a.FullName.Contains("GMap.NET.WindowsForms") || a.FullName.Contains("GMap.NET.WindowsPresentation"))
{
l = a;
break;
}
}
 
if (l == null)
{
var jj = Assembly.GetExecutingAssembly().Location;
var hh = Path.GetDirectoryName(jj);
var f1 = hh + Path.DirectorySeparatorChar + "GMap.NET.WindowsForms.dll";
var f2 = hh + Path.DirectorySeparatorChar + "GMap.NET.WindowsPresentation.dll";
if (File.Exists(f1))
{
l = Assembly.LoadFile(f1);
}
else if (File.Exists(f2))
{
l = Assembly.LoadFile(f2);
}
}
 
if (l != null)
{
Type t = null;
 
if (l.FullName.Contains("GMap.NET.WindowsForms"))
{
t = l.GetType("GMap.NET.WindowsForms.GMapImageProxy");
}
else if (l.FullName.Contains("GMap.NET.WindowsPresentation"))
{
t = l.GetType("GMap.NET.WindowsPresentation.GMapImageProxy");
}
 
if (t != null)
{
t.InvokeMember("Enable", BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Static | BindingFlags.InvokeMethod, null, null, null);
}
}
}
catch (Exception ex)
{
Debug.WriteLine("GMaps, try set TileImageProxy failed: " + ex.Message);
}
}
}
#endif
 
public GMaps()
{
#region singleton check
if(Instance != null)
{
throw (new Exception("You have tried to create a new singleton class where you should have instanced it. Replace your \"new class()\" with \"class.Instance\""));
}
#endregion
 
ServicePointManager.DefaultConnectionLimit = 5;
}
 
#if !PocketPC
/// <summary>
/// triggers dynamic sqlite loading,
/// call this before you use sqlite for other reasons than caching maps
/// </summary>
public void SQLitePing()
{
#if SQLite
#if !MONO
SQLitePureImageCache.Ping();
#endif
#endif
}
#endif
 
#region -- Stuff --
 
#if !PocketPC
 
/// <summary>
/// exports current map cache to GMDB file
/// if file exsist only new records will be added
/// otherwise file will be created and all data exported
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
public bool ExportToGMDB(string file)
{
#if SQLite
if(PrimaryCache is SQLitePureImageCache)
{
StringBuilder db = new StringBuilder((PrimaryCache as SQLitePureImageCache).GtileCache);
db.AppendFormat(CultureInfo.InvariantCulture, "{0}{1}Data.gmdb", GMapProvider.LanguageStr, Path.DirectorySeparatorChar);
 
return SQLitePureImageCache.ExportMapDataToDB(db.ToString(), file);
}
#endif
return false;
}
 
/// <summary>
/// imports GMDB file to current map cache
/// only new records will be added
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
public bool ImportFromGMDB(string file)
{
#if SQLite
if(PrimaryCache is GMap.NET.CacheProviders.SQLitePureImageCache)
{
StringBuilder db = new StringBuilder((PrimaryCache as SQLitePureImageCache).GtileCache);
db.AppendFormat(CultureInfo.InvariantCulture, "{0}{1}Data.gmdb", GMapProvider.LanguageStr, Path.DirectorySeparatorChar);
 
return SQLitePureImageCache.ExportMapDataToDB(file, db.ToString());
}
#endif
return false;
}
 
#if SQLite
 
/// <summary>
/// optimizes map database, *.gmdb
/// </summary>
/// <param name="file">database file name or null to optimize current user db</param>
/// <returns></returns>
public bool OptimizeMapDb(string file)
{
if(PrimaryCache is GMap.NET.CacheProviders.SQLitePureImageCache)
{
if(string.IsNullOrEmpty(file))
{
StringBuilder db = new StringBuilder((PrimaryCache as SQLitePureImageCache).GtileCache);
db.AppendFormat(CultureInfo.InvariantCulture, "{0}{1}Data.gmdb", GMapProvider.LanguageStr, Path.DirectorySeparatorChar);
 
return SQLitePureImageCache.VacuumDb(db.ToString());
}
else
{
return SQLitePureImageCache.VacuumDb(file);
}
}
 
return false;
}
#endif
 
#endif
 
/// <summary>
/// enqueueens tile to cache
/// </summary>
/// <param name="task"></param>
void EnqueueCacheTask(CacheQueueItem task)
{
lock(tileCacheQueue)
{
if(!tileCacheQueue.Contains(task))
{
Debug.WriteLine("EnqueueCacheTask: " + task);
 
tileCacheQueue.Enqueue(task);
 
if(CacheEngine != null && CacheEngine.IsAlive)
{
WaitForCache.Set();
}
#if PocketPC
else if(CacheEngine == null || CacheEngine.State == ThreadState.Stopped || CacheEngine.State == ThreadState.Unstarted)
#else
else if(CacheEngine == null || CacheEngine.ThreadState == System.Threading.ThreadState.Stopped || CacheEngine.ThreadState == System.Threading.ThreadState.Unstarted)
#endif
{
CacheEngine = null;
CacheEngine = new Thread(new ThreadStart(CacheEngineLoop));
CacheEngine.Name = "CacheEngine";
CacheEngine.IsBackground = false;
CacheEngine.Priority = ThreadPriority.Lowest;
 
abortCacheLoop = false;
CacheEngine.Start();
}
}
}
}
 
volatile bool abortCacheLoop = false;
internal volatile bool noMapInstances = false;
 
public TileCacheComplete OnTileCacheComplete;
public TileCacheStart OnTileCacheStart;
public TileCacheProgress OnTileCacheProgress;
 
/// <summary>
/// immediately stops background tile caching, call it if you want fast exit the process
/// </summary>
public void CancelTileCaching()
{
Debug.WriteLine("CancelTileCaching...");
 
abortCacheLoop = true;
lock(tileCacheQueue)
{
tileCacheQueue.Clear();
WaitForCache.Set();
}
}
 
int readingCache = 0;
volatile bool cacheOnIdleRead = true;
 
/// <summary>
/// delays writing tiles to cache while performing reads
/// </summary>
public bool CacheOnIdleRead
{
get
{
return cacheOnIdleRead;
}
set
{
cacheOnIdleRead = value;
}
}
 
volatile bool boostCacheEngine = false;
 
/// <summary>
/// disables delay between saving tiles into database/cache
/// </summary>
public bool BoostCacheEngine
{
get
{
return boostCacheEngine;
}
set
{
boostCacheEngine = value;
}
}
 
/// <summary>
/// live for cache ;}
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void CacheEngineLoop()
{
Debug.WriteLine("CacheEngine: start");
int left = 0;
 
if(OnTileCacheStart != null)
{
OnTileCacheStart();
}
 
bool startEvent = false;
 
while(!abortCacheLoop)
{
try
{
CacheQueueItem? task = null;
 
lock(tileCacheQueue)
{
left = tileCacheQueue.Count;
if(left > 0)
{
task = tileCacheQueue.Dequeue();
}
}
 
if(task.HasValue)
{
if(startEvent)
{
startEvent = false;
 
if(OnTileCacheStart != null)
{
OnTileCacheStart();
}
}
 
if(OnTileCacheProgress != null)
{
OnTileCacheProgress(left);
}
 
#region -- save --
// check if stream wasn't disposed somehow
if(task.Value.Img != null)
{
Debug.WriteLine("CacheEngine[" + left + "]: storing tile " + task.Value + ", " + task.Value.Img.Length / 1024 + "kB...");
 
if((task.Value.CacheType & CacheUsage.First) == CacheUsage.First && PrimaryCache != null)
{
if(cacheOnIdleRead)
{
while(Interlocked.Decrement(ref readingCache) > 0)
{
Thread.Sleep(1000);
}
}
PrimaryCache.PutImageToCache(task.Value.Img, task.Value.Tile.Type, task.Value.Tile.Pos, task.Value.Tile.Zoom);
}
 
if((task.Value.CacheType & CacheUsage.Second) == CacheUsage.Second && SecondaryCache != null)
{
if(cacheOnIdleRead)
{
while(Interlocked.Decrement(ref readingCache) > 0)
{
Thread.Sleep(1000);
}
}
SecondaryCache.PutImageToCache(task.Value.Img, task.Value.Tile.Type, task.Value.Tile.Pos, task.Value.Tile.Zoom);
}
 
task.Value.Clear();
 
if(!boostCacheEngine)
{
#if PocketPC
Thread.Sleep(3333);
#else
Thread.Sleep(333);
#endif
}
}
else
{
Debug.WriteLine("CacheEngineLoop: skip, tile disposed to early -> " + task.Value);
}
task = null;
#endregion
}
else
{
if(!startEvent)
{
startEvent = true;
 
if(OnTileCacheComplete != null)
{
OnTileCacheComplete();
}
}
 
if(abortCacheLoop || noMapInstances || !WaitForCache.WaitOne(33333, false) || noMapInstances)
{
break;
}
}
}
#if !PocketPC
catch(AbandonedMutexException)
{
break;
}
#endif
catch(Exception ex)
{
Debug.WriteLine("CacheEngineLoop: " + ex.ToString());
}
}
Debug.WriteLine("CacheEngine: stop");
 
if(!startEvent)
{
if(OnTileCacheComplete != null)
{
OnTileCacheComplete();
}
}
}
 
class StringWriterExt : StringWriter
{
public StringWriterExt(IFormatProvider info)
: base(info)
{
 
}
 
public override Encoding Encoding
{
get
{
return Encoding.UTF8;
}
}
}
 
public string SerializeGPX(gpxType targetInstance)
{
string retVal = string.Empty;
using(StringWriterExt writer = new StringWriterExt(CultureInfo.InvariantCulture))
{
XmlSerializer serializer = new XmlSerializer(targetInstance.GetType());
serializer.Serialize(writer, targetInstance);
retVal = writer.ToString();
}
return retVal;
}
 
public gpxType DeserializeGPX(string objectXml)
{
gpxType retVal = null;
 
using(StringReader stringReader = new StringReader(objectXml))
{
XmlTextReader xmlReader = new XmlTextReader(stringReader);
 
XmlSerializer serializer = new XmlSerializer(typeof(gpxType));
retVal = serializer.Deserialize(xmlReader) as gpxType;
 
xmlReader.Close();
}
return retVal;
}
 
/// <summary>
/// exports gps data to gpx file
/// </summary>
/// <param name="log">gps data</param>
/// <param name="gpxFile">file to export</param>
/// <returns>true if success</returns>
public bool ExportGPX(IEnumerable<List<GpsLog>> log, string gpxFile)
{
try
{
gpxType gpx = new gpxType();
{
gpx.creator = "GMap.NET - http://greatmaps.codeplex.com";
gpx.trk = new trkType[1];
gpx.trk[0] = new trkType();
}
 
var sessions = new List<List<GpsLog>>(log);
gpx.trk[0].trkseg = new trksegType[sessions.Count];
 
int sesid = 0;
 
foreach(var session in sessions)
{
trksegType seg = new trksegType();
{
seg.trkpt = new wptType[session.Count];
}
gpx.trk[0].trkseg[sesid++] = seg;
 
for(int i = 0; i < session.Count; i++)
{
var point = session[i];
 
wptType t = new wptType();
{
#region -- set values --
t.lat = new decimal(point.Position.Lat);
t.lon = new decimal(point.Position.Lng);
 
t.time = point.TimeUTC;
t.timeSpecified = true;
 
if(point.FixType != FixType.Unknown)
{
t.fix = (point.FixType == FixType.XyD ? fixType.Item2d : fixType.Item3d);
t.fixSpecified = true;
}
 
if(point.SeaLevelAltitude.HasValue)
{
t.ele = new decimal(point.SeaLevelAltitude.Value);
t.eleSpecified = true;
}
 
if(point.EllipsoidAltitude.HasValue)
{
t.geoidheight = new decimal(point.EllipsoidAltitude.Value);
t.geoidheightSpecified = true;
}
 
if(point.VerticalDilutionOfPrecision.HasValue)
{
t.vdopSpecified = true;
t.vdop = new decimal(point.VerticalDilutionOfPrecision.Value);
}
 
if(point.HorizontalDilutionOfPrecision.HasValue)
{
t.hdopSpecified = true;
t.hdop = new decimal(point.HorizontalDilutionOfPrecision.Value);
}
 
if(point.PositionDilutionOfPrecision.HasValue)
{
t.pdopSpecified = true;
t.pdop = new decimal(point.PositionDilutionOfPrecision.Value);
}
 
if(point.SatelliteCount.HasValue)
{
t.sat = point.SatelliteCount.Value.ToString();
}
#endregion
}
seg.trkpt[i] = t;
}
}
sessions.Clear();
 
#if !PocketPC
File.WriteAllText(gpxFile, SerializeGPX(gpx), Encoding.UTF8);
#else
using(StreamWriter w = File.CreateText(gpxFile))
{
w.Write(SerializeGPX(gpx));
w.Close();
}
#endif
}
catch(Exception ex)
{
Debug.WriteLine("ExportGPX: " + ex.ToString());
return false;
}
return true;
}
 
#endregion
 
/// <summary>
/// gets image from tile server
/// </summary>
/// <param name="provider"></param>
/// <param name="pos"></param>
/// <param name="zoom"></param>
/// <returns></returns>
public PureImage GetImageFrom(GMapProvider provider, GPoint pos, int zoom, out Exception result)
{
PureImage ret = null;
result = null;
 
try
{
var rtile = new RawTile(provider.DbId, pos, zoom);
 
// let't check memmory first
if(UseMemoryCache)
{
var m = MemoryCache.GetTileFromMemoryCache(rtile);
if(m != null)
{
if(GMapProvider.TileImageProxy != null)
{
ret = GMapProvider.TileImageProxy.FromArray(m);
if(ret == null)
{
#if DEBUG
Debug.WriteLine("Image disposed in MemoryCache o.O, should never happen ;} " + new RawTile(provider.DbId, pos, zoom));
if(Debugger.IsAttached)
{
Debugger.Break();
}
#endif
m = null;
}
}
}
}
 
if(ret == null)
{
if(Mode != AccessMode.ServerOnly && !provider.BypassCache)
{
if(PrimaryCache != null)
{
// hold writer for 5s
if(cacheOnIdleRead)
{
Interlocked.Exchange(ref readingCache, 5);
}
 
ret = PrimaryCache.GetImageFromCache(provider.DbId, pos, zoom);
if(ret != null)
{
if(UseMemoryCache)
{
MemoryCache.AddTileToMemoryCache(rtile, ret.Data.GetBuffer());
}
return ret;
}
}
 
if(SecondaryCache != null)
{
// hold writer for 5s
if(cacheOnIdleRead)
{
Interlocked.Exchange(ref readingCache, 5);
}
 
ret = SecondaryCache.GetImageFromCache(provider.DbId, pos, zoom);
if(ret != null)
{
if(UseMemoryCache)
{
MemoryCache.AddTileToMemoryCache(rtile, ret.Data.GetBuffer());
}
EnqueueCacheTask(new CacheQueueItem(rtile, ret.Data.GetBuffer(), CacheUsage.First));
return ret;
}
}
}
 
if(Mode != AccessMode.CacheOnly)
{
ret = provider.GetTileImage(pos, zoom);
{
// Enqueue Cache
if(ret != null)
{
if(UseMemoryCache)
{
MemoryCache.AddTileToMemoryCache(rtile, ret.Data.GetBuffer());
}
 
if (Mode != AccessMode.ServerOnly && !provider.BypassCache)
{
EnqueueCacheTask(new CacheQueueItem(rtile, ret.Data.GetBuffer(), CacheUsage.Both));
}
}
}
}
else
{
result = noDataException;
}
}
}
catch(Exception ex)
{
result = ex;
ret = null;
Debug.WriteLine("GetImageFrom: " + ex.ToString());
}
 
return ret;
}
 
readonly Exception noDataException = new Exception("No data in local tile cache...");
 
#if !PocketPC
TileHttpHost host;
 
/// <summary>
/// turns on tile host
/// </summary>
/// <param name="port"></param>
public void EnableTileHost(int port)
{
if(host == null)
{
host = new TileHttpHost();
}
host.Start(port);
}
 
/// <summary>
/// turns off tile host
/// </summary>
/// <param name="port"></param>
public void DisableTileHost()
{
if (host != null)
{
host.Stop();
}
}
#endif
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/GPoint.cs
0,0 → 1,160
 
namespace GMap.NET
{
using System.Globalization;
using System;
using System.Collections.Generic;
 
/// <summary>
/// the point ;}
/// </summary>
[Serializable]
public struct GPoint
{
public static readonly GPoint Empty = new GPoint();
 
private long x;
private long y;
 
public GPoint(long x, long y)
{
this.x = x;
this.y = y;
}
 
public GPoint(GSize sz)
{
this.x = sz.Width;
this.y = sz.Height;
}
 
//public GPoint(int dw)
//{
// this.x = (short) LOWORD(dw);
// this.y = (short) HIWORD(dw);
//}
 
public bool IsEmpty
{
get
{
return x == 0 && y == 0;
}
}
 
public long X
{
get
{
return x;
}
set
{
x = value;
}
}
 
public long Y
{
get
{
return y;
}
set
{
y = value;
}
}
 
public static explicit operator GSize(GPoint p)
{
return new GSize(p.X, p.Y);
}
 
public static GPoint operator+(GPoint pt, GSize sz)
{
return Add(pt, sz);
}
 
public static GPoint operator-(GPoint pt, GSize sz)
{
return Subtract(pt, sz);
}
 
public static bool operator==(GPoint left, GPoint right)
{
return left.X == right.X && left.Y == right.Y;
}
 
public static bool operator!=(GPoint left, GPoint right)
{
return !(left == right);
}
 
public static GPoint Add(GPoint pt, GSize sz)
{
return new GPoint(pt.X + sz.Width, pt.Y + sz.Height);
}
 
public static GPoint Subtract(GPoint pt, GSize sz)
{
return new GPoint(pt.X - sz.Width, pt.Y - sz.Height);
}
 
public override bool Equals(object obj)
{
if(!(obj is GPoint))
return false;
GPoint comp = (GPoint) obj;
return comp.X == this.X && comp.Y == this.Y;
}
 
public override int GetHashCode()
{
return (int)(x ^ y);
}
 
public void Offset(long dx, long dy)
{
X += dx;
Y += dy;
}
 
public void Offset(GPoint p)
{
Offset(p.X, p.Y);
}
public void OffsetNegative(GPoint p)
{
Offset(-p.X, -p.Y);
}
 
public override string ToString()
{
return "{X=" + X.ToString(CultureInfo.CurrentCulture) + ",Y=" + Y.ToString(CultureInfo.CurrentCulture) + "}";
}
 
//private static int HIWORD(int n)
//{
// return (n >> 16) & 0xffff;
//}
 
//private static int LOWORD(int n)
//{
// return n & 0xffff;
//}
}
 
internal class GPointComparer : IEqualityComparer<GPoint>
{
public bool Equals(GPoint x, GPoint y)
{
return x.X == y.X && x.Y == y.Y;
}
 
public int GetHashCode(GPoint obj)
{
return obj.GetHashCode();
}
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/GRect.cs
0,0 → 1,324
 
namespace GMap.NET
{
using System;
using System.Globalization;
 
/// <summary>
/// the rect
/// </summary>
public struct GRect
{
public static readonly GRect Empty = new GRect();
 
private long x;
private long y;
private long width;
private long height;
 
public GRect(long x, long y, long width, long height)
{
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
 
public GRect(GPoint location, GSize size)
{
this.x = location.X;
this.y = location.Y;
this.width = size.Width;
this.height = size.Height;
}
 
public static GRect FromLTRB(int left, int top, int right, int bottom)
{
return new GRect(left,
top,
right - left,
bottom - top);
}
 
public GPoint Location
{
get
{
return new GPoint(X, Y);
}
set
{
X = value.X;
Y = value.Y;
}
}
 
public GPoint RightBottom
{
get
{
return new GPoint(Right, Bottom);
}
}
 
public GPoint RightTop
{
get
{
return new GPoint(Right, Top);
}
}
 
public GPoint LeftBottom
{
get
{
return new GPoint(Left, Bottom);
}
}
 
public GSize Size
{
get
{
return new GSize(Width, Height);
}
set
{
this.Width = value.Width;
this.Height = value.Height;
}
}
 
public long X
{
get
{
return x;
}
set
{
x = value;
}
}
 
public long Y
{
get
{
return y;
}
set
{
y = value;
}
}
 
public long Width
{
get
{
return width;
}
set
{
width = value;
}
}
 
public long Height
{
get
{
return height;
}
set
{
height = value;
}
}
 
public long Left
{
get
{
return X;
}
}
 
public long Top
{
get
{
return Y;
}
}
 
public long Right
{
get
{
return X + Width;
}
}
 
public long Bottom
{
get
{
return Y + Height;
}
}
 
public bool IsEmpty
{
get
{
return height == 0 && width == 0 && x == 0 && y == 0;
}
}
 
public override bool Equals(object obj)
{
if(!(obj is GRect))
return false;
 
GRect comp = (GRect) obj;
 
return (comp.X == this.X) &&
(comp.Y == this.Y) &&
(comp.Width == this.Width) &&
(comp.Height == this.Height);
}
 
public static bool operator==(GRect left, GRect right)
{
return (left.X == right.X
&& left.Y == right.Y
&& left.Width == right.Width
&& left.Height == right.Height);
}
 
public static bool operator!=(GRect left, GRect right)
{
return !(left == right);
}
 
public bool Contains(long x, long y)
{
return this.X <= x &&
x < this.X + this.Width &&
this.Y <= y &&
y < this.Y + this.Height;
}
 
public bool Contains(GPoint pt)
{
return Contains(pt.X, pt.Y);
}
 
public bool Contains(GRect rect)
{
return (this.X <= rect.X) &&
((rect.X + rect.Width) <= (this.X + this.Width)) &&
(this.Y <= rect.Y) &&
((rect.Y + rect.Height) <= (this.Y + this.Height));
}
 
public override int GetHashCode()
{
if(this.IsEmpty)
{
return 0;
}
return (int)(((this.X ^ ((this.Y << 13) | (this.Y >> 0x13))) ^ ((this.Width << 0x1a) | (this.Width >> 6))) ^ ((this.Height << 7) | (this.Height >> 0x19)));
}
 
public void Inflate(long width, long height)
{
this.X -= width;
this.Y -= height;
this.Width += 2*width;
this.Height += 2*height;
}
 
public void Inflate(GSize size)
{
Inflate(size.Width, size.Height);
}
 
public static GRect Inflate(GRect rect, long x, long y)
{
GRect r = rect;
r.Inflate(x, y);
return r;
}
 
public void Intersect(GRect rect)
{
GRect result = GRect.Intersect(rect, this);
 
this.X = result.X;
this.Y = result.Y;
this.Width = result.Width;
this.Height = result.Height;
}
 
public static GRect Intersect(GRect a, GRect b)
{
long x1 = Math.Max(a.X, b.X);
long x2 = Math.Min(a.X + a.Width, b.X + b.Width);
long y1 = Math.Max(a.Y, b.Y);
long y2 = Math.Min(a.Y + a.Height, b.Y + b.Height);
 
if(x2 >= x1
&& y2 >= y1)
{
 
return new GRect(x1, y1, x2 - x1, y2 - y1);
}
return GRect.Empty;
}
 
public bool IntersectsWith(GRect rect)
{
return (rect.X < this.X + this.Width) &&
(this.X < (rect.X + rect.Width)) &&
(rect.Y < this.Y + this.Height) &&
(this.Y < rect.Y + rect.Height);
}
 
public static GRect Union(GRect a, GRect b)
{
long x1 = Math.Min(a.X, b.X);
long x2 = Math.Max(a.X + a.Width, b.X + b.Width);
long y1 = Math.Min(a.Y, b.Y);
long y2 = Math.Max(a.Y + a.Height, b.Y + b.Height);
 
return new GRect(x1, y1, x2 - x1, y2 - y1);
}
 
public void Offset(GPoint pos)
{
Offset(pos.X, pos.Y);
}
 
public void OffsetNegative(GPoint pos)
{
Offset(-pos.X, -pos.Y);
}
 
public void Offset(long x, long y)
{
this.X += x;
this.Y += y;
}
 
public override string ToString()
{
return "{X=" + X.ToString(CultureInfo.CurrentCulture) + ",Y=" + Y.ToString(CultureInfo.CurrentCulture) +
",Width=" + Width.ToString(CultureInfo.CurrentCulture) +
",Height=" + Height.ToString(CultureInfo.CurrentCulture) + "}";
}
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/GSize.cs
0,0 → 1,121
 
namespace GMap.NET
{
using System.Globalization;
 
/// <summary>
/// the size
/// </summary>
public struct GSize
{
public static readonly GSize Empty = new GSize();
 
private long width;
private long height;
 
public GSize(GPoint pt)
{
width = pt.X;
height = pt.Y;
}
 
public GSize(long width, long height)
{
this.width = width;
this.height = height;
}
 
public static GSize operator +(GSize sz1, GSize sz2)
{
return Add(sz1, sz2);
}
 
public static GSize operator -(GSize sz1, GSize sz2)
{
return Subtract(sz1, sz2);
}
 
public static bool operator ==(GSize sz1, GSize sz2)
{
return sz1.Width == sz2.Width && sz1.Height == sz2.Height;
}
 
public static bool operator !=(GSize sz1, GSize sz2)
{
return !(sz1 == sz2);
}
 
public static explicit operator GPoint(GSize size)
{
return new GPoint(size.Width, size.Height);
}
 
public bool IsEmpty
{
get
{
return width == 0 && height == 0;
}
}
 
public long Width
{
get
{
return width;
}
set
{
width = value;
}
}
 
public long Height
{
get
{
return height;
}
set
{
height = value;
}
}
 
public static GSize Add(GSize sz1, GSize sz2)
{
return new GSize(sz1.Width + sz2.Width, sz1.Height + sz2.Height);
}
 
public static GSize Subtract(GSize sz1, GSize sz2)
{
return new GSize(sz1.Width - sz2.Width, sz1.Height - sz2.Height);
}
 
public override bool Equals(object obj)
{
if(!(obj is GSize))
return false;
 
GSize comp = (GSize)obj;
// Note value types can't have derived classes, so we don't need to
//
return (comp.width == this.width) &&
(comp.height == this.height);
}
 
public override int GetHashCode()
{
if(this.IsEmpty)
{
return 0;
}
return (Width.GetHashCode() ^ Height.GetHashCode());
}
 
public override string ToString()
{
return "{Width=" + width.ToString(CultureInfo.CurrentCulture) + ", Height=" + height.ToString(CultureInfo.CurrentCulture) + "}";
}
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/GeocodingProvider.cs
0,0 → 1,25

namespace GMap.NET
{
using System.Collections.Generic;
 
/// <summary>
/// geocoding interface
/// </summary>
public interface GeocodingProvider
{
GeoCoderStatusCode GetPoints(string keywords, out List<PointLatLng> pointList);
 
PointLatLng? GetPoint(string keywords, out GeoCoderStatusCode status);
 
GeoCoderStatusCode GetPoints(Placemark placemark, out List<PointLatLng> pointList);
 
PointLatLng? GetPoint(Placemark placemark, out GeoCoderStatusCode status);
 
// ...
 
GeoCoderStatusCode GetPlacemarks(PointLatLng location, out List<Placemark> placemarkList);
 
Placemark ? GetPlacemark(PointLatLng location, out GeoCoderStatusCode status);
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/GpsLog.cs
0,0 → 1,49

namespace GMap.NET
{
using System;
 
public struct GpsLog
{
public DateTime TimeUTC;
public long SessionCounter;
public double? Delta;
public double? Speed;
public double? SeaLevelAltitude;
public double? EllipsoidAltitude;
public short? SatellitesInView;
public short? SatelliteCount;
public PointLatLng Position;
public double? PositionDilutionOfPrecision;
public double? HorizontalDilutionOfPrecision;
public double? VerticalDilutionOfPrecision;
public FixQuality FixQuality;
public FixType FixType;
public FixSelection FixSelection;
 
public override string ToString()
{
return string.Format("{0}: {1}", SessionCounter, TimeUTC);
}
}
 
public enum FixQuality : int
{
Unknown=0,
Gps,
DGps
}
public enum FixType : int
{
Unknown=0,
XyD,
XyzD
}
 
public enum FixSelection : int
{
Unknown=0,
Auto,
Manual
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/Interface.cs
0,0 → 1,72

namespace GMap.NET
{
using GMap.NET.MapProviders;
 
public interface Interface
{
PointLatLng Position
{
get;
set;
}
 
GPoint PositionPixel
{
get;
}
 
string CacheLocation
{
get;
set;
}
 
bool IsDragging
{
get;
}
 
RectLatLng ViewArea
{
get;
}
 
GMapProvider MapProvider
{
get;
set;
}
 
bool CanDragMap
{
get;
set;
}
 
RenderMode RenderMode
{
get;
}
 
// events
event PositionChanged OnPositionChanged;
event TileLoadComplete OnTileLoadComplete;
event TileLoadStart OnTileLoadStart;
event MapDrag OnMapDrag;
event MapZoomChanged OnMapZoomChanged;
event MapTypeChanged OnMapTypeChanged;
 
void ReloadMap();
 
PointLatLng FromLocalToLatLng(int x, int y);
GPoint FromLatLngToLocal(PointLatLng point);
 
#if !PocketPC
#if SQLite
bool ShowExportDialog();
bool ShowImportDialog();
#endif
#endif
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/LanguageType.cs
0,0 → 1,179

namespace GMap.NET
{
using System.ComponentModel;
 
/// <summary>
/// This enum contains all possible languages for the Google maps.
/// You can find latest information about supported languages in the:
/// http://tinyurl.com/yh4va36 <- http://spreadsheets.server.com/pub?key=p9pdwsai2hDMsLkXsoM05KQ&gid=1
/// </summary>
public enum LanguageType
{
[Description("ar")]
Arabic,
 
[Description("bg")]
Bulgarian,
 
[Description("bn")]
Bengali,
 
[Description("ca")]
Catalan,
 
[Description("cs")]
Czech,
 
[Description("da")]
Danish,
 
[Description("de")]
German,
 
[Description("el")]
Greek,
 
[Description("en")]
English,
 
[Description("en-AU")]
EnglishAustralian,
 
[Description("en-GB")]
EnglishGreatBritain,
 
[Description("es")]
Spanish,
 
[Description("eu")]
Basque,
 
[Description("fa")]
FARSI,
 
[Description("fi")]
Finnish,
 
[Description("fil")]
Filipino,
 
[Description("fr")]
French,
 
[Description("gl")]
Galician,
 
[Description("gu")]
Gujarati,
[Description("hi")]
Hindi,
 
[Description("hr")]
Croatian,
 
[Description("hu")]
Hungarian,
 
[Description("id")]
Indonesian,
 
[Description("it")]
Italian,
 
[Description("iw")]
Hebrew,
 
[Description("ja")]
Japanese,
 
[Description("kn")]
Kannada,
 
[Description("ko")]
Korean,
 
[Description("lt")]
Lithuanian,
 
[Description("lv")]
Latvian,
 
[Description("ml")]
Malayalam,
 
[Description("mr")]
Marathi,
 
[Description("nl")]
Dutch,
 
[Description("nn")]
NorwegianNynorsk,
 
[Description("no")]
Norwegian,
 
[Description("or")]
Oriya,
 
[Description("pl")]
Polish,
 
[Description("pt")]
Portuguese,
 
[Description("pt-BR")]
PortugueseBrazil,
 
[Description("pt-PT")]
PortuguesePortugal,
 
[Description("rm")]
Romansch,
[Description("ro")]
Romanian,
 
[Description("ru")]
Russian,
 
[Description("sk")]
Slovak,
 
[Description("sl")]
Slovenian,
 
[Description("sr")]
Serbian,
 
[Description("sv")]
Swedish,
 
[Description("tl")]
TAGALOG,
 
[Description("ta")]
Tamil,
 
[Description("te")]
Telugu,
 
[Description("th")]
Thai,
 
[Description("tr")]
Turkish,
 
[Description("uk")]
Ukrainian,
 
[Description("vi")]
Vietnamese,
 
[Description("zh-CN")]
ChineseSimplified,
 
[Description("zh-TW")]
ChineseTraditional,
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/MapRoute.cs
0,0 → 1,160

namespace GMap.NET
{
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using GMap.NET.MapProviders;
 
/// <summary>
/// represents route of map
/// </summary>
[Serializable]
#if !PocketPC
public class MapRoute : ISerializable, IDeserializationCallback
#else
public class MapRoute
#endif
{
/// <summary>
/// points of route
/// </summary>
public readonly List<PointLatLng> Points = new List<PointLatLng>();
 
/// <summary>
/// route info
/// </summary>
public string Name;
 
/// <summary>
/// custom object
/// </summary>
public object Tag;
 
/// <summary>
/// route start point
/// </summary>
public PointLatLng? From
{
get
{
if(Points.Count > 0)
{
return Points[0];
}
 
return null;
}
}
 
/// <summary>
/// route end point
/// </summary>
public PointLatLng? To
{
get
{
if(Points.Count > 1)
{
return Points[Points.Count - 1];
}
 
return null;
}
}
 
public MapRoute(string name)
{
Name = name;
}
 
public MapRoute(IEnumerable<PointLatLng> points, string name)
{
Points.AddRange(points);
Name = name;
}
 
/// <summary>
/// route distance (in km)
/// </summary>
public double Distance
{
get
{
double distance = 0.0;
 
if(From.HasValue && To.HasValue)
{
for(int i = 1; i < Points.Count; i++)
{
distance += GMapProviders.EmptyProvider.Projection.GetDistance(Points[i - 1], Points[i]);
}
}
 
return distance;
}
}
 
/// <summary>
/// clears points and sets tag and name to null
/// </summary>
public void Clear()
{
Points.Clear();
Tag = null;
Name = null;
}
 
#if !PocketPC
#region ISerializable Members
 
// Temp store for de-serialization.
private PointLatLng[] deserializedPoints;
 
/// <summary>
/// Populates a <see cref="T:System.Runtime.Serialization.SerializationInfo"/> with the data needed to serialize the target object.
/// </summary>
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> to populate with data.</param>
/// <param name="context">The destination (see <see cref="T:System.Runtime.Serialization.StreamingContext"/>) for this serialization.</param>
/// <exception cref="T:System.Security.SecurityException">
/// The caller does not have the required permission.
/// </exception>
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("Name", this.Name);
info.AddValue("Tag", this.Tag);
info.AddValue("Points", this.Points.ToArray());
}
 
/// <summary>
/// Initializes a new instance of the <see cref="MapRoute"/> class.
/// </summary>
/// <param name="info">The info.</param>
/// <param name="context">The context.</param>
protected MapRoute(SerializationInfo info, StreamingContext context)
{
this.Name = info.GetString("Name");
this.Tag = Extensions.GetValue<object>(info, "Tag", null);
this.deserializedPoints = Extensions.GetValue<PointLatLng[]>(info, "Points");
this.Points = new List<PointLatLng>();
}
 
#endregion
 
#region IDeserializationCallback Members
 
/// <summary>
/// Runs when the entire object graph has been de-serialized.
/// </summary>
/// <param name="sender">The object that initiated the callback. The functionality for this parameter is not currently implemented.</param>
public virtual void OnDeserialization(object sender)
{
// Accounts for the de-serialization being breadth first rather than depth first.
Points.AddRange(deserializedPoints);
Points.TrimExcess();
}
 
#endregion
#endif
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/MapType.cs
0,0 → 1,127

namespace GMap.NET
{
using System;
 
/// <summary>
/// types of great maps, legacy, not used anymore,
/// left for old ids
/// </summary>
public enum MapType
{
None = 0, // displays no map
 
[Obsolete("check http://greatmaps.codeplex.com/discussions/252531", false)]
GoogleMap = 1,
[Obsolete("check http://greatmaps.codeplex.com/discussions/252531", false)]
GoogleSatellite = 4,
[Obsolete("check http://greatmaps.codeplex.com/discussions/252531", false)]
GoogleLabels = 8,
[Obsolete("check http://greatmaps.codeplex.com/discussions/252531", false)]
GoogleTerrain = 16,
[Obsolete("check http://greatmaps.codeplex.com/discussions/252531", false)]
GoogleHybrid = 20,
 
[Obsolete("check http://greatmaps.codeplex.com/discussions/252531", false)]
GoogleMapChina = 22,
[Obsolete("check http://greatmaps.codeplex.com/discussions/252531", false)]
GoogleSatelliteChina = 24,
[Obsolete("check http://greatmaps.codeplex.com/discussions/252531", false)]
GoogleLabelsChina = 26,
[Obsolete("check http://greatmaps.codeplex.com/discussions/252531", false)]
GoogleTerrainChina = 28,
[Obsolete("check http://greatmaps.codeplex.com/discussions/252531", false)]
GoogleHybridChina = 29,
 
OpenStreetMap = 32, //
OpenStreetOsm = 33, //
OpenStreetMapSurfer = 34, //
OpenStreetMapSurferTerrain = 35, //
OpenSeaMapLabels = 36, //
OpenSeaMapHybrid = 37, //
OpenCycleMap = 38, //
 
YahooMap = 64,
YahooSatellite = 128,
YahooLabels = 256,
YahooHybrid = 333,
 
BingMap = 444,
BingMap_New = 455,
BingSatellite = 555,
BingHybrid = 666,
 
ArcGIS_StreetMap_World_2D = 777,
ArcGIS_Imagery_World_2D = 788,
ArcGIS_ShadedRelief_World_2D = 799,
ArcGIS_Topo_US_2D = 811,
 
#region -- use these numbers to clean up old stuff --
//ArcGIS_MapsLT_Map_Old= 877,
//ArcGIS_MapsLT_OrtoFoto_Old = 888,
//ArcGIS_MapsLT_Map_Labels_Old = 890,
//ArcGIS_MapsLT_Map_Hybrid_Old = 899,
//ArcGIS_MapsLT_Map=977,
//ArcGIS_MapsLT_OrtoFoto=988,
//ArcGIS_MapsLT_Map_Labels=990,
//ArcGIS_MapsLT_Map_Hybrid=999,
//ArcGIS_MapsLT_Map=978,
//ArcGIS_MapsLT_OrtoFoto=989,
//ArcGIS_MapsLT_Map_Labels=991,
//ArcGIS_MapsLT_Map_Hybrid=998,
#endregion
 
ArcGIS_World_Physical_Map = 822,
ArcGIS_World_Shaded_Relief = 833,
ArcGIS_World_Street_Map = 844,
ArcGIS_World_Terrain_Base = 855,
ArcGIS_World_Topo_Map = 866,
 
MapsLT_Map = 1000,
MapsLT_OrtoFoto = 1001,
MapsLT_Map_Labels = 1002,
MapsLT_Map_Hybrid = 1003,
MapsLT_Map_2_5D = 1004, // 2.5D only for zoom 10 & 11
MapsLT_OrtoFoto_2010 = 1101, // new but only partial coverage
MapsLT_Map_Hybrid_2010 = 1103, // --..--
 
KarteLV_Map = 1500,
 
PergoTurkeyMap = 2001,
SigPacSpainMap = 3001,
 
[Obsolete("check http://greatmaps.codeplex.com/discussions/252531", false)]
GoogleMapKorea = 4001,
[Obsolete("check http://greatmaps.codeplex.com/discussions/252531", false)]
GoogleSatelliteKorea = 4002,
[Obsolete("check http://greatmaps.codeplex.com/discussions/252531", false)]
GoogleLabelsKorea = 4003,
[Obsolete("check http://greatmaps.codeplex.com/discussions/252531", false)]
GoogleHybridKorea = 4005,
 
YandexMapRu = 5000,
YandexMapRuSatellite = 5001,
YandexMapRuLabels = 5002,
YandexMapRuHybrid = 5003,
 
MapBenderWMS = 6000,
 
MapyCZ_Map = 7000,
MapyCZ_MapTurist = 7001,
MapyCZ_Satellite = 7002,
MapyCZ_Labels = 7003,
MapyCZ_Hybrid = 7004,
MapyCZ_History = 7005,
MapyCZ_HistoryHybrid = 7006,
 
NearMap = 8000,
NearMapSatellite = 8001,
NearMapLabels = 8002,
NearMapHybrid = 8003,
 
OviMap = 9000,
OviMapSatellite = 9001,
OviMapHybrid = 9002,
OviMapTerrain = 9003,
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/MouseWheelZoomType.cs
0,0 → 1,25

namespace GMap.NET
{
/// <summary>
/// map zooming type
/// </summary>
public enum MouseWheelZoomType
{
/// <summary>
/// zooms map to current mouse position and makes it map center
/// </summary>
MousePositionAndCenter,
 
/// <summary>
/// zooms to current mouse position, but doesn't make it map center,
/// google/bing style ;}
/// </summary>
MousePositionWithoutCenter,
 
/// <summary>
/// zooms map to current view center
/// </summary>
ViewCenter,
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/Placemark.cs
0,0 → 1,63

namespace GMap.NET
{
/// <summary>
/// represents place info
/// </summary>
public struct Placemark
{
string address;
 
/// <summary>
/// the address
/// </summary>
public string Address
{
get
{
return address;
}
internal set
{
address = value;
}
}
 
/// <summary>
/// the accuracy of address
/// </summary>
public int Accuracy;
 
// parsed values from address
public string ThoroughfareName;
public string LocalityName;
public string PostalCodeNumber;
public string CountryName;
public string AdministrativeAreaName;
public string DistrictName;
public string SubAdministrativeAreaName;
public string Neighborhood;
public string StreetNumber;
 
public string CountryNameCode;
public string HouseNo;
 
internal Placemark(string address)
{
this.address = address;
 
Accuracy = 0;
HouseNo = string.Empty;
ThoroughfareName = string.Empty;
DistrictName = string.Empty;
LocalityName = string.Empty;
PostalCodeNumber = string.Empty;
CountryName = string.Empty;
CountryNameCode = string.Empty;
AdministrativeAreaName = string.Empty;
SubAdministrativeAreaName = string.Empty;
Neighborhood = string.Empty;
StreetNumber = string.Empty;
}
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/PointLatLng.cs
0,0 → 1,129

namespace GMap.NET
{
using System;
using System.Globalization;
 
/// <summary>
/// the point of coordinates
/// </summary>
[Serializable]
public struct PointLatLng
{
public static readonly PointLatLng Empty = new PointLatLng();
private double lat;
private double lng;
 
bool NotEmpty;
 
public PointLatLng(double lat, double lng)
{
this.lat = lat;
this.lng = lng;
NotEmpty = true;
}
 
/// <summary>
/// returns true if coordinates wasn't assigned
/// </summary>
public bool IsEmpty
{
get
{
return !NotEmpty;
}
}
 
public double Lat
{
get
{
return this.lat;
}
set
{
this.lat = value;
NotEmpty = true;
}
}
 
public double Lng
{
get
{
return this.lng;
}
set
{
this.lng = value;
NotEmpty = true;
}
}
 
public static PointLatLng operator +(PointLatLng pt, SizeLatLng sz)
{
return Add(pt, sz);
}
 
public static PointLatLng operator -(PointLatLng pt, SizeLatLng sz)
{
return Subtract(pt, sz);
}
 
public static SizeLatLng operator -(PointLatLng pt1, PointLatLng pt2)
{
return new SizeLatLng(pt1.Lat - pt2.Lat, pt2.Lng - pt1.Lng);
}
 
public static bool operator ==(PointLatLng left, PointLatLng right)
{
return ((left.Lng == right.Lng) && (left.Lat == right.Lat));
}
 
public static bool operator !=(PointLatLng left, PointLatLng right)
{
return !(left == right);
}
 
public static PointLatLng Add(PointLatLng pt, SizeLatLng sz)
{
return new PointLatLng(pt.Lat - sz.HeightLat, pt.Lng + sz.WidthLng);
}
 
public static PointLatLng Subtract(PointLatLng pt, SizeLatLng sz)
{
return new PointLatLng(pt.Lat + sz.HeightLat, pt.Lng - sz.WidthLng);
}
 
public override bool Equals(object obj)
{
if(!(obj is PointLatLng))
{
return false;
}
PointLatLng tf = (PointLatLng)obj;
return (((tf.Lng == this.Lng) && (tf.Lat == this.Lat)) && tf.GetType().Equals(base.GetType()));
}
 
public void Offset(PointLatLng pos)
{
this.Offset(pos.Lat, pos.Lng);
}
 
public void Offset(double lat, double lng)
{
this.Lng += lng;
this.Lat -= lat;
}
 
public override int GetHashCode()
{
return (this.Lng.GetHashCode() ^ this.Lat.GetHashCode());
}
 
public override string ToString()
{
return string.Format(CultureInfo.CurrentCulture, "{{Lat={0}, Lng={1}}}", this.Lat, this.Lng);
}
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/PureImageCache.cs
0,0 → 1,39

namespace GMap.NET
{
using System.IO;
using System;
 
/// <summary>
/// pure abstraction for image cache
/// </summary>
public interface PureImageCache
{
/// <summary>
/// puts image to db
/// </summary>
/// <param name="tile"></param>
/// <param name="type"></param>
/// <param name="pos"></param>
/// <param name="zoom"></param>
/// <returns></returns>
bool PutImageToCache(byte[] tile, int type, GPoint pos, int zoom);
 
/// <summary>
/// gets image from db
/// </summary>
/// <param name="type"></param>
/// <param name="pos"></param>
/// <param name="zoom"></param>
/// <returns></returns>
PureImage GetImageFromCache(int type, GPoint pos, int zoom);
 
/// <summary>
/// delete old tiles beyond a supplied date
/// </summary>
/// <param name="date">Tiles older than this will be deleted.</param>
/// <param name="type">provider dbid or null to use all providers</param>
/// <returns>The number of deleted tiles.</returns>
int DeleteOlderThan(DateTime date, int ? type);
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/PureProjection.cs
0,0 → 1,537

namespace GMap.NET
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
 
/// <summary>
/// defines projection
/// </summary>
public abstract class PureProjection
{
readonly List<Dictionary<PointLatLng, GPoint>> FromLatLngToPixelCache = new List<Dictionary<PointLatLng, GPoint>>(33);
readonly List<Dictionary<GPoint, PointLatLng>> FromPixelToLatLngCache = new List<Dictionary<GPoint, PointLatLng>>(33);
 
public PureProjection()
{
for(int i = 0; i < FromLatLngToPixelCache.Capacity; i++)
{
FromLatLngToPixelCache.Add(new Dictionary<PointLatLng, GPoint>());
FromPixelToLatLngCache.Add(new Dictionary<GPoint, PointLatLng>());
}
}
 
/// <summary>
/// size of tile
/// </summary>
public abstract GSize TileSize
{
get;
}
 
/// <summary>
/// Semi-major axis of ellipsoid, in meters
/// </summary>
public abstract double Axis
{
get;
}
 
/// <summary>
/// Flattening of ellipsoid
/// </summary>
public abstract double Flattening
{
get;
}
 
/// <summary>
/// get pixel coordinates from lat/lng
/// </summary>
/// <param name="lat"></param>
/// <param name="lng"></param>
/// <param name="zoom"></param>
/// <returns></returns>
public abstract GPoint FromLatLngToPixel(double lat, double lng, int zoom);
 
/// <summary>
/// gets lat/lng coordinates from pixel coordinates
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="zoom"></param>
/// <returns></returns>
public abstract PointLatLng FromPixelToLatLng(long x, long y, int zoom);
 
public GPoint FromLatLngToPixel(PointLatLng p, int zoom)
{
return FromLatLngToPixel(p, zoom, false);
}
 
/// <summary>
/// get pixel coordinates from lat/lng
/// </summary>
/// <param name="p"></param>
/// <param name="zoom"></param>
/// <returns></returns>
public GPoint FromLatLngToPixel(PointLatLng p, int zoom, bool useCache)
{
if(useCache)
{
GPoint ret = GPoint.Empty;
if(!FromLatLngToPixelCache[zoom].TryGetValue(p, out ret))
{
ret = FromLatLngToPixel(p.Lat, p.Lng, zoom);
FromLatLngToPixelCache[zoom].Add(p, ret);
 
// for reverse cache
if(!FromPixelToLatLngCache[zoom].ContainsKey(ret))
{
FromPixelToLatLngCache[zoom].Add(ret, p);
}
 
Debug.WriteLine("FromLatLngToPixelCache[" + zoom + "] added " + p + " with " + ret);
}
return ret;
}
else
{
return FromLatLngToPixel(p.Lat, p.Lng, zoom);
}
}
 
public PointLatLng FromPixelToLatLng(GPoint p, int zoom)
{
return FromPixelToLatLng(p, zoom, false);
}
 
/// <summary>
/// gets lat/lng coordinates from pixel coordinates
/// </summary>
/// <param name="p"></param>
/// <param name="zoom"></param>
/// <returns></returns>
public PointLatLng FromPixelToLatLng(GPoint p, int zoom, bool useCache)
{
if(useCache)
{
PointLatLng ret = PointLatLng.Empty;
if(!FromPixelToLatLngCache[zoom].TryGetValue(p, out ret))
{
ret = FromPixelToLatLng(p.X, p.Y, zoom);
FromPixelToLatLngCache[zoom].Add(p, ret);
 
// for reverse cache
if(!FromLatLngToPixelCache[zoom].ContainsKey(ret))
{
FromLatLngToPixelCache[zoom].Add(ret, p);
}
 
Debug.WriteLine("FromPixelToLatLngCache[" + zoom + "] added " + p + " with " + ret);
}
return ret;
}
else
{
return FromPixelToLatLng(p.X, p.Y, zoom);
}
}
 
/// <summary>
/// gets tile coorddinate from pixel coordinates
/// </summary>
/// <param name="p"></param>
/// <returns></returns>
public virtual GPoint FromPixelToTileXY(GPoint p)
{
return new GPoint((long)(p.X / TileSize.Width), (long)(p.Y / TileSize.Height));
}
 
/// <summary>
/// gets pixel coordinate from tile coordinate
/// </summary>
/// <param name="p"></param>
/// <returns></returns>
public virtual GPoint FromTileXYToPixel(GPoint p)
{
return new GPoint((p.X * TileSize.Width), (p.Y * TileSize.Height));
}
 
/// <summary>
/// min. tile in tiles at custom zoom level
/// </summary>
/// <param name="zoom"></param>
/// <returns></returns>
public abstract GSize GetTileMatrixMinXY(int zoom);
 
/// <summary>
/// max. tile in tiles at custom zoom level
/// </summary>
/// <param name="zoom"></param>
/// <returns></returns>
public abstract GSize GetTileMatrixMaxXY(int zoom);
 
/// <summary>
/// gets matrix size in tiles
/// </summary>
/// <param name="zoom"></param>
/// <returns></returns>
public virtual GSize GetTileMatrixSizeXY(int zoom)
{
GSize sMin = GetTileMatrixMinXY(zoom);
GSize sMax = GetTileMatrixMaxXY(zoom);
 
return new GSize(sMax.Width - sMin.Width + 1, sMax.Height - sMin.Height + 1);
}
 
/// <summary>
/// tile matrix size in pixels at custom zoom level
/// </summary>
/// <param name="zoom"></param>
/// <returns></returns>
public long GetTileMatrixItemCount(int zoom)
{
GSize s = GetTileMatrixSizeXY(zoom);
return (s.Width * s.Height);
}
 
/// <summary>
/// gets matrix size in pixels
/// </summary>
/// <param name="zoom"></param>
/// <returns></returns>
public virtual GSize GetTileMatrixSizePixel(int zoom)
{
GSize s = GetTileMatrixSizeXY(zoom);
return new GSize(s.Width * TileSize.Width, s.Height * TileSize.Height);
}
 
/// <summary>
/// gets all tiles in rect at specific zoom
/// </summary>
public List<GPoint> GetAreaTileList(RectLatLng rect, int zoom, int padding)
{
List<GPoint> ret = new List<GPoint>();
 
GPoint topLeft = FromPixelToTileXY(FromLatLngToPixel(rect.LocationTopLeft, zoom));
GPoint rightBottom = FromPixelToTileXY(FromLatLngToPixel(rect.LocationRightBottom, zoom));
 
for(long x = (topLeft.X - padding); x <= (rightBottom.X + padding); x++)
{
for(long y = (topLeft.Y - padding); y <= (rightBottom.Y + padding); y++)
{
GPoint p = new GPoint(x, y);
if(!ret.Contains(p) && p.X >= 0 && p.Y >= 0)
{
ret.Add(p);
}
}
}
 
return ret;
}
 
/// <summary>
/// The ground resolution indicates the distance (in meters) on the ground that’s represented by a single pixel in the map.
/// For example, at a ground resolution of 10 meters/pixel, each pixel represents a ground distance of 10 meters.
/// </summary>
/// <param name="zoom"></param>
/// <param name="latitude"></param>
/// <returns></returns>
public virtual double GetGroundResolution(int zoom, double latitude)
{
return (Math.Cos(latitude * (Math.PI / 180)) * 2 * Math.PI * Axis) / GetTileMatrixSizePixel(zoom).Width;
}
 
/// <summary>
/// gets boundaries
/// </summary>
public virtual RectLatLng Bounds
{
get
{
return RectLatLng.FromLTRB(-180, 90, 180, -90);
}
}
 
#region -- math functions --
 
/// <summary>
/// PI
/// </summary>
protected static readonly double PI = Math.PI;
 
/// <summary>
/// Half of PI
/// </summary>
protected static readonly double HALF_PI = (PI * 0.5);
 
/// <summary>
/// PI * 2
/// </summary>
protected static readonly double TWO_PI = (PI * 2.0);
 
/// <summary>
/// EPSLoN
/// </summary>
protected static readonly double EPSLoN = 1.0e-10;
 
/// <summary>
/// MAX_VAL
/// </summary>
protected const double MAX_VAL = 4;
 
/// <summary>
/// MAXLONG
/// </summary>
protected static readonly double MAXLONG = 2147483647;
 
/// <summary>
/// DBLLONG
/// </summary>
protected static readonly double DBLLONG = 4.61168601e18;
 
static readonly double R2D = 180 / Math.PI;
static readonly double D2R = Math.PI / 180;
 
public static double DegreesToRadians(double deg)
{
return (D2R * deg);
}
 
public static double RadiansToDegrees(double rad)
{
return (R2D * rad);
}
 
///<summary>
/// return the sign of an argument
///</summary>
protected static double Sign(double x)
{
if(x < 0.0)
return (-1);
else
return (1);
}
 
protected static double AdjustLongitude(double x)
{
long count = 0;
while(true)
{
if(Math.Abs(x) <= PI)
break;
else
if(((long)Math.Abs(x / Math.PI)) < 2)
x = x - (Sign(x) * TWO_PI);
else
if(((long)Math.Abs(x / TWO_PI)) < MAXLONG)
{
x = x - (((long)(x / TWO_PI)) * TWO_PI);
}
else
if(((long)Math.Abs(x / (MAXLONG * TWO_PI))) < MAXLONG)
{
x = x - (((long)(x / (MAXLONG * TWO_PI))) * (TWO_PI * MAXLONG));
}
else
if(((long)Math.Abs(x / (DBLLONG * TWO_PI))) < MAXLONG)
{
x = x - (((long)(x / (DBLLONG * TWO_PI))) * (TWO_PI * DBLLONG));
}
else
x = x - (Sign(x) * TWO_PI);
count++;
if(count > MAX_VAL)
break;
}
return (x);
}
 
/// <summary>
/// calculates the sine and cosine
/// </summary>
protected static void SinCos(double val, out double sin, out double cos)
{
sin = Math.Sin(val);
cos = Math.Cos(val);
}
 
/// <summary>
/// computes the constants e0, e1, e2, and e3 which are used
/// in a series for calculating the distance along a meridian.
/// </summary>
/// <param name="x">represents the eccentricity squared</param>
/// <returns></returns>
protected static double e0fn(double x)
{
return (1.0 - 0.25 * x * (1.0 + x / 16.0 * (3.0 + 1.25 * x)));
}
 
protected static double e1fn(double x)
{
return (0.375 * x * (1.0 + 0.25 * x * (1.0 + 0.46875 * x)));
}
 
protected static double e2fn(double x)
{
return (0.05859375 * x * x * (1.0 + 0.75 * x));
}
 
protected static double e3fn(double x)
{
return (x * x * x * (35.0 / 3072.0));
}
 
/// <summary>
/// computes the value of M which is the distance along a meridian
/// from the Equator to latitude phi.
/// </summary>
protected static double mlfn(double e0, double e1, double e2, double e3, double phi)
{
return (e0 * phi - e1 * Math.Sin(2.0 * phi) + e2 * Math.Sin(4.0 * phi) - e3 * Math.Sin(6.0 * phi));
}
 
/// <summary>
/// calculates UTM zone number
/// </summary>
/// <param name="lon">Longitude in degrees</param>
/// <returns></returns>
protected static long GetUTMzone(double lon)
{
return ((long)(((lon + 180.0) / 6.0) + 1.0));
}
 
/// <summary>
/// Clips a number to the specified minimum and maximum values.
/// </summary>
/// <param name="n">The number to clip.</param>
/// <param name="minValue">Minimum allowable value.</param>
/// <param name="maxValue">Maximum allowable value.</param>
/// <returns>The clipped value.</returns>
protected static double Clip(double n, double minValue, double maxValue)
{
return Math.Min(Math.Max(n, minValue), maxValue);
}
 
/// <summary>
/// distance (in km) between two points specified by latitude/longitude
/// The Haversine formula, http://www.movable-type.co.uk/scripts/latlong.html
/// </summary>
/// <param name="p1"></param>
/// <param name="p2"></param>
/// <returns></returns>
public double GetDistance(PointLatLng p1, PointLatLng p2)
{
double dLat1InRad = p1.Lat * (Math.PI / 180);
double dLong1InRad = p1.Lng * (Math.PI / 180);
double dLat2InRad = p2.Lat * (Math.PI / 180);
double dLong2InRad = p2.Lng * (Math.PI / 180);
double dLongitude = dLong2InRad - dLong1InRad;
double dLatitude = dLat2InRad - dLat1InRad;
double a = Math.Pow(Math.Sin(dLatitude / 2), 2) + Math.Cos(dLat1InRad) * Math.Cos(dLat2InRad) * Math.Pow(Math.Sin(dLongitude / 2), 2);
double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
double dDistance = (Axis / 1000.0) * c;
return dDistance;
}
 
 
public double GetDistanceInPixels(GPoint point1, GPoint point2)
{
double a = (double)(point2.X - point1.X);
double b = (double)(point2.Y - point1.Y);
 
return Math.Sqrt(a * a + b * b);
}
 
/// <summary>
/// point from distance (in m) to point specified by latitude/longitude
/// without bearing (bearing = 0°)
/// for calculating radius of circle around a point
/// The Haversine formula, http://www.movable-type.co.uk/scripts/latlong.html
/// </summary>
/// <param name="p1"></param>
/// <param name="dDist"></param>
/// <returns></returns>
public static PointLatLng GetPointFromDistance(PointLatLng p1, double dDist)
{
double R = 6378137;
double dBearing = 0;
double dLat1InRad = p1.Lat * (Math.PI / 180);
double dLong1InRad = p1.Lng * (Math.PI / 180);
 
double dLat2InRad = Math.Asin(Math.Sin(dLat1InRad) * Math.Cos(dDist / R) + Math.Cos(dLat1InRad) * Math.Sin(dDist / R));
double dLong2InRad = dLong1InRad + Math.Atan2(Math.Sin(dBearing) * Math.Sin(dDist / R) * Math.Cos(dLat1InRad), Math.Cos(dDist / R) - Math.Sin(dLat1InRad) * Math.Sin(dLat2InRad));
 
double dLatitude = dLat2InRad / (Math.PI / 180);
double dLongitude = dLong2InRad / (Math.PI / 180);
 
return new PointLatLng(dLatitude, dLongitude);
}
/// <summary>
/// Accepts two coordinates in degrees.
/// </summary>
/// <returns>A double value in degrees. From 0 to 360.</returns>
public double GetBearing(PointLatLng p1, PointLatLng p2)
{
var latitude1 = DegreesToRadians(p1.Lat);
var latitude2 = DegreesToRadians(p2.Lat);
var longitudeDifference = DegreesToRadians(p2.Lng - p1.Lng);
 
var y = Math.Sin(longitudeDifference) * Math.Cos(latitude2);
var x = Math.Cos(latitude1) * Math.Sin(latitude2) - Math.Sin(latitude1) * Math.Cos(latitude2) * Math.Cos(longitudeDifference);
 
return (RadiansToDegrees(Math.Atan2(y, x)) + 360) % 360;
}
 
/// <summary>
/// Conversion from cartesian earth-sentered coordinates to geodetic coordinates in the given datum
/// </summary>
/// <param name="Lat"></param>
/// <param name="Lon"></param>
/// <param name="Height">Height above ellipsoid [m]</param>
/// <param name="X"></param>
/// <param name="Y"></param>
/// <param name="Z"></param>
public void FromGeodeticToCartesian(double Lat, double Lng, double Height, out double X, out double Y, out double Z)
{
Lat = (Math.PI / 180) * Lat;
Lng = (Math.PI / 180) * Lng;
 
double B = Axis * (1.0 - Flattening);
double ee = 1.0 - (B / Axis) * (B / Axis);
double N = (Axis / Math.Sqrt(1.0 - ee * Math.Sin(Lat) * Math.Sin(Lat)));
 
X = (N + Height) * Math.Cos(Lat) * Math.Cos(Lng);
Y = (N + Height) * Math.Cos(Lat) * Math.Sin(Lng);
Z = (N * (B / Axis) * (B / Axis) + Height) * Math.Sin(Lat);
}
 
/// <summary>
/// Conversion from cartesian earth-sentered coordinates to geodetic coordinates in the given datum
/// </summary>
/// <param name="X"></param>
/// <param name="Y"></param>
/// <param name="Z"></param>
/// <param name="Lat"></param>
/// <param name="Lon"></param>
public void FromCartesianTGeodetic(double X, double Y, double Z, out double Lat, out double Lng)
{
double E = Flattening * (2.0 - Flattening);
Lng = Math.Atan2(Y, X);
 
double P = Math.Sqrt(X * X + Y * Y);
double Theta = Math.Atan2(Z, (P * (1.0 - Flattening)));
double st = Math.Sin(Theta);
double ct = Math.Cos(Theta);
Lat = Math.Atan2(Z + E / (1.0 - Flattening) * Axis * st * st * st, P - E * Axis * ct * ct * ct);
 
Lat /= (Math.PI / 180);
Lng /= (Math.PI / 180);
}
 
#endregion
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/RectLatLng.cs
0,0 → 1,318

namespace GMap.NET
{
using System;
using System.Globalization;
 
/// <summary>
/// the rect of coordinates
/// </summary>
public struct RectLatLng
{
public static readonly RectLatLng Empty;
private double lng;
private double lat;
private double widthLng;
private double heightLat;
 
public RectLatLng(double lat, double lng, double widthLng, double heightLat)
{
this.lng = lng;
this.lat = lat;
this.widthLng = widthLng;
this.heightLat = heightLat;
NotEmpty = true;
}
 
public RectLatLng(PointLatLng location, SizeLatLng size)
{
this.lng = location.Lng;
this.lat = location.Lat;
this.widthLng = size.WidthLng;
this.heightLat = size.HeightLat;
NotEmpty = true;
}
 
public static RectLatLng FromLTRB(double leftLng, double topLat, double rightLng, double bottomLat)
{
return new RectLatLng(topLat, leftLng, rightLng - leftLng, topLat - bottomLat);
}
 
public PointLatLng LocationTopLeft
{
get
{
return new PointLatLng(this.Lat, this.Lng);
}
set
{
this.Lng = value.Lng;
this.Lat = value.Lat;
}
}
 
public PointLatLng LocationRightBottom
{
get
{
PointLatLng ret = new PointLatLng(this.Lat, this.Lng);
ret.Offset(HeightLat, WidthLng);
return ret;
}
}
 
public PointLatLng LocationMiddle
{
get
{
PointLatLng ret = new PointLatLng(this.Lat, this.Lng);
ret.Offset(HeightLat / 2, WidthLng / 2);
return ret;
}
}
 
public SizeLatLng Size
{
get
{
return new SizeLatLng(this.HeightLat, this.WidthLng);
}
set
{
this.WidthLng = value.WidthLng;
this.HeightLat = value.HeightLat;
}
}
 
public double Lng
{
get
{
return this.lng;
}
set
{
this.lng = value;
}
}
 
public double Lat
{
get
{
return this.lat;
}
set
{
this.lat = value;
}
}
 
public double WidthLng
{
get
{
return this.widthLng;
}
set
{
this.widthLng = value;
}
}
 
public double HeightLat
{
get
{
return this.heightLat;
}
set
{
this.heightLat = value;
}
}
 
public double Left
{
get
{
return this.Lng;
}
}
 
public double Top
{
get
{
return this.Lat;
}
}
 
public double Right
{
get
{
return (this.Lng + this.WidthLng);
}
}
 
public double Bottom
{
get
{
return (this.Lat - this.HeightLat);
}
}
 
bool NotEmpty;
 
/// <summary>
/// returns true if coordinates wasn't assigned
/// </summary>
public bool IsEmpty
{
get
{
return !NotEmpty;
}
}
 
public override bool Equals(object obj)
{
if(!(obj is RectLatLng))
{
return false;
}
RectLatLng ef = (RectLatLng)obj;
return ((((ef.Lng == this.Lng) && (ef.Lat == this.Lat)) && (ef.WidthLng == this.WidthLng)) && (ef.HeightLat == this.HeightLat));
}
 
public static bool operator ==(RectLatLng left, RectLatLng right)
{
return ((((left.Lng == right.Lng) && (left.Lat == right.Lat)) && (left.WidthLng == right.WidthLng)) && (left.HeightLat == right.HeightLat));
}
 
public static bool operator !=(RectLatLng left, RectLatLng right)
{
return !(left == right);
}
 
public bool Contains(double lat, double lng)
{
return ((((this.Lng <= lng) && (lng < (this.Lng + this.WidthLng))) && (this.Lat >= lat)) && (lat > (this.Lat - this.HeightLat)));
}
 
public bool Contains(PointLatLng pt)
{
return this.Contains(pt.Lat, pt.Lng);
}
 
public bool Contains(RectLatLng rect)
{
return ((((this.Lng <= rect.Lng) && ((rect.Lng + rect.WidthLng) <= (this.Lng + this.WidthLng))) && (this.Lat >= rect.Lat)) && ((rect.Lat - rect.HeightLat) >= (this.Lat - this.HeightLat)));
}
 
public override int GetHashCode()
{
if(this.IsEmpty)
{
return 0;
}
return (((this.Lng.GetHashCode() ^ this.Lat.GetHashCode()) ^ this.WidthLng.GetHashCode()) ^ this.HeightLat.GetHashCode());
}
 
// from here down need to test each function to be sure they work good
// |
// .
 
#region -- unsure --
public void Inflate(double lat, double lng)
{
this.Lng -= lng;
this.Lat += lat;
this.WidthLng += 2d * lng;
this.HeightLat += 2d * lat;
}
 
public void Inflate(SizeLatLng size)
{
this.Inflate(size.HeightLat, size.WidthLng);
}
 
public static RectLatLng Inflate(RectLatLng rect, double lat, double lng)
{
RectLatLng ef = rect;
ef.Inflate(lat, lng);
return ef;
}
 
public void Intersect(RectLatLng rect)
{
RectLatLng ef = Intersect(rect, this);
this.Lng = ef.Lng;
this.Lat = ef.Lat;
this.WidthLng = ef.WidthLng;
this.HeightLat = ef.HeightLat;
}
 
// ok ???
public static RectLatLng Intersect(RectLatLng a, RectLatLng b)
{
double lng = Math.Max(a.Lng, b.Lng);
double num2 = Math.Min((double)(a.Lng + a.WidthLng), (double)(b.Lng + b.WidthLng));
 
double lat = Math.Max(a.Lat, b.Lat);
double num4 = Math.Min((double)(a.Lat + a.HeightLat), (double)(b.Lat + b.HeightLat));
 
if((num2 >= lng) && (num4 >= lat))
{
return new RectLatLng(lat, lng, num2 - lng, num4 - lat);
}
return Empty;
}
 
// ok ???
// http://greatmaps.codeplex.com/workitem/15981
public bool IntersectsWith(RectLatLng a)
{
return this.Left < a.Right && this.Top > a.Bottom && this.Right > a.Left && this.Bottom < a.Top;
}
 
// ok ???
// http://greatmaps.codeplex.com/workitem/15981
public static RectLatLng Union(RectLatLng a, RectLatLng b)
{
return RectLatLng.FromLTRB(
Math.Min(a.Left, b.Left),
Math.Max(a.Top, b.Top),
Math.Max(a.Right, b.Right),
Math.Min(a.Bottom, b.Bottom));
}
#endregion
 
// .
// |
// unsure ends here
 
public void Offset(PointLatLng pos)
{
this.Offset(pos.Lat, pos.Lng);
}
 
public void Offset(double lat, double lng)
{
this.Lng += lng;
this.Lat -= lat;
}
 
public override string ToString()
{
return ("{Lat=" + this.Lat.ToString(CultureInfo.CurrentCulture) + ",Lng=" + this.Lng.ToString(CultureInfo.CurrentCulture) + ",WidthLng=" + this.WidthLng.ToString(CultureInfo.CurrentCulture) + ",HeightLat=" + this.HeightLat.ToString(CultureInfo.CurrentCulture) + "}");
}
 
static RectLatLng()
{
Empty = new RectLatLng();
}
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/RenderMode.cs
0,0 → 1,19

namespace GMap.NET
{
/// <summary>
/// types of map rendering
/// </summary>
public enum RenderMode
{
/// <summary>
/// gdi+ should work anywhere on Windows Forms
/// </summary>
GDI_PLUS,
 
/// <summary>
/// only on Windows Presentation Foundation
/// </summary>
WPF,
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/RoutingProvider.cs
0,0 → 1,19

namespace GMap.NET
{
/// <summary>
/// routing interface
/// </summary>
public interface RoutingProvider
{
/// <summary>
/// get route between two points
/// </summary>
MapRoute GetRoute(PointLatLng start, PointLatLng end, bool avoidHighways, bool walkingMode, int Zoom);
 
/// <summary>
/// get route between two points
/// </summary>
MapRoute GetRoute(string start, string end, bool avoidHighways, bool walkingMode, int Zoom);
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/Singleton.cs
0,0 → 1,60

namespace GMap.NET
{
using System;
using System.Diagnostics;
using System.Reflection;
 
/// <summary>
/// generic for singletons
/// </summary>
/// <typeparam name="T"></typeparam>
public class Singleton<T> where T : new()
{
// ctor
protected Singleton()
{
if(Instance != null)
{
throw (new Exception("You have tried to create a new singleton class where you should have instanced it. Replace your \"new class()\" with \"class.Instance\""));
}
}
 
public static T Instance
{
get
{
if(SingletonCreator.exception != null)
{
throw SingletonCreator.exception;
}
return SingletonCreator.instance;
}
}
 
class SingletonCreator
{
static SingletonCreator()
{
try
{
instance = new T();
}
catch(Exception ex)
{
if(ex.InnerException != null)
{
exception = ex.InnerException;
}
else
{
exception = ex;
}
Trace.WriteLine("Singleton: " + exception);
}
}
internal static readonly T instance;
internal static readonly Exception exception;
}
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/SizeLatLng.cs
0,0 → 1,135

namespace GMap.NET
{
using System.Globalization;
 
/// <summary>
/// the size of coordinates
/// </summary>
public struct SizeLatLng
{
public static readonly SizeLatLng Empty;
 
private double heightLat;
private double widthLng;
 
public SizeLatLng(SizeLatLng size)
{
this.widthLng = size.widthLng;
this.heightLat = size.heightLat;
}
 
public SizeLatLng(PointLatLng pt)
{
this.heightLat = pt.Lat;
this.widthLng = pt.Lng;
}
 
public SizeLatLng(double heightLat, double widthLng)
{
this.heightLat = heightLat;
this.widthLng = widthLng;
}
 
public static SizeLatLng operator+(SizeLatLng sz1, SizeLatLng sz2)
{
return Add(sz1, sz2);
}
 
public static SizeLatLng operator-(SizeLatLng sz1, SizeLatLng sz2)
{
return Subtract(sz1, sz2);
}
 
public static bool operator==(SizeLatLng sz1, SizeLatLng sz2)
{
return ((sz1.WidthLng == sz2.WidthLng) && (sz1.HeightLat == sz2.HeightLat));
}
 
public static bool operator!=(SizeLatLng sz1, SizeLatLng sz2)
{
return !(sz1 == sz2);
}
 
public static explicit operator PointLatLng(SizeLatLng size)
{
return new PointLatLng(size.HeightLat, size.WidthLng);
}
 
public bool IsEmpty
{
get
{
return ((this.widthLng == 0d) && (this.heightLat == 0d));
}
}
 
public double WidthLng
{
get
{
return this.widthLng;
}
set
{
this.widthLng = value;
}
}
 
public double HeightLat
{
get
{
return this.heightLat;
}
set
{
this.heightLat = value;
}
}
 
public static SizeLatLng Add(SizeLatLng sz1, SizeLatLng sz2)
{
return new SizeLatLng(sz1.HeightLat + sz2.HeightLat, sz1.WidthLng + sz2.WidthLng);
}
 
public static SizeLatLng Subtract(SizeLatLng sz1, SizeLatLng sz2)
{
return new SizeLatLng(sz1.HeightLat - sz2.HeightLat, sz1.WidthLng - sz2.WidthLng);
}
 
public override bool Equals(object obj)
{
if(!(obj is SizeLatLng))
{
return false;
}
SizeLatLng ef = (SizeLatLng) obj;
return (((ef.WidthLng == this.WidthLng) && (ef.HeightLat == this.HeightLat)) && ef.GetType().Equals(base.GetType()));
}
 
public override int GetHashCode()
{
if(this.IsEmpty)
{
return 0;
}
return (this.WidthLng.GetHashCode() ^ this.HeightLat.GetHashCode());
}
 
public PointLatLng ToPointLatLng()
{
return (PointLatLng) this;
}
 
public override string ToString()
{
return ("{WidthLng=" + this.widthLng.ToString(CultureInfo.CurrentCulture) + ", HeightLng=" + this.heightLat.ToString(CultureInfo.CurrentCulture) + "}");
}
 
static SizeLatLng()
{
Empty = new SizeLatLng();
}
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/StatusCodes.cs
0,0 → 1,125

namespace GMap.NET
{
/// <summary>
/// GeoCoder StatusCode
/// </summary>
public enum GeoCoderStatusCode : int
{
/// <summary>
/// unknow response
/// </summary>
Unknow = -1,
 
/// <summary>
/// No errors occurred; the address was successfully parsed and its geocode has been returned.
/// </summary>
G_GEO_SUCCESS = 200,
 
/// <summary>
/// A directions request could not be successfully parsed.
/// For example, the request may have been rejected if it contained more than the maximum number of waypoints allowed.
/// </summary>
G_GEO_BAD_REQUEST = 400,
 
/// <summary>
/// A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.
/// </summary>
G_GEO_SERVER_ERROR = 500,
 
/// <summary>
/// The HTTP q parameter was either missing or had no value.
/// For geocoding requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.
/// </summary>
G_GEO_MISSING_QUERY = 601,
 
/// <summary>
/// Synonym for G_GEO_MISSING_QUERY.
/// </summary>
G_GEO_MISSING_ADDRESS = 601,
 
/// <summary>
/// No corresponding geographic location could be found for the specified address.
/// This may be due to the fact that the address is relatively new, or it may be incorrect.
/// </summary>
G_GEO_UNKNOWN_ADDRESS = 602,
 
/// <summary>
/// The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.
/// </summary>
G_GEO_UNAVAILABLE_ADDRESS = 603,
 
/// <summary>
/// The GDirections object could not compute directions between the points mentioned in the query.
/// This is usually because there is no route available between the two points, or because we do not have data for routing in that region.
/// </summary>
G_GEO_UNKNOWN_DIRECTIONS = 604,
 
/// <summary>
/// The given key is either invalid or does not match the domain for which it was given.
/// </summary>
G_GEO_BAD_KEY = 610,
 
/// <summary>
/// The given key has gone over the requests limit in the 24 hour period or has submitted too many requests in too short a period of time.
/// If you're sending multiple requests in parallel or in a tight loop, use a timer or pause in your code to make sure you don't send the requests too quickly.
/// </summary>
G_GEO_TOO_MANY_QUERIES = 620,
 
/// <summary>
/// indicates that exception occured during execution
/// </summary>
ExceptionInCode,
}
 
/// <summary>
/// Direction StatusCode
/// </summary>
public enum DirectionsStatusCode : int
{
/// <summary>
/// indicates the response contains a valid result.
/// </summary>
OK = 0,
 
/// <summary>
/// indicates at least one of the locations specified in the requests's origin, destination, or waypoints could not be geocoded.
/// </summary>
NOT_FOUND,
 
/// <summary>
/// indicates no route could be found between the origin and destination.
/// </summary>
ZERO_RESULTS,
 
/// <summary>
/// indicates that too many waypointss were provided in the request The maximum allowed waypoints is 8, plus the origin, and destination.
/// </summary>
MAX_WAYPOINTS_EXCEEDED,
 
/// <summary>
/// indicates that the provided request was invalid.
/// </summary>
INVALID_REQUEST,
 
/// <summary>
/// indicates the service has received too many requests from your application within the allowed time period.
/// </summary>
OVER_QUERY_LIMIT,
 
/// <summary>
/// indicates that the service denied use of the directions service by your application.
/// </summary>
REQUEST_DENIED,
 
/// <summary>
/// indicates a directions request could not be processed due to a server error. The request may succeed if you try again.
/// </summary>
UNKNOWN_ERROR,
 
/// <summary>
/// indicates that exception occured during execution
/// </summary>
ExceptionInCode,
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/ZipStorer.cs
0,0 → 1,748
// ZipStorer, by Jaime Olivares
// Website: zipstorer.codeplex.com
// Version: 2.35 (March 14, 2010)
 
using System.Collections.Generic;
using System.Text;
 
namespace System.IO.Compression
{
/// <summary>
/// Unique class for compression/decompression file. Represents a Zip file.
/// </summary>
public class ZipStorer : IDisposable
{
/// <summary>
/// Compression method enumeration
/// </summary>
public enum Compression : ushort {
/// <summary>Uncompressed storage</summary>
Store = 0,
/// <summary>Deflate compression method</summary>
Deflate = 8 }
 
/// <summary>
/// Represents an entry in Zip file directory
/// </summary>
public struct ZipFileEntry
{
/// <summary>Compression method</summary>
public Compression Method;
/// <summary>Full path and filename as stored in Zip</summary>
public string FilenameInZip;
/// <summary>Original file size</summary>
public uint FileSize;
/// <summary>Compressed file size</summary>
public uint CompressedSize;
/// <summary>Offset of header information inside Zip storage</summary>
public uint HeaderOffset;
/// <summary>Offset of file inside Zip storage</summary>
public uint FileOffset;
/// <summary>Size of header information</summary>
public uint HeaderSize;
/// <summary>32-bit checksum of entire file</summary>
public uint Crc32;
/// <summary>Last modification time of file</summary>
public DateTime ModifyTime;
/// <summary>User comment for file</summary>
public string Comment;
/// <summary>True if UTF8 encoding for filename and comments, false if default (CP 437)</summary>
public bool EncodeUTF8;
 
/// <summary>Overriden method</summary>
/// <returns>Filename in Zip</returns>
public override string ToString()
{
return this.FilenameInZip;
}
}
 
#region Public fields
/// <summary>True if UTF8 encoding for filename and comments, false if default (CP 437)</summary>
public bool EncodeUTF8 = false;
/// <summary>Force deflate algotithm even if it inflates the stored file. Off by default.</summary>
public bool ForceDeflating = false;
#endregion
 
#region Private fields
// List of files to store
private List<ZipFileEntry> Files = new List<ZipFileEntry>();
// Filename of storage file
private string FileName;
// Stream object of storage file
private Stream ZipFileStream;
// General comment
private string Comment = "";
// Central dir image
private byte[] CentralDirImage = null;
// Existing files in zip
private ushort ExistingFiles = 0;
// File access for Open method
private FileAccess Access;
// Static CRC32 Table
private static UInt32[] CrcTable = null;
// Default filename encoder
private static Encoding DefaultEncoding = Encoding.GetEncoding(437);
#endregion
 
#region Public methods
// Static constructor. Just invoked once in order to create the CRC32 lookup table.
static ZipStorer()
{
// Generate CRC32 table
CrcTable = new UInt32[256];
for (int i = 0; i < CrcTable.Length; i++)
{
UInt32 c = (UInt32)i;
for (int j = 0; j < 8; j++)
{
if ((c & 1) != 0)
c = 3988292384 ^ (c >> 1);
else
c >>= 1;
}
CrcTable[i] = c;
}
}
/// <summary>
/// Method to create a new storage file
/// </summary>
/// <param name="_filename">Full path of Zip file to create</param>
/// <param name="_comment">General comment for Zip file</param>
/// <returns>A valid ZipStorer object</returns>
public static ZipStorer Create(string _filename, string _comment)
{
Stream stream = new FileStream(_filename, FileMode.Create, FileAccess.ReadWrite);
 
ZipStorer zip = Create(stream, _comment);
zip.Comment = _comment;
zip.FileName = _filename;
 
return zip;
}
/// <summary>
/// Method to create a new zip storage in a stream
/// </summary>
/// <param name="_stream"></param>
/// <param name="_comment"></param>
/// <returns>A valid ZipStorer object</returns>
public static ZipStorer Create(Stream _stream, string _comment)
{
ZipStorer zip = new ZipStorer();
zip.Comment = _comment;
zip.ZipFileStream = _stream;
zip.Access = FileAccess.Write;
 
return zip;
}
/// <summary>
/// Method to open an existing storage file
/// </summary>
/// <param name="_filename">Full path of Zip file to open</param>
/// <param name="_access">File access mode as used in FileStream constructor</param>
/// <returns>A valid ZipStorer object</returns>
public static ZipStorer Open(string _filename, FileAccess _access)
{
Stream stream = (Stream)new FileStream(_filename, FileMode.Open, _access == FileAccess.Read ? FileAccess.Read : FileAccess.ReadWrite);
 
ZipStorer zip = Open(stream, _access);
zip.FileName = _filename;
 
return zip;
}
/// <summary>
/// Method to open an existing storage from stream
/// </summary>
/// <param name="_stream">Already opened stream with zip contents</param>
/// <param name="_access">File access mode for stream operations</param>
/// <returns>A valid ZipStorer object</returns>
public static ZipStorer Open(Stream _stream, FileAccess _access)
{
if (!_stream.CanSeek && _access != FileAccess.Read)
throw new InvalidOperationException("Stream cannot seek");
 
ZipStorer zip = new ZipStorer();
//zip.FileName = _filename;
zip.ZipFileStream = _stream;
zip.Access = _access;
 
if (zip.ReadFileInfo())
return zip;
 
throw new System.IO.InvalidDataException();
}
/// <summary>
/// Add full contents of a file into the Zip storage
/// </summary>
/// <param name="_method">Compression method</param>
/// <param name="_pathname">Full path of file to add to Zip storage</param>
/// <param name="_filenameInZip">Filename and path as desired in Zip directory</param>
/// <param name="_comment">Comment for stored file</param>
public void AddFile(Compression _method, string _pathname, string _filenameInZip, string _comment)
{
if (Access == FileAccess.Read)
throw new InvalidOperationException("Writing is not alowed");
 
FileStream stream = new FileStream(_pathname, FileMode.Open, FileAccess.Read);
AddStream(_method, _filenameInZip, stream, File.GetLastWriteTime(_pathname), _comment);
stream.Close();
}
/// <summary>
/// Add full contents of a stream into the Zip storage
/// </summary>
/// <param name="_method">Compression method</param>
/// <param name="_filenameInZip">Filename and path as desired in Zip directory</param>
/// <param name="_source">Stream object containing the data to store in Zip</param>
/// <param name="_modTime">Modification time of the data to store</param>
/// <param name="_comment">Comment for stored file</param>
public void AddStream(Compression _method, string _filenameInZip, Stream _source, DateTime _modTime, string _comment)
{
if (Access == FileAccess.Read)
throw new InvalidOperationException("Writing is not alowed");
 
long offset;
if (this.Files.Count==0)
offset = 0;
else
{
ZipFileEntry last = this.Files[this.Files.Count-1];
offset = last.HeaderOffset + last.HeaderSize;
}
 
// Prepare the fileinfo
ZipFileEntry zfe = new ZipFileEntry();
zfe.Method = _method;
zfe.EncodeUTF8 = this.EncodeUTF8;
zfe.FilenameInZip = NormalizedFilename(_filenameInZip);
zfe.Comment = (_comment == null ? "" : _comment);
 
// Even though we write the header now, it will have to be rewritten, since we don't know compressed size or crc.
zfe.Crc32 = 0; // to be updated later
zfe.HeaderOffset = (uint)this.ZipFileStream.Position; // offset within file of the start of this local record
zfe.ModifyTime = _modTime;
 
// Write local header
WriteLocalHeader(ref zfe);
zfe.FileOffset = (uint)this.ZipFileStream.Position;
 
// Write file to zip (store)
Store(ref zfe, _source);
_source.Close();
 
this.UpdateCrcAndSizes(ref zfe);
 
Files.Add(zfe);
}
/// <summary>
/// Updates central directory (if pertinent) and close the Zip storage
/// </summary>
/// <remarks>This is a required step, unless automatic dispose is used</remarks>
public void Close()
{
if(this.ZipFileStream == null)
return;
 
if (this.Access != FileAccess.Read)
{
uint centralOffset = (uint)this.ZipFileStream.Position;
uint centralSize = 0;
 
if (this.CentralDirImage != null)
this.ZipFileStream.Write(CentralDirImage, 0, CentralDirImage.Length);
 
for (int i = 0; i < Files.Count; i++)
{
long pos = this.ZipFileStream.Position;
this.WriteCentralDirRecord(Files[i]);
centralSize += (uint)(this.ZipFileStream.Position - pos);
}
 
if (this.CentralDirImage != null)
this.WriteEndRecord(centralSize + (uint)CentralDirImage.Length, centralOffset);
else
this.WriteEndRecord(centralSize, centralOffset);
}
 
if (this.ZipFileStream != null)
{
this.ZipFileStream.Flush();
this.ZipFileStream.Dispose();
this.ZipFileStream = null;
}
}
/// <summary>
/// Read all the file records in the central directory
/// </summary>
/// <returns>List of all entries in directory</returns>
public List<ZipFileEntry> ReadCentralDir()
{
if (this.CentralDirImage == null)
throw new InvalidOperationException("Central directory currently does not exist");
 
List<ZipFileEntry> result = new List<ZipFileEntry>();
 
for (int pointer = 0; pointer < this.CentralDirImage.Length; )
{
uint signature = BitConverter.ToUInt32(CentralDirImage, pointer);
if (signature != 0x02014b50)
break;
 
bool encodeUTF8 = (BitConverter.ToUInt16(CentralDirImage, pointer + 8) & 0x0800) != 0;
ushort method = BitConverter.ToUInt16(CentralDirImage, pointer + 10);
uint modifyTime = BitConverter.ToUInt32(CentralDirImage, pointer + 12);
uint crc32 = BitConverter.ToUInt32(CentralDirImage, pointer + 16);
uint comprSize = BitConverter.ToUInt32(CentralDirImage, pointer + 20);
uint fileSize = BitConverter.ToUInt32(CentralDirImage, pointer + 24);
ushort filenameSize = BitConverter.ToUInt16(CentralDirImage, pointer + 28);
ushort extraSize = BitConverter.ToUInt16(CentralDirImage, pointer + 30);
ushort commentSize = BitConverter.ToUInt16(CentralDirImage, pointer + 32);
uint headerOffset = BitConverter.ToUInt32(CentralDirImage, pointer + 42);
uint headerSize = (uint)( 46 + filenameSize + extraSize + commentSize);
 
Encoding encoder = encodeUTF8 ? Encoding.UTF8 : DefaultEncoding;
 
ZipFileEntry zfe = new ZipFileEntry();
zfe.Method = (Compression)method;
zfe.FilenameInZip = encoder.GetString(CentralDirImage, pointer + 46, filenameSize);
zfe.FileOffset = GetFileOffset(headerOffset);
zfe.FileSize = fileSize;
zfe.CompressedSize = comprSize;
zfe.HeaderOffset = headerOffset;
zfe.HeaderSize = headerSize;
zfe.Crc32 = crc32;
zfe.ModifyTime = DosTimeToDateTime(modifyTime);
if (commentSize > 0)
zfe.Comment = encoder.GetString(CentralDirImage, pointer + 46 + filenameSize + extraSize, commentSize);
 
result.Add(zfe);
pointer += (46 + filenameSize + extraSize + commentSize);
}
 
return result;
}
/// <summary>
/// Copy the contents of a stored file into a physical file
/// </summary>
/// <param name="_zfe">Entry information of file to extract</param>
/// <param name="_filename">Name of file to store uncompressed data</param>
/// <returns>True if success, false if not.</returns>
/// <remarks>Unique compression methods are Store and Deflate</remarks>
public bool ExtractFile(ZipFileEntry _zfe, string _filename)
{
// Make sure the parent directory exist
string path = System.IO.Path.GetDirectoryName(_filename);
 
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
// Check it is directory. If so, do nothing
if (Directory.Exists(_filename))
return true;
 
Stream output = new FileStream(_filename, FileMode.Create, FileAccess.Write);
bool result = ExtractFile(_zfe, output);
if (result)
output.Close();
 
File.SetCreationTime(_filename, _zfe.ModifyTime);
File.SetLastWriteTime(_filename, _zfe.ModifyTime);
return result;
}
/// <summary>
/// Copy the contents of a stored file into an opened stream
/// </summary>
/// <param name="_zfe">Entry information of file to extract</param>
/// <param name="_stream">Stream to store the uncompressed data</param>
/// <returns>True if success, false if not.</returns>
/// <remarks>Unique compression methods are Store and Deflate</remarks>
public bool ExtractFile(ZipFileEntry _zfe, Stream _stream)
{
if (!_stream.CanWrite)
throw new InvalidOperationException("Stream cannot be written");
 
// check signature
byte[] signature = new byte[4];
this.ZipFileStream.Seek(_zfe.HeaderOffset, SeekOrigin.Begin);
this.ZipFileStream.Read(signature, 0, 4);
if (BitConverter.ToUInt32(signature, 0) != 0x04034b50)
return false;
 
// Select input stream for inflating or just reading
Stream inStream;
if (_zfe.Method == Compression.Store)
inStream = this.ZipFileStream;
else if (_zfe.Method == Compression.Deflate)
inStream = new DeflateStream(this.ZipFileStream, CompressionMode.Decompress, true);
else
return false;
 
// Buffered copy
byte[] buffer = new byte[16384];
this.ZipFileStream.Seek(_zfe.FileOffset, SeekOrigin.Begin);
uint bytesPending = _zfe.FileSize;
while (bytesPending > 0)
{
int bytesRead = inStream.Read(buffer, 0, (int)Math.Min(bytesPending, buffer.Length));
_stream.Write(buffer, 0, bytesRead);
bytesPending -= (uint)bytesRead;
}
_stream.Flush();
 
if (_zfe.Method == Compression.Deflate)
inStream.Dispose();
return true;
}
/// <summary>
/// Removes one of many files in storage. It creates a new Zip file.
/// </summary>
/// <param name="_zip">Reference to the current Zip object</param>
/// <param name="_zfes">List of Entries to remove from storage</param>
/// <returns>True if success, false if not</returns>
/// <remarks>This method only works for storage of type FileStream</remarks>
public static bool RemoveEntries(ref ZipStorer _zip, List<ZipFileEntry> _zfes)
{
if (!(_zip.ZipFileStream is FileStream))
throw new InvalidOperationException("RemoveEntries is allowed just over streams of type FileStream");
 
 
//Get full list of entries
List<ZipFileEntry> fullList = _zip.ReadCentralDir();
 
//In order to delete we need to create a copy of the zip file excluding the selected items
string tempZipName = Path.GetTempFileName();
string tempEntryName = Path.GetTempFileName();
 
try
{
ZipStorer tempZip = ZipStorer.Create(tempZipName, string.Empty);
 
foreach (ZipFileEntry zfe in fullList)
{
if (!_zfes.Contains(zfe))
{
if (_zip.ExtractFile(zfe, tempEntryName))
{
tempZip.AddFile(zfe.Method, tempEntryName, zfe.FilenameInZip, zfe.Comment);
}
}
}
_zip.Close();
tempZip.Close();
 
File.Delete(_zip.FileName);
File.Move(tempZipName, _zip.FileName);
 
_zip = ZipStorer.Open(_zip.FileName, _zip.Access);
}
catch
{
return false;
}
finally
{
if (File.Exists(tempZipName))
File.Delete(tempZipName);
if (File.Exists(tempEntryName))
File.Delete(tempEntryName);
}
return true;
}
#endregion
 
#region Private methods
// Calculate the file offset by reading the corresponding local header
private uint GetFileOffset(uint _headerOffset)
{
byte[] buffer = new byte[2];
 
this.ZipFileStream.Seek(_headerOffset + 26, SeekOrigin.Begin);
this.ZipFileStream.Read(buffer, 0, 2);
ushort filenameSize = BitConverter.ToUInt16(buffer, 0);
this.ZipFileStream.Read(buffer, 0, 2);
ushort extraSize = BitConverter.ToUInt16(buffer, 0);
 
return (uint)(30 + filenameSize + extraSize + _headerOffset);
}
/* Local file header:
local file header signature 4 bytes (0x04034b50)
version needed to extract 2 bytes
general purpose bit flag 2 bytes
compression method 2 bytes
last mod file time 2 bytes
last mod file date 2 bytes
crc-32 4 bytes
compressed size 4 bytes
uncompressed size 4 bytes
filename length 2 bytes
extra field length 2 bytes
 
filename (variable size)
extra field (variable size)
*/
private void WriteLocalHeader(ref ZipFileEntry _zfe)
{
long pos = this.ZipFileStream.Position;
Encoding encoder = _zfe.EncodeUTF8 ? Encoding.UTF8 : DefaultEncoding;
byte[] encodedFilename = encoder.GetBytes(_zfe.FilenameInZip);
 
this.ZipFileStream.Write(new byte[] { 80, 75, 3, 4, 20, 0}, 0, 6); // No extra header
this.ZipFileStream.Write(BitConverter.GetBytes((ushort)(_zfe.EncodeUTF8 ? 0x0800 : 0)), 0, 2); // filename and comment encoding
this.ZipFileStream.Write(BitConverter.GetBytes((ushort)_zfe.Method), 0, 2); // zipping method
this.ZipFileStream.Write(BitConverter.GetBytes(DateTimeToDosTime(_zfe.ModifyTime)), 0, 4); // zipping date and time
this.ZipFileStream.Write(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0, 12); // unused CRC, un/compressed size, updated later
this.ZipFileStream.Write(BitConverter.GetBytes((ushort)encodedFilename.Length), 0, 2); // filename length
this.ZipFileStream.Write(BitConverter.GetBytes((ushort)0), 0, 2); // extra length
 
this.ZipFileStream.Write(encodedFilename, 0, encodedFilename.Length);
_zfe.HeaderSize = (uint)(this.ZipFileStream.Position - pos);
}
/* Central directory's File header:
central file header signature 4 bytes (0x02014b50)
version made by 2 bytes
version needed to extract 2 bytes
general purpose bit flag 2 bytes
compression method 2 bytes
last mod file time 2 bytes
last mod file date 2 bytes
crc-32 4 bytes
compressed size 4 bytes
uncompressed size 4 bytes
filename length 2 bytes
extra field length 2 bytes
file comment length 2 bytes
disk number start 2 bytes
internal file attributes 2 bytes
external file attributes 4 bytes
relative offset of local header 4 bytes
 
filename (variable size)
extra field (variable size)
file comment (variable size)
*/
private void WriteCentralDirRecord(ZipFileEntry _zfe)
{
Encoding encoder = _zfe.EncodeUTF8 ? Encoding.UTF8 : DefaultEncoding;
byte[] encodedFilename = encoder.GetBytes(_zfe.FilenameInZip);
byte[] encodedComment = encoder.GetBytes(_zfe.Comment);
 
this.ZipFileStream.Write(new byte[] { 80, 75, 1, 2, 23, 0xB, 20, 0 }, 0, 8);
this.ZipFileStream.Write(BitConverter.GetBytes((ushort)(_zfe.EncodeUTF8 ? 0x0800 : 0)), 0, 2); // filename and comment encoding
this.ZipFileStream.Write(BitConverter.GetBytes((ushort)_zfe.Method), 0, 2); // zipping method
this.ZipFileStream.Write(BitConverter.GetBytes(DateTimeToDosTime(_zfe.ModifyTime)), 0, 4); // zipping date and time
this.ZipFileStream.Write(BitConverter.GetBytes(_zfe.Crc32), 0, 4); // file CRC
this.ZipFileStream.Write(BitConverter.GetBytes(_zfe.CompressedSize), 0, 4); // compressed file size
this.ZipFileStream.Write(BitConverter.GetBytes(_zfe.FileSize), 0, 4); // uncompressed file size
this.ZipFileStream.Write(BitConverter.GetBytes((ushort)encodedFilename.Length), 0, 2); // Filename in zip
this.ZipFileStream.Write(BitConverter.GetBytes((ushort)0), 0, 2); // extra length
this.ZipFileStream.Write(BitConverter.GetBytes((ushort)encodedComment.Length), 0, 2);
 
this.ZipFileStream.Write(BitConverter.GetBytes((ushort)0), 0, 2); // disk=0
this.ZipFileStream.Write(BitConverter.GetBytes((ushort)0), 0, 2); // file type: binary
this.ZipFileStream.Write(BitConverter.GetBytes((ushort)0), 0, 2); // Internal file attributes
this.ZipFileStream.Write(BitConverter.GetBytes((ushort)0x8100), 0, 2); // External file attributes (normal/readable)
this.ZipFileStream.Write(BitConverter.GetBytes(_zfe.HeaderOffset), 0, 4); // Offset of header
 
this.ZipFileStream.Write(encodedFilename, 0, encodedFilename.Length);
this.ZipFileStream.Write(encodedComment, 0, encodedComment.Length);
}
/* End of central dir record:
end of central dir signature 4 bytes (0x06054b50)
number of this disk 2 bytes
number of the disk with the
start of the central directory 2 bytes
total number of entries in
the central dir on this disk 2 bytes
total number of entries in
the central dir 2 bytes
size of the central directory 4 bytes
offset of start of central
directory with respect to
the starting disk number 4 bytes
zipfile comment length 2 bytes
zipfile comment (variable size)
*/
private void WriteEndRecord(uint _size, uint _offset)
{
Encoding encoder = this.EncodeUTF8 ? Encoding.UTF8 : DefaultEncoding;
byte[] encodedComment = encoder.GetBytes(this.Comment);
 
this.ZipFileStream.Write(new byte[] { 80, 75, 5, 6, 0, 0, 0, 0 }, 0, 8);
this.ZipFileStream.Write(BitConverter.GetBytes((ushort)Files.Count+ExistingFiles), 0, 2);
this.ZipFileStream.Write(BitConverter.GetBytes((ushort)Files.Count+ExistingFiles), 0, 2);
this.ZipFileStream.Write(BitConverter.GetBytes(_size), 0, 4);
this.ZipFileStream.Write(BitConverter.GetBytes(_offset), 0, 4);
this.ZipFileStream.Write(BitConverter.GetBytes((ushort)encodedComment.Length), 0, 2);
this.ZipFileStream.Write(encodedComment, 0, encodedComment.Length);
}
// Copies all source file into storage file
private void Store(ref ZipFileEntry _zfe, Stream _source)
{
byte[] buffer = new byte[16384];
int bytesRead;
uint totalRead = 0;
Stream outStream;
 
long posStart = this.ZipFileStream.Position;
long sourceStart = _source.Position;
 
if (_zfe.Method == Compression.Store)
outStream = this.ZipFileStream;
else
outStream = new DeflateStream(this.ZipFileStream, CompressionMode.Compress, true);
 
_zfe.Crc32 = 0 ^ 0xffffffff;
do
{
bytesRead = _source.Read(buffer, 0, buffer.Length);
totalRead += (uint)bytesRead;
if (bytesRead > 0)
{
outStream.Write(buffer, 0, bytesRead);
 
for (uint i = 0; i < bytesRead; i++)
{
_zfe.Crc32 = ZipStorer.CrcTable[(_zfe.Crc32 ^ buffer[i]) & 0xFF] ^ (_zfe.Crc32 >> 8);
}
}
} while (bytesRead == buffer.Length);
outStream.Flush();
 
if (_zfe.Method == Compression.Deflate)
outStream.Dispose();
 
_zfe.Crc32 ^= 0xffffffff;
_zfe.FileSize = totalRead;
_zfe.CompressedSize = (uint)(this.ZipFileStream.Position - posStart);
 
// Verify for real compression
if (_zfe.Method == Compression.Deflate && !this.ForceDeflating && _source.CanSeek && _zfe.CompressedSize > _zfe.FileSize)
{
// Start operation again with Store algorithm
_zfe.Method = Compression.Store;
this.ZipFileStream.Position = posStart;
this.ZipFileStream.SetLength(posStart);
_source.Position = sourceStart;
this.Store(ref _zfe, _source);
}
}
/* DOS Date and time:
MS-DOS date. The date is a packed value with the following format. Bits Description
0-4 Day of the month (1–31)
5-8 Month (1 = January, 2 = February, and so on)
9-15 Year offset from 1980 (add 1980 to get actual year)
MS-DOS time. The time is a packed value with the following format. Bits Description
0-4 Second divided by 2
5-10 Minute (0–59)
11-15 Hour (0–23 on a 24-hour clock)
*/
private uint DateTimeToDosTime(DateTime _dt)
{
return (uint)(
(_dt.Second / 2) | (_dt.Minute << 5) | (_dt.Hour << 11) |
(_dt.Day<<16) | (_dt.Month << 21) | ((_dt.Year - 1980) << 25));
}
private DateTime DosTimeToDateTime(uint _dt)
{
return new DateTime(
(int)(_dt >> 25) + 1980,
(int)(_dt >> 21) & 15,
(int)(_dt >> 16) & 31,
(int)(_dt >> 11) & 31,
(int)(_dt >> 5) & 63,
(int)(_dt & 31) * 2);
}
 
/* CRC32 algorithm
The 'magic number' for the CRC is 0xdebb20e3.
The proper CRC pre and post conditioning
is used, meaning that the CRC register is
pre-conditioned with all ones (a starting value
of 0xffffffff) and the value is post-conditioned by
taking the one's complement of the CRC residual.
If bit 3 of the general purpose flag is set, this
field is set to zero in the local header and the correct
value is put in the data descriptor and in the central
directory.
*/
private void UpdateCrcAndSizes(ref ZipFileEntry _zfe)
{
long lastPos = this.ZipFileStream.Position; // remember position
 
this.ZipFileStream.Position = _zfe.HeaderOffset + 8;
this.ZipFileStream.Write(BitConverter.GetBytes((ushort)_zfe.Method), 0, 2); // zipping method
 
this.ZipFileStream.Position = _zfe.HeaderOffset + 14;
this.ZipFileStream.Write(BitConverter.GetBytes(_zfe.Crc32), 0, 4); // Update CRC
this.ZipFileStream.Write(BitConverter.GetBytes(_zfe.CompressedSize), 0, 4); // Compressed size
this.ZipFileStream.Write(BitConverter.GetBytes(_zfe.FileSize), 0, 4); // Uncompressed size
 
this.ZipFileStream.Position = lastPos; // restore position
}
// Replaces backslashes with slashes to store in zip header
private string NormalizedFilename(string _filename)
{
string filename = _filename.Replace('\\', '/');
 
int pos = filename.IndexOf(':');
if (pos >= 0)
filename = filename.Remove(0, pos + 1);
 
return filename.Trim('/');
}
// Reads the end-of-central-directory record
private bool ReadFileInfo()
{
if (this.ZipFileStream.Length < 22)
return false;
 
try
{
this.ZipFileStream.Seek(-17, SeekOrigin.End);
BinaryReader br = new BinaryReader(this.ZipFileStream);
do
{
this.ZipFileStream.Seek(-5, SeekOrigin.Current);
UInt32 sig = br.ReadUInt32();
if (sig == 0x06054b50)
{
this.ZipFileStream.Seek(6, SeekOrigin.Current);
 
UInt16 entries = br.ReadUInt16();
Int32 centralSize = br.ReadInt32();
UInt32 centralDirOffset = br.ReadUInt32();
UInt16 commentSize = br.ReadUInt16();
 
// check if comment field is the very last data in file
if (this.ZipFileStream.Position + commentSize != this.ZipFileStream.Length)
return false;
 
// Copy entire central directory to a memory buffer
this.ExistingFiles = entries;
this.CentralDirImage = new byte[centralSize];
this.ZipFileStream.Seek(centralDirOffset, SeekOrigin.Begin);
this.ZipFileStream.Read(this.CentralDirImage, 0, centralSize);
 
// Leave the pointer at the begining of central dir, to append new files
this.ZipFileStream.Seek(centralDirOffset, SeekOrigin.Begin);
return true;
}
} while (this.ZipFileStream.Position > 0);
}
catch { }
 
return false;
}
#endregion
 
#region IDisposable Members
/// <summary>
/// Closes the Zip file stream
/// </summary>
public void Dispose()
{
this.Close();
}
#endregion
}
}
/MKLiveView/v1.0/Source/MKLiveView/GMap.NET.Core/GMap.NET/gpx.cs
0,0 → 1,1442
//
// This source code was auto-generated by xsd, Version=4.0.30319.1.
//
namespace GMap.NET
{
using System.Xml.Serialization;
 
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.topografix.com/GPX/1/1")]
[System.Xml.Serialization.XmlRootAttribute("gpx", Namespace="http://www.topografix.com/GPX/1/1", IsNullable=false)]
public partial class gpxType
{
 
private metadataType metadataField;
 
private wptType[] wptField;
 
private rteType[] rteField;
 
private trkType[] trkField;
 
private extensionsType extensionsField;
 
private string versionField;
 
private string creatorField;
 
public gpxType()
{
this.versionField = "1.1";
}
 
/// <remarks/>
public metadataType metadata
{
get
{
return this.metadataField;
}
set
{
this.metadataField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("wpt")]
public wptType[] wpt
{
get
{
return this.wptField;
}
set
{
this.wptField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("rte")]
public rteType[] rte
{
get
{
return this.rteField;
}
set
{
this.rteField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("trk")]
public trkType[] trk
{
get
{
return this.trkField;
}
set
{
this.trkField = value;
}
}
 
/// <remarks/>
public extensionsType extensions
{
get
{
return this.extensionsField;
}
set
{
this.extensionsField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string version
{
get
{
return this.versionField;
}
set
{
this.versionField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string creator
{
get
{
return this.creatorField;
}
set
{
this.creatorField = value;
}
}
}
 
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.topografix.com/GPX/1/1")]
public partial class metadataType
{
 
private string nameField;
 
private string descField;
 
private personType authorField;
 
private copyrightType copyrightField;
 
private linkType[] linkField;
 
private System.DateTime timeField;
 
private bool timeFieldSpecified;
 
private string keywordsField;
 
private boundsType boundsField;
 
private extensionsType extensionsField;
 
/// <remarks/>
public string name
{
get
{
return this.nameField;
}
set
{
this.nameField = value;
}
}
 
/// <remarks/>
public string desc
{
get
{
return this.descField;
}
set
{
this.descField = value;
}
}
 
/// <remarks/>
public personType author
{
get
{
return this.authorField;
}
set
{
this.authorField = value;
}
}
 
/// <remarks/>
public copyrightType copyright
{
get
{
return this.copyrightField;
}
set
{
this.copyrightField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("link")]
public linkType[] link
{
get
{
return this.linkField;
}
set
{
this.linkField = value;
}
}
 
/// <remarks/>
public System.DateTime time
{
get
{
return this.timeField;
}
set
{
this.timeField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool timeSpecified
{
get
{
return this.timeFieldSpecified;
}
set
{
this.timeFieldSpecified = value;
}
}
 
/// <remarks/>
public string keywords
{
get
{
return this.keywordsField;
}
set
{
this.keywordsField = value;
}
}
 
/// <remarks/>
public boundsType bounds
{
get
{
return this.boundsField;
}
set
{
this.boundsField = value;
}
}
 
/// <remarks/>
public extensionsType extensions
{
get
{
return this.extensionsField;
}
set
{
this.extensionsField = value;
}
}
}
 
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.topografix.com/GPX/1/1")]
public partial class personType
{
 
private string nameField;
 
private emailType emailField;
 
private linkType linkField;
 
/// <remarks/>
public string name
{
get
{
return this.nameField;
}
set
{
this.nameField = value;
}
}
 
/// <remarks/>
public emailType email
{
get
{
return this.emailField;
}
set
{
this.emailField = value;
}
}
 
/// <remarks/>
public linkType link
{
get
{
return this.linkField;
}
set
{
this.linkField = value;
}
}
}
 
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.topografix.com/GPX/1/1")]
public partial class emailType
{
 
private string idField;
 
private string domainField;
 
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string id
{
get
{
return this.idField;
}
set
{
this.idField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string domain
{
get
{
return this.domainField;
}
set
{
this.domainField = value;
}
}
}
 
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.topografix.com/GPX/1/1")]
public partial class trksegType
{
 
private wptType[] trkptField;
 
private extensionsType extensionsField;
 
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("trkpt")]
public wptType[] trkpt
{
get
{
return this.trkptField;
}
set
{
this.trkptField = value;
}
}
 
/// <remarks/>
public extensionsType extensions
{
get
{
return this.extensionsField;
}
set
{
this.extensionsField = value;
}
}
}
 
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.topografix.com/GPX/1/1")]
public partial class wptType
{
 
private decimal eleField;
 
private bool eleFieldSpecified;
 
private System.DateTime timeField;
 
private bool timeFieldSpecified;
 
private decimal magvarField;
 
private bool magvarFieldSpecified;
 
private decimal geoidheightField;
 
private bool geoidheightFieldSpecified;
 
private string nameField;
 
private string cmtField;
 
private string descField;
 
private string srcField;
 
private linkType[] linkField;
 
private string symField;
 
private string typeField;
 
private fixType fixField;
 
private bool fixFieldSpecified;
 
private string satField;
 
private decimal hdopField;
 
private bool hdopFieldSpecified;
 
private decimal vdopField;
 
private bool vdopFieldSpecified;
 
private decimal pdopField;
 
private bool pdopFieldSpecified;
 
private decimal ageofdgpsdataField;
 
private bool ageofdgpsdataFieldSpecified;
 
private string dgpsidField;
 
private extensionsType extensionsField;
 
private decimal latField;
 
private decimal lonField;
 
/// <remarks/>
public decimal ele
{
get
{
return this.eleField;
}
set
{
this.eleField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool eleSpecified
{
get
{
return this.eleFieldSpecified;
}
set
{
this.eleFieldSpecified = value;
}
}
 
/// <remarks/>
public System.DateTime time
{
get
{
return this.timeField;
}
set
{
this.timeField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool timeSpecified
{
get
{
return this.timeFieldSpecified;
}
set
{
this.timeFieldSpecified = value;
}
}
 
/// <remarks/>
public decimal magvar
{
get
{
return this.magvarField;
}
set
{
this.magvarField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool magvarSpecified
{
get
{
return this.magvarFieldSpecified;
}
set
{
this.magvarFieldSpecified = value;
}
}
 
/// <remarks/>
public decimal geoidheight
{
get
{
return this.geoidheightField;
}
set
{
this.geoidheightField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool geoidheightSpecified
{
get
{
return this.geoidheightFieldSpecified;
}
set
{
this.geoidheightFieldSpecified = value;
}
}
 
/// <remarks/>
public string name
{
get
{
return this.nameField;
}
set
{
this.nameField = value;
}
}
 
/// <remarks/>
public string cmt
{
get
{
return this.cmtField;
}
set
{
this.cmtField = value;
}
}
 
/// <remarks/>
public string desc
{
get
{
return this.descField;
}
set
{
this.descField = value;
}
}
 
/// <remarks/>
public string src
{
get
{
return this.srcField;
}
set
{
this.srcField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("link")]
public linkType[] link
{
get
{
return this.linkField;
}
set
{
this.linkField = value;
}
}
 
/// <remarks/>
public string sym
{
get
{
return this.symField;
}
set
{
this.symField = value;
}
}
 
/// <remarks/>
public string type
{
get
{
return this.typeField;
}
set
{
this.typeField = value;
}
}
 
/// <remarks/>
public fixType fix
{
get
{
return this.fixField;
}
set
{
this.fixField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool fixSpecified
{
get
{
return this.fixFieldSpecified;
}
set
{
this.fixFieldSpecified = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(DataType="nonNegativeInteger")]
public string sat
{
get
{
return this.satField;
}
set
{
this.satField = value;
}
}
 
/// <remarks/>
public decimal hdop
{
get
{
return this.hdopField;
}
set
{
this.hdopField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool hdopSpecified
{
get
{
return this.hdopFieldSpecified;
}
set
{
this.hdopFieldSpecified = value;
}
}
 
/// <remarks/>
public decimal vdop
{
get
{
return this.vdopField;
}
set
{
this.vdopField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool vdopSpecified
{
get
{
return this.vdopFieldSpecified;
}
set
{
this.vdopFieldSpecified = value;
}
}
 
/// <remarks/>
public decimal pdop
{
get
{
return this.pdopField;
}
set
{
this.pdopField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool pdopSpecified
{
get
{
return this.pdopFieldSpecified;
}
set
{
this.pdopFieldSpecified = value;
}
}
 
/// <remarks/>
public decimal ageofdgpsdata
{
get
{
return this.ageofdgpsdataField;
}
set
{
this.ageofdgpsdataField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool ageofdgpsdataSpecified
{
get
{
return this.ageofdgpsdataFieldSpecified;
}
set
{
this.ageofdgpsdataFieldSpecified = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(DataType="integer")]
public string dgpsid
{
get
{
return this.dgpsidField;
}
set
{
this.dgpsidField = value;
}
}
 
/// <remarks/>
public extensionsType extensions
{
get
{
return this.extensionsField;
}
set
{
this.extensionsField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public decimal lat
{
get
{
return this.latField;
}
set
{
this.latField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public decimal lon
{
get
{
return this.lonField;
}
set
{
this.lonField = value;
}
}
}
 
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.topografix.com/GPX/1/1")]
public partial class linkType
{
 
private string textField;
 
private string typeField;
 
private string hrefField;
 
/// <remarks/>
public string text
{
get
{
return this.textField;
}
set
{
this.textField = value;
}
}
 
/// <remarks/>
public string type
{
get
{
return this.typeField;
}
set
{
this.typeField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute(DataType="anyURI")]
public string href
{
get
{
return this.hrefField;
}
set
{
this.hrefField = value;
}
}
}
 
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.topografix.com/GPX/1/1")]
public enum fixType
{
 
/// <remarks/>
none,
 
/// <remarks/>
[System.Xml.Serialization.XmlEnumAttribute("2d")]
Item2d,
 
/// <remarks/>
[System.Xml.Serialization.XmlEnumAttribute("3d")]
Item3d,
 
/// <remarks/>
dgps,
 
/// <remarks/>
pps,
}
 
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.topografix.com/GPX/1/1")]
public partial class extensionsType
{
 
private System.Xml.XmlElement[] anyField;
 
/// <remarks/>
[System.Xml.Serialization.XmlAnyElementAttribute()]
public System.Xml.XmlElement[] Any
{
get
{
return this.anyField;
}
set
{
this.anyField = value;
}
}
}
 
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.topografix.com/GPX/1/1")]
public partial class trkType
{
 
private string nameField;
 
private string cmtField;
 
private string descField;
 
private string srcField;
 
private linkType[] linkField;
 
private string numberField;
 
private string typeField;
 
private extensionsType extensionsField;
 
private trksegType[] trksegField;
 
/// <remarks/>
public string name
{
get
{
return this.nameField;
}
set
{
this.nameField = value;
}
}
 
/// <remarks/>
public string cmt
{
get
{
return this.cmtField;
}
set
{
this.cmtField = value;
}
}
 
/// <remarks/>
public string desc
{
get
{
return this.descField;
}
set
{
this.descField = value;
}
}
 
/// <remarks/>
public string src
{
get
{
return this.srcField;
}
set
{
this.srcField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("link")]
public linkType[] link
{
get
{
return this.linkField;
}
set
{
this.linkField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(DataType="nonNegativeInteger")]
public string number
{
get
{
return this.numberField;
}
set
{
this.numberField = value;
}
}
 
/// <remarks/>
public string type
{
get
{
return this.typeField;
}
set
{
this.typeField = value;
}
}
 
/// <remarks/>
public extensionsType extensions
{
get
{
return this.extensionsField;
}
set
{
this.extensionsField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("trkseg")]
public trksegType[] trkseg
{
get
{
return this.trksegField;
}
set
{
this.trksegField = value;
}
}
}
 
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.topografix.com/GPX/1/1")]
public partial class rteType
{
 
private string nameField;
 
private string cmtField;
 
private string descField;
 
private string srcField;
 
private linkType[] linkField;
 
private string numberField;
 
private string typeField;
 
private extensionsType extensionsField;
 
private wptType[] rteptField;
 
/// <remarks/>
public string name
{
get
{
return this.nameField;
}
set
{
this.nameField = value;
}
}
 
/// <remarks/>
public string cmt
{
get
{
return this.cmtField;
}
set
{
this.cmtField = value;
}
}
 
/// <remarks/>
public string desc
{
get
{
return this.descField;
}
set
{
this.descField = value;
}
}
 
/// <remarks/>
public string src
{
get
{
return this.srcField;
}
set
{
this.srcField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("link")]
public linkType[] link
{
get
{
return this.linkField;
}
set
{
this.linkField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(DataType="nonNegativeInteger")]
public string number
{
get
{
return this.numberField;
}
set
{
this.numberField = value;
}
}
 
/// <remarks/>
public string type
{
get
{
return this.typeField;
}
set
{
this.typeField = value;
}
}
 
/// <remarks/>
public extensionsType extensions
{
get
{
return this.extensionsField;
}
set
{
this.extensionsField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("rtept")]
public wptType[] rtept
{
get
{
return this.rteptField;
}
set
{
this.rteptField = value;
}
}
}
 
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.topografix.com/GPX/1/1")]
public partial class boundsType
{
 
private decimal minlatField;
 
private decimal minlonField;
 
private decimal maxlatField;
 
private decimal maxlonField;
 
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public decimal minlat
{
get
{
return this.minlatField;
}
set
{
this.minlatField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public decimal minlon
{
get
{
return this.minlonField;
}
set
{
this.minlonField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public decimal maxlat
{
get
{
return this.maxlatField;
}
set
{
this.maxlatField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public decimal maxlon
{
get
{
return this.maxlonField;
}
set
{
this.maxlonField = value;
}
}
}
 
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.topografix.com/GPX/1/1")]
public partial class copyrightType
{
 
private string yearField;
 
private string licenseField;
 
private string authorField;
 
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(DataType="gYear")]
public string year
{
get
{
return this.yearField;
}
set
{
this.yearField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(DataType="anyURI")]
public string license
{
get
{
return this.licenseField;
}
set
{
this.licenseField = value;
}
}
 
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string author
{
get
{
return this.authorField;
}
set
{
this.authorField = value;
}
}
}
}