svn - r34359 - in trunk/modules: library/sample-data/src/main/resources/org/geotools/test-data/shapes plugin/shapefile/src/main/java/org/geotools/data/shapefile/dbf plugin/shapefile/src/test/java/org/geotools/data/shapefile

1 message Options
Embed this post
Permalink
svn_geotools

svn - r34359 - in trunk/modules: library/sample-data/src/main/resources/org/geotools/test-data/shapes plugin/shapefile/src/main/java/org/geotools/data/shapefile/dbf plugin/shapefile/src/test/java/org/geotools/data/shapefile

Reply Threaded More More options
Print post
Permalink
Author: aaime
Date: 2009-11-11 09:22:46 -0500 (Wed, 11 Nov 2009)
New Revision: 34359

Added:
   trunk/modules/library/sample-data/src/main/resources/org/geotools/test-data/shapes/rus-windows-1251.dbf
   trunk/modules/library/sample-data/src/main/resources/org/geotools/test-data/shapes/rus-windows-1251.prj
   trunk/modules/library/sample-data/src/main/resources/org/geotools/test-data/shapes/rus-windows-1251.shp
   trunk/modules/library/sample-data/src/main/resources/org/geotools/test-data/shapes/rus-windows-1251.shx
Modified:
   trunk/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/dbf/DbaseFileReader.java
   trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/ShapefileDataStoreTest.java
Log:
GEOT-2683, Speed up dbf reading when the target charset is not multibyte

Added: trunk/modules/library/sample-data/src/main/resources/org/geotools/test-data/shapes/rus-windows-1251.dbf
===================================================================
(Binary files differ)


Property changes on: trunk/modules/library/sample-data/src/main/resources/org/geotools/test-data/shapes/rus-windows-1251.dbf
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/modules/library/sample-data/src/main/resources/org/geotools/test-data/shapes/rus-windows-1251.prj
===================================================================
--- trunk/modules/library/sample-data/src/main/resources/org/geotools/test-data/shapes/rus-windows-1251.prj                        (rev 0)
+++ trunk/modules/library/sample-data/src/main/resources/org/geotools/test-data/shapes/rus-windows-1251.prj 2009-11-11 14:22:46 UTC (rev 34359)
@@ -0,0 +1 @@
+GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
\ No newline at end of file

Added: trunk/modules/library/sample-data/src/main/resources/org/geotools/test-data/shapes/rus-windows-1251.shp
===================================================================
(Binary files differ)


Property changes on: trunk/modules/library/sample-data/src/main/resources/org/geotools/test-data/shapes/rus-windows-1251.shp
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/modules/library/sample-data/src/main/resources/org/geotools/test-data/shapes/rus-windows-1251.shx
===================================================================
(Binary files differ)


Property changes on: trunk/modules/library/sample-data/src/main/resources/org/geotools/test-data/shapes/rus-windows-1251.shx
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Modified: trunk/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/dbf/DbaseFileReader.java
===================================================================
--- trunk/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/dbf/DbaseFileReader.java 2009-11-10 02:58:00 UTC (rev 34358)
+++ trunk/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/dbf/DbaseFileReader.java 2009-11-11 14:22:46 UTC (rev 34359)
@@ -26,7 +26,6 @@
 import java.nio.channels.FileChannel;
 import java.nio.channels.ReadableByteChannel;
 import java.nio.charset.Charset;
-import java.nio.charset.CharsetEncoder;
 import java.util.Calendar;
 
 import org.geotools.data.shapefile.FileReader;
@@ -185,9 +184,9 @@
         bytes = new byte[header.getRecordLength() - 1];
         
 
-        // check if we working with a 1 byte == 1 char Charset
-        final CharsetEncoder encoder = stringCharset.newEncoder();
-        oneBytePerChar = encoder.maxBytesPerChar() == 1.0f;
+        // check if we working with a latin-1 char Charset
+        final String cname = stringCharset.name();
+        oneBytePerChar = "ISO-8869-1".equals(cname) || "US-ASCII".equals(cname);
         
         row = new Row();
     }

Modified: trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/ShapefileDataStoreTest.java
===================================================================
--- trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/ShapefileDataStoreTest.java 2009-11-10 02:58:00 UTC (rev 34358)
+++ trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/ShapefileDataStoreTest.java 2009-11-11 14:22:46 UTC (rev 34359)
@@ -78,6 +78,7 @@
     final static String STREAM = "shapes/stream.shp";
     final static String DANISH = "shapes/danish_point.shp";
     final static String CHINESE = "shapes/chinese_poly.shp";
+    final static String RUSSIAN = "shapes/rus-windows-1251.shp";
     final static FilterFactory2 ff = CommonFactoryFinder
             .getFilterFactory2(null);
 
@@ -137,16 +138,32 @@
             SimpleFeature first = firstFeature(fc);
             String s = (String) first.getAttribute("NAME");
             assertEquals("\u9ed1\u9f99\u6c5f\u7701", s);
-        } catch (UnsupportedCharsetException notInstalledInJRE){
-                // this just means you have not installed
-                // chinese support into your JRE
-                // (as such it represents a bad configuration
-                //  rather than a test failure)
-                // we only wanted to ensure that if you have Chinese support
-                // available - GeoTools can use it
-            }
+        } catch (UnsupportedCharsetException notInstalledInJRE) {
+            // this just means you have not installed
+            // chinese support into your JRE
+            // (as such it represents a bad configuration
+            // rather than a test failure)
+            // we only wanted to ensure that if you have Chinese support
+            // available - GeoTools can use it
         }
+    }
     
+    public void testLoadRussianChars() throws Exception {
+        try {
+            FeatureCollection<SimpleFeatureType, SimpleFeature> fc = loadFeatures(RUSSIAN, Charset
+                    .forName("CP1251"), null);
+            FeatureIterator<SimpleFeature> features = fc.features();
+            SimpleFeature f = features.next();
+            assertEquals("\u041A\u0438\u0440\u0438\u043B\u043B\u0438\u0446\u0430", f.getAttribute("TEXT"));
+            f = features.next();
+            assertEquals("\u0421\u043C\u0435\u0448\u0430\u043D\u044B\u0439 12345", f.getAttribute("TEXT"));
+            features.close();
+        } catch (UnsupportedCharsetException notInstalledInJRE) {
+            // this just means you have not installed Russian support into your JRE
+            // (as such it represents a bad configuration rather than a test failure)
+        }
+    }
+    
 
     public void testNamespace() throws Exception {
         ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory();


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
GeoTools-commits mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-commits