Hello,

I have been working under the notion that this code will work fine for 
processing a shapefile until I recently received an "Out of memory" exception.  
I have already exhausted my heap sizes, is there a more efficient way to move 
all features and all of their properties/attributes to a data structure?

Map<String, URL> connect = new HashMap<String, URL>();
                Map<String,Serializable> connectParameters = new 
HashMap<String,Serializable>();
                try {
                        URL url = pFile.toURL();
                        connect.put("url", url);
                        connectParameters.put("url", pFile.toURI().toURL());
                } catch (MalformedURLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }

                FeatureCollection<SimpleFeatureType, SimpleFeature> 
featureCollection = null;
                try {
                        DataStore dataStore = 
DataStoreFinder.getDataStore(connectParameters);
                        String[] typeNames = dataStore.getTypeNames();
                        String typeName = typeNames[0];

                        FeatureSource featureSource = 
dataStore.getFeatureSource( typeName );
                        featureCollection = featureSource.getFeatures();
                } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }

public List<Map<String, Object>> mPropertyValueList = new ArrayList<Map<String, 
Object>>();
Map<String, Object> map = new HashMap<String, Object>();

                                        for (Property property : 
feature.getProperties()) {
                                                  String name = 
property.getName().toString();
                                                  Object value = 
feature.getAttribute( property.getName() );
                                                  map.put(name, value);

                                        }
                                        mPropertyValueList.add(map);




java.lang.OutOfMemoryError: Java heap space
        at 
com.vividsolutions.jts.geom.impl.CoordinateArraySequence.<init>(CoordinateArraySequence.java:75)
        at 
com.vividsolutions.jts.geom.impl.CoordinateArraySequenceFactory.create(CoordinateArraySequenceFactory.java:92)
        at 
org.geotools.data.shapefile.shp.PolygonHandler.read(PolygonHandler.java:174)
        at 
org.geotools.data.shapefile.shp.ShapefileReader$Record.shape(ShapefileReader.java:106)
        at 
org.geotools.data.shapefile.ShapefileAttributeReader.next(ShapefileAttributeReader.java:154)
        at 
org.geotools.data.shapefile.indexed.IndexedShapefileAttributeReader.next(IndexedShapefileAttributeReader.java:122)
        at org.geotools.data.FIDFeatureReader.next(FIDFeatureReader.java:96)
        at org.geotools.data.FIDFeatureReader.next(FIDFeatureReader.java:55)
        at 
org.geotools.data.store.FeatureReaderIterator.next(FeatureReaderIterator.java:71)
        at 
org.geotools.data.store.FeatureReaderIterator.next(FeatureReaderIterator.java:41)
        at 
org.geotools.feature.collection.DelegateFeatureIterator.next(DelegateFeatureIterator.java:58)
        at 
com.railinc.ba.geo.ShapefilePropertyValueFormatter.convertPropertyValue(ShapefilePropertyValueFormatter.java:56)
        at 
com.railinc.ba.geo.TestShapefilePropertyValueFormatter.testShapefileFormat(TestShapefilePropertyValueFormatter.java:19)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)



This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed. If 
you have received this email in error please notify the system manager. This 
message contains confidential information and is intended only for the 
individual named. If you are not the named addressee you should not 
disseminate, distribute or copy this e-mail.

------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to