You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(39) |
Dec
(70) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(52) |
Feb
(168) |
Mar
(248) |
Apr
(143) |
May
(418) |
Jun
(558) |
Jul
(702) |
Aug
(311) |
Sep
(141) |
Oct
(350) |
Nov
(172) |
Dec
(182) |
2003 |
Jan
(320) |
Feb
(362) |
Mar
(356) |
Apr
(218) |
May
(447) |
Jun
(203) |
Jul
(745) |
Aug
(494) |
Sep
(175) |
Oct
(422) |
Nov
(554) |
Dec
(162) |
2004 |
Jan
(217) |
Feb
(353) |
Mar
(228) |
Apr
(407) |
May
(211) |
Jun
(270) |
Jul
(264) |
Aug
(198) |
Sep
(268) |
Oct
(227) |
Nov
(118) |
Dec
(47) |
2005 |
Jan
(207) |
Feb
(243) |
Mar
(297) |
Apr
(197) |
May
(281) |
Jun
(166) |
Jul
(164) |
Aug
(92) |
Sep
(155) |
Oct
(196) |
Nov
(189) |
Dec
(114) |
2006 |
Jan
(129) |
Feb
(219) |
Mar
(274) |
Apr
(213) |
May
(245) |
Jun
(220) |
Jul
(376) |
Aug
(347) |
Sep
(179) |
Oct
(493) |
Nov
(448) |
Dec
(339) |
2007 |
Jan
(304) |
Feb
(273) |
Mar
(237) |
Apr
(186) |
May
(215) |
Jun
(320) |
Jul
(229) |
Aug
(313) |
Sep
(331) |
Oct
(279) |
Nov
(347) |
Dec
(266) |
2008 |
Jan
(332) |
Feb
(280) |
Mar
(203) |
Apr
(277) |
May
(301) |
Jun
(356) |
Jul
(292) |
Aug
(203) |
Sep
(277) |
Oct
(142) |
Nov
(210) |
Dec
(239) |
2009 |
Jan
(250) |
Feb
(193) |
Mar
(174) |
Apr
(183) |
May
(342) |
Jun
(230) |
Jul
(292) |
Aug
(161) |
Sep
(204) |
Oct
(280) |
Nov
(281) |
Dec
(175) |
2010 |
Jan
(113) |
Feb
(106) |
Mar
(199) |
Apr
(166) |
May
(298) |
Jun
(147) |
Jul
(175) |
Aug
(192) |
Sep
(71) |
Oct
(79) |
Nov
(58) |
Dec
(55) |
2011 |
Jan
(83) |
Feb
(169) |
Mar
(142) |
Apr
(207) |
May
(311) |
Jun
(183) |
Jul
(218) |
Aug
(190) |
Sep
(158) |
Oct
(197) |
Nov
(93) |
Dec
(74) |
2012 |
Jan
(92) |
Feb
(50) |
Mar
(64) |
Apr
(45) |
May
(100) |
Jun
(70) |
Jul
(3) |
Aug
(1) |
Sep
(2) |
Oct
(5) |
Nov
(7) |
Dec
(4) |
2013 |
Jan
(6) |
Feb
(2) |
Mar
(2) |
Apr
(4) |
May
(3) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
2014 |
Jan
(2) |
Feb
(2) |
Mar
(2) |
Apr
(3) |
May
(3) |
Jun
(1) |
Jul
|
Aug
(4) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(1) |
Dec
(1) |
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
(1) |
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
2017 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <svn...@os...> - 2012-02-04 11:04:51
|
Author: aaime Date: 2012-02-04 03:04:45 -0800 (Sat, 04 Feb 2012) New Revision: 38549 Modified: branches/2.7.x/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileDataStore.java branches/2.7.x/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/ShapefileDataStoreTest.java Log: [GEOT-4031] Add UUID support to shapefile output, patch by Shane StClair Modified: branches/2.7.x/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileDataStore.java =================================================================== --- branches/2.7.x/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileDataStore.java 2012-02-04 11:00:10 UTC (rev 38548) +++ branches/2.7.x/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileDataStore.java 2012-02-04 11:04:45 UTC (rev 38549) @@ -1165,7 +1165,7 @@ header.addColumn(colName, 'D', fieldLen, 0); } else if (colType == Boolean.class) { header.addColumn(colName, 'L', 1, 0); - } else if (CharSequence.class.isAssignableFrom(colType)) { + } else if (CharSequence.class.isAssignableFrom(colType) || colType == java.util.UUID.class) { // Possible fix for GEOT-42 : ArcExplorer doesn't like 0 length // ensure that maxLength is at least 1 header.addColumn(colName, 'C', Math.min(254, fieldLen), 0); Modified: branches/2.7.x/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/ShapefileDataStoreTest.java =================================================================== --- branches/2.7.x/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/ShapefileDataStoreTest.java 2012-02-04 11:00:10 UTC (rev 38548) +++ branches/2.7.x/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/ShapefileDataStoreTest.java 2012-02-04 11:04:45 UTC (rev 38549) @@ -34,6 +34,7 @@ import java.util.List; import java.util.Map; import java.util.TimeZone; +import java.util.UUID; import org.geotools.TestData; import org.geotools.data.DataUtilities; @@ -544,7 +545,8 @@ GregorianCalendar calendar = new GregorianCalendar(); calendar.setTimeInMillis(i); build.add(calendar); - + build.add(UUID.randomUUID()); + SimpleFeature feature = build.buildFeature(null); features.add(feature); } @@ -567,6 +569,7 @@ build.add("k", BigDecimal.class); build.add("l", BigInteger.class); build.add("m", Calendar.class); + build.add("n", UUID.class); return build.buildFeatureType(); } |
From: <svn...@os...> - 2012-02-04 11:00:17
|
Author: aaime Date: 2012-02-04 03:00:10 -0800 (Sat, 04 Feb 2012) New Revision: 38548 Modified: branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISDialect.java branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostgisViewTest.java branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostgisViewTestSetup.java Log: [GEOT-4030] Make sure last resort check on geometry srid is done on a non null geometry Modified: branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISDialect.java =================================================================== --- branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISDialect.java 2012-02-04 10:58:48 UTC (rev 38547) +++ branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISDialect.java 2012-02-04 11:00:10 UTC (rev 38548) @@ -435,6 +435,7 @@ if(srid == null) { String sqlStatement = "SELECT SRID(\"" + columnName + "\") " + "FROM \"" + schemaName + "\".\"" + tableName + "\" " + + "WHERE " + columnName + " IS NOT NULL " + "LIMIT 1"; result = statement.executeQuery(sqlStatement); if (result.next()) { Modified: branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostgisViewTest.java =================================================================== --- branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostgisViewTest.java 2012-02-04 10:58:48 UTC (rev 38547) +++ branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostgisViewTest.java 2012-02-04 11:00:10 UTC (rev 38548) @@ -2,6 +2,9 @@ import org.geotools.jdbc.JDBCViewTest; import org.geotools.jdbc.JDBCViewTestSetup; +import org.geotools.referencing.CRS; +import org.opengis.feature.simple.SimpleFeatureType; +import org.opengis.referencing.crs.CoordinateReferenceSystem; public class PostgisViewTest extends JDBCViewTest { @@ -10,4 +13,11 @@ return new PostgisViewTestSetup(); } + + public void testViewSrid() throws Exception { + SimpleFeatureType schema = dataStore.getSchema("lakes_null_view"); + CoordinateReferenceSystem crs = schema.getGeometryDescriptor().getCoordinateReferenceSystem(); + assertNotNull(crs); + assertTrue(CRS.equalsIgnoreMetadata(CRS.decode("EPSG:4326"), crs)); + } } Modified: branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostgisViewTestSetup.java =================================================================== --- branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostgisViewTestSetup.java 2012-02-04 10:58:48 UTC (rev 38547) +++ branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostgisViewTestSetup.java 2012-02-04 11:00:10 UTC (rev 38548) @@ -9,6 +9,24 @@ } @Override + protected void setUpData() throws Exception { + super.setUpData(); + + runSafe("DROP VIEW \"lakes_null_view\""); + runSafe("DROP TABLE \"lakes_null\""); + + run("CREATE TABLE \"lakes_null\"(\"fid\" int primary key, \"id\" int, " + + "\"geom\" geometry, \"name\" varchar )"); + + run("INSERT INTO \"lakes_null\" (\"fid\", \"id\",\"geom\",\"name\") VALUES (-1, -1," + + "null, 'empty')"); + run("INSERT INTO \"lakes_null\" (\"fid\", \"id\",\"geom\",\"name\") VALUES (0, 0," + + "GeomFromText('POLYGON((12 6, 14 8, 16 6, 16 4, 14 4, 12 6))',4326)," + + "'muddy')"); + run("CREATE VIEW \"lakes_null_view\" AS SELECT * FROM \"lakes_null\""); + } + + @Override protected void createLakesTable() throws Exception { run("CREATE TABLE \"lakes\"(\"fid\" int primary key, \"id\" int, " + "\"geom\" geometry, \"name\" varchar )"); |
From: <svn...@os...> - 2012-02-04 10:58:55
|
Author: aaime Date: 2012-02-04 02:58:48 -0800 (Sat, 04 Feb 2012) New Revision: 38547 Modified: trunk/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISDialect.java trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostgisViewTest.java trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostgisViewTestSetup.java Log: [GEOT-4030] Make sure last resort check on geometry srid is done on a non null geometry Modified: trunk/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISDialect.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISDialect.java 2012-02-04 10:56:11 UTC (rev 38546) +++ trunk/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISDialect.java 2012-02-04 10:58:48 UTC (rev 38547) @@ -453,6 +453,7 @@ if(srid == null) { String sqlStatement = "SELECT SRID(\"" + columnName + "\") " + "FROM \"" + schemaName + "\".\"" + tableName + "\" " + + "WHERE " + columnName + " IS NOT NULL " + "LIMIT 1"; result = statement.executeQuery(sqlStatement); if (result.next()) { Modified: trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostgisViewTest.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostgisViewTest.java 2012-02-04 10:56:11 UTC (rev 38546) +++ trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostgisViewTest.java 2012-02-04 10:58:48 UTC (rev 38547) @@ -2,6 +2,9 @@ import org.geotools.jdbc.JDBCViewTest; import org.geotools.jdbc.JDBCViewTestSetup; +import org.geotools.referencing.CRS; +import org.opengis.feature.simple.SimpleFeatureType; +import org.opengis.referencing.crs.CoordinateReferenceSystem; /** * @@ -15,4 +18,11 @@ return new PostgisViewTestSetup(); } + + public void testViewSrid() throws Exception { + SimpleFeatureType schema = dataStore.getSchema("lakes_null_view"); + CoordinateReferenceSystem crs = schema.getGeometryDescriptor().getCoordinateReferenceSystem(); + assertNotNull(crs); + assertTrue(CRS.equalsIgnoreMetadata(CRS.decode("EPSG:4326"), crs)); + } } Modified: trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostgisViewTestSetup.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostgisViewTestSetup.java 2012-02-04 10:56:11 UTC (rev 38546) +++ trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostgisViewTestSetup.java 2012-02-04 10:58:48 UTC (rev 38547) @@ -14,6 +14,24 @@ } @Override + protected void setUpData() throws Exception { + super.setUpData(); + + runSafe("DROP VIEW \"lakes_null_view\""); + runSafe("DROP TABLE \"lakes_null\""); + + run("CREATE TABLE \"lakes_null\"(\"fid\" int primary key, \"id\" int, " + + "\"geom\" geometry, \"name\" varchar )"); + + run("INSERT INTO \"lakes_null\" (\"fid\", \"id\",\"geom\",\"name\") VALUES (-1, -1," + + "null, 'empty')"); + run("INSERT INTO \"lakes_null\" (\"fid\", \"id\",\"geom\",\"name\") VALUES (0, 0," + + "GeomFromText('POLYGON((12 6, 14 8, 16 6, 16 4, 14 4, 12 6))',4326)," + + "'muddy')"); + run("CREATE VIEW \"lakes_null_view\" AS SELECT * FROM \"lakes_null\""); + } + + @Override protected void createLakesTable() throws Exception { run("CREATE TABLE \"lakes\"(\"fid\" int primary key, \"id\" int, " + "\"geom\" geometry, \"name\" varchar )"); |
From: <svn...@os...> - 2012-02-04 10:56:18
|
Author: aaime Date: 2012-02-04 02:56:11 -0800 (Sat, 04 Feb 2012) New Revision: 38546 Modified: trunk/modules/library/jdbc/src/main/java/org/geotools/jdbc/CompositePrimaryKeyFinder.java trunk/modules/library/jdbc/src/main/java/org/geotools/jdbc/JDBCDataStore.java Log: GEOT-4026, Make primary lookup code more robust in face of failures Modified: trunk/modules/library/jdbc/src/main/java/org/geotools/jdbc/CompositePrimaryKeyFinder.java =================================================================== --- trunk/modules/library/jdbc/src/main/java/org/geotools/jdbc/CompositePrimaryKeyFinder.java 2012-02-03 19:10:25 UTC (rev 38545) +++ trunk/modules/library/jdbc/src/main/java/org/geotools/jdbc/CompositePrimaryKeyFinder.java 2012-02-04 10:56:11 UTC (rev 38546) @@ -20,7 +20,10 @@ import java.sql.SQLException; import java.util.Arrays; import java.util.List; +import java.util.logging.Logger; +import org.geotools.util.logging.Logging; + /** * Executes a chain of {@link PrimaryKeyFinder} in the order they are defined * @@ -31,6 +34,8 @@ * @source $URL$ */ public class CompositePrimaryKeyFinder extends PrimaryKeyFinder { + + private static final Logger LOGGER = Logging.getLogger(CompositePrimaryKeyFinder.class); List<PrimaryKeyFinder> finders; @@ -42,9 +47,13 @@ public PrimaryKey getPrimaryKey(JDBCDataStore store, String schema, String table, Connection cx) throws SQLException { for (PrimaryKeyFinder finder : finders) { - PrimaryKey pk = finder.getPrimaryKey(store, schema, table, cx); - if (pk != null) - return pk; + try { + PrimaryKey pk = finder.getPrimaryKey(store, schema, table, cx); + if (pk != null) + return pk; + } catch(SQLException e) { + LOGGER.warning("Failure occurred while looking up the primary key with finder: " + finder); + } } return null; Modified: trunk/modules/library/jdbc/src/main/java/org/geotools/jdbc/JDBCDataStore.java =================================================================== --- trunk/modules/library/jdbc/src/main/java/org/geotools/jdbc/JDBCDataStore.java 2012-02-03 19:10:25 UTC (rev 38545) +++ trunk/modules/library/jdbc/src/main/java/org/geotools/jdbc/JDBCDataStore.java 2012-02-04 10:56:11 UTC (rev 38546) @@ -903,7 +903,7 @@ Connection cx = createConnection(); try { - PrimaryKey pkey; + PrimaryKey pkey = null; String tableName = entry.getName().getLocalPart(); if(virtualTables.containsKey(tableName)) { VirtualTable vt = virtualTables.get(tableName); @@ -929,7 +929,12 @@ pkey = new PrimaryKey(tableName, kcols); } } else { - pkey = primaryKeyFinder.getPrimaryKey(this, databaseSchema, tableName, cx); + try { + pkey = primaryKeyFinder.getPrimaryKey(this, databaseSchema, tableName, cx); + } catch(SQLException e) { + LOGGER.warning("Failure occurred while looking up the primary key with " + + "finder: " + primaryKeyFinder); + } if ( pkey == null ) { String msg = "No primary key or unique index found for " + tableName + "."; |
From: <svn...@os...> - 2012-02-03 19:10:34
|
Author: jdeolive Date: 2012-02-03 11:10:25 -0800 (Fri, 03 Feb 2012) New Revision: 38545 Modified: trunk/modules/unsupported/pom.xml Log: disabling geogit-versioned from all profile, does not compile Modified: trunk/modules/unsupported/pom.xml =================================================================== --- trunk/modules/unsupported/pom.xml 2012-02-01 04:55:39 UTC (rev 38544) +++ trunk/modules/unsupported/pom.xml 2012-02-03 19:10:25 UTC (rev 38545) @@ -165,9 +165,9 @@ </profile> <profile> <id>geogit-versioned</id> - <activation> + <!--activation> <property><name>all</name></property> - </activation> + </activation--> <modules> <module>geogit-versioned</module> </modules> |
From: <svn...@os...> - 2012-02-01 04:55:47
|
Author: bencaradocdavies Date: 2012-01-31 20:55:39 -0800 (Tue, 31 Jan 2012) New Revision: 38544 Modified: trunk/modules/extension/xsd/xsd-gml2/src/main/java/org/geotools/gml2/bindings/GML2EncodingUtils.java trunk/modules/extension/xsd/xsd-gml2/src/main/java/org/geotools/gml2/bindings/GMLEncodingUtils.java trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/GML3EncodingUtils.java trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/MultiCurveTypeBinding.java trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/MultiGeometryTypeBinding.java trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/MultiLineStringTypeBinding.java trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/MultiPointTypeBinding.java trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/MultiPolygonTypeBinding.java trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/MultiSurfaceTypeBinding.java trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/ext/MultiCurveTypeBinding.java trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/GML3TestSupport.java trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiCurveTypeBindingTest.java trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiGeometryTypeBindingTest.java trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiLineStringTypeBindingTest.java trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiPointTypeBindingTest.java trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiPolygonTypeBindingTest.java trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiSurfaceTypeBindingTest.java Log: GEOT-3824: Encoded GML 3.2 MultiSurface is schema-invalid because contained Polygon lacks gml:id Modified: trunk/modules/extension/xsd/xsd-gml2/src/main/java/org/geotools/gml2/bindings/GML2EncodingUtils.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml2/src/main/java/org/geotools/gml2/bindings/GML2EncodingUtils.java 2012-02-01 02:13:18 UTC (rev 38543) +++ trunk/modules/extension/xsd/xsd-gml2/src/main/java/org/geotools/gml2/bindings/GML2EncodingUtils.java 2012-02-01 04:55:39 UTC (rev 38544) @@ -16,9 +16,6 @@ */ package org.geotools.gml2.bindings; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -26,56 +23,25 @@ import java.util.logging.Logger; import javax.xml.namespace.QName; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDCompositor; -import org.eclipse.xsd.XSDDerivationMethod; import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDParticle; import org.eclipse.xsd.XSDTypeDefinition; -import org.eclipse.xsd.util.XSDConstants; -import org.geotools.feature.NameImpl; -//import org.geotools.gml2.GML; import org.geotools.gml2.GML; -import org.geotools.gml2.GMLConfiguration; -import org.geotools.gml2.bindings.GMLEncodingUtils; import org.geotools.metadata.iso.citation.Citations; import org.geotools.referencing.CRS; import org.geotools.referencing.CRS.AxisOrder; import org.geotools.util.logging.Logging; -import org.geotools.xlink.XLINK; import org.geotools.xml.Configuration; -import org.geotools.xml.Encoder; import org.geotools.xml.SchemaIndex; -import org.geotools.xml.Schemas; -import org.geotools.xs.XS; -import org.opengis.feature.ComplexAttribute; import org.opengis.feature.Feature; -import org.opengis.feature.GeometryAttribute; -import org.opengis.feature.Property; -import org.opengis.feature.simple.SimpleFeature; import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.feature.type.AttributeDescriptor; -import org.opengis.feature.type.ComplexType; import org.opengis.feature.type.FeatureType; -import org.opengis.feature.type.GeometryDescriptor; -import org.opengis.feature.type.Name; -import org.opengis.geometry.BoundingBox; import org.opengis.metadata.Identifier; import org.opengis.referencing.crs.CoordinateReferenceSystem; -import org.opengis.referencing.crs.GeographicCRS; -import org.opengis.referencing.crs.ProjectedCRS; -import org.opengis.referencing.cs.AxisDirection; -import org.opengis.referencing.cs.CoordinateSystem; import org.w3c.dom.Document; import org.w3c.dom.Element; import com.vividsolutions.jts.geom.Geometry; -import com.vividsolutions.jts.geom.GeometryCollection; /** * Utility methods used by gml2 bindigns when encodding. @@ -185,6 +151,19 @@ } /** + * Set the identifier (gml:id) of the geometry as a key in the user data map + * {@link Geometry#getUserData()} (creating it with{@link Geometry#getUserData()} + * if it does not already exist). If the user data exists and is not a + * {@link Map}, this method has no effect. + * + * @param g the geometry + * @param id the gml:id to be set + */ + public static void setID(Geometry g, String id) { + e.setMetadata(g, "gml:id", id); + } + + /** * Determines the description (gml:description) of the geometry by checking * {@link Geometry#getUserData()}. * <p> @@ -196,6 +175,19 @@ } /** + * Set the name (gml:name) of the geometry as a key in the user data map + * {@link Geometry#getUserData()} (creating it with{@link Geometry#getUserData()} + * if it does not already exist). If the user data exists and is not a + * {@link Map}, this method has no effect. + * + * @param g the geometry + * @param name the gml:name to be set + */ + public static void setName(Geometry g, String name) { + e.setMetadata(g, "gml:name", name); + } + + /** * Determines the name (gml:name) of the geometry by checking * {@link Geometry#getUserData()}. * <p> @@ -206,6 +198,19 @@ return e.getMetadata( g, "gml:description" ); } + /** + * Set the description (gml:description) of the geometry as a key in the user data map + * {@link Geometry#getUserData()} (creating it with{@link Geometry#getUserData()} + * if it does not already exist). If the user data exists and is not a + * {@link Map}, this method has no effect. + * + * @param g the geometry + * @param description the gml:description to be set + */ + public static void setDescription(Geometry g, String description) { + e.setMetadata(g, "gml:description", description); + } + public static Element AbstractFeatureType_encode(Object object, Document document, Element value) { Feature feature = (Feature) object; FeatureType featureType = feature.getType(); Modified: trunk/modules/extension/xsd/xsd-gml2/src/main/java/org/geotools/gml2/bindings/GMLEncodingUtils.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml2/src/main/java/org/geotools/gml2/bindings/GMLEncodingUtils.java 2012-02-01 02:13:18 UTC (rev 38543) +++ trunk/modules/extension/xsd/xsd-gml2/src/main/java/org/geotools/gml2/bindings/GMLEncodingUtils.java 2012-02-01 04:55:39 UTC (rev 38544) @@ -3,7 +3,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -24,7 +23,6 @@ import org.eclipse.xsd.XSDTypeDefinition; import org.eclipse.xsd.util.XSDConstants; import org.geotools.feature.NameImpl; -import org.geotools.gml2.GML; import org.geotools.gml2.GMLConfiguration; import org.geotools.util.logging.Logging; import org.geotools.xlink.XLINK; @@ -415,14 +413,6 @@ } public List GeometryPropertyType_getProperties(Geometry geometry) { - - String id = getID( geometry ); - - if ( !isEmpty(geometry) && id != null ) { - // return a comment which is hte xlink href - return Collections.singletonList(new Object[] { Encoder.COMMENT, "#" +id }); - } - return null; } @@ -453,6 +443,19 @@ } /** + * Set the identifier (gml:id) of the geometry as a key in the user data map + * {@link Geometry#getUserData()} (creating it with{@link Geometry#getUserData()} + * if it does not already exist). If the user data exists and is not a + * {@link Map}, this method has no effect. + * + * @param g the geometry + * @param id the gml:id to be set + */ + public void setID(Geometry g, String id) { + setMetadata(g, "gml:id", id); + } + + /** * Determines the description (gml:description) of the geometry by checking * {@link Geometry#getUserData()}. * <p> @@ -464,6 +467,19 @@ } /** + * Set the name (gml:name) of the geometry as a key in the user data map + * {@link Geometry#getUserData()} (creating it with{@link Geometry#getUserData()} + * if it does not already exist). If the user data exists and is not a + * {@link Map}, this method has no effect. + * + * @param g the geometry + * @param name the gml:name to be set + */ + public void setName(Geometry g, String name) { + setMetadata(g, "gml:name", name); + } + + /** * Determines the name (gml:name) of the geometry by checking * {@link Geometry#getUserData()}. * <p> @@ -474,14 +490,36 @@ return getMetadata( g, "gml:description" ); } + /** + * Set the description (gml:description) of the geometry as a key in the user data map + * {@link Geometry#getUserData()} (creating it with{@link Geometry#getUserData()} + * if it does not already exist). If the user data exists and is not a + * {@link Map}, this method has no effect. + * + * @param g the geometry + * @param description the gml:description to be set + */ + public void setDescription(Geometry g, String description) { + setMetadata(g, "gml:description", description); + } + + @SuppressWarnings("rawtypes") String getMetadata(Geometry g, String metadata) { if (g.getUserData() instanceof Map) { Map userData = (Map) g.getUserData(); - return (String) userData.get(metadata); } - return null; } + @SuppressWarnings({ "unchecked", "rawtypes" }) + void setMetadata(Geometry g, String metadata, String value) { + if (g.getUserData() == null) { + g.setUserData(new HashMap()); + } + if (g.getUserData() instanceof Map) { + ((Map) g.getUserData()).put(metadata, value); + } + } + } Modified: trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/GML3EncodingUtils.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/GML3EncodingUtils.java 2012-02-01 02:13:18 UTC (rev 38543) +++ trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/GML3EncodingUtils.java 2012-02-01 04:55:39 UTC (rev 38544) @@ -24,7 +24,6 @@ import java.util.List; import java.util.Map; -import javax.xml.XMLConstants; import javax.xml.namespace.QName; import org.eclipse.xsd.XSDElementDeclaration; @@ -32,7 +31,6 @@ import org.geotools.geometry.DirectPosition2D; import org.geotools.gml2.bindings.GML2EncodingUtils; import org.geotools.gml2.bindings.GMLEncodingUtils; -//import org.geotools.gml3.GML; import org.geotools.gml3.GML; import org.geotools.gml3.XSDIdRegistry; import org.geotools.util.Converters; @@ -136,15 +134,47 @@ return GML2EncodingUtils.getID(g); } + static void setID(Geometry g, String id) { + GML2EncodingUtils.setID(g, id); + } + static String getName(Geometry g) { return GML2EncodingUtils.getName(g); } + static void setName(Geometry g, String name) { + GML2EncodingUtils.setName(g, name); + } + static String getDescription(Geometry g) { return GML2EncodingUtils.getDescription(g); } + static void setDescription(Geometry g, String description) { + GML2EncodingUtils.setDescription(g, description); + } + /** + * Set a synthetic gml:id on each child of a multigeometry. If the multigeometry has no gml:id, + * this method has no effect. The synthetic gml:id of each child is constructed from that of the + * parent by appending "." and then an integer starting from one for the first child. + * + * @param multiGeometry + * parent multigeometry containing the children to be modified + */ + static void setChildIDs(Geometry multiGeometry) { + String id = getID(multiGeometry); + if (id != null) { + for (int i = 0; i < multiGeometry.getNumGeometries(); i++) { + StringBuilder builder = new StringBuilder(id); + builder.append("."); // separator + builder.append(i + 1); // synthetic gml:id suffix one-based + GML2EncodingUtils.setID(multiGeometry.getGeometryN(i), builder.toString()); + } + } + } + + /** * Helper method used to implement {@link ComplexBinding#getProperty(Object, QName)} for * bindings of geometry reference types: * <ul> Modified: trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/MultiCurveTypeBinding.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/MultiCurveTypeBinding.java 2012-02-01 02:13:18 UTC (rev 38543) +++ trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/MultiCurveTypeBinding.java 2012-02-01 04:55:39 UTC (rev 38544) @@ -16,7 +16,6 @@ */ package org.geotools.gml3.bindings; -import java.util.Arrays; import java.util.List; import javax.xml.namespace.QName; @@ -134,6 +133,8 @@ members[i] = (LineString) multiCurve.getGeometryN(i); } + GML3EncodingUtils.setChildIDs(multiCurve); + return members; } Modified: trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/MultiGeometryTypeBinding.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/MultiGeometryTypeBinding.java 2012-02-01 02:13:18 UTC (rev 38543) +++ trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/MultiGeometryTypeBinding.java 2012-02-01 04:55:39 UTC (rev 38544) @@ -120,6 +120,8 @@ members[i] = (Geometry) multiGeometry.getGeometryN(i); } + GML3EncodingUtils.setChildIDs(multiGeometry); + return members; } Modified: trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/MultiLineStringTypeBinding.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/MultiLineStringTypeBinding.java 2012-02-01 02:13:18 UTC (rev 38543) +++ trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/MultiLineStringTypeBinding.java 2012-02-01 04:55:39 UTC (rev 38544) @@ -111,6 +111,8 @@ members[i] = (LineString) multiLineString.getGeometryN(i); } + GML3EncodingUtils.setChildIDs(multiLineString); + return members; } Modified: trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/MultiPointTypeBinding.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/MultiPointTypeBinding.java 2012-02-01 02:13:18 UTC (rev 38543) +++ trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/MultiPointTypeBinding.java 2012-02-01 04:55:39 UTC (rev 38544) @@ -126,6 +126,8 @@ members[i] = (Point) multiPoint.getGeometryN(i); } + GML3EncodingUtils.setChildIDs(multiPoint); + return members; } Modified: trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/MultiPolygonTypeBinding.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/MultiPolygonTypeBinding.java 2012-02-01 02:13:18 UTC (rev 38543) +++ trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/MultiPolygonTypeBinding.java 2012-02-01 04:55:39 UTC (rev 38544) @@ -110,6 +110,8 @@ members[i] = (Polygon) multiPolygon.getGeometryN(i); } + GML3EncodingUtils.setChildIDs(multiPolygon); + return members; } Modified: trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/MultiSurfaceTypeBinding.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/MultiSurfaceTypeBinding.java 2012-02-01 02:13:18 UTC (rev 38543) +++ trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/MultiSurfaceTypeBinding.java 2012-02-01 04:55:39 UTC (rev 38544) @@ -123,6 +123,8 @@ members[i] = (Polygon) multiSurface.getGeometryN(i); } + GML3EncodingUtils.setChildIDs(multiSurface); + return members; } Modified: trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/ext/MultiCurveTypeBinding.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/ext/MultiCurveTypeBinding.java 2012-02-01 02:13:18 UTC (rev 38543) +++ trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/ext/MultiCurveTypeBinding.java 2012-02-01 04:55:39 UTC (rev 38544) @@ -17,13 +17,8 @@ package org.geotools.gml3.bindings.ext; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import javax.xml.namespace.QName; - -import org.geotools.gml3.GML; -import org.geotools.xml.AbstractComplexBinding; import org.geotools.xml.ElementInstance; import org.geotools.xml.Node; Modified: trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/GML3TestSupport.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/GML3TestSupport.java 2012-02-01 02:13:18 UTC (rev 38543) +++ trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/GML3TestSupport.java 2012-02-01 04:55:39 UTC (rev 38544) @@ -19,6 +19,7 @@ import org.geotools.xml.Configuration; import org.geotools.xml.test.XMLTestSupport; import org.w3c.dom.Element; +import org.w3c.dom.Node; /* * Test bindings by extending this class with test cases that follow this pattern: @@ -87,4 +88,16 @@ protected boolean enableExtendedArcSurfaceSupport() { return false; } + + /** + * Return the gml:id of a Node (must be an Element). + * + * @param node + * @return the gml:id + */ + protected String getID(Node node) { + return node.getAttributes().getNamedItemNS(GML.NAMESPACE, GML.id.getLocalPart()) + .getNodeValue(); + } + } Modified: trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiCurveTypeBindingTest.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiCurveTypeBindingTest.java 2012-02-01 02:13:18 UTC (rev 38543) +++ trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiCurveTypeBindingTest.java 2012-02-01 04:55:39 UTC (rev 38544) @@ -19,22 +19,32 @@ import org.geotools.gml3.GML; import org.geotools.gml3.GML3TestSupport; import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.MultiLineString; -import com.vividsolutions.jts.geom.MultiPolygon; - /** * * * @source $URL$ */ public class MultiCurveTypeBindingTest extends GML3TestSupport { + public void testEncode() throws Exception { - Document dom = encode(GML3MockData.multiLineString(), GML.MultiCurve); + Geometry geometry = GML3MockData.multiLineString(); + GML3EncodingUtils.setID(geometry, "geometry"); + Document dom = encode(geometry, GML.MultiCurve); + // print(dom); + assertEquals("geometry", getID(dom.getDocumentElement())); assertEquals(2, dom.getElementsByTagNameNS(GML.NAMESPACE, "curveMember").getLength()); + NodeList children = dom + .getElementsByTagNameNS(GML.NAMESPACE, GML.LineString.getLocalPart()); + assertEquals(2, children.getLength()); + assertEquals("geometry.1", getID(children.item(0))); + assertEquals("geometry.2", getID(children.item(1))); } - + public void testParseWithCurveMember() throws Exception { GML3MockData.multiCurve(document, document); MultiLineString mline = (MultiLineString) parse(); Modified: trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiGeometryTypeBindingTest.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiGeometryTypeBindingTest.java 2012-02-01 02:13:18 UTC (rev 38543) +++ trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiGeometryTypeBindingTest.java 2012-02-01 04:55:39 UTC (rev 38544) @@ -20,6 +20,7 @@ import org.geotools.gml3.GML3TestSupport; import org.w3c.dom.Document; +import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryCollection; /** @@ -39,9 +40,19 @@ assertEquals(3, multiGeom.getNumGeometries()); } - public void testEncode() throws Exception { - Document dom = encode(GML3MockData.multiGeometry(), GML.MultiGeometry); - assertEquals(3, - dom.getElementsByTagNameNS(GML.NAMESPACE, GML.geometryMember.getLocalPart()).getLength()); + public void testEncode() throws Exception { Geometry geometry = GML3MockData.multiGeometry(); + GML3EncodingUtils.setID(geometry, "geometry"); + Document dom = encode(geometry, GML.MultiGeometry); + // print(dom); + assertEquals("geometry", getID(dom.getDocumentElement())); + assertEquals(3, dom.getElementsByTagNameNS(GML.NAMESPACE, "geometryMember").getLength()); + // geometry.1 is not encoded on the gml:Point because user data is already being used for + // srsDimension and srsName; not going to support the use of these inside a multigeometry + // and combined with gml:id + assertEquals("geometry.2", getID(dom.getElementsByTagNameNS(GML.NAMESPACE, "LineString") + .item(0))); + assertEquals("geometry.3", + getID(dom.getElementsByTagNameNS(GML.NAMESPACE, "Polygon").item(0))); } + } Modified: trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiLineStringTypeBindingTest.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiLineStringTypeBindingTest.java 2012-02-01 02:13:18 UTC (rev 38543) +++ trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiLineStringTypeBindingTest.java 2012-02-01 04:55:39 UTC (rev 38544) @@ -19,7 +19,9 @@ import org.geotools.gml3.GML; import org.geotools.gml3.GML3TestSupport; import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.MultiLineString; @@ -39,9 +41,16 @@ } public void testEncode() throws Exception { - Document dom = encode(GML3MockData.multiLineString(), GML.MultiLineString); - assertEquals(2, - dom.getElementsByTagNameNS(GML.NAMESPACE, GML.lineStringMember.getLocalPart()) - .getLength()); + Geometry geometry = GML3MockData.multiLineString(); + GML3EncodingUtils.setID(geometry, "geometry"); + Document dom = encode(geometry, GML.MultiLineString); + // print(dom); + assertEquals("geometry", getID(dom.getDocumentElement())); + assertEquals(2, dom.getElementsByTagNameNS(GML.NAMESPACE, "lineStringMember").getLength()); + NodeList children = dom.getElementsByTagNameNS(GML.NAMESPACE, GML.LineString.getLocalPart()); + assertEquals(2, children.getLength()); + assertEquals("geometry.1", getID(children.item(0))); + assertEquals("geometry.2", getID(children.item(1))); } + } Modified: trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiPointTypeBindingTest.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiPointTypeBindingTest.java 2012-02-01 02:13:18 UTC (rev 38543) +++ trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiPointTypeBindingTest.java 2012-02-01 04:55:39 UTC (rev 38544) @@ -19,7 +19,9 @@ import org.geotools.gml3.GML; import org.geotools.gml3.GML3TestSupport; import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.MultiPoint; @@ -39,8 +41,16 @@ } public void testEncode() throws Exception { - Document dom = encode(GML3MockData.multiPoint(), GML.MultiPoint); - assertEquals(2, - dom.getElementsByTagNameNS(GML.NAMESPACE, GML.pointMember.getLocalPart()).getLength()); + Geometry geometry = GML3MockData.multiPoint(); + GML3EncodingUtils.setID(geometry, "geometry"); + Document dom = encode(geometry, GML.MultiPoint); + // print(dom); + assertEquals("geometry", getID(dom.getDocumentElement())); + assertEquals(2, dom.getElementsByTagNameNS(GML.NAMESPACE, "pointMember").getLength()); + NodeList children = dom.getElementsByTagNameNS(GML.NAMESPACE, GML.Point.getLocalPart()); + assertEquals(2, children.getLength()); + assertEquals("geometry.1", getID(children.item(0))); + assertEquals("geometry.2", getID(children.item(1))); } + } Modified: trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiPolygonTypeBindingTest.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiPolygonTypeBindingTest.java 2012-02-01 02:13:18 UTC (rev 38543) +++ trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiPolygonTypeBindingTest.java 2012-02-01 04:55:39 UTC (rev 38544) @@ -19,7 +19,9 @@ import org.geotools.gml3.GML; import org.geotools.gml3.GML3TestSupport; import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.MultiPolygon; @@ -38,8 +40,16 @@ } public void testEncode() throws Exception { - Document dom = encode(GML3MockData.multiPolygon(), GML.MultiPolygon); - assertEquals(2, - dom.getElementsByTagNameNS(GML.NAMESPACE, GML.polygonMember.getLocalPart()).getLength()); + Geometry geometry = GML3MockData.multiPolygon(); + GML3EncodingUtils.setID(geometry, "geometry"); + Document dom = encode(geometry, GML.MultiPolygon); + // print(dom); + assertEquals("geometry", getID(dom.getDocumentElement())); + assertEquals(2, dom.getElementsByTagNameNS(GML.NAMESPACE, "polygonMember").getLength()); + NodeList children = dom.getElementsByTagNameNS(GML.NAMESPACE, GML.Polygon.getLocalPart()); + assertEquals(2, children.getLength()); + assertEquals("geometry.1", getID(children.item(0))); + assertEquals("geometry.2", getID(children.item(1))); } + } Modified: trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiSurfaceTypeBindingTest.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiSurfaceTypeBindingTest.java 2012-02-01 02:13:18 UTC (rev 38543) +++ trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiSurfaceTypeBindingTest.java 2012-02-01 04:55:39 UTC (rev 38544) @@ -19,7 +19,9 @@ import org.geotools.gml3.GML; import org.geotools.gml3.GML3TestSupport; import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.MultiPolygon; @@ -29,12 +31,20 @@ * @source $URL$ */ public class MultiSurfaceTypeBindingTest extends GML3TestSupport { + public void testEncode() throws Exception { - Document dom = encode(GML3MockData.multiPolygon(), GML.MultiSurface); - assertEquals(2, - dom.getElementsByTagNameNS(GML.NAMESPACE, GML.Polygon.getLocalPart()).getLength()); + Geometry geometry = GML3MockData.multiPolygon(); + GML3EncodingUtils.setID(geometry, "geometry"); + Document dom = encode(geometry, GML.MultiSurface); + // print(dom); + assertEquals("geometry", getID(dom.getDocumentElement())); + assertEquals(2, dom.getElementsByTagNameNS(GML.NAMESPACE, "surfaceMember").getLength()); + NodeList children = dom.getElementsByTagNameNS(GML.NAMESPACE, GML.Polygon.getLocalPart()); + assertEquals(2, children.getLength()); + assertEquals("geometry.1", getID(children.item(0))); + assertEquals("geometry.2", getID(children.item(1))); } - + public void testParseWithSurfaceMember() throws Exception { GML3MockData.multiSurface(document, document); MultiPolygon mpoly = (MultiPolygon) parse(); |
From: <svn...@os...> - 2012-02-01 02:13:25
|
Author: bencaradocdavies Date: 2012-01-31 18:13:18 -0800 (Tue, 31 Jan 2012) New Revision: 38543 Modified: trunk/pom.xml Log: GEOT-3932: Build failure with subversion >= 1.7 working directory Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-01-31 21:00:34 UTC (rev 38542) +++ trunk/pom.xml 2012-02-01 02:13:18 UTC (rev 38543) @@ -1261,8 +1261,8 @@ <!-- ======================================================= --> <plugin> <groupId>com.google.code.maven-svn-revision-number-plugin</groupId> - <artifactId>maven-svn-revision-number-plugin</artifactId> - <version>1.5</version> + <artifactId>svn-revision-number-maven-plugin</artifactId> + <version>1.8-SVN7</version> <executions> <execution> <goals> @@ -1464,6 +1464,16 @@ <enabled>false</enabled> </snapshots> </pluginRepository> + <pluginRepository> + <id>maven-svn-revision-number-plugin.googlecode.com</id> + <url>http://maven-svn-revision-number-plugin.googlecode.com/svn/m2/releases</url> + <releases> + <enabled>true</enabled> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </pluginRepository> </pluginRepositories> |
Author: groldan Date: 2012-01-31 13:00:34 -0800 (Tue, 31 Jan 2012) New Revision: 38542 Added: trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/CapabilityBinding.java trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/DCPTypeBinding.java trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/LatLongBoundingBoxBinding.java trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/ServiceTypeBinding.java trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/WFSCapabilities.java trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/WFSCapabilitiesConfiguration.java trunk/modules/extension/xsd/xsd-wfs/src/test/java/org/geotools/wfs/WFS_1_0_0_ParsingTest.java trunk/modules/extension/xsd/xsd-wfs/src/test/resources/org/geotools/wfs/geoserver-GetCapabilities_1_0_0.xml Modified: trunk/modules/extension/xsd/xsd-filter/src/test/java/org/geotools/filter/v1_0/FilterTestSupport.java trunk/modules/extension/xsd/xsd-filter/src/test/java/org/geotools/filter/v1_0/capabilities/FilterCapabilitiesTestSupport.java trunk/modules/extension/xsd/xsd-filter/src/test/java/org/geotools/filter/v1_0/capabilities/_Filter_CapabilitiesTypeBindingTest.java trunk/modules/extension/xsd/xsd-filter/src/test/java/org/geotools/filter/v1_1/FilterTestSupport.java trunk/modules/extension/xsd/xsd-filter/src/test/java/org/geotools/filter/v1_1/capabilities/OGCTestSupport.java trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/bindings/FeatureTypeTypeBinding.java trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/WFS.java trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/WFSConfiguration.java Log: add missing xsd-filter and xsd-wfs bindings to enable WFS 1.0 capabilities parsing Modified: trunk/modules/extension/xsd/xsd-filter/src/test/java/org/geotools/filter/v1_0/FilterTestSupport.java =================================================================== --- trunk/modules/extension/xsd/xsd-filter/src/test/java/org/geotools/filter/v1_0/FilterTestSupport.java 2012-01-29 17:47:31 UTC (rev 38541) +++ trunk/modules/extension/xsd/xsd-filter/src/test/java/org/geotools/filter/v1_0/FilterTestSupport.java 2012-01-31 21:00:34 UTC (rev 38542) @@ -25,7 +25,7 @@ * * @source $URL$ */ -public class FilterTestSupport extends XMLTestSupport { +public abstract class FilterTestSupport extends XMLTestSupport { protected Configuration createConfiguration() { return new OGCConfiguration(); } Modified: trunk/modules/extension/xsd/xsd-filter/src/test/java/org/geotools/filter/v1_0/capabilities/FilterCapabilitiesTestSupport.java =================================================================== --- trunk/modules/extension/xsd/xsd-filter/src/test/java/org/geotools/filter/v1_0/capabilities/FilterCapabilitiesTestSupport.java 2012-01-29 17:47:31 UTC (rev 38541) +++ trunk/modules/extension/xsd/xsd-filter/src/test/java/org/geotools/filter/v1_0/capabilities/FilterCapabilitiesTestSupport.java 2012-01-31 21:00:34 UTC (rev 38542) @@ -25,7 +25,7 @@ * * @source $URL$ */ -public class FilterCapabilitiesTestSupport extends XMLTestSupport { +public abstract class FilterCapabilitiesTestSupport extends XMLTestSupport { protected Configuration createConfiguration() { return new OGCConfiguration(); } Modified: trunk/modules/extension/xsd/xsd-filter/src/test/java/org/geotools/filter/v1_0/capabilities/_Filter_CapabilitiesTypeBindingTest.java =================================================================== --- trunk/modules/extension/xsd/xsd-filter/src/test/java/org/geotools/filter/v1_0/capabilities/_Filter_CapabilitiesTypeBindingTest.java 2012-01-29 17:47:31 UTC (rev 38541) +++ trunk/modules/extension/xsd/xsd-filter/src/test/java/org/geotools/filter/v1_0/capabilities/_Filter_CapabilitiesTypeBindingTest.java 2012-01-31 21:00:34 UTC (rev 38542) @@ -16,9 +16,12 @@ */ package org.geotools.filter.v1_0.capabilities; +import java.io.ByteArrayInputStream; + import org.w3c.dom.Document; import org.opengis.filter.capability.FilterCapabilities; import org.geotools.xml.Binding; +import org.geotools.xml.Parser; /** @@ -38,6 +41,8 @@ public void testParse() throws Exception { FilterMockData.capabilities(document, document); + // print(document); + FilterCapabilities caps = (FilterCapabilities) parse(); assertEquals(FilterCapabilities.VERSION_100, caps.getVersion()); @@ -45,6 +50,51 @@ assertNotNull(caps.getSpatialCapabilities()); } + public void testParseWithParser() throws Exception { + String xml= "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + + "<Filter_Capabilities version=\"1.0.0\" xmlns=\"http://www.opengis.net/ogc\">" + + "<Scalar_Capabilities>" + + "<Logical_Operators/>" + + "<Comparison_Operators>" + + "<Simple_Comparisons/>" + + "<Like/>" + + "<Between/>" + + "<NullCheck/>" + + "</Comparison_Operators>" + + "<Arithmetic_Operators>" + + "<Simple_Arithmetic/>" + + "<Functions>" + + "<Function_Names>" + + "<Function_Name nArgs=\"2\">foo</Function_Name>" + + "<Function_Name nArgs=\"3\">bar</Function_Name>" + + "</Function_Names>" + + "</Functions>" + + "</Arithmetic_Operators>" + + "</Scalar_Capabilities>" + + "<Spatial_Capabilities>" + + "<Spatial_Operators>" + + "<BBOX/>" + + "<Equals/>" + + "<Disjoint/>" + + "<Intersect/>" + + "<Touches/>" + + "<Contains/>" + + "<Crosses/>" + + "<Within/>" + + "<Overlaps/>" + + "<Beyond/>" + + "<DWithin/>" + + "</Spatial_Operators>" + + "</Spatial_Capabilities>" + + "</Filter_Capabilities>"; + + Parser parser = new Parser(createConfiguration()); + FilterCapabilities caps = (FilterCapabilities) parser.parse(new ByteArrayInputStream(xml.getBytes())); + assertEquals(FilterCapabilities.VERSION_100, caps.getVersion()); + assertNotNull(caps.getScalarCapabilities()); + assertNotNull(caps.getSpatialCapabilities()); + } + public void testEncode() throws Exception { Document dom = encode(FilterMockData.capabilities(), OGC.Filter_Capabilities); Modified: trunk/modules/extension/xsd/xsd-filter/src/test/java/org/geotools/filter/v1_1/FilterTestSupport.java =================================================================== --- trunk/modules/extension/xsd/xsd-filter/src/test/java/org/geotools/filter/v1_1/FilterTestSupport.java 2012-01-29 17:47:31 UTC (rev 38541) +++ trunk/modules/extension/xsd/xsd-filter/src/test/java/org/geotools/filter/v1_1/FilterTestSupport.java 2012-01-31 21:00:34 UTC (rev 38542) @@ -25,7 +25,7 @@ * * @source $URL$ */ -public class FilterTestSupport extends XMLTestSupport { +public abstract class FilterTestSupport extends XMLTestSupport { protected Configuration createConfiguration() { return new OGCConfiguration(); } Modified: trunk/modules/extension/xsd/xsd-filter/src/test/java/org/geotools/filter/v1_1/capabilities/OGCTestSupport.java =================================================================== --- trunk/modules/extension/xsd/xsd-filter/src/test/java/org/geotools/filter/v1_1/capabilities/OGCTestSupport.java 2012-01-29 17:47:31 UTC (rev 38541) +++ trunk/modules/extension/xsd/xsd-filter/src/test/java/org/geotools/filter/v1_1/capabilities/OGCTestSupport.java 2012-01-31 21:00:34 UTC (rev 38542) @@ -30,7 +30,7 @@ * * @source $URL$ */ -public class OGCTestSupport extends XMLTestSupport { +public abstract class OGCTestSupport extends XMLTestSupport { protected Configuration createConfiguration() { return new OGCConfiguration(); } Modified: trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/bindings/FeatureTypeTypeBinding.java =================================================================== --- trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/bindings/FeatureTypeTypeBinding.java 2012-01-29 17:47:31 UTC (rev 38541) +++ trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/bindings/FeatureTypeTypeBinding.java 2012-01-31 21:00:34 UTC (rev 38542) @@ -16,13 +16,19 @@ */ package org.geotools.wfs.bindings; +import java.math.BigInteger; import java.net.URI; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.List; +import java.util.Map; import javax.xml.namespace.QName; +import net.opengis.ows10.KeywordsType; +import net.opengis.ows10.Ows10Factory; +import net.opengis.ows10.WGS84BoundingBoxType; import net.opengis.wfs.FeatureTypeType; import net.opengis.wfs.WfsFactory; @@ -161,9 +167,22 @@ URI uri = (URI) value; value = uri.toString(); } - } else if ("DefaultCRS".equals(property)) { + } else if ("DefaultCRS".equals(property) || "SRS".equals(property)) { // WFS 1.0 String crs = value == null ? null : String.valueOf(value); ((FeatureTypeType) eObject).setDefaultSRS(crs); + } else if ("Keywords".equals(property)){ + if (value instanceof String) { + String[] split = ((String) value).split(","); + KeywordsType kwd = Ows10Factory.eINSTANCE.createKeywordsType(); + for(int i = 0; i < split.length; i++){ + String kw = split[i].trim(); + kwd.getKeyword().add(kw); + } + ((FeatureTypeType) eObject).getKeywords().add(kwd); + return; + } + } else if ("LatLongBoundingBox".equals(property)){ // WFS 1.0 + property = "WGS84BoundingBox"; } super.setProperty(eObject, property, value, lax); } Added: trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/CapabilityBinding.java =================================================================== --- trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/CapabilityBinding.java (rev 0) +++ trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/CapabilityBinding.java 2012-01-31 21:00:34 UTC (rev 38542) @@ -0,0 +1,146 @@ +package org.geotools.wfs.v1_0; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javax.xml.namespace.QName; + +import net.opengis.ows10.DCPType; +import net.opengis.ows10.DomainType; +import net.opengis.ows10.OperationType; +import net.opengis.ows10.OperationsMetadataType; +import net.opengis.ows10.Ows10Factory; + +import org.geotools.xml.AbstractComplexEMFBinding; +import org.geotools.xml.ElementInstance; +import org.geotools.xml.InstanceComponent; +import org.geotools.xml.Node; + +public class CapabilityBinding extends AbstractComplexEMFBinding { + + @Override + public QName getTarget() { + return WFSCapabilities.Capability; + } + + @SuppressWarnings("rawtypes") + @Override + public Class getType() { + return OperationsMetadataType.class; + } + + @Override + public Object parse(ElementInstance instance, Node node, Object value) throws Exception { + Ows10Factory ows10Factory = Ows10Factory.eINSTANCE; + + OperationsMetadataType om = ows10Factory.createOperationsMetadataType(); + + Node request = node.getChild("Request"); + + OperationType operation; + + operation = getCapabilities(request.getChild("GetCapabilities"), ows10Factory); + addOperation(om, operation); + + operation = dft(request.getChild("DescribeFeatureType"), ows10Factory); + addOperation(om, operation); + + operation = getFeature(request.getChild("GetFeature"), ows10Factory); + addOperation(om, operation); + + operation = createOperation("Transaction", node, ows10Factory); + addOperation(om, operation); + + operation = createOperation("LockFeature", node, ows10Factory); + addOperation(om, operation); + + operation = createOperation("GetFeatureWithLock", node, ows10Factory); + addOperation(om, operation); + + operation = createOperation("Transaction", node, ows10Factory); + addOperation(om, operation); + + return om; + } + + private OperationType getFeature(Node node, Ows10Factory ows10Factory) { + OperationType operationType = createOperation("GetFeature", node, ows10Factory); + addParameter(node, ows10Factory, operationType, "ResultFormat"); + return operationType; + } + + private OperationType dft(Node node, Ows10Factory ows10Factory) { + OperationType operationType = createOperation("DescribeFeatureType", node, ows10Factory); + + addParameter(node, ows10Factory, operationType, "SchemaDescriptionLanguage"); + return operationType; + } + + private OperationType createOperation(String opetationName, Node node, Ows10Factory ows10Factory) { + if (node == null) { + return null; + } + OperationType operationType = ows10Factory.createOperationType(); + operationType.setName(opetationName); + addDCPTypes(node, operationType); + return operationType; + } + + @SuppressWarnings("unchecked") + private void addParameter(Node node, Ows10Factory ows10Factory, OperationType operationType, + String parameterName) { + Node paramParentNode = node.getChild(parameterName); + List<String> paramValues = childNames(paramParentNode); + + DomainType domain = ows10Factory.createDomainType(); + domain.setName(parameterName); + + for (String paramValue : paramValues) { + domain.getValue().add(paramValue); + } + operationType.getParameter().add(domain); + } + + @SuppressWarnings("unchecked") + private List<String> childNames(Node node) { + if (null == node) { + return Collections.emptyList(); + } + List<Node> children = node.getChildren(); + List<String> names = new ArrayList<String>(children.size()); + for (Node child : children) { + InstanceComponent component = child.getComponent(); + String paramValue = component.getName(); + names.add(paramValue); + } + return names; + } + + private OperationType getCapabilities(Node node, Ows10Factory ows10Factory) { + if (node == null) { + return null; + } + OperationType operationType = ows10Factory.createOperationType(); + operationType.setName("GetCapabilities"); + addDCPTypes(node, operationType); + return operationType; + } + + @SuppressWarnings("unchecked") + private void addDCPTypes(Node node, OperationType operationType) { + List<Node> dcpNodes = node.getChildren(DCPType.class); + for (Node dcpNode : dcpNodes) { + DCPType dcp = (DCPType) dcpNode.getValue(); + operationType.getDCP().add(dcp); + } + } + + @SuppressWarnings("unchecked") + private void addOperation(OperationsMetadataType om, OperationType operation) { + if (operation != null) { + om.getOperation().add(operation); + } + } + +} Property changes on: trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/CapabilityBinding.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: svn:eol-style + native Added: trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/DCPTypeBinding.java =================================================================== --- trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/DCPTypeBinding.java (rev 0) +++ trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/DCPTypeBinding.java 2012-01-31 21:00:34 UTC (rev 38542) @@ -0,0 +1,65 @@ +package org.geotools.wfs.v1_0; + +import java.math.BigInteger; +import java.util.Arrays; +import java.util.List; + +import javax.xml.namespace.QName; + +import net.opengis.ows10.DCPType; +import net.opengis.ows10.HTTPType; +import net.opengis.ows10.Ows10Factory; +import net.opengis.ows10.RequestMethodType; +import net.opengis.ows10.WGS84BoundingBoxType; + +import org.geotools.xml.AbstractComplexEMFBinding; +import org.geotools.xml.ElementInstance; +import org.geotools.xml.Node; + +public class DCPTypeBinding extends AbstractComplexEMFBinding { + + @Override + public QName getTarget() { + return WFSCapabilities.DCPType; + } + + @SuppressWarnings("rawtypes") + @Override + public Class getType() { + return DCPType.class; + } + + @SuppressWarnings("unchecked") + @Override + public Object parse(ElementInstance instance, Node node, Object value) throws Exception { + Ows10Factory ows10Factory = Ows10Factory.eINSTANCE; + + DCPType dcpType = ows10Factory.createDCPType(); + HTTPType httpType = ows10Factory.createHTTPType(); + dcpType.setHTTP(httpType); + + List<Node> httpChildren = node.getChildren("HTTP"); + for (Node http : httpChildren) { + Node get = http.getChild("Get"); + if (get != null) { + RequestMethodType methodType = createRequestMethodType(ows10Factory, get); + httpType.getGet().add(methodType); + } + Node post = http.getChild("Post"); + if (post != null) { + RequestMethodType methodType = createRequestMethodType(ows10Factory, post); + httpType.getPost().add(methodType); + } + } + + return dcpType; + + } + + private RequestMethodType createRequestMethodType(Ows10Factory ows10Factory, Node getOrPostNode) { + RequestMethodType methodType = ows10Factory.createRequestMethodType(); + String href = (String) getOrPostNode.getAttributeValue("onlineResource"); + methodType.setHref(href); + return methodType; + } +} Property changes on: trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/DCPTypeBinding.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: svn:eol-style + native Added: trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/LatLongBoundingBoxBinding.java =================================================================== --- trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/LatLongBoundingBoxBinding.java (rev 0) +++ trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/LatLongBoundingBoxBinding.java 2012-01-31 21:00:34 UTC (rev 38542) @@ -0,0 +1,44 @@ +package org.geotools.wfs.v1_0; + +import java.math.BigInteger; +import java.util.Arrays; + +import javax.xml.namespace.QName; + +import net.opengis.ows10.Ows10Factory; +import net.opengis.ows10.WGS84BoundingBoxType; + +import org.geotools.xml.AbstractComplexEMFBinding; +import org.geotools.xml.ElementInstance; +import org.geotools.xml.Node; + +public class LatLongBoundingBoxBinding extends AbstractComplexEMFBinding { + + @Override + public QName getTarget() { + return WFSCapabilities.LatLongBoundingBox; + } + + @SuppressWarnings("rawtypes") + @Override + public Class getType() { + return WGS84BoundingBoxType.class; + } + + @Override + public Object parse(ElementInstance instance, Node node, Object value) throws Exception { + + Double minx = Double.valueOf((String) node.getAttributeValue("minx")); + Double miny = Double.valueOf((String) node.getAttributeValue("miny")); + Double maxx = Double.valueOf((String) node.getAttributeValue("maxx")); + Double maxy = Double.valueOf((String) node.getAttributeValue("maxy")); + WGS84BoundingBoxType bbox = Ows10Factory.eINSTANCE.createWGS84BoundingBoxType(); + bbox.setCrs("EPSG:4326"); + bbox.setDimensions(BigInteger.valueOf(2)); + bbox.setLowerCorner(Arrays.asList(minx, miny)); + bbox.setUpperCorner(Arrays.asList(maxx, maxy)); + + return bbox; + + } +} Property changes on: trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/LatLongBoundingBoxBinding.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: svn:eol-style + native Added: trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/ServiceTypeBinding.java =================================================================== --- trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/ServiceTypeBinding.java (rev 0) +++ trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/ServiceTypeBinding.java 2012-01-31 21:00:34 UTC (rev 38542) @@ -0,0 +1,67 @@ +package org.geotools.wfs.v1_0; + +import javax.xml.namespace.QName; + +import net.opengis.ows10.CodeType; +import net.opengis.ows10.KeywordsType; +import net.opengis.ows10.Ows10Factory; +import net.opengis.ows10.ServiceIdentificationType; + +import org.geotools.xml.AbstractComplexEMFBinding; +import org.geotools.xml.AttributeInstance; +import org.geotools.xml.ElementInstance; +import org.geotools.xml.Node; + +public class ServiceTypeBinding extends AbstractComplexEMFBinding { + + @Override + public QName getTarget() { + return WFSCapabilities.Service; + } + + @SuppressWarnings("rawtypes") + @Override + public Class getType() { + return ServiceIdentificationType.class; + } + + @Override + public Object parse(ElementInstance instance, Node node, Object value) throws Exception { + Ows10Factory ows10Factory = Ows10Factory.eINSTANCE; + ServiceIdentificationType service = ows10Factory.createServiceIdentificationType(); + + String name = (String) node.getChildValue("Name"); + String title = (String) node.getChildValue("Title"); + String keywords = (String) node.getChildValue("Keywords"); + if (keywords != null) { + KeywordsType kwd = ows10Factory.createKeywordsType(); + String[] split = (keywords).split(","); + for (int i = 0; i < split.length; i++) { + String kw = split[i].trim(); + kwd.getKeyword().add(kw); + } + service.getKeywords().add(kwd); + } + + String abstract_ = (String) node.getChildValue("Abstract"); + String accessConstraints = (String) node.getChildValue("AccessConstraints"); + String fees = (String) node.getChildValue("Fees"); + // OnlineResource + + CodeType serviceType = ows10Factory.createCodeType(); + serviceType.setValue(name); + service.setServiceType(serviceType); + + service.setServiceTypeVersion("1.0.0"); + + service.setTitle(title); + service.setAbstract(abstract_); + service.setAccessConstraints(accessConstraints); + service.setFees(fees); + + // service.setServiceType(value) + // service.setServiceTypeVersion(serviceTypeVersion); + + return service; + } +} Property changes on: trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/ServiceTypeBinding.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: svn:eol-style + native Modified: trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/WFS.java =================================================================== --- trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/WFS.java 2012-01-29 17:47:31 UTC (rev 38541) +++ trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/WFS.java 2012-01-31 21:00:34 UTC (rev 38542) @@ -21,12 +21,13 @@ import org.geotools.filter.v1_0.OGC; /** - * XSD for wfs 1.0. + * XSD for wfs 1.0; except for WFS 1.0 capabilities document, for which {@link WFSCapabilities} + * shall be used, as its based on a different schema. * * @author Justin Deoliveira, OpenGEO - * - * - * + * + * + * * @source $URL$ */ public final class WFS extends org.geotools.wfs.WFS { @@ -41,6 +42,7 @@ return instance; } + @SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected void addDependencies(Set dependencies) { dependencies.add( OGC.getInstance() ); Copied: trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/WFSCapabilities.java (from rev 38539, trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/WFS.java) =================================================================== --- trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/WFSCapabilities.java (rev 0) +++ trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/WFSCapabilities.java 2012-01-31 21:00:34 UTC (rev 38542) @@ -0,0 +1,71 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package org.geotools.wfs.v1_0; + +import java.util.Set; + +import javax.xml.namespace.QName; + +/** + * XSD for wfs 1.0. capabilities document; for non capabilities use {@link WFS}, as it's based on a + * different schema. + * + * @see WFSCapabilitiesConfiguration + */ +public final class WFSCapabilities extends org.geotools.wfs.WFS { + + /** singleton instance */ + private static final WFSCapabilities instance = new WFSCapabilities(); + + /** + * Returns the singleton instance. + */ + public static final WFSCapabilities getInstance() { + return instance; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + protected void addDependencies(Set dependencies) { + dependencies.add(org.geotools.filter.v1_0.capabilities.OGC.getInstance()); + } + + /** + * Returns the location of 'WFS-transaction.xsd.'. + */ + public String getSchemaLocation() { + return getClass().getResource("WFS-capabilities.xsd").toString(); + } + + /** + * Returns '1.0.0'. + */ + @Override + public String getVersion() { + return "1.0.0"; + } + + public static final QName Service = new QName("http://www.opengis.net/wfs", "Service"); + + public static final QName LatLongBoundingBox = new QName("http://www.opengis.net/wfs", + "LatLongBoundingBox"); + + public static final QName DCPType = new QName("http://www.opengis.net/wfs", "DCPType"); + + public static final QName Capability = new QName("http://www.opengis.net/wfs", "Capability"); + +} Added: trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/WFSCapabilitiesConfiguration.java =================================================================== --- trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/WFSCapabilitiesConfiguration.java (rev 0) +++ trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/WFSCapabilitiesConfiguration.java 2012-01-31 21:00:34 UTC (rev 38542) @@ -0,0 +1,49 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package org.geotools.wfs.v1_0; + +/** + * Parser configuration for the wfs 1.0 {@link WFSCapabilities schema}, different from the + * {@link WFSConfiguration} because WFS 1.0 bases capabilities document and request/response + * documents on different schemas. + * + * @see WFSCapabilities + */ +public class WFSCapabilitiesConfiguration extends org.geotools.wfs.WFSConfiguration { + /** + * Creates a new configuration. + * + * @generated + */ + public WFSCapabilitiesConfiguration() { + super(WFSCapabilities.getInstance()); + + addDependency(new org.geotools.filter.v1_0.capabilities.OGCConfiguration()); + } + + protected void configureBindings(org.picocontainer.MutablePicoContainer container) { + + container + .registerComponentImplementation(WFSCapabilities.Service, ServiceTypeBinding.class); + container.registerComponentImplementation(WFSCapabilities.LatLongBoundingBox, + LatLongBoundingBoxBinding.class); + + container.registerComponentImplementation(WFSCapabilities.DCPType, DCPTypeBinding.class); + container.registerComponentImplementation(WFSCapabilities.Capability, + CapabilityBinding.class); + } +} Property changes on: trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/WFSCapabilitiesConfiguration.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: svn:eol-style + native Modified: trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/WFSConfiguration.java =================================================================== --- trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/WFSConfiguration.java 2012-01-29 17:47:31 UTC (rev 38541) +++ trunk/modules/extension/xsd/xsd-wfs/src/main/java/org/geotools/wfs/v1_0/WFSConfiguration.java 2012-01-31 21:00:34 UTC (rev 38542) @@ -19,12 +19,13 @@ import org.geotools.filter.v1_0.OGCConfiguration; /** - * Parser configuration for the wfs 1.0 schema. - * + * Parser configuration for the wfs 1.0 {@link WFS schema}, for capabilities documents use + * {@link WFSCapabilitiesConfiguration} instead. + * * @generated - * - * - * + * + * + * * @source $URL$ */ public class WFSConfiguration extends org.geotools.wfs.WFSConfiguration { @@ -40,6 +41,7 @@ } protected void configureBindings(org.picocontainer.MutablePicoContainer container) { + super.configureBindings(container); container.registerComponentImplementation(WFS.QueryType, QueryTypeBinding.class); } } Added: trunk/modules/extension/xsd/xsd-wfs/src/test/java/org/geotools/wfs/WFS_1_0_0_ParsingTest.java =================================================================== --- trunk/modules/extension/xsd/xsd-wfs/src/test/java/org/geotools/wfs/WFS_1_0_0_ParsingTest.java (rev 0) +++ trunk/modules/extension/xsd/xsd-wfs/src/test/java/org/geotools/wfs/WFS_1_0_0_ParsingTest.java 2012-01-31 21:00:34 UTC (rev 38542) @@ -0,0 +1,403 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package org.geotools.wfs; + +import java.io.BufferedWriter; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileWriter; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Writer; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.net.URI; +import java.util.Collection; +import java.util.Date; +import java.util.List; + +import javax.xml.namespace.QName; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import junit.framework.TestCase; +import net.opengis.ows10.DCPType; +import net.opengis.ows10.KeywordsType; +import net.opengis.ows10.OperationType; +import net.opengis.ows10.OperationsMetadataType; +import net.opengis.ows10.RequestMethodType; +import net.opengis.ows10.ServiceIdentificationType; +import net.opengis.ows10.WGS84BoundingBoxType; +import net.opengis.wfs.FeatureCollectionType; +import net.opengis.wfs.FeatureTypeListType; +import net.opengis.wfs.FeatureTypeType; +import net.opengis.wfs.WFSCapabilitiesType; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.xsd.XSDComplexTypeDefinition; +import org.eclipse.xsd.XSDElementDeclaration; +import org.eclipse.xsd.XSDSchema; +import org.geotools.data.DataUtilities; +import org.geotools.data.simple.SimpleFeatureCollection; +import org.geotools.data.simple.SimpleFeatureIterator; +import org.geotools.xml.Configuration; +import org.geotools.xml.Parser; +import org.geotools.xml.Schemas; +import org.geotools.xml.StreamingParser; +import org.opengis.feature.simple.SimpleFeature; +import org.opengis.filter.capability.FilterCapabilities; +import org.opengis.filter.capability.Operator; +import org.opengis.filter.capability.SpatialOperators; +import org.w3c.dom.Document; + +import com.vividsolutions.jts.geom.Point; + +/** + * + * + * @source $URL$ + */ +public class WFS_1_0_0_ParsingTest extends TestCase { + + Configuration configuration; + + protected void setUp() throws Exception { + super.setUp(); + + // configuration = new org.geotools.wfs.v1_0.WFSConfiguration(); + } + + public void _testParseEmptyGetCapabilities() throws Exception { + String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + "<WFS_Capabilities " + + " version=\"1.0.0\" " + + " xmlns=\"http://www.opengis.net/wfs\"" + + " xmlns:ogc=\"http://www.opengis.net/ogc\"" + + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + + " xsi:schemaLocation=\"http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-capabilities.xsd\">" + + "</WFS_Capabilities>"; + + configuration = new org.geotools.wfs.v1_0.WFSCapabilitiesConfiguration(); + + Parser parser = new Parser(configuration); + Object parsed = parser.parse(new ByteArrayInputStream(xml.getBytes())); + assertNotNull(parsed); + assertTrue(parsed.getClass().getName(), parsed instanceof WFSCapabilitiesType); + WFSCapabilitiesType caps = (WFSCapabilitiesType) parsed; + + assertNotNull(caps); + assertEquals("1.0.0", caps.getVersion()); + } + + public void testParseGetCapabilities() throws Exception { + configuration = new org.geotools.wfs.v1_0.WFSCapabilitiesConfiguration(); + + Parser parser = new Parser(configuration); + Object parsed = parser.parse(getClass().getResourceAsStream( + "geoserver-GetCapabilities_1_0_0.xml")); + + assertNotNull(parsed); + assertTrue(parsed.getClass().getName(), parsed instanceof WFSCapabilitiesType); + WFSCapabilitiesType caps = (WFSCapabilitiesType) parsed; + + assertNotNull(caps); + assertEquals("1.0.0", caps.getVersion()); + + assertServiceIdentification(caps); + assertOperationsMetadata(caps); + assertFeatureTypeList(caps); + assertFilterCapabilities(caps); + } + + /** + * TODO: fix me + * + * @throws Exception + */ + public void _testParseGetCapabilitiesDeegree() throws Exception { + Parser parser = new Parser(configuration); + WFSCapabilitiesType caps = (WFSCapabilitiesType) parser.parse(getClass() + .getResourceAsStream("deegree-GetCapabilities.xml")); + + assertNotNull(caps); + assertEquals("1.0.0", caps.getVersion()); + + // assertServiceIdentification(caps); + assertOperationsMetadataDeeGree(caps); + // assertFeatureTypeList(caps); + // assertFilterCapabilities(caps); + } + + private void assertOperationsMetadataDeeGree(WFSCapabilitiesType caps) { + OperationsMetadataType om = caps.getOperationsMetadata(); + assertNotNull(om); + + assertEquals(6, om.getOperation().size()); + + OperationType getCapsOp = (OperationType) om.getOperation().get(2); + assertEquals("GetCapabilities", getCapsOp.getName()); + assertEquals(1, getCapsOp.getDCP().size()); + + DCPType dcp = (DCPType) getCapsOp.getDCP().get(0); + assertEquals(1, dcp.getHTTP().getGet().size()); + assertEquals(1, dcp.getHTTP().getPost().size()); + + assertEquals("http://demo.deegree.org/deegree-wfs/services?", ((RequestMethodType) dcp + .getHTTP().getGet().get(0)).getHref()); + assertEquals("http://demo.deegree.org/deegree-wfs/services", ((RequestMethodType) dcp + .getHTTP().getPost().get(0)).getHref()); + + assertEquals("GetFeature", ((OperationType) om.getOperation().get(0)).getName()); + assertEquals("DescribeFeatureType", ((OperationType) om.getOperation().get(1)).getName()); + assertEquals("GetFeatureWithLock", ((OperationType) om.getOperation().get(3)).getName()); + assertEquals("LockFeature", ((OperationType) om.getOperation().get(4)).getName()); + assertEquals("Transaction", ((OperationType) om.getOperation().get(5)).getName()); + } + + void assertServiceIdentification(WFSCapabilitiesType caps) { + ServiceIdentificationType sa = caps.getServiceIdentification(); + assertNotNull(sa); + + assertEquals(1, sa.getKeywords().size()); + + KeywordsType keywords = (KeywordsType) sa.getKeywords().get(0); + assertTrue(keywords.getKeyword().contains("WFS")); + assertTrue(keywords.getKeyword().contains("NY")); + assertTrue(keywords.getKeyword().contains("New York")); + + assertEquals("WFS", sa.getServiceType().getValue()); + assertEquals("1.0.0", sa.getServiceTypeVersion()); + } + + void assertOperationsMetadata(WFSCapabilitiesType caps) { + OperationsMetadataType om = caps.getOperationsMetadata(); + assertNotNull(om); + + // assertEquals(6, om.getOperation().size()); + + OperationType getCapsOp = (OperationType) om.getOperation().get(0); + assertEquals("GetCapabilities", getCapsOp.getName()); + assertEquals(2, getCapsOp.getDCP().size()); + + DCPType dcp1 = (DCPType) getCapsOp.getDCP().get(0); + DCPType dcp2 = (DCPType) getCapsOp.getDCP().get(1); + assertEquals(1, dcp1.getHTTP().getGet().size()); + assertEquals(1, dcp2.getHTTP().getPost().size()); + + assertEquals("http://localhost:8080/geoserver/wfs?request=GetCapabilities", + ((RequestMethodType) dcp1.getHTTP().getGet().get(0)).getHref()); + assertEquals("http://localhost:8080/geoserver/wfs", ((RequestMethodType) dcp2.getHTTP() + .getPost().get(0)).getHref()); + + assertEquals("DescribeFeatureType", ((OperationType) om.getOperation().get(1)).getName()); + assertEquals("GetFeature", ((OperationType) om.getOperation().get(2)).getName()); + assertEquals("Transaction", ((OperationType) om.getOperation().get(3)).getName()); + assertEquals("LockFeature", ((OperationType) om.getOperation().get(4)).getName()); + assertEquals("GetFeatureWithLock", ((OperationType) om.getOperation().get(5)).getName()); + } + + void assertFeatureTypeList(WFSCapabilitiesType caps) { + FeatureTypeListType ftl = caps.getFeatureTypeList(); + assertNotNull(ftl); + + assertEquals(3, ftl.getFeatureType().size()); + + FeatureTypeType featureType = (FeatureTypeType) ftl.getFeatureType().get(0); + assertEquals("poly_landmarks", featureType.getName().getLocalPart()); + assertEquals("tiger", featureType.getName().getPrefix()); + assertEquals("http://www.census.gov", featureType.getName().getNamespaceURI()); + + assertEquals("EPSG:4326", featureType.getDefaultSRS()); + + List<WGS84BoundingBoxType> wgs84BoundingBox = featureType.getWGS84BoundingBox(); + assertEquals(1, wgs84BoundingBox.size()); + + WGS84BoundingBoxType bbox = wgs84BoundingBox.get(0); + assertEquals("EPSG:4326", bbox.getCrs()); + assertEquals(BigInteger.valueOf(2), bbox.getDimensions()); + + assertEquals(-74.047185D, (Double) bbox.getLowerCorner().get(0), 1E-6); + assertEquals(40.679648D, (Double) bbox.getLowerCorner().get(1), 1E-6); + assertEquals(-73.90782D, (Double) bbox.getUpperCorner().get(0), 1E-6); + assertEquals(40.882078D, (Double) bbox.getUpperCorner().get(1), 1E-6); + + } + + void assertFilterCapabilities(WFSCapabilitiesType caps) { + FilterCapabilities fc = (FilterCapabilities) caps.getFilterCapabilities(); + + assertNotNull(fc.getSpatialCapabilities()); + assertNotNull(fc.getSpatialCapabilities().getSpatialOperators()); + assertNotNull(fc.getSpatialCapabilities().getSpatialOperators().getOperators()); + assertEquals(11, fc.getSpatialCapabilities().getSpatialOperators().getOperators().size()); + + assertNotNull(fc.getSpatialCapabilities().getSpatialOperators().getOperator("Disjoint")); + assertNotNull(fc.getSpatialCapabilities().getSpatialOperators().getOperator("Equals")); + assertNotNull(fc.getSpatialCapabilities().getSpatialOperators().getOperator("DWithin")); + assertNotNull(fc.getSpatialCapabilities().getSpatialOperators().getOperator("Beyond")); + assertNotNull(fc.getSpatialCapabilities().getSpatialOperators().getOperator("Intersect")); + assertNotNull(fc.getSpatialCapabilities().getSpatialOperators().getOperator("Touches")); + assertNotNull(fc.getSpatialCapabilities().getSpatialOperators().getOperator("Crosses")); + assertNotNull(fc.getSpatialCapabilities().getSpatialOperators().getOperator("Within")); + assertNotNull(fc.getSpatialCapabilities().getSpatialOperators().getOperator("Contains")); + assertNotNull(fc.getSpatialCapabilities().getSpatialOperators().getOperator("Overlaps")); + assertNotNull(fc.getSpatialCapabilities().getSpatialOperators().getOperator("BBOX")); + + assertNotNull(fc.getScalarCapabilities()); + assertTrue(fc.getScalarCapabilities().hasLogicalOperators()); + assertNotNull(fc.getScalarCapabilities().getArithmeticOperators()); + assertNotNull(fc.getScalarCapabilities().getComparisonOperators()); + + assertTrue(fc.getScalarCapabilities().getArithmeticOperators().hasSimpleArithmetic()); + assertNotNull(fc.getScalarCapabilities().getArithmeticOperators().getFunctions()); + assertEquals(7, fc.getScalarCapabilities().getArithmeticOperators().getFunctions() + .getFunctionNames().size()); + + Collection<Operator> operators = fc.getScalarCapabilities().getComparisonOperators() + .getOperators(); + + assertEquals(3, operators.size());// "Simple_Comparisons" is commented out on purpose + + assertNotNull(fc.getScalarCapabilities().getComparisonOperators().getOperator("Between")); + assertNotNull(fc.getScalarCapabilities().getComparisonOperators().getOperator("Like")); + assertNotNull(fc.getScalarCapabilities().getComparisonOperators().getOperator("NullCheck")); + } + + public void _testParseDescribeFeatureType() throws Exception { + String loc = getClass().getResource("geoserver-DescribeFeatureType.xml").getFile(); + XSDSchema schema = Schemas.parse(loc); + + assertNotNull(schema); + final String targetNs = "http://cite.opengeospatial.org/gmlsf"; + final String featureName = "PrimitiveGeoFeature"; + QName name = new QName(targetNs, featureName); + XSDElementDeclaration elementDeclaration = Schemas.getElementDeclaration(schema, name); + assertNotNull(elementDeclaration); + + XSDComplexTypeDefinition type = (XSDComplexTypeDefinition) elementDeclaration.getType(); + + assertEquals("PrimitiveGeoFeatureType", type.getName()); + assertEquals(targetNs, type.getTargetNamespace()); + } + + @SuppressWarnings("unchecked") + public void _testParseGetFeature() throws Exception { + File tmp = File.createTempFile("geoserver-DescribeFeatureType", "xml"); + tmp.deleteOnExit(); + + InputStream in = getClass().getResourceAsStream("geoserver-DescribeFeatureType.xml"); + copy(in, tmp); + + in = getClass().getResourceAsStream("geoserver-GetFeature.xml"); + + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setNamespaceAware(true); + + DocumentBuilder db = dbf.newDocumentBuilder(); + Document doc = db.parse(in); + + // http://cite.opengeospatial.org/gmlsf + // http://localhost:8080/geoserver/wfs?service=WFS&version=1.1.0&request=DescribeFeatureType&typeName=sf:PrimitiveGeoFeature + String schemaLocation = doc.getDocumentElement().getAttributeNS( + "http://www.w3.org/2001/XMLSchema-instance", "schemaLocation"); + String absolutePath = DataUtilities.fileToURL(tmp).toExternalForm(); + + schemaLocation = schemaLocation.replaceAll("http://cite.opengeospatial.org/gmlsf .*", + "http://cite.opengeospatial.org/gmlsf " + absolutePath); + doc.getDocumentElement().setAttributeNS("http://www.w3.org/2001/XMLSchema-instance", + "schemaLocation", schemaLocation); + + tmp = File.createTempFile("geoserver-GetFeature", "xml"); + tmp.deleteOnExit(); + + Transformer tx = TransformerFactory.newInstance().newTransformer(); + tx.transform(new DOMSource(doc), new StreamResult(tmp)); + + in = new FileInputStream(tmp); + + Parser parser = new Parser(configuration); + FeatureCollectionType fc = (FeatureCollectionType) parser.parse(in); + assertNotNull(fc); + + List featureCollections = fc.getFeature(); + assertEquals(1, featureCollections.size()); + + SimpleFeatureCollection featureCollection; + featureCollection = (SimpleFeatureCollection) featureCollections.get(0); + assertEquals(5, featureCollection.size()); + + SimpleFeatureIterator features = featureCollection.features(); + + try { + assertTrue(features.hasNext()); + + SimpleFeature f = features.next(); + + assertEquals("PrimitiveGeoFeature.f001", f.getID()); + assertNull(f.getDefaultGeometry()); + + assertNotNull(f.getAttribute("pointProperty")); + Point p = (Point) f.getAttribute("pointProperty"); + + assertEquals(39.73245, p.getX(), 0.1); + assertEquals(2.00342, p.getY(), 0.1); + + Object intProperty = f.getAttribute("intProperty"); + assertNotNull(intProperty); + assertTrue(intProperty.getClass().getName(), intProperty instanceof BigInteger); + + assertEquals(BigInteger.valueOf(155), intProperty); + assertEquals(new URI("http://www.opengeospatial.org/"), f.getAttribute("uriProperty")); + assertEquals(new Float(12765.0), f.getAttribute("measurand")); + assertTrue(f.getAttribute("dateProperty") instanceof Date); + assertEquals(BigDecimal.valueOf(5.03), f.getAttribute("decimalProperty")); + } finally { + featureCollection.close(features); + } + } + + void copy(InputStream in, File to) throws Exception { + Writer writer = new BufferedWriter(new FileWriter(to)); + InputStreamReader reader = new InputStreamReader(in); + + int b = -1; + + while ((b = reader.read()) != -1) { + writer.write(b); + } + + writer.flush(); + writer.close(); + } + + public void _testParseGetFeatureStreaming() throws Exception { + InputStream in = getClass().getResourceAsStream("geoserver-GetFeature.xml"); + StreamingParser parser = new StreamingParser(configuration, in, SimpleFeature.class); + + int n = 0; + + while (parser.parse() != null) + n++; + + assertEquals(5, n); + } +} Property changes on: trunk/modules/extension/xsd/xsd-wfs/src/test/java/org/geotools/wfs/WFS_1_0_0_ParsingTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: svn:eol-style + native Added: trunk/modules/extension/xsd/xsd-wfs/src/test/resources/org/geotools/wfs/geoserver-GetCapabilities_1_0_0.xml =================================================================== --- trunk/modules/extension/xsd/xsd-wfs/src/test/resources/org/geotools/wfs/geoserver-GetCapabilities_1_0_0.xml (rev 0) +++ trunk/modules/extension/xsd/xsd-wfs/src/test/resources/org/geotools/wfs/geoserver-GetCapabilities_1_0_0.xml 2012-01-31 21:00:34 UTC (rev 38542) @@ -0,0 +1,186 @@ +<?xml version="1.0" encoding="UTF-8"?> +<WFS_Capabilities + version="1.0.0" + xmlns="http://www.opengis.net/wfs" + xmlns:tiger="http://www.census.gov" + xmlns:topp="http://www.openplans.org/topp" + xmlns:ogc="http://www.opengis.net/ogc" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-capabilities.xsd"> + <Service> + <Name>WFS</Name> + <Title>GeoServer Web Feature Service</Title> + <Abstract>This is the reference implementation of WFS 1.0.0 and WFS 1.1.0, supports all WFS operations including + Transaction. + </Abstract> + <Keywords>WFS, NY, New York</Keywords> + <OnlineResource>http://localhost:8080/geoserver/wfs</OnlineResource> + <Fees>NONE</Fees> + <AccessConstraints>NONE</AccessConstraints> + </Service> + <Capability> + <Request> + <GetCapabilities> + <DCPType> + <HTTP> + <Get onlineResource="http://localhost:8080/geoserver/wfs?request=GetCapabilities" /> + </HTTP> + </DCPType> + <DCPType> + <HTTP> + <Post onlineResource="http://localhost:8080/geoserver/wfs" /> + </HTTP> + </DCPType> + </GetCapabilities> + <DescribeFeatureType> + <SchemaDescriptionLanguage> + <XMLSCHEMA /> + </SchemaDescriptionLanguage> + <DCPType> + <HTTP> + <Get onlineResource="http://localhost:8080/geoserver/wfs?request=DescribeFeatureType" /> + </HTTP> + </DCPType> + <DCPType> + <HTTP> + <Post onlineResource="http://localhost:8080/geoserver/wfs" /> + </HTTP> + </DCPType> + </DescribeFeatureType> + <GetFeature> + <ResultFormat> + <GML2 /> + <GML3 /> + <SHAPE-ZIP /> + <GEOJSON /> + <CSV /> + </ResultFormat> + <DCPType> + <HTTP> + <Get onlineResource="http://localhost:8080/geoserver/wfs?request=GetFeature" /> + </HTTP> + </DCPType> + <DCPType> + <HTTP> + <Post onlineResource="http://localhost:8080/geoserver/wfs" /> + </HTTP> + </DCPType> + </GetFeature> + <Transaction> + <DCPType> + <HTTP> + <Get onlineResource="http://localhost:8080/geoserver/wfs?request=Transaction" /> + </HTTP> + </DCPType> + <DCPType> + <HTTP> + <Post onlineResource="http://localhost:8080/geoserver/wfs" /> + </HTTP> + </DCPType> + </Transaction> + <LockFeature> + <DCPType> + <HTTP> + <Get onlineResource="http://localhost:8080/geoserver/wfs?request=LockFeature" /> + </HTTP> + </DCPType> + <DCPType> + <HTTP> + <Post onlineResource="http://localhost:8080/geoserver/wfs" /> + </HTTP> + </DCPType> + </LockFeature> + <GetFeatureWithLock> + <ResultFormat> + <GML2 /> + </ResultFormat> + <DCPType> + <HTTP> + <Get onlineResource="http://localhost:8080/geoserver/wfs?request=GetFeatureWithLock" /> + </HTTP> + </DCPType> + <DCPType> + <HTTP> + <Post onlineResource="http://localhost:8080/geoserver/wfs" /> + </HTTP> + </DCPType> + </GetFeatureWithLock> + </Request> + </Capability> + <FeatureTypeList> + <Operations> + <Query /> + <Insert /> + <Update /> + <Delete /> + <Lock /> + </Operations> + <FeatureType> + <Name>tiger:poly_landmarks</Name> + <Title>Manhattan (NY) landmarks</Title> + <Abstract>Manhattan landmarks, identifies water, lakes, parks, interesting buildilngs</Abstract> + <Keywords>landmarks, DS_poly_landmarks, manhattan, poly_landmarks</Keywords> + <SRS>EPSG:4326</SRS> + <LatLongBoundingBox minx="-74.047185" miny="40.679648" maxx="-73.90782" maxy="40.882078" /> + </FeatureType> + <FeatureType> + <Name>tiger:poi</Name> + <Title>Manhattan (NY) points of interest</Title> + <Abstract>Points of interest in New York, New York (on Manhattan). One of the attributes contains the name of a + file with a picture of the point of interest. + </Abstract> + <Keywords>poi, Manhattan, DS_poi, points_of_interest</Keywords> + <SRS>EPSG:4326</SRS> + <LatLongBoundingBox minx="-74.0118315772888" miny="40.70754683896324" maxx="-74.00857344353275" + maxy="40.711945649065406" /> + </FeatureType> + <FeatureType> + <Name>topp:states</Name> + <Title>USA Population</Title> + <Abstract>This is some census data on the states.</Abstract> + <Keywords>census, united, boundaries, state, states</Keywords> + <SRS>EPSG:4326</SRS> + <LatLongBoundingBox minx="-124.731422" miny="24.955967" maxx="-66.969849" maxy="49.371735" /> + </FeatureType> + </FeatureTypeList> + <ogc:Filter_Capabilities> + <ogc:Spatial_Capabilities> + <ogc:Spatial_Operators> + <ogc:Disjoint /> + <ogc:Equals /> + <ogc:DWithin /> + <ogc:Beyond /> + <ogc:Intersect /> + <ogc:Touches /> + <ogc:Crosses /> + <ogc:Within /> + <ogc:Contains /> + <ogc:Overlaps /> + <ogc:BBOX /> + </ogc:Spatial_Operators> + </ogc:Spatial_Capabilities> + <ogc:Scalar_Capabilities> + <ogc:Logical_Operators /> + <ogc:Comparison_Operators> + <!-- ogc:Simple_Comparisons /--> + <ogc:Between /> + <ogc:Like /> + <ogc:NullCheck /> + </ogc:Comparison_Operators> + <ogc:Arithmetic_Operators> + <ogc:Simple_Arithmetic /> + <ogc:Functions> + <ogc:Function_Names> + <ogc:Function_Name nArgs="1">abs</ogc:Function_Name> + <ogc:Function_Name nArgs="1">area</ogc:Function_Name> + <ogc:Function_Name nArgs="1">asin</ogc:Function_Name> + <ogc:Function_Name nArgs="1">atan</ogc:Function_Name> + <ogc:Function_Name nArgs="3">between</ogc:Function_Name> + <ogc:Function_Name nArgs="1">boundary</ogc:Function_Name> + <ogc:Function_Name nArgs="2">buffer</ogc:Function_Name> + </ogc:Function_Names> + </ogc:Functions> + </ogc:Arithmetic_Operators> + </ogc:Scalar_Capabilities> + </ogc:Filter_Capabilities> +</WFS_Capabilities> \ No newline at end of file Property changes on: trunk/modules/extension/xsd/xsd-wfs/src/test/resources/org/geotools/wfs/geoserver-GetCapabilities_1_0_0.xml ___________________________________________________________________ Added: svn:mime-type + text/xml Added: svn:keywords + Id Added: svn:eol-style + native |
From: <svn...@os...> - 2012-01-29 17:47:38
|
Author: aaime Date: 2012-01-29 09:47:31 -0800 (Sun, 29 Jan 2012) New Revision: 38541 Modified: branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/LifecycleConnection.java Log: Revering "Be gentle with people building 2.7.x with java 6", it uses classes that are not available in java 5. Long story short, if you are building geotools 2.7.x, use java 5 as you should always have had to. This reverts commit 7abd5cea2319d5d53c53b02e3d55b1ee546e2f51. Modified: branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/LifecycleConnection.java =================================================================== --- branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/LifecycleConnection.java 2012-01-29 15:12:47 UTC (rev 38540) +++ branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/LifecycleConnection.java 2012-01-29 17:47:31 UTC (rev 38541) @@ -22,12 +22,9 @@ import java.sql.Clob; import java.sql.Connection; import java.sql.DatabaseMetaData; -import java.sql.NClob; import java.sql.PreparedStatement; -import java.sql.SQLClientInfoException; import java.sql.SQLException; import java.sql.SQLWarning; -import java.sql.SQLXML; import java.sql.Savepoint; import java.sql.Statement; import java.sql.Struct; @@ -226,84 +223,6 @@ return delegate.prepareStatement(sql, columnNames); } - - public <T> T unwrap(Class<T> iface) throws SQLException { - // TODO Auto-generated method stub - return null; - } - - - public boolean isWrapperFor(Class<?> iface) throws SQLException { - // TODO Auto-generated method stub - return false; - } - - - public Clob createClob() throws SQLException { - // TODO Auto-generated method stub - return null; - } - - - public Blob createBlob() throws SQLException { - // TODO Auto-generated method stub - return null; - } - - - public NClob createNClob() throws SQLException { - // TODO Auto-generated method stub - return null; - } - - - public SQLXML createSQLXML() throws SQLException { - // TODO Auto-generated method stub - return null; - } - - - public boolean isValid(int timeout) throws SQLException { - // TODO Auto-generated method stub - return false; - } - - - public void setClientInfo(String name, String value) throws SQLClientInfoException { - // TODO Auto-generated method stub - - } - - - public void setClientInfo(Properties properties) throws SQLClientInfoException { - // TODO Auto-generated method stub - - } - - - public String getClientInfo(String name) throws SQLException { - // TODO Auto-generated method stub - return null; - } - - - public Properties getClientInfo() throws SQLException { - // TODO Auto-generated method stub - return null; - } - - - public Array createArrayOf(String typeName, Object[] elements) throws SQLException { - // TODO Auto-generated method stub - return null; - } - - - public Struct createStruct(String typeName, Object[] attributes) throws SQLException { - // TODO Auto-generated method stub - return null; - } - } |
From: <svn...@os...> - 2012-01-29 15:12:54
|
Author: aaime Date: 2012-01-29 07:12:47 -0800 (Sun, 29 Jan 2012) New Revision: 38540 Modified: branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/LifecycleConnection.java Log: Be gentle with people building 2.7.x with java 6 Modified: branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/LifecycleConnection.java =================================================================== --- branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/LifecycleConnection.java 2012-01-29 14:59:26 UTC (rev 38539) +++ branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/LifecycleConnection.java 2012-01-29 15:12:47 UTC (rev 38540) @@ -22,9 +22,12 @@ import java.sql.Clob; import java.sql.Connection; import java.sql.DatabaseMetaData; +import java.sql.NClob; import java.sql.PreparedStatement; +import java.sql.SQLClientInfoException; import java.sql.SQLException; import java.sql.SQLWarning; +import java.sql.SQLXML; import java.sql.Savepoint; import java.sql.Statement; import java.sql.Struct; @@ -223,6 +226,84 @@ return delegate.prepareStatement(sql, columnNames); } + + public <T> T unwrap(Class<T> iface) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + + public boolean isWrapperFor(Class<?> iface) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + + public Clob createClob() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + + public Blob createBlob() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + + public NClob createNClob() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + + public SQLXML createSQLXML() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + + public boolean isValid(int timeout) throws SQLException { + // TODO Auto-generated method stub + return false; + } + + + public void setClientInfo(String name, String value) throws SQLClientInfoException { + // TODO Auto-generated method stub + + } + + + public void setClientInfo(Properties properties) throws SQLClientInfoException { + // TODO Auto-generated method stub + + } + + + public String getClientInfo(String name) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + + public Properties getClientInfo() throws SQLException { + // TODO Auto-generated method stub + return null; + } + + + public Array createArrayOf(String typeName, Object[] elements) throws SQLException { + // TODO Auto-generated method stub + return null; + } + + + public Struct createStruct(String typeName, Object[] attributes) throws SQLException { + // TODO Auto-generated method stub + return null; + } + } |
From: <svn...@os...> - 2012-01-29 14:59:32
|
Author: aaime Date: 2012-01-29 06:59:26 -0800 (Sun, 29 Jan 2012) New Revision: 38539 Modified: trunk/modules/library/main/src/main/java/org/geotools/filter/FidFilterImpl.java Log: And on more patch, apparently fid filter, despite teh name, should work with any Identifier, not just feature ids Modified: trunk/modules/library/main/src/main/java/org/geotools/filter/FidFilterImpl.java =================================================================== --- trunk/modules/library/main/src/main/java/org/geotools/filter/FidFilterImpl.java 2012-01-29 14:56:47 UTC (rev 38538) +++ trunk/modules/library/main/src/main/java/org/geotools/filter/FidFilterImpl.java 2012-01-29 14:59:26 UTC (rev 38539) @@ -249,7 +249,7 @@ return false; } else { for(Object identifier : fids) { - FeatureId fid = (FeatureId) identifier; + Identifier fid = (Identifier) identifier; if(fid.getID().equals(evaluate)) { return true; } |
From: <svn...@os...> - 2012-01-29 14:56:54
|
Author: aaime Date: 2012-01-29 06:56:47 -0800 (Sun, 29 Jan 2012) New Revision: 38538 Modified: branches/2.7.x/modules/library/main/src/main/java/org/geotools/filter/FidFilterImpl.java Log: Go back to comparing strings, apparently there are many implementations of FeatureId and comparison between them works only by comparing the actual ID Modified: branches/2.7.x/modules/library/main/src/main/java/org/geotools/filter/FidFilterImpl.java =================================================================== --- branches/2.7.x/modules/library/main/src/main/java/org/geotools/filter/FidFilterImpl.java 2012-01-29 14:39:57 UTC (rev 38537) +++ branches/2.7.x/modules/library/main/src/main/java/org/geotools/filter/FidFilterImpl.java 2012-01-29 14:56:47 UTC (rev 38538) @@ -30,6 +30,7 @@ import org.geotools.filter.expression.SimpleFeaturePropertyAccessorFactory; import org.opengis.filter.FilterFactory; import org.opengis.filter.FilterVisitor; +import org.opengis.filter.identity.FeatureId; import org.opengis.filter.identity.Identifier; /** @@ -246,7 +247,13 @@ if(evaluate == null) { return false; } else { - return fids.contains(ff.featureId(evaluate)); + for(Object identifier : fids) { + Identifier fid = (Identifier) identifier; + if(fid.getID().equals(evaluate)) { + return true; + } + } + return false; } } |
From: <svn...@os...> - 2012-01-29 14:40:04
|
Author: aaime Date: 2012-01-29 06:39:57 -0800 (Sun, 29 Jan 2012) New Revision: 38537 Modified: trunk/modules/library/main/src/main/java/org/geotools/filter/FidFilterImpl.java Log: Fixing the build, but have doubts the current and previous behavior of FidFilterImpl makes any sense in a versioned setup Modified: trunk/modules/library/main/src/main/java/org/geotools/filter/FidFilterImpl.java =================================================================== --- trunk/modules/library/main/src/main/java/org/geotools/filter/FidFilterImpl.java 2012-01-29 14:22:35 UTC (rev 38536) +++ trunk/modules/library/main/src/main/java/org/geotools/filter/FidFilterImpl.java 2012-01-29 14:39:57 UTC (rev 38537) @@ -30,6 +30,7 @@ import org.geotools.filter.expression.SimpleFeaturePropertyAccessorFactory; import org.opengis.filter.FilterFactory; import org.opengis.filter.FilterVisitor; +import org.opengis.filter.identity.FeatureId; import org.opengis.filter.identity.Identifier; /** @@ -247,7 +248,13 @@ if(evaluate == null) { return false; } else { - return fids.contains(ff.featureId(evaluate)); + for(Object identifier : fids) { + FeatureId fid = (FeatureId) identifier; + if(fid.getID().equals(evaluate)) { + return true; + } + } + return false; } } |
Author: aaime Date: 2012-01-29 06:22:35 -0800 (Sun, 29 Jan 2012) New Revision: 38536 Added: trunk/modules/library/metadata/src/test/java/org/geotools/factory/DummyInterfaceImpl.java trunk/modules/library/metadata/src/test/resources/META-INF/ trunk/modules/library/metadata/src/test/resources/META-INF/services/ trunk/modules/library/metadata/src/test/resources/META-INF/services/org.geotools.factory.DummyInterface Modified: trunk/modules/library/metadata/src/main/java/org/geotools/factory/FactoryRegistry.java trunk/modules/library/metadata/src/main/java/org/geotools/factory/GeoTools.java trunk/modules/library/metadata/src/test/java/org/geotools/factory/FactoryRegistryTest.java Log: [GEOT-2817] Multiple classloaders giving ClassCastExceptions when GeoTools is used in GWT hosted mode, patch by Jan De Moerloose Modified: trunk/modules/library/metadata/src/main/java/org/geotools/factory/FactoryRegistry.java =================================================================== --- trunk/modules/library/metadata/src/main/java/org/geotools/factory/FactoryRegistry.java 2012-01-29 11:14:03 UTC (rev 38535) +++ trunk/modules/library/metadata/src/main/java/org/geotools/factory/FactoryRegistry.java 2012-01-29 14:22:35 UTC (rev 38536) @@ -708,6 +708,7 @@ } loaders.remove(null); loaders.addAll(GeoTools.getClassLoaders()); + /* * We now have a set of class loaders with duplicated object already removed * (e.g. system classloader == context classloader). However, we may still @@ -859,26 +860,31 @@ loadingFailure(category, error, true); continue; } - final Class<? extends T> factoryClass = factory.getClass().asSubclass(category); - /* - * If the factory implements more than one interface and an instance were - * already registered, reuse the same instance instead of duplicating it. - */ - final T replacement = getServiceProviderByClass(factoryClass); - if (replacement != null) { - factory = replacement; - // Need to register anyway, because the category may not be the same. - } - if (registerServiceProvider(factory, category)) { + if (category.isAssignableFrom(factory.getClass())) { + final Class<? extends T> factoryClass = factory.getClass().asSubclass(category); /* - * The factory is now registered. Add it to the message to be logged. We will log - * all factories together in a single log event because some registration (e.g. - * MathTransformProviders) would be otherwise quite verbose. + * If the factory implements more than one interface and an + * instance were already registered, reuse the same instance + * instead of duplicating it. */ - message.append(lineSeparator); - message.append(" "); - message.append(factoryClass.getName()); - newServices = true; + final T replacement = getServiceProviderByClass(factoryClass); + if (replacement != null) { + factory = replacement; + // Need to register anyway, because the category may not be + // the same. + } + if (registerServiceProvider(factory, category)) { + /* + * The factory is now registered. Add it to the message to + * be logged. We will log all factories together in a single + * log event because some registration (e.g. + * MathTransformProviders) would be otherwise quite verbose. + */ + message.append(lineSeparator); + message.append(" "); + message.append(factoryClass.getName()); + newServices = true; + } } } return newServices; Modified: trunk/modules/library/metadata/src/main/java/org/geotools/factory/GeoTools.java =================================================================== --- trunk/modules/library/metadata/src/main/java/org/geotools/factory/GeoTools.java 2012-01-29 11:14:03 UTC (rev 38535) +++ trunk/modules/library/metadata/src/main/java/org/geotools/factory/GeoTools.java 2012-01-29 14:22:35 UTC (rev 38536) @@ -38,12 +38,12 @@ import org.geotools.resources.Arguments; import org.geotools.resources.Classes; +import org.geotools.resources.i18n.ErrorKeys; import org.geotools.resources.i18n.Errors; -import org.geotools.resources.i18n.ErrorKeys; +import org.geotools.util.Utilities; +import org.geotools.util.Version; import org.geotools.util.logging.LoggerFactory; import org.geotools.util.logging.Logging; -import org.geotools.util.Utilities; -import org.geotools.util.Version; /** @@ -733,7 +733,7 @@ static Set<ClassLoader> getClassLoaders() { return addedClassLoaders; } - + /** * Reports the GeoTools {@linkplain #getVersion version} number to the * {@linkplain System#out standard output stream}. Added: trunk/modules/library/metadata/src/test/java/org/geotools/factory/DummyInterfaceImpl.java =================================================================== --- trunk/modules/library/metadata/src/test/java/org/geotools/factory/DummyInterfaceImpl.java (rev 0) +++ trunk/modules/library/metadata/src/test/java/org/geotools/factory/DummyInterfaceImpl.java 2012-01-29 14:22:35 UTC (rev 38536) @@ -0,0 +1,22 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2007-2008, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package org.geotools.factory; + + +public class DummyInterfaceImpl implements DummyInterface { + +} \ No newline at end of file Modified: trunk/modules/library/metadata/src/test/java/org/geotools/factory/FactoryRegistryTest.java =================================================================== --- trunk/modules/library/metadata/src/test/java/org/geotools/factory/FactoryRegistryTest.java 2012-01-29 11:14:03 UTC (rev 38535) +++ trunk/modules/library/metadata/src/test/java/org/geotools/factory/FactoryRegistryTest.java 2012-01-29 14:22:35 UTC (rev 38536) @@ -16,16 +16,23 @@ */ package org.geotools.factory; +import static org.junit.Assert.*; + +import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; import org.geotools.resources.LazySet; +import org.junit.Before; +import org.junit.Test; -import org.junit.*; -import static org.junit.Assert.*; - /** * Tests {@link FactoryRegistry} implementation. * @@ -282,11 +289,49 @@ URLClassLoader cl = new URLClassLoader(new URL[]{url}); GeoTools.addClassLoader(cl); reg.scanForPlugins(); - + + // collect the classes it = reg.getServiceProviders(DummyInterface.class, false); - assertTrue(it.hasNext()); + Set<String> classes = new HashSet<String>(); + while(it.hasNext()) { + classes.add(it.next().getClass().getName()); + } - Object next = it.next(); - assertEquals( "pkg.Foo", next.getClass().getName() ); + assertEquals(2, classes.size()); + assertTrue(classes.contains("pkg.Foo")); + assertTrue(classes.contains("org.geotools.factory.DummyInterfaceImpl")); } + + /** + * Tests for GEOT-2817 + * @throws MalformedURLException + * @throws ClassNotFoundException + */ + @Test + public void testLookupWithSameFactoryInTwoClassLoaders() throws MalformedURLException, ClassNotFoundException { + // create url to this project's classes + URL projectClasses = getClass().getResource("/"); + // create 2 classloaders with parent null to avoid delegation to the system class loader ! + // this occurs in reality with split class loader hierarchies (e.g. GWT plugin and + // some application servers) + URLClassLoader cl1 = new URLClassLoader(new URL[] { projectClasses }, null); + URLClassLoader cl2 = new URLClassLoader(new URL[] { projectClasses }, null); + // extend with both class loaders + GeoTools.addClassLoader(cl1); + GeoTools.addClassLoader(cl2); + // code below was throwing ClassCastException (before java 7) prior to adding isAssignableFrom() check (line 862) + for (int i = 0; i < 2; i++) { + ClassLoader loader = (i == 0 ? cl1 : cl2); + Class dummy = loader.loadClass("org.geotools.factory.DummyInterface"); + FactoryRegistry reg = new FactoryCreator(dummy); + reg.scanForPlugins(); + Iterator it = reg.getServiceProviders(dummy, false); + assertTrue(it.hasNext()); + Object next = it.next(); + // factory class should have same class loader as interface + assertSame(loader, next.getClass().getClassLoader()); + } + } + + } Added: trunk/modules/library/metadata/src/test/resources/META-INF/services/org.geotools.factory.DummyInterface =================================================================== --- trunk/modules/library/metadata/src/test/resources/META-INF/services/org.geotools.factory.DummyInterface (rev 0) +++ trunk/modules/library/metadata/src/test/resources/META-INF/services/org.geotools.factory.DummyInterface 2012-01-29 14:22:35 UTC (rev 38536) @@ -0,0 +1 @@ +org.geotools.factory.DummyInterfaceImpl \ No newline at end of file |
From: <svn...@os...> - 2012-01-29 11:14:10
|
Author: aaime Date: 2012-01-29 03:14:03 -0800 (Sun, 29 Jan 2012) New Revision: 38535 Added: branches/2.7.x/modules/library/metadata/src/test/java/org/geotools/factory/DummyInterface.java branches/2.7.x/modules/library/metadata/src/test/java/org/geotools/factory/DummyInterfaceImpl.java branches/2.7.x/modules/library/metadata/src/test/resources/ branches/2.7.x/modules/library/metadata/src/test/resources/META-INF/ branches/2.7.x/modules/library/metadata/src/test/resources/META-INF/services/ branches/2.7.x/modules/library/metadata/src/test/resources/META-INF/services/org.geotools.factory.DummyInterface Log: Adding some files for GEOT-2817 that I've missed in the first commit Added: branches/2.7.x/modules/library/metadata/src/test/java/org/geotools/factory/DummyInterface.java =================================================================== --- branches/2.7.x/modules/library/metadata/src/test/java/org/geotools/factory/DummyInterface.java (rev 0) +++ branches/2.7.x/modules/library/metadata/src/test/java/org/geotools/factory/DummyInterface.java 2012-01-29 11:14:03 UTC (rev 38535) @@ -0,0 +1,26 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2007-2008, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package org.geotools.factory; + +/** + * + * + * @source $URL: http://svn.osgeo.org/geotools/trunk/modules/library/metadata/src/test/java/org/geotools/factory/DummyInterface.java $ + */ +public interface DummyInterface { + +} Added: branches/2.7.x/modules/library/metadata/src/test/java/org/geotools/factory/DummyInterfaceImpl.java =================================================================== --- branches/2.7.x/modules/library/metadata/src/test/java/org/geotools/factory/DummyInterfaceImpl.java (rev 0) +++ branches/2.7.x/modules/library/metadata/src/test/java/org/geotools/factory/DummyInterfaceImpl.java 2012-01-29 11:14:03 UTC (rev 38535) @@ -0,0 +1,22 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2007-2008, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package org.geotools.factory; + + +public class DummyInterfaceImpl implements DummyInterface { + +} Added: branches/2.7.x/modules/library/metadata/src/test/resources/META-INF/services/org.geotools.factory.DummyInterface =================================================================== --- branches/2.7.x/modules/library/metadata/src/test/resources/META-INF/services/org.geotools.factory.DummyInterface (rev 0) +++ branches/2.7.x/modules/library/metadata/src/test/resources/META-INF/services/org.geotools.factory.DummyInterface 2012-01-29 11:14:03 UTC (rev 38535) @@ -0,0 +1 @@ +org.geotools.factory.DummyInterfaceImpl \ No newline at end of file |
From: <svn...@os...> - 2012-01-29 11:11:50
|
Author: aaime Date: 2012-01-29 03:11:44 -0800 (Sun, 29 Jan 2012) New Revision: 38534 Modified: branches/2.7.x/modules/library/metadata/src/main/java/org/geotools/factory/FactoryRegistry.java branches/2.7.x/modules/library/metadata/src/main/java/org/geotools/factory/GeoTools.java branches/2.7.x/modules/library/metadata/src/test/java/org/geotools/factory/FactoryRegistryTest.java Log: [GEOT-2817] Multiple classloaders giving ClassCastExceptions when GeoTools is used in GWT hosted mode, patch by Jan De Moerloose Modified: branches/2.7.x/modules/library/metadata/src/main/java/org/geotools/factory/FactoryRegistry.java =================================================================== --- branches/2.7.x/modules/library/metadata/src/main/java/org/geotools/factory/FactoryRegistry.java 2012-01-29 10:38:09 UTC (rev 38533) +++ branches/2.7.x/modules/library/metadata/src/main/java/org/geotools/factory/FactoryRegistry.java 2012-01-29 11:11:44 UTC (rev 38534) @@ -706,6 +706,8 @@ loaders.add(loader); } loaders.remove(null); + loaders.addAll(GeoTools.getClassLoaders()); + /* * We now have a set of class loaders with duplicated object already removed * (e.g. system classloader == context classloader). However, we may still @@ -857,26 +859,31 @@ loadingFailure(category, error, true); continue; } - final Class<? extends T> factoryClass = factory.getClass().asSubclass(category); - /* - * If the factory implements more than one interface and an instance were - * already registered, reuse the same instance instead of duplicating it. - */ - final T replacement = getServiceProviderByClass(factoryClass); - if (replacement != null) { - factory = replacement; - // Need to register anyway, because the category may not be the same. - } - if (registerServiceProvider(factory, category)) { + if (category.isAssignableFrom(factory.getClass())) { + final Class<? extends T> factoryClass = factory.getClass().asSubclass(category); /* - * The factory is now registered. Add it to the message to be logged. We will log - * all factories together in a single log event because some registration (e.g. - * MathTransformProviders) would be otherwise quite verbose. + * If the factory implements more than one interface and an + * instance were already registered, reuse the same instance + * instead of duplicating it. */ - message.append(lineSeparator); - message.append(" "); - message.append(factoryClass.getName()); - newServices = true; + final T replacement = getServiceProviderByClass(factoryClass); + if (replacement != null) { + factory = replacement; + // Need to register anyway, because the category may not be + // the same. + } + if (registerServiceProvider(factory, category)) { + /* + * The factory is now registered. Add it to the message to + * be logged. We will log all factories together in a single + * log event because some registration (e.g. + * MathTransformProviders) would be otherwise quite verbose. + */ + message.append(lineSeparator); + message.append(" "); + message.append(factoryClass.getName()); + newServices = true; + } } } return newServices; Modified: branches/2.7.x/modules/library/metadata/src/main/java/org/geotools/factory/GeoTools.java =================================================================== --- branches/2.7.x/modules/library/metadata/src/main/java/org/geotools/factory/GeoTools.java 2012-01-29 10:38:09 UTC (rev 38533) +++ branches/2.7.x/modules/library/metadata/src/main/java/org/geotools/factory/GeoTools.java 2012-01-29 11:11:44 UTC (rev 38534) @@ -20,9 +20,11 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.Set; import java.util.StringTokenizer; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -36,12 +38,12 @@ import org.geotools.resources.Arguments; import org.geotools.resources.Classes; +import org.geotools.resources.i18n.ErrorKeys; import org.geotools.resources.i18n.Errors; -import org.geotools.resources.i18n.ErrorKeys; +import org.geotools.util.Utilities; +import org.geotools.util.Version; import org.geotools.util.logging.LoggerFactory; import org.geotools.util.logging.Logging; -import org.geotools.util.Utilities; -import org.geotools.util.Version; /** @@ -198,6 +200,15 @@ } /** + * Class loaders to be added to the list in ${link {@link FactoryRegistry#getClassLoaders()}} + * which are used to look-up plug-ins. Class loaders are added via + * {@link #addClassLoader(ClassLoader)} + */ + private static final Set<ClassLoader> addedClassLoaders = + Collections.synchronizedSet(new HashSet<ClassLoader>()); + + + /** * The initial context. Will be created only when first needed. */ private static InitialContext context; @@ -688,6 +699,29 @@ } /** + * Adds a class loader to be included in the list of class loaders that are used to locate + * GeoTools plug-ins. + * <p> + * Client code that calls this method may also need to call {@link FactoryRegistry#scanForPlugins()} + * on any existing registry to force it to clear its cache and use the added class loader to + * locate plugins. + * </p> + * + * @param classLoader The class loader. + */ + public static void addClassLoader(ClassLoader classLoader) { + addedClassLoaders.add(classLoader); + fireConfigurationChanged(); + } + + /** + * Returns the class loaders added via {@link #addClassLoader(ClassLoader)}. + */ + static Set<ClassLoader> getClassLoaders() { + return addedClassLoaders; + } + + /** * Reports the GeoTools {@linkplain #getVersion version} number to the * {@linkplain System#out standard output stream}. * Modified: branches/2.7.x/modules/library/metadata/src/test/java/org/geotools/factory/FactoryRegistryTest.java =================================================================== --- branches/2.7.x/modules/library/metadata/src/test/java/org/geotools/factory/FactoryRegistryTest.java 2012-01-29 10:38:09 UTC (rev 38533) +++ branches/2.7.x/modules/library/metadata/src/test/java/org/geotools/factory/FactoryRegistryTest.java 2012-01-29 11:11:44 UTC (rev 38534) @@ -16,13 +16,27 @@ */ package org.geotools.factory; -import java.util.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + import org.geotools.resources.LazySet; +import org.junit.Before; +import org.junit.Test; -import org.junit.*; -import static org.junit.Assert.*; - /** * Tests {@link FactoryRegistry} implementation. * @@ -265,4 +279,39 @@ factory = registry.getServiceProvider(DummyFactory.class, null, hints, key); assertEquals("An instance of Factory #4 should have been created.", DummyFactory.Example4.class, factory.getClass()); } + + /** + * Tests for GEOT-2817 + * @throws MalformedURLException + * @throws ClassNotFoundException + */ + @Test + public void testLookupWithSameFactoryInTwoClassLoaders() throws MalformedURLException, ClassNotFoundException { + // create url to this project's classes + URL projectClasses = getClass().getResource("/"); + // create 2 classloaders with parent null to avoid delegation to the system class loader ! + // this occurs in reality with split class loader hierarchies (e.g. GWT plugin and + // some application servers) + URLClassLoader cl1 = new URLClassLoader(new URL[] { projectClasses }, null); + URLClassLoader cl2 = new URLClassLoader(new URL[] { projectClasses }, null); + // extend with both class loaders + GeoTools.addClassLoader(cl1); + GeoTools.addClassLoader(cl2); + // code below was throwing ClassCastException (before java 7) prior to adding isAssignableFrom() check (line 862) + for (int i = 0; i < 2; i++) { + ClassLoader loader = (i == 0 ? cl1 : cl2); + Class dummy = loader.loadClass("org.geotools.factory.DummyInterface"); + FactoryRegistry reg = new FactoryCreator(dummy); + reg.scanForPlugins(); + Iterator it = reg.getServiceProviders(dummy, false); + assertTrue(it.hasNext()); + Object next = it.next(); + // factory class should have same class loader as interface + assertSame(loader, next.getClass().getClassLoader()); + } + } + + + + } |
From: <svn...@os...> - 2012-01-29 10:38:15
|
Author: aaime Date: 2012-01-29 02:38:09 -0800 (Sun, 29 Jan 2012) New Revision: 38533 Modified: branches/2.7.x/modules/library/main/src/main/java/org/geotools/filter/FidFilterImpl.java Log: [GEOT-3986] using FidFilter could be very cost intensive Modified: branches/2.7.x/modules/library/main/src/main/java/org/geotools/filter/FidFilterImpl.java =================================================================== --- branches/2.7.x/modules/library/main/src/main/java/org/geotools/filter/FidFilterImpl.java 2012-01-29 10:35:37 UTC (rev 38532) +++ branches/2.7.x/modules/library/main/src/main/java/org/geotools/filter/FidFilterImpl.java 2012-01-29 10:38:09 UTC (rev 38533) @@ -28,6 +28,7 @@ import org.geotools.factory.CommonFactoryFinder; import org.geotools.filter.expression.PropertyAccessor; import org.geotools.filter.expression.SimpleFeaturePropertyAccessorFactory; +import org.opengis.filter.FilterFactory; import org.opengis.filter.FilterVisitor; import org.opengis.filter.identity.Identifier; @@ -235,16 +236,18 @@ * @see SimpleFeaturePropertyAccessorFactory */ public boolean evaluate(Object feature) { - if (feature == null) { - return false; - } - - final Set fids = fids(); - - - //NC - updated, using attributeexpressionimpl will be easiest, don't have to copy and paste lots of code - Object evaluate = CommonFactoryFinder.getFilterFactory(null).property("@id").evaluate(feature); - return evaluate == null? false : fids.contains(evaluate); + if (feature == null) { + return false; + } + + //NC - updated, using attributeexpressionimpl will be easiest, don't have to copy and paste lots of code + FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); + String evaluate = ff.property("@id").evaluate(feature, String.class); + if(evaluate == null) { + return false; + } else { + return fids.contains(ff.featureId(evaluate)); + } } /** |
From: <svn...@os...> - 2012-01-29 10:35:44
|
Author: aaime Date: 2012-01-29 02:35:37 -0800 (Sun, 29 Jan 2012) New Revision: 38532 Modified: trunk/modules/library/main/src/main/java/org/geotools/filter/FidFilterImpl.java Log: [GEOT-3986] using FidFilter could be very cost intensive Modified: trunk/modules/library/main/src/main/java/org/geotools/filter/FidFilterImpl.java =================================================================== --- trunk/modules/library/main/src/main/java/org/geotools/filter/FidFilterImpl.java 2012-01-27 14:52:51 UTC (rev 38531) +++ trunk/modules/library/main/src/main/java/org/geotools/filter/FidFilterImpl.java 2012-01-29 10:35:37 UTC (rev 38532) @@ -28,6 +28,7 @@ import org.geotools.factory.CommonFactoryFinder; import org.geotools.filter.expression.PropertyAccessor; import org.geotools.filter.expression.SimpleFeaturePropertyAccessorFactory; +import org.opengis.filter.FilterFactory; import org.opengis.filter.FilterVisitor; import org.opengis.filter.identity.Identifier; @@ -236,16 +237,18 @@ * @see SimpleFeaturePropertyAccessorFactory */ public boolean evaluate(Object feature) { - if (feature == null) { - return false; - } - - final Set fids = fids(); - - - //NC - updated, using attributeexpressionimpl will be easiest, don't have to copy and paste lots of code - Object evaluate = CommonFactoryFinder.getFilterFactory(null).property("@id").evaluate(feature); - return evaluate == null? false : fids.contains(evaluate); + if (feature == null) { + return false; + } + + //NC - updated, using attributeexpressionimpl will be easiest, don't have to copy and paste lots of code + FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); + String evaluate = ff.property("@id").evaluate(feature, String.class); + if(evaluate == null) { + return false; + } else { + return fids.contains(ff.featureId(evaluate)); + } } /** |
From: <svn...@os...> - 2012-01-27 14:53:03
|
Author: jdeolive Date: 2012-01-27 06:52:51 -0800 (Fri, 27 Jan 2012) New Revision: 38531 Added: trunk/modules/library/main/src/main/java/org/geotools/styling/DefaultResourceLocator.java Modified: trunk/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/se/v1_1/SEConfiguration.java trunk/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/se/v1_1/bindings/OnlineResourceBinding.java trunk/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/sld/SLDConfiguration.java trunk/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/sld/bindings/SLDOnlineResourceBinding.java trunk/modules/library/main/src/main/java/org/geotools/styling/SLDParser.java Log: GEOT-4000, supporting SLD ResourceLocator interface in xsd SLD/SE parsers Modified: trunk/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/se/v1_1/SEConfiguration.java =================================================================== --- trunk/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/se/v1_1/SEConfiguration.java 2012-01-27 14:51:46 UTC (rev 38530) +++ trunk/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/se/v1_1/SEConfiguration.java 2012-01-27 14:52:51 UTC (rev 38531) @@ -18,6 +18,8 @@ import org.eclipse.xsd.util.XSDSchemaLocationResolver; import org.geotools.filter.v1_1.OGCConfiguration; import org.geotools.se.v1_1.bindings.*; +import org.geotools.styling.DefaultResourceLocator; +import org.geotools.styling.ResourceLocator; import org.geotools.styling.StyleFactory; import org.geotools.styling.StyleFactoryImpl; import org.geotools.xml.Configuration; @@ -127,6 +129,7 @@ super.configureContext(container); container.registerComponentImplementation(StyleFactory.class, StyleFactoryImpl.class); + container.registerComponentInstance(ResourceLocator.class, new DefaultResourceLocator()); } @Override Modified: trunk/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/se/v1_1/bindings/OnlineResourceBinding.java =================================================================== --- trunk/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/se/v1_1/bindings/OnlineResourceBinding.java 2012-01-27 14:51:46 UTC (rev 38530) +++ trunk/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/se/v1_1/bindings/OnlineResourceBinding.java 2012-01-27 14:52:51 UTC (rev 38531) @@ -18,6 +18,7 @@ import org.geotools.se.v1_1.SE; import org.geotools.sld.bindings.SLDOnlineResourceBinding; +import org.geotools.styling.ResourceLocator; import org.geotools.xml.*; import javax.xml.namespace.QName; @@ -49,6 +50,10 @@ */ public class OnlineResourceBinding extends SLDOnlineResourceBinding { + public OnlineResourceBinding(ResourceLocator resourceLocator) { + super(resourceLocator); + } + /** * @generated */ Modified: trunk/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/sld/SLDConfiguration.java =================================================================== --- trunk/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/sld/SLDConfiguration.java 2012-01-27 14:51:46 UTC (rev 38530) +++ trunk/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/sld/SLDConfiguration.java 2012-01-27 14:52:51 UTC (rev 38531) @@ -16,6 +16,9 @@ */ package org.geotools.sld; +import java.net.MalformedURLException; +import java.net.URL; + import org.picocontainer.MutablePicoContainer; import org.geotools.filter.v1_0.OGCConfiguration; import org.geotools.sld.bindings.SLD; @@ -66,6 +69,8 @@ import org.geotools.sld.bindings.SLDUserLayerBinding; import org.geotools.sld.bindings.SLDUserStyleBinding; import org.geotools.sld.bindings.SLDVendorOptionBinding; +import org.geotools.styling.DefaultResourceLocator; +import org.geotools.styling.ResourceLocator; import org.geotools.styling.StyleFactory; import org.geotools.styling.StyleFactoryImpl; import org.geotools.xml.Configuration; @@ -189,6 +194,7 @@ super.configureContext(container); container.registerComponentImplementation(StyleFactory.class, StyleFactoryImpl.class); + container.registerComponentInstance(ResourceLocator.class, new DefaultResourceLocator()); } @Override Modified: trunk/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/sld/bindings/SLDOnlineResourceBinding.java =================================================================== --- trunk/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/sld/bindings/SLDOnlineResourceBinding.java 2012-01-27 14:51:46 UTC (rev 38530) +++ trunk/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/sld/bindings/SLDOnlineResourceBinding.java 2012-01-27 14:52:51 UTC (rev 38531) @@ -20,7 +20,11 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; import java.net.URI; +import java.net.URL; + import javax.xml.namespace.QName; + +import org.geotools.styling.ResourceLocator; import org.geotools.xml.*; @@ -51,6 +55,13 @@ * @source $URL$ */ public class SLDOnlineResourceBinding extends AbstractComplexBinding { + + ResourceLocator resourceLocator; + + public SLDOnlineResourceBinding(ResourceLocator resourceLocator) { + this.resourceLocator = resourceLocator; + } + /** * @generated */ @@ -96,6 +107,14 @@ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { //just grab the URI and pass it back - return node.getAttributeValue("href"); + Object href = node.getAttributeValue("href"); + if (href != null) { + URL located = resourceLocator.locateResource(href.toString()); + if (located != null) { + //return as a uri + return located.toURI(); + } + } + return href; } } Added: trunk/modules/library/main/src/main/java/org/geotools/styling/DefaultResourceLocator.java =================================================================== --- trunk/modules/library/main/src/main/java/org/geotools/styling/DefaultResourceLocator.java (rev 0) +++ trunk/modules/library/main/src/main/java/org/geotools/styling/DefaultResourceLocator.java 2012-01-27 14:52:51 UTC (rev 38531) @@ -0,0 +1,63 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2005-2008, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package org.geotools.styling; + +import java.net.MalformedURLException; +import java.net.URL; + +/** + * Default locator for online resources. Searches by absolute URL, relative + * path w.r.t. to SLD document or classpath. + * + * @author Jan De Moerloose + * + */ +public class DefaultResourceLocator implements ResourceLocator { + + URL sourceUrl; + + private static final java.util.logging.Logger LOGGER = org.geotools.util.logging.Logging + .getLogger("org.geotools.styling"); + + public void setSourceUrl(URL sourceUrl) { + this.sourceUrl = sourceUrl; + } + + public URL locateResource(String uri) { + URL url = null; + try { + url = new URL(uri); + } catch (MalformedURLException mfe) { + LOGGER.fine("Looks like " + uri + " is a relative path.."); + if (sourceUrl != null) { + try { + url = new URL(sourceUrl, uri); + } catch (MalformedURLException e) { + LOGGER.warning("can't parse " + uri + " as relative to" + + sourceUrl.toExternalForm()); + } + } + if (url == null) + { + url = getClass().getResource(uri); + if (url == null) + LOGGER.warning("can't parse " + uri + " as a java resource present in the classpath"); + } + } + return url; + } +} Property changes on: trunk/modules/library/main/src/main/java/org/geotools/styling/DefaultResourceLocator.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id URL Added: svn:eol-style + native Modified: trunk/modules/library/main/src/main/java/org/geotools/styling/SLDParser.java =================================================================== --- trunk/modules/library/main/src/main/java/org/geotools/styling/SLDParser.java 2012-01-27 14:51:46 UTC (rev 38530) +++ trunk/modules/library/main/src/main/java/org/geotools/styling/SLDParser.java 2012-01-27 14:52:51 UTC (rev 38531) @@ -223,7 +223,7 @@ File f = new File(filename); source = new InputSource(new java.io.FileInputStream(f)); try { - sourceUrl = f.toURI().toURL(); + setSourceUrl(f.toURI().toURL()); } catch (MalformedURLException e) { LOGGER.warning("Can't build URL for file " + f.getAbsolutePath()); } @@ -241,7 +241,7 @@ public void setInput(File f) throws java.io.FileNotFoundException { source = new InputSource(new java.io.FileInputStream(f)); try { - sourceUrl = f.toURI().toURL(); + setSourceUrl(f.toURI().toURL()); } catch (MalformedURLException e) { LOGGER.warning("Can't build URL for file " + f.getAbsolutePath()); } @@ -258,7 +258,7 @@ */ public void setInput(java.net.URL url) throws java.io.IOException { source = new InputSource(url.openStream()); - sourceUrl = url; + setSourceUrl(url); } /** @@ -280,12 +280,25 @@ public void setInput(java.io.Reader in) { source = new InputSource(in); } - + + /** + * Sets the resource loader implementation for parsing online resources. + */ public void setOnLineResourceLocator(ResourceLocator onlineResourceLocator) { this.onlineResourceLocator = onlineResourceLocator; } /** + * Internal setter for source url. + */ + void setSourceUrl(URL sourceUrl) { + this.sourceUrl = sourceUrl; + if (onlineResourceLocator instanceof DefaultResourceLocator) { + ((DefaultResourceLocator) onlineResourceLocator).setSourceUrl(sourceUrl); + } + } + + /** * Read the xml inputsource provided and create a Style object for each user style found * * @return Style[] the styles constructed. @@ -2353,39 +2366,4 @@ return halo; } - - /** - * Default locator for online resources. Searches by absolute URL, relative - * path w.r.t. to SLD document or classpath. - * - * @author Jan De Moerloose - * - */ - class DefaultResourceLocator implements ResourceLocator { - - public URL locateResource(String uri) { - URL url = null; - try { - url = new URL(uri); - } catch (MalformedURLException mfe) { - LOGGER.fine("Looks like " + uri + " is a relative path.."); - if (sourceUrl != null) { - try { - url = new URL(sourceUrl, uri); - } catch (MalformedURLException e) { - LOGGER.warning("can't parse " + uri + " as relative to" - + sourceUrl.toExternalForm()); - } - } - if (url == null) - { - url = getClass().getResource(uri); - if (url == null) - LOGGER.warning("can't parse " + uri + " as a java resource present in the classpath"); - } - } - return url; - } - - } } |
From: <svn...@os...> - 2012-01-27 14:51:53
|
Author: jdeolive Date: 2012-01-27 06:51:46 -0800 (Fri, 27 Jan 2012) New Revision: 38530 Added: branches/2.7.x/modules/library/main/src/main/java/org/geotools/styling/DefaultResourceLocator.java Modified: branches/2.7.x/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/se/v1_1/SEConfiguration.java branches/2.7.x/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/se/v1_1/bindings/OnlineResourceBinding.java branches/2.7.x/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/sld/SLDConfiguration.java branches/2.7.x/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/sld/bindings/SLDOnlineResourceBinding.java branches/2.7.x/modules/library/main/src/main/java/org/geotools/styling/SLDParser.java Log: GEOT-4000, supporting SLD ResourceLocator interface in xsd SLD/SE parsers Modified: branches/2.7.x/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/se/v1_1/SEConfiguration.java =================================================================== --- branches/2.7.x/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/se/v1_1/SEConfiguration.java 2012-01-27 02:41:33 UTC (rev 38529) +++ branches/2.7.x/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/se/v1_1/SEConfiguration.java 2012-01-27 14:51:46 UTC (rev 38530) @@ -18,6 +18,8 @@ import org.eclipse.xsd.util.XSDSchemaLocationResolver; import org.geotools.filter.v1_1.OGCConfiguration; import org.geotools.se.v1_1.bindings.*; +import org.geotools.styling.DefaultResourceLocator; +import org.geotools.styling.ResourceLocator; import org.geotools.styling.StyleFactory; import org.geotools.styling.StyleFactoryImpl; import org.geotools.xml.Configuration; @@ -126,6 +128,7 @@ super.configureContext(container); container.registerComponentImplementation(StyleFactory.class, StyleFactoryImpl.class); + container.registerComponentInstance(ResourceLocator.class, new DefaultResourceLocator()); } @Override Modified: branches/2.7.x/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/se/v1_1/bindings/OnlineResourceBinding.java =================================================================== --- branches/2.7.x/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/se/v1_1/bindings/OnlineResourceBinding.java 2012-01-27 02:41:33 UTC (rev 38529) +++ branches/2.7.x/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/se/v1_1/bindings/OnlineResourceBinding.java 2012-01-27 14:51:46 UTC (rev 38530) @@ -18,6 +18,7 @@ import org.geotools.se.v1_1.SE; import org.geotools.sld.bindings.SLDOnlineResourceBinding; +import org.geotools.styling.ResourceLocator; import org.geotools.xml.*; import javax.xml.namespace.QName; @@ -48,6 +49,10 @@ */ public class OnlineResourceBinding extends SLDOnlineResourceBinding { + public OnlineResourceBinding(ResourceLocator resourceLocator) { + super(resourceLocator); + } + /** * @generated */ Modified: branches/2.7.x/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/sld/SLDConfiguration.java =================================================================== --- branches/2.7.x/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/sld/SLDConfiguration.java 2012-01-27 02:41:33 UTC (rev 38529) +++ branches/2.7.x/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/sld/SLDConfiguration.java 2012-01-27 14:51:46 UTC (rev 38530) @@ -16,6 +16,9 @@ */ package org.geotools.sld; +import java.net.MalformedURLException; +import java.net.URL; + import org.picocontainer.MutablePicoContainer; import org.geotools.filter.v1_0.OGCConfiguration; import org.geotools.sld.bindings.SLD; @@ -66,6 +69,8 @@ import org.geotools.sld.bindings.SLDUserLayerBinding; import org.geotools.sld.bindings.SLDUserStyleBinding; import org.geotools.sld.bindings.SLDVendorOptionBinding; +import org.geotools.styling.DefaultResourceLocator; +import org.geotools.styling.ResourceLocator; import org.geotools.styling.StyleFactory; import org.geotools.styling.StyleFactoryImpl; import org.geotools.xml.Configuration; @@ -188,6 +193,7 @@ super.configureContext(container); container.registerComponentImplementation(StyleFactory.class, StyleFactoryImpl.class); + container.registerComponentInstance(ResourceLocator.class, new DefaultResourceLocator()); } @Override Modified: branches/2.7.x/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/sld/bindings/SLDOnlineResourceBinding.java =================================================================== --- branches/2.7.x/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/sld/bindings/SLDOnlineResourceBinding.java 2012-01-27 02:41:33 UTC (rev 38529) +++ branches/2.7.x/modules/extension/xsd/xsd-sld/src/main/java/org/geotools/sld/bindings/SLDOnlineResourceBinding.java 2012-01-27 14:51:46 UTC (rev 38530) @@ -20,7 +20,11 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; import java.net.URI; +import java.net.URL; + import javax.xml.namespace.QName; + +import org.geotools.styling.ResourceLocator; import org.geotools.xml.*; @@ -50,6 +54,13 @@ * @source $URL$ */ public class SLDOnlineResourceBinding extends AbstractComplexBinding { + + ResourceLocator resourceLocator; + + public SLDOnlineResourceBinding(ResourceLocator resourceLocator) { + this.resourceLocator = resourceLocator; + } + /** * @generated */ @@ -95,6 +106,14 @@ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { //just grab the URI and pass it back - return node.getAttributeValue("href"); + Object href = node.getAttributeValue("href"); + if (href != null) { + URL located = resourceLocator.locateResource(href.toString()); + if (located != null) { + //return as a uri + return located.toURI(); + } + } + return href; } } Added: branches/2.7.x/modules/library/main/src/main/java/org/geotools/styling/DefaultResourceLocator.java =================================================================== --- branches/2.7.x/modules/library/main/src/main/java/org/geotools/styling/DefaultResourceLocator.java (rev 0) +++ branches/2.7.x/modules/library/main/src/main/java/org/geotools/styling/DefaultResourceLocator.java 2012-01-27 14:51:46 UTC (rev 38530) @@ -0,0 +1,63 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2005-2008, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package org.geotools.styling; + +import java.net.MalformedURLException; +import java.net.URL; + +/** + * Default locator for online resources. Searches by absolute URL, relative + * path w.r.t. to SLD document or classpath. + * + * @author Jan De Moerloose + * + */ +public class DefaultResourceLocator implements ResourceLocator { + + URL sourceUrl; + + private static final java.util.logging.Logger LOGGER = org.geotools.util.logging.Logging + .getLogger("org.geotools.styling"); + + public void setSourceUrl(URL sourceUrl) { + this.sourceUrl = sourceUrl; + } + + public URL locateResource(String uri) { + URL url = null; + try { + url = new URL(uri); + } catch (MalformedURLException mfe) { + LOGGER.fine("Looks like " + uri + " is a relative path.."); + if (sourceUrl != null) { + try { + url = new URL(sourceUrl, uri); + } catch (MalformedURLException e) { + LOGGER.warning("can't parse " + uri + " as relative to" + + sourceUrl.toExternalForm()); + } + } + if (url == null) + { + url = getClass().getResource(uri); + if (url == null) + LOGGER.warning("can't parse " + uri + " as a java resource present in the classpath"); + } + } + return url; + } +} Property changes on: branches/2.7.x/modules/library/main/src/main/java/org/geotools/styling/DefaultResourceLocator.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id URL Added: svn:eol-style + native Modified: branches/2.7.x/modules/library/main/src/main/java/org/geotools/styling/SLDParser.java =================================================================== --- branches/2.7.x/modules/library/main/src/main/java/org/geotools/styling/SLDParser.java 2012-01-27 02:41:33 UTC (rev 38529) +++ branches/2.7.x/modules/library/main/src/main/java/org/geotools/styling/SLDParser.java 2012-01-27 14:51:46 UTC (rev 38530) @@ -219,7 +219,7 @@ File f = new File(filename); source = new InputSource(new java.io.FileInputStream(f)); try { - sourceUrl = f.toURI().toURL(); + setSourceUrl(f.toURI().toURL()); } catch (MalformedURLException e) { LOGGER.warning("Can't build URL for file " + f.getAbsolutePath()); } @@ -237,7 +237,7 @@ public void setInput(File f) throws java.io.FileNotFoundException { source = new InputSource(new java.io.FileInputStream(f)); try { - sourceUrl = f.toURI().toURL(); + setSourceUrl(f.toURI().toURL()); } catch (MalformedURLException e) { LOGGER.warning("Can't build URL for file " + f.getAbsolutePath()); } @@ -254,7 +254,7 @@ */ public void setInput(java.net.URL url) throws java.io.IOException { source = new InputSource(url.openStream()); - sourceUrl = url; + setSourceUrl(url); } /** @@ -276,12 +276,25 @@ public void setInput(java.io.Reader in) { source = new InputSource(in); } - + + /** + * Sets the resource loader implementation for parsing online resources. + */ public void setOnLineResourceLocator(ResourceLocator onlineResourceLocator) { this.onlineResourceLocator = onlineResourceLocator; } /** + * Internal setter for source url. + */ + void setSourceUrl(URL sourceUrl) { + this.sourceUrl = sourceUrl; + if (onlineResourceLocator instanceof DefaultResourceLocator) { + ((DefaultResourceLocator) onlineResourceLocator).setSourceUrl(sourceUrl); + } + } + + /** * Read the xml inputsource provided and create a Style object for each user style found * * @return Style[] the styles constructed. @@ -2328,39 +2341,4 @@ return halo; } - - /** - * Default locator for online resources. Searches by absolute URL, relative - * path w.r.t. to SLD document or classpath. - * - * @author Jan De Moerloose - * - */ - class DefaultResourceLocator implements ResourceLocator { - - public URL locateResource(String uri) { - URL url = null; - try { - url = new URL(uri); - } catch (MalformedURLException mfe) { - LOGGER.fine("Looks like " + uri + " is a relative path.."); - if (sourceUrl != null) { - try { - url = new URL(sourceUrl, uri); - } catch (MalformedURLException e) { - LOGGER.warning("can't parse " + uri + " as relative to" - + sourceUrl.toExternalForm()); - } - } - if (url == null) - { - url = getClass().getResource(uri); - if (url == null) - LOGGER.warning("can't parse " + uri + " as a java resource present in the classpath"); - } - } - return url; - } - - } } |
From: <svn...@os...> - 2012-01-27 02:49:01
|
Author: jive Date: 2012-01-26 18:40:28 -0800 (Thu, 26 Jan 2012) New Revision: 38526 Modified: trunk/modules/library/main/src/main/java/org/geotools/data/AbstractDataStoreFactory.java trunk/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileDataStoreFactory.java trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/ShapefileDataStoreFactoryTest.java trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactory.java trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactoryTest.java Log: Allow canProcess to check options; and use FSType to allow client code to choose between shapefile and ShapefileNG Modified: trunk/modules/library/main/src/main/java/org/geotools/data/AbstractDataStoreFactory.java =================================================================== --- trunk/modules/library/main/src/main/java/org/geotools/data/AbstractDataStoreFactory.java 2012-01-27 02:39:28 UTC (rev 38525) +++ trunk/modules/library/main/src/main/java/org/geotools/data/AbstractDataStoreFactory.java 2012-01-27 02:40:28 UTC (rev 38526) @@ -19,6 +19,7 @@ import java.io.IOException; import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.geotools.data.DataAccessFactory.Param; @@ -142,6 +143,15 @@ if ( !param.type.isInstance( value )){ return false; // value was not of the required type } + if( param.metadata != null ){ + // check metadata + if( param.metadata.containsKey(Param.OPTIONS)){ + List<Object> options = (List<Object>) param.metadata.get(Param.OPTIONS); + if( options != null && !options.contains(value) ){ + return false; // invalid option + } + } + } } } return true; Modified: trunk/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileDataStoreFactory.java =================================================================== --- trunk/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileDataStoreFactory.java 2012-01-27 02:39:28 UTC (rev 38525) +++ trunk/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileDataStoreFactory.java 2012-01-27 02:40:28 UTC (rev 38526) @@ -29,6 +29,7 @@ import java.util.TimeZone; import java.util.logging.Logger; +import org.geotools.data.AbstractDataStoreFactory; import org.geotools.data.DataSourceException; import org.geotools.data.DataStore; import org.geotools.data.DataUtilities; @@ -59,12 +60,10 @@ * * @author Chris Holmes, TOPP * - * * @source $URL$ - * @version $Id: ShapefileDataStoreFactory.java 27856 2007-11-12 17:23:35Z - * desruisseaux $ + * @version $Id: ShapefileDataStoreFactory.java 27856 2007-11-12 17:23:35Z desruisseaux $ */ -public class ShapefileDataStoreFactory implements FileDataStoreFactorySpi { +public class ShapefileDataStoreFactory extends AbstractDataStoreFactory implements FileDataStoreFactorySpi { public static final Logger LOGGER = org.geotools.util.logging.Logging .getLogger("org.geotools.data.shapefile"); @@ -152,12 +151,13 @@ }; /** - * Optional - marker parameter to allow shapefile ng support to be specified + * Optional parameter used to indicate 'shape' or 'index' (marker to select the implementation + * of DataStore to use). */ - public static final Param SORT = new Param("sort", - String.class, "Sort strategy 'none' supported, 'memory' and 'disk' not supported", false, "none", - new KVP(Param.LEVEL, "advanced", Param.OPTIONS,Arrays.asList(new String[]{"none","memory","disk"}))); - + public static final Param FSTYPE = new Param("fstype", + String.class, "Enable 'shape' or 'index'.", false, "shape", + new KVP(Param.LEVEL, "advanced", Param.OPTIONS, Arrays.asList(new String[]{"shape","index"}))); + /** * Takes a map of parameters which describes how to access a DataStore and * determines if it can be read by the ShapefileDataStore or @@ -171,41 +171,27 @@ * ending in shp */ public boolean canProcess(Map params) { - boolean accept = false; - try { - String sort = (String) SORT.lookUp(params); - if( sort == null || "none".equals( sort )){ - // this is fine we can support that - } - else if ("memory".equals(sort)){ - return false; // not supported - } - else if ("disk".equals(sort)){ - return false; // not supported - } - else { - LOGGER.warning("Unexpected sort level request: '"+sort+"'"); - } - } catch (IOException e) { - return false; + if (!super.canProcess(params)) { + return false; // fail basic param check } if (params.containsKey(URLP.key)) { try { URL url = (URL) URLP.lookUp(params); - accept = canProcess(url); - if(!accept) { + if( !canProcess(url) ){ // maybe it's a directory? Object fileType = FILE_TYPE.lookUp(params); File dir = DataUtilities.urlToFile(url); - // check for null fileType for backwards compatibility - accept = dir.isDirectory() && (fileType == null || "shapefile".equals(fileType)); + boolean testFileTest = dir.isDirectory() && (fileType == null || "shapefile".equals(fileType)); + if (!testFileTest){ + return false; // check for null fileType for backwards compatibility + } } } catch (IOException ioe) { // yes, I am eating this - since it is my job to return a // true/false } } - return accept; + return true; } /** @@ -376,7 +362,7 @@ */ public Param[] getParametersInfo() { return new Param[] { URLP, NAMESPACEP, CREATE_SPATIAL_INDEX, - DBFCHARSET, DBFTIMEZONE, MEMORY_MAPPED, CACHE_MEMORY_MAPS, FILE_TYPE }; + DBFCHARSET, DBFTIMEZONE, MEMORY_MAPPED, CACHE_MEMORY_MAPS, FILE_TYPE, FSTYPE }; } /** Modified: trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/ShapefileDataStoreFactoryTest.java =================================================================== --- trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/ShapefileDataStoreFactoryTest.java 2012-01-27 02:39:28 UTC (rev 38525) +++ trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/ShapefileDataStoreFactoryTest.java 2012-01-27 02:40:28 UTC (rev 38526) @@ -23,16 +23,7 @@ import org.geotools.util.KVP; import org.junit.Test; -import static org.geotools.data.shapefile.ShapefileDataStoreFactory.CACHE_MEMORY_MAPS; -import static org.geotools.data.shapefile.ShapefileDataStoreFactory.CREATE_SPATIAL_INDEX; -import static org.geotools.data.shapefile.ShapefileDataStoreFactory.DBFCHARSET; -import static org.geotools.data.shapefile.ShapefileDataStoreFactory.DBFTIMEZONE; -import static org.geotools.data.shapefile.ShapefileDataStoreFactory.FILE_TYPE; -import static org.geotools.data.shapefile.ShapefileDataStoreFactory.LOGGER; -import static org.geotools.data.shapefile.ShapefileDataStoreFactory.MEMORY_MAPPED; -import static org.geotools.data.shapefile.ShapefileDataStoreFactory.NAMESPACEP; -import static org.geotools.data.shapefile.ShapefileDataStoreFactory.SORT; -import static org.geotools.data.shapefile.ShapefileDataStoreFactory.URLP; +import static org.geotools.data.shapefile.ShapefileDataStoreFactory.*; /** * Test the functionality of ShapefileDataStoreFactory; specifically the handling of @@ -57,21 +48,24 @@ } @Test - public void testSortParameter() throws Exception { + public void testFSTypeParameter() throws Exception { URL url = TestData.url(STATE_POP); KVP params = new KVP( URLP.key,url ); assertTrue( "Sorting is optional", factory.canProcess(params) ); - params.put( SORT.key, "memory" ); - assertFalse( "Memory sorting not supported", factory.canProcess(params) ); + params.put(FSTYPE.key, "shape" ); + assertTrue( "Plain shape implementation provided", factory.canProcess(params) ); - params.put(SORT.key, "disk" ); - assertFalse( "Disk sorting not supported", factory.canProcess(params) ); + params.put(FSTYPE.key, "index" ); + assertTrue( "Index shape implementation provided", factory.canProcess(params) ); - params.put(SORT.key, "none" ); - assertTrue( "Sorting is not supported", factory.canProcess(params) ); + params.put( FSTYPE.key, "shape-ng" ); + assertFalse( "Shape NG sorting not supported", factory.canProcess(params) ); + + params.put( FSTYPE.key, "smurf" ); + assertFalse( "Feeling blue; don't try a smruf", factory.canProcess(params) ); } } Modified: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactory.java =================================================================== --- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactory.java 2012-01-27 02:39:28 UTC (rev 38525) +++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactory.java 2012-01-27 02:40:28 UTC (rev 38526) @@ -109,14 +109,13 @@ return ((Charset) value).name(); } }; - /** - * Optional - marker parameter to allow shapefile ng support to be specified + * Optional parameter used to indicate 'shape-ng' (as a marker to select the implementation + * of DataStore to use). */ - public static final Param SORT = new Param("sort", - String.class, "Sort strategy 'disk' supported, 'memory' and 'none' not supported", false, "none", - new KVP(Param.LEVEL, "advanced", Param.OPTIONS,Arrays.asList(new String[]{"none","memory","disk"}))); - + public static final Param FSTYPE = new Param("fstype", + String.class, "Enable using a setting of 'shape-ng'.", false, "shape-ng", + new KVP(Param.LEVEL, "advanced", Param.OPTIONS,Arrays.asList(new String[]{"shape-ng"}))); /** * Optional - timezone to decode dates from the DBF file */ @@ -143,7 +142,7 @@ public Param[] getParametersInfo() { return new Param[] { URLP, NAMESPACEP, CREATE_SPATIAL_INDEX, DBFCHARSET, DBFTIMEZONE, - MEMORY_MAPPED, CACHE_MEMORY_MAPS, FILE_TYPE }; + MEMORY_MAPPED, CACHE_MEMORY_MAPS, FILE_TYPE, FSTYPE }; } public boolean isAvailable() { @@ -217,23 +216,9 @@ @Override public boolean canProcess(Map params) { if (!super.canProcess(params)) { - return false; + return false; // fail basic param check } try { - String sort = (String) SORT.lookUp(params); - if( sort == null || "disk".equals( sort )){ - // this is fine we can support that - } - else if ("memory".equals(sort) || "none".equals(sort)){ - return false; // not supported - } - else { - LOGGER.warning("Unexpected sort level request: '"+sort+"'"); - } - } catch (IOException e) { - return false; - } - try { URL url = (URL) URLP.lookUp(params); if (canProcess(url)) { return true; @@ -272,7 +257,7 @@ public DataStore getDataStore(File file) throws IOException { final URL url = DataUtilities.fileToURL(file); if (shpFactory.canProcess(url)) { - Map params = new HashMap(originalParams); + Map<String,Serializable> params = new HashMap<String,Serializable>(originalParams); params.put(URLP.key, url); return shpFactory.createDataStore(params); } else { Modified: trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactoryTest.java =================================================================== --- trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactoryTest.java 2012-01-27 02:39:28 UTC (rev 38525) +++ trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactoryTest.java 2012-01-27 02:40:28 UTC (rev 38526) @@ -23,16 +23,7 @@ import org.geotools.util.KVP; import org.junit.Test; -import static org.geotools.data.shapefile.ng.ShapefileDataStoreFactory.CACHE_MEMORY_MAPS; -import static org.geotools.data.shapefile.ng.ShapefileDataStoreFactory.CREATE_SPATIAL_INDEX; -import static org.geotools.data.shapefile.ng.ShapefileDataStoreFactory.DBFCHARSET; -import static org.geotools.data.shapefile.ng.ShapefileDataStoreFactory.DBFTIMEZONE; -import static org.geotools.data.shapefile.ng.ShapefileDataStoreFactory.FILE_TYPE; -import static org.geotools.data.shapefile.ng.ShapefileDataStoreFactory.LOGGER; -import static org.geotools.data.shapefile.ng.ShapefileDataStoreFactory.MEMORY_MAPPED; -import static org.geotools.data.shapefile.ng.ShapefileDataStoreFactory.NAMESPACEP; -import static org.geotools.data.shapefile.ng.ShapefileDataStoreFactory.SORT; -import static org.geotools.data.shapefile.ng.ShapefileDataStoreFactory.URLP; +import static org.geotools.data.shapefile.ng.ShapefileDataStoreFactory.*; /** * Test the functionality of ShapefileDataStoreFactory; specifically the handling of @@ -57,21 +48,21 @@ } @Test - public void testSortParameter() throws Exception { + public void testFSTypeParameter() throws Exception { URL url = TestData.url(STATE_POP); KVP params = new KVP( URLP.key,url ); assertTrue( "Sorting is optional", factory.canProcess(params) ); - params.put( SORT.key, "memory" ); - assertFalse( "Memory sorting not supported", factory.canProcess(params) ); + params.put( FSTYPE.key, "shape-ng" ); + assertTrue( "Shape NG supported", factory.canProcess(params) ); - params.put(SORT.key, "disk" ); - assertTrue( "Disk sorting not supported", factory.canProcess(params) ); + params.put(FSTYPE.key, "shape" ); + assertFalse( "Plain shape not supported", factory.canProcess(params) ); - params.put(SORT.key, "none" ); - assertFalse( "Sorting is not supported", factory.canProcess(params) ); + params.put(FSTYPE.key, "index" ); + assertFalse( "Plain index not supported", factory.canProcess(params) ); } } |
Author: jive Date: 2012-01-26 18:41:33 -0800 (Thu, 26 Jan 2012) New Revision: 38529 Modified: trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/ShapefileDataStoreFactoryTest.java trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactoryTest.java Log: Test query capabilities for shapefile and shapefile-ng Modified: trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/ShapefileDataStoreFactoryTest.java =================================================================== --- trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/ShapefileDataStoreFactoryTest.java 2012-01-27 02:41:02 UTC (rev 38528) +++ trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/ShapefileDataStoreFactoryTest.java 2012-01-27 02:41:33 UTC (rev 38529) @@ -20,8 +20,17 @@ import java.net.URL; import org.geotools.TestData; +import org.geotools.data.DataStore; +import org.geotools.data.QueryCapabilities; +import org.geotools.data.simple.SimpleFeatureSource; +import org.geotools.factory.CommonFactoryFinder; import org.geotools.util.KVP; import org.junit.Test; +import org.opengis.feature.simple.SimpleFeatureType; +import org.opengis.feature.type.Name; +import org.opengis.filter.FilterFactory2; +import org.opengis.filter.sort.SortBy; +import org.opengis.filter.sort.SortOrder; import static org.geotools.data.shapefile.ShapefileDataStoreFactory.*; @@ -53,7 +62,7 @@ KVP params = new KVP( URLP.key,url ); - assertTrue( "Sorting is optional", factory.canProcess(params) ); + assertTrue( "FST is optional", factory.canProcess(params) ); params.put(FSTYPE.key, "shape" ); assertTrue( "Plain shape implementation provided", factory.canProcess(params) ); @@ -68,4 +77,27 @@ assertFalse( "Feeling blue; don't try a smruf", factory.canProcess(params) ); } + @Test + public void testQueryCapabilities() throws Exception { + URL url = TestData.url(STATE_POP); + + KVP params = new KVP( URLP.key,url ); + DataStore dataStore = factory.createDataStore( params ); + Name typeName = dataStore.getNames().get(0); + SimpleFeatureSource featureSource = dataStore.getFeatureSource( typeName); + + QueryCapabilities caps = featureSource.getQueryCapabilities(); + + SortBy[] sortBy = new SortBy[]{SortBy.NATURAL_ORDER,}; + assertTrue( "Natural", caps.supportsSorting( sortBy )); + + SimpleFeatureType schema = featureSource.getSchema(); + String attr = schema.getDescriptor(1).getLocalName(); + + sortBy[0] = ff.sort( attr, SortOrder.ASCENDING ); + assertFalse( "Cannot sort "+attr, caps.supportsSorting( sortBy )); + + sortBy[0] = ff.sort( "the_geom", SortOrder.ASCENDING ); + assertFalse( "Cannot sort the_geom", caps.supportsSorting( sortBy )); + } } Modified: trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactoryTest.java =================================================================== --- trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactoryTest.java 2012-01-27 02:41:02 UTC (rev 38528) +++ trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactoryTest.java 2012-01-27 02:41:33 UTC (rev 38529) @@ -17,11 +17,20 @@ package org.geotools.data.shapefile.ng; import java.io.IOException; +import java.io.Serializable; import java.net.URL; +import java.util.Map; import org.geotools.TestData; +import org.geotools.data.DataStore; +import org.geotools.data.QueryCapabilities; +import org.geotools.data.simple.SimpleFeatureSource; import org.geotools.util.KVP; import org.junit.Test; +import org.opengis.feature.simple.SimpleFeatureType; +import org.opengis.feature.type.Name; +import org.opengis.filter.sort.SortBy; +import org.opengis.filter.sort.SortOrder; import static org.geotools.data.shapefile.ng.ShapefileDataStoreFactory.*; @@ -67,5 +76,27 @@ params.put( FSTYPE.key, "smurf" ); assertFalse( "Feeling blue; don't try a smruf", factory.canProcess(params) ); } - + @Test + public void testQueryCapabilities() throws Exception { + URL url = TestData.url(STATE_POP); + + Map params = new KVP( URLP.key,url ); + DataStore dataStore = factory.createDataStore( params ); + Name typeName = dataStore.getNames().get(0); + SimpleFeatureSource featureSource = dataStore.getFeatureSource( typeName); + + QueryCapabilities caps = featureSource.getQueryCapabilities(); + + SortBy[] sortBy = new SortBy[]{SortBy.NATURAL_ORDER,}; + assertTrue( "Natural", caps.supportsSorting( sortBy )); + + SimpleFeatureType schema = featureSource.getSchema(); + String attr = schema.getDescriptor(1).getLocalName(); + + sortBy[0] = ff.sort( attr, SortOrder.ASCENDING ); + assertTrue( "Sort "+attr, caps.supportsSorting( sortBy )); + + sortBy[0] = ff.sort( "the_geom", SortOrder.ASCENDING ); + assertFalse( "Cannot sort the_geom", caps.supportsSorting( sortBy )); + } } |
From: <svn...@os...> - 2012-01-27 02:49:01
|
Author: jive Date: 2012-01-26 18:40:45 -0800 (Thu, 26 Jan 2012) New Revision: 38527 Modified: trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactoryTest.java Log: Check that smurfs are not allowed (example of an invalid fstype) Modified: trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactoryTest.java =================================================================== --- trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactoryTest.java 2012-01-27 02:40:28 UTC (rev 38526) +++ trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactoryTest.java 2012-01-27 02:40:45 UTC (rev 38527) @@ -23,6 +23,7 @@ import org.geotools.util.KVP; import org.junit.Test; +import static org.geotools.data.shapefile.ShapefileDataStoreFactory.FSTYPE; import static org.geotools.data.shapefile.ng.ShapefileDataStoreFactory.*; /** @@ -63,6 +64,9 @@ params.put(FSTYPE.key, "index" ); assertFalse( "Plain index not supported", factory.canProcess(params) ); + + params.put( FSTYPE.key, "smurf" ); + assertFalse( "Feeling blue; don't try a smruf", factory.canProcess(params) ); } } |
From: <svn...@os...> - 2012-01-27 02:41:08
|
Author: jive Date: 2012-01-26 18:41:02 -0800 (Thu, 26 Jan 2012) New Revision: 38528 Modified: trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactoryTest.java Log: Fix import for TestCaseSupport Modified: trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactoryTest.java =================================================================== --- trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactoryTest.java 2012-01-27 02:40:45 UTC (rev 38527) +++ trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactoryTest.java 2012-01-27 02:41:02 UTC (rev 38528) @@ -23,7 +23,6 @@ import org.geotools.util.KVP; import org.junit.Test; -import static org.geotools.data.shapefile.ShapefileDataStoreFactory.FSTYPE; import static org.geotools.data.shapefile.ng.ShapefileDataStoreFactory.*; /** |
From: <svn...@os...> - 2012-01-27 02:39:35
|
Author: jive Date: 2012-01-26 18:39:28 -0800 (Thu, 26 Jan 2012) New Revision: 38525 Added: trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/ShapefileDataStoreFactoryTest.java trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactoryTest.java Removed: trunk/modules/unsupported/shapefile-ng/src/main/resources/META-INF/services/org.geotools.catalog.ServiceFactory Modified: trunk/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileDataStoreFactory.java trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/ShapefileDataStoreTest.java trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/TestCaseSupport.java trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactory.java trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/TestCaseSupport.java Log: Initial Shapefile and Shapefile NG sort parameter with test cases Modified: trunk/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileDataStoreFactory.java =================================================================== --- trunk/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileDataStoreFactory.java 2012-01-25 07:01:42 UTC (rev 38524) +++ trunk/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/ShapefileDataStoreFactory.java 2012-01-27 02:39:28 UTC (rev 38525) @@ -22,6 +22,7 @@ import java.net.URI; import java.net.URL; import java.nio.charset.Charset; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -33,6 +34,7 @@ import org.geotools.data.DataUtilities; import org.geotools.data.FileDataStore; import org.geotools.data.FileDataStoreFactorySpi; +import org.geotools.data.DataAccessFactory.Param; import org.geotools.data.directory.DirectoryDataStore; import org.geotools.data.directory.FileStoreFactory; import org.geotools.data.shapefile.indexed.IndexType; @@ -149,8 +151,14 @@ } }; - /** + * Optional - marker parameter to allow shapefile ng support to be specified + */ + public static final Param SORT = new Param("sort", + String.class, "Sort strategy 'none' supported, 'memory' and 'disk' not supported", false, "none", + new KVP(Param.LEVEL, "advanced", Param.OPTIONS,Arrays.asList(new String[]{"none","memory","disk"}))); + + /** * Takes a map of parameters which describes how to access a DataStore and * determines if it can be read by the ShapefileDataStore or * IndexedShapefileDataStore implementations. @@ -164,6 +172,23 @@ */ public boolean canProcess(Map params) { boolean accept = false; + try { + String sort = (String) SORT.lookUp(params); + if( sort == null || "none".equals( sort )){ + // this is fine we can support that + } + else if ("memory".equals(sort)){ + return false; // not supported + } + else if ("disk".equals(sort)){ + return false; // not supported + } + else { + LOGGER.warning("Unexpected sort level request: '"+sort+"'"); + } + } catch (IOException e) { + return false; + } if (params.containsKey(URLP.key)) { try { URL url = (URL) URLP.lookUp(params); Added: trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/ShapefileDataStoreFactoryTest.java =================================================================== --- trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/ShapefileDataStoreFactoryTest.java (rev 0) +++ trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/ShapefileDataStoreFactoryTest.java 2012-01-27 02:39:28 UTC (rev 38525) @@ -0,0 +1,77 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2012, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package org.geotools.data.shapefile; + +import java.io.IOException; +import java.net.URL; + +import org.geotools.TestData; +import org.geotools.util.KVP; +import org.junit.Test; + +import static org.geotools.data.shapefile.ShapefileDataStoreFactory.CACHE_MEMORY_MAPS; +import static org.geotools.data.shapefile.ShapefileDataStoreFactory.CREATE_SPATIAL_INDEX; +import static org.geotools.data.shapefile.ShapefileDataStoreFactory.DBFCHARSET; +import static org.geotools.data.shapefile.ShapefileDataStoreFactory.DBFTIMEZONE; +import static org.geotools.data.shapefile.ShapefileDataStoreFactory.FILE_TYPE; +import static org.geotools.data.shapefile.ShapefileDataStoreFactory.LOGGER; +import static org.geotools.data.shapefile.ShapefileDataStoreFactory.MEMORY_MAPPED; +import static org.geotools.data.shapefile.ShapefileDataStoreFactory.NAMESPACEP; +import static org.geotools.data.shapefile.ShapefileDataStoreFactory.SORT; +import static org.geotools.data.shapefile.ShapefileDataStoreFactory.URLP; + +/** + * Test the functionality of ShapefileDataStoreFactory; specifically the handling of + * connection parameters. + * + * @author Jody Garnett + */ +public class ShapefileDataStoreFactoryTest extends TestCaseSupport { + + private ShapefileDataStore store = null; + private ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory(); + + public ShapefileDataStoreFactoryTest(String testName) throws IOException { + super(testName); + } + @Override + protected void tearDown() throws Exception { + if(store != null) { + store.dispose(); + } + super.tearDown(); + } + + @Test + public void testSortParameter() throws Exception { + URL url = TestData.url(STATE_POP); + + KVP params = new KVP( URLP.key,url ); + + assertTrue( "Sorting is optional", factory.canProcess(params) ); + + params.put( SORT.key, "memory" ); + assertFalse( "Memory sorting not supported", factory.canProcess(params) ); + + params.put(SORT.key, "disk" ); + assertFalse( "Disk sorting not supported", factory.canProcess(params) ); + + params.put(SORT.key, "none" ); + assertTrue( "Sorting is not supported", factory.canProcess(params) ); + } + +} Property changes on: trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/ShapefileDataStoreFactoryTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: svn:eol-style + native 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 2012-01-25 07:01:42 UTC (rev 38524) +++ trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/ShapefileDataStoreTest.java 2012-01-27 02:39:28 UTC (rev 38525) @@ -80,14 +80,7 @@ */ public class ShapefileDataStoreTest extends TestCaseSupport { - final static String STATE_POP = "shapes/statepop.shp"; - 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); - private ShapefileDataStore store; + private ShapefileDataStore store; public ShapefileDataStoreTest(String testName) throws IOException { super(testName); Modified: trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/TestCaseSupport.java =================================================================== --- trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/TestCaseSupport.java 2012-01-25 07:01:42 UTC (rev 38524) +++ trunk/modules/plugin/shapefile/src/test/java/org/geotools/data/shapefile/TestCaseSupport.java 2012-01-27 02:39:28 UTC (rev 38525) @@ -31,8 +31,10 @@ import org.geotools.TestData; import org.geotools.data.simple.SimpleFeatureCollection; import org.geotools.data.simple.SimpleFeatureIterator; +import org.geotools.factory.CommonFactoryFinder; import org.geotools.index.CloseableIterator; import org.opengis.feature.simple.SimpleFeature; +import org.opengis.filter.FilterFactory2; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.io.ParseException; @@ -54,6 +56,25 @@ * @author Martin Desruisseaux */ public class TestCaseSupport extends TestCase { + + /** References a known test file provided by sample data. */ + final static String STATE_POP = "shapes/statepop.shp"; + + /** References a known test file provided by sample data. */ + final static String STREAM = "shapes/stream.shp"; + + /** References a known test file provided by sample data. */ + final static String DANISH = "shapes/danish_point.shp"; + + /** References a known test file provided by sample data. */ + final static String CHINESE = "shapes/chinese_poly.shp"; + + /** References a known test file provided by sample data. */ + final static String RUSSIAN = "shapes/rus-windows-1251.shp"; + + /** References a known test file provided by sample data. */ + final static FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(); + /** * Set to {@code true} if {@code println} are wanted during normal * execution. It doesn't apply to message displayed in case of errors. Modified: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactory.java =================================================================== --- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactory.java 2012-01-25 07:01:42 UTC (rev 38524) +++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactory.java 2012-01-27 02:39:28 UTC (rev 38525) @@ -23,6 +23,7 @@ import java.net.URI; import java.net.URL; import java.nio.charset.Charset; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -32,6 +33,7 @@ import org.geotools.data.AbstractDataStoreFactory; import org.geotools.data.DataStore; import org.geotools.data.DataUtilities; +import org.geotools.data.DataAccessFactory.Param; import org.geotools.data.directory.DirectoryDataStore; import org.geotools.data.directory.FileStoreFactory; import org.geotools.data.shapefile.ng.files.ShpFiles; @@ -109,6 +111,13 @@ }; /** + * Optional - marker parameter to allow shapefile ng support to be specified + */ + public static final Param SORT = new Param("sort", + String.class, "Sort strategy 'disk' supported, 'memory' and 'none' not supported", false, "none", + new KVP(Param.LEVEL, "advanced", Param.OPTIONS,Arrays.asList(new String[]{"none","memory","disk"}))); + + /** * Optional - timezone to decode dates from the DBF file */ public static final Param DBFTIMEZONE = new Param("timezone", TimeZone.class, @@ -210,8 +219,21 @@ if (!super.canProcess(params)) { return false; } - try { + String sort = (String) SORT.lookUp(params); + if( sort == null || "disk".equals( sort )){ + // this is fine we can support that + } + else if ("memory".equals(sort) || "none".equals(sort)){ + return false; // not supported + } + else { + LOGGER.warning("Unexpected sort level request: '"+sort+"'"); + } + } catch (IOException e) { + return false; + } + try { URL url = (URL) URLP.lookUp(params); if (canProcess(url)) { return true; Deleted: trunk/modules/unsupported/shapefile-ng/src/main/resources/META-INF/services/org.geotools.catalog.ServiceFactory =================================================================== --- trunk/modules/unsupported/shapefile-ng/src/main/resources/META-INF/services/org.geotools.catalog.ServiceFactory 2012-01-25 07:01:42 UTC (rev 38524) +++ trunk/modules/unsupported/shapefile-ng/src/main/resources/META-INF/services/org.geotools.catalog.ServiceFactory 2012-01-27 02:39:28 UTC (rev 38525) @@ -1 +0,0 @@ -org.geotools.catalog.shapefile.ng.ShapefileServiceFactory Added: trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactoryTest.java =================================================================== --- trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactoryTest.java (rev 0) +++ trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactoryTest.java 2012-01-27 02:39:28 UTC (rev 38525) @@ -0,0 +1,77 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2012, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package org.geotools.data.shapefile.ng; + +import java.io.IOException; +import java.net.URL; + +import org.geotools.TestData; +import org.geotools.util.KVP; +import org.junit.Test; + +import static org.geotools.data.shapefile.ng.ShapefileDataStoreFactory.CACHE_MEMORY_MAPS; +import static org.geotools.data.shapefile.ng.ShapefileDataStoreFactory.CREATE_SPATIAL_INDEX; +import static org.geotools.data.shapefile.ng.ShapefileDataStoreFactory.DBFCHARSET; +import static org.geotools.data.shapefile.ng.ShapefileDataStoreFactory.DBFTIMEZONE; +import static org.geotools.data.shapefile.ng.ShapefileDataStoreFactory.FILE_TYPE; +import static org.geotools.data.shapefile.ng.ShapefileDataStoreFactory.LOGGER; +import static org.geotools.data.shapefile.ng.ShapefileDataStoreFactory.MEMORY_MAPPED; +import static org.geotools.data.shapefile.ng.ShapefileDataStoreFactory.NAMESPACEP; +import static org.geotools.data.shapefile.ng.ShapefileDataStoreFactory.SORT; +import static org.geotools.data.shapefile.ng.ShapefileDataStoreFactory.URLP; + +/** + * Test the functionality of ShapefileDataStoreFactory; specifically the handling of + * connection parameters. + * + * @author Jody Garnett + */ +public class ShapefileDataStoreFactoryTest extends TestCaseSupport { + + private ShapefileDataStore store = null; + private ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory(); + + public ShapefileDataStoreFactoryTest(String testName) throws IOException { + super(testName); + } + @Override + protected void tearDown() throws Exception { + if(store != null) { + store.dispose(); + } + super.tearDown(); + } + + @Test + public void testSortParameter() throws Exception { + URL url = TestData.url(STATE_POP); + + KVP params = new KVP( URLP.key,url ); + + assertTrue( "Sorting is optional", factory.canProcess(params) ); + + params.put( SORT.key, "memory" ); + assertFalse( "Memory sorting not supported", factory.canProcess(params) ); + + params.put(SORT.key, "disk" ); + assertTrue( "Disk sorting not supported", factory.canProcess(params) ); + + params.put(SORT.key, "none" ); + assertFalse( "Sorting is not supported", factory.canProcess(params) ); + } + +} Property changes on: trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactoryTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: svn:eol-style + native Modified: trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/TestCaseSupport.java =================================================================== --- trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/TestCaseSupport.java 2012-01-25 07:01:42 UTC (rev 38524) +++ trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/TestCaseSupport.java 2012-01-27 02:39:28 UTC (rev 38525) @@ -32,7 +32,9 @@ import org.geotools.data.shapefile.ng.index.CloseableIterator; import org.geotools.data.simple.SimpleFeatureCollection; import org.geotools.data.simple.SimpleFeatureIterator; +import org.geotools.factory.CommonFactoryFinder; import org.opengis.feature.simple.SimpleFeature; +import org.opengis.filter.FilterFactory2; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.io.ParseException; @@ -54,6 +56,26 @@ * @author Martin Desruisseaux */ public class TestCaseSupport extends TestCase { + + + /** References a known test file provided by sample data. */ + final static String STATE_POP = "shapes/statepop.shp"; + + /** References a known test file provided by sample data. */ + final static String STREAM = "shapes/stream.shp"; + + /** References a known test file provided by sample data. */ + final static String DANISH = "shapes/danish_point.shp"; + + /** References a known test file provided by sample data. */ + final static String CHINESE = "shapes/chinese_poly.shp"; + + /** References a known test file provided by sample data. */ + final static String RUSSIAN = "shapes/rus-windows-1251.shp"; + + /** References a known test file provided by sample data. */ + final static FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(); + /** * Set to {@code true} if {@code println} are wanted during normal * execution. It doesn't apply to message displayed in case of errors. |