Passed
Pull Request — dev (#82)
by Stephan
01:10
created

data.orm.openstreetmap   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 419
Duplicated Lines 63.72 %

Importance

Changes 0
Metric Value
wmc 0
eloc 381
dl 267
loc 419
rs 10
c 0
b 0
f 0

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
from geoalchemy2.types import Geometry
2
from sqlalchemy import (
3
    ARRAY,
4
    BigInteger,
5
    Column,
6
    Float,
7
    Integer,
8
    SmallInteger,
9
    Text,
10
    text,
11
)
12
from sqlalchemy.dialects.postgresql import HSTORE
13
from sqlalchemy.ext.declarative import declarative_base
14
15
Base = declarative_base()
16
metadata = Base.metadata
17
18
19 View Code Duplication
class OsmLine(Base):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
20
    __tablename__ = "osm_line"
21
    __table_args__ = {
22
        "schema": "openstreetmap",
23
    }
24
25
    osm_id = Column(BigInteger)
26
    access = Column(Text)
27
    addr_housename = Column("addr:housename", Text)
28
    addr_housenumber = Column("addr:housenumber", Text)
29
    addr_interpolation = Column("addr:interpolation", Text)
30
    admin_level = Column(Text)
31
    aerialway = Column(Text)
32
    aeroway = Column(Text)
33
    amenity = Column(Text)
34
    area = Column(Text)
35
    barrier = Column(Text)
36
    bicycle = Column(Text)
37
    brand = Column(Text)
38
    bridge = Column(Text)
39
    boundary = Column(Text)
40
    building = Column(Text)
41
    construction = Column(Text)
42
    covered = Column(Text)
43
    culvert = Column(Text)
44
    cutting = Column(Text)
45
    denomination = Column(Text)
46
    disused = Column(Text)
47
    embankment = Column(Text)
48
    foot = Column(Text)
49
    generator_source = Column("generator:source", Text)
50
    harbour = Column(Text)
51
    highway = Column(Text)
52
    historic = Column(Text)
53
    horse = Column(Text)
54
    intermittent = Column(Text)
55
    junction = Column(Text)
56
    landuse = Column(Text)
57
    layer = Column(Text)
58
    leisure = Column(Text)
59
    line = Column(Text)
60
    lock = Column(Text)
61
    man_made = Column(Text)
62
    military = Column(Text)
63
    motorcar = Column(Text)
64
    name = Column(Text)
65
    natural = Column(Text)
66
    office = Column(Text)
67
    oneway = Column(Text)
68
    operator = Column(Text)
69
    place = Column(Text)
70
    population = Column(Text)
71
    power = Column(Text)
72
    power_source = Column(Text)
73
    public_transport = Column(Text)
74
    railway = Column(Text)
75
    ref = Column(Text)
76
    religion = Column(Text)
77
    route = Column(Text)
78
    service = Column(Text)
79
    sidewalk = Column(Text)
80
    shop = Column(Text)
81
    sport = Column(Text)
82
    surface = Column(Text)
83
    toll = Column(Text)
84
    tourism = Column(Text)
85
    tower_type = Column("tower:type", Text)
86
    tracktype = Column(Text)
87
    tunnel = Column(Text)
88
    water = Column(Text)
89
    waterway = Column(Text)
90
    wetland = Column(Text)
91
    width = Column(Text)
92
    wood = Column(Text)
93
    z_order = Column(Integer)
94
    way_area = Column(Float)
95
    abandoned_aeroway = Column("abandoned:aeroway", Text)
96
    abandoned_amenity = Column("abandoned:amenity", Text)
97
    abandoned_building = Column("abandoned:building", Text)
98
    abandoned_landuse = Column("abandoned:landuse", Text)
99
    abandoned_power = Column("abandoned:power", Text)
100
    area_highway = Column("area:highway", Text)
101
    tags = Column(HSTORE(Text()), index=True)
102
    geom = Column(Geometry("LINESTRING", 3857), index=True)
103
    gid = Column(
104
        Integer,
105
        primary_key=True,
106
        server_default=text(
107
            "nextval('openstreetmap.osm_line_gid_seq'::regclass)"
108
        ),
109
    )
110
111
112
class OsmNode(Base):
113
    __tablename__ = "osm_nodes"
114
    __table_args__ = {
115
        "schema": "openstreetmap",
116
    }
117
118
    id = Column(BigInteger, primary_key=True)
119
    lat = Column(Integer, nullable=False)
120
    lon = Column(Integer, nullable=False)
121
122
123
class OsmPoint(Base):
124
    __tablename__ = "osm_point"
125
    __table_args__ = {
126
        "schema": "openstreetmap",
127
    }
128
129
    osm_id = Column(BigInteger)
130
    access = Column(Text)
131
    addr_housename = Column("addr:housename", Text)
132
    addr_housenumber = Column("addr:housenumber", Text)
133
    addr_interpolation = Column("addr:interpolation", Text)
134
    admin_level = Column(Text)
135
    aerialway = Column(Text)
136
    aeroway = Column(Text)
137
    amenity = Column(Text)
138
    area = Column(Text)
139
    barrier = Column(Text)
140
    bicycle = Column(Text)
141
    brand = Column(Text)
142
    bridge = Column(Text)
143
    boundary = Column(Text)
144
    building = Column(Text)
145
    capital = Column(Text)
146
    construction = Column(Text)
147
    covered = Column(Text)
148
    culvert = Column(Text)
149
    cutting = Column(Text)
150
    denomination = Column(Text)
151
    disused = Column(Text)
152
    ele = Column(Text)
153
    embankment = Column(Text)
154
    foot = Column(Text)
155
    generator_source = Column("generator:source", Text)
156
    harbour = Column(Text)
157
    highway = Column(Text)
158
    historic = Column(Text)
159
    horse = Column(Text)
160
    intermittent = Column(Text)
161
    junction = Column(Text)
162
    landuse = Column(Text)
163
    layer = Column(Text)
164
    leisure = Column(Text)
165
    line = Column(Text)
166
    lock = Column(Text)
167
    man_made = Column(Text)
168
    military = Column(Text)
169
    motorcar = Column(Text)
170
    name = Column(Text)
171
    natural = Column(Text)
172
    office = Column(Text)
173
    oneway = Column(Text)
174
    operator = Column(Text)
175
    place = Column(Text)
176
    population = Column(Text)
177
    power = Column(Text)
178
    power_source = Column(Text)
179
    public_transport = Column(Text)
180
    railway = Column(Text)
181
    ref = Column(Text)
182
    religion = Column(Text)
183
    route = Column(Text)
184
    service = Column(Text)
185
    sidewalk = Column(Text)
186
    shop = Column(Text)
187
    sport = Column(Text)
188
    surface = Column(Text)
189
    toll = Column(Text)
190
    tourism = Column(Text)
191
    tower_type = Column("tower:type", Text)
192
    tunnel = Column(Text)
193
    water = Column(Text)
194
    waterway = Column(Text)
195
    wetland = Column(Text)
196
    width = Column(Text)
197
    wood = Column(Text)
198
    z_order = Column(Integer)
199
    tags = Column(HSTORE(Text()), index=True)
200
    geom = Column(Geometry("POINT", 3857), index=True)
201
    gid = Column(
202
        Integer,
203
        primary_key=True,
204
        server_default=text(
205
            "nextval('openstreetmap.osm_point_gid_seq'::regclass)"
206
        ),
207
    )
208
209
210 View Code Duplication
class OsmPolygon(Base):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
211
    __tablename__ = "osm_polygon"
212
    __table_args__ = {
213
        "schema": "openstreetmap",
214
    }
215
216
    osm_id = Column(BigInteger)
217
    access = Column(Text)
218
    addr_housename = Column("addr:housename", Text)
219
    addr_housenumber = Column("addr:housenumber", Text)
220
    addr_interpolation = Column("addr:interpolation", Text)
221
    admin_level = Column(Text)
222
    aerialway = Column(Text)
223
    aeroway = Column(Text)
224
    amenity = Column(Text)
225
    area = Column(Text)
226
    barrier = Column(Text)
227
    bicycle = Column(Text)
228
    brand = Column(Text)
229
    bridge = Column(Text)
230
    boundary = Column(Text)
231
    building = Column(Text)
232
    construction = Column(Text)
233
    covered = Column(Text)
234
    culvert = Column(Text)
235
    cutting = Column(Text)
236
    denomination = Column(Text)
237
    disused = Column(Text)
238
    embankment = Column(Text)
239
    foot = Column(Text)
240
    generator_source = Column("generator:source", Text)
241
    harbour = Column(Text)
242
    highway = Column(Text)
243
    historic = Column(Text)
244
    horse = Column(Text)
245
    intermittent = Column(Text)
246
    junction = Column(Text)
247
    landuse = Column(Text)
248
    layer = Column(Text)
249
    leisure = Column(Text)
250
    line = Column(Text)
251
    lock = Column(Text)
252
    man_made = Column(Text)
253
    military = Column(Text)
254
    motorcar = Column(Text)
255
    name = Column(Text)
256
    natural = Column(Text)
257
    office = Column(Text)
258
    oneway = Column(Text)
259
    operator = Column(Text)
260
    place = Column(Text)
261
    population = Column(Text)
262
    power = Column(Text)
263
    power_source = Column(Text)
264
    public_transport = Column(Text)
265
    railway = Column(Text)
266
    ref = Column(Text)
267
    religion = Column(Text)
268
    route = Column(Text)
269
    service = Column(Text)
270
    sidewalk = Column(Text)
271
    shop = Column(Text)
272
    sport = Column(Text)
273
    surface = Column(Text)
274
    toll = Column(Text)
275
    tourism = Column(Text)
276
    tower_type = Column("tower:type", Text)
277
    tracktype = Column(Text)
278
    tunnel = Column(Text)
279
    water = Column(Text)
280
    waterway = Column(Text)
281
    wetland = Column(Text)
282
    width = Column(Text)
283
    wood = Column(Text)
284
    z_order = Column(Integer)
285
    way_area = Column(Float)
286
    abandoned_aeroway = Column("abandoned:aeroway", Text)
287
    abandoned_amenity = Column("abandoned:amenity", Text)
288
    abandoned_building = Column("abandoned:building", Text)
289
    abandoned_landuse = Column("abandoned:landuse", Text)
290
    abandoned_power = Column("abandoned:power", Text)
291
    area_highway = Column("area:highway", Text)
292
    tags = Column(HSTORE(Text()), index=True)
293
    geom = Column(Geometry(srid=3857), index=True)
294
    gid = Column(
295
        Integer,
296
        primary_key=True,
297
        server_default=text(
298
            "nextval('openstreetmap.osm_polygon_gid_seq'::regclass)"
299
        ),
300
    )
301
302
303
class OsmRel(Base):
304
    __tablename__ = "osm_rels"
305
    __table_args__ = {
306
        "schema": "openstreetmap",
307
    }
308
309
    id = Column(BigInteger, primary_key=True)
310
    way_off = Column(SmallInteger)
311
    rel_off = Column(SmallInteger)
312
    parts = Column(ARRAY(BigInteger()), index=True)
313
    members = Column(ARRAY(Text()))
314
    tags = Column(ARRAY(Text()))
315
316
317 View Code Duplication
class OsmRoad(Base):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
318
    __tablename__ = "osm_roads"
319
    __table_args__ = {
320
        "schema": "openstreetmap",
321
    }
322
323
    osm_id = Column(BigInteger)
324
    access = Column(Text)
325
    addr_housename = Column("addr:housename", Text)
326
    addr_housenumber = Column("addr:housenumber", Text)
327
    addr_interpolation = Column("addr:interpolation", Text)
328
    admin_level = Column(Text)
329
    aerialway = Column(Text)
330
    aeroway = Column(Text)
331
    amenity = Column(Text)
332
    area = Column(Text)
333
    barrier = Column(Text)
334
    bicycle = Column(Text)
335
    brand = Column(Text)
336
    bridge = Column(Text)
337
    boundary = Column(Text)
338
    building = Column(Text)
339
    construction = Column(Text)
340
    covered = Column(Text)
341
    culvert = Column(Text)
342
    cutting = Column(Text)
343
    denomination = Column(Text)
344
    disused = Column(Text)
345
    embankment = Column(Text)
346
    foot = Column(Text)
347
    generator_source = Column("generator:source", Text)
348
    harbour = Column(Text)
349
    highway = Column(Text)
350
    historic = Column(Text)
351
    horse = Column(Text)
352
    intermittent = Column(Text)
353
    junction = Column(Text)
354
    landuse = Column(Text)
355
    layer = Column(Text)
356
    leisure = Column(Text)
357
    line = Column(Text)
358
    lock = Column(Text)
359
    man_made = Column(Text)
360
    military = Column(Text)
361
    motorcar = Column(Text)
362
    name = Column(Text)
363
    natural = Column(Text)
364
    office = Column(Text)
365
    oneway = Column(Text)
366
    operator = Column(Text)
367
    place = Column(Text)
368
    population = Column(Text)
369
    power = Column(Text)
370
    power_source = Column(Text)
371
    public_transport = Column(Text)
372
    railway = Column(Text)
373
    ref = Column(Text)
374
    religion = Column(Text)
375
    route = Column(Text)
376
    service = Column(Text)
377
    sidewalk = Column(Text)
378
    shop = Column(Text)
379
    sport = Column(Text)
380
    surface = Column(Text)
381
    toll = Column(Text)
382
    tourism = Column(Text)
383
    tower_type = Column("tower:type", Text)
384
    tracktype = Column(Text)
385
    tunnel = Column(Text)
386
    water = Column(Text)
387
    waterway = Column(Text)
388
    wetland = Column(Text)
389
    width = Column(Text)
390
    wood = Column(Text)
391
    z_order = Column(Integer)
392
    way_area = Column(Float)
393
    abandoned_aeroway = Column("abandoned:aeroway", Text)
394
    abandoned_amenity = Column("abandoned:amenity", Text)
395
    abandoned_building = Column("abandoned:building", Text)
396
    abandoned_landuse = Column("abandoned:landuse", Text)
397
    abandoned_power = Column("abandoned:power", Text)
398
    area_highway = Column("area:highway", Text)
399
    tags = Column(HSTORE(Text()), index=True)
400
    geom = Column(Geometry("LINESTRING", 3857), index=True)
401
    gid = Column(
402
        Integer,
403
        primary_key=True,
404
        server_default=text(
405
            "nextval('openstreetmap.osm_roads_gid_seq'::regclass)"
406
        ),
407
    )
408
409
410
class OsmWay(Base):
411
    __tablename__ = "osm_ways"
412
    __table_args__ = {
413
        "schema": "openstreetmap",
414
    }
415
416
    id = Column(BigInteger, primary_key=True)
417
    nodes = Column(ARRAY(BigInteger()), nullable=False, index=True)
418
    tags = Column(ARRAY(Text()))
419