Thanks for your prompt reply Jody!

I do see a SimpleFeatureTypeBuilder#setDefaultGeometry(String) and will
try that.  I do notice that the javadocs say:

"A default geometry for the feature type can be specified explictly via
|setDefaultGeometry(String)|
<http://geotools.org/javadocs/org/geotools/feature/simple/SimpleFeatureTypeBuilder.html#setDefaultGeometry%28java.lang.String%29>.
However if one is not set the first geometric attribute (|GeometryType|
<http://geoapi.sourceforge.net/snapshot/javadoc/org/opengis/feature/type/GeometryType.html>)
added will be resulting default. So if only specifying a single geometry
for the type there is no need to call the method."

so there may be a bug lurking somewhere here.

Also, it appears that SimpleFeatureCollection, SimpleFeatureSource no
longer exist and that the following lines needed to be changed in the
example:

//SimpleFeatureCollection collection = FeatureCollections.newCollection();
FeatureCollection<SimpleFeatureType,SimpleFeature> collection =
(FeatureCollection<SimpleFeatureType,SimpleFeature>)FeatureCollections.newCollection();

//SimpleFeatureSource featureSource =
newDataStore.getFeatureSource(typeName);
FeatureSource<SimpleFeatureType,SimpleFeature> featureSource =
(FeatureSource<SimpleFeatureType,SimpleFeature>)newDataStore.getFeatureSource(typeName);

Does that seem reasonable to you?

Thanks again for your help!

--john



On 05/06/2010 10:08 AM, Jody Garnett wrote:
> It may be the example that is wrong; I can see the 
> builder.add("Location",Point.class) line ...
> can you try and see if there is a builder method to set the default geometry? 
> I assumed it would pick up the first geometry all on its own ....
>
> Jody
>
> On 07/05/2010, at 1:51 AM, John Cartwright wrote:
>
>   
>> Hello All,
>>
>> I'm trying to follow the very nice Csv2Shp example
>> (http://geotools.org/examples/csv2shp.html) using version 2.6.3 and am
>> having a little trouble.
>>
>> Using the recommended alternative method for creating a SimpleFeatureType:
>>
>> private static SimpleFeatureType createFeatureType() {
>>
>>        SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
>>        builder.setName("Location");
>>        builder.setCRS(DefaultGeographicCRS.WGS84); // <- Coordinate 
>> reference system
>>
>>        // add attributes in order
>>        builder.add("Location", Point.class);
>>        builder.length(15).add("Name", String.class); // <- 15 chars width 
>> for name field
>>
>>        // build the type
>>        final SimpleFeatureType LOCATION = builder.buildFeatureType();
>>
>>        return LOCATION;
>>    }
>>
>> I find that the subsequent call "newDataStore.createSchema(TYPE);" throws a 
>> NPE, apparently because the the 
>> GeometryDescriptor is null (ShapefileDataStore.java: line 815).
>>
>> Can someone please explain what I'm doing wrong here?
>>
>> Thanks!
>>
>> --john
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Geotools-gt2-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>>     
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>   
------------------------------------------------------------------------------
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to