TPEG2

tpeg2 このモジュールでは、 TPEG2 メッセージの Java/Scala モデルを定義します。 標準で定義されている XML 形式およびバイナリ形式の読み取りおよび書き込みを行うマーシャリングおよびアンマーシャリングがあります。

バイナリ形式は、帯域幅が非常に限られている使用例を想定して設計されているため、非常に効率的で、本番環境での使用を目的としています。 XML マークアップの表現はより詳細で、一般的には、テストやデバッグなどの人間が読める形式で使用されます。

モジュールのメインパッケージでは、マーシャリングおよびアンマーシャリング機能にアクセスできます。

サポートされている各 TPEG2 アプリケーション / ツールキットにはサブパッケージがあります。

  • tpegdatatypes ISO 21219-2:2019 以降のすべてのアプリケーションとツールキットで共有される基本的なデータ型。

  • sfw ISO 21219-5:2019 に準拠した信頼性の高い送信を行うために、アプリケーションメッセージのフレーミングに必要なサービスフレームワーク( SFW )タイプ。

  • mmc Message Management Container ( MMC )のタイプ。このタイプには、 ISO 21219-6:2019 に準拠してデコーダがメッセージを適切に処理できるようにする管理情報が含まれています。

  • lrc ISO 21219-7 : 2017 に続く一般的な方法で位置参照をラップするタイプ。

  • sni サービスおよびネットワーク情報を表現するために使用されるタイプ。 ISO 21219-9 : 2016 に準拠したバイナリエンコードの SFW フレームの内容を記述するために使用されます。

  • tec ISO 21219-15 : 2016 に準拠した交通イベントコンパクトアプリケーションに使用されるタイプ。

  • tfp ISO 21219-18:2019 に準拠したトラフィックフローおよび予測アプリケーションに使用されるタイプ。

  • etl TISA SP13003-20 以降の拡張 TMC 位置参照に使用されるタイプ。

  • olr OpenLR の場所を示すために使用されるタイプは、 ISO 21219-22:2017 に準拠しています。

  • tmc ISO 17572-2 に準拠する TPEG1 TMC 位置を参照するために使用されるタイプ。

TPEG2 データ構造の操作

tpeg2 プロジェクトの依存関係にモジュールを追加して、モジュールの操作を開始します。

SBT
Maven
グレードル
libraryDependencies ++= Seq(
  "com.here.platform.location" %% "location-tpeg2" % "0.21.788"
)
<dependencies>
    <dependency>
        <groupId>com.here.platform.location</groupId>
        <artifactId>location-tpeg2_${scala.compat.version}</artifactId>
        <version>0.21.788</version>
    </dependency>
</dependencies>
dependencies {
    compile group: 'com.here.platform.location', name: 'location-tpeg2_2.12', version:'0.21.788'
}

TPEG2 マーシャリング機能のエントリーポイントは BinaryMarshallersXmlMarshallers それぞれおよびです。

TPEG2 は、データを送信するためのプロトコル全体を提供します。このプロトコルは、メッセージをフレームで送信する方法を指定します。 通常、何がワイヤを介して送信されるか、または空気が sfw.TransportFrameストリーミングされる前に ss にパッケージ化されます。

通常、は TransportFrame マーシャリングおよびアンマーシャリングの出発点ですが、その他の重要な型のいくつかは、 TPEG-Binary または TPEG XML に個別にマーシャリングおよびアンマーシャリングできます。

たとえば OpenLRLocationReference 、次のように、 TPEG-Binary から個別にマーシャリング解除できます。

Scala
Java
import com.here.platform.location.tpeg2.BinaryMarshallers
import com.here.platform.location.tpeg2.olr.OpenLRLocationReference

import java.io.ByteArrayInputStream

// Given the TPEG-Binary representation of an OpenLR location reference,
val tpegBinaryOpenLRReference: Array[Byte] =
  Array(0x08, 0x28, 0x01, 0x10, 0x02, 0x24, 0x23, 0x09, 0x9B, 0x42, 0x25, 0x4F, 0xE2, 0x00,
        0x09, 0x05, 0x04, 0x05, 0x03, 0x27, 0x00, 0x0A, 0x04, 0x03, 0x05, 0x76, 0x00, 0x00,
        0xA0, 0x00, 0x29, 0x00, 0x09, 0x05, 0x04, 0x05, 0x03, 0xB3, 0x00, 0x01, 0x02, 0x00).map(
    _.toByte)

// We can use a BinaryMarshaller to unmarshall the reference.
val reference: OpenLRLocationReference =
  BinaryMarshallers.openLRLocationReference.unmarshall(
    new ByteArrayInputStream(tpegBinaryOpenLRReference))

// Now we can use the reference object. Here we just use its string representation.
System.out.println(reference)
import com.here.platform.location.tpeg2.javadsl.BinaryMarshallers;
import com.here.platform.location.tpeg2.olr.OpenLRLocationReference;

