static int on_alt_routes_btn_cb(SsdWidget widget, const char *new_value){ const RoadMapPosition *from; RoadMapPosition to; AltRouteTrip route; RealtimeAltRoutes_Clear(); from =navigate_main_get_src_position (); navigate_get_waypoint(-1, &to); ssd_progress_msg_dialog_show( roadmap_lang_get( "Calculating alternative routes, please wait..." ) ); RealtimeAltRoutes_Init_Record(&route); route.srcPosition = *from; route.destPosition = to; route.iTripId = -1; navigate_main_stop_navigation(); roadmap_trip_set_point ("Destination", &route.destPosition); roadmap_trip_set_point ("Departure", &route.srcPosition); RealtimeAltRoutes_Add_Route(&route); RealtimeAltRoutes_Route_Request (-1, from, &to, MAX_ROUTES); return 1; }
const char* on_suggested_trips(int NumParams,const char* pData){ int i; int iBufferSize; AltRouteTrip route; int numRecords = NumParams/7; for (i = 0; i < numRecords; i++){ if ( i%7 == 0) RealtimeAltRoutes_Init_Record(&route); //ID pData = ReadIntFromString( pData, // [in] Source string ",", // [in,opt] Value termination NULL, // [in,opt] Allowed padding &route.iTripId,// [out] Put it here 1); // [in] Remove if (!pData){ roadmap_log( ROADMAP_ERROR, "Tripserver::on_suggested_trips() - Failed to read ID"); return NULL; } //Src name iBufferSize = sizeof(route.sSrcName); pData = ExtractNetworkString( pData, // [in] Source string route.sSrcName,// [out] Output buffer &iBufferSize, // [in,out] Buffer size / Size of extracted string ",", // [in] Array of chars to terminate the copy operation 1); // [in] Remove additional termination chars if (!pData){ roadmap_log( ROADMAP_ERROR, "Tripserver::on_suggested_trips() - Failed to read SrcName. ID=%d",route.iTripId, route.sDestinationName ); return NULL; } //Src Lon pData = ReadIntFromString( pData, // [in] Source string ",", // [in,opt] Value termination NULL, // [in,opt] Allowed padding &route.srcPosition.longitude,// [out] Put it here 1); // [in] Remove if (!pData){ roadmap_log( ROADMAP_ERROR, "Tripserver::on_suggested_trips() - Failed to read Src longitude. ID=%d",route.iTripId ); return NULL; } //Src Lat pData = ReadIntFromString( pData, // [in] Source string ",\r\n", // [in,opt] Value termination NULL, // [in,opt] Allowed padding &route.srcPosition.latitude,// [out] Put it here TRIM_ALL_CHARS); // [in] Remove if (!pData){ roadmap_log( ROADMAP_ERROR, "Tripserver::on_suggested_trips() - Failed to read Src latitude. ID=%d",route.iTripId ); return NULL; } //Dest name iBufferSize = sizeof(route.sDestinationName); pData = ExtractNetworkString( pData, // [in] Source string route.sDestinationName,// [out] Output buffer &iBufferSize, // [in,out] Buffer size / Size of extracted string ",", // [in] Array of chars to terminate the copy operation 1); // [in] Remove additional termination chars if (!pData){ roadmap_log( ROADMAP_ERROR, "Tripserver::on_suggested_trips() - Failed to read DestName. ID=%d",route.iTripId, route.sDestinationName ); return NULL; } //Dest Lon pData = ReadIntFromString( pData, // [in] Source string ",", // [in,opt] Value termination NULL, // [in,opt] Allowed padding &route.destPosition.longitude,// [out] Put it here 1); // [in] Remove if (!pData){ roadmap_log( ROADMAP_ERROR, "Tripserver::on_suggested_trips() - Failed to read Destination longitude. ID=%d",route.iTripId ); return NULL; } //Dest Lat pData = ReadIntFromString( pData, // [in] Source string ",\r\n", // [in,opt] Value termination NULL, // [in,opt] Allowed padding &route.destPosition.latitude,// [out] Put it here TRIM_ALL_CHARS); // [in] Remove if (!pData){ roadmap_log( ROADMAP_ERROR, "Tripserver::on_suggested_trips() - Failed to read Destination latitude. ID=%d",route.iTripId ); return NULL; } RealtimeAltRoutes_Add_Route(&route); } roadmap_alternative_routes_suggested_trip(); return pData; }