Skip to content

๐Ÿš— Driving Profiles & Speed Corridors โ€‹

The Veg Sahayyak SDK includes a legally compliant, globally localized Driving Profiles system (DrivingProfile.kt) designed to configure speed warning corridors in a single function call.


๐ŸŽฏ Why Driving Profiles? โ€‹

Traditional speed limit apps perform naive floating-point conversions (e.g. converting 120 km/h gives 74.5645 mph), leading to awkward numbers on driver dashboards.

DrivingProfile provides explicitly rounded, legally localized speed limits for each vehicle type and speed unit (120 km/h for Europe vs 75 mph for US interstate highways).


๐Ÿ“ฆ Applying a Driving Profile โ€‹

Apply any predefined profile to SpeedAssistant:

kotlin
import com.vegsahayyak.speedcore.api.SpeedAssistant
import com.vegsahayyak.speedcore.api.DrivingProfile

// Apply standard Highway Profile with 1 line of code
SpeedAssistant.with(context, "YOUR_JWT_LICENSE")
    .setDrivingProfile(DrivingProfile.CarHighway)
    .start()

๐ŸŽ๏ธ Built-In Vehicle Profiles Matrix โ€‹

Vehicle CategoryProfile ObjectMax Limit (km/h)Min Limit (km/h)Max Limit (mph)Min Limit (mph)Target Domain
Passenger CarsDrivingProfile.CarHighway120607540Interstates, Motorways, Expressways
Passenger CarsDrivingProfile.CarCity500300Urban and suburban commuting
MotorcyclesDrivingProfile.Motorcycle1200750Unrestricted motorcycle riding
Logistics / FreightDrivingProfile.TruckHighway90506030EU/US governed Heavy Goods Vehicles (HGV)
Public TransitDrivingProfile.BusCoach100506530Intercity passenger buses
Agriculture / HeavyDrivingProfile.TractorAgricultural400250Farm and construction machinery
Micro-MobilityDrivingProfile.EScooter20012.50Shared e-scooters & micromobility
Micro-MobilityDrivingProfile.Bicycle250150Pedelecs, e-bikes, and city bicycles
PedestrianDrivingProfile.Walking8050Jogging, fitness, walking pace
Special ZonesDrivingProfile.SchoolZone300200School zones and residential quiet zones

๐Ÿ› ๏ธ Dynamic Cloud Limits (CustomProfile) โ€‹

If your fleet application integrates with the Google Roads API, HERE Maps, or OpenStreetMap to ingest real-time geofenced legal speed limits, use DrivingProfile.CustomProfile:

kotlin
import com.vegsahayyak.speedcore.api.DrivingProfile
import com.vegsahayyak.speedcore.units.SpeedUnit

// Dynamically received 65 mph limit from cloud GPS corridor
val dynamicLimitFromMap = 65f
val minimumCorridorLimit = 40f

val roadProfile = DrivingProfile.CustomProfile(
    maxLimit = dynamicLimitFromMap,
    minLimit = minimumCorridorLimit,
    unit = SpeedUnit.MILES_PER_HOUR
)

// Ingest into SpeedAssistant
SpeedAssistant.with(context, "YOUR_JWT_LICENSE").setDrivingProfile(roadProfile)

The SDK automatically converts custom bounds to SI units (m/s) internally while maintaining display accuracy for any user-selected gauge unit.


๐Ÿงช Unit Testing Driving Profiles โ€‹

DrivingProfile is designed to be easily testable without requiring Android context or mock hardware:

kotlin
@Test
fun verifyHighwayLimitsMetricAndImperial() {
    val highway = DrivingProfile.CarHighway
    
    // Metric validation
    assertEquals(120f, highway.getMaxLimit(SpeedUnit.KILOMETERS_PER_HOUR))
    assertEquals(60f, highway.getMinLimit(SpeedUnit.KILOMETERS_PER_HOUR))
    
    // Imperial validation
    assertEquals(75f, highway.getMaxLimit(SpeedUnit.MILES_PER_HOUR))
    assertEquals(40f, highway.getMinLimit(SpeedUnit.MILES_PER_HOUR))
}

Released under Commercial Enterprise License. Follow us on LinkedIn | Contact Us.