Class TrafficClient

java.lang.Object
com.azure.maps.traffic.TrafficClient

public final class TrafficClient extends Object
Initializes a new instance of the synchronous TrafficClient type. TrafficClient instances are created via the TrafficClientBuilder, as shown below. Creating a sync client using a AzureKeyCredential:
 // Authenticates using subscription key
 AzureKeyCredential keyCredential = new AzureKeyCredential(System.getenv("SUBSCRIPTION_KEY"));

 // Creates a builder
 TrafficClientBuilder builder = new TrafficClientBuilder();
 builder.credential(keyCredential);
 builder.httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS));

 // Builds the client
 TrafficClient client = builder.buildClient();
 
  • Method Details

    • getTrafficFlowTile

      public com.azure.core.util.BinaryData getTrafficFlowTile(TrafficFlowTileOptions options)
      __Traffic Flow Tile__
       System.out.println("Get Traffic Flow Tile:");
      
       // options
       client.getTrafficFlowTile(
           new TrafficFlowTileOptions()
               .setTrafficFlowTileStyle(TrafficFlowTileStyle.RELATIVE_DELAY).setFormat(TileFormat.PNG).setZoom(10));
      
       // complete
       client.getTrafficFlowTile(
           new TrafficFlowTileOptions()
               .setTrafficFlowTileStyle(TrafficFlowTileStyle.RELATIVE_DELAY).setFormat(TileFormat.PNG).setZoom(10)
               .setTileIndex(new TileIndex().setX(2044).setY(1360)).setThickness(10));
       

      **Applies to**: S0 and S1 pricing tiers.

      The Azure Flow Tile API serves 256 x 256 pixel tiles showing traffic flow. All tiles use the same grid system. Because the traffic tiles use transparent images, they can be layered on top of map tiles to create a compound display. The Flow tiles use colors to indicate either the speed of traffic on different road segments, or the difference between that speed and the free-flow speed on the road segment in question.

      Parameters:
      options - TrafficFlowTileOptions the options to be used in this search.
      Returns:
      the response.
      Throws:
      IllegalArgumentException - thrown if parameters fail the validation.
      com.azure.maps.traffic.implementation.models.ErrorResponseException - thrown if the request is rejected by server.
      RuntimeException - all other wrapped checked exceptions if the request fails to be sent.
    • getTrafficFlowTileWithResponse

      public com.azure.core.http.rest.Response<com.azure.core.util.BinaryData> getTrafficFlowTileWithResponse(TrafficFlowTileOptions options, com.azure.core.util.Context context)
      Get traffic flow tile with response
       System.out.println("Get Traffic Flow Tile:");
      
       // options
       client.getTrafficFlowTile(
           new TrafficFlowTileOptions()
               .setTrafficFlowTileStyle(TrafficFlowTileStyle.RELATIVE_DELAY).setFormat(TileFormat.PNG).setZoom(10));
      
       // complete
       client.getTrafficFlowTile(
           new TrafficFlowTileOptions()
               .setTrafficFlowTileStyle(TrafficFlowTileStyle.RELATIVE_DELAY).setFormat(TileFormat.PNG).setZoom(10)
               .setTileIndex(new TileIndex().setX(2044).setY(1360)).setThickness(10));
       
      Parameters:
      context - The context to associate with this operation.
      options - TrafficFlowTileOptions the options to be used in this search.
      Returns:
      the response
    • getTrafficFlowSegment

      public TrafficFlowSegmentData getTrafficFlowSegment(TrafficFlowSegmentOptions options)
      __Traffic Flow Segment__
       System.out.println("Get Traffic Flow Segment:");
      
       // options
       client.getTrafficFlowSegment(
           new TrafficFlowSegmentOptions()
               .setTrafficFlowSegmentStyle(TrafficFlowSegmentStyle.ABSOLUTE).setZoom(10)
               .setCoordinates(new GeoPosition(4.84239, 52.41072)));
      
       // complete
       client.getTrafficFlowSegment(
           new TrafficFlowSegmentOptions()
               .setTrafficFlowSegmentStyle(TrafficFlowSegmentStyle.ABSOLUTE).setZoom(10)
               .setCoordinates(new GeoPosition(4.84239, 52.41072)).setOpenLr(false)
               .setThickness(2).setUnit(SpeedUnit.MPH));
       

      **Applies to**: S0 and S1 pricing tiers.

      This service provides information about the speeds and travel times of the road fragment closest to the given coordinates. It is designed to work alongside the Flow layer of the Render Service to support clickable flow data visualizations. With this API, the client side can connect any place in the map with flow data on the closest road and present it to the user.

      Parameters:
      options - TrafficFlowSegmentOptions the options to be used in this search.
      Returns:
      this object is returned from a successful Traffic Flow Segment call.
      Throws:
      IllegalArgumentException - thrown if parameters fail the validation.
      com.azure.maps.traffic.implementation.models.ErrorResponseException - thrown if the request is rejected by server.
      RuntimeException - all other wrapped checked exceptions if the request fails to be sent.
    • getTrafficFlowSegmentWithResponse

      public com.azure.core.http.rest.Response<TrafficFlowSegmentData> getTrafficFlowSegmentWithResponse(TrafficFlowSegmentOptions options, com.azure.core.util.Context context)
      Get traffic flow segment with response
       System.out.println("Get Traffic Flow Segment:");
      
       // options
       client.getTrafficFlowSegment(
           new TrafficFlowSegmentOptions()
               .setTrafficFlowSegmentStyle(TrafficFlowSegmentStyle.ABSOLUTE).setZoom(10)
               .setCoordinates(new GeoPosition(4.84239, 52.41072)));
      
       // complete
       client.getTrafficFlowSegment(
           new TrafficFlowSegmentOptions()
               .setTrafficFlowSegmentStyle(TrafficFlowSegmentStyle.ABSOLUTE).setZoom(10)
               .setCoordinates(new GeoPosition(4.84239, 52.41072)).setOpenLr(false)
               .setThickness(2).setUnit(SpeedUnit.MPH));
       
      Parameters:
      context - The context to associate with this operation.
      options - TrafficFlowSegmentOptions the options to be used in this search.
      Returns:
      the response
    • getTrafficIncidentTile

      public com.azure.core.util.BinaryData getTrafficIncidentTile(TrafficIncidentTileOptions options)
      __Traffic Incident Tile__
       System.out.println("Get Traffic Incident Tile:");
      
       // options
       client.getTrafficIncidentTile(
           new TrafficIncidentTileOptions()
               .setFormat(TileFormat.PNG).setTrafficIncidentTileStyle(TrafficIncidentTileStyle.S3)
               .setZoom(10));
      
       // complete
       client.getTrafficIncidentTile(
           new TrafficIncidentTileOptions()
               .setFormat(TileFormat.PNG).setTrafficIncidentTileStyle(TrafficIncidentTileStyle.S3)
               .setZoom(10).setTileIndex(new TileIndex().setX(175).setY(408)));
       

      **Applies to**: S0 and S1 pricing tiers.

      This service serves 256 x 256 pixel tiles showing traffic incidents. All tiles use the same grid system. Because the traffic tiles use transparent images, they can be layered on top of map tiles to create a compound display. Traffic tiles render graphics to indicate traffic on the roads in the specified area.

      Parameters:
      options - TrafficIncidentTileOptions the options to be used in this search.
      Returns:
      the response.
      Throws:
      IllegalArgumentException - thrown if parameters fail the validation.
      com.azure.maps.traffic.implementation.models.ErrorResponseException - thrown if the request is rejected by server.
      RuntimeException - all other wrapped checked exceptions if the request fails to be sent.
    • getTrafficIncidentTileWithResponse

      public com.azure.core.http.rest.Response<com.azure.core.util.BinaryData> getTrafficIncidentTileWithResponse(TrafficIncidentTileOptions options, com.azure.core.util.Context context)
      Traffic Incident Tile
       System.out.println("Get Traffic Incident Tile:");
      
       // options
       client.getTrafficIncidentTile(
           new TrafficIncidentTileOptions()
               .setFormat(TileFormat.PNG).setTrafficIncidentTileStyle(TrafficIncidentTileStyle.S3)
               .setZoom(10));
      
       // complete
       client.getTrafficIncidentTile(
           new TrafficIncidentTileOptions()
               .setFormat(TileFormat.PNG).setTrafficIncidentTileStyle(TrafficIncidentTileStyle.S3)
               .setZoom(10).setTileIndex(new TileIndex().setX(175).setY(408)));
       
      Parameters:
      context - The context to associate with this operation.
      options - TrafficIncidentTileOptions the options to be used in this search.
      Returns:
      the response
    • getTrafficIncidentDetail

      public TrafficIncidentDetail getTrafficIncidentDetail(TrafficIncidentDetailOptions options)
      __Traffic Incident Detail__
       System.out.println("Get Traffic Incident Detail:");
      
       // options
       client.getTrafficIncidentDetail(
           new TrafficIncidentDetailOptions()
               .setBoundingBox(new GeoBoundingBox(45, 45, 45, 45)).setBoundingZoom(11)
               .setIncidentDetailStyle(IncidentDetailStyle.S3).setBoundingZoom(11)
               .setTrafficmodelId("1335294634919"));
      
       // complete
       client.getTrafficIncidentDetail(
           new TrafficIncidentDetailOptions()
               .setBoundingBox(new GeoBoundingBox(45, 45, 45, 45)).setBoundingZoom(11)
               .setIncidentDetailStyle(IncidentDetailStyle.S3).setBoundingZoom(11)
               .setTrafficmodelId("1335294634919").setLanguage("en")
               .setProjectionStandard(ProjectionStandard.EPSG900913).setIncidentGeometryType(IncidentGeometryType.ORIGINAL)
               .setExpandCluster(false).setOriginalPosition(false));
       

      **Applies to**: S0 and S1 pricing tiers.

      This API provides information on traffic incidents inside a given bounding box, based on the current Traffic Model ID. The Traffic Model ID is available to grant synchronization of data between calls and API's. The Traffic Model ID is a key value for determining the currency of traffic incidents. It is updated every minute, and is valid for two minutes before it times out. It is used in rendering [incident tiles](https://docs.microsoft.com/rest/api/maps/traffic/gettrafficincidenttile). It can be obtained from the [Viewport API](https://docs.microsoft.com//rest/api/maps/traffic/gettrafficincidentviewport).

      Parameters:
      options - TrafficIncidentDetailOptions the options to be used in this search.
      Returns:
      this object is returned from a successful Traffic incident Detail call.
      Throws:
      IllegalArgumentException - thrown if parameters fail the validation.
      com.azure.maps.traffic.implementation.models.ErrorResponseException - thrown if the request is rejected by server.
      RuntimeException - all other wrapped checked exceptions if the request fails to be sent.
    • getTrafficIncidentDetailWithResponse

      public com.azure.core.http.rest.Response<TrafficIncidentDetail> getTrafficIncidentDetailWithResponse(TrafficIncidentDetailOptions options, com.azure.core.util.Context context)
      Get traffic incident detail with response
       System.out.println("Get Traffic Incident Detail:");
      
       // options
       client.getTrafficIncidentDetail(
           new TrafficIncidentDetailOptions()
               .setBoundingBox(new GeoBoundingBox(45, 45, 45, 45)).setBoundingZoom(11)
               .setIncidentDetailStyle(IncidentDetailStyle.S3).setBoundingZoom(11)
               .setTrafficmodelId("1335294634919"));
      
       // complete
       client.getTrafficIncidentDetail(
           new TrafficIncidentDetailOptions()
               .setBoundingBox(new GeoBoundingBox(45, 45, 45, 45)).setBoundingZoom(11)
               .setIncidentDetailStyle(IncidentDetailStyle.S3).setBoundingZoom(11)
               .setTrafficmodelId("1335294634919").setLanguage("en")
               .setProjectionStandard(ProjectionStandard.EPSG900913).setIncidentGeometryType(IncidentGeometryType.ORIGINAL)
               .setExpandCluster(false).setOriginalPosition(false));
       
      Parameters:
      context - The context to associate with this operation.
      options - TrafficIncidentDetailOptions the options to be used in this search.
      Returns:
      the response
    • getTrafficIncidentViewport

      public TrafficIncidentViewport getTrafficIncidentViewport(TrafficIncidentViewportOptions options)
      __Traffic Incident Viewport__
       System.out.println("Get Traffic Incident Tile:");
      
       // options
       client.getTrafficIncidentViewport(
           new TrafficIncidentViewportOptions()
               .setBoundingBox(new GeoBoundingBox(45, 45, 45, 45))
               .setBoundingZoom(2).setOverview(new GeoBoundingBox(45, 45, 45, 45))
               .setOverviewZoom(2));
      
       // complete
       client.getTrafficIncidentViewport(
           new TrafficIncidentViewportOptions()
               .setBoundingBox(new GeoBoundingBox(45, 45, 45, 45))
               .setBoundingZoom(2).setOverview(new GeoBoundingBox(45, 45, 45, 45))
               .setOverviewZoom(2).setCopyright(true));
       

      **Applies to**: S0 and S1 pricing tiers.

      This API returns legal and technical information for the viewport described in the request. It should be called by client applications whenever the viewport changes (for instance, through zooming, panning, going to a location, or displaying a route). The request should contain the bounding box and zoom level of the viewport whose information is needed. The return will contain map version information, as well as the current Traffic Model ID and copyright IDs. The Traffic Model ID returned by the Viewport Description is used by other APIs to retrieve last traffic information for further processing.

      Parameters:
      options - TrafficIncidentViewportOptions the options to be used in this search.
      Returns:
      this object is returned from a successful Traffic Incident Viewport call.
      Throws:
      IllegalArgumentException - thrown if parameters fail the validation.
      com.azure.maps.traffic.implementation.models.ErrorResponseException - thrown if the request is rejected by server.
      RuntimeException - all other wrapped checked exceptions if the request fails to be sent.
    • getTrafficIncidentViewportWithResponse

      public com.azure.core.http.rest.Response<TrafficIncidentViewport> getTrafficIncidentViewportWithResponse(TrafficIncidentViewportOptions options, com.azure.core.util.Context context)
      Get traffic incident viewport with response
       System.out.println("Get Traffic Incident Tile:");
      
       // options
       client.getTrafficIncidentViewport(
           new TrafficIncidentViewportOptions()
               .setBoundingBox(new GeoBoundingBox(45, 45, 45, 45))
               .setBoundingZoom(2).setOverview(new GeoBoundingBox(45, 45, 45, 45))
               .setOverviewZoom(2));
      
       // complete
       client.getTrafficIncidentViewport(
           new TrafficIncidentViewportOptions()
               .setBoundingBox(new GeoBoundingBox(45, 45, 45, 45))
               .setBoundingZoom(2).setOverview(new GeoBoundingBox(45, 45, 45, 45))
               .setOverviewZoom(2).setCopyright(true));
       
      Parameters:
      context - The context to associate with this operation.
      options - TrafficIncidentViewportOptions the options to be used in this search.
      Returns:
      the response