Add location search and polish running route planner

This commit is contained in:
Peter Stockings
2026-10-03 10:01:16 +10:00
parent 52943cd05b
commit 5ede1a01d2
7 changed files with 420 additions and 43 deletions
+14 -1
View File
@@ -6,7 +6,7 @@ from flask_login import current_user, login_required
from .extensions import db, limiter
from .models import PlannedRoute
from .planner_engine import PlannerError, generate, validate
from .planner_engine import PlannerError, generate, search_locations, validate
planner = Blueprint("planner", __name__, url_prefix="/routes")
@@ -62,6 +62,19 @@ def candidates():
return jsonify(routes=[serialise(row) for row in rows], warnings=warnings)
@planner.post("/search")
@login_required
@limiter.limit("30 per minute; 600 per day")
def search():
try:
locations = search_locations(
request.get_json(silent=True), current_app.config.get("ORS_API_KEY")
)
except PlannerError as error:
return jsonify(error=str(error)), 400
return jsonify(locations=locations)
@planner.get("/<int:route_id>")
@login_required
def detail(route_id):