[Schmitzm-commits] r2194 - in trunk/schmitzm-adresses/src: main/java/de/schmitzm/adresses test/java/de/schmitzm/adresses

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Wed Jan 23 20:47:41 CET 2013


Author: alfonx
Date: 2013-01-23 20:47:40 +0100 (Wed, 23 Jan 2013)
New Revision: 2194

Modified:
   trunk/schmitzm-adresses/src/main/java/de/schmitzm/adresses/AddrStringUtil.java
   trunk/schmitzm-adresses/src/test/java/de/schmitzm/adresses/AddrStringUtilTest.java
Log:
addrstrUtil

Modified: trunk/schmitzm-adresses/src/main/java/de/schmitzm/adresses/AddrStringUtil.java
===================================================================
--- trunk/schmitzm-adresses/src/main/java/de/schmitzm/adresses/AddrStringUtil.java	2013-01-23 19:11:05 UTC (rev 2193)
+++ trunk/schmitzm-adresses/src/main/java/de/schmitzm/adresses/AddrStringUtil.java	2013-01-23 19:47:40 UTC (rev 2194)
@@ -185,6 +185,27 @@
 	 */
 	public static String[] split(final String... stringStrHnZusatz) {
 
+		String[] s = splitInternal1(stringStrHnZusatz);
+
+		if (s[0] != null) {
+			RegexCache rC = RegexCache.getInstance();
+			Matcher matcher = rC.getMatcher("^(.*?)\\s*+(\\d+\\.\\s*reihe)\\s*+(.*?)$", s[0]);
+			if (matcher.find()) {
+				s[0] = matcher.group(1);
+				if (matcher.group(3).length() > 0)
+					s[0] += " " + matcher.group(3);
+				if (s[2] == null)
+					s[2] = "";
+				if (s[2].length() > 0)
+					s[2] += " ";
+				s[2] += matcher.group(2);
+			}
+		}
+
+		return s;
+	}
+
+	private static String[] splitInternal1(final String... stringStrHnZusatz) {
 		boolean warn = false;
 
 		if (stringStrHnZusatz.length < 1 || stringStrHnZusatz.length > 3)
@@ -229,6 +250,8 @@
 
 		zusammen = removeSpacesBetweenHiphenAndDotAndLetters(zusammen);
 
+		// Angaben wie "2.Reihe" oder "3.OG" direkt ausschneiden und in Zusatz packen
+
 		Matcher m = REGEX_splitFullString.matcher(zusammen);
 		final boolean found = m.find();
 
@@ -653,6 +676,9 @@
 	static public String saeubereStrassenname(final String orginal) {
 		String strasse = LangUtil.removeTags(orginal).toLowerCase();
 
+		// Forststr. , 3
+		strasse = RegexCache.getInstance().replaceAll(strasse, "(\\D\\D\\D)\\s*[,](\\s*\\d+\\D*)$", "$1 $2");
+
 		strasse = RegexCache.getInstance().replaceAll(strasse, "(\\s+/[^\\d]++)$", "");
 
 		strasse = RegexCache.getInstance().replaceAll(strasse, "\\s*\\(.*?\\)\\s*", "");

Modified: trunk/schmitzm-adresses/src/test/java/de/schmitzm/adresses/AddrStringUtilTest.java
===================================================================
--- trunk/schmitzm-adresses/src/test/java/de/schmitzm/adresses/AddrStringUtilTest.java	2013-01-23 19:11:05 UTC (rev 2193)
+++ trunk/schmitzm-adresses/src/test/java/de/schmitzm/adresses/AddrStringUtilTest.java	2013-01-23 19:47:40 UTC (rev 2194)
@@ -118,6 +118,8 @@
 		// checkSplit("Kocherstrasse", "Kocherstrasse 15 1", "15", null, "1", null);
 
 		// checkSplit("Kosselstr.2 u 4", "Kosselstr.","2 u 4", null);
+		checkSplit("Kollau Str. 2.reihe 90a", "Kollau Str.", "90","a 2.reihe");
+		
 		checkSplit("Seminar Str. 8", "Seminar Str.", "8", null);
 		checkSplit("Seminar Str., 8", "Seminar Str.", "8", null);
 		
@@ -447,6 +449,10 @@
 
 	@Test
 	public void testSaeubereStrassenname() {
+		assertEquals("Forststr. 13", AddrStringUtil.saeubereStrassenname("Forststr. , 13"));
+		
+		assertEquals("Lloydstr. 13", AddrStringUtil.saeubereStrassenname("Lloydstr., 13"));
+		
 		assertEquals("Autobahn A6 Am Autohof", AddrStringUtil.saeubereStrassenname("Autobahn A 6AmAutohof"));
 
 		assertEquals("Str. des 18. Oktober 2", AddrStringUtil.saeubereStrassenname("Str. des 18. Oktober 2"));
@@ -484,7 +490,6 @@
 		assertEquals("Franz-Mehring-Str.", AddrStringUtil.saeubereStrassenname("Franz- Mehring- Straße"));
 		assertEquals("Auf dem Glockenberg 30", AddrStringUtil.saeubereStrassenname("Auf Dem Glockenberg 30"));
 
-		assertEquals("Lloydstr. 13", AddrStringUtil.saeubereStrassenname("Lloydstr., 13"));
 	}
 
 }



More information about the Schmitzm-commits mailing list