Hello all,

 

I'm trying to use the VPF reading functionality of the GeoTools API and have
run into some strange issues. I want to make sure I'm using the API
correctly before I jump to any conclusions, so I'll quickly layout what I am
doing.

 

First, I create the data store.

 

VPFDataStoreFactory factory = new VPFDataStoreFactory();

Map<String, URL> map = new HashMap<String, URL>();

File file = new File(DIR);

URL url = file.toURL();

map.put("url", url);          

DataStore dataStore = factory.createDataStore(map);

 

I get the type names.

 

Then, I get a feature source.

 

dataStore.getFeatureSource(typeName);

 

 

I get the featureCollection, and iterate through, printing feature
information.

 

FeatureCollection features = featureSource.getFeatures();

Iterator iter = features.iterator();

while (iter.hasNext()) {

    Feature feature = (Feature) iter.next();

    System.out.println("Feature: " + feature);

}

 

All this works file. in the surface.

 

To be specific, I'm using the Gen26 library of dnc 26.

 

The type name I use is BUOY_POINT

 

The features that print:

 

Feature: Feature[ id=1 , id=1 , f_code=BC020 , acc=-32768 , brf=-2147483648
, br2=-2147483648 , btc=Ocean Data Acquisition System .

Feature: Feature[ id=2 , id=2 , f_code=BC020 , acc=-32768 , brf=-2147483648
, br2=-2147483648 , btc=Ocean Data Acquisition System (ODAS) , .

 

 

I have run across two problems..

 

If, after this first bit of code, I add, more or less, a duplicate set of
code, this time with a data type SOUNDING_POINT,

When it tries to read, I get the following exception:

 

java.io.IOException: The handle is invalid

      at java.io.RandomAccessFile.length(Native Method)

      at org.geotools.data.vpf.file.VPFFile.hasNext(VPFFile.java:493)

      at
org.geotools.data.vpf.VPFFeatureReader.readNext(VPFFeatureReader.java:145)

      at
org.geotools.data.vpf.VPFFeatureReader.hasNext(VPFFeatureReader.java:117)

      at
org.geotools.data.ReTypeFeatureReader.hasNext(ReTypeFeatureReader.java:149)

      at
org.geotools.data.store.FeatureReaderIterator.hasNext(FeatureReaderIterator.
java:45)

      at
com.p21csi.aedgex.nmea.sample.geotools.TestVpfReader.testVpfReader(TestVpfRe
ader.java:89) 

      at
com.p21csi.aedgex.nmea.sample.geotools.TestVpfReader.main(TestVpfReader.java
:104)

 

 

If I try reading souding points first, it works fine, and then trying to
read the buoy points breaks.

 

All the variations of the different point data do this.

 

My next problem is trying to read in line data.

 

If I try to read DEPTH_CURVE_LINE, I get the following exception.

 

java.io.EOFException

      at java.io.RandomAccessFile.readFully(RandomAccessFile.java:373)

      at org.geotools.data.vpf.file.VPFFile.readTripletId(VPFFile.java:981)

      at
org.geotools.data.vpf.file.VPFFile.readFixedSizeData(VPFFile.java:795)

      at org.geotools.data.vpf.file.VPFFile.readFeature(VPFFile.java:724)

      at org.geotools.data.vpf.file.VPFFile.readAllRows(VPFFile.java:552)

      at org.geotools.data.vpf.file.VPFFile.getRowFromId(VPFFile.java:420)

      at
org.geotools.data.vpf.readers.LineGeometryFactory.createGeometry(LineGeometr
yFactory.java:63)

      at
org.geotools.data.vpf.VPFFeatureReader.retrieveObject(VPFFeatureReader.java:
274)

      at
org.geotools.data.vpf.VPFFeatureReader.readNext(VPFFeatureReader.java:168)

      at
org.geotools.data.vpf.VPFFeatureReader.hasNext(VPFFeatureReader.java:117)

      at
org.geotools.data.ReTypeFeatureReader.hasNext(ReTypeFeatureReader.java:149)

      at
org.geotools.data.store.FeatureReaderIterator.hasNext(FeatureReaderIterator.
java:45)

      at
com.p21csi.aedgex.nmea.sample.geotools.TestVpfReader.testVpfReader(TestVpfRe
ader.java:74)

      at
com.p21csi.aedgex.nmea.sample.geotools.TestVpfReader.main(TestVpfReader.java
:104)

 

 

Is there some step in the data reading process I am missing? Am I getting
the information out correctly or do I have my head in an unsunny place on
this?

 

Thanks,

 

-Jason Clark




-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to