Changeset f696037 in osmose-backend


Ignore:
Timestamp:
May 18, 2014 11:07:25 PM (5 years ago)
Author:
Jocelyn Jaubert <jocelyn.jaubert@…>
Branches:
master
Children:
248308a
Parents:
6437605
git-author:
Jocelyn Jaubert <jocelyn.jaubert@…> (18/05/2014 23:03:59)
git-committer:
Jocelyn Jaubert <jocelyn.jaubert@…> (18/05/2014 23:07:25)
Message:

Add support for postal code without space

Postcodes in Netherlands are using NNNNAA format instead of NNNN AA format as
listed on wikipedia.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/TagFix_Postcode.py

    r27d4d8a rf696037  
    4848                    regex = f.replace("N", "[0-9]").replace("A", "[A-Z]").replace("CC", self.Country) 
    4949                    regexs.append(regex) 
     50                    regexs.append(regex.replace(" ","")) 
    5051 
    5152            if len(regexs) > 1: 
    52                 postcode[iso] = "^\("+("\)|\(".join(regexs))+"\)$" 
     53                postcode[iso] = "^("+(")|(".join(regexs))+")$" 
    5354            elif len(regexs) == 1: 
    5455                postcode[iso] = "^"+regexs[0]+"$" 
     
    9293 
    9394class Test(TestPluginCommon): 
    94     def test(self): 
     95    def test_FR(self): 
    9596        a = TagFix_Postcode(None) 
    9697        class _config: 
     
    102103        self.check_err(a.node(None, {"addr:postcode":"la bas"})) 
    103104        assert not a.node(None, {"addr:postcode":"75000"}) 
     105        assert a.node(None, {"addr:postcode":"75 000"}) 
    104106 
    105107    def test_no_country(self): 
     
    113115        assert not a.node(None, {"addr:postcode":"la bas"}) 
    114116        assert not a.node(None, {"addr:postcode":"75000"}) 
     117 
     118    def test_NL(self): 
     119        a = TagFix_Postcode(None) 
     120        class _config: 
     121            options = {"country": "NL"} 
     122        class father: 
     123            config = _config() 
     124        a.father = father() 
     125        a.init(None) 
     126        self.check_err(a.node(None, {"addr:postcode":"la bas"})) 
     127        assert not a.node(None, {"addr:postcode":"1234 AB"}) 
     128        assert not a.node(None, {"addr:postcode":"1234AB"}) 
     129        assert a.node(None, {"addr:postcode":"12 34AB"}) 
     130        assert a.node(None, {"addr:postcode":"12241AB"}) 
Note: See TracChangeset for help on using the changeset viewer.