Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Jcofles/Proyecto-web/llms.txt

Use this file to discover all available pages before exploring further.

The routing API calculates the shortest walking path between two campus waypoints. Internally, NodoController::ruta builds an adjacency list from the 50 in-memory directed edges and runs Dijkstra’s algorithm to return the ordered sequence of nodes from origin to destination along with the total walking distance in meters. Node IDs used in route requests come from GET /api/nodos.
The campus graph is a static, directed chain of 51 nodes and 50 edges loaded in-memory on every request. No database reads are performed during routing, which keeps latency low but means dynamically created nodes (via POST /api/nodos) are not reflected in route calculations until the graph is updated in source code.

Get shortest path

Returns the ordered list of nodes forming the shortest path between two campus waypoints and the total distance in meters.
GET /api/nodos/ruta/{origen}/{destino}
origen
integer
required
ID of the starting node. Must exist in the static node set (151).
destino
integer
required
ID of the destination node. Must exist in the static node set (151). Must differ from origen.
# Route from Entrada Universidad (1) to Cafeteria (49)
curl -s https://your-api.example.com/api/nodos/ruta/1/49
Example response — 200 OK
{
  "origen": {
    "id": 1,
    "nombre": "Entrada Universidad",
    "latitud": 4.1540264,
    "longitud": -74.8956435,
    "tipo_id": 2,
    "piso": 1
  },
  "destino": {
    "id": 49,
    "nombre": "Cafeteria",
    "latitud": 4.1569299,
    "longitud": -74.8976371,
    "tipo_id": 2,
    "piso": 1
  },
  "distancia_total": 473.52,
  "pasos": 48,
  "ruta": [
    {
      "id": 1,
      "nombre": "Entrada Universidad",
      "latitud": 4.1540264,
      "longitud": -74.8956435,
      "tipo_id": 2,
      "piso": 1
    },
    {
      "id": 2,
      "nombre": "Paso 2",
      "latitud": 4.1540938,
      "longitud": -74.8957258,
      "tipo_id": 2,
      "piso": 1
    },
    {
      "id": 3,
      "nombre": "Paso 3",
      "latitud": 4.1541906,
      "longitud": -74.8957731,
      "tipo_id": 2,
      "piso": 1
    },
    "... (intermediate nodes omitted for brevity) ...",
    {
      "id": 49,
      "nombre": "Cafeteria",
      "latitud": 4.1569299,
      "longitud": -74.8976371,
      "tipo_id": 2,
      "piso": 1
    }
  ]
}

Response fields

origen
object
Full node object of the origin waypoint.
destino
object
Full node object of the destination waypoint.
distancia_total
number
Cumulative walking distance along the computed path, in meters (rounded to 2 decimal places).
pasos
integer
Number of edges (hops) traversed. Equal to length(ruta) - 1.
ruta
array
Ordered array of node objects from origen to destino. Render these coordinates sequentially to draw the path on the map.

Error responses

404 — Node not found
{
  "error": "Nodo no encontrado"
}
Returned when either origen or destino is not a valid node ID. 404 — No route available
{
  "error": "No hay ruta disponible entre estos nodos"
}
Returned when the graph has no directed path connecting the two nodes. Because the current graph is a sequential chain (1 → 2 → … → 51), this only occurs if the origen is numerically greater than destino (since edges are directed forward only).
Always call GET /api/nodos first to obtain valid IDs. Node IDs in the static graph run from 1 to 51.

Get node type catalog

Returns all active node type definitions. Use the id values here as tipo_id when creating nodes or filtering the map by type.
GET /api/nodo-tipos
No parameters required. Returns only records where activo = true.
curl -s https://your-api.example.com/api/nodo-tipos
Example response — 200 OK
[
  { "id": 1, "nombre": "salon",     "descripcion": "Classroom or lecture hall",            "activo": true },
  { "id": 2, "nombre": "pasillo",   "descripcion": "Corridor or outdoor walkway",          "activo": true },
  { "id": 3, "nombre": "baño",      "descripcion": "Restroom",                             "activo": true },
  { "id": 4, "nombre": "escaleras", "descripcion": "Staircase connecting multiple floors", "activo": true }
]
id
integer
Primary key. Use as tipo_id in node objects.
nombre
string
Machine-readable type name: salon, pasillo, baño, or escaleras.
descripcion
string
Human-readable description of the node type.
activo
boolean
Whether this type is currently in use. Inactive types are filtered out of this response.

Graph structure

The campus navigation graph used for routing has the following characteristics:
PropertyValue
Nodes51
Edges50 directed edges (sequential: n → n+1)
Edge weightsHaversine distance in meters between each pair
AlgorithmDijkstra (O(V²) adjacency-list implementation)
Data storageIn-memory PHP array (no database I/O)
Notable nodes1 = Entrada Universidad, 17 = Punto Central, 44 = Bloque D, 49 = Cafeteria, 51 = Escalera Cafetería
Because edges are directed from lower to higher IDs, routing from a lower-numbered node to a higher-numbered node will always succeed. Routing in the reverse direction (high → low) will return a 404 “No hay ruta disponible” response unless bidirectional edges are added via POST /api/nodos/conectar.

Build docs developers (and LLMs) love