snprintf(location, sizeof(location), "%s", str);
free(str);
+ index = 0;
last_location[index] = (char *)strtok_r(location, ";", &last);
- while (last_location[index++] != NULL) {
- if (index == MAX_NPS_LOC_ITEM)
+ while (last_location[index] != NULL) {
+ switch (index) {
+ case 0:
+ latitude = strtod(last_location[index], NULL);
+ break;
+ case 1:
+ longitude = strtod(last_location[index], NULL);
+ break;
+ case 2:
+ altitude = strtod(last_location[index], NULL);
+ break;
+ case 3:
+ speed = strtod(last_location[index], NULL);
+ break;
+ case 4:
+ direction = strtod(last_location[index], NULL);
+ break;
+ case 5:
+ hor_accuracy = strtod(last_location[index], NULL);
+ break;
+ default:
break;
+ }
+ if (++index == MAX_NPS_LOC_ITEM) break;
last_location[index] = (char *)strtok_r(NULL, ";", &last);
}
-
- if (index != MAX_NPS_LOC_ITEM) {
- MOD_NPS_LOGD("Error item index");
- return LOCATION_ERROR_NOT_AVAILABLE;
- }
- index = 0;
- latitude = strtod(last_location[index++], NULL);
- longitude = strtod(last_location[index++], NULL);
- altitude = strtod(last_location[index++], NULL);
- speed = strtod(last_location[index++], NULL);
- direction = strtod(last_location[index++], NULL);
- hor_accuracy = strtod(last_location[index], NULL);
}
}
- level = LOCATION_ACCURACY_LEVEL_STREET;
-
if (timestamp)
status = LOCATION_STATUS_3D_FIX;
else
return LOCATION_ERROR_NOT_AVAILABLE;
+ level = LOCATION_ACCURACY_LEVEL_STREET;
*position = location_position_new((guint) timestamp, latitude, longitude, altitude, status);
*velocity = location_velocity_new((guint) timestamp, speed, direction, 0.0);
*accuracy = location_accuracy_new(level, hor_accuracy, -1.0);