-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
107 lines (105 loc) · 2.93 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
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,
post:process.env.db_port,
database:'rwss_assets',
},
format:{
type: 'mbtiles',
output: __dirname + '/data/parcels.mbtiles',
metadata: {
"name": "rwanda-parcels",
"description":"parcels data in vector tiles",
"format":"pbf",
"version": 1,
"minzoom": 15,
"maxzoom": 15,
"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: 15,
maxzoom:15,
query:`
WITH 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.fid as id,
x."Parcel_ID" parcel_no
) AS p
)) AS properties
FROM parcels x
WHERE NOT ST_IsEmpty(x.geom)
AND x.geom && ST_Buffer(${BBOX}, 0.0000001)
)
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: 15,
maxzoom:15,
query:`
WITH 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.fid as id,
x."Parcel_ID" parcel_no
) AS p
)) AS properties
FROM parcels x
WHERE NOT ST_IsEmpty(x.geom)
AND x.geom && ST_Buffer(${BBOX}, 0.0000001)
)
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(ST_CENTROID(x.geom))::json AS geometry,
x.properties
FROM final x
WHERE NOT ST_IsEmpty(x.geom)
) AS feature
) AS featurecollection
`
},
]
}