import java.io.ByteArrayInputStream;
// Given the TPEG-Binary representation of an OpenLR location reference,
final byte[] tpegBinaryOpenLRReference =
    new byte[] {
      (byte) 0x08, (byte) 0x28, (byte) 0x01, (byte) 0x10, (byte) 0x02, (byte) 0x24, (byte) 0x23,
      (byte) 0x09, (byte) 0x9B, (byte) 0x42, (byte) 0x25, (byte) 0x4F, (byte) 0xE2, (byte) 0x00,
      (byte) 0x09, (byte) 0x05, (byte) 0x04, (byte) 0x05, (byte) 0x03, (byte) 0x27, (byte) 0x00,
      (byte) 0x0A, (byte) 0x04, (byte) 0x03, (byte) 0x05, (byte) 0x76, (byte) 0x00, (byte) 0x00,
      (byte) 0xA0, (byte) 0x00, (byte) 0x29, (byte) 0x00, (byte) 0x09, (byte) 0x05, (byte) 0x04,
      (byte) 0x05, (byte) 0x03, (byte) 0xB3, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x00
    };

// We can use a BinaryMarshaller to unmarshall the reference.
final OpenLRLocationReference reference =
    BinaryMarshallers.openLRLocationReference()
        .unmarshall(new ByteArrayInputStream(tpegBinaryOpenLRReference));

// Now we can use the reference object. Here we just use its string representation.
System.out.println(reference);

デバッグの目的で、以下のように TPEG-ML から削除することもできます。

Scala
Java
import com.here.platform.location.tpeg2.{BinaryMarshallers, XmlMarshallers}

import java.io.{ByteArrayInputStream, ByteArrayOutputStream}
import java.nio.charset.StandardCharsets

// Given the TPEG-ML representation of an OpenLR location reference,
val tpegML =
  """|<?xml version="1.0" encoding="utf-8" standalone="yes"?>
     |<olr:OpenLRLocationReference xmlns:olr="http://www.tisa.org/TPEG/OLR_0_1">
     |    <olr:version>1.0</olr:version>
     |    <olr:locationReference>
     |        <olr:optionPointAlongLineLocationReference>
     |            <olr:pointAlongLine>
     |                <olr:first>
     |                    <olr:coordinate>
     |                        <olr:longitude>629570</olr:longitude>
     |                        <olr:latitude>2445282</olr:latitude>
     |                    </olr:coordinate>
     |                    <olr:lineProperties>
     |                        <olr:frc olr:table="olr001_FunctionalRoadClass" olr:code="5"/>
     |                        <olr:fow olr:table="olr002_FormOfWay" olr:code="3"/>
     |                        <olr:bearing>
     |                            <olr:value>39</olr:value>
     |                        </olr:bearing>
     |                    </olr:lineProperties>
     |                    <olr:pathProperties>
     |                        <olr:lfrcnp olr:table="olr001_FunctionalRoadClass" olr:code="5"/>
     |                        <olr:dnp>
     |                            <olr:value>118</olr:value>
     |                        </olr:dnp>
     |                        <olr:againstDrivingDirection>false</olr:againstDrivingDirection>
     |                    </olr:pathProperties>
     |                </olr:first>
     |                <olr:last>
     |                    <olr:coordinate>
     |                        <olr:longitude>160</olr:longitude>
     |                        <olr:latitude>41</olr:latitude>
     |                    </olr:coordinate>
     |                    <olr:lineProperties>
     |                        <olr:frc olr:table="olr001_FunctionalRoadClass" olr:code="5"/>
     |                        <olr:fow olr:table="olr002_FormOfWay" olr:code="3"/>
     |                        <olr:bearing>
     |                            <olr:value>179</olr:value>
     |                        </olr:bearing>
     |                    </olr:lineProperties>
     |                </olr:last>
     |                <olr:sideOfRoad olr:table="olr004_SideOfRoad" olr:code="1"/>
     |                <olr:orientation olr:table="olr003_Orientation" olr:code="2"/>
     |            </olr:pointAlongLine>
     |        </olr:optionPointAlongLineLocationReference>
     |    </olr:locationReference>
     |</olr:OpenLRLocationReference>
     |""".stripMargin

// We can use an XmlMarshaller to unmarshall the reference.
val ref = XmlMarshallers.openLRLocationReference.unmarshall(
  new ByteArrayInputStream(tpegML.getBytes(StandardCharsets.UTF_8)))

