From: William T. S. <bu...@vi...> - 2002-07-17 19:47:18
|
Hi, Attached are "updated" source codes for Shapefile (original checked out from CVS at the beginning of July) and Ian's ShapefileExample (same checkout date), as well as a perhaps troublesome shapefile. In the ShapefileExample (now ShapefileExample_1), the main changes I made to the code were to use FeatureCollectionDefault rather than DefaultFeatureTable(line 48), to use a JFileChooser to allow the user to pick a shapefile to plot, and to use a JFrame instead of a Frame (near line 163). I also added a number of println statements which helped me follow the code (and check whether the url I created was working correctly). In Shapefile, the major change I made was in the "read" method. In the try block (starts near line 132) which loops through the shapefile reading the records, I added a second catch block to catch an InvalidShapefileException to exit the loop. I found that I encountered this condition before reaching an EOF when reading several of my shapefiles. While this works, I'm not sure it's really the optimal solution. What appears to happen is that when reading one of these troublesome shapefiles, the loop which reads the shapefile records continues to read beyond the last record, resulting in a negative recordNumber and contentLength in Shapefile.read(geomFactory). The PolygonHandler then attempts to read (in PolygonHandler.read(file,geomFactory)) the shape data and gets an invalid shapeType, at which point it throws an InvalidShapefileException (near line 47 in PolygonHandler). I'm not sure why an EOF is not encountered after reading the last record--apparently there're some extra bits at the end of the file. Arcview & ArcMap don't have any problem reading the file. I also put some additional println statements in Shapefile. Finally, if you try the ShapefileExample code with the shapefile, note that the outline doesn't continue all the way around some of the polygons (if you get the same results I get). The example code didn't use a fill, so I originally thought only part of the polygons were being plotted! Hope this is helpful. Best regards, Buck *********************************************************************** *William T. Stockhausen, PhD e-mail: bu...@vi... * *Senior Marine Scientist voice : 804-684-7643 * *Virginia Institute of Marine Science fax : 804-684-7250 * *College of William and Mary http://www.vims.edu/~buck * *Greate Road * *Gloucester Point, VA 23062-1346 * *********************************************************************** |