ガイド変更履歴HERE SDK API references
ガイド

トラックをナビゲートする

ナビゲーションはNavigateライセンスでのみ利用できます。

HERE SDKは、さまざまな機能によってトラックのルーティングとガイダンスをサポートしています。たとえば、リスナーを実装して、ナビゲーション中に狭いトンネルなど前方のトラック制約について通知を受け取ることができます。可能性のある制限の他の例としては、大型トラックが通過するのに十分な高さがない橋、トラックの重量が道路の許容重量を超えた道路などがあります。

次のコードスニペットを参照してください。

// Notifies truck drivers on road restrictions ahead. Called whenever there is a change.
visualNavigator.setTruckRestrictionsWarningListener(new TruckRestrictionsWarningListener() {
    @Override
    public void onTruckRestrictionsWarningUpdated(@NonNull List<TruckRestrictionWarning> list) {
        // The list is guaranteed to be non-empty.
        for (TruckRestrictionWarning truckRestrictionWarning : list) {
            if (truckRestrictionWarning.distanceType == DistanceType.AHEAD) {
                Log.d(TAG, "TruckRestrictionWarning ahead in: "+ truckRestrictionWarning.distanceInMeters + " meters.");
                if (truckRestrictionWarning.timeRule != null && !truckRestrictionWarning.timeRule.appliesTo(new Date())) {
                  // For example, during a specific time period of a day, some truck restriction warnings do not apply.
                  // If truckRestrictionWarning.timeRule is null, the warning applies at anytime.
                  Log.d(TAG, "Note that this truck restriction warning currently does not apply.");
                }
            } else if (truckRestrictionWarning.distanceType == DistanceType.REACHED) {
                Log.d(TAG, "A restriction has been reached.");
            } else if (truckRestrictionWarning.distanceType == DistanceType.PASSED) {
                // If not preceded by a "REACHED"-notification, this restriction was valid only for the passed location.
                Log.d(TAG, "A restriction just passed.");
            }

            // One of the following restrictions applies ahead, if more restrictions apply at the same time,
            // they are part of another TruckRestrictionWarning element contained in the list.
            if (truckRestrictionWarning.weightRestriction != null) {
                WeightRestrictionType type = truckRestrictionWarning.weightRestriction.type;
                int value = truckRestrictionWarning.weightRestriction.valueInKilograms;
                Log.d(TAG, "TruckRestriction for weight (kg): " + type.name() + ": " + value);
            } else if (truckRestrictionWarning.dimensionRestriction != null) {
                // Can be either a length, width or height restriction of the truck. For example, a height
                // restriction can apply for a tunnel. Other possible restrictions are delivered in
                // separate TruckRestrictionWarning objects contained in the list, if any.
                DimensionRestrictionType type = truckRestrictionWarning.dimensionRestriction.type;
                int value = truckRestrictionWarning.dimensionRestriction.valueInCentimeters;
                Log.d(TAG, "TruckRestriction for dimension: " + type.name() + ": " + value);
            } else {
                Log.d(TAG, "TruckRestriction: General restriction - no trucks allowed.");
            }
        }
    }
});

DistanceType.REACHED はトラック制約のある場所に達すると通知します。規制のある場所を通過すると、このイベントの後に PASSED が送信されます。長さの規制がない場合は、REACHED はスキップされ、PASSED イベントのみが送信されます。AHEAD イベントは常に最初に送信されます。

各距離タイプの制限が通知されるのは1回のみです。更新された距離情報を継続してドライバーに通知する場合は、目的地までの頻繁な距離更新が含まれるRouteProgressをトラッキングすることで継続して通知できます。

すべての制限がnilの場合は、トラックに関する一般的な制約が適用されます。

規制の警告を地図上の MapFeatures.VEHICLE_RESTRICTIONS レイヤーと比較したときに、一部の制限は道路の一方向に対してのみ有効な場合があります。

null のルートを設定する、または新しいルートを設定してガイダンスが停止すると、AHEAD 通知で知らされた制限は即座に PASSED イベントになり、保留中の制限警告はクリアされます。ルートを追随している間はルート上にない制限は除外されますが、ドライバーがルートから十分な距離 (15 m以上) を逸脱するとすぐに、その道路の前方にあるサポート対象の制限は再び制限警告に結びつきます。

トラック制約の通知しきい値は、他の警告と若干異なります。こちらに記載されたしきい値を確認してください。

TruckRestrictionWarningイベントは、前方の道路ネットワークのマップデータに基づいています。現在の設定されているTransportModeに関係なく、制限を配信します。

