๐ 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:
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 Category | Profile Object | Max Limit (km/h) | Min Limit (km/h) | Max Limit (mph) | Min Limit (mph) | Target Domain |
|---|---|---|---|---|---|---|
| Passenger Cars | DrivingProfile.CarHighway | 120 | 60 | 75 | 40 | Interstates, Motorways, Expressways |
| Passenger Cars | DrivingProfile.CarCity | 50 | 0 | 30 | 0 | Urban and suburban commuting |
| Motorcycles | DrivingProfile.Motorcycle | 120 | 0 | 75 | 0 | Unrestricted motorcycle riding |
| Logistics / Freight | DrivingProfile.TruckHighway | 90 | 50 | 60 | 30 | EU/US governed Heavy Goods Vehicles (HGV) |
| Public Transit | DrivingProfile.BusCoach | 100 | 50 | 65 | 30 | Intercity passenger buses |
| Agriculture / Heavy | DrivingProfile.TractorAgricultural | 40 | 0 | 25 | 0 | Farm and construction machinery |
| Micro-Mobility | DrivingProfile.EScooter | 20 | 0 | 12.5 | 0 | Shared e-scooters & micromobility |
| Micro-Mobility | DrivingProfile.Bicycle | 25 | 0 | 15 | 0 | Pedelecs, e-bikes, and city bicycles |
| Pedestrian | DrivingProfile.Walking | 8 | 0 | 5 | 0 | Jogging, fitness, walking pace |
| Special Zones | DrivingProfile.SchoolZone | 30 | 0 | 20 | 0 | School 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:
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:
@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))
}