mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 10:57:07 +00:00
Adapt GIS endpoint to new preplots tables structure
This commit is contained in:
@@ -12,27 +12,53 @@ async function lines (projectId, options = {}) {
|
||||
["V", "S"].includes(options.class) && options.class || "S"
|
||||
];
|
||||
|
||||
const text = `
|
||||
SELECT json_build_object(
|
||||
'type', 'FeatureCollection',
|
||||
'features', json_agg(geojson::json)) geojson
|
||||
FROM (
|
||||
SELECT ST_AsGeoJSON(t.*) geojson
|
||||
const text = values[6] == 'V'
|
||||
? `
|
||||
SELECT json_build_object(
|
||||
'type', 'FeatureCollection',
|
||||
'features', json_agg(geojson::json)) geojson
|
||||
FROM (
|
||||
SELECT line, incr, remarks, ntba, ST_Transform(geometry, 4326) geometry
|
||||
FROM preplot_lines
|
||||
WHERE
|
||||
class = $7
|
||||
AND (
|
||||
($1 IS true
|
||||
AND ST_Transform(geometry, 4326) && ST_MakeEnvelope($2, $3, $4, $5, 4326)
|
||||
SELECT ST_AsGeoJSON(t.*) geojson
|
||||
FROM (
|
||||
SELECT pl.line, psl.incr, psl.remarks, psl.ntba, ST_Transform(pl.geometry, 4326) geometry
|
||||
FROM preplot_lines pl
|
||||
INNER JOIN preplot_saillines psl
|
||||
ON pl.line = psl.sailline
|
||||
WHERE
|
||||
class = $7
|
||||
AND (
|
||||
($1 IS true
|
||||
AND ST_Transform(pl.geometry, 4326) && ST_MakeEnvelope($2, $3, $4, $5, 4326)
|
||||
)
|
||||
OR ($1 IS false AND true)
|
||||
)
|
||||
OR ($1 IS false AND true)
|
||||
)
|
||||
LIMIT $6
|
||||
) t
|
||||
) f;
|
||||
`;
|
||||
LIMIT $6
|
||||
) t
|
||||
) f;
|
||||
`
|
||||
: `
|
||||
SELECT json_build_object(
|
||||
'type', 'FeatureCollection',
|
||||
'features', json_agg(geojson::json)) geojson
|
||||
FROM (
|
||||
SELECT ST_AsGeoJSON(t.*) geojson
|
||||
FROM (
|
||||
SELECT pl.line, psl.incr, psl.remarks, psl.ntba, ST_Transform(pl.geometry, 4326) geometry
|
||||
FROM preplot_lines pl
|
||||
INNER JOIN preplot_saillines psl
|
||||
ON pl.line = psl.line
|
||||
WHERE
|
||||
class = $7
|
||||
AND (
|
||||
($1 IS true
|
||||
AND ST_Transform(pl.geometry, 4326) && ST_MakeEnvelope($2, $3, $4, $5, 4326)
|
||||
)
|
||||
OR ($1 IS false AND true)
|
||||
)
|
||||
LIMIT $6
|
||||
) t
|
||||
) f;
|
||||
`
|
||||
|
||||
const res = await client.query(text, values);
|
||||
client.release();
|
||||
|
||||
Reference in New Issue
Block a user