sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tlpin...@apache.org
Subject svn commit: r1517326 - in /sis/branches/Shapefile/storage/sis-shapefile/src: main/java/org/apache/sis/storage/shapefile/ShapeFile.java test/java/org/apache/sis/storage/shapefile/test/ShapeFileTest.java
Date Sun, 25 Aug 2013 16:10:56 GMT
Author: tlpinney
Date: Sun Aug 25 16:10:56 2013
New Revision: 1517326

URL: http://svn.apache.org/r1517326
Log:
Shapefile driver now uses DataStoreException

Added:
    sis/branches/Shapefile/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/test/ShapeFileTest.java
  (with props)
Modified:
    sis/branches/Shapefile/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java

Modified: sis/branches/Shapefile/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java
URL: http://svn.apache.org/viewvc/sis/branches/Shapefile/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java?rev=1517326&r1=1517325&r2=1517326&view=diff
==============================================================================
--- sis/branches/Shapefile/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java
(original)
+++ sis/branches/Shapefile/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java
Sun Aug 25 16:10:56 2013
@@ -31,6 +31,9 @@ import com.esri.core.geometry.Polygon;
 import com.esri.core.geometry.Polyline;
 //import org.apache.sis.internal.storage.ChannelImageInputStream;
 
+import org.apache.sis.storage.DataStoreException;
+
+
 
 /**
  * Provides a ShapeFile Reader
@@ -69,7 +72,7 @@ public class ShapeFile {
 	
 	
 	
-	public ShapeFile(String shpfile) throws IOException {
+	public ShapeFile(String shpfile) throws IOException, DataStoreException {
 			
 		FileInputStream fis = new FileInputStream(shpfile);
 		FileChannel fc = fis.getChannel();
@@ -171,10 +174,7 @@ public class ShapeFile {
 				int NumPoints = rf.getInt();
 				
 				if (NumParts > 1) {
-					// not implemented yet
-					// TODO: throw an exception
-					System.out.println("Not implemented yet.");
-					System.exit(-1);
+                    throw new DataStoreException("Polygons with multiple linear rings have
not implemented yet.");
 				}
 				
 				// read the one part 
@@ -232,10 +232,7 @@ public class ShapeFile {
 				f.setGeom(ply);
 				
 			} else {
-				// TODO: throw an exception
-				System.out.println("Unsupported shapefile type");
-				System.out.println(this.ShapeType);
-				System.exit(-1);
+                throw new DataStoreException("Unsupported shapefile type: " + this.ShapeType);
 			}
 			
 			rf.order(ByteOrder.BIG_ENDIAN);

Added: sis/branches/Shapefile/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/test/ShapeFileTest.java
URL: http://svn.apache.org/viewvc/sis/branches/Shapefile/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/test/ShapeFileTest.java?rev=1517326&view=auto
==============================================================================
--- sis/branches/Shapefile/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/test/ShapeFileTest.java
(added)
+++ sis/branches/Shapefile/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/test/ShapeFileTest.java
Sun Aug 25 16:10:56 2013
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2013 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.storage.shapefile.test;
+
+import java.io.IOException;
+import static junit.framework.Assert.assertEquals;
+
+import org.apache.sis.storage.DataStoreException;
+import org.apache.sis.storage.shapefile.ShapeFile;
+import org.junit.Test;
+
+
+
+public final strictfp class ShapeFileTest {
+    
+    
+    
+    
+    @Test
+    public void testPolyineCount() throws IOException, DataStoreException
+    {
+    	ShapeFile shp = new ShapeFile("data/SignedBikeRoute_4326_clipped.shp");		
+        assertEquals(shp.FeatureMap.size(), shp.FeatureCount);
+    }
+
+    @Test
+    public void testPolygonCount() throws IOException, DataStoreException
+    {
+    	 ShapeFile shp = new ShapeFile("data/ANC90Ply_4326.shp");
+    	 assertEquals(shp.FeatureMap.size(), shp.FeatureCount);
+    }
+
+    
+    @Test
+    public void testPointCount() throws IOException, DataStoreException
+    {
+    	ShapeFile shp = new ShapeFile("data/ABRALicenseePt_4326_clipped.shp");
+	    assertEquals(shp.FeatureMap.size(), shp.FeatureCount);
+    }
+
+  
+    
+    
+}

Propchange: sis/branches/Shapefile/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/test/ShapeFileTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message