[Schmitzm-commits] r2062 - 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 Jun 27 22:58:57 CEST 2012
Author: alfonx
Date: 2012-06-27 22:58:57 +0200 (Wed, 27 Jun 2012)
New Revision: 2062
Modified:
trunk/schmitzm-adresses/src/main/java/de/schmitzm/adresses/AddrStringUtil.java
trunk/schmitzm-adresses/src/test/java/de/schmitzm/adresses/AddrStringUtilTest.java
Log:
Modified: trunk/schmitzm-adresses/src/main/java/de/schmitzm/adresses/AddrStringUtil.java
===================================================================
--- trunk/schmitzm-adresses/src/main/java/de/schmitzm/adresses/AddrStringUtil.java 2012-06-27 20:31:26 UTC (rev 2061)
+++ trunk/schmitzm-adresses/src/main/java/de/schmitzm/adresses/AddrStringUtil.java 2012-06-27 20:58:57 UTC (rev 2062)
@@ -63,7 +63,7 @@
Matcher matcher = RegexCache.getInstance().getMatcher("^(\\d+)\\D+\\1", hn);
if (matcher.find())
hn = matcher.group(1);
-
+
hn = RegexCache.getInstance().replaceAll(hn, "^0+", "");
hn = RegexCache.getInstance().replaceAll(hn, "\\s", "");
hn = RegexCache.getInstance().replaceAll(hn, "bis", "-");
@@ -72,6 +72,29 @@
}
/**
+ * Verionfacht die Schreibweise einer Hausnummer, z.B. "3-4" -> "4", so dass nur noch eine Integer-Zahl (die
+ * niedrigste angegebene) da steht.
+ */
+ public static final Integer simplyfyHn(String hn) {
+
+ if (hn == null)
+ return null;
+
+ Integer smallestHn = null;
+
+ Matcher m = RegexCache.getInstance().getMatcher("(\\d+)", hn);
+
+ while (m.find()) {
+ Integer h = Integer.valueOf(m.group(1));
+
+ if (smallestHn == null || h < smallestHn)
+ smallestHn = h;
+ }
+
+ return smallestHn;
+ }
+
+ /**
* Normalisiert die Schreibweise eines Hn-Zusatzes, z.B. " A " -> "a"
*/
public static final NormResult normalizeZusatz(final String zusatz) {
@@ -587,7 +610,7 @@
strasse = RegexCache.getInstance().replaceAll(strasse, "plz/ort", " ");
strasse = RegexCache.getInstance().replaceAll(strasse, "egli", " ");
strasse = RegexCache.getInstance().replaceAll(strasse, "\\*ort", " ");
-
+
strasse = RegexCache.getInstance().replaceAll(strasse, "\\+", " ");
strasse = RegexCache.getInstance().replaceAll(strasse, "\\s\\s+", " ");
strasse = RegexCache.getInstance().replaceAll(strasse, "(\\d)\\s", "$1");
@@ -600,9 +623,10 @@
strasse = RegexCache.getInstance().replaceAll(strasse, "str$", "str.");
strasse = RegexCache.getInstance().replaceAll(strasse, "^Str\\.$", "");
-
- strasse = RegexCache.getInstance().replaceFirst(strasse, "([\\d\\s])(?:(?i)eg|og|vh|hh)\\s*(?:(?i)li|re|links|rechts)$", "$1");
+ strasse = RegexCache.getInstance().replaceFirst(strasse,
+ "([\\d\\s])(?:(?i)eg|og|vh|hh)\\s*(?:(?i)li|re|links|rechts)$", "$1");
+
{
// Großschreibung aller Anfangsbuchstaben, AUSSER in den Hausnummerzusätzen
Modified: trunk/schmitzm-adresses/src/test/java/de/schmitzm/adresses/AddrStringUtilTest.java
===================================================================
--- trunk/schmitzm-adresses/src/test/java/de/schmitzm/adresses/AddrStringUtilTest.java 2012-06-27 20:31:26 UTC (rev 2061)
+++ trunk/schmitzm-adresses/src/test/java/de/schmitzm/adresses/AddrStringUtilTest.java 2012-06-27 20:58:57 UTC (rev 2062)
@@ -344,6 +344,14 @@
}
@Test
+ public void testSimplyfyHn() {
+ assertEquals(1, AddrStringUtil.simplyfyHn("001"),0);
+ assertEquals(32, AddrStringUtil.simplyfyHn("32-34"),0);
+ assertEquals(32, AddrStringUtil.simplyfyHn("34-32"),0);
+ assertEquals(12, AddrStringUtil.simplyfyHn("12/24"),0);
+ assertEquals(1, AddrStringUtil.simplyfyHn("12 bis 24/1"),0);
+ }
+ @Test
public void testNormalizeHn() {
assertEquals("1", AddrStringUtil.normalizeHn(" 001"));
assertEquals("1", AddrStringUtil.normalizeHn("001"));
More information about the Schmitzm-commits
mailing list