ルートを計算するときに、TruckSpecificationsを含めてTruckOptionsを指定できます。これは、結果のRouteに影響します。ただし、TruckRestrictionWarningイベントには影響しません。前方のマップデータにあるほとんどの制限は転送されます。そのため、現在の車に関係のない制限警告を除外することがアプリケーションにとって合理的な場合があります。追随するルートがない場合は、トラッキングモードでもこのイベントによってイベントが配信されます。

トラックのルーティングの詳細については、ルート検索のセクションを参照してください。たとえば、トラック専用のルートを計算する方法を見つけることができます。一般に、ルートにTruckの交通機関タイプが含まれている場合は、トラックに最適化されています。

さらに、特定の市街エリアを除外するなど、いくつかの回避設定オプションを指定できます。これはすべて、ルートが計算されてNavigatorまたはVisualNavigatorに渡される前に指定できます。

以下のような機能もあります。

  • TruckSpecificationsおよびHazardousGoodのリストが含まれたTruckOptionsで、トラックの寸法や、トラックが危険物を運搬しているかどうかなどの車両制限を指定できます。この情報によって、トラックのルートを構想できます。前方にあるトラック制約について通知を受けるには、上に示されているTruckRestrictionWarningイベントをリッスンします。
  • 前述したように特定の RoadAttributes をリッスンできます。
  • 移動モードが TRUCK に設定されている場合、SpeedLimit イベントは商用車規制 (CVR) の制限速度を示します。これは自動車よりも低速な場合があります。ルートを計算するときには、RouteOptions内のTruckSpecificationsを指定することも検討します。トラッキングモードの場合は、navigator.setTrackingTransportProfile(vehicleProfile)を呼び出し、TRUCK移動モードでVehicleProfileを設定します。トラッキングのデフォルトでは、CAR が想定されています。重量など、トラックに応じたその他の車両属性を必ず指定してください。
  • 特記する点として、grossWeightInKilogramsおよびweightInKilogramsはCVRの制限速度の他、ルート制限、予想到着時間に影響します。適切なTruckSpecificationsを設定しないと、ルートや通知が不適切なものになる可能性があります。
  • AvoidanceOptionsを使用して排気ガス規制ゾーンを除外し、排気ガスの影響を受けやすい都心部の大気汚染を避けることができます。この方法では、トンネルなどの特定のRoadFeaturesも回避できます。これらはTruckOptionsで設定でき、ルート計算から除外されます。
  • セーフティ カメラ アイコンを地図に表示する、MapScene.Layers.SAFETY_CAMERAS マップ レイヤー スキームを有効にできます。注:このレイヤーは普通車にも適しています。
  • トラック固有の情報を地図上に表示するように最適化された、MapScene.Layers.VEHICLE_RESTRICTIONS マップ レイヤー スキームを有効にできます。いくつかのMapFeatureModesが提供されています。たとえば、影響を受ける道路上でアクティブな制限と非アクティブな制限を強調表示するために紫色の線を使用します。灰色の線または灰色のアイコンは制限が非アクティブであることを示します。道路がその紫色の線と交差している場合、道路自体が紫色で示されていない場合は、この制限は現在の道路には適用されません。アイコンは必ずしも正確な場所を示すわけではありません。たとえば、制限のある道路の場合には、制限のある道路の中央にアイコンが配置されることがあります。また、制限が長く続く場合には、1つの道路または複数の道路上の同じ制限に対してアイコンが数回にわたり繰り返されることがあります。アイコン自体は国に応じてローカライズされており、制限のタイプが示されています。ほとんどの制限では、制限の場所とタイプもTruckRestrictionWarningイベントによって示されます (上の例を参照)。
  • PlaceDetailsにシャワーやトイレの情報が含まれたTruckAmenitiesを使用します。ルートの軌道に沿って検索し、場所にトラックのアメニティが含まれているかどうかを確認します。オンラインで使用する場合、TruckAmenitiesの取得にはname"show"に、value"truck"にしてsearchEngine.setCustomOption()を呼び出し、クローズドアルファ版の機能を有効にする必要があります。また、追加のライセンスも必要です。OfflineSearchEngineで使用する場合 (お使いのライセンスで利用可能であれば)、ライセンスは不要です。オンラインアクセス権を取得するには、当社までお問い合わせください。資格情報が有効になっていない場合、ライセンスが不足していることを示すSearchError.forbiddenエラーが表示されます。

車両制限レイヤーを構成する

