Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

road type fix #24

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions lib/src/osrm_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import 'dart:math';

import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:routing_client_dart/src/models/lng_lat.dart';
import 'package:routing_client_dart/src/models/lng_lat_radian.dart';
import 'package:routing_client_dart/src/models/math_utils.dart';
import 'package:routing_client_dart/src/models/osrm_mixin.dart';
import 'package:routing_client_dart/src/utilities/computes_utilities.dart';

import 'package:routing_client_dart/src/models/lng_lat.dart';
import 'package:routing_client_dart/src/models/road.dart';
import 'package:routing_client_dart/src/utilities/computes_utilities.dart';
import 'package:routing_client_dart/src/utilities/utils.dart';

/// [OSRMManager]
Expand Down Expand Up @@ -54,13 +53,14 @@ class OSRMManager with OSRMHelper {
/// in case of any problem
Future<Road> getRoad({
required List<LngLat> waypoints,
RoadType roadType = RoadType.car,
RoadType? roadType,
bool alternative = false,
bool steps = true,
Overview overview = Overview.full,
Geometries geometries = Geometries.geojson,
Languages language = Languages.en,
}) async {
roadType ??= this.roadType;
String path = generatePath(
server,
waypoints.toWaypoints(),
Expand All @@ -87,7 +87,7 @@ class OSRMManager with OSRMHelper {
}

/// [getTrip]
///
///
/// this method used to get route from trip service api
/// used if you have more that 10 waypoint to generate route will more accurate
/// than [getRoad].
Expand All @@ -96,7 +96,7 @@ class OSRMManager with OSRMHelper {
/// [source] and [destination] must be provided.
Future<Road> getTrip({
required List<LngLat> waypoints,
RoadType roadType = RoadType.car,
RoadType? roadType,
bool roundTrip = true,
SourceGeoPointOption source = SourceGeoPointOption.any,
DestinationGeoPointOption destination = DestinationGeoPointOption.any,
Expand All @@ -105,6 +105,8 @@ class OSRMManager with OSRMHelper {
Geometries geometries = Geometries.polyline,
Languages language = Languages.en,
}) async {
roadType ??= this.roadType;

if (!roundTrip &&
(source == SourceGeoPointOption.any ||
destination == DestinationGeoPointOption.any)) {
Expand Down