forked from osm-fr/osmose-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyser_merge_geodesie.py
122 lines (114 loc) · 6.2 KB
/
analyser_merge_geodesie.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env python
#-*- coding: utf-8 -*-
###########################################################################
## ##
## Copyrights Frédéric Rodrigo 2012 ##
## ##
## 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 modules.OsmoseTranslation import T_
from .Analyser_Merge import Analyser_Merge_Point, Source, CSV, Load_XY, Conflate, Select, Mapping
doc = dict(
detail = T_(
'''[WikiProject_France/Repères_Géodésiques](https://wiki.openstreetmap.org/wiki/WikiProject_France/Rep%C3%A8res_G%C3%A9od%C3%A9siques)
French survey point imported in OSM but not found.'''),
fix = T_(
'''Restore node or relation.'''),
trap = T_(
'''Offered fix reimport the missing sites as point, but if was a
relation. Must be converted manually, keep the tags and put survey points
in relation.'''))
class Analyser_Merge_Geodesie(Analyser_Merge_Point):
def __init__(self, config, logger = None):
Analyser_Merge_Point.__init__(self, config, logger)
self.def_class_missing_official(item = 8070, id = 1, level = 3, tags = ['merge', 'infrastructure', 'fix:survey', 'fix:picture'],
title = T_('Missing survey point'),
**doc)
self.def_class_moved_official(item = 8070, id = 3, level = 3, tags = ['merge', 'infrastructure', 'fix:survey', 'fix:picture'],
title = T_('Moved survey point'),
**doc)
self.init(
u"http://geodesie.ign.fr",
u"Fiches géodésiques",
CSV(Source(attribution = "©IGN {0} dans le cadre de la cartographie réglementaire", millesime = "2010",
file = "geodesie.csv.bz2", bz2 = True),
header = False),
Load_XY("lon", "lat",
where = lambda res: not (u'Point constaté détruit' in res[u'description'] or u'Point non retrouvé' in res[u'description']), # No more unique ref
create = """
id VARCHAR(254) PRIMARY KEY,
lat VARCHAR(254),
lon VARCHAR(254),
description VARCHAR(4096),
ele VARCHAR(254),
ref VARCHAR(254)"""),
Conflate(
select = Select(
types = ["nodes"],
tags = {"man_made": "survey_point"}),
osmRef = "ref",
extraJoin = "description",
mapping = Mapping(
static1 = {
"man_made": "survey_point"},
static2 = {
"note": u"Ne pas déplacer ce point, cf. - Do not move this node, see - http://wiki.openstreetmap.org/wiki/WikiProject_France/Repères_Géodésiques#Permanence_des_rep.C3.A8res",
"source": self.source},
mapping1 = {
"ref": "ref",
"ele": "ele"},
mapping2 = {
"description": "description"},
text = lambda tags, fields: {"en": "Survey point {0}".format(tags["ref"]), "fr": "Repères géodésiques {0}".format(tags["ref"]), "es": "Señales geodésicas {0}".format(tags["ref"])} )))
class Analyser_Merge_Geodesie_Site(Analyser_Merge_Point):
def __init__(self, config, logger = None):
Analyser_Merge_Point.__init__(self, config, logger)
self.def_class_missing_official(item = 8070, id = 2, level = 3, tags = ['merge'],
title = T_('Missing survey site'),
**doc)
self.init(
u"http://geodesie.ign.fr",
u"Fiches géodésiques-site",
CSV(Source(attribution = "©IGN {0} dans le cadre de la cartographie réglementaire", millesime = "2010",
file = "geodesie_site.csv.bz2", bz2 = True),
header = False),
Load_XY("lon", "lat",
create = """
id VARCHAR(254) PRIMARY KEY,
ref VARCHAR(254),
name VARCHAR(254),
note VARCHAR(254),
network VARCHAR(254),
source VARCHAR(254),
lat VARCHAR(254),
lon VARCHAR(254)"""),
Conflate(
select = Select(
types = ["relations"],
tags = {
"type": "site",
"site": "geodesic"}),
osmRef = "ref",
mapping = Mapping(
static1 = {
"type": "site",
"site": "geodesic"},
static2 = {"source": self.source},
mapping1 = {
"ref": "ref",
"name": "name",
"network": "network"},
mapping2 = {"note": "note"},
text = lambda tags, fields: {"en": "Survey site {0} - {1}".format(fields["ref"], fields["name"]), "fr": "Site géodésique {0} - {1}".format(fields["ref"], fields["name"]), "es": "Sitio geodésico {0} - {1}".format(fields["ref"], fields["name"])} )))