postgis
Version:
A Node.js class for interacting with PostGIS-enabled PostgreSQL databases.
23 lines (18 loc) • 449 B
JavaScript
module.exports = function (table_from, table_to, columns, distance, geom_column_from, geom_column_to, filter, sort, limit) {
return `
SELECT
${columns}
FROM
${table_from},
${table_to}
WHERE
ST_DWithin(
${table_from}.${geom_column_from},
${table_to}.${geom_column_to},
${distance}
)
${filter ? `AND ${filter}` : ''}
${sort ? `ORDER BY ${sort}` : ''}
${limit ? `LIMIT ${limit}` : ''}
`
}