FeatureType

 

Each feature in a vector layer consists of 3 parts: an identifier, a series of attributes and a geometry. These 3 parts are defined here, in the FeatureType. Let us again start with a small example:

<featureType>
	<layerModelFactoryRef>africaCountryShape</layerModelFactoryRef>
	<name>country</name>
	<identifier>
		<label>Id</label>
		<name>ID</name>
		<type>long</type>
	</identifier>
	<geometryType>
		<name>the_geom</name>
		<crs>EPSG:4326</crs>
		<editable>false</editable>
	</geometryType>			
	<attributes>
 ....
In this small piece of XML we can already clearly see the identifier, geometry and attributes. But there is more:
  • layerModelFactoryRef : A long name for something simple. This is a reference to the layerModelFactory. These factories are defined in the application.xml file, and are you basic sources of data. In this example you see the name "africaCountryShape", which is taken from the tutorial application from geomajas 1.3.1, and which is defined in the application.xml as a layermodel pointing to a shapefile.
  • name : This is the basic name for your FeatureType. Depending on the type of LayerModel that you use (see layerModelFactoryRef), this will look differently. Possible cases:
    • ShapeInMemLayerModelFactory : The name should be the same name as the shapefile, but without the .shp.
    • GeotoolsLayerModelFactory : The name should be a name that geotools uses as featuretype. For example if you use geotools to point to a database, then geotools will automatically use the database tablenames. Then so must you.
    • HibernateLayerModelFactory : When using Hibernate Spatial, you need to use the name of the Javaclass of the Pojo object that represents features in this layer.
  • Identifier : This is the definition of the identifier in the layer. It must point to a unique attribute, by which features can be referenced. It contains 3 tags:
    • label : The label, used on the client.
    • name :  The actual name in the featuretype. When using shapefiles or geotools, leave this at "ID".
    • type : The type of the identifier. Can be "integer, long, float, string".
  • geometryType : This is the configuration of the geometry for features in this layer. It contains 3 tags:
    • name : The name of the geometry attribute in the featuretype. When using shapefiles or geotools, this is usually "the_geom". When using Hibernate Spatial, this name will result in a getter function in the JAVA object ( "geom" => getGeom() ).
    • crs : The coordinate system for the geometries of the features. Best to keep this the same as the CRS definition of this layer. Again expressed as an EPSG code.
    • editable : Determines whether or not editing of geometries in this layer is allowed (true or false). Of course the general "editPermissions" of a vectorlayer can override this value!

 

 Next up are the attributes!