HERE Traffic フロー カタログは、ドライバーがストレスのない方法で効率的に目的地に到着できるよう支援します。 カタログでは、交通状況や、通常よりも遅い交通状況、道路工事、事故など、遅延の原因となる可能性のある事故についての最新情報を提供しています。 さらに、高速道路や動脈の交通状況を表示することができ、交通状況を把握できる到着予定時間( ETA )を計算するための要素となります。
olp catalog show hrn:here:data::olp-here:here-traffic-flow-v2
出力には、次の情報が含まれている必要があります。
ID here-traffic-flow-v2
name HERE Traffic Flow (new)
HRN hrn:here:data::olp-here:here-traffic-flow-v2
summary "HERE RealTime Traffic Flow" provides live information on traffic conditions on roadways.
description "HERE RealTime Traffic Flow" provides a live depiction of conditions on the road. It identifies where traffic congestion occurs, and how bad it is, delivering minute-by-minute information on road conditions that could set a driver back.
Real-time traffic data is produced by a sophisticated model that aggregates and analyzes a mix of sources, including high-quality rich vehicle sensor data.
The result: best-in-class accuracy in depicting real-world traffic conditions.
notifications enabled? false
tags TrafficItem, TrafficItems, flow, traffic, RealtimeTraffic
billing tags 10648TAppsProd
created 2022-02-11T21:10:59.475863Z
owner HERE-e64d84b3-556e-4f69-ac85-e615cc2c2cab, olp-here
config version 4
metadata version -1
metadata minimum version -1
marketplace ready false
layers
type ID name
volatile realtime-traffic-flow-volatile RealTime Traffic Flow (v2)
replication
role ID
primary eu-ireland
olp catalog layer show hrn:here:data::olp-here:here-traffic-flow-v2 realtime-traffic-flow-volatile
出力には、次の情報が含まれている必要があります。
Details of the realtime-traffic-flow-volatile layer:
ID realtime-traffic-flow-volatile
name RealTime Traffic Flow (v2)
summary RealtimeFlow 3.3
description The traffic flow layer provides the current speed of traffic on roads. Powered by HERE Traffic, the speeds are updated every minute.
Each tile contains Protobuf data, which is a list of all the current traffic flow messages based on the Traffic schema. Any message which spans across multiple tiles will be reported in all tiles where it exists, with the same ID.
layerType volatile
partitioning heretile, tile levels: 12
partitioningScheme heretile
volume volatile
contentType application/x-protobuf
schema hrn:here:schema::olp-here:com.here.traffic.realtime:traffic_v2:2.1.15
tags TOLP
billingTags 10648TAppsProd
coverage US
created 2022-02-11T21:35:45.216436Z
volatileProperties {"dataRedundancy":"multi-instance","storageCapacityMb":21000}
TTL 3600000
Segment メッセージで最後に使用されたメッセージは Lane 、道路の個々の車線の交通速度に関する情報を含むメッセージです。 このメッセージは、道路沿いに異なる車線速度がある場合にのみ表示されます。
メッセージ定義は次 flow.proto のファイルにあります。
syntax = "proto3";
package com.here.traffic.realtime.v2;
import "com/here/traffic/realtime/v2/LocationTypes.proto";
/**
The `Flow` message contains information about the speed of traffic on one or
more road segments. The segments contained by a flow are determined by
algorithms in the Open Location Platform.
*/
message Flow {
/**
One or more messages containing information about the flow of traffic on
a section of roadway, or "segment". If a `Flow` message contains multiple
`segment` messages, the segments represent
connected sections of the roadway and are ordered in the driving direction.
Each `segment` contains a start_offset field which defines the ratio of
this segment to the overall Flow message. The congestion level for this
segment is of value 1, i.e. CONSERVATIVE.
*/
repeated Segment segment = 1;
/**
A number from 0.0 to 1.0 indicating the percentage of real-time data used
in the speed calculation.
You can use this field to identify whether the data for this `Flow` is
derived from real-time probe sources or historical information only.
Confidence is only available for the `Flow` message and applies to all
`Segment` messages.
- 0.71 to 1.0: Real-time speeds were used to calculate the traffic speed
for the `Flow`. A value of 0.75 or greater indicates high confidence
real-time information.
- 0.5 to 0.7: Historical speeds were used to calculate the traffic
speed for the `Flow`.
- 0.0 to 0.5: The speed limit was used to calculate the speed of
traffic for the `Flow`.
- -1.0: The road is closed
*/
double confidence = 2;
/**
DEPRECATED. Flow conditions for supplementary location reference,
one for each applicable location type
*/
repeated SupplementaryFlowCondition supplementary_flow_condition
= 3 [deprecated = true];
/**
Additional segments for congestion levels 2 and 3.
*/
repeated CongestionLevelCodedSegments congestion_level_coded_segments_list
= 4;
}
/**
Congestion level Option specifies the desired level of “aggressiveness”
to represent the traffic condition.
The client can decide which CF element, if encoded, to utilize.
*/
enum CongestionLevelOption {
UNKNOWN = 0;
CONSERVATIVE = 1;
MEDIUM_AGGRESSIVE = 2;
MOST_AGGRESSIVE = 3;
}
/**
Segments coded according to congestion level option
*/
message CongestionLevelCodedSegments {
//Congestion level option identifier
CongestionLevelOption congestion_level_option = 1;
//One or more segments for the congestion level
repeated Segment segments = 2;
}
/**
The `Segment` message contains information about the flow of traffic on a
section of roadway.
*/
message Segment {
/**
Information about the speed of traffic for this segment.
*/
Speed speed = 1;
/**
A number between 0.0 and 10.0 indicating how freely traffic is flowing.
A value of 0 means traffic is flowing freely. A value of 10 means
traffic is stopped.
A value of -1.0 indicates that `jam_factor` could not be calculated.
If a road is closed, `jam_factor` is 10.
If a road is reversible and traffic is flowing opposite the driving direction,
`jam_factor` is -1. This value is useful when displaying traffic on a map
and you do not want to display the road as closed.
*/
double jam_factor = 2;
/**
The offset ratio from the start of this segment in relation to the entire
traffic condition.
*/
double start_offset = 3;
/**
Specifies whether the segment is traversable.
See `Flow.TraversabilityStatus` for valid values.
*/
TraversabilityStatus traversability_status = 4;
/**
The traffic condition in each lane. The `lanes` field is only provided
if there are different lane condition along a roadway.
When there is lane-level traffic along a roadway, there will be two or
more `Lane` messages in the `Segment`.
*/
repeated Lane lanes = 5;
//The junction traversability status.
JunctionTraversabilityStatus junction_traversability_status = 6;
//Length of the segment in km
double segment_length_in_km = 7;
//The lane type for this road segment
BasicLaneType basic_lane_type = 8;
//Trend of jam factor
JamFactorTrend jam_factor_trend = 9;
//Flow conditions and causes based on TFP
TFPCode tfp_code = 10;
/**
Flow conditions and causes codes based on specification of TISA TPEG2-TFP_1.1
*/
message TFPCode {
//The tfp006 cause of the traffic flow.
int32 cause_code = 1;
//Status parameters per TFP specification.
StatusParameters status_parameters = 2;
//Statistical parameters per TFP specification.
StatisticalParameters statistical_parameters = 3;
//The vehicle restriction per TFP specification.
Restrictions restriction = 4;
}
//At-grade junction traversability status. Used for road
//closures to indicate if the closure can be crossed.
enum JunctionTraversabilityStatus {
UNKNOWN = 0;
ALL_JUNCTIONS_CLOSED = 1;
INTERMEDIATE_CLOSED_EDGE_OPEN = 2;
ALL_JUNCTIONS_OPEN = 3;
}
/**
The basic type of the lane.
*/
enum BasicLaneType {
//Regular traffic lane
TRAFFIC_LANE = 0;
//Express lane
EXPRESS = 1;
//Ramp lane
RAMP = 2;
//Entry lane;
ENTRY = 3;
//EXIT lane
EXIT = 4;
}
/**
The flow status parameters.
*/
message StatusParameters {
//The tfp003 Level Of Service code.
int32 level_of_service = 1;
//The achievable average speed in km/h.
int32 average_speed_in_kmh = 2;
//The time in seconds it takes to traverse the affected
//road segment under free flow traffic conditions.
int32 free_flow_travel_time_in_seconds = 3;
//The delay on the road segment in seconds.
int32 delay_in_seconds= 4;
}
/**
The statistical parameters based on TISA TPEG2-TFP_1.1.
*/
message StatisticalParameters {
//The risk (%) that a congestion
// (LOS level 'stationary traffic' or 'blocked') will occur
// at this road section.
int32 congestion_probability = 1;
//TFP based value Used to determine the risk that the travel time
// may exceed the expected travel time considerably.
int32 t90_relative = 2;
//The tfp008 flow data quality
int32 flow_data_quality = 3;
//This parameter may be used to link to a LOS prediction pattern.
int32 prediction = 4;
}
/**
tfp based information on restrictions related to the reported traffic flow
*/
message Restrictions {
//The tfp001 Vehicle class
int32 vehicle_class_assignment = 1;
//The tfp002 vehicle Credentials
int32 vehicle_credentials = 2;
//The tfp005 lane restrictions
int32 lane_restriction = 3;
//Angle of an entry/exit to the road stretch in 360/255 degree steps
// clockwise to the direction of the road stretch at the entry/exit point
int32 angle = 4;
//Length affected in 10 meter steps
int32 length_in_ten_meters_steps = 5;
}
}
/**
The `Speed` message contains information about the velocity of traffic
traveling along the segment.
*/
message Speed {
/**
The average speed that traffic is traveling, in Kilometers per hour.
A value of -1.0 indicates that the average speed could not be calculated.
*/
double average_speed_kph = 1;
/**
The average speed that traffic is traveling, but limited to the speed limit.
If the traffic speed is greater than the speed limit, the value of this
field will be the speed limit instead of the actual
traffic speed. The speed is in in Kilometers per hour.
A value of -1.0 indicates that the average speed could not be calculated.
*/
double average_speed_capped_kph = 2;
/**
The speed at which vehicles can travel the segment when there is no traffic
congestion or other impediments such as a road closure.
This speed is calculated as the 80th percentile of observed speeds
during non-rush hour periods.
Free flow is useful for understanding the level of congestion.
When the average speed is greater than or equal to the free flow speed,
it can be assumed that there is no traffic congestion.
*/
double free_flow_speed_kph = 3;
}
/**
The `TraversablityStatus` field indicates whether a segment is open to traffic.
- `OPEN`: The segment is open for traffic. This includes reversible roads
that are open.
- `CLOSED`: The segment is closed to traffic. No `Speed` messages will be
provided for this segment.
- `ROAD_NOT_ROUTABLE`: The segment is restricted from carrying traffic.
In some situations, portions of a reversible road will be marked as CLOSED
rather than ROAD_NOT_ROUTABLE. This can happen when both directions of the
reversible road are closed, such as for construction or major accidents.
In a map display, we recommend that you use ROAD_NOT_ROUTABLE to indicate that
the road is not routable, the road segment is not drivable, and not to show
traffic on this roadway.
*/
enum TraversabilityStatus {
OPEN = 0;
CLOSED = 1;
ROAD_NOT_ROUTABLE = 2;
}
/**
Trend of Jam Factor
*/
enum JamFactorTrend {
CONSTANT_CONGESTION = 0;
DECREASING_CONGESTION = 1;
RAPIDLY_DECREASING_CONGESTION = 2;
INCREASING_CONGESTION = 3;
RAPIDLY_INCREASING_CONGESTION = 4;
}
/**
The `Lane` message contains information about the speed of traffic in individual
lanes in a roadway. A `Lane` message is only provided if there are different
lane speeds along a roadway.
The number of lanes along a roadway can be determined by looking at the maximum
lane number in all `Lane` messages in the segment.
*/
message Lane {
/**
A list of lanes associated with the traffic. Lane numbers use the HERE Map
method of lane numbering where the left lane is 1 and each lane to the
right of the left lane is numbered sequentially. For example, in a
three-lane road, the left lane is 1, the center lane is 2, and the right
lane is 3. Lane 1 is always the left lane, regardless of the driving side.
If multiple lane numbers are presented, all lanes will have the traffic
condition. Lane numbers will always be sequential.
*/
repeated int32 lane_number = 1;
/**
A Flow.Speed message containing the traffic speed for this lane.
*/
Speed speed = 2;
/**
The jam factor for this `Lane`. See `jam_factor` field in `Segment` message
for definition.
*/
double jam_factor = 3;
//Additional lane type information
SpecialtyLaneType lane_type = 4;
//More granular trend information of jam factor
JamFactorTrend jam_factor_trend = 5;
//Zero or more arterial turn lane information
repeated ArterialTurnLane arterial_turn_lanes = 6;
/**
Specialty lane types
*/
enum SpecialtyLaneType {
REGULAR = 0;
HOV = 1;
ARTERIAL_TURN = 2;
}
/**
ArterialTurnLane message is provided if there are one or more Arterial Turn Lane
events associated with this lane.
*/
message ArterialTurnLane {
//To Bearing is the bearing associated with the Arterial Turn
//Lane maneuver. Bearing is the relative angle (degrees 0-359)
//based on the link prior to intersection and the successor link
//after the maneuver. For example, a right turn is represented
//by TB=90, straight is TB=0, and left turn is TB=270.
int32 to_bearing = 1;
//To LinkID is the successor linkID associated with the
//maneuver. The linkID will be in driving direction order; “F”
//represents travel direction FROM reference node, “T”
//represents travel direction TO reference node.
string to_here_map_link_id = 2;
//The extra delay in seconds that corresponds to the maneuver.
//This delay time is extra delay in addition to the the time of
//the speed reported at segment level.
int32 extra_delay_in_seconds = 3;
//The average speed, not capped by speed limit, on these lanes
//of traffic that current traffic is travelling.
double average_speed_in_kph = 4;
//The number between 0.0 and 10.0 indicating the expected
//quality of travel.
double jam_factor = 5;
}
}
トポロジセグメント ID に関する情報を含む速度項目リストを取得し、特定のセグメント ID で結果をフィルタリングすることで、トラフィックに関する情報を含むすべてのセグメントを取得します。202981252, 203203107 82419435。
Scala
Java
/*
* Copyright (c) 2018-2023 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/import akka.NotUsed
importakka.actor.{ActorSystem, CoordinatedShutdown}importakka.stream.ActorMaterializer
importakka.stream.javadsl.{Sink, Source}importcom.here.hrn.HRN
importcom.here.platform.data.client.common.VolatilePartitionsFilter.byIds
importcom.here.platform.data.client.engine.javadsl.{DataEngine, ReadEngine}importcom.here.platform.data.client.javadsl.{DataClient, Partition, QueryApi}importcom.here.platform.data.client.model.AdditionalFields
importcom.here.traffic.realtime.v2.Traffic.TrafficItems
importscala.collection.convert.ImplicitConversions.`collection AsScalaIterable`
importscala.concurrent.ExecutionContext.Implicits.global
object RealTimeTrafficTutorialScala {privateval FLOW_CATALOG = HRN.fromString("hrn:here:data::olp-here:here-traffic-flow-v2")privateval FLOW_LAYER ="realtime-traffic-flow-volatile"def main(args: Array[String]):Unit={val actorSystem: ActorSystem = ActorSystem.create("flow")val actorMaterializer: ActorMaterializer = ActorMaterializer.create(actorSystem)val queryApi: QueryApi = DataClient.get(actorSystem).queryApi(FLOW_CATALOG)val readEngine: ReadEngine = DataEngine.get(actorSystem).readEngine(FLOW_CATALOG)val berlinCityCenterTileId ="23618402"val segmentsIdForStreet = List(202981252,203203107,82419435)// Step 1: Retrieve Partition metadata for the given Brandenburg Gate Tile ID on zoom level 8val partition = queryApi
.getVolatilePartitions(FLOW_LAYER,
byIds(Set(berlinCityCenterTileId)),
AdditionalFields.AllFields).thenCompose((partitionsSource: Source[Partition, NotUsed])=>
partitionsSource.runWith(Sink.head(), actorMaterializer)).toCompletableFuture
.join()// Step 2: Download partition for the given `Brandenburg Gate` Tile ID on zoom level `12`val partDownloadedTraffic = readEngine.getDataAsBytes(partition).toCompletableFuture.join()// Step 3: Parse real-time traffic dataval speedsTrafficItems = TrafficItems.parseFrom(partDownloadedTraffic)// Step 4: Fetch speed item list that contains information about topology segment IDs// and then get all segments with information about traffic// by filtering results by given segments IDs: `202981252, 203203107 82419435`.val realTimeTraffic = speedsTrafficItems.getItemsList
.filter(item =>
item.getTopologySegment.getTopologySegmentIdList.exists(segmentsIdForStreet.contains)).flatMap(traffic => traffic.getFlow.getSegmentList)
printf(
s"The real-time traffic data for the given segments Ids [${segmentsIdForStreet.map(_.longValue()).mkString(",")}] is: $realTimeTraffic")
CoordinatedShutdown
.get(actorSystem).run(CoordinatedShutdown.unknownReason).onComplete(print)}}
/*
* Copyright (c) 2018-2023 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/importakka.actor.ActorSystem;importakka.actor.CoordinatedShutdown;importakka.stream.ActorMaterializer;importakka.stream.javadsl.Sink;importcom.google.protobuf.InvalidProtocolBufferException;importcom.here.hrn.HRN;importcom.here.platform.data.client.common.VolatilePartitionsFilter;importcom.here.platform.data.client.engine.javadsl.DataEngine;importcom.here.platform.data.client.engine.javadsl.ReadEngine;importcom.here.platform.data.client.javadsl.DataClient;importcom.here.platform.data.client.javadsl.Partition;importcom.here.platform.data.client.javadsl.QueryApi;importcom.here.traffic.realtime.v2.*;importjava.util.*;importjava.util.concurrent.ExecutionException;importjava.util.stream.Collectors;publicclassRealTimeTrafficTutorial{privatestaticfinalHRN FLOW_CATALOG =
HRN.fromString("hrn:here:data::olp-here:here-traffic-flow-v2");privatestaticfinalString FLOW_LAYER ="realtime-traffic-flow-volatile";publicstaticvoidmain(String[] args)throwsExecutionException,InterruptedException,InvalidProtocolBufferException{ActorSystem actorSystem =ActorSystem.create("flow");ActorMaterializer actorMaterializer =ActorMaterializer.create(actorSystem);QueryApi queryApi =DataClient.get(actorSystem).queryApi(FLOW_CATALOG);ReadEngine readEngine =DataEngine.get(actorSystem).readEngine(FLOW_CATALOG);String berlinCityCenterTileId ="23618402";List<Integer> segmentsIdForStreet =newArrayList<>(Arrays.asList(202981252,203203107,82419435));// Step 1: Retrieve Partition metadata for the given Brandenburg Gate Tile ID on zoom level 8Partition partition =
queryApi
.getVolatilePartitions(
FLOW_LAYER,newVolatilePartitionsFilter.Builder().withIds(Collections.singleton(berlinCityCenterTileId)).build(),Collections.emptySet()).thenCompose(
partitionsSource -> partitionsSource.runWith(Sink.head(), actorMaterializer)).toCompletableFuture().join();// Step 2: Download partition for the given `Brandenburg Gate` Tile ID on zoom level `12`byte[] partDownloadedTraffic = readEngine.getDataAsBytes(partition).toCompletableFuture().get();// Step 3: Parse real-time traffic dataTraffic.TrafficItems speedsTrafficItems =Traffic.TrafficItems.parseFrom(partDownloadedTraffic);// Step 4: Fetch speed item list that contains information about topology segment IDs// and then get all segments with information about traffic// by filtering results by given segments IDs: `202981252, 203203107 82419435`.List<FlowOuterClass.Segment> realTimeTraffic =
speedsTrafficItems
.getItemsList().stream().filter(
item ->!Collections.disjoint(
item.getTopologySegment().getTopologySegmentIdList(), segmentsIdForStreet)).flatMap(t -> t.getFlow().getSegmentList().stream()).collect(Collectors.toList());System.out.printf("The real-time traffic data for the given segments Ids %s is: %s",
segmentsIdForStreet, realTimeTraffic);CoordinatedShutdown.get(actorSystem).run(CoordinatedShutdown.unknownReason(),Optional.empty()).toCompletableFuture().join();}}