Hi Matthias

I'm moving your question to the user list...

> i use most of the code from the Csv2Shape example
> http://docs.geotools.org/latest/userguide/tutorial/feature/csv2shp.html to
> generate a shape file from my own special csv file. The problem is, that i
> need the same order of the features as in the csv file. I add the features
> in the same order as in the csv file, but in the resulting shape file i get
> an other order :-(
>
> How can i ensure the same order in the shapefile?

In that example you are using default feature IDs by calling the
buildFeature method with a null argument in this section of the code:
http://docs.geotools.org/latest/userguide/tutorial/feature/csv2shp.html#read-into-a-featurecollection

I think the order of the features in the collection, and subsequently
in the shapefile, follows the natural order of the IDs. Try providing
your own feature IDs and see if that fixes the problem.  For
example...

int featureIndex = 1;
for (line = reader.readLine(); line != null; line = reader.readLine()) {
    // read data into feature builder
    SimpleFeature feature = featureBuilder.buildFeature(
String.valueOf( featureIndex++ ) );
    collection.add(feature);
}

Jody: now that adding features to a feature collection had been
deprecated I guess we need to update this example ?

Michael

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to