Docs /

HERE Optimized Map for Analytics (OMA) Data Specification

Optimized Map for Analytics Data Specification

OMA Code Examples

Create a Data Frame and table of Speed Limits


val layerHRN   = catalogHRN + ":" + speedLimitLayer
val speedLimitDF = ( "partitions", 900)
             .option("parallelism", 4)

spark.sql("SELECT inline(speed_limit) FROM SpeedLimitPartitions").createOrReplaceTempView("SpeedLimit")

Find Segments with a Specific Speed Limit

%%spark -c sql
SELECT * FROM SpeedLimit where value = 30 LIMIT 10

Calculate Average Speed Limit per Segment

%%spark -c sql
SELECT start_node_partition_name, identifier,  avg(SpeedLimit.value)
FROM SegmentInBoundingBox,SpeedLimit
WHERE SegmentInBoundingBox.identifier = SpeedLimit.segment_identifier
GROUP BY identifier, start_node_partition_name LIMIT 10

OMA Integration with Optimized Map for Location Library

OMA can interoperate with Optimized Map for Location Library, for instance, OM4LL can be used for map matching or proximity search and then OMA can be used to retrieve attributes related to matched segments.

OMA and OM4LL must be compatible. Both are compiled from the same HERE Map Content version. The following code is an example of how to get the compatible OM4LL version for OMA:

import scala.concurrent.duration._
import scala.concurrent.Await
import scala.collection.JavaConverters._

// create catalog HRNS
val omaCatalogHRN = "hrn:here:data:::oma-3"
val omaHrn = HRN(omaCatalogHRN)
val hmcHrn = HRN("hrn:here:data:::rib-2")
val om4llHrn = HRN("hrn:here:data:::here-optimized-map-for-location-library-2")
// Create queryApi objects for OMA and OM4LL catalogs using hrns and settings
val omaQueryApi = DataClient(masterActorSystem).queryApi(omaHrn, settings)
val om4llQueryApi = DataClient(masterActorSystem).queryApi(om4llHrn, settings)

// get latest version for OMA and OM4LL
val omaVersion = Await.result(omaQueryApi.getLatestVersion(), Duration.Inf).get
val om4llVersion = Await.result(om4llQueryApi.getLatestVersion(), Duration.Inf).get 

// get dependent catalog version for queryApi catalog in a given version 
def resolveDependencyVersion(queryApi: QueryApi, dependency: HRN, version: Long): Long =
  (Await.result(queryApi.getVersion(version), Duration.Inf).dependencies.find(_.hrn == dependency)
     .getOrElse(throw new RuntimeException(s"There is no catalog $dependency in the dependencies"))
// get HERE Map Content version for OMA and OM4LL
val omaHmcVersion = resolveDependencyVersion(omaQueryApi,hmcHrn,omaVersion)
val om4llHmcVersion = resolveDependencyVersion(om4llQueryApi,hmcHrn,om4llVersion)
// get OM4LL version compatible with OMA
def getOm4llVersionCompatibleWithOma(om4llLatestVersion: Long): Long = {
  def om4llHmcVersion = resolveDependencyVersion(om4llQueryApi,hmcHrn,om4llLatestVersion)
  if(omaHmcVersion == om4llHmcVersion) om4llLatestVersion else getOm4llVersionCompatibleWithOma(om4llLatestVersion - 1)

val om4llCompatibleVersionWithOma = getOm4llVersionCompatibleWithOma(om4llVersion)