-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
186 lines (184 loc) · 4.88 KB
/
config.js
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
require('dotenv').config();
const BBOX = `ST_Transform(ST_MakeEnvelope({minx}, {miny}, {maxx}, {maxy}, 3857), 4326)`;
module.exports ={
db: {
user:process.env.db_user,
password:process.env.db_password,
host:process.env.db_host,
port:process.env.db_port,
database:'rw_parcels',
},
format:{
type: 'mbtiles',
output: __dirname + '/data/parcels.mbtiles',
metadata: {
"name": "rwanda-parcels",
"description":"parcels data in vector tiles as of 21 July 2020",
"format":"pbf",
"version": 1,
"minzoom": 16,
"maxzoom": 16,
"center": "30.060,-1.945, 15",
"bounds": "28.861730820621, -2.84023010213741, 30.8997466415943, -1.04716670707785",
"type": "overlay",
"json": `{"vector_layers": [ { "id": "parcels", "description": "", "minzoom": 15, "maxzoom": 15, "fields": {} },{ "id": "parcels_annotation", "description": "", "minzoom": 15, "maxzoom": 15, "fields": {} } ] }`
},
},
// format:{
// type: 'pbf',
// output: __dirname + '/public/tiles',
// },
layers : [
{
name: 'parcels',
buffer: 2,
minzoom: 16,
maxzoom:16,
query:`
WITH union_parcels as(
SELECT
objectid,
parcel_num,
geom
FROM eastern_province
WHERE NOT ST_IsEmpty(geom)
AND geom && ST_Buffer(${BBOX}, 0.0000001)
UNION ALL
SELECT
objectid,
parcel_num,
geom
FROM kigali_city_province
WHERE NOT ST_IsEmpty(geom)
AND geom && ST_Buffer(${BBOX}, 0.0000001)
UNION ALL
SELECT
objectid,
parcel_num,
geom
FROM northern_province
WHERE NOT ST_IsEmpty(geom)
AND geom && ST_Buffer(${BBOX}, 0.0000001)
UNION ALL
SELECT
objectid,
parcel_num,
geom
FROM southern_province
WHERE NOT ST_IsEmpty(geom)
AND geom && ST_Buffer(${BBOX}, 0.0000001)
UNION ALL
SELECT
objectid,
parcel_num,
geom
FROM western_province
WHERE NOT ST_IsEmpty(geom)
AND geom && ST_Buffer(${BBOX}, 0.0000001)
)
,final as(
SELECT
'Feature' AS type,
ST_Intersection(ST_Buffer(x.geom, 0.0000001), ST_Buffer(${BBOX}, 0.0000001)) AS geom,
row_to_json((
SELECT p FROM (
SELECT
x.objectid as id,
x.parcel_num parcel_no
) AS p
)) AS properties
FROM union_parcels x
)
SELECT row_to_json(featurecollection) AS json FROM (
SELECT
'FeatureCollection' AS type,
array_to_json(array_agg(feature)) AS features
FROM (
SELECT
x.type,
ST_AsGeoJSON(x.geom)::json AS geometry,
x.properties
FROM final x
WHERE NOT ST_IsEmpty(x.geom)
) AS feature
) AS featurecollection
`
},
{
name: 'parcels_annotation',
buffer: 0,
minzoom: 16,
maxzoom:16,
query:`
WITH union_parcels as(
SELECT
objectid,
parcel_num,
geom
FROM eastern_province
WHERE NOT ST_IsEmpty(geom)
AND geom && ST_Buffer(${BBOX}, 0.0000001)
UNION ALL
SELECT
objectid,
parcel_num,
geom
FROM kigali_city_province
WHERE NOT ST_IsEmpty(geom)
AND geom && ST_Buffer(${BBOX}, 0.0000001)
UNION ALL
SELECT
objectid,
parcel_num,
geom
FROM northern_province
WHERE NOT ST_IsEmpty(geom)
AND geom && ST_Buffer(${BBOX}, 0.0000001)
UNION ALL
SELECT
objectid,
parcel_num,
geom
FROM southern_province
WHERE NOT ST_IsEmpty(geom)
AND geom && ST_Buffer(${BBOX}, 0.0000001)
UNION ALL
SELECT
objectid,
parcel_num,
geom
FROM western_province
WHERE NOT ST_IsEmpty(geom)
AND geom && ST_Buffer(${BBOX}, 0.0000001)
)
,final as(
SELECT
'Feature' AS type,
ST_Intersection(ST_CENTROID(x.geom), ST_Buffer(${BBOX}, 0.0000001)) AS geom,
row_to_json((
SELECT p FROM (
SELECT
x.objectid as id,
x.parcel_num parcel_no
) AS p
)) AS properties
FROM union_parcels x
WHERE NOT ST_IsEmpty(x.geom)
)
SELECT row_to_json(featurecollection) AS json FROM (
SELECT
'FeatureCollection' AS type,
array_to_json(array_agg(feature)) AS features
FROM (
SELECT
x.type,
ST_AsGeoJSON(x.geom)::json AS geometry,
x.properties
FROM final x
WHERE x.geom IS NOT NULL AND (NOT ST_IsEmpty(x.geom))
) AS feature
) AS featurecollection
`
},
]
}