add placesearch
This commit is contained in:
@@ -14,6 +14,7 @@ namespace CampusAppWP8.Feed.GeoApi
|
||||
using CampusAppWP8.Model.Utility;
|
||||
using CampusAppWP8.Resources;
|
||||
using CampusAppWP8.Utility;
|
||||
using System.Device.Location;
|
||||
|
||||
/// <summary>
|
||||
/// Class for SPSAPI
|
||||
|
||||
@@ -105,7 +105,9 @@
|
||||
<Compile Include="Feed\Mensa\MensaFeedCBNorth.cs" />
|
||||
<Compile Include="Feed\Mensa\MensaFeedCBMain.cs" />
|
||||
<Compile Include="Model\Campusmap\CBMainMapModel.cs" />
|
||||
<Compile Include="Model\GeoDb\PlaceInformation.cs" />
|
||||
<Compile Include="Model\GeoDb\PlaceModel.cs" />
|
||||
<Compile Include="Model\GeoDb\PlaceService.cs" />
|
||||
<Compile Include="Model\GeoDb\SpsModel.cs" />
|
||||
<Compile Include="Model\Mensa\MealModel.cs" />
|
||||
<Compile Include="Model\Setting\AppSettings.cs" />
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
namespace CampusAppWP8.Model.Campusmap
|
||||
{
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows;
|
||||
using CampusAppWP8.Model.GeoDb;
|
||||
|
||||
/// <summary>
|
||||
/// Class for the MapModel of the mainCampus of cottbus
|
||||
@@ -30,5 +32,34 @@ namespace CampusAppWP8.Model.Campusmap
|
||||
this.GeoOffsetX = 14.327159;
|
||||
this.GeoOffsetY = 51.766548;
|
||||
}
|
||||
|
||||
/// <summary>Loads the spatial./.</summary>
|
||||
/// <remarks>Stubbfel, 19.08.2013.</remarks>
|
||||
protected override void LoadSpatials()
|
||||
{
|
||||
ObservableCollection<PlaceModel> places = new ObservableCollection<PlaceModel>();
|
||||
ObservableCollection<PlaceInformation> infos = new ObservableCollection<PlaceInformation>();
|
||||
|
||||
infos.Add(new PlaceInformation() { InformationName = "name", InformationValue = "Campus Cottbus Mitte" });
|
||||
infos.Add(new PlaceInformation() { InformationName = "type", InformationValue = "campus" });
|
||||
places.Add(new PlaceModel() { PlaceId = "1", RefPoint = "POINT(14.324056352976152 51.76737987049448)", Informations = infos });
|
||||
|
||||
infos = new ObservableCollection<PlaceInformation>();
|
||||
infos.Add(new PlaceInformation() { InformationName = "name", InformationValue = "MZG" });
|
||||
infos.Add(new PlaceInformation() { InformationName = "type", InformationValue = "Mehrzweck" });
|
||||
places.Add(new PlaceModel() { PlaceId = "5", ParentId = "1", RefPoint = "POINT(14.321714914733889 51.76608468494122)", Informations = infos });
|
||||
|
||||
infos = new ObservableCollection<PlaceInformation>();
|
||||
infos.Add(new PlaceInformation() { InformationName = "name", InformationValue = "BTU Mensa" });
|
||||
infos.Add(new PlaceInformation() { InformationName = "type", InformationValue = "restaurant" });
|
||||
places.Add(new PlaceModel() { PlaceId = "145280193", ParentId = "1", RefPoint = "POINT(14.326168833333334 51.76649038666667)", Informations = infos });
|
||||
|
||||
if (this.Spatial == null)
|
||||
{
|
||||
this.Spatial = new SpsModel();
|
||||
}
|
||||
|
||||
this.Spatial.Places = places;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace CampusAppWP8.Model.Campusmap
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media.Imaging;
|
||||
using CampusAppWP8.Model.GeoDb;
|
||||
|
||||
/// <summary>
|
||||
/// This Class manage the properties of a Map
|
||||
@@ -24,6 +25,7 @@ namespace CampusAppWP8.Model.Campusmap
|
||||
/// </summary>
|
||||
public MapModel()
|
||||
{
|
||||
this.LoadSpatials();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -80,6 +82,10 @@ namespace CampusAppWP8.Model.Campusmap
|
||||
/// </summary>
|
||||
public Point RefPoint { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the spatial of the map.</summary>
|
||||
/// <value>The spatial.</value>
|
||||
public SpsModel Spatial { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
@@ -199,6 +205,11 @@ namespace CampusAppWP8.Model.Campusmap
|
||||
return this.ConverToMapPoint(point.X, point.Y);
|
||||
}
|
||||
|
||||
/// <summary>Loads the spatial./</summary>
|
||||
/// <remarks>Stubbfel, 19.08.2013.</remarks>
|
||||
protected virtual void LoadSpatials()
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
26
CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceInformation.cs
Normal file
26
CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceInformation.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="PlaceInformation.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// </copyright>
|
||||
// <author>stubbfel</author>
|
||||
// <sience>19.08.2013</sience>
|
||||
//----------------------------------------------------------------------
|
||||
namespace CampusAppWP8.Model.GeoDb
|
||||
{
|
||||
using System.Xml.Serialization;
|
||||
|
||||
/// <summary>Information about the place.</summary>
|
||||
/// <remarks>Stubbfel, 19.08.2013.</remarks>
|
||||
public class PlaceInformation
|
||||
{
|
||||
/// <summary>Gets or sets the name of the information.</summary>
|
||||
/// <value>The name of the information.</value>
|
||||
[XmlElement("placeInformationName")]
|
||||
public string InformationName { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the information value.</summary>
|
||||
/// <value>The information value.</value>
|
||||
[XmlText]
|
||||
public string InformationValue { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,14 @@
|
||||
|
||||
namespace CampusAppWP8.Model.GeoDb
|
||||
{
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Device.Location;
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml.Serialization;
|
||||
using CampusAppWP8.Resources;
|
||||
using CampusAppWP8.Utility;
|
||||
|
||||
/// <summary>
|
||||
/// Model for a place of the SPSService
|
||||
@@ -32,5 +39,49 @@ namespace CampusAppWP8.Model.GeoDb
|
||||
/// </summary>
|
||||
[XmlAttribute("refpoint")]
|
||||
public string RefPoint { get; set; }
|
||||
|
||||
/// <summary>Gets the geo reference point.</summary>
|
||||
/// <value>The geo reference point.</value>
|
||||
public GeoCoordinate GeoRefPoint
|
||||
{
|
||||
get
|
||||
{
|
||||
string refstring = this.RefPoint;
|
||||
Regex rx = new Regex(Constants.Regex_Coordinate);
|
||||
MatchCollection matches = rx.Matches(refstring);
|
||||
if (matches.Count != 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
string[] values = matches[0].ToString().Split(' ');
|
||||
|
||||
if (values.Length != 2)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// create the GeoCoordirate
|
||||
try
|
||||
{
|
||||
return new GeoCoordinate(double.Parse(values[1], CultureInfo.InvariantCulture), double.Parse(values[0], CultureInfo.InvariantCulture));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogException(ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets or sets the information.</summary>
|
||||
/// <value>The information.</value>
|
||||
[XmlElement("placeInformation")]
|
||||
public ObservableCollection<PlaceInformation> Informations { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the services.</summary>
|
||||
/// <value>The services.</value>
|
||||
[XmlElement("placeService")]
|
||||
public ObservableCollection<PlaceService> Services { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
32
CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceService.cs
Normal file
32
CampusAppWP8/CampusAppWP8/Model/GeoDb/PlaceService.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// <copyright file="PlaceService.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// </copyright>
|
||||
// <author>stubbfel</author>
|
||||
// <sience>19.08.2013</sience>
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace CampusAppWP8.Model.GeoDb
|
||||
{
|
||||
using System.Xml.Serialization;
|
||||
|
||||
/// <summary>Place service.</summary>
|
||||
/// <remarks>Stubbfel, 19.08.2013.</remarks>
|
||||
public class PlaceService
|
||||
{
|
||||
/// <summary>Gets or sets the name of the service.</summary>
|
||||
/// <value>The name of the service.</value>
|
||||
[XmlAttribute("placeServiceName")]
|
||||
public string ServiceName { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the SAP of an service.</summary>
|
||||
/// <value>The sap.</value>
|
||||
[XmlElement("sap")]
|
||||
public string SAP { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the request for a place.</summary>
|
||||
/// <value>The request.</value>
|
||||
[XmlElement("request")]
|
||||
public string Request { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,9 @@
|
||||
|
||||
namespace CampusAppWP8.Model.GeoDb
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
/// <summary>
|
||||
@@ -22,5 +24,57 @@ namespace CampusAppWP8.Model.GeoDb
|
||||
/// </summary>
|
||||
[XmlElement("place")]
|
||||
public ObservableCollection<PlaceModel> Places { get; set; }
|
||||
|
||||
/// <summary>Gets places by information.</summary>
|
||||
/// <remarks>Stubbfel, 19.08.2013.</remarks>
|
||||
/// <param name="query"> The query.</param>
|
||||
/// <param name="ignoreCases"> (Optional) the ignore cases.</param>
|
||||
/// <param name="informationName">(Optional) name of the information.</param>
|
||||
/// <returns>The places by information.</returns>
|
||||
public List<PlaceModel> GetPlacesByInformation(string query, bool ignoreCases = true, string informationName = null)
|
||||
{
|
||||
string querryLow = string.Empty;
|
||||
IEnumerable<PlaceModel> resultplaces = null;
|
||||
|
||||
// select correct statement
|
||||
if (ignoreCases && informationName == null)
|
||||
{
|
||||
querryLow = query.ToLower();
|
||||
resultplaces = from place in this.Places
|
||||
from info in place.Informations
|
||||
where info.InformationValue.ToLower().Contains(querryLow)
|
||||
select place;
|
||||
}
|
||||
else if (ignoreCases && informationName != null)
|
||||
{
|
||||
querryLow = query.ToLower();
|
||||
resultplaces = from place in this.Places
|
||||
from info in place.Informations
|
||||
where info.InformationValue.ToLower().Contains(querryLow) && info.InformationName.Equals(informationName)
|
||||
select place;
|
||||
}
|
||||
else if (!ignoreCases && informationName == null)
|
||||
{
|
||||
resultplaces = from place in this.Places
|
||||
from info in place.Informations
|
||||
where info.InformationValue.Contains(querryLow)
|
||||
select place;
|
||||
}
|
||||
else if (!ignoreCases && informationName != null)
|
||||
{
|
||||
resultplaces = from place in this.Places
|
||||
from info in place.Informations
|
||||
where info.InformationValue.Contains(querryLow) && info.InformationName.Equals(informationName)
|
||||
select place;
|
||||
}
|
||||
|
||||
// null assert
|
||||
if (resultplaces == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return resultplaces.ToList<PlaceModel>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,11 +35,11 @@
|
||||
<Grid Grid.Row="0">
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<!-- <ColumnDefinition Width="*"/> -->
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0">
|
||||
<!-- <StackPanel Grid.Column="0">
|
||||
<TextBlock Text="Lat:" />
|
||||
<TextBox Name="YPoint" Text="51,767747" InputScope="Number" />
|
||||
</StackPanel>
|
||||
@@ -49,6 +49,12 @@
|
||||
</StackPanel>
|
||||
<Button Grid.Column="2" Click="Button_Click">
|
||||
<Image Source="{Binding Path=ThemelizedIcon.Search, Source={StaticResource ThemelizedIcons}}" Width="60"/>
|
||||
</Button>-->
|
||||
<StackPanel Grid.Column="0" VerticalAlignment="Center">
|
||||
<TextBox Name="QString" InputScope="Text" AcceptsReturn="True" />
|
||||
</StackPanel>
|
||||
<Button Grid.Column="1" Click="Button_Click2">
|
||||
<Image Source="{Binding Path=ThemelizedIcon.Search, Source={StaticResource ThemelizedIcons}}" Width="60"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
<ScrollViewer Name="MapScroller" Grid.Row="1" HorizontalScrollBarVisibility="Auto" RenderTransformOrigin="0,0">
|
||||
|
||||
@@ -8,11 +8,14 @@
|
||||
namespace CampusAppWP8.Pages.Campusmap
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Device.Location;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Navigation;
|
||||
using CampusAppWP8.Model.Campusmap;
|
||||
using CampusAppWP8.Model.GeoDb;
|
||||
using CampusAppWP8.Resources;
|
||||
using CampusAppWP8.Utility;
|
||||
using Microsoft.Phone.Controls;
|
||||
@@ -39,7 +42,9 @@ namespace CampusAppWP8.Pages.Campusmap
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
this.ShowCurrentPositionDispatcher();
|
||||
MapCanvas.Children.Clear();
|
||||
this.AddPins(this.SearchPlaces("campus"));
|
||||
this.ShowCurrentPositionDispatcher();
|
||||
}
|
||||
|
||||
/// <summary>Button click method.</summary>
|
||||
@@ -48,7 +53,48 @@ namespace CampusAppWP8.Pages.Campusmap
|
||||
/// <param name="e"> some EventArgs.</param>
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.AddPin(double.Parse(XPoint.Text), double.Parse(YPoint.Text));
|
||||
// this.AddPin(double.Parse(XPoint.Text), double.Parse(YPoint.Text));
|
||||
}
|
||||
|
||||
/// <summary>Button click method.</summary>
|
||||
/// <remarks>Stubbfel, 19.08.2013.</remarks>
|
||||
/// <param name="sender">caller object.</param>
|
||||
/// <param name="e"> some EventArgs.</param>
|
||||
private void Button_Click2(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string query = QString.Text.Trim();
|
||||
|
||||
if (query.Equals(string.Empty))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MapCanvas.Children.Clear();
|
||||
this.AddPins(this.SearchPlaces(query));
|
||||
}
|
||||
|
||||
/// <summary>Searches for the first places.</summary>
|
||||
/// <remarks>Stubbfel, 19.08.2013.</remarks>
|
||||
/// <param name="query">The query.</param>
|
||||
/// <returns>The found places.</returns>
|
||||
private List<PlaceModel> SearchPlaces(string query)
|
||||
{
|
||||
return this.map.Spatial.GetPlacesByInformation(query);
|
||||
}
|
||||
|
||||
/// <summary>Adds the pins.</summary>
|
||||
/// <remarks>Stubbfel, 19.08.2013.</remarks>
|
||||
/// <param name="places">The places.</param>
|
||||
private void AddPins(List<PlaceModel> places)
|
||||
{
|
||||
foreach (PlaceModel place in places)
|
||||
{
|
||||
GeoCoordinate coor = place.GeoRefPoint;
|
||||
if (coor != null)
|
||||
{
|
||||
this.AddPin(coor.Longitude, coor.Latitude);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Add Pin to an certain position.</summary>
|
||||
@@ -57,15 +103,15 @@ namespace CampusAppWP8.Pages.Campusmap
|
||||
/// <param name="y">latitude parameter.</param>
|
||||
private void AddPin(double x, double y)
|
||||
{
|
||||
MapCanvas.Children.Clear();
|
||||
Point scrollPoint = this.map.GetScrollPoint(this.map.ConverToPixelPoint(this.map.ConverToMapPoint(x, y)));
|
||||
MapCanvas.Children.Add(this.map.AddPinFromRefPoint(this.map.ConverToPixelPoint(this.map.ConverToMapPoint(x, y))));
|
||||
|
||||
MapScroller.UpdateLayout();
|
||||
MapScroller.ScrollToVerticalOffset(scrollPoint.Y);
|
||||
MapScroller.ScrollToHorizontalOffset(scrollPoint.X);
|
||||
XPoint.Text = x.ToString();
|
||||
YPoint.Text = y.ToString();
|
||||
|
||||
// XPoint.Text = x.ToString();
|
||||
// YPoint.Text = y.ToString();
|
||||
}
|
||||
|
||||
/// <summary>On clicking the update button in the ApplicationBar.</summary>
|
||||
@@ -74,7 +120,7 @@ namespace CampusAppWP8.Pages.Campusmap
|
||||
/// <param name="e"> some EventArgs.</param>
|
||||
private void UpdateButtonAppBar_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
this.ShowCurrentPositionDispatcher();
|
||||
this.ShowCurrentPositionDispatcher();
|
||||
}
|
||||
|
||||
/// <summary>execute ShowCurrentPosition-Method via Dispatcher.</summary>
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace CampusAppWP8.Pages.Mensa
|
||||
using CampusAppWP8.Resources;
|
||||
using CampusAppWP8.Utility.Lui.MessageBoxes;
|
||||
using Microsoft.Phone.Controls;
|
||||
using System.Threading;
|
||||
|
||||
/// <summary>
|
||||
/// Class for the MensaPage
|
||||
@@ -99,7 +100,14 @@ namespace CampusAppWP8.Pages.Mensa
|
||||
/// </summary>
|
||||
private void SpsApiIsReady()
|
||||
{
|
||||
this.InitializeFeed(this.campusApi.GetCampus());
|
||||
if (this.Dispatcher != null)
|
||||
{
|
||||
this.Dispatcher.BeginInvoke(new Action(() => this.InitializeFeed(this.campusApi.GetCampus())));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.InitializeFeed(this.campusApi.GetCampus());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -153,14 +161,8 @@ namespace CampusAppWP8.Pages.Mensa
|
||||
{
|
||||
if (Settings.AppSetting.GeoWatchEnable)
|
||||
{
|
||||
if (this.Dispatcher != null)
|
||||
{
|
||||
this.Dispatcher.BeginInvoke(new Action(() => this.DeterminCurrentCampusAndLoadFeed()));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.DeterminCurrentCampusAndLoadFeed();
|
||||
}
|
||||
Thread thread = new Thread(new ThreadStart( this.DeterminCurrentCampusAndLoadFeed));
|
||||
thread.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -645,6 +645,15 @@ namespace CampusAppWP8.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die [+-]{0,1}[0-9]+[.,]{0,1}[0-9]+[\s][+-]{0,1}[0-9]+[.,]{0,1}[0-9]+ ähnelt.
|
||||
/// </summary>
|
||||
public static string Regex_Coordinate {
|
||||
get {
|
||||
return ResourceManager.GetString("Regex_Coordinate", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die 767 ähnelt.
|
||||
/// </summary>
|
||||
|
||||
@@ -408,4 +408,7 @@
|
||||
<data name="PathCampusmap_Campusmap" xml:space="preserve">
|
||||
<value>/Pages/Campusmap/CampusMapPage.xaml</value>
|
||||
</data>
|
||||
<data name="Regex_Coordinate" xml:space="preserve">
|
||||
<value>[+-]{0,1}[0-9]+[.,]{0,1}[0-9]+[\s][+-]{0,1}[0-9]+[.,]{0,1}[0-9]+</value>
|
||||
</data>
|
||||
</root>
|
||||
Reference in New Issue
Block a user