Skip to content

Commit

Permalink
Refactor code for instantiating converters
Browse files Browse the repository at this point in the history
  • Loading branch information
adeet1 committed Mar 19, 2024
1 parent ba3e38b commit 237db93
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,13 @@ object SimpleFeatureReadSupport {
}

private def geometryV2(binding: ObjectType, i: Int, callback: Settable): Converter = {
binding match {
case ObjectType.POINT => new GeometryWkbConverter(i, callback)
case ObjectType.LINESTRING => new GeometryWkbConverter(i, callback)
case ObjectType.POLYGON => new GeometryWkbConverter(i, callback)
case ObjectType.MULTIPOINT => new GeometryWkbConverter(i, callback)
case ObjectType.MULTILINESTRING => new GeometryWkbConverter(i, callback)
case ObjectType.MULTIPOLYGON => new GeometryWkbConverter(i, callback)
case ObjectType.GEOMETRY => new GeometryWkbConverter(i, callback)
case _ => throw new IllegalArgumentException(s"Can't deserialize field of type $binding")
val geomTypes = Seq(ObjectType.POINT, ObjectType.LINESTRING, ObjectType.POLYGON, ObjectType.MULTIPOINT,
ObjectType.MULTILINESTRING, ObjectType.MULTIPOLYGON, ObjectType.GEOMETRY)

if (geomTypes.contains(binding)) {
new GeometryWkbConverter(i, callback)
} else {
throw new IllegalArgumentException(s"Can't serialize field of type $binding")
}
}

Expand Down

0 comments on commit 237db93

Please sign in to comment.