encodeHeader method

  1. @override
Map<String, dynamic> encodeHeader()

Implementation

@override
Map<String, dynamic> encodeHeader() {
  final mapHeader = {
    'locations': waypoints.map((e) {
      final mPoint = e.toMap();
      mPoint['type'] = 'break';
      return mPoint;
    }).toList(),
    'exclude_polygons': [],
    'costing': costing.name,
    'units': units.name,
    'language': languages.name,
    'directions_type': directionsType.name,
    'format': valhallaFormat.name,
    'alternates': alternatives,
  }
    ..addIfNotNull('id', id)
    ..addIfNotNull(
      'shape_format',
      valhallaFormat == ValhallaFormat.orsm && valhallaShapeFormat != null
          ? (valhallaShapeFormat ?? Geometries.polyline6).name
          : null,
    )
    ..addIfNotNull(
      'costing_options',
      costingOption != null
          ? {
              costing.name: costingOption!.toMap(),
            }
          : null,
    )
    ..addIfNotNull(
      'banner_instructions',
      bannerInstructions,
    )
    ..addIfNotNull(
      'voice_instructions',
      voiceInstructions,
    )
    ..addIfNotNull(
      'exclude_polygons',
      excludePolygones != null
          ? convertNestedLngLatToList(excludePolygones!)
          : null,
    )
    ..addIfNotNull(
      'exclude_locations',
      excludeLocations?.toWaypoints(),
    );

  return mapHeader;
}