Keeping the FID order when creating a shapefile

Description

The improvement consists in creating shapefiles according to the FID order as defined in the FeatureCollection the user wants to save.
Therefore in the regular order for ListFeatureCollection or following a map tree index for MemoryFeatureCollection.

Here is Jody's answer on the geotools mailing list:
Internally (until you hit commit) the features are held in memory in a TransactionStateDiff; and then they are written out when commit() is called. What is the bet that that data structure uses a HashMap internally; I think if we change it to use a ListMap then the functionality you wanted would be preserved?

Here is the variable:

/**

  • Map of differences by typeName.
    *
    * <p>
    * Differences are stored as a Map of Feature by fid, and are reset during
    * a commit() or rollback().
    * </p>
    */
    Map typeNameDiff = new HashMap();

Looking at the code a bit more I am updating that to be:

As for Diff?

public class Diff{
private final Map modifiedFeatures;
private final Map addedFeatures;
And yes they are set to a form of HashMap:

public Diff( )
{
modifiedFeatures=new ConcurrentHashMap();
addedFeatures=new ConcurrentHashMap();
modified2=Collections.unmodifiableMap(modifiedFeatures);
added=Collections.unmodifiableMap(addedFeatures);
spatialIndex=new Quadtree();
mutex=this;
}

Environment

None

Assignee

Unassigned

Reporter

codehaus

Triage

None

Components

Fix versions

Affects versions

Priority

Low
Configure