Class GLRouteRequest

java.lang.Object
globus.glmap.GLNativeObject
globus.glroute.GLRouteRequest

public class GLRouteRequest extends GLNativeObject
GLMapRouteData used request online or offline route.
  • Constructor Details

    • GLRouteRequest

      public GLRouteRequest()
      Default constructor
    • GLRouteRequest

      public GLRouteRequest(@NonNull String userJSON)
      Constructor with custom json request to valhalla
      Parameters:
      userJSON - json request to valhalla
  • Method Details

    • startOnline

      public long startOnline(@NonNull GLRouteRequest.ResultsCallback callback)
      Start online request
      Parameters:
      callback - results callback
      Returns:
      id of task
    • startOffline

      public long startOffline(@NonNull String config, @NonNull GLRouteRequest.ResultsCallback callback)
      Start offline request
      Parameters:
      config - Contents of configuration file for routing engine Valhalla. See valhalla3.json inside the demoApp.
      callback - results callback
      Returns:
      id of task
    • offlineActionOrError

      @Nullable public static Object offlineActionOrError(@NonNull String action, @NonNull String request, @NonNull String config, @Nullable MapGeoPoint startPoint)
      Start synchronous offline request
      Parameters:
      action - valhalla action (eg route, optimized_route, ...)
      request - json string with request
      config - Contents of configuration file for Valhalla routing engine. See valhalla.json inside the demoApp.
      startPoint - start point to optimize navigation data lookup or null otherwise
      Returns:
      string on success or GLMapError on failure
    • cancel

      public static void cancel(long requestID)
      Cancels request that was started
      Parameters:
      requestID - ID of request to cancel
    • addPoint

      public void addPoint(@NonNull GLRoutePoint point)
      Adds point
      Parameters:
      point - point to add
    • addExcludeLocation

      public void addExcludeLocation(@NonNull GLRoutePoint point)
      A location to exclude or avoid
      Parameters:
      point - point to add
    • addExcludePolygon

      public void addExcludePolygon(@NonNull MapGeoPoint[] points)
      Roads intersecting this polygon will be avoided during path finding. If you only need to avoid a few specific roads, it's much more efficient to use exclude locations.
      Parameters:
      points - points of polygon exterior ring
    • setRequestID

      public void setRequestID(@NonNull String requestID)
      Name your route request. If id is specified, the naming will be sent thru to the response.
      Parameters:
      requestID - request id
    • setAutoWithOptions

      public void setAutoWithOptions(@NonNull CostingOptions.Auto options)
      Sets navigation mode to auto
      Parameters:
      options - options
    • setBicycleWithOptions

      public void setBicycleWithOptions(@NonNull CostingOptions.Bicycle options)
      Sets navigation mode to cycle
      Parameters:
      options - options
    • setPedestrianWithOptions

      public void setPedestrianWithOptions(@NonNull CostingOptions.Pedestrian options)
      Sets navigation mode to walk
      Parameters:
      options - options
    • setStraightWithOptions

      public void setStraightWithOptions(@NonNull CostingOptions.Straight options)
      Sets navigation mode to straight
      Parameters:
      options - options
    • setBusWithOptions

      public void setBusWithOptions(@NonNull CostingOptions.Auto options)
      Sets navigation mode to bus
      Parameters:
      options - options
    • setBikeshareWithOptions

      public void setBikeshareWithOptions(@NonNull CostingOptions.Bicycle options)
      Sets navigation mode to bikeshare
      Parameters:
      options - options
    • setTruckWithOptions

      public void setTruckWithOptions(@NonNull CostingOptions.Truck options)
      Sets navigation mode to truck
      Parameters:
      options - options
    • setTaxiWithOptions

      public void setTaxiWithOptions(@NonNull CostingOptions.Auto options)
      Sets navigation mode to taxi
      Parameters:
      options - options
    • setMotorScooterWithOptions

      public void setMotorScooterWithOptions(@NonNull CostingOptions.MotorScooter options)
      Sets navigation mode to scooter
      Parameters:
      options - options
    • setMotorcycleWithOptions

      public void setMotorcycleWithOptions(@NonNull CostingOptions.Motorcycle options)
      Sets navigation mode to motorcycle
      Parameters:
      options - options
    • setOptimize

      public void setOptimize(boolean optimize)
      If `true`, then order of middle points can be changed to make route faster. By default is false.
      Parameters:
      optimize - reorder middle points for better route
    • getOptimize

      public boolean getOptimize()
      Returns:
      current set value
    • getMode

      public int getMode()
      By default `GLRoute.Mode.AUTO`
      Returns:
      Mode of the route
    • setUnitSystem

      public void setUnitSystem(int unitSystem)
      Unit system for instructions. By default `GLUnitSystem.International`
      Parameters:
      unitSystem - unit system for instruction
    • getUnitSystem

      public int getUnitSystem()
      Returns:
      Unit system for instructions.
    • setLocale

      public void setLocale(String locale)
      Locale for instructions By default equals to `Locale.getDefault().getLanguage()`
      Parameters:
      locale - locale for instructions
    • getLocale

      public String getLocale()
      Returns:
      Locale for instructions
    • getJson

      public String getJson()
      Returns:
      Json request that will be sent to valhalla
    • setAlternates

      public void setAlternates(int alternates)
      A number denoting how many alternate routes should be provided. There may be no alternates or less alternates than the user specifies. Alternates are not yet supported on multipoint routes (that is, routes with more than 2 locations). They are also not supported on time dependent routes. By default = 2
      Parameters:
      alternates - alternates to set
    • getAlternates

      public int getAlternates()
      Get number of alternates
      Returns:
      number of alternates
    • bikeTypeToString

      public static String bikeTypeToString(int type)
      Converts BikeType to it's string representation
      Parameters:
      type - type to convert
      Returns:
      string representation of type
    • bikeTypeFromString

      public static int bikeTypeFromString(String type)
      Converts string representation of BikeType to it's value
      Parameters:
      type - type to convert
      Returns:
      value