refactor query to 3 way join

This commit is contained in:
Ed Chalstrey 2022-04-21 16:48:35 +01:00
parent ac82c33bcb
commit d73a526835

View File

@ -192,28 +192,14 @@ function getDataConfig(tileset: string): DataConfig {
JOIN
geometries AS g
ON d.geometry_id = g.geometry_id
) AS data
`;
if(table == 'buildings') {
const query = `(
SELECT
d.*,
g.geometry_geom
FROM (
${table}
) AS d
JOIN
geometries AS g
ON d.geometry_id = g.geometry_id
buildings AS b
ON d.geometry_id = b.geometry_id
WHERE
d.latest_demolish_date IS NULL
b.latest_demolish_date IS NULL
) AS data
`;
}
return {
geometry_field: GEOMETRY_FIELD,
table: query