diff --git a/CampusAppWP8/CampusAppWP8/Model/GeoDb/SpsModel.cs b/CampusAppWP8/CampusAppWP8/Model/GeoDb/SpsModel.cs
index 1430a436..b51fb54c 100644
--- a/CampusAppWP8/CampusAppWP8/Model/GeoDb/SpsModel.cs
+++ b/CampusAppWP8/CampusAppWP8/Model/GeoDb/SpsModel.cs
@@ -47,56 +47,28 @@ namespace CampusAppWP8.Model.GeoDb
#region Method
+ #region public
+
/// Gets places by information.
/// Stubbfel, 19.08.2013.
/// The query.
/// (Optional) the ignore cases.
- /// (Optional) name of the information.
+ /// (Optional) name of the information.
/// The places by information.
- public List GetPlacesByInformation(string query, bool ignoreCases = true, string informationName = null)
+ public List GetPlacesByInformation(string query, bool ignoreCases = true, List informationNames = null)
{
- string querryLow = string.Empty;
- IEnumerable resultplaces = null;
+ string querryStr = string.Empty;
+ List resultplaces = new List();
- // select correct statement
- if (ignoreCases && informationName == null)
+ foreach (PlaceModel place in this.Places)
{
- 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;
+ if (this.IsPlaceQueryMatched(place, query, ignoreCases, informationNames))
+ {
+ resultplaces.Add(place);
+ }
}
- // null assert
- if (resultplaces == null)
- {
- return null;
- }
-
- return resultplaces.ToList();
+ return resultplaces;
}
/// Adds the places.
@@ -209,5 +181,52 @@ namespace CampusAppWP8.Model.GeoDb
}
#endregion
+
+ #region private
+
+ ///
+ /// Method check if a certain place matched by query string
+ ///
+ /// the Place
+ /// the Query
+ /// (Optional) the ignore cases.
+ /// (Optional) name of the information.
+ /// true if it match otherwise false
+ private bool IsPlaceQueryMatched(PlaceModel place, string query, bool ignoreCases = true, List informationNames = null)
+ {
+ string queryString = query;
+ if (ignoreCases)
+ {
+ queryString = query.ToLower();
+ }
+
+ bool allInfos = true;
+ if (informationNames != null && informationNames.Count > 0)
+ {
+ allInfos = false;
+ }
+
+ foreach (PlaceInformation info in place.Informations)
+ {
+ if (allInfos || informationNames.Contains(info.InformationName))
+ {
+ string infoVal = info.InformationValue;
+ if (ignoreCases)
+ {
+ infoVal = infoVal.ToLower();
+ }
+
+ if (infoVal.Contains(queryString))
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ #endregion
+ #endregion
}
}
diff --git a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs
index bbcb0173..87c8ed5e 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs
@@ -29,6 +29,11 @@ namespace CampusAppWP8.Pages.Campusmap
/// Variable for the map model.
private MapModel map;
+ ///
+ /// List of information names
+ ///
+ private List informationsNames;
+
#endregion
#region Constructor
@@ -111,7 +116,15 @@ namespace CampusAppWP8.Pages.Campusmap
/// The found places.
private List SearchPlaces(string query)
{
- return this.map.Spatial.GetPlacesByInformation(query);
+ if (this.informationsNames == null)
+ {
+ this.informationsNames = new List();
+ this.informationsNames.Add(Constants.PisInformationName_Name);
+ this.informationsNames.Add(Constants.PisInformationName_Typ);
+ this.informationsNames.Add(Constants.PisInformationName_ShortName);
+ }
+
+ return this.map.Spatial.GetPlacesByInformation(query, true, this.informationsNames);
}
/// Adds the pins.
diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs
index 9b04fcca..23152345 100644
--- a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs
+++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs
@@ -915,6 +915,24 @@ namespace CampusAppWP8.Resources {
}
}
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die Kurzbeschreibung ähnelt.
+ ///
+ public static string PisInformationName_ShortDesc {
+ get {
+ return ResourceManager.GetString("PisInformationName_ShortDesc", resourceCulture);
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die Kurzname ähnelt.
+ ///
+ public static string PisInformationName_ShortName {
+ get {
+ return ResourceManager.GetString("PisInformationName_ShortName", resourceCulture);
+ }
+ }
+
///
/// Sucht eine lokalisierte Zeichenfolge, die typ ähnelt.
///
diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx
index 20106915..9c2833fb 100644
--- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx
+++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx
@@ -528,4 +528,10 @@
http://141.43.76.140/service/pss
+
+ Kurzbeschreibung
+
+
+ Kurzname
+
\ No newline at end of file