Find Nearby Drivers
GET /viajes/find_nearby_drivers.php
Find available drivers near a specific location.
Query Parameters
Vehicle type to search for: moto, auto, or mototaxi
Search radius in kilometers
Response
List of available drivers within the radius Distance from search location
Estimated arrival time in minutes
Request Example
curl -X GET "https://76.13.114.194/viajes/find_nearby_drivers.php?latitud=4.6814&longitud=-74.0479&tipo=moto&radius=5" \
-H "Accept: application/json"
Response Example
Drivers Found
No Drivers Available
{
"success" : true ,
"drivers" : [
{
"conductor_id" : 25 ,
"nombre" : "Juan Martínez" ,
"calificacion" : 4.8 ,
"vehiculo_tipo" : "moto" ,
"vehiculo_placa" : "ABC123" ,
"latitud" : 4.6820 ,
"longitud" : -74.0485 ,
"distancia_km" : 0.8 ,
"tiempo_estimado_minutos" : 3
},
{
"conductor_id" : 32 ,
"nombre" : "Carlos Pérez" ,
"calificacion" : 4.9 ,
"vehiculo_tipo" : "moto" ,
"vehiculo_placa" : "DEF456" ,
"latitud" : 4.6850 ,
"longitud" : -74.0500 ,
"distancia_km" : 1.5 ,
"tiempo_estimado_minutos" : 5
}
]
}
Price Estimation
The API calculates price estimates automatically when creating a trip based on distance and service type. There is currently no separate price calculation endpoint.
The estimated price is calculated using:
class PriceCalculator {
// Base fares by service type (COP)
static const baseFares = {
'motocicleta' : 5000 ,
'mototaxi' : 6000 ,
'auto' : 8000 ,
};
// Price per kilometer (COP)
static const pricePerKm = {
'motocicleta' : 2500 ,
'mototaxi' : 3000 ,
'auto' : 3500 ,
};
// Minimum fare (COP)
static const minimumFare = 8000 ;
static double calculatePrice (
String serviceType,
double distanceKm, {
double surchargeMultiplier = 1.0 , // For peak hours
}) {
final baseFare = baseFares[serviceType] ?? 5000 ;
final perKm = pricePerKm[serviceType] ?? 2500 ;
double price = baseFare + (distanceKm * perKm);
price = price * surchargeMultiplier;
// Apply minimum fare
if (price < minimumFare) {
price = minimumFare;
}
// Round to nearest 500
return (price / 500 ). ceil () * 500 ;
}
}
// Example:
final price = PriceCalculator . calculatePrice (
'motocicleta' ,
4.2 ,
surchargeMultiplier : 1.0 ,
);
print (price); // 15500 COP
Dynamic Pricing
Prices may increase during:
Peak hours : 7-9 AM, 5-7 PM (Monday-Friday)
High demand : When driver availability is low
Bad weather : Rain, storms
Special events : Holidays, concerts, sporting events
Surge pricing multipliers typically range from 1.2x to 2.0x during extreme demand.
Distance Calculation
The API uses the Haversine formula to calculate distances:
import 'dart:math' ;
class DistanceCalculator {
static const earthRadiusKm = 6371.0 ;
static double haversineDistance (
double lat1,
double lon1,
double lat2,
double lon2,
) {
final dLat = _toRadians (lat2 - lat1);
final dLon = _toRadians (lon2 - lon1);
final a = sin (dLat / 2 ) * sin (dLat / 2 ) +
cos ( _toRadians (lat1)) *
cos ( _toRadians (lat2)) *
sin (dLon / 2 ) *
sin (dLon / 2 );
final c = 2 * atan2 ( sqrt (a), sqrt ( 1 - a));
return earthRadiusKm * c;
}
static double _toRadians ( double degrees) {
return degrees * pi / 180 ;
}
}
// Example:
final distance = DistanceCalculator . haversineDistance (
4.6814 , - 74.0479 , // Origen
4.6533 , - 74.0602 , // Destino
);
print ( ' ${ distance . toStringAsFixed ( 2 )} km' ); // 4.23 km
Estimated Time of Arrival (ETA)
Calculate ETA based on distance and traffic conditions:
class ETACalculator {
// Average speeds in km/h
static const speeds = {
'moto' : 30.0 , // Motorcycles faster in traffic
'auto' : 25.0 , // Cars slower in urban areas
'mototaxi' : 28.0 ,
};
static int calculateETA (
String vehicleType,
double distanceKm, {
double trafficMultiplier = 1.0 ,
}) {
final speed = speeds[vehicleType] ?? 25.0 ;
final adjustedSpeed = speed / trafficMultiplier;
final hours = distanceKm / adjustedSpeed;
final minutes = (hours * 60 ). ceil ();
return minutes;
}
}
// Example:
final eta = ETACalculator . calculateETA (
'moto' ,
4.2 ,
trafficMultiplier : 1.2 , // 20% slower due to traffic
);
print ( ' $ eta minutos' ); // 10 minutos
Service Type Comparison
Motocicleta Base : $5,000 COPPer km : $2,500 COPSpeed : Fastest in trafficCapacity : 1 passenger
Mototaxi Base : $6,000 COPPer km : $3,000 COPSpeed : FastCapacity : 1-2 passengers
Auto Base : $8,000 COPPer km : $3,500 COPSpeed : ModerateCapacity : 3-4 passengers
Error Responses
Invalid coordinates or parameters
Server error during search
See Also