From: paul m. <pau...@sa...> - 2008-10-21 09:01:47
|
Hi, I'm a new user of geotools and java. I would like to get this VPF reader to work I foud the snippet on the web and I had to modify it a bit. Now I can read features but the geometry will allways be null. I would be grateful if someone can tell me what is wrong. Snippet: import java.io.File; import org.geotools.data.DataStore; import org.geotools.feature.FeatureCollection; import org.geotools.feature.FeatureIterator; import org.geotools.feature.FeatureType; import org.geotools.data.FeatureSource; import org.geotools.feature.Feature; import com.vividsolutions.jts.geom.Geometry; public class VPFTest { public static void main( String[] args ) throws Exception { if ( args.length != 1 ) { System.err.println( "Usage: java " + VPFTest.class.getName() + " " ); System.exit( 1 ); } DataStore ds = new org.geotools.data.vpf.VPFLibrary( new File( args[0] ) ); String[] types = ds.getTypeNames(); for ( int i = 0; i < types.length; i++ ) runThrough( ds, types[i] ); } static void runThrough( DataStore ds, String feature ) throws Exception { try { FeatureSource fs = ds.getFeatureSource( feature ); FeatureCollection res = fs.getFeatures(); FeatureIterator fi = res.features(); while ( fi.hasNext() ) { Feature f = fi.next(); Geometry g = f.getDefaultGeometry(); if ( g == null ) System.out.println( "Default Geometry is null for: " + f ); else System.out.println( "Default Geometry for: " + f ); } } finally { } } } -- View this message in context: http://www.nabble.com/trouble-reading-geometries-%28VPF%29-tp20083774p20083774.html Sent from the geotools-gt2-users mailing list archive at Nabble.com. |