Copy DataStore Plug-in from Trunk
In order to minimize missing out on improvments and bug fixes from trunk, before beginning a data store port you should copy the latest and greatest version from trunk.
Be sure to make that trunk itself is in sync with the current stable branch (2.2.x) before proceeding. This can be done by either emailing the list and asking or checking the version control logs. |
You can copy over the plugin with the following svn commands.
Get the Plug-in to Compile
The first task is getting code to compile. If you are keen on TDD (Test Driven Development) you will start with tests.
. Here are some guidelines and tips that will help.
org.geotools.feature
The org.geotools.feature interfaces are now gone and replaced with org.opengis.feature and org.opengis.feature.type. So references to the old Feature and FeatureType can pretty much be replaced mechanically.
FeatureType
As stated above org.geotools.feature.FeatureType has been removed and placed with org.opengis.feature.FeatureType. In the new model, the old FeatureType best maps to org.opengis.feature.simple.SimpleFeatureType. The following table maps the methods across. In some cases no such mapping exists so the alternative is listed.
FeatureType |
SimpleFeatureType |
Alternative |
|---|---|---|
getTypeName() |
getName().getLocalPart() |
|
getNamespace() |
getName().getNamespaceURI() |
|
isDescendedFrom(URI,String) |
|
Types.isSuperType(AttributeType,AttributeType) |
isDescendedFrom(FeatureType) |
|
Types.isSuperType(AttributeType,AttributeType) |
isAbstract() |
|
|
getAnscestors() |
getSuper() |
|
getDefaultGeometry() |
defaultGeometry() |
|
getAttributeCount() |
getNumberOfAttributes() |
|
getAttributeType(String) |
get(String) |
|
find(AttributeType) |
|
|
find(String) |
|
|
getAttributeType(int) |
get(int) |
|
getAttributeTypes() |
types() |
|
hasAttributeType(String) |
|
get(String) != null |
duplicate(Feature) |
|
SimpleFeatures.duplicate(SimpleFeature,SimpleFeature) |
create(Object[]) |
|
SimpleFeatures.create(SimpleFeatureType,Object[],String |
create(Object[], String) |
|
SimpleFeatures.create(SimpleFeatureType,Object[],String) |
Feature
Similar to FeatureType, org.geotools.feature.Feature maps to org.opengis.feature.simple.SimpleFeature.
Feature |
SimpleFeature |
Alternative |
|---|---|---|
getParent() |
|
|
setParent(FeatureCollection |
|
|
getFeatureType() |
getType() |
|
getID() |
|
|
getAttributes(Object[]) |
values() |
|
getAttribute(String) |
get(String) |
|
getAttribute(int) |
get(int) |
|
setAttribute(String,Object) |
set(String,Object) |
|
setAttribute(int,Object) |
set(int,Object) |
|
getNumberOfAttributes() |
|
|
getDefaultGeometry() |
defaultGeometry() |
|
setDefaultGeometry(Geometry) |
defaultGeometry(Object) |
|
getBounds() |
|
|
FeatureType Creation
Creating feature types is done with SimpleFeatureTypeBuilder.
Feature Creation
Creating features is done with SimpleFeatureBuilder
org.geotools.data
DataStore
The datastore api has mostly maintained backwards compatability. The changes have to do with naming. Methods that accepted a String to reference a FeatureType, no accept a TypeName.
AbstractDataStore
The above methods referencing FeatureType by a single String have been deprecated and finalized. So any subclasses of AbstractDataStore are broken and must convert the internal name storage to the TypeName system.