// Now we can use the reference object. Here we use a BinaryMarshaller to write it as TPEG-Binary.
val outputStream = new ByteArrayOutputStream
BinaryMarshallers.openLRLocationReference.marshall(ref, outputStream)
import com.here.platform.location.tpeg2.XmlMarshallers;
import com.here.platform.location.tpeg2.javadsl.BinaryMarshallers;
import com.here.platform.location.tpeg2.olr.OpenLRLocationReference;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.nio.charset.StandardCharsets;
// Given the TPEG-ML representation of an OpenLR location reference,
final String tpegML =
    "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>"
        + "<olr:OpenLRLocationReference xmlns:olr=\"http://www.tisa.org/TPEG/OLR_0_1\">"
        + "    <olr:version>1.0</olr:version>"
        + "    <olr:locationReference>"
        + "        <olr:optionPointAlongLineLocationReference>"
        + "            <olr:pointAlongLine>"
        + "                <olr:first>"
        + "                    <olr:coordinate>"
        + "                        <olr:longitude>629570</olr:longitude>"
        + "                        <olr:latitude>2445282</olr:latitude>"
        + "                    </olr:coordinate>"
        + "                    <olr:lineProperties>"
        + "                        <olr:frc olr:table=\"olr001_FunctionalRoadClass\" olr:code=\"5\"/>"
        + "                        <olr:fow olr:table=\"olr002_FormOfWay\" olr:code=\"3\"/>"
        + "                        <olr:bearing>"
        + "                            <olr:value>39</olr:value>"
        + "                        </olr:bearing>"
        + "                    </olr:lineProperties>"
        + "                    <olr:pathProperties>"
        + "                        <olr:lfrcnp olr:table=\"olr001_FunctionalRoadClass\" olr:code=\"5\"/>"
        + "                        <olr:dnp>"
        + "                            <olr:value>118</olr:value>"
        + "                        </olr:dnp>"
        + "                        <olr:againstDrivingDirection>false</olr:againstDrivingDirection>"
        + "                    </olr:pathProperties>"
        + "                </olr:first>"
        + "                <olr:last>"
        + "                    <olr:coordinate>"
        + "                        <olr:longitude>160</olr:longitude>"
        + "                        <olr:latitude>41</olr:latitude>"
        + "                    </olr:coordinate>"
        + "                    <olr:lineProperties>"
        + "                        <olr:frc olr:table=\"olr001_FunctionalRoadClass\" olr:code=\"5\"/>"
        + "                        <olr:fow olr:table=\"olr002_FormOfWay\" olr:code=\"3\"/>"
        + "                        <olr:bearing>"
        + "                            <olr:value>179</olr:value>"
        + "                        </olr:bearing>"
        + "                    </olr:lineProperties>"
        + "                </olr:last>"
        + "                <olr:sideOfRoad olr:table=\"olr004_SideOfRoad\" olr:code=\"1\"/>"
        + "                <olr:orientation olr:table=\"olr003_Orientation\" olr:code=\"2\"/>"
        + "            </olr:pointAlongLine>"
        + "        </olr:optionPointAlongLineLocationReference>"
        + "    </olr:locationReference>"
        + "</olr:OpenLRLocationReference>";

// We can use an XmlMarshaller to unmarshall the reference.
final OpenLRLocationReference ref =
    XmlMarshallers.openLRLocationReference()
        .unmarshall(new ByteArrayInputStream(tpegML.getBytes(StandardCharsets.UTF_8)));

// Now we can use the reference object. Here we use a BinaryMarshaller to write it as
// TPEG-Binary.
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BinaryMarshallers.openLRLocationReference().marshall(ref, outputStream);

フル SFW ( Service Framework )ストリームの TransportFrame場合、は次のようにデシリアライズされます。

Scala
Java
import com.here.platform.location.tpeg2.sfw.TransportFrame
import com.here.platform.location.tpeg2.tec.TECMessage
import com.here.platform.location.tpeg2.{BinaryMarshallers, Tpeg2Messages}

// Given the TPEG-Binary representation of an OpenLR location reference,
val inputStream: InputStream = loadTpegBinaryTransportFrames()

// We can use a BinaryMarshaller to get an iterator that unmarshalls TransportFrames.
val transportFrames: Seq[TransportFrame] =
  BinaryMarshallers.transportFrames.unmarshall(inputStream).toSeq

// We can then use an extractor to get interesting information. E.g., here we get all TECMessages.
val tecMessages: Seq[TECMessage] =
  Tpeg2Messages(transportFrames).filterTecMessages.applicationMessages
import com.here.platform.location.tpeg2.Tpeg2Messages;
import com.here.platform.location.tpeg2.javadsl.BinaryMarshallers;
import com.here.platform.location.tpeg2.sfw.TransportFrame;
import com.here.platform.location.tpeg2.tec.TECMessage;

import java.io.InputStream;
import java.util.Iterator;
import java.util.List;
// Given the TPEG-Binary representation of an OpenLR location reference,
final InputStream inputStream = loadTpegBinaryTransportFrames();

// We can use a BinaryMarshaller to get an iterator that unmarshalls TransportFrames.
final Iterator<TransportFrame> transportFrames =
    BinaryMarshallers.transportFrames().unmarshall(inputStream);

// We can then use an extractor to get interesting information. E.g., here we get all
// TECMessages.
final List<TECMessage> tecMessages =
    Tpeg2Messages.create(transportFrames).filterTecMessages().getApplicationMessages();

」に一致する結果は 件です

    」に一致する結果はありません