Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions controllers/features.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ exports.upsert = function(req, res) {
exports.getById = function(req, res) {
let query = {
id: req.params.id.split(','),
filter_namespace: req.query.filter_namespace,
include: req.query.include
};

Expand All @@ -37,6 +38,7 @@ exports.getByPoint = function(req, res) {
let query = {
latitude: parseFloat(req.params.latitude),
longitude: parseFloat(req.params.longitude),
filter_namespace: req.query.filter_namespace,
include: req.query.include
};

Expand All @@ -54,6 +56,7 @@ exports.getByPoint = function(req, res) {
exports.getByName = function(req, res) {
let query = {
name: req.params.name.split(/,(?=[^ ])/),
filter_namespace: req.query.filter_namespace,
include: req.query.include
};

Expand All @@ -75,6 +78,7 @@ exports.getByBoundingBox = function(req, res) {
south: parseFloat(req.params.south),
east: parseFloat(req.params.east),
filter_name: req.query.filter_name,
filter_namespace: req.query.filter_namespace,
include: req.query.include
};

Expand Down
1 change: 1 addition & 0 deletions schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ CREATE TABLE features

CREATE INDEX features_hull_index ON features USING gist (hull);
CREATE INDEX features_name_lower_index ON features(lower(name));
CREATE INDEX features_namespace_index ON features(lower(split_part(id, '-', 1)));

GRANT SELECT, UPDATE, INSERT, DELETE ON features TO frontend;

Expand Down
4 changes: 4 additions & 0 deletions services/features.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ function addQueryPredicates(sql, query) {
sql += ` AND strpos(lower(name), lower(${escapeSql(query.filter_name)})) > 0`;
}

if (query.filter_namespace) {
sql += ` AND lower(split_part(id, '-', 1)) = lower(${escapeSql(query.filter_namespace)})`;
}

return sql;
}

Expand Down