diff --git a/IsraelHiking.API/Services/TagsHelper.cs b/IsraelHiking.API/Services/TagsHelper.cs index 00193658f..2bf0c0c02 100644 --- a/IsraelHiking.API/Services/TagsHelper.cs +++ b/IsraelHiking.API/Services/TagsHelper.cs @@ -292,19 +292,20 @@ private Category[] CreateRoutesCategories() /// public (double SearchFactor, IconColorCategory IconColorCategory) GetInfo(IAttributesTable attributesTable) { + var highSearchFactor = _options.SearchFactor * 2; if (attributesTable.GetNames().Any(k => k.Equals("place", StringComparison.OrdinalIgnoreCase))) { var category = attributesTable.GetNames().Any(k => k.StartsWith(FeatureAttributes.WIKIPEDIA)) ? Categories.WIKIPEDIA : Categories.NONE; - return (1, new IconColorCategory("icon-home", category)); + return (highSearchFactor, new IconColorCategory("icon-home", category)); } var iconTags = _categories.SelectMany(c => c.Items) .FirstOrDefault(i => i.Tags .Any(t => attributesTable.Has(t.Key, t.Value))); if (iconTags != null) { - return (1, iconTags.IconColorCategory); + return (highSearchFactor, iconTags.IconColorCategory); } if (attributesTable.Has("landuse", "farmyard") || @@ -312,7 +313,7 @@ private Category[] CreateRoutesCategories() attributesTable.Has("waterway", "river") || attributesTable.Has("waterway", "wadi")) { - return (1, new IconColorCategory()); + return (highSearchFactor, new IconColorCategory()); } if (attributesTable.Has("natural", "peak")) @@ -321,17 +322,17 @@ private Category[] CreateRoutesCategories() n.StartsWith(FeatureAttributes.DESCRIPTION) || n.StartsWith(FeatureAttributes.IMAGE_URL)) ? Categories.NATURAL : Categories.NONE; - return (1, new IconColorCategory("icon-peak", category)); + return (highSearchFactor, new IconColorCategory("icon-peak", category)); } if (attributesTable.GetNames().Any(k => k.StartsWith(FeatureAttributes.WIKIPEDIA))) { - return (1, new IconColorCategory("icon-wikipedia-w", Categories.WIKIPEDIA)); + return (highSearchFactor, new IconColorCategory("icon-wikipedia-w", Categories.WIKIPEDIA)); } if (attributesTable.GetNames().Any(k => k.Contains(FeatureAttributes.MTB_NAME))) { - return (1, new IconColorCategory("icon-bike", Categories.ROUTE_BIKE, "gray", string.Empty)); + return (highSearchFactor, new IconColorCategory("icon-bike", Categories.ROUTE_BIKE, "gray", string.Empty)); } if (attributesTable.GetNames().Any(k => k == "highway")) { @@ -339,7 +340,7 @@ private Category[] CreateRoutesCategories() ? new IconColorCategory("icon-bus-stop") : new IconColorCategory("icon-map-signs"); var importantHighway = attributesTable["highway"].ToString() == "path" || attributesTable["highway"].ToString() == "track"; - return (importantHighway ? 1 : _options.SearchFactor, icon); + return (importantHighway ? highSearchFactor : _options.SearchFactor, icon); } return (_options.SearchFactor, new IconColorCategory()); } diff --git a/IsraelHiking.Common/Configuration/ConfigurationData.cs b/IsraelHiking.Common/Configuration/ConfigurationData.cs index 1e9c5128e..7f90a05d2 100644 --- a/IsraelHiking.Common/Configuration/ConfigurationData.cs +++ b/IsraelHiking.Common/Configuration/ConfigurationData.cs @@ -159,7 +159,7 @@ public ConfigurationData() MaxNumberOfPointsPerLine = 1000; MaxLengthPerLine = 3000; RadialSimplificationAngle = 90; - SearchFactor = 0.5; + SearchFactor = 1; MergePointsOfInterestThreshold = 0.001; // around 100m MergeExternalPointsOfInterestThreshold = 1 / 60.0; // 1 minute ClosestPointsOfInterestThreshold = 0.001; // around 100m diff --git a/Tests/IsraelHiking.API.Tests/Services/TagsHelperTests.cs b/Tests/IsraelHiking.API.Tests/Services/TagsHelperTests.cs index 084ad3cfd..4bb6287f8 100644 --- a/Tests/IsraelHiking.API.Tests/Services/TagsHelperTests.cs +++ b/Tests/IsraelHiking.API.Tests/Services/TagsHelperTests.cs @@ -31,7 +31,7 @@ public void RegularPlace_ShouldReturnHomeIconNoneCategory() {"place", "place"} }); - Assert.AreEqual(1, factor); + Assert.AreEqual(2, factor); Assert.AreEqual("icon-home", iconColorCategory.Icon); Assert.AreEqual(Categories.NONE, iconColorCategory.Category); } @@ -45,7 +45,7 @@ public void PlaceWithWikipediaTag_ShouldReturnHomeIconWikipediaCategory() {"wikipedia", "wiki title" } }); - Assert.AreEqual(1, factor); + Assert.AreEqual(2, factor); Assert.AreEqual("icon-home", iconColorCategory.Icon); Assert.AreEqual(Categories.WIKIPEDIA, iconColorCategory.Category); } @@ -59,7 +59,7 @@ public void Spring_ShouldReturnTintIconWaterCategory() {"wikipedia", "wiki title" } }); - Assert.AreEqual(1, factor); + Assert.AreEqual(2, factor); Assert.AreEqual("icon-tint", iconColorCategory.Icon); Assert.AreEqual(Categories.WATER, iconColorCategory.Category); } @@ -72,7 +72,7 @@ public void WikipediaOnly_ShouldReturnWikipediaIconWikipediaCategory() {"wikipedia", "wiki title" } }); - Assert.AreEqual(1, factor); + Assert.AreEqual(2, factor); Assert.AreEqual("icon-wikipedia-w", iconColorCategory.Icon); Assert.AreEqual(Categories.WIKIPEDIA, iconColorCategory.Category); } @@ -121,7 +121,7 @@ public void AWayWithMtbName_ShouldReturnBikeIconWithFactorOne() {FeatureAttributes.MTB_NAME, "some-name"} }); - Assert.AreEqual(1, factor); + Assert.AreEqual(2, factor); Assert.AreEqual("icon-bike", iconColorCategory.Icon); Assert.AreEqual(Categories.ROUTE_BIKE, iconColorCategory.Category); } @@ -134,7 +134,7 @@ public void River_ShouldReturnHighFactor() {"waterway", "river"} }); - Assert.AreEqual(1, factor); + Assert.AreEqual(2, factor); Assert.AreEqual(Categories.NONE, iconColorCategory.Category); } @@ -146,7 +146,7 @@ public void Stream_ShouldReturnHighFactor() {"waterway", "stream"} }); - Assert.AreEqual(1, factor); + Assert.AreEqual(2, factor); Assert.AreEqual(Categories.NONE, iconColorCategory.Category); } @@ -158,7 +158,7 @@ public void Wadi_ShouldReturnHighFactor() {"waterway", "wadi"} }); - Assert.AreEqual(1, factor); + Assert.AreEqual(2, factor); Assert.AreEqual(Categories.NONE, iconColorCategory.Category); } @@ -170,7 +170,7 @@ public void Farm_ShouldReturnHighFactor() {"landuse", "farmyard"} }); - Assert.AreEqual(1, factor); + Assert.AreEqual(2, factor); Assert.AreEqual(Categories.NONE, iconColorCategory.Category); } @@ -182,7 +182,7 @@ public void Peak_WithNoDescription_ShouldReturnNoneCategory() {"natural", "peak"}, }); - Assert.AreEqual(1, factor); + Assert.AreEqual(2, factor); Assert.AreEqual(Categories.NONE, iconColorCategory.Category); } @@ -195,7 +195,7 @@ public void Peak_WithDescription_ShouldReturnNaturalCategory() {FeatureAttributes.DESCRIPTION, "desc"} }); - Assert.AreEqual(1, factor); + Assert.AreEqual(2, factor); Assert.AreEqual(Categories.NATURAL, iconColorCategory.Category); } @@ -208,7 +208,7 @@ public void Peak_WithImage_ShouldReturnNaturalCategory() {FeatureAttributes.IMAGE_URL, "image_url"} }); - Assert.AreEqual(1, factor); + Assert.AreEqual(2, factor); Assert.AreEqual(Categories.NATURAL, iconColorCategory.Category); } } diff --git a/Tests/IsraelHiking.DataAccess.Tests/ElasticSearch/ElasticSearchGatewayTests.cs b/Tests/IsraelHiking.DataAccess.Tests/ElasticSearch/ElasticSearchGatewayTests.cs index 79aedf96f..bde8f8a45 100644 --- a/Tests/IsraelHiking.DataAccess.Tests/ElasticSearch/ElasticSearchGatewayTests.cs +++ b/Tests/IsraelHiking.DataAccess.Tests/ElasticSearch/ElasticSearchGatewayTests.cs @@ -48,6 +48,15 @@ public void SearchWithinPlace_ShouldReturnResults() Assert.AreEqual(1, results.Count); } + [TestMethod] + [Ignore] + public void SearchWithinPlace_WithLowFactor_ShouldReturnResults() + { + var results = _gateway.SearchByLocation( + new Coordinate(35.023903300000001, 32.248676099999997), new Coordinate(34.836766599999997, 32.003519799999999), "הסיבים", Languages.HEBREW).Result; + Assert.IsTrue(results.Any(f => f.Attributes.GetNames().Contains(FeatureAttributes.NAME) && f.Attributes[FeatureAttributes.NAME].ToString() == "הסיבים")); + } + [TestMethod] [Ignore] public void GetHighways_ShouldReturnResults()