以下のスクリーンショットは、VEHICLE_RESTRICTIONSマップフィーチャーが有効になっているときに地図上に表示される利用可能な車両制限アイコンの選択を示しています。

車両制限が有効な場合に、指定した条件に一致するアイコンのみを表示するように、MapContentSettings.configureVehicleRestrictionFilter(...)を介してMapFeatures.VEHICLE_RESTRICTIONSのフィルターを構成できます。MapScene.enableFeaturesを使用してフィーチャーを有効にし、MapScene.setLayerVisibilityを使用してレイヤーの表示設定を行ったマップフィーチャーレイヤーMapFeatures.VEHICLE_RESTRICTIONSを有効にすることで、車両制限の表示を有効にできます。

指定されたパラメーターセットからアイコンを作成するIconProvider.createVehicleRestrictionIcon​(...)を使用して、車両制限アイコンを作成できます。マップコンテンツの選択結果に基づいて、地図上に表示される車両制限を表すか、地図上に表示されるとおりに作成されたアイコンを構成できます。

地図に合わせて最適化されたアイコンを含むアイコンを読み込むためのIconProviderAssetType.MAPと、UIに合わせて最適化されたアイコンを含むアイコンを読み込むためのIconProviderAssetType.UIもHERE SDKには用意されています。

また、HERE SDKの抽出されたバイナリ内にあるgeoviz/assets/osloディレクトリの下に、SVG形式で使用できるすべてのアイコンがあります。

実装の詳細については、次のコードスニペットを参照してください。

// Configure the displayed vehicle restrictions.
// Only the specified types will be shown. For example, when TRUCK is set, then only
// icons applicable for trucks are displayed.
// TunnelCategory are closely related to the HazardousMaterial.
// Tunnels are categorized from B (low risk, few restrictions) to E (high risk)
// based on their safety features and the potential danger posed by the goods
// transported through them.
private void configureVehicleRestrictionFilter() {
        List<HazardousMaterial> hazardousMaterials = new ArrayList<>();
        hazardousMaterials.add(HazardousMaterial.EXPLOSIVE);
        hazardousMaterials.add(HazardousMaterial.FLAMMABLE);

        TruckSpecifications truckSpecifications = createTruckSpecifications();

        VehicleSpecification.TruckBuilder truckBuilder = new VehicleSpecification.TruckBuilder()
                .withGrossWeightInKilograms(truckSpecifications.grossWeightInKilograms)
                .withHeightInCentimeters(truckSpecifications.heightInCentimeters)
                .withWidthInCentimeters(truckSpecifications.widthInCentimeters)
                .withLengthInCentimeters(truckSpecifications.lengthInCentimeters)
                .withTruckCategory(MyTruckSpecs.truckCategory)
                .withTunnelCategory(TunnelCategory.B)
                .withHazardousMaterials(hazardousMaterials);

        if (truckSpecifications.weightPerAxleInKilograms != null) {
            truckBuilder.withWeightPerAxleInKilograms(truckSpecifications.weightPerAxleInKilograms);
        }
        if (truckSpecifications.axleCount != null) {
            truckBuilder.withAxleCount(truckSpecifications.axleCount);
        }
        if (truckSpecifications.trailerCount != null) {
            truckBuilder.withTrailerCount(truckSpecifications.trailerCount);
        }

        VehicleSpecification vehicleSpecification = truckBuilder.build();

        TransportSpecification transportSpecification = new TransportSpecification.TruckBuilder()
                .withVehicleSpecification(vehicleSpecification)
                .build();

        MapContentSettings.configureVehicleRestrictionFilter(transportSpecification);
    }

private TruckSpecifications createTruckSpecifications() {
    TruckSpecifications truckSpecifications = new TruckSpecifications();
    // When weight is not set, possible weight restrictions will not be taken into consideration
    // for route calculation. By default, weight is not set.
    // Specify the weight including trailers and shipped goods (if any).
    truckSpecifications.grossWeightInKilograms = MyTruckSpecs.grossWeightInKilograms;
    truckSpecifications.heightInCentimeters = MyTruckSpecs.heightInCentimeters;
    truckSpecifications.widthInCentimeters = MyTruckSpecs.widthInCentimeters;
    // The total length including all trailers (if any).
    truckSpecifications.lengthInCentimeters = MyTruckSpecs.lengthInCentimeters;
    truckSpecifications.weightPerAxleInKilograms = MyTruckSpecs.weightPerAxleInKilograms;
    truckSpecifications.axleCount = MyTruckSpecs.axleCount;
    truckSpecifications.trailerCount = MyTruckSpecs.trailerCount;
    truckSpecifications.truckType = MyTruckSpecs.truckType;
    return truckSpecifications;
}

