Implicits (Scala only)

The Location Library offers Implicits objects that simplify the use of the Location Library type classes. For example, by exposing type class operations as extension methods.

The simplest way to achieve this is to add this line at the top of your source file:

Scala
import com.here.platform.location.core.geospatial.Implicits._

You can see the resulting simplification in the following example:

Scala
def processLineString[LS: LineStringOperations](lineString: LS) = {
  // Using the type class without the `Implicits` object
  val points = implicitly[LineStringOperations[LS]].points(lineString)

  import com.here.platform.location.core.geospatial.Implicits._

  // Using the type class with the `Implicits` object
  val points2 = lineString.points

  assert(points == points2)
}

The Location Library also supports using HERE Map Content types with Location Library type classes by importing the contents of the corresponding Implicits object.

Scala
val point0 = com.here.schema.geometry.v2.geometry.Point(0, 0)
val point1 = com.here.schema.geometry.v2.geometry.Point(1, 1)

import com.here.platform.location.integration.heremapcontent.geospatial.Implicits._

val distance = GeoCoordinates.greatCircleDistanceMeters(point0, point1)

results matching ""

    No results matching ""