9.6. Programmatic UseΒΆ

Converters and SimpleFeatureTypes can be imported through Maven and used directly in code:

<dependency>
  <groupId>org.locationtech.geomesa</groupId>
  <!-- pull in all converters, or use a specific converter, e.g. geomesa-convert-json_2.12 -->
  <artifactId>geomesa-convert-all_2.12</artifactId>
</dependency>
import org.locationtech.geomesa.convert2.SimpleFeatureConverter

val converter = SimpleFeatureConverter("example-csv", "example-csv") // load by-name from the classpath
try {
  val is: InputStream = ??? // load your input data
  val features = converter.process(is)
  try {
    features.foreach(???) // do something with the conversion result
  } finally {
    features.close() // will also close the input stream
  }
} finally {
  converter.close() // clean up any resources associated with your converter
}