add geomappoint
This commit is contained in:
@@ -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;
|
||||
|
||||
/// <summary> Class for SPSAPI. </summary>
|
||||
/// <remarks> Stubbfel, 14.10.2013. </remarks>
|
||||
@@ -37,7 +38,7 @@ namespace CampusAppWP8.Api.GeoApi
|
||||
/// <remarks> Stubbfel, 14.10.2013. </remarks>
|
||||
/// <param name="lat"> latitude parameter. </param>
|
||||
/// <param name="log"> longitude parameter. </param>
|
||||
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<string>(Constants.GeoWatch_CurrentPosition_Lat);
|
||||
string log = App.LoadFromAppState<string>(Constants.GeoWatch_CurrentPosition_Long);
|
||||
this.SetupCampusRequest(lat, log);
|
||||
GeoMapPoint currentPosition = App.LoadFromAppState<GeoMapPoint>(Constants.GeoWatch_CurrentPositionPoint);
|
||||
if (currentPosition != null)
|
||||
{
|
||||
this.SetupCampusRequest(currentPosition.Latitude, currentPosition.Longitude);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary> Method return the campus of the placeList. </summary>
|
||||
|
||||
@@ -41,11 +41,11 @@ namespace CampusAppWP8.Api.GeoApi
|
||||
/// <param name="lat"> latitude of the place. </param>
|
||||
/// <param name="log"> longitude of the place. </param>
|
||||
/// <param name="domian"> (Optional) request domain. </param>
|
||||
public void SetupPlaceRequest(string lat, string log, string domian = null)
|
||||
public void SetupPlaceRequest(double lat, double log, string domian = null)
|
||||
{
|
||||
List<UrlParamModel> parameterList = new List<UrlParamModel>();
|
||||
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<string>(Constants.GeoWatch_CurrentPosition_Lat);
|
||||
string log = App.LoadFromAppState<string>(Constants.GeoWatch_CurrentPosition_Long);
|
||||
this.SetupPlaceRequest(lat, log, domian);
|
||||
GeoMapPoint currentPosition = App.LoadFromAppState<GeoMapPoint>(Constants.GeoWatch_CurrentPositionPoint);
|
||||
if (currentPosition != null)
|
||||
{
|
||||
this.SetupPlaceRequest(currentPosition.Latitude, currentPosition.Latitude, domian);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace CampusAppWP8.Model.GeoDb
|
||||
using System.Text.RegularExpressions;
|
||||
using CampusAppWP8.Resources;
|
||||
using CampusAppWPortalLib8.Utility;
|
||||
using CampusAppWPortalLib8.Model.Utility;
|
||||
|
||||
/// <summary> Model for a place of the SPSService. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
@@ -25,7 +26,7 @@ namespace CampusAppWP8.Model.GeoDb
|
||||
|
||||
/// <summary> Gets the geo reference point. </summary>
|
||||
/// <value> The geo reference point. </value>
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -604,7 +604,7 @@ namespace CampusAppWP8.Pages.Campusmap
|
||||
continue;
|
||||
}
|
||||
|
||||
GeoCoordinate coor = place.GeoRefPoint;
|
||||
GeoMapPoint coor = place.GeoRefPoint;
|
||||
if (coor != null)
|
||||
{
|
||||
List<PlaceWp8Model> assocPlaces = new List<PlaceWp8Model>();
|
||||
@@ -709,9 +709,8 @@ namespace CampusAppWP8.Pages.Campusmap
|
||||
/// <param name="scroll"> (Optional) the scroll. </param>
|
||||
private void SetPinToCurrentPosition(bool scroll = true)
|
||||
{
|
||||
string lat = App.LoadFromAppState<string>(Constants.GeoWatch_CurrentPosition_Lat);
|
||||
string log = App.LoadFromAppState<string>(Constants.GeoWatch_CurrentPosition_Long);
|
||||
if (lat == null || log == null || (lat.Equals("0") && log.Equals("0")))
|
||||
GeoMapPoint currentPosition = App.LoadFromAppState<GeoMapPoint>(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<string>() { 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
|
||||
/// <param name="longitude"> The longitude. </param>
|
||||
/// <param name="type"> The type. </param>
|
||||
/// <param name="scroll"> (Optional) the scroll. </param>
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -318,15 +318,6 @@
|
||||
<data name="AppSetting_InitApp" xml:space="preserve">
|
||||
<value>AppSetting.InitApp</value>
|
||||
</data>
|
||||
<data name="GeoWatch_CurrentPosition_Lat" xml:space="preserve">
|
||||
<value>CurrentPosition.Lat</value>
|
||||
</data>
|
||||
<data name="GeoWatch_CurrentPosition_Long" xml:space="preserve">
|
||||
<value>CurrentPosition.Long</value>
|
||||
</data>
|
||||
<data name="GeoWatch_CurrentPosition_Time" xml:space="preserve">
|
||||
<value>CurrentPosition.Time</value>
|
||||
</data>
|
||||
<data name="UrlSpsService" xml:space="preserve">
|
||||
<value>http://141.43.76.140/service/sps</value>
|
||||
</data>
|
||||
@@ -585,4 +576,7 @@
|
||||
<data name="BTUTAG_QRStart" xml:space="preserve">
|
||||
<value>BTU-CampusApp</value>
|
||||
</data>
|
||||
<data name="GeoWatch_CurrentPositionPoint" xml:space="preserve">
|
||||
<value>CurrentPositionPoint</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -421,29 +421,11 @@ namespace CampusAppWP8.Resources {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die CurrentPosition.Lat ähnelt.
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die CurrentPositionPoint ähnelt.
|
||||
/// </summary>
|
||||
public static string GeoWatch_CurrentPosition_Lat {
|
||||
public static string GeoWatch_CurrentPositionPoint {
|
||||
get {
|
||||
return ResourceManager.GetString("GeoWatch_CurrentPosition_Lat", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die CurrentPosition.Long ähnelt.
|
||||
/// </summary>
|
||||
public static string GeoWatch_CurrentPosition_Long {
|
||||
get {
|
||||
return ResourceManager.GetString("GeoWatch_CurrentPosition_Long", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die CurrentPosition.Time ähnelt.
|
||||
/// </summary>
|
||||
public static string GeoWatch_CurrentPosition_Time {
|
||||
get {
|
||||
return ResourceManager.GetString("GeoWatch_CurrentPosition_Time", resourceCulture);
|
||||
return ResourceManager.GetString("GeoWatch_CurrentPositionPoint", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -258,10 +258,7 @@ namespace CampusAppWP8.Utility
|
||||
/// <remarks> Stubbfel, 14.10.2013. </remarks>
|
||||
public static void SetGeoPositionToZero()
|
||||
{
|
||||
string time = DateTime.Now.Ticks.ToString();
|
||||
App.SaveToAppState<string>(Constants.GeoWatch_CurrentPosition_Lat, "0");
|
||||
App.SaveToAppState<string>(Constants.GeoWatch_CurrentPosition_Long, "0");
|
||||
App.SaveToAppState<string>(Constants.GeoWatch_CurrentPosition_Time, time);
|
||||
App.SaveToAppState<GeoMapPoint>(Constants.GeoWatch_CurrentPositionPoint, CampusMapPoints.ZeroGeoPoint);
|
||||
}
|
||||
|
||||
/// <summary> Method determine and store the current position of the phone. </summary>
|
||||
@@ -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<string>(Constants.GeoWatch_CurrentPosition_Lat, lat);
|
||||
App.SaveToAppState<string>(Constants.GeoWatch_CurrentPosition_Long, log);
|
||||
App.SaveToAppState<string>(Constants.GeoWatch_CurrentPosition_Time, time);
|
||||
App.SaveToAppState<GeoMapPoint>(Constants.GeoWatch_CurrentPositionPoint, geoPoint);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -294,22 +287,14 @@ namespace CampusAppWP8.Utility
|
||||
/// <remarks> Stubbfel, 14.10.2013. </remarks>
|
||||
public static void DetermineAndStoreCurrentPosition()
|
||||
{
|
||||
string lat = App.LoadFromAppState<string>(Constants.GeoWatch_CurrentPosition_Lat);
|
||||
string log = App.LoadFromAppState<string>(Constants.GeoWatch_CurrentPosition_Long);
|
||||
string time = App.LoadFromAppState<string>(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<GeoMapPoint>(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<string>(Constants.GeoWatch_CurrentPosition_Lat), NumberStyles.Number, CultureInfo.InvariantCulture, out lat)
|
||||
|| !double.TryParse(App.LoadFromAppState<string>(Constants.GeoWatch_CurrentPosition_Long), NumberStyles.Number, CultureInfo.InvariantCulture, out log))
|
||||
|
||||
MapPoint currentPoint = App.LoadFromAppState<GeoMapPoint>("CurrentGeoPoint");
|
||||
if (currentPoint == null)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
MapPoint currentPoint = new MapPoint(log, lat);
|
||||
MapPoint tmpCampus = CampusMapPoints.NorthCB;
|
||||
|
||||
double minDistance = MapPoint.CalcDistance(currentPoint, tmpCampus);
|
||||
|
||||
@@ -82,6 +82,7 @@
|
||||
<Compile Include="Model\Utility\CourseListPickerItemListModel.cs" />
|
||||
<Compile Include="Model\Utility\CourseModel.cs" />
|
||||
<Compile Include="Model\Utility\DegreeListPickerItemListModel.cs" />
|
||||
<Compile Include="Model\Utility\GeoMapPoint.cs" />
|
||||
<Compile Include="Model\Utility\ListPickerItemListModel.cs" />
|
||||
<Compile Include="Model\Utility\ListPickerItemModel.cs" />
|
||||
<Compile Include="Model\Utility\MapPoint.cs" />
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
namespace CampusAppWPortalLib8.Model.Campusmap.Map
|
||||
{
|
||||
using CampusAppWPortalLib8.Model.Utility;
|
||||
using System;
|
||||
|
||||
/// <summary> The campus map points. </summary>
|
||||
/// <remarks> Stubbfel, 22.10.2013. </remarks>
|
||||
@@ -28,10 +29,20 @@ namespace CampusAppWPortalLib8.Model.Campusmap.Map
|
||||
/// <summary> The middle campus of senftenberg. </summary>
|
||||
private static MapPoint midSFB = new MapPoint(13.986618441187698, 51.522217168257356);
|
||||
|
||||
/// <summary> The zero geo point. </summary>
|
||||
private static GeoMapPoint zeroGeoPoint = new GeoMapPoint(0, 0, DateTime.Now.Ticks);
|
||||
|
||||
#endregion
|
||||
|
||||
#region porperty
|
||||
|
||||
/// <summary> Gets the zero geo point. </summary>
|
||||
/// <value> The zero geo point. </value>
|
||||
public static GeoMapPoint ZeroGeoPoint
|
||||
{
|
||||
get { return CampusMapPoints.zeroGeoPoint; }
|
||||
}
|
||||
|
||||
/// <summary> Gets the middle sfb. </summary>
|
||||
/// <value> The middle sfb. </value>
|
||||
public static MapPoint MidSFB
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,12 @@ namespace CampusAppWPortalLib8.Model.Utility
|
||||
{
|
||||
#region Constructor
|
||||
|
||||
/// <summary> Initializes a new instance of the MapPoint class. </summary>
|
||||
/// <remarks> Stubbfel, 22.10.2013. </remarks>
|
||||
public MapPoint()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary> Initializes a new instance of the MapPoint class. </summary>
|
||||
/// <remarks> Stubbfel, 22.10.2013. </remarks>
|
||||
/// <param name="x"> The x coordinate. </param>
|
||||
|
||||
Reference in New Issue
Block a user