Hello Andrea,

thanks a lot for your fast answer, but I still have a problem

As you suggested I switched to SimpleFeatureTypeBuilder, therefor I replaced
the code for creating the FeatureType as follows:


SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.setName("Ereignisse");
builder.setCRS(CRS.decode("EPSG:32632"));
builder.add("Location", MultiLineString.class);
for (String fieldName : fieldNames) {
        builder.length(3500).add(fieldName, String.class);
}
TYPE = builder.buildFeatureType();


I can now set a restriction for Strings to be _shorter_ than 255 chars, but
not to be _longer_.
I'd need a possible maximum of 3500 chars in Field



-----Ursprüngliche Nachricht-----
Von: Andrea Aime [mailto:[email protected]] 
Gesendet: Dienstag, 2. Februar 2010 11:00
An: Schuster Stefan
Cc: [email protected]
Betreff: Re: [Geotools-gt2-users] Width of Metadata in Shapefile

Schuster Stefan ha scritto:
> Hi,
> 
>  
> 
> I wrote a programm that creates a Shapefile, and it basically works 
> fine. But the strings in the metadata can have more than 255 characters, 
> and I have no idea how I can define this in the SimpleFeatureType.
> 
>  
> 
> Currently I create the type as follows, and this leads to Strings that 
> are truncated after 255 chars:
> 
>  
> 
> StringBuilder sb = *new* StringBuilder();
> 
> sb.append("location:MultiLineString:srid=32632");
> 
> *for* (String fieldName : fieldNames) {         
> 
>       sb.append("," + fieldName + ":String");
> 
> }
> 
> TYPE = DataUtilities./createType/("Testereignisse", // <- the name for
> 
>             // our feature type
> 
>             sb.toString())

I don't think setting the field length is supported using
this method. It's really just there to make unit testing easier,
was not expanded to make it of general utility.

I suggest you use SimpleFeatureTypeBuilder instead

Cheers
Andrea

-- 
Andrea Aime
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.



------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to