車両制限フィルターを作成するときは、以下のフィルタールールに留意する必要があります。

  • 指定されたTruckSpecificationsにのみ適用される制限が表示されます。たとえば、truckSpecificationsの高さが200cmに設定されている場合、高さが200cmを超える高さ制限アイコンは表示されません。truckSpecificationsのトレーラーカウントが2に設定されている場合、2を超えるカウントのトレーラー制限アイコンは表示されません。
  • 指定されたHazardousMaterialのリストにのみ適用される制限が表示されます。リストにいずれかのタイプの危険物が少なくとも1つ存在する場合、利用可能なすべてのTunnelCategory制限が表示されます。適用できないトンネルカテゴリーを除外するには、車両に適用されるTunnelCategoryを追加で指定できます。たとえば、hazardousMaterialsHazardousMaterial.EXPLOSIVEHazardousMaterial.FLAMMABLEが含まれている場合、爆発性および可燃性に関する物体制限のみが表示されます。hazardousMaterialsリストが空の場合、物体制限は表示されません。ただし、hazardousMaterialsにいずれかのタイプの危険物が少なくとも1つ含まれており、tunnelCategorynullである場合は、対応する物体制限のみが使用可能なすべてのトンネルカテゴリーとともに表示されます。
  • TunnelCategoryの制限は指定される制限のレベルに基づいてラベル付けおよび評価されます。制限の最低レベルはTunnelCategory.Bですが、最高レベルで最も制限が厳しいのはTunnelCategory.Eです。たとえば、TunnelCategoryTunnelCategory.Dに設定されている場合、トンネルカテゴリーTunnelCategory.ETunnelCategory.Dの制限は表示されますが、カテゴリーTunnelCategory.BTunnelCategory.Cの制限は表示されません。

EN 日本語

HERE documentation

Find answers to your product and technical questions

Documentation

What's new

Videos

EN 日本語

HERE ドキュメント

製品や技術に関する質問の答えを見つけましょう。より多くの内容と最新の情報については、英語版をご覧ください。

ドキュメント

ダイナミックマップ

動的コンテンツ関連のAPIをアプリやサービスに活用して、ドライバーが安全・快適かつ予定どおりに目的地へ到着できるよう支援します。

地図とデータ

世界中を走行する多数のマッピング車両から得られる最新の位置情報データを活用し、精度の高い地図やカスタムレイヤーを構築できます。

最新情報

動画

(function () { const input = document.querySelector('input[data-typeahead]'); if (!input) return; // Prevent the form from submitting/navigating input.closest('form')?.addEventListener('submit', e => e.preventDefault()); input.addEventListener('input', function () { const q = this.value.trim().toLowerCase(); document.querySelectorAll('.nav-group-name').forEach(group => { let anyVisible = false; group.querySelectorAll('.nav-group-task').forEach(task => { const text = task.textContent.trim().toLowerCase(); const show = !q || text.includes(q); task.style.display = show ? '' : 'none'; if (show) anyVisible = true; }); // Hide the whole group header if nothing matches group.style.display = anyVisible || !q ? '' : 'none'; }); }); })(); (function () { function onTokenClick(event) { var link = event.target.closest('.sdk-for-ios .item .token'); if (!link) return; event.preventDefault(); console.log('token clicked', link.textContent.trim()); var item = link.closest('.item'); if (!item) return; var content = item.querySelector('.height-container'); if (!content) { console.log('no .height-container found for item', item); return; } var isHidden = window.getComputedStyle(content).display === 'none'; content.style.display = isHidden ? 'block' : 'none'; link.classList.toggle('token-open', isHidden); var href = link.getAttribute('href'); if (href) { if (history.pushState) history.pushState({}, '', href); else location.hash = href; } } function openHashTarget() { var hash = window.location.hash.slice(1); if (!hash) return; var anchor = document.querySelector('.sdk-for-ios a[name="' + hash + '"]'); if (!anchor) return; var item = anchor.closest('.item'); if (!item) return; var link = item.querySelector('.token'); var content = item.querySelector('.height-container'); if (!link || !content) return; content.style.display = 'block'; link.classList.add('token-open'); } function init() { console.log('HERE SDK accordion init'); openHashTarget(); } document.removeEventListener('click', onTokenClick); document.addEventListener('click', onTokenClick); if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } window.addEventListener('hashchange', openHashTarget); window.addEventListener('pageLoad', init); })();