Exemplo n.º 1
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="Place" /> class.
 /// </summary>
 /// <param name="location"> The geographical location of this pin. </param>
 /// <param name="id"> The ID of this place. </param>
 /// <param name="name"> The name of this place. </param>
 public Place(Location location, Guid id = default(Guid), string name = DefaultName)
 {
     if (location == null)
     {
         throw new ArgumentNullException("location", "Location is required in order to create a place.");
     }
     Location = location;
     Id = id == default(Guid) ? Guid.NewGuid() : id;
     Name = name;
 }
Exemplo n.º 2
0
 public bool Equals(Location other)
 {
     if (ReferenceEquals(null, other))
     {
         return false;
     }
     if (ReferenceEquals(this, other))
     {
         return true;
     }
     return other.Latitude.Equals(Latitude) && other.Longitude.Equals(Longitude);
 }
Exemplo n.º 3
0
 /// <summary>
 ///     Decodes the encoded polyline points string.
 /// </summary>
 /// <remarks>
 ///     Translated from the Original Java code located at http://www.geekyblogger.com/2010/12/decoding-polylines-from-google-maps.html.
 /// </remarks>
 public static List<Location> DecodePolylinePoints(String encodedPoints)
 {
     var poly = new List<Location>();
     var chars = encodedPoints.ToCharArray();
     int index = 0, len = encodedPoints.Length;
     int lat = 0, lng = 0;
     while (index < len)
     {
         int b, shift = 0, result = 0;
         do
         {
             b = chars[index++] - 63;
             result |= (b & 0x1f) << shift;
             shift += 5;
         } while (b >= 0x20);
         var dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
         lat += dlat;
         shift = 0;
         result = 0;
         do
         {
             b = chars[index++] - 63;
             result |= (b & 0x1f) << shift;
             shift += 5;
         } while (b >= 0x20);
         var dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
         lng += dlng;
         var p = new Location
         {
             Latitude = lat/1E5,
             Longitude = lng/1E5
         };
         poly.Add(p);
     }
     return poly;
 }
Exemplo n.º 4
0
 /// <summary>
 ///     Called when <see cref="CommandAddPlace" /> is executed.
 /// </summary>
 private void OnAddPlace(Location location)
 {
     VisualState.Value = VisualStates.Default;
     var newPlace = _data.AddNewPlace(location);
     newPlace.Color = Data.DataExtensions.GetRandomElementColor();
 }