This repository has been archived by the owner on Aug 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig-search.js
51 lines (49 loc) · 1.55 KB
/
config-search.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
require('dotenv').config();
const env = process.env;
const export_dir = env.export_dir || __dirname;
module.exports = {
db: {
user:env.db_user,
password:env.db_password,
host:env.db_host,
post:env.db_port,
database:env.db_name,
},
layers : [
{
name: 'meter',
geojsonFileName: export_dir + '/public/meter.geojson',
select:`
SELECT row_to_json(featurecollection) AS json FROM (
SELECT
'FeatureCollection' AS type,
array_to_json(array_agg(feature)) AS features
FROM (
SELECT
'Feature' AS type,
ST_AsGeoJSON(ST_TRANSFORM(x.geom,4326))::json AS geometry,
row_to_json((
SELECT p FROM (
SELECT
x.meterid as fid,
CASE WHEN x.connno=-1 THEN NULL ELSE LPAD(CAST(x.connno as text), 4, '0') || x.zonecd END as connno,
x.serialno,
b.name as customer,
c.name as village
) AS p
)) AS properties
FROM meter x
INNER JOIN metertype a
ON x.metertypeid = a.metertypeid
LEFT JOIN customer b
ON x.zonecd = b.zonecd
AND x.connno = b.connno
LEFT JOIN village c
on b.villageid = c.villageid
WHERE NOT ST_IsEmpty(x.geom) AND x.metertypeid = 1
) AS feature
) AS featurecollection
`
},
],
};