[Schmitzm-commits] r1483 - in trunk: schmitzm-core/src/test/java/de/schmitzm/io schmitzm-gt/src/main/java/de/schmitzm/geotools/feature

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Feb 2 23:46:06 CET 2011


Author: alfonx
Date: 2011-02-02 23:46:05 +0100 (Wed, 02 Feb 2011)
New Revision: 1483

Modified:
   trunk/schmitzm-core/src/test/java/de/schmitzm/io/IOUtilTest.java
   trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/AttributeModificationRule.java
Log:
Fixed a bug the was found with a GP JUnit-test... When cloning a AttribtueFeatureType, settings the CRS is not enough to indicate that it is a a geometry Attribute Type.. since the crs may be null... 

Modified: trunk/schmitzm-core/src/test/java/de/schmitzm/io/IOUtilTest.java
===================================================================
--- trunk/schmitzm-core/src/test/java/de/schmitzm/io/IOUtilTest.java	2011-02-02 22:01:37 UTC (rev 1482)
+++ trunk/schmitzm-core/src/test/java/de/schmitzm/io/IOUtilTest.java	2011-02-02 22:46:05 UTC (rev 1483)
@@ -3,6 +3,7 @@
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
@@ -15,6 +16,7 @@
 import org.junit.Test;
 
 import de.schmitzm.testing.TestingClass;
+
 public class IOUtilTest extends TestingClass {
 	@Test
 	public void testZipDir() throws IOException {
@@ -70,7 +72,7 @@
 
 		assertEquals("exterme",
 				IOUtil.getFilename(new URL("http://www.bahn.de/exterme/")));
-		
+
 		assertEquals("exterme",
 				IOUtil.getFilename(new URL("http://www.bahn.de/exterme//")));
 
@@ -79,17 +81,27 @@
 	}
 
 	@Test
-	public void testGetFileFromJarFileUrl() throws MalformedURLException
-	{
-		URL u = new URL("jar:file:/home/stefan/.m2/repository/org/geopublishing/geopublisher/gpcore/1.7-SNAPSHOT/gpcore-1.7-SNAPSHOT-tests.jar!/atlases/ChartDemoAtlas/atlas.gpa");
-		
-		assertEquals("/home/stefan/.m2/repository/org/geopublishing/geopublisher/gpcore/1.7-SNAPSHOT/gpcore-1.7-SNAPSHOT-tests.jar", IOUtil.getFileFromJarFileUrl(u).toString());
+	public void testGetFileFromJarFileUrl() throws MalformedURLException {
+		URL u = new URL(
+				"jar:file:/home/stefan/.m2/repository/org/geopublishing/geopublisher/gpcore/1.7-SNAPSHOT/gpcore-1.7-SNAPSHOT-tests.jar!/atlases/ChartDemoAtlas/atlas.gpa");
+
+		assertEquals(
+				"/home/stefan/.m2/repository/org/geopublishing/geopublisher/gpcore/1.7-SNAPSHOT/gpcore-1.7-SNAPSHOT-tests.jar",
+				IOUtil.getFileFromJarFileUrl(u).toString());
 	}
 
 	@Test
-	public void testCleanFilename()
-	{
-		assertEquals( "geopublisher_poster.pdf", IOUtil.cleanFilename("Geopublisher Poster.pdf"));
-		assertEquals( "geopublisher_poster.pdf", IOUtil.cleanFilename("Geopublisher%20Poster.pdf"));
+	public void testCleanFilename() {
+		assertEquals("geopublisher_poster.pdf",
+				IOUtil.cleanFilename("Geopublisher Poster.pdf"));
+		assertEquals("geopublisher_poster.pdf",
+				IOUtil.cleanFilename("Geopublisher%20Poster.pdf"));
 	}
+
+	@Test
+	public void testUrlToFile() throws MalformedURLException {
+		assertNull(IOUtil
+				.urlToFile(new URL(
+						"jar:file:/home/stefan/Desktop/ae/DISK/atlasdata/vector_01367156967.jar!/ad/data/vector_01367156967_join10/join10.shp")));
+	}
 }

Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/AttributeModificationRule.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/AttributeModificationRule.java	2011-02-02 22:01:37 UTC (rev 1482)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/AttributeModificationRule.java	2011-02-02 22:46:05 UTC (rev 1483)
@@ -225,9 +225,10 @@
 		CoordinateReferenceSystem crs = null;
 		// if it is a GeometryAttributeType, the CRS must be stored
 		// in the meta data
-		if (FeatureUtil.isGeometryAttribute(sourceAttrDescr))
+		if (FeatureUtil.isGeometryAttribute(sourceAttrDescr)) {
 			crs = ((GeometryDescriptor) sourceAttrDescr)
 					.getCoordinateReferenceSystem();
+		}
 
 		// User the meta data from source type:
 		// combine the restrictions of the attribute type for the
@@ -235,7 +236,7 @@
 		Filter newRestrictions = FilterUtil.FILTER_FAC.and(sourceAttrDescr
 				.getType().getRestrictions());
 
-		if (crs == null)
+		if (!FeatureUtil.isGeometryAttribute(sourceAttrDescr))
 			return AttributeTypeFactory.newAttributeDescriptor(newName,
 					binding, newNillable, newRestrictions, newDefaultValue);
 		else



More information about the Schmitzm-commits mailing list