diff --git a/CampusAppWP8/CampusAppWP8/Api/GeoApi/CampusSpsApi.cs b/CampusAppWP8/CampusAppWP8/Api/GeoApi/CampusSpsApi.cs
index 578ebf8a..f9df631b 100644
--- a/CampusAppWP8/CampusAppWP8/Api/GeoApi/CampusSpsApi.cs
+++ b/CampusAppWP8/CampusAppWP8/Api/GeoApi/CampusSpsApi.cs
@@ -11,7 +11,8 @@ namespace CampusAppWP8.Api.GeoApi
using System;
using CampusAppWP8.Model.GeoDb;
using CampusAppWP8.Resources;
- using CampusAppWP8.Utility;
+ using CampusAppWP8.Utility;
+ using CampusAppWPortalLib8.Model.Utility;
/// Class for SPSAPI.
/// Stubbfel, 14.10.2013.
@@ -37,7 +38,7 @@ namespace CampusAppWP8.Api.GeoApi
/// Stubbfel, 14.10.2013.
/// latitude parameter.
/// longitude parameter.
- public void SetupCampusRequest(string lat, string log)
+ public void SetupCampusRequest(double lat, double log)
{
this.SetupPlaceRequest(lat, log, Constants.SpsApi_CampusDomain);
}
@@ -47,9 +48,12 @@ namespace CampusAppWP8.Api.GeoApi
public void SetupCurrentCampusRequest()
{
Utilities.DetermineAndStoreCurrentPosition();
- string lat = App.LoadFromAppState(Constants.GeoWatch_CurrentPosition_Lat);
- string log = App.LoadFromAppState(Constants.GeoWatch_CurrentPosition_Long);
- this.SetupCampusRequest(lat, log);
+ GeoMapPoint currentPosition = App.LoadFromAppState(Constants.GeoWatch_CurrentPositionPoint);
+ if (currentPosition != null)
+ {
+ this.SetupCampusRequest(currentPosition.Latitude, currentPosition.Longitude);
+ }
+
}
/// Method return the campus of the placeList.
diff --git a/CampusAppWP8/CampusAppWP8/Api/GeoApi/SpsApi.cs b/CampusAppWP8/CampusAppWP8/Api/GeoApi/SpsApi.cs
index 6e0959db..ec7d42bf 100644
--- a/CampusAppWP8/CampusAppWP8/Api/GeoApi/SpsApi.cs
+++ b/CampusAppWP8/CampusAppWP8/Api/GeoApi/SpsApi.cs
@@ -41,11 +41,11 @@ namespace CampusAppWP8.Api.GeoApi
/// latitude of the place.
/// longitude of the place.
/// (Optional) request domain.
- public void SetupPlaceRequest(string lat, string log, string domian = null)
+ public void SetupPlaceRequest(double lat, double log, string domian = null)
{
List parameterList = new List();
- parameterList.Add(new CleanUrlParamModel(Constants.SpsApi_LatitudeParaKey, lat));
- parameterList.Add(new CleanUrlParamModel(Constants.SpsApi_LongitudeParaKey, log));
+ parameterList.Add(new CleanUrlParamModel(Constants.SpsApi_LatitudeParaKey, lat.ToString()));
+ parameterList.Add(new CleanUrlParamModel(Constants.SpsApi_LongitudeParaKey, log.ToString()));
if (domian != null)
{
parameterList.Add(new CleanUrlParamModel(Constants.SpsApi_DomainParaKey, domian));
@@ -60,9 +60,11 @@ namespace CampusAppWP8.Api.GeoApi
public void SetupCurrentPlaceRequest(string domian = null)
{
Utilities.DetermineAndStoreCurrentPosition();
- string lat = App.LoadFromAppState(Constants.GeoWatch_CurrentPosition_Lat);
- string log = App.LoadFromAppState(Constants.GeoWatch_CurrentPosition_Long);
- this.SetupPlaceRequest(lat, log, domian);
+ GeoMapPoint currentPosition = App.LoadFromAppState(Constants.GeoWatch_CurrentPositionPoint);
+ if (currentPosition != null)
+ {
+ this.SetupPlaceRequest(currentPosition.Latitude, currentPosition.Latitude, domian);
+ }
}
#endregion
diff --git a/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceWp8Model.cs b/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceWp8Model.cs
index 92113a00..de0deb4c 100644
--- a/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceWp8Model.cs
+++ b/CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceWp8Model.cs
@@ -14,6 +14,7 @@ namespace CampusAppWP8.Model.GeoDb
using System.Text.RegularExpressions;
using CampusAppWP8.Resources;
using CampusAppWPortalLib8.Utility;
+ using CampusAppWPortalLib8.Model.Utility;
/// Model for a place of the SPSService.
/// Stubbfel, 15.10.2013.
@@ -25,7 +26,7 @@ namespace CampusAppWP8.Model.GeoDb
/// Gets the geo reference point.
/// The geo reference point.
- public GeoCoordinate GeoRefPoint
+ public GeoMapPoint GeoRefPoint
{
get
{
@@ -47,7 +48,7 @@ namespace CampusAppWP8.Model.GeoDb
// create the GeoCoordirate
try
{
- return new GeoCoordinate(double.Parse(values[1], CultureInfo.InvariantCulture), double.Parse(values[0], CultureInfo.InvariantCulture));
+ return new GeoMapPoint(double.Parse(values[1], CultureInfo.InvariantCulture), double.Parse(values[0], CultureInfo.InvariantCulture),0);
}
catch (Exception ex)
{
diff --git a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs
index 34b88ea9..1e9d688f 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs
@@ -604,7 +604,7 @@ namespace CampusAppWP8.Pages.Campusmap
continue;
}
- GeoCoordinate coor = place.GeoRefPoint;
+ GeoMapPoint coor = place.GeoRefPoint;
if (coor != null)
{
List assocPlaces = new List();
@@ -709,9 +709,8 @@ namespace CampusAppWP8.Pages.Campusmap
/// (Optional) the scroll.
private void SetPinToCurrentPosition(bool scroll = true)
{
- string lat = App.LoadFromAppState(Constants.GeoWatch_CurrentPosition_Lat);
- string log = App.LoadFromAppState(Constants.GeoWatch_CurrentPosition_Long);
- if (lat == null || log == null || (lat.Equals("0") && log.Equals("0")))
+ GeoMapPoint currentPosition = App.LoadFromAppState(Constants.GeoWatch_CurrentPositionPoint);
+ if (currentPosition == null || currentPosition.Latitude == 0 || currentPosition.Longitude == 0)
{
if (Settings.AppSetting.GeoWatchEnable)
{
@@ -723,7 +722,7 @@ namespace CampusAppWP8.Pages.Campusmap
else
{
this.ClearMap(new List() { MapPinModel.CurrentPositionPlacePinString });
- this.SetPinToPosition(lat, log, PinType.CurrentPosition, scroll);
+ this.SetPinToPosition(currentPosition.Latitude,currentPosition.Longitude, PinType.CurrentPosition, scroll);
}
}
@@ -733,16 +732,9 @@ namespace CampusAppWP8.Pages.Campusmap
/// The longitude.
/// The type.
/// (Optional) the scroll.
- private void SetPinToPosition(string latitude, string longitude, PinType type, bool scroll = true)
+ private void SetPinToPosition(double latitude, double longitude, PinType type, bool scroll = true)
{
- double x;
- double y;
- if (!double.TryParse(longitude, NumberStyles.Any, CultureInfo.InvariantCulture, out x) || !double.TryParse(latitude, NumberStyles.Any, CultureInfo.InvariantCulture, out y))
- {
- return;
- }
-
- this.AddPin(x, y, type, scroll);
+ this.AddPin(longitude, latitude, type, scroll);
this.DefHeader.ProgressVisibility = Visibility.Collapsed;
}
diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx
index 98f32ee9..e6331c78 100644
--- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx
+++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx
@@ -318,15 +318,6 @@
AppSetting.InitApp
-
- CurrentPosition.Lat
-
-
- CurrentPosition.Long
-
-
- CurrentPosition.Time
-
http://141.43.76.140/service/sps
@@ -585,4 +576,7 @@
BTU-CampusApp
+
+ CurrentPositionPoint
+
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs
index 2da9f39b..e1e2dbbb 100644
--- a/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs
+++ b/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs
@@ -421,29 +421,11 @@ namespace CampusAppWP8.Resources {
}
///
- /// Sucht eine lokalisierte Zeichenfolge, die CurrentPosition.Lat ähnelt.
+ /// Sucht eine lokalisierte Zeichenfolge, die CurrentPositionPoint ähnelt.
///
- public static string GeoWatch_CurrentPosition_Lat {
+ public static string GeoWatch_CurrentPositionPoint {
get {
- return ResourceManager.GetString("GeoWatch_CurrentPosition_Lat", resourceCulture);
- }
- }
-
- ///
- /// Sucht eine lokalisierte Zeichenfolge, die CurrentPosition.Long ähnelt.
- ///
- public static string GeoWatch_CurrentPosition_Long {
- get {
- return ResourceManager.GetString("GeoWatch_CurrentPosition_Long", resourceCulture);
- }
- }
-
- ///
- /// Sucht eine lokalisierte Zeichenfolge, die CurrentPosition.Time ähnelt.
- ///
- public static string GeoWatch_CurrentPosition_Time {
- get {
- return ResourceManager.GetString("GeoWatch_CurrentPosition_Time", resourceCulture);
+ return ResourceManager.GetString("GeoWatch_CurrentPositionPoint", resourceCulture);
}
}
diff --git a/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs b/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs
index cf835b3f..8bd87ed9 100644
--- a/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs
+++ b/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs
@@ -258,10 +258,7 @@ namespace CampusAppWP8.Utility
/// Stubbfel, 14.10.2013.
public static void SetGeoPositionToZero()
{
- string time = DateTime.Now.Ticks.ToString();
- App.SaveToAppState(Constants.GeoWatch_CurrentPosition_Lat, "0");
- App.SaveToAppState(Constants.GeoWatch_CurrentPosition_Long, "0");
- App.SaveToAppState(Constants.GeoWatch_CurrentPosition_Time, time);
+ App.SaveToAppState(Constants.GeoWatch_CurrentPositionPoint, CampusMapPoints.ZeroGeoPoint);
}
/// Method determine and store the current position of the phone.
@@ -272,14 +269,10 @@ namespace CampusAppWP8.Utility
if (geoposition != null)
{
- string lat = geoposition.Location.Latitude.ToString(CultureInfo.InvariantCulture);
- string log = geoposition.Location.Longitude.ToString(CultureInfo.InvariantCulture);
- string time = geoposition.Timestamp.Ticks.ToString();
+ GeoMapPoint geoPoint = new GeoMapPoint(geoposition.Location.Latitude, geoposition.Location.Longitude, geoposition.Timestamp.Ticks);
try
{
- App.SaveToAppState(Constants.GeoWatch_CurrentPosition_Lat, lat);
- App.SaveToAppState(Constants.GeoWatch_CurrentPosition_Long, log);
- App.SaveToAppState(Constants.GeoWatch_CurrentPosition_Time, time);
+ App.SaveToAppState(Constants.GeoWatch_CurrentPositionPoint, geoPoint);
}
catch (Exception ex)
{
@@ -294,22 +287,14 @@ namespace CampusAppWP8.Utility
/// Stubbfel, 14.10.2013.
public static void DetermineAndStoreCurrentPosition()
{
- string lat = App.LoadFromAppState(Constants.GeoWatch_CurrentPosition_Lat);
- string log = App.LoadFromAppState(Constants.GeoWatch_CurrentPosition_Long);
- string time = App.LoadFromAppState(Constants.GeoWatch_CurrentPosition_Time);
- if (lat == null || log == null || time == null || lat.Equals(string.Empty) || log.Equals(string.Empty) || time.Equals(string.Empty))
+ GeoMapPoint currentPoint = App.LoadFromAppState(Constants.GeoWatch_CurrentPositionPoint);
+ if (currentPoint == null)
{
Utilities.DetermineAndStoreCurrentPositionForce();
}
else
{
- long longTime = 0;
- if (!long.TryParse(time, out longTime))
- {
- return;
- }
-
- DateTime expired = new DateTime(longTime).AddMinutes(15);
+ DateTime expired = new DateTime(currentPoint.Timestamp).AddMinutes(15);
if (DateTime.Now.Ticks > expired.Ticks)
{
Utilities.DetermineAndStoreCurrentPositionForce();
@@ -398,15 +383,13 @@ namespace CampusAppWP8.Utility
Campus result = Campus.UserSettingCampus;
Utilities.DetermineAndStoreCurrentPosition();
- double lat;
- double log;
- if (!double.TryParse(App.LoadFromAppState(Constants.GeoWatch_CurrentPosition_Lat), NumberStyles.Number, CultureInfo.InvariantCulture, out lat)
- || !double.TryParse(App.LoadFromAppState(Constants.GeoWatch_CurrentPosition_Long), NumberStyles.Number, CultureInfo.InvariantCulture, out log))
+
+ MapPoint currentPoint = App.LoadFromAppState("CurrentGeoPoint");
+ if (currentPoint == null)
{
return result;
}
- MapPoint currentPoint = new MapPoint(log, lat);
MapPoint tmpCampus = CampusMapPoints.NorthCB;
double minDistance = MapPoint.CalcDistance(currentPoint, tmpCampus);
diff --git a/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj b/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj
index 26f3acae..21f28040 100644
--- a/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj
+++ b/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj
@@ -82,6 +82,7 @@
+
diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Campusmap/Maps/CampusMapPoints.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Campusmap/Maps/CampusMapPoints.cs
index 8a50382c..daa3c1b5 100644
--- a/CampusAppWP8/CampusAppWPortalLib8/Model/Campusmap/Maps/CampusMapPoints.cs
+++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Campusmap/Maps/CampusMapPoints.cs
@@ -9,6 +9,7 @@
namespace CampusAppWPortalLib8.Model.Campusmap.Map
{
using CampusAppWPortalLib8.Model.Utility;
+using System;
/// The campus map points.
/// Stubbfel, 22.10.2013.
@@ -28,10 +29,20 @@ namespace CampusAppWPortalLib8.Model.Campusmap.Map
/// The middle campus of senftenberg.
private static MapPoint midSFB = new MapPoint(13.986618441187698, 51.522217168257356);
+ /// The zero geo point.
+ private static GeoMapPoint zeroGeoPoint = new GeoMapPoint(0, 0, DateTime.Now.Ticks);
+
#endregion
#region porperty
+ /// Gets the zero geo point.
+ /// The zero geo point.
+ public static GeoMapPoint ZeroGeoPoint
+ {
+ get { return CampusMapPoints.zeroGeoPoint; }
+ }
+
/// Gets the middle sfb.
/// The middle sfb.
public static MapPoint MidSFB
diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/GeoMapPoint.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/GeoMapPoint.cs
new file mode 100644
index 00000000..ab300aed
--- /dev/null
+++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/GeoMapPoint.cs
@@ -0,0 +1,71 @@
+using System.Globalization;
+using System.Runtime.Serialization;
+
+namespace CampusAppWPortalLib8.Model.Utility
+{
+ public class GeoMapPoint : MapPoint
+ {
+ #region Constructor
+
+ public GeoMapPoint(double latitude, double longitude, long timestamp)
+ : base(longitude, latitude)
+ {
+ this.Timestamp = timestamp;
+ }
+
+ public GeoMapPoint(string latitude, string longitude, string timestamp)
+ {
+ double lat;
+ double log;
+ long time;
+
+ if (double.TryParse(latitude, NumberStyles.Number, CultureInfo.InvariantCulture, out lat)
+ && double.TryParse(longitude, NumberStyles.Number, CultureInfo.InvariantCulture, out log)
+ && long.TryParse(timestamp, NumberStyles.Number, CultureInfo.InvariantCulture, out time))
+ {
+ this.Latitude = lat;
+ this.Longitude = log;
+ this.Timestamp = time;
+ }
+
+ }
+
+ #endregion
+
+ #region Property
+
+ [DataMember]
+ public double Latitude
+ {
+ get
+ {
+ return this.Y;
+ }
+
+ set
+ {
+ this.Y = value;
+ }
+ }
+
+ [DataMember]
+ public double Longitude
+ {
+ get
+ {
+ return this.X;
+ }
+
+ set
+ {
+ this.X = value;
+ }
+ }
+
+ [DataMember]
+ public long Timestamp { get; set; }
+
+
+ #endregion
+ }
+}
diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/MapPoint.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/MapPoint.cs
index 6105c472..3a6de69f 100644
--- a/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/MapPoint.cs
+++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/MapPoint.cs
@@ -17,6 +17,12 @@ namespace CampusAppWPortalLib8.Model.Utility
{
#region Constructor
+ /// Initializes a new instance of the MapPoint class.
+ /// Stubbfel, 22.10.2013.
+ public MapPoint()
+ {
+ }
+
/// Initializes a new instance of the MapPoint class.
/// Stubbfel, 22.10.2013.
/// The x coordinate.