8.6. Defining Simple Feature Types

A SimpleFeatureType defines the names and types of attributes in a schema. Several of the command-line tools require the definition of a SimpleFeatureType, for example to create a new schema. GeoMesa commands support several different ways to define one (in order of priority):

  1. the well-known name of a SimpleFeatureType available on the classpath

  2. a specification string

  3. a TypeSafe configuration

  4. the name of a file containing either a specification string or a TypeSafe configuration

8.6.1. Included Feature Types

GeoMesa distributions ship with SimpleFeatureType definitions for several common data types including Twitter, GeoNames, T-drive, and more. See Prepackaged Converter Definitions for full details.

These types are available via classpath loading, as described next. Available types can be examined using the env command.

8.6.2. Classpath Loading

GeoMesa uses the TypeSafe Config library for loading SimpleFeatureTypes from the classpath. Following convention, GeoMesa will load the default configuration, which is defined by the files reference.conf and/or application.conf. In the binary distributions, those files are included in the conf directory, with a variety of pre-defined types. See Prepackaged Converter Definitions for more information on the provided types.

Users can modify these files to define their own SimpleFeatureTypes. By default, SimpleFeatureTypes should be defined as objects under the path geomesa.sfts. They are identified by their key.

The SimpleFeatureType object allows for the following keys:

  • type-name - a string to specify the type name. If omitted, type name will default to the object key.

  • attributes (required) - an array of fields (see below)

  • user-data - arbitrary key-value pairs that will be set as user data in the SimpleFeatureType

The attributes object allows for the definition of fields, which allow for the following keys:

  • name (required) - the simple name for the attribute

  • type (required) - the type of the attribute. See GeoTools Feature Types for more details.

Other attribute keys will be set as user data on the attribute, and can be used to enabled attribute indexing, indicate the default date field, etc. See Setting Attribute Options for more details.

Once a SimpleFeatureType has been defined on the classpath, it can be referenced by its well-known name, i.e. the object key under geomesa.sfts. Available types can be examined using the env command.

8.6.2.1. Example

The following file defines a SimpleFeatureType called example, with four attributes:

geomesa = {
  sfts = {
     # other SFTs
     # ...
    example = {
      attributes = [
        { name = "name", type = "String", index = true                  }
        { name = "age",  type = "Integer"                               }
        { name = "dtg",  type = "Date",   default = true,  index = true }
        { name = "geom", type = "Point",  default = true , srid = 4326  }
      ]
    }
  }
}

8.6.3. Specification String

A SimpleFeatureType can also be defined as a string. The format for each attribute is name:type:foo=bar, where name is the attribute name, type is the attribute binding, and foo=bar is optional user data. A full type is defined as 1-n attributes separated by commas, then (optionally), a semi-colon followed by type-level user data separated with commas. The default geometry is specified with *.

See GeoTools Feature Types and Setting Attribute Options for more details on attribute types and user data.

Since a specification string does not contain a feature type name, the name has to be provided separately.

8.6.3.1. Example

This string corresponds to the configuration example above:

name:String:index=true,age:Integer,dtg:Date:index=true:default=true,*geom:Point:srid=4326

8.6.4. Configuration String

Instead of defining a SimpleFeatureType configuration on the classpath, the same configuration string can be passed directly as an argument. Be careful to ensure the definition is still nested under geomesa.sfts.

8.6.5. File Name

Instead of defining them directly on the command line, a type can be defined in a file containing either a specification string or a configuration string. The file can then be referenced by name.