1 /***********************************************************************
2  * Copyright (c) 2013-2024 Commonwealth Computer Research, Inc.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Apache License, Version 2.0
5  * which accompanies this distribution and is available at
6  * http://www.opensource.org/licenses/apache2.0.php.
7  ***********************************************************************/
8 
9 package org.locationtech.geomesa.spark.jts.encoders
10 
11 import org.apache.spark.sql.Encoder
12 import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
13 import org.locationtech.jts.geom._
14 
15 /** Encoders are Spark SQL's mechanism for converting a JVM type into a Catalyst representation.
16  * They are fetched from implicit scope whenever types move beween RDDs and Datasets. Because each
17  * of the types supported below has a corresponding UDT, we are able to use a standard Spark Encoder
18  * to construct these implicits. */
19 trait SpatialEncoders {
20   implicit def jtsGeometryEncoder: Encoder[Geometry] = ExpressionEncoder()
21   implicit def jtsPointEncoder: Encoder[Point] = ExpressionEncoder()
22   implicit def jtsLineStringEncoder: Encoder[LineString] = ExpressionEncoder()
23   implicit def jtsPolygonEncoder: Encoder[Polygon] = ExpressionEncoder()
24   implicit def jtsMultiPointEncoder: Encoder[MultiPoint] = ExpressionEncoder()
25   implicit def jtsMultiLineStringEncoder: Encoder[MultiLineString] = ExpressionEncoder()
26   implicit def jtsMultiPolygonEncoder: Encoder[MultiPolygon] = ExpressionEncoder()
27   implicit def jtsGeometryCollectionEncoder: Encoder[GeometryCollection] = ExpressionEncoder()
28 }
Line Stmt Id Pos Tree Symbol Tests Code
20 68930 1066 - 1085 ApplyToImplicitArgs org.apache.spark.sql.catalyst.encoders.ExpressionEncoder.apply org.apache.spark.sql.catalyst.encoders.ExpressionEncoder.apply[org.locationtech.jts.geom.Geometry]()(({ val $u: reflect.runtime.universe.type = scala.reflect.runtime.`package`.universe; val $m: $u.Mirror = scala.reflect.runtime.`package`.universe.runtimeMirror(classOf[org.locationtech.geomesa.spark.jts.encoders.SpatialEncoders].getClassLoader()); $u.TypeTag.apply[org.locationtech.jts.geom.Geometry]($m, { final class $typecreator1 extends TypeCreator { def <init>(): $typecreator1 = { $typecreator1.super.<init>(); () }; def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; $m.staticClass("org.locationtech.jts.geom.Geometry").asType.toTypeConstructor } }; new $typecreator1() }) }: reflect.runtime.universe.TypeTag[org.locationtech.jts.geom.Geometry]))
21 68931 1135 - 1154 ApplyToImplicitArgs org.apache.spark.sql.catalyst.encoders.ExpressionEncoder.apply org.apache.spark.sql.catalyst.encoders.ExpressionEncoder.apply[org.locationtech.jts.geom.Point]()(({ val $u: reflect.runtime.universe.type = scala.reflect.runtime.`package`.universe; val $m: $u.Mirror = scala.reflect.runtime.`package`.universe.runtimeMirror(classOf[org.locationtech.geomesa.spark.jts.encoders.SpatialEncoders].getClassLoader()); $u.TypeTag.apply[org.locationtech.jts.geom.Point]($m, { final class $typecreator1 extends TypeCreator { def <init>(): $typecreator1 = { $typecreator1.super.<init>(); () }; def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; $m.staticClass("org.locationtech.jts.geom.Point").asType.toTypeConstructor } }; new $typecreator1() }) }: reflect.runtime.universe.TypeTag[org.locationtech.jts.geom.Point]))
22 68932 1214 - 1233 ApplyToImplicitArgs org.apache.spark.sql.catalyst.encoders.ExpressionEncoder.apply org.apache.spark.sql.catalyst.encoders.ExpressionEncoder.apply[org.locationtech.jts.geom.LineString]()(({ val $u: reflect.runtime.universe.type = scala.reflect.runtime.`package`.universe; val $m: $u.Mirror = scala.reflect.runtime.`package`.universe.runtimeMirror(classOf[org.locationtech.geomesa.spark.jts.encoders.SpatialEncoders].getClassLoader()); $u.TypeTag.apply[org.locationtech.jts.geom.LineString]($m, { final class $typecreator1 extends TypeCreator { def <init>(): $typecreator1 = { $typecreator1.super.<init>(); () }; def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; $m.staticClass("org.locationtech.jts.geom.LineString").asType.toTypeConstructor } }; new $typecreator1() }) }: reflect.runtime.universe.TypeTag[org.locationtech.jts.geom.LineString]))
23 68933 1287 - 1306 ApplyToImplicitArgs org.apache.spark.sql.catalyst.encoders.ExpressionEncoder.apply org.apache.spark.sql.catalyst.encoders.ExpressionEncoder.apply[org.locationtech.jts.geom.Polygon]()(({ val $u: reflect.runtime.universe.type = scala.reflect.runtime.`package`.universe; val $m: $u.Mirror = scala.reflect.runtime.`package`.universe.runtimeMirror(classOf[org.locationtech.geomesa.spark.jts.encoders.SpatialEncoders].getClassLoader()); $u.TypeTag.apply[org.locationtech.jts.geom.Polygon]($m, { final class $typecreator1 extends TypeCreator { def <init>(): $typecreator1 = { $typecreator1.super.<init>(); () }; def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; $m.staticClass("org.locationtech.jts.geom.Polygon").asType.toTypeConstructor } }; new $typecreator1() }) }: reflect.runtime.universe.TypeTag[org.locationtech.jts.geom.Polygon]))
24 68934 1366 - 1385 ApplyToImplicitArgs org.apache.spark.sql.catalyst.encoders.ExpressionEncoder.apply org.apache.spark.sql.catalyst.encoders.ExpressionEncoder.apply[org.locationtech.jts.geom.MultiPoint]()(({ val $u: reflect.runtime.universe.type = scala.reflect.runtime.`package`.universe; val $m: $u.Mirror = scala.reflect.runtime.`package`.universe.runtimeMirror(classOf[org.locationtech.geomesa.spark.jts.encoders.SpatialEncoders].getClassLoader()); $u.TypeTag.apply[org.locationtech.jts.geom.MultiPoint]($m, { final class $typecreator1 extends TypeCreator { def <init>(): $typecreator1 = { $typecreator1.super.<init>(); () }; def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; $m.staticClass("org.locationtech.jts.geom.MultiPoint").asType.toTypeConstructor } }; new $typecreator1() }) }: reflect.runtime.universe.TypeTag[org.locationtech.jts.geom.MultiPoint]))
25 68935 1455 - 1474 ApplyToImplicitArgs org.apache.spark.sql.catalyst.encoders.ExpressionEncoder.apply org.apache.spark.sql.catalyst.encoders.ExpressionEncoder.apply[org.locationtech.jts.geom.MultiLineString]()(({ val $u: reflect.runtime.universe.type = scala.reflect.runtime.`package`.universe; val $m: $u.Mirror = scala.reflect.runtime.`package`.universe.runtimeMirror(classOf[org.locationtech.geomesa.spark.jts.encoders.SpatialEncoders].getClassLoader()); $u.TypeTag.apply[org.locationtech.jts.geom.MultiLineString]($m, { final class $typecreator1 extends TypeCreator { def <init>(): $typecreator1 = { $typecreator1.super.<init>(); () }; def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; $m.staticClass("org.locationtech.jts.geom.MultiLineString").asType.toTypeConstructor } }; new $typecreator1() }) }: reflect.runtime.universe.TypeTag[org.locationtech.jts.geom.MultiLineString]))
26 68936 1538 - 1557 ApplyToImplicitArgs org.apache.spark.sql.catalyst.encoders.ExpressionEncoder.apply org.apache.spark.sql.catalyst.encoders.ExpressionEncoder.apply[org.locationtech.jts.geom.MultiPolygon]()(({ val $u: reflect.runtime.universe.type = scala.reflect.runtime.`package`.universe; val $m: $u.Mirror = scala.reflect.runtime.`package`.universe.runtimeMirror(classOf[org.locationtech.geomesa.spark.jts.encoders.SpatialEncoders].getClassLoader()); $u.TypeTag.apply[org.locationtech.jts.geom.MultiPolygon]($m, { final class $typecreator1 extends TypeCreator { def <init>(): $typecreator1 = { $typecreator1.super.<init>(); () }; def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; $m.staticClass("org.locationtech.jts.geom.MultiPolygon").asType.toTypeConstructor } }; new $typecreator1() }) }: reflect.runtime.universe.TypeTag[org.locationtech.jts.geom.MultiPolygon]))
27 68937 1633 - 1652 ApplyToImplicitArgs org.apache.spark.sql.catalyst.encoders.ExpressionEncoder.apply org.apache.spark.sql.catalyst.encoders.ExpressionEncoder.apply[org.locationtech.jts.geom.GeometryCollection]()(({ val $u: reflect.runtime.universe.type = scala.reflect.runtime.`package`.universe; val $m: $u.Mirror = scala.reflect.runtime.`package`.universe.runtimeMirror(classOf[org.locationtech.geomesa.spark.jts.encoders.SpatialEncoders].getClassLoader()); $u.TypeTag.apply[org.locationtech.jts.geom.GeometryCollection]($m, { final class $typecreator1 extends TypeCreator { def <init>(): $typecreator1 = { $typecreator1.super.<init>(); () }; def apply[U <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = { val $u: U = $m$untyped.universe; val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; $m.staticClass("org.locationtech.jts.geom.GeometryCollection").asType.toTypeConstructor } }; new $typecreator1() }) }: reflect.runtime.universe.TypeTag[org.locationtech.jts.geom.GeometryCollection]))