Overview
Tourist routes (RutaTuristica) connect multiple destinations into ordered itineraries. Routes feature automatic distance-based ordering, interactive maps, and flexible management capabilities.
Routes require a minimum of 2 POIs and automatically order them by geographic proximity for optimal travel planning.
Data Model
TheRutaTuristica entity is defined in src/domain/entities/ruta_turistica.py:
Route Entity
RutaPOI Structure
Each point in a route is represented byRutaPOI (src/domain/entities/ruta_poi.py):
POI Reference
API Endpoints
All route endpoints are defined insrc/infrastructure/api/routers/rutas_router.py:
Create Route
POST Response:
/rutas/crearRequires: Editor roleAutomatically orders POIs by proximity using the CrearRutaTuristicaUseCase.Request Body
Validation Rules
Validation Rules
- Minimum 2 POIs required
- All POI IDs must exist in the database
- First POI becomes the starting point
- Remaining POIs are automatically ordered by distance
Get Route by ID
GET
/rutas/{ruta_id}Public endpoint - retrieves complete route details including all POI information.Update Route
PUT
/rutas/{ruta_id}Requires: Editor roleUpdates route metadata and POI ordering.Request Body
Creating Routes
TheCrearRutaTuristicaUseCase (src/application/use_cases/Rutas/crear_ruta_turistica.py) implements intelligent route creation:
Route Creation Logic
Distance-Based Ordering
The_ordenar_por_distancia method implements a greedy nearest-neighbor algorithm:
Proximity Ordering Algorithm
Distance Calculation
The Haversine formula (src/application/services/validacion_rutas_service.py) calculates great-circle distances:Haversine Implementation
Interactive Maps
Routes are displayed on Leaflet-powered interactive maps with:- Markers: Each POI is marked with coordinates
- Polylines: Visual route path connecting POIs in order
- Popups: POI details on marker click
- Zoom Controls: Navigate and explore route details
The frontend integration uses Leaflet.js to render routes from the API data, displaying ordered POIs with connecting paths.
POI Suggestions
While creating routes, the system can suggest nearby POIs: POST/rutas/sugerencias
Requires: Current POI ID and list of already selected POIs
Request
Response
Best Practices
Minimum POIs
Always include at least 2 POIs - the system enforces this at the use case level
Starting Point
Choose the most accessible or iconic site as the starting point for better user experience
Route Categories
Use consistent category naming (e.g., “Histórica”, “Cultural”, “Religiosa”) for better organization
Descriptions
Provide clear descriptions highlighting what makes the route unique or noteworthy
Related Features
- Route Generation - AI-powered automatic route creation
- Destinations - Manage POIs included in routes
- Multimedia - View destination media within routes