Overview
The CECOCO Mobile Units API provides detailed tracking and analysis capabilities for mobile resources. You can retrieve complete route histories, identify stopped intervals, and monitor unit behavior patterns for operational oversight and compliance.Get Mobile Unit Routes
Retrieves the complete GPS tracking history for one or more mobile units within a specified time range. This endpoint returns detailed route information including coordinates, speeds, timestamps, and reverse-geocoded addresses.Request Parameters
Array of resource identifiers to track. Must not be “Seleccionar recurso”.Example:
["MOVIL-101", "MOVIL-102", "PATRULLA-05"]Start datetime for route tracking in format
Y-m-d H:i:sExample: "2023-11-01 08:00:00"End datetime for route tracking in format
Y-m-d H:i:sExample: "2023-11-01 18:00:00"Response Structure
Array of mobile unit tracking data, grouped by resource
Resource identifier (e.g., “MOVIL-101”)
Array of GPS tracking points for this resource
Unique GPS position record ID
Resource identifier
Latitude in decimal degrees
Longitude in decimal degrees
Speed at this position (km/h or m/s depending on system configuration)
Timestamp in format
d/m/Y H:i:sReverse-geocoded street address for this position
Response Example
Reverse Geocoding: The API automatically converts GPS coordinates to human-readable addresses using cached geocoding data. When coordinates are
0.0, 0.0, the address returns as “Dirección no encontrada”.Get Stopped Mobile Units
Analyzes mobile unit movement patterns to identify intervals where units were stationary for longer than a specified threshold. This is useful for compliance monitoring, idle time analysis, and operational efficiency reviews.Request Parameters
JSON-encoded array of resource identifiers to analyzeExample:
"[\"MOVIL-101\", \"MOVIL-102\"]"Start datetime for analysis in format
Y-m-d H:i:sEnd datetime for analysis in format
Y-m-d H:i:sMinimum stopped duration in minutes to report. Units stopped for less than this threshold are not included in results.Example:
15 (report only stops longer than 15 minutes)Response Structure
Array of stopped interval records
Resource identifier
Time when the unit stopped moving (format:
H:i:s)Time when the unit resumed movement (format:
H:i:s)Latitude where the unit was stopped
Longitude where the unit was stopped
Reverse-geocoded address of the stopped location
Total stopped duration in minutes
Response Example
List Mobile Units
Retrieves a comprehensive list of all mobile units (cars and trucks) registered in the system, along with their associated vehicle information and current assignments.Response Structure
Response Example
Implementation Details
Movement Detection Algorithm
The stopped intervals endpoint uses the Haversine formula to calculate distances between consecutive GPS points. A unit is considered “stopped” when consecutive positions are less than 0.02 km apart:tiempo_permitido threshold.
Geocoding Cache
To optimize performance, the system maintains a geocoding cache in thegeocodificacion_inversa table. When an address is requested:
- Check cache for exact coordinate match (rounded to 7 decimal places)
- If found, return cached address immediately
- If not found, query Google Maps Geocoding API
- Store result in cache for future requests
Coordinate Conversion
All GPS coordinates are stored in radians in theposicionesgps table. The API converts them to decimal degrees using the conversion factor:
Validation Rules
The endpoints enforce the following validation:Get Mobile Unit Routes
recursos: Required, must not equal “Seleccionar recurso”fecha_desde: Required, valid datetime stringfecha_hasta: Required, valid datetime string
Get Stopped Intervals
recursos: Required, must be valid JSON stringfecha_desde: Required, valid datetime stringfecha_hasta: Required, valid datetime stringtiempo_permitido: Required, must be numeric
Error Handling
All endpoints return standardized error responses:Use Cases
Route Replay and Analysis
Use/get-moviles to reconstruct and visualize complete patrol routes for:
- Incident investigation and timeline reconstruction
- Response time analysis
- Coverage area verification
- Training and performance review
Compliance Monitoring
Use/get-moviles-parados to identify:
- Unauthorized extended stops
- Pattern analysis for operational efficiency
- Break compliance verification
- Location-based behavior analysis
Resource Availability
Use/get-moviles-json to:
- Display available mobile units in dispatch interfaces
- Filter resources by vehicle type for assignment
- Track current deployment locations
- Generate resource allocation reports
Performance Considerations
Large Dataset Warning: Route queries for multiple units over extended time periods can return large datasets. Consider implementing pagination or limiting the time range to maintain reasonable response times.
- Single unit, 24-hour period: 2-5 seconds
- 5 units, 24-hour period: 10-30 seconds
- Single unit, 7-day period: 15-45 seconds
- Number of resources requested
- Time range duration
- GPS tracking frequency (higher frequency = more data points)
- Geocoding cache hit rate