From 342c5d0fd4cfad7dd6da8c2f4f0bda103d76b188 Mon Sep 17 00:00:00 2001 From: orbiter Date: Sun, 6 Sep 2009 20:44:02 +0000 Subject: [PATCH] fixed city name detection: finds now also substrings of city names git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6300 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/data/OpenGeoDB.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/de/anomic/data/OpenGeoDB.java b/source/de/anomic/data/OpenGeoDB.java index 42c896bbf..4405badda 100644 --- a/source/de/anomic/data/OpenGeoDB.java +++ b/source/de/anomic/data/OpenGeoDB.java @@ -38,9 +38,9 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.Set; import java.util.SortedMap; -import java.util.SortedSet; import java.util.TreeMap; import java.util.zip.GZIPInputStream; @@ -170,8 +170,11 @@ public class OpenGeoDB { */ public HashSet find(String anyname) { HashSet r = new HashSet(); - List c; - c = this.locationName2ids.get(anyname); if (c != null) r.addAll(c); + SortedMap> cities = this.locationName2ids.tailMap(anyname); + for (Map.Entry> e: cities.entrySet()) { + if (e.getKey().toLowerCase().startsWith(anyname.toLowerCase())) r.addAll(e.getValue()); else break; + } + List c; c = this.kfz2ids.get(anyname); if (c != null) r.addAll(c); c = this.predial2ids.get(anyname); if (c != null) r.addAll(c); Integer i = this.zip2id.get(anyname); if (i != null) r.add(i);