Ignore:
Timestamp:
2009-12-02T17:03:12+01:00 (15 years ago)
Author:
rcernoch
Message:

CzechAddress: Address database supports new format from MVCR

Location:
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/StringUtils.java

    r16417 r18894  
    111111    }
    112112
     113    public static String tryTrim(String s) {
     114        if (s == null) return null;
     115        return s.trim();
     116    }
     117
    113118    /**
    114119     * Capitalizes the given string (first letter of every word upper-case,
  • applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/parser/MvcrParser.java

    r15763 r18894  
    22
    33import static org.openstreetmap.josm.plugins.czechaddress.StringUtils.capitalize;
     4import static org.openstreetmap.josm.plugins.czechaddress.StringUtils.tryTrim;
    45
    56import java.io.FileInputStream;
     
    4344        if (name.equals("a")) {
    4445
    45             String cp = attributes.getValue("p");
    46             String co = attributes.getValue("o");
     46            String cp = tryTrim(attributes.getValue("p"));
     47            String co = tryTrim(attributes.getValue("o"));
    4748            if ((cp == null) && (co == null))
    4849                return;
     
    5960        // ========== PARSING STREET ========== //
    6061        if (name.equals("ulice")) {
    61             String nazev = attributes.getValue("nazev");
     62            String nazev = tryTrim(attributes.getValue("nazev"));
    6263
    6364            // If the street filter is on, apply it!
     
    8586                return;
    8687
    87             String nazev = attributes.getValue("nazev");
     88            String nazev = tryTrim(attributes.getValue("nazev"));
    8889
    8990            // If the suburb filter is on, apply it!
     
    106107        if (name.equals("obec")) {
    107108
    108             String nazev = attributes.getValue("nazev");
     109            String nazev = tryTrim(attributes.getValue("nazev"));
    109110
    110111            // If the viToCi filter is on, apply it!
     
    129130
    130131            // If the region filter is on, apply it!
    131             if (filRegion != null && !attributes.getValue("nazev").equals(filRegion)) {
     132            if (filRegion != null &&
     133                    !attributes.getValue("nazev").trim().equals(filRegion)) {
    132134                curRegion = null;
    133135                curViToCi = null;
     
    144146            if (curRegion == null) {*/
    145147                curRegion = new Region(
    146                     capitalize(attributes.getValue("nazev")),
    147                     capitalize(attributes.getValue("kraj")),
    148                     capitalize(attributes.getValue("okres")));
     148                    capitalize(tryTrim(attributes.getValue("nazev"))),
     149                    capitalize(tryTrim(attributes.getValue("kraj"))),
     150                    capitalize(tryTrim(attributes.getValue("okres"))));
    149151
    150152                target.regions.add(curRegion);
Note: See TracChangeset for help on using the changeset viewer.