Skip to content

Commit

Permalink
Fixes #2019 - Can't find הסיבים street in פתח תקווה
Browse files Browse the repository at this point in the history
  • Loading branch information
HarelM committed Nov 14, 2024
1 parent 8a41fd0 commit e51c162
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
15 changes: 8 additions & 7 deletions IsraelHiking.API/Services/TagsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,27 +292,28 @@ private Category[] CreateRoutesCategories()
///<inheritdoc/>
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") ||
attributesTable.Has("waterway", "stream") ||
attributesTable.Has("waterway", "river") ||
attributesTable.Has("waterway", "wadi"))
{
return (1, new IconColorCategory());
return (highSearchFactor, new IconColorCategory());
}

if (attributesTable.Has("natural", "peak"))
Expand All @@ -321,25 +322,25 @@ 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"))
{
var icon = attributesTable["highway"].ToString() == "bus_stop"
? 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());
}
Expand Down
2 changes: 1 addition & 1 deletion IsraelHiking.Common/Configuration/ConfigurationData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions Tests/IsraelHiking.API.Tests/Services/TagsHelperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -134,7 +134,7 @@ public void River_ShouldReturnHighFactor()
{"waterway", "river"}
});

Assert.AreEqual(1, factor);
Assert.AreEqual(2, factor);
Assert.AreEqual(Categories.NONE, iconColorCategory.Category);
}

Expand All @@ -146,7 +146,7 @@ public void Stream_ShouldReturnHighFactor()
{"waterway", "stream"}
});

Assert.AreEqual(1, factor);
Assert.AreEqual(2, factor);
Assert.AreEqual(Categories.NONE, iconColorCategory.Category);
}

Expand All @@ -158,7 +158,7 @@ public void Wadi_ShouldReturnHighFactor()
{"waterway", "wadi"}
});

Assert.AreEqual(1, factor);
Assert.AreEqual(2, factor);
Assert.AreEqual(Categories.NONE, iconColorCategory.Category);
}

Expand All @@ -170,7 +170,7 @@ public void Farm_ShouldReturnHighFactor()
{"landuse", "farmyard"}
});

Assert.AreEqual(1, factor);
Assert.AreEqual(2, factor);
Assert.AreEqual(Categories.NONE, iconColorCategory.Category);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit e51c162

Please sign in to comment.