Skip to content

Commit 65736c0

Browse files
committed
Fossils coordinate api
1 parent b1307d2 commit 65736c0

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

v2/fossils.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ module.exports = function (req, res, next) {
3333
req.query.col_group_id ||
3434
req.query.strat_name_id ||
3535
req.query.strat_name_concept_id ||
36-
"sample" in req.query
36+
"sample" in req.query ||
37+
req.query.lat ||
38+
req.query.lng
3739
) {
3840
callback(null, {
3941
interval_name: "Unknown",
@@ -114,6 +116,13 @@ module.exports = function (req, res, next) {
114116
);
115117
}
116118

119+
if (req.query.lat && req.query.lng) {
120+
where += " AND ST_DWithin(pbdb_matches.coordinate, ST_SetSRID(ST_MakePoint(:lng, :lat), 4326), :radius)";
121+
params["lat"] = parseFloat(req.query.lat);
122+
params["lng"] = parseFloat(req.query.lng);
123+
params["radius"] = parseFloat(req.query.radius) || .1;
124+
}
125+
117126
if (req.query.col_group_id) {
118127
where += " AND col_group_id = ANY(:col_group_ids)";
119128
params["col_group_ids"] = larkin.parseMultipleIds(
@@ -251,4 +260,4 @@ module.exports = function (req, res, next) {
251260
},
252261
);
253262
}
254-
};
263+
};

0 commit comments

Comments
 (0)