import 'package:flutter_map/flutter_map.dart';
import 'package:location/data/bean/atmob_track_point.dart';

class TrackUtil {
  static List<TraceLocation> points2TraceLocation(
      List<AtmobTrackPoint>? pointsList) {
    if (pointsList == null) {
      return [];
    }
    List<TraceLocation> traceLocations = [];
    for (var value in pointsList) {
      TraceLocation traceLocation = TraceLocation(
        latitude: value.latitude,
        longitude: value.longitude,
        time: value.time,
        speed: value.speed,
        bearing: value.bearing,
      );
      traceLocations.add(traceLocation);
    }
    return traceLocations;
  }

  static List<LatLng> traceLocation2LatLng(
      List<TraceLocation>? traceLocations) {
    if (traceLocations == null) {
      return [];
    }
    return traceLocations
        .map((e) => LatLng(latitude: e.latitude, longitude: e.longitude))
        .toList();
  }
}
