/
power.py
145 lines (132 loc) · 3.4 KB
/
power.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
from funcs import (
table,
relation_tables,
generalized_table,
str_col,
int_col,
bool_col,
type_col,
)
table(
"power_line",
{
"power": ["line", "minor_line", "cable", "minor_cable"],
"construction:power": ["line", "minor_line", "cable", "minor_cable"],
},
"linestring",
columns=[
type_col,
str_col("location"),
str_col("line"),
str_col("voltage"),
str_col("frequency"),
int_col("circuits"),
str_col("construction:power", "construction"),
bool_col("tunnel"),
],
)
generalized_table(
"power_line_gen_100",
"power_line",
100,
"coalesce(convert_voltage(voltage), 0) > 100000 AND ST_length(geometry) > 200 "
"AND line NOT IN ('bay', 'busbar')",
)
generalized_table(
"power_line_gen_500",
"power_line",
500,
"coalesce(convert_voltage(voltage), 0) > 100000 AND ST_length(geometry) > 600 "
"AND line NOT IN ('bay', 'busbar')",
)
table(
"power_tower",
{
"power": ["tower", "pole", "portal"],
"construction:power": ["tower", "pole", "portal"],
},
["points", "linestrings"],
columns=[
type_col,
bool_col("location:transition", "transition"),
str_col("construction:power", "construction"),
],
)
table(
"power_substation",
{
"power": ["substation", "sub_station"],
"construction:power": ["substation", "sub_station"],
},
["points", "polygons"],
columns=[
type_col,
str_col("substation"),
str_col("voltage"),
str_col("frequency"),
str_col("construction:power", "construction"),
bool_col("tunnel"),
],
)
relation_tables(
"power_substation_relation",
{
"power": ["substation", "sub_station"],
"construction:power": ["substation", "sub_station"],
},
relation_types=["site"],
relation_columns=[
str_col("substation"),
str_col("voltage"),
str_col("frequency"),
str_col("construction:power", "construction"),
bool_col("tunnel"),
],
)
table(
"power_switchgear",
{
"power": [
"switch",
"transformer",
"compensator",
"insulator",
"terminal",
"converter",
]
},
["points", "polygons"],
columns=[str_col("voltage"), type_col],
)
table(
"power_plant",
{"power": ["plant"], "construction:power": ["plant"]},
"polygon",
columns=[
str_col("plant:output:electricity", "output"),
str_col("plant:source", "source"),
str_col("construction_power", "construction"),
],
)
relation_tables(
"power_plant_relation",
{"power": ["plant"], "construction:power": ["plant"]},
["site"],
relation_columns=[
str_col("plant:output:electricity", "output"),
str_col("plant:source", "source"),
str_col("construction_power", "construction"),
],
)
table(
"power_generator",
{"power": ["generator"], "construction:power": ["generator"]},
["points", "polygons"],
columns=[
str_col("generator:source", "source"),
str_col("generator:method", "method"),
str_col("generator:type", "type"),
str_col("generator:output", "output"), # TODO: should be generator:output:electricity
str_col("construction_power", "construction"), # TODO: should be construction:power
],
)