Auto load Wikidata items
This commit is contained in:
parent
0c98ca921c
commit
f0cb54bf95
2 changed files with 34 additions and 0 deletions
18
web_view.py
18
web_view.py
|
|
@ -409,6 +409,24 @@ def get_bbox_centroid(bbox):
|
|||
|
||||
return lat, lon
|
||||
|
||||
@app.route("/api/1/count")
|
||||
def api_wikidata_items_count():
|
||||
t0 = time()
|
||||
bounds = request.args.get("bounds")
|
||||
|
||||
db_bbox = make_envelope(bounds)
|
||||
|
||||
q = (
|
||||
model.Item.query.join(model.ItemLocation)
|
||||
.filter(func.ST_Covers(db_bbox, model.ItemLocation.location))
|
||||
)
|
||||
|
||||
t1 = time() - t0
|
||||
response = jsonify(success=True, count=q.count(), duration=t1)
|
||||
response.headers["Access-Control-Allow-Origin"] = "*"
|
||||
return response
|
||||
|
||||
|
||||
@app.route("/api/1/items")
|
||||
def api_wikidata_items():
|
||||
bounds = request.args.get("bounds")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue