forked from osm-fr/osmose-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Source_FR.py
97 lines (80 loc) · 3.91 KB
/
Source_FR.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#-*- coding: utf-8 -*-
###########################################################################
## ##
## Copyrights Etienne Chové <[email protected]> 2010 ##
## Copyrights Frédéric Rodrigo 2011-2014 ##
## ##
## This program is free software: you can redistribute it and/or modify ##
## it under the terms of the GNU General Public License as published by ##
## the Free Software Foundation, either version 3 of the License, or ##
## (at your option) any later version. ##
## ##
## This program is distributed in the hope that it will be useful, ##
## but WITHOUT ANY WARRANTY; without even the implied warranty of ##
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ##
## GNU General Public License for more details. ##
## ##
## You should have received a copy of the GNU General Public License ##
## along with this program. If not, see <http://www.gnu.org/licenses/>. ##
## ##
###########################################################################
from plugins.Plugin import Plugin
import re
class Source_FR(Plugin):
only_for = ["FR"]
def init(self, logger):
Plugin.init(self, logger)
self.IGN = re.compile(".*(\wign)|(ign\w).*")
def check(self, tags):
if u"AAAA" in tags[u"source"]:
return {"class": 706, "subclass": 0, "text": T_(u"Source tag contains AAAA")}
if u"Cartographes Associés" in tags[u"source"]:
return {"class": 706, "subclass": 1, "text": {"en":u"Cartographes Associés"}}
source = tags[u"source"].lower()
if u"geoportail" in source or u"géoportail" in source:
return {"class": 706, "subclass": 3, "text": {"en":u"Géoportail"}}
if u"camptocamp" in source:
return {"class": 706, "subclass": 5, "text": {"en":u"CampToCamp"}}
def node(self, data, tags):
if u"source" not in tags:
return
return self.check(tags)
def way(self, data, tags, nds):
if u"source" not in tags:
if tags.get(u"boundary", None) == u"administrative":
return {"class": 707, "subclass": 0}
return
return self.check(tags)
def relation(self, data, tags, members):
if u"source" not in tags:
return
return self.check(tags)
###########################################################################
from plugins.Plugin import TestPluginCommon
class Test(TestPluginCommon):
def test(self):
a = Source_FR(None)
a.init(None)
for d in [{u"highway":u"residential"},
{u"source":u"ignoville"},
{u"source":u"BDOrtho IGN"},
{u"source":u"road sign"},
]:
assert not a.node(None, d), d
assert not a.way(None, d, None), d
assert not a.relation(None, d, None), d
for d in [{u"boundary":u"administrative"},
]:
assert not a.node(None, d), d
assert not a.relation(None, d, None), d
for d in [{u"source": u" AAAA "},
{u"source": u"Cartographes Associés"},
{u"source": u"geoportail"},
{u"source": u"camptocamp"},
]:
self.check_err(a.node(None, d), d)
self.check_err(a.way(None, d, None), d)
self.check_err(a.relation(None, d, None), d)
for d in [{u"boundary":u"administrative"},
]:
self.check_err(a.way(None, d, None), d)