* @throws DataSourceException
*/
Pointer convertGTFeature(Pointer featureDefinition, SimpleFeature feature)
throws IOException {
// create a new empty OGR feature
Pointer ogrFeature = OGR_F_Create(featureDefinition);
// go thru GeoTools feature attributes, and convert
SimpleFeatureType schema = feature.getFeatureType();
for (int i = 0, j = 0; i < schema.getAttributeCount(); i++) {
Object attribute = feature.getAttribute(i);
if (attribute instanceof Geometry) {
// using setGeoemtryDirectly the feature becomes the owner of the generated
// OGR geometry and we don't have to .delete() it (it's faster, too)
Pointer geometry = geomMapper.parseGTGeometry((Geometry) attribute);
OGR_F_SetGeometryDirectly(ogrFeature, geometry);
} else {
setFieldValue(featureDefinition, ogrFeature, j, attribute);
j++;
}