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-03-03 14:24:23
|
Author: aaime
Date: 2012-03-03 06:24:17 -0800 (Sat, 03 Mar 2012)
New Revision: 38598
Modified:
branches/2.7.x/modules/library/referencing/src/main/java/org/geotools/referencing/operation/transform/SimilarityTransformProvider.java
Log:
Fix java 5 incompatibility
Modified: branches/2.7.x/modules/library/referencing/src/main/java/org/geotools/referencing/operation/transform/SimilarityTransformProvider.java
===================================================================
--- branches/2.7.x/modules/library/referencing/src/main/java/org/geotools/referencing/operation/transform/SimilarityTransformProvider.java 2012-03-03 14:14:45 UTC (rev 38597)
+++ branches/2.7.x/modules/library/referencing/src/main/java/org/geotools/referencing/operation/transform/SimilarityTransformProvider.java 2012-03-03 14:24:17 UTC (rev 38598)
@@ -73,7 +73,7 @@
new NamedIdentifier(Citations.EPSG, "Scale difference"),
new NamedIdentifier(Citations.EPSG, "8611")
},
- 1, Double.MIN_NORMAL, Double.POSITIVE_INFINITY, Dimensionless.UNIT);
+ 1, /* Double.MIN_NORMAL, but not available in jdk 1.5 */ 0x1.0p-1022 , Double.POSITIVE_INFINITY, Dimensionless.UNIT);
/**
* "Rotation angle of source coordinate reference system axes" EPSG::8614
|
|
From: <svn...@os...> - 2012-03-03 14:14:51
|
Author: aaime
Date: 2012-03-03 06:14:45 -0800 (Sat, 03 Mar 2012)
New Revision: 38597
Modified:
trunk/modules/library/referencing/src/main/java/org/geotools/referencing/factory/epsg/DirectEpsgFactory.java
Log:
Fixing build by working around a H2 bug, reworking some atrocious code handling resultset closing in the process
Modified: trunk/modules/library/referencing/src/main/java/org/geotools/referencing/factory/epsg/DirectEpsgFactory.java
===================================================================
--- trunk/modules/library/referencing/src/main/java/org/geotools/referencing/factory/epsg/DirectEpsgFactory.java 2012-03-03 11:04:54 UTC (rev 38596)
+++ trunk/modules/library/referencing/src/main/java/org/geotools/referencing/factory/epsg/DirectEpsgFactory.java 2012-03-03 14:14:45 UTC (rev 38597)
@@ -2492,6 +2492,7 @@
{
ensureNonNull("code", code);
CoordinateOperation returnValue = null;
+ ResultSet result = null;
try {
final String primaryKey = toPrimaryKey(CoordinateOperation.class, code,
"[Coordinate_Operation]", "COORD_OP_CODE", "COORD_OP_NAME");
@@ -2510,8 +2511,8 @@
+ " FROM [Coordinate_Operation]"
+ " WHERE COORD_OP_CODE = ?");
stmt.setInt(1, Integer.parseInt(primaryKey));
- ResultSet result = stmt.executeQuery();
- while (result.next()) {
+ result = stmt.executeQuery();
+ while (hasNext(result)) {
final String epsg = getString(result, 1, code);
final String name = getString(result, 2, code);
final String type = getString(result, 3, code).trim().toLowerCase();
@@ -2580,7 +2581,6 @@
try {
num = Integer.parseInt(methodCode);
} catch (NumberFormatException exception) {
- result.close();
throw new FactoryException(exception);
}
isBursaWolf = (num>=BURSA_WOLF_MIN_CODE && num<=BURSA_WOLF_MAX_CODE);
@@ -2655,7 +2655,6 @@
* to avoid loading the quite large Geotools's implementation of this factory,
* and also because it is not part of FactoryGroup anyway.
*/
- result.close();
result = null;
final PreparedStatement cstmt = prepareStatement("ConcatenatedOperation",
"SELECT SINGLE_OPERATION_CODE"
@@ -2709,7 +2708,6 @@
parameters.parameter("tgt_dim").setValue(targetCRS.getCoordinateSystem().getDimension());
}
} catch (ParameterNotFoundException exception) {
- result.close();
throw new FactoryException(Errors.format(
ErrorKeys.GEOTOOLS_EXTENSION_REQUIRED_$1,
method.getName().getCode(), exception));
@@ -2724,7 +2722,6 @@
} else if (isConversion) {
expected = Conversion.class;
} else {
- result.close();
throw new FactoryException(Errors.format(ErrorKeys.UNKNOW_TYPE_$1, type));
}
final MathTransform mt = factories.getMathTransformFactory().createBaseToDerived(
@@ -2734,15 +2731,17 @@
mt, method, expected);
}
returnValue = ensureSingleton(operation, returnValue, code);
- if (result == null) {
- // Bypass the 'result.close()' line below:
- // the ResultSet has already been closed.
- return returnValue;
- }
}
- result.close();
} catch (SQLException exception) {
throw databaseFailure(CoordinateOperation.class, code, exception);
+ } finally {
+ if(result != null) {
+ try {
+ result.close();
+ } catch(Exception e) {
+ // fine, we tried
+ }
+ }
}
if (returnValue == null) {
throw noSuchAuthorityCode(CoordinateOperation.class, code);
@@ -2750,6 +2749,22 @@
return returnValue;
}
+ private boolean hasNext(ResultSet result) throws SQLException {
+ // this stuff works around a cross issue between h2 and hsql
+ // hsql does not have the isClosed method, h2 apparently caches
+ // and returns the ResultSet of a previous call even if the
+ // result was closed (crazy)
+ try {
+ return result.next();
+ } catch(SQLException e) {
+ if(result.isClosed()) {
+ return false;
+ } else {
+ throw e;
+ }
+ }
+ }
+
/**
* Creates operations from coordinate reference system codes.
* The returned set is ordered with the most accurate operations first.
|
|
From: <svn...@os...> - 2012-03-03 11:05:01
|
Author: aaime
Date: 2012-03-03 03:04:54 -0800 (Sat, 03 Mar 2012)
New Revision: 38596
Removed:
trunk/modules/plugin/jdbc/jdbc-oracle/src/test/resources/org/geotools/data/oracle/db.properties
trunk/modules/plugin/jdbc/jdbc-oracle/src/test/resources/org/geotools/data/oracle/factory.properties
Modified:
trunk/modules/plugin/jdbc/jdbc-oracle/src/test/java/org/geotools/data/oracle/OracleNGDataStoreFactoryTest.java
Log:
[GEOT-4047] OracleNGDataStoreFactoryTest fails because it does not use common fixture, patch by Ben Caradoc Davies
Modified: trunk/modules/plugin/jdbc/jdbc-oracle/src/test/java/org/geotools/data/oracle/OracleNGDataStoreFactoryTest.java
===================================================================
--- trunk/modules/plugin/jdbc/jdbc-oracle/src/test/java/org/geotools/data/oracle/OracleNGDataStoreFactoryTest.java 2012-03-03 11:04:01 UTC (rev 38595)
+++ trunk/modules/plugin/jdbc/jdbc-oracle/src/test/java/org/geotools/data/oracle/OracleNGDataStoreFactoryTest.java 2012-03-03 11:04:54 UTC (rev 38596)
@@ -31,6 +31,7 @@
import org.geotools.jdbc.JDBCDataStore;
import org.geotools.jdbc.JDBCTestSetup;
import org.geotools.jdbc.JDBCTestSupport;
+import org.geotools.test.FixtureUtilities;
/**
*
@@ -55,14 +56,13 @@
}
private void checkCreateConnection(OracleNGDataStoreFactory factory, String dbtype) throws IOException {
- Properties db = new Properties();
- db.load(getClass().getResourceAsStream("factory.properties"));
+ Properties db = FixtureUtilities.loadFixture("oracle");
Map<String, Object> params = new HashMap<String, Object>();
params.put(HOST.key, db.getProperty(HOST.key));
params.put(DATABASE.key, db.getProperty(DATABASE.key));
params.put(PORT.key, db.getProperty(PORT.key));
params.put(USER.key, db.getProperty(USER.key));
- params.put(PASSWD.key, db.getProperty(PASSWD.key));
+ params.put(PASSWD.key, db.getProperty("password"));
params.put(DBTYPE.key, dbtype);
Deleted: trunk/modules/plugin/jdbc/jdbc-oracle/src/test/resources/org/geotools/data/oracle/db.properties
===================================================================
--- trunk/modules/plugin/jdbc/jdbc-oracle/src/test/resources/org/geotools/data/oracle/db.properties 2012-03-03 11:04:01 UTC (rev 38595)
+++ trunk/modules/plugin/jdbc/jdbc-oracle/src/test/resources/org/geotools/data/oracle/db.properties 2012-03-03 11:04:54 UTC (rev 38596)
@@ -1,4 +0,0 @@
-driver=oracle.jdbc.driver.OracleDriver
-url=jdbc:oracle:thin:@localhost:1521:xe
-username=geoserver
-password=postgis
Deleted: trunk/modules/plugin/jdbc/jdbc-oracle/src/test/resources/org/geotools/data/oracle/factory.properties
===================================================================
--- trunk/modules/plugin/jdbc/jdbc-oracle/src/test/resources/org/geotools/data/oracle/factory.properties 2012-03-03 11:04:01 UTC (rev 38595)
+++ trunk/modules/plugin/jdbc/jdbc-oracle/src/test/resources/org/geotools/data/oracle/factory.properties 2012-03-03 11:04:54 UTC (rev 38596)
@@ -1,7 +0,0 @@
-driver=oracle.jdbc.driver.OracleDriver
-host=localhost
-port=1521
-database=xe
-user=geoserver
-passwd=postgis
-dbtype=Oracle
|
|
From: <svn...@os...> - 2012-03-03 11:04:08
|
Author: aaime
Date: 2012-03-03 03:04:01 -0800 (Sat, 03 Mar 2012)
New Revision: 38595
Removed:
branches/2.7.x/modules/plugin/jdbc/jdbc-oracle/src/test/resources/org/geotools/data/oracle/db.properties
branches/2.7.x/modules/plugin/jdbc/jdbc-oracle/src/test/resources/org/geotools/data/oracle/factory.properties
Modified:
branches/2.7.x/modules/plugin/jdbc/jdbc-oracle/src/test/java/org/geotools/data/oracle/OracleNGDataStoreFactoryTest.java
Log:
[GEOT-4047] OracleNGDataStoreFactoryTest fails because it does not use common fixture, patch by Ben Caradoc Davies
Modified: branches/2.7.x/modules/plugin/jdbc/jdbc-oracle/src/test/java/org/geotools/data/oracle/OracleNGDataStoreFactoryTest.java
===================================================================
--- branches/2.7.x/modules/plugin/jdbc/jdbc-oracle/src/test/java/org/geotools/data/oracle/OracleNGDataStoreFactoryTest.java 2012-03-03 10:30:40 UTC (rev 38594)
+++ branches/2.7.x/modules/plugin/jdbc/jdbc-oracle/src/test/java/org/geotools/data/oracle/OracleNGDataStoreFactoryTest.java 2012-03-03 11:04:01 UTC (rev 38595)
@@ -31,6 +31,7 @@
import org.geotools.jdbc.JDBCDataStore;
import org.geotools.jdbc.JDBCTestSetup;
import org.geotools.jdbc.JDBCTestSupport;
+import org.geotools.test.FixtureUtilities;
public class OracleNGDataStoreFactoryTest extends JDBCTestSupport {
@@ -50,14 +51,13 @@
}
private void checkCreateConnection(OracleNGDataStoreFactory factory, String dbtype) throws IOException {
- Properties db = new Properties();
- db.load(getClass().getResourceAsStream("factory.properties"));
+ Properties db = FixtureUtilities.loadFixture("oracle");
Map<String, Object> params = new HashMap<String, Object>();
params.put(HOST.key, db.getProperty(HOST.key));
params.put(DATABASE.key, db.getProperty(DATABASE.key));
params.put(PORT.key, db.getProperty(PORT.key));
params.put(USER.key, db.getProperty(USER.key));
- params.put(PASSWD.key, db.getProperty(PASSWD.key));
+ params.put(PASSWD.key, db.getProperty("password"));
params.put(DBTYPE.key, dbtype);
Deleted: branches/2.7.x/modules/plugin/jdbc/jdbc-oracle/src/test/resources/org/geotools/data/oracle/db.properties
===================================================================
--- branches/2.7.x/modules/plugin/jdbc/jdbc-oracle/src/test/resources/org/geotools/data/oracle/db.properties 2012-03-03 10:30:40 UTC (rev 38594)
+++ branches/2.7.x/modules/plugin/jdbc/jdbc-oracle/src/test/resources/org/geotools/data/oracle/db.properties 2012-03-03 11:04:01 UTC (rev 38595)
@@ -1,4 +0,0 @@
-driver=oracle.jdbc.driver.OracleDriver
-url=jdbc:oracle:thin:@localhost:1521:xe
-username=geoserver
-password=postgis
Deleted: branches/2.7.x/modules/plugin/jdbc/jdbc-oracle/src/test/resources/org/geotools/data/oracle/factory.properties
===================================================================
--- branches/2.7.x/modules/plugin/jdbc/jdbc-oracle/src/test/resources/org/geotools/data/oracle/factory.properties 2012-03-03 10:30:40 UTC (rev 38594)
+++ branches/2.7.x/modules/plugin/jdbc/jdbc-oracle/src/test/resources/org/geotools/data/oracle/factory.properties 2012-03-03 11:04:01 UTC (rev 38595)
@@ -1,7 +0,0 @@
-driver=oracle.jdbc.driver.OracleDriver
-host=localhost
-port=1521
-database=xe
-user=geoserver
-passwd=postgis
-dbtype=Oracle
|
Author: aaime Date: 2012-03-03 02:30:40 -0800 (Sat, 03 Mar 2012) New Revision: 38594 Added: branches/2.7.x/modules/library/referencing/src/main/java/org/geotools/referencing/operation/transform/SimilarityTransformProvider.java branches/2.7.x/modules/library/referencing/src/test/java/org/geotools/referencing/operation/transform/SimilarityTransformProviderTest.java Modified: branches/2.7.x/modules/library/referencing/src/main/resources/META-INF/services/org.geotools.referencing.operation.MathTransformProvider branches/2.7.x/modules/plugin/epsg-hsql/src/test/java/org/geotools/referencing/CRSTest.java branches/2.7.x/modules/plugin/epsg-hsql/src/test/java/org/geotools/referencing/factory/epsg/PropertyDumper.java Log: [GEOT-4050] Similarity Transformation, EPSG:9621, patch by Oscar Fonts Added: branches/2.7.x/modules/library/referencing/src/main/java/org/geotools/referencing/operation/transform/SimilarityTransformProvider.java =================================================================== --- branches/2.7.x/modules/library/referencing/src/main/java/org/geotools/referencing/operation/transform/SimilarityTransformProvider.java (rev 0) +++ branches/2.7.x/modules/library/referencing/src/main/java/org/geotools/referencing/operation/transform/SimilarityTransformProvider.java 2012-03-03 10:30:40 UTC (rev 38594) @@ -0,0 +1,151 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2002-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.referencing.operation.transform; + +import javax.measure.quantity.Dimensionless; +import javax.measure.unit.NonSI; +import javax.measure.unit.SI; + +import org.geotools.metadata.iso.citation.Citations; +import org.geotools.referencing.NamedIdentifier; +import org.geotools.referencing.operation.MathTransformProvider; +import org.geotools.referencing.operation.transform.AffineTransform2D; +import org.opengis.parameter.ParameterDescriptor; +import org.opengis.parameter.ParameterDescriptorGroup; +import org.opengis.parameter.ParameterNotFoundException; +import org.opengis.parameter.ParameterValueGroup; +import org.opengis.referencing.operation.MathTransform; + +/** + * The provider for the "<cite>Similarity transformation</cite>" (EPSG 9621). + * <p> + * Note that similarity transform is a special case of an Affine transform 2D. + * + * @source $URL$ + * @version $Id$ + * @author Oscar Fonts + */ +public class SimilarityTransformProvider extends MathTransformProvider { + + private static final long serialVersionUID = -7413519919588731455L; + + // TODO: TRANSLATION_1 and TRANSLATION_2 should be expressed in "target CRS units", not necessarily SI.METER. + + /** + * "Ordinate 1 of evaluation point in target CRS" EPSG::8621 + */ + public static final ParameterDescriptor<Double> TRANSLATION_1 = createDescriptor( + new NamedIdentifier[] { + new NamedIdentifier(Citations.EPSG, "Ordinate 1 of evaluation point in target CRS"), + new NamedIdentifier(Citations.EPSG, "8621") + }, + 0, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METER); + + /** + * "Ordinate 2 of evaluation point in target CRS" EPSG::8622 + */ + public static final ParameterDescriptor<Double> TRANSLATION_2 = createDescriptor( + new NamedIdentifier[] { + new NamedIdentifier(Citations.EPSG, "Ordinate 2 of evaluation point in target CRS"), + new NamedIdentifier(Citations.EPSG, "8622") + }, + 0, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METER); + + /** + * "Scale difference" EPSG::8611 + */ + public static final ParameterDescriptor<Double> SCALE = createDescriptor( + new NamedIdentifier[] { + new NamedIdentifier(Citations.EPSG, "Scale difference"), + new NamedIdentifier(Citations.EPSG, "8611") + }, + 1, Double.MIN_NORMAL, Double.POSITIVE_INFINITY, Dimensionless.UNIT); + + /** + * "Rotation angle of source coordinate reference system axes" EPSG::8614 + */ + public static final ParameterDescriptor<Double> ROTATION = createDescriptor( + new NamedIdentifier[] { + new NamedIdentifier(Citations.EPSG, "Rotation angle of source coordinate reference system axes"), + new NamedIdentifier(Citations.EPSG, "8614") + }, + 0, 0, 360 * 60 * 60, NonSI.SECOND_ANGLE); + + /** + * The parameter group for "Similarity transformation" EPSG::9621. + * + * Includes {@link #TRANSLATION_1}, {@link #TRANSLATION_2}, {@link #SCALE}, {@link #ROTATION}. + */ + static final ParameterDescriptorGroup PARAMETERS = createDescriptorGroup( + new NamedIdentifier[] { + new NamedIdentifier(Citations.EPSG, "Similarity transformation"), + new NamedIdentifier(Citations.EPSG, "9621") + }, + new ParameterDescriptor[] { + TRANSLATION_1, + TRANSLATION_2, + SCALE, + ROTATION + } + ); + + /** + * Creates a two-dimensional similarity transform. + * + * EPSG defines explicitly this transform as 2D. + */ + public SimilarityTransformProvider() { + super(2, 2, PARAMETERS); + } + + /** + * Constructs an {@link AffineTransform2D} math transform from the specified group of parameter values. + * + * The similarity transform is a particular case of Affine Transform 2D where: + * + * <blockquote><pre> + * m00 = SCALE * cos(ROTATION) + * m01 = SCALE * sin(ROTATION) + * m02 = TRANSLATION_1 + * m10 = -m01 + * m11 = m00 + * m12 = TRANSLATION_2 + * </pre></blockquote> + * + * @param values The group of parameter values {@link #PARAMETERS}. + * @return an {@link AffineTransform2D}. + * @throws ParameterNotFoundException if a required parameter was not found. + */ + protected MathTransform createMathTransform(ParameterValueGroup values) + throws ParameterNotFoundException { + + // The four parameters + double t1 = doubleValue(TRANSLATION_1, values); + double t2 = doubleValue(TRANSLATION_2, values); + double scale = doubleValue(SCALE, values); + double rotation = doubleValue(ROTATION, values); + + // Calculate affine transform coefficients + double theta = Math.PI * rotation / 648000; // arcsec to rad + double p1 = scale * Math.cos(theta); + double p2 = scale * Math.sin(theta); + + return new AffineTransform2D(p1, -p2, p2, p1, t1, t2); + } + +} + Modified: branches/2.7.x/modules/library/referencing/src/main/resources/META-INF/services/org.geotools.referencing.operation.MathTransformProvider =================================================================== --- branches/2.7.x/modules/library/referencing/src/main/resources/META-INF/services/org.geotools.referencing.operation.MathTransformProvider 2012-03-03 10:21:13 UTC (rev 38593) +++ branches/2.7.x/modules/library/referencing/src/main/resources/META-INF/services/org.geotools.referencing.operation.MathTransformProvider 2012-03-03 10:30:40 UTC (rev 38594) @@ -10,6 +10,7 @@ org.geotools.referencing.operation.transform.MolodenskiTransform$Provider org.geotools.referencing.operation.transform.MolodenskiTransform$ProviderAbridged org.geotools.referencing.operation.transform.NADCONTransform$Provider +org.geotools.referencing.operation.transform.SimilarityTransformProvider org.geotools.referencing.operation.transform.WarpTransform2D$Provider org.geotools.referencing.operation.projection.EquidistantCylindrical$Provider org.geotools.referencing.operation.projection.EquidistantCylindrical$SphericalProvider Added: branches/2.7.x/modules/library/referencing/src/test/java/org/geotools/referencing/operation/transform/SimilarityTransformProviderTest.java =================================================================== --- branches/2.7.x/modules/library/referencing/src/test/java/org/geotools/referencing/operation/transform/SimilarityTransformProviderTest.java (rev 0) +++ branches/2.7.x/modules/library/referencing/src/test/java/org/geotools/referencing/operation/transform/SimilarityTransformProviderTest.java 2012-03-03 10:30:40 UTC (rev 38594) @@ -0,0 +1,55 @@ +package org.geotools.referencing.operation.transform; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import org.geotools.parameter.ParameterGroup; +import org.geotools.referencing.operation.DefaultMathTransformFactory; +import org.opengis.referencing.FactoryException; +import org.opengis.referencing.operation.MathTransform; +import org.opengis.referencing.operation.TransformException; + +/** + * Tests {@link SimilarityTransformProvider}. + * + * @source $URL$ + * @version $Id$ + * @author Oscar Fonts + */ +public final class SimilarityTransformProviderTest { + + /** + * Tests {@link SimilarityTransformProvider}, both direct and inverse transfoms. + */ + @Test + public void testSimilarityTransform() throws FactoryException, TransformException { + + // Parameters from EPSG::5166 transform + ParameterGroup params = new ParameterGroup(SimilarityTransformProvider.PARAMETERS); + params.parameter("8621").setValue(-129.549); + params.parameter("8622").setValue(-208.185); + params.parameter("8611").setValue(1.0000015504); + params.parameter("8614").setValue(1.56504); + + // Transform instance + MathTransform mt = new DefaultMathTransformFactory().createParameterizedTransform(params); + + // Data from EPSG::9621 example + final double precision = 1E-3; // dstPoints have 3 decimal units + final double[] srcPoints = new double[] {300000, 4500000}; + final double[] dstPoints = new double[] {299905.060, 4499796.515}; + final double[] calculatedPoints = new double[srcPoints.length]; + + // Direct transform test + mt.transform(srcPoints, 0, calculatedPoints, 0, srcPoints.length/2); + for (int i=0; i<calculatedPoints.length; i++) { + assertEquals(dstPoints[i], calculatedPoints[i], precision); + } + + // Inverse transform test + mt.inverse().transform(dstPoints, 0, calculatedPoints, 0, dstPoints.length/2); + for (int i=0; i<calculatedPoints.length; i++) { + assertEquals(srcPoints[i], calculatedPoints[i], precision); + } + } + +} Modified: branches/2.7.x/modules/plugin/epsg-hsql/src/test/java/org/geotools/referencing/CRSTest.java =================================================================== --- branches/2.7.x/modules/plugin/epsg-hsql/src/test/java/org/geotools/referencing/CRSTest.java 2012-03-03 10:21:13 UTC (rev 38593) +++ branches/2.7.x/modules/plugin/epsg-hsql/src/test/java/org/geotools/referencing/CRSTest.java 2012-03-03 10:30:40 UTC (rev 38594) @@ -412,6 +412,30 @@ } finally { Hints.removeSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER); } - } + + /** + * Tests similarity transform on the example provided in the EPSG projection guide, page 99 + * @throws Exception + */ + public void testSimilarityTransform() throws Exception { + // Tombak LNG Plant + CoordinateReferenceSystem tombak = CRS.decode("EPSG:5817", true); + // Nakhl-e Ghanem / UTM zone 39N + CoordinateReferenceSystem ng39 = CRS.decode("EPSG:3307", true); + + // forward + double[] src = new double[] {20000, 10000}; + double[] dst = new double[2]; + MathTransform mt = CRS.findMathTransform(tombak, ng39); + mt.transform(src, 0, dst, 0, 1); + + assertEquals(618336.748, dst[0], 0.001); + assertEquals(3067774.210, dst[1], 0.001); + + // and back + mt.inverse().transform(dst, 0, src, 0, 1); + assertEquals(20000, src[0], 0.001); + assertEquals(10000, src[1], 0.001); + } } Modified: branches/2.7.x/modules/plugin/epsg-hsql/src/test/java/org/geotools/referencing/factory/epsg/PropertyDumper.java =================================================================== --- branches/2.7.x/modules/plugin/epsg-hsql/src/test/java/org/geotools/referencing/factory/epsg/PropertyDumper.java 2012-03-03 10:21:13 UTC (rev 38593) +++ branches/2.7.x/modules/plugin/epsg-hsql/src/test/java/org/geotools/referencing/factory/epsg/PropertyDumper.java 2012-03-03 10:30:40 UTC (rev 38594) @@ -49,6 +49,7 @@ Properties props = new Properties(); List<String> codes = new ArrayList(CRS.getSupportedCodes("EPSG")); Collections.sort(codes, new Comparator<String>() { + public int compare(String c1, String c2) { try { Long n1 = new Long(c1); |
Author: aaime Date: 2012-03-03 02:21:13 -0800 (Sat, 03 Mar 2012) New Revision: 38593 Added: trunk/modules/library/referencing/src/main/java/org/geotools/referencing/operation/transform/SimilarityTransformProvider.java trunk/modules/library/referencing/src/test/java/org/geotools/referencing/operation/transform/SimilarityTransformProviderTest.java Modified: trunk/modules/library/referencing/src/main/resources/META-INF/services/org.geotools.referencing.operation.MathTransformProvider trunk/modules/plugin/epsg-hsql/src/test/java/org/geotools/referencing/CRSTest.java trunk/modules/plugin/epsg-hsql/src/test/java/org/geotools/referencing/factory/epsg/PropertyDumper.java Log: [GEOT-4050] Similarity Transformation, EPSG:9621, patch by Oscar Fonts Added: trunk/modules/library/referencing/src/main/java/org/geotools/referencing/operation/transform/SimilarityTransformProvider.java =================================================================== --- trunk/modules/library/referencing/src/main/java/org/geotools/referencing/operation/transform/SimilarityTransformProvider.java (rev 0) +++ trunk/modules/library/referencing/src/main/java/org/geotools/referencing/operation/transform/SimilarityTransformProvider.java 2012-03-03 10:21:13 UTC (rev 38593) @@ -0,0 +1,151 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2002-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.referencing.operation.transform; + +import javax.measure.quantity.Dimensionless; +import javax.measure.unit.NonSI; +import javax.measure.unit.SI; + +import org.geotools.metadata.iso.citation.Citations; +import org.geotools.referencing.NamedIdentifier; +import org.geotools.referencing.operation.MathTransformProvider; +import org.geotools.referencing.operation.transform.AffineTransform2D; +import org.opengis.parameter.ParameterDescriptor; +import org.opengis.parameter.ParameterDescriptorGroup; +import org.opengis.parameter.ParameterNotFoundException; +import org.opengis.parameter.ParameterValueGroup; +import org.opengis.referencing.operation.MathTransform; + +/** + * The provider for the "<cite>Similarity transformation</cite>" (EPSG 9621). + * <p> + * Note that similarity transform is a special case of an Affine transform 2D. + * + * @source $URL$ + * @version $Id$ + * @author Oscar Fonts + */ +public class SimilarityTransformProvider extends MathTransformProvider { + + private static final long serialVersionUID = -7413519919588731455L; + + // TODO: TRANSLATION_1 and TRANSLATION_2 should be expressed in "target CRS units", not necessarily SI.METER. + + /** + * "Ordinate 1 of evaluation point in target CRS" EPSG::8621 + */ + public static final ParameterDescriptor<Double> TRANSLATION_1 = createDescriptor( + new NamedIdentifier[] { + new NamedIdentifier(Citations.EPSG, "Ordinate 1 of evaluation point in target CRS"), + new NamedIdentifier(Citations.EPSG, "8621") + }, + 0, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METER); + + /** + * "Ordinate 2 of evaluation point in target CRS" EPSG::8622 + */ + public static final ParameterDescriptor<Double> TRANSLATION_2 = createDescriptor( + new NamedIdentifier[] { + new NamedIdentifier(Citations.EPSG, "Ordinate 2 of evaluation point in target CRS"), + new NamedIdentifier(Citations.EPSG, "8622") + }, + 0, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METER); + + /** + * "Scale difference" EPSG::8611 + */ + public static final ParameterDescriptor<Double> SCALE = createDescriptor( + new NamedIdentifier[] { + new NamedIdentifier(Citations.EPSG, "Scale difference"), + new NamedIdentifier(Citations.EPSG, "8611") + }, + 1, Double.MIN_NORMAL, Double.POSITIVE_INFINITY, Dimensionless.UNIT); + + /** + * "Rotation angle of source coordinate reference system axes" EPSG::8614 + */ + public static final ParameterDescriptor<Double> ROTATION = createDescriptor( + new NamedIdentifier[] { + new NamedIdentifier(Citations.EPSG, "Rotation angle of source coordinate reference system axes"), + new NamedIdentifier(Citations.EPSG, "8614") + }, + 0, 0, 360 * 60 * 60, NonSI.SECOND_ANGLE); + + /** + * The parameter group for "Similarity transformation" EPSG::9621. + * + * Includes {@link #TRANSLATION_1}, {@link #TRANSLATION_2}, {@link #SCALE}, {@link #ROTATION}. + */ + static final ParameterDescriptorGroup PARAMETERS = createDescriptorGroup( + new NamedIdentifier[] { + new NamedIdentifier(Citations.EPSG, "Similarity transformation"), + new NamedIdentifier(Citations.EPSG, "9621") + }, + new ParameterDescriptor[] { + TRANSLATION_1, + TRANSLATION_2, + SCALE, + ROTATION + } + ); + + /** + * Creates a two-dimensional similarity transform. + * + * EPSG defines explicitly this transform as 2D. + */ + public SimilarityTransformProvider() { + super(2, 2, PARAMETERS); + } + + /** + * Constructs an {@link AffineTransform2D} math transform from the specified group of parameter values. + * + * The similarity transform is a particular case of Affine Transform 2D where: + * + * <blockquote><pre> + * m00 = SCALE * cos(ROTATION) + * m01 = SCALE * sin(ROTATION) + * m02 = TRANSLATION_1 + * m10 = -m01 + * m11 = m00 + * m12 = TRANSLATION_2 + * </pre></blockquote> + * + * @param values The group of parameter values {@link #PARAMETERS}. + * @return an {@link AffineTransform2D}. + * @throws ParameterNotFoundException if a required parameter was not found. + */ + protected MathTransform createMathTransform(ParameterValueGroup values) + throws ParameterNotFoundException { + + // The four parameters + double t1 = doubleValue(TRANSLATION_1, values); + double t2 = doubleValue(TRANSLATION_2, values); + double scale = doubleValue(SCALE, values); + double rotation = doubleValue(ROTATION, values); + + // Calculate affine transform coefficients + double theta = Math.PI * rotation / 648000; // arcsec to rad + double p1 = scale * Math.cos(theta); + double p2 = scale * Math.sin(theta); + + return new AffineTransform2D(p1, -p2, p2, p1, t1, t2); + } + +} + Modified: trunk/modules/library/referencing/src/main/resources/META-INF/services/org.geotools.referencing.operation.MathTransformProvider =================================================================== --- trunk/modules/library/referencing/src/main/resources/META-INF/services/org.geotools.referencing.operation.MathTransformProvider 2012-03-01 14:15:12 UTC (rev 38592) +++ trunk/modules/library/referencing/src/main/resources/META-INF/services/org.geotools.referencing.operation.MathTransformProvider 2012-03-03 10:21:13 UTC (rev 38593) @@ -10,6 +10,7 @@ org.geotools.referencing.operation.transform.MolodenskiTransform$Provider org.geotools.referencing.operation.transform.MolodenskiTransform$ProviderAbridged org.geotools.referencing.operation.transform.NADCONTransform$Provider +org.geotools.referencing.operation.transform.SimilarityTransformProvider org.geotools.referencing.operation.transform.WarpTransform2D$Provider org.geotools.referencing.operation.projection.EquidistantCylindrical$Provider org.geotools.referencing.operation.projection.EquidistantCylindrical$SphericalProvider Added: trunk/modules/library/referencing/src/test/java/org/geotools/referencing/operation/transform/SimilarityTransformProviderTest.java =================================================================== --- trunk/modules/library/referencing/src/test/java/org/geotools/referencing/operation/transform/SimilarityTransformProviderTest.java (rev 0) +++ trunk/modules/library/referencing/src/test/java/org/geotools/referencing/operation/transform/SimilarityTransformProviderTest.java 2012-03-03 10:21:13 UTC (rev 38593) @@ -0,0 +1,55 @@ +package org.geotools.referencing.operation.transform; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import org.geotools.parameter.ParameterGroup; +import org.geotools.referencing.operation.DefaultMathTransformFactory; +import org.opengis.referencing.FactoryException; +import org.opengis.referencing.operation.MathTransform; +import org.opengis.referencing.operation.TransformException; + +/** + * Tests {@link SimilarityTransformProvider}. + * + * @source $URL$ + * @version $Id$ + * @author Oscar Fonts + */ +public final class SimilarityTransformProviderTest { + + /** + * Tests {@link SimilarityTransformProvider}, both direct and inverse transfoms. + */ + @Test + public void testSimilarityTransform() throws FactoryException, TransformException { + + // Parameters from EPSG::5166 transform + ParameterGroup params = new ParameterGroup(SimilarityTransformProvider.PARAMETERS); + params.parameter("8621").setValue(-129.549); + params.parameter("8622").setValue(-208.185); + params.parameter("8611").setValue(1.0000015504); + params.parameter("8614").setValue(1.56504); + + // Transform instance + MathTransform mt = new DefaultMathTransformFactory().createParameterizedTransform(params); + + // Data from EPSG::9621 example + final double precision = 1E-3; // dstPoints have 3 decimal units + final double[] srcPoints = new double[] {300000, 4500000}; + final double[] dstPoints = new double[] {299905.060, 4499796.515}; + final double[] calculatedPoints = new double[srcPoints.length]; + + // Direct transform test + mt.transform(srcPoints, 0, calculatedPoints, 0, srcPoints.length/2); + for (int i=0; i<calculatedPoints.length; i++) { + assertEquals(dstPoints[i], calculatedPoints[i], precision); + } + + // Inverse transform test + mt.inverse().transform(dstPoints, 0, calculatedPoints, 0, dstPoints.length/2); + for (int i=0; i<calculatedPoints.length; i++) { + assertEquals(srcPoints[i], calculatedPoints[i], precision); + } + } + +} Modified: trunk/modules/plugin/epsg-hsql/src/test/java/org/geotools/referencing/CRSTest.java =================================================================== --- trunk/modules/plugin/epsg-hsql/src/test/java/org/geotools/referencing/CRSTest.java 2012-03-01 14:15:12 UTC (rev 38592) +++ trunk/modules/plugin/epsg-hsql/src/test/java/org/geotools/referencing/CRSTest.java 2012-03-03 10:21:13 UTC (rev 38593) @@ -413,6 +413,30 @@ } finally { Hints.removeSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER); } - } + + /** + * Tests similarity transform on the example provided in the EPSG projection guide, page 99 + * @throws Exception + */ + public void testSimilarityTransform() throws Exception { + // Tombak LNG Plant + CoordinateReferenceSystem tombak = CRS.decode("EPSG:5817", true); + // Nakhl-e Ghanem / UTM zone 39N + CoordinateReferenceSystem ng39 = CRS.decode("EPSG:3307", true); + + // forward + double[] src = new double[] {20000, 10000}; + double[] dst = new double[2]; + MathTransform mt = CRS.findMathTransform(tombak, ng39); + mt.transform(src, 0, dst, 0, 1); + + assertEquals(618336.748, dst[0], 0.001); + assertEquals(3067774.210, dst[1], 0.001); + + // and back + mt.inverse().transform(dst, 0, src, 0, 1); + assertEquals(20000, src[0], 0.001); + assertEquals(10000, src[1], 0.001); + } } Modified: trunk/modules/plugin/epsg-hsql/src/test/java/org/geotools/referencing/factory/epsg/PropertyDumper.java =================================================================== --- trunk/modules/plugin/epsg-hsql/src/test/java/org/geotools/referencing/factory/epsg/PropertyDumper.java 2012-03-01 14:15:12 UTC (rev 38592) +++ trunk/modules/plugin/epsg-hsql/src/test/java/org/geotools/referencing/factory/epsg/PropertyDumper.java 2012-03-03 10:21:13 UTC (rev 38593) @@ -51,7 +51,6 @@ List<String> codes = new ArrayList(CRS.getSupportedCodes("EPSG")); Collections.sort(codes, new Comparator<String>() { - @Override public int compare(String c1, String c2) { try { Long n1 = new Long(c1); |
|
From: <svn...@os...> - 2012-03-01 14:15:23
|
Author: jive
Date: 2012-03-01 06:15:12 -0800 (Thu, 01 Mar 2012)
New Revision: 38592
Modified:
trunk/modules/unsupported/process-feature/src/main/java/org/geotools/process/feature/gs/ReShapeProcess.java
trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/AggregateProcessTest.java
trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/BufferFeatureCollectionTest.java
trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/FeatureGSProcessFactoryFactoryTest.java
trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/FeatureProcessTest.java
trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/InclusionFeatureCollectionTest.java
trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/IntersectionFeatureCollectionTest.java
trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/UnionFeatureCollectionTest.java
Log:
Add a test case to confirm expected schema generated by ReShapeOperation; also added a couple of headers to the various test cases
Modified: trunk/modules/unsupported/process-feature/src/main/java/org/geotools/process/feature/gs/ReShapeProcess.java
===================================================================
--- trunk/modules/unsupported/process-feature/src/main/java/org/geotools/process/feature/gs/ReShapeProcess.java 2012-03-01 14:14:53 UTC (rev 38591)
+++ trunk/modules/unsupported/process-feature/src/main/java/org/geotools/process/feature/gs/ReShapeProcess.java 2012-03-01 14:15:12 UTC (rev 38592)
@@ -245,8 +245,12 @@
this.definition = definition;
this.schema = toReShapeFeatureType( delegate, definition );
}
-
@Override
+ public SimpleFeatureType getSchema() {
+ return schema;
+ }
+
+ @Override
public SimpleFeatureIterator features() {
return new ReshapeFeatureIterator(delegate.features(), definition, schema);
}
@@ -282,6 +286,7 @@
fb = new SimpleFeatureBuilder(schema);
}
+
public void close() {
delegate.close();
}
Modified: trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/AggregateProcessTest.java
===================================================================
--- trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/AggregateProcessTest.java 2012-03-01 14:14:53 UTC (rev 38591)
+++ trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/AggregateProcessTest.java 2012-03-01 14:15:12 UTC (rev 38592)
@@ -1,6 +1,22 @@
+/*
+ * GeoTools - The Open Source Java GIS Toolkit
+ * http://geotools.org
+ *
+ * (C) 2011, Open Source Geospatial Foundation (OSGeo)
+ * (C) 2001-2007 TOPP - www.openplans.org.
+ *
+ * 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.process.feature.gs;
-
import static org.junit.Assert.assertTrue;
import java.io.File;
Modified: trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/BufferFeatureCollectionTest.java
===================================================================
--- trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/BufferFeatureCollectionTest.java 2012-03-01 14:14:53 UTC (rev 38591)
+++ trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/BufferFeatureCollectionTest.java 2012-03-01 14:15:12 UTC (rev 38592)
@@ -1,3 +1,20 @@
+/*
+ * GeoTools - The Open Source Java GIS Toolkit
+ * http://geotools.org
+ *
+ * (C) 2011, Open Source Geospatial Foundation (OSGeo)
+ * (C) 2001-2007 TOPP - www.openplans.org.
+ *
+ * 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.process.feature.gs;
import junit.framework.TestCase;
Modified: trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/FeatureGSProcessFactoryFactoryTest.java
===================================================================
--- trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/FeatureGSProcessFactoryFactoryTest.java 2012-03-01 14:14:53 UTC (rev 38591)
+++ trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/FeatureGSProcessFactoryFactoryTest.java 2012-03-01 14:15:12 UTC (rev 38592)
@@ -1,3 +1,20 @@
+/*
+ * GeoTools - The Open Source Java GIS Toolkit
+ * http://geotools.org
+ *
+ * (C) 2011, Open Source Geospatial Foundation (OSGeo)
+ * (C) 2001-2007 TOPP - www.openplans.org.
+ *
+ * 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.process.feature.gs;
import static org.junit.Assert.*;
Modified: trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/FeatureProcessTest.java
===================================================================
--- trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/FeatureProcessTest.java 2012-03-01 14:14:53 UTC (rev 38591)
+++ trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/FeatureProcessTest.java 2012-03-01 14:15:12 UTC (rev 38592)
@@ -1,3 +1,20 @@
+/*
+ * GeoTools - The Open Source Java GIS Toolkit
+ * http://geotools.org
+ *
+ * (C) 2011, Open Source Geospatial Foundation (OSGeo)
+ * (C) 2001-2007 TOPP - www.openplans.org.
+ *
+ * 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.process.feature.gs;
import static org.junit.Assert.*;
Modified: trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/InclusionFeatureCollectionTest.java
===================================================================
--- trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/InclusionFeatureCollectionTest.java 2012-03-01 14:14:53 UTC (rev 38591)
+++ trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/InclusionFeatureCollectionTest.java 2012-03-01 14:15:12 UTC (rev 38592)
@@ -1,3 +1,20 @@
+/*
+ * GeoTools - The Open Source Java GIS Toolkit
+ * http://geotools.org
+ *
+ * (C) 2011, Open Source Geospatial Foundation (OSGeo)
+ * (C) 2001-2007 TOPP - www.openplans.org.
+ *
+ * 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.process.feature.gs;
import static org.junit.Assert.assertEquals;
Modified: trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/IntersectionFeatureCollectionTest.java
===================================================================
--- trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/IntersectionFeatureCollectionTest.java 2012-03-01 14:14:53 UTC (rev 38591)
+++ trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/IntersectionFeatureCollectionTest.java 2012-03-01 14:15:12 UTC (rev 38592)
@@ -1,3 +1,20 @@
+/*
+ * GeoTools - The Open Source Java GIS Toolkit
+ * http://geotools.org
+ *
+ * (C) 2011, Open Source Geospatial Foundation (OSGeo)
+ * (C) 2001-2007 TOPP - www.openplans.org.
+ *
+ * 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.process.feature.gs;
import java.util.List;
Modified: trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/UnionFeatureCollectionTest.java
===================================================================
--- trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/UnionFeatureCollectionTest.java 2012-03-01 14:14:53 UTC (rev 38591)
+++ trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/UnionFeatureCollectionTest.java 2012-03-01 14:15:12 UTC (rev 38592)
@@ -1,3 +1,20 @@
+/*
+ * GeoTools - The Open Source Java GIS Toolkit
+ * http://geotools.org
+ *
+ * (C) 2011, Open Source Geospatial Foundation (OSGeo)
+ * (C) 2001-2007 TOPP - www.openplans.org.
+ *
+ * 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.process.feature.gs;
import static org.junit.Assert.*;
|
|
From: <svn...@os...> - 2012-03-01 14:15:05
|
Author: jive Date: 2012-03-01 06:14:53 -0800 (Thu, 01 Mar 2012) New Revision: 38591 Added: trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/ReShapeProcessTest.java Log: Add a test case to confirm expected schema generated by ReShapeOperation; also added a couple of headers to the various test cases Added: trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/ReShapeProcessTest.java =================================================================== --- trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/ReShapeProcessTest.java (rev 0) +++ trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/ReShapeProcessTest.java 2012-03-01 14:14:53 UTC (rev 38591) @@ -0,0 +1,92 @@ +/* + * 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.process.feature.gs; + + +import static org.junit.Assert.*; + +import java.io.File; +import java.io.IOException; +import java.util.EnumSet; +import java.util.List; +import java.util.Set; + +import org.geotools.data.DataStore; +import org.geotools.data.property.PropertyDataStore; +import org.geotools.data.simple.SimpleFeatureCollection; +import org.geotools.data.simple.SimpleFeatureSource; +import org.geotools.process.feature.gs.AggregateProcess.AggregationFunction; +import org.geotools.process.feature.gs.AggregateProcess.Results; +import org.geotools.process.feature.gs.ReShapeProcess.Definition; +import org.geotools.test.TestData; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.opengis.feature.simple.SimpleFeatureType; +import org.opengis.feature.type.AttributeDescriptor; +import org.opengis.filter.expression.PropertyName; + +/** + * + * + * @source $URL$ + */ +public class ReShapeProcessTest { + DataStore bugs; + + @Before + public void setup() throws IOException { + File file = TestData.file(this, null ); + bugs = new PropertyDataStore( file ); + } + @After + public void tearDown(){ + bugs.dispose(); + } + + + @Test + public void testDefinition() throws Exception { + String definition = "the_geom=the_geom"; + List<Definition> def = ReShapeProcess.toDefinition( definition ); + + assertEquals( 1, def.size() ); + + assertEquals( "the_geom", def.get(0).name ); + assertTrue( def.get(0).expression instanceof PropertyName ); + } + + @Test + public void testSum() throws Exception { + SimpleFeatureSource source = bugs.getFeatureSource("bugsites"); + + + ReShapeProcess process = new ReShapeProcess(); + + String definition = "the_geom=the_geom\nnumber=cat"; + SimpleFeatureCollection origional = source.getFeatures(); + SimpleFeatureCollection result = process.execute( origional, definition ); + + assertEquals( origional.size(), result.size() ); + + SimpleFeatureType schema = result.getSchema(); + AttributeDescriptor number = schema.getDescriptor("number"); + assertTrue( Long.class.isAssignableFrom( number.getType().getBinding() ) ); + + } + +} Property changes on: trunk/modules/unsupported/process-feature/src/test/java/org/geotools/process/feature/gs/ReShapeProcessTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: svn:eol-style + native |
Author: aaime
Date: 2012-02-29 07:46:16 -0800 (Wed, 29 Feb 2012)
New Revision: 38590
Added:
trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/filter/ArcSdeSimplifyingFilterVisitor.java
Modified:
trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEQuery.java
trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/filter/GeometryEncoderSDE.java
trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/data/FilterTest.java
trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/data/TestData.java
Log:
[GEOT-4051] ArcSDE store does not properly handle or-ed spatial filters
Modified: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEQuery.java
===================================================================
--- trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEQuery.java 2012-02-29 15:44:21 UTC (rev 38589)
+++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEQuery.java 2012-02-29 15:46:16 UTC (rev 38590)
@@ -33,6 +33,7 @@
import org.geotools.arcsde.ArcSdeException;
import org.geotools.arcsde.data.FIDReader.SdeManagedFidReader;
import org.geotools.arcsde.data.FIDReader.UserManagedFidReader;
+import org.geotools.arcsde.filter.ArcSdeSimplifyingFilterVisitor;
import org.geotools.arcsde.filter.FilterToSQLSDE;
import org.geotools.arcsde.filter.GeometryEncoderException;
import org.geotools.arcsde.filter.GeometryEncoderSDE;
@@ -952,10 +953,15 @@
*/
private void createGeotoolsFilters() {
FilterToSQLSDE sqlEncoder = getSqlEncoder();
-
+
+ // first off, simplify the filter
+ ArcSdeSimplifyingFilterVisitor visitor = new ArcSdeSimplifyingFilterVisitor(featureType);
+ Filter simplified = (Filter) sourceFilter.accept(visitor, null);
+
+ // then perform the splits
PostPreProcessFilterSplittingVisitor unpacker = new PostPreProcessFilterSplittingVisitor(
sqlEncoder.getCapabilities(), featureType, null);
- sourceFilter.accept(unpacker, null);
+ simplified.accept(unpacker, null);
SimplifyingFilterVisitor filterSimplifier = new SimplifyingFilterVisitor();
final String typeName = this.featureType.getTypeName();
@@ -980,8 +986,9 @@
if (LOGGER.isLoggable(Level.FINE) && geometryFilter != null)
LOGGER.fine("Spatial-Filter portion of SDE Query: '" + geometryFilter + "'");
- this.unsupportedFilter = unpacker.getFilterPost();
- this.unsupportedFilter = (Filter) this.unsupportedFilter.accept(filterSimplifier, null);
+ // SDE geometry filters are setup to be same or less restrictive than the JTS ones,
+ // so we do post filterin in memory with the full filter (it's fast anyways)
+ this.unsupportedFilter = remainingFilter;
if (LOGGER.isLoggable(Level.FINE) && unsupportedFilter != null)
LOGGER.fine("Unsupported (and therefore ignored) portion of SDE Query: '"
+ unsupportedFilter + "'");
Added: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/filter/ArcSdeSimplifyingFilterVisitor.java
===================================================================
--- trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/filter/ArcSdeSimplifyingFilterVisitor.java (rev 0)
+++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/filter/ArcSdeSimplifyingFilterVisitor.java 2012-02-29 15:46:16 UTC (rev 38590)
@@ -0,0 +1,230 @@
+/*
+ * GeoTools - The Open Source Java GIS Toolkit
+ * http://geotools.org
+ *
+ * (C) 2002-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.arcsde.filter;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.geotools.factory.CommonFactoryFinder;
+import org.geotools.filter.visitor.SimplifyingFilterVisitor;
+import org.opengis.feature.simple.SimpleFeatureType;
+import org.opengis.filter.Filter;
+import org.opengis.filter.FilterFactory2;
+import org.opengis.filter.Or;
+import org.opengis.filter.expression.Literal;
+import org.opengis.filter.expression.PropertyName;
+import org.opengis.filter.spatial.BBOX;
+import org.opengis.filter.spatial.BinarySpatialOperator;
+import org.opengis.filter.spatial.Crosses;
+import org.opengis.filter.spatial.Intersects;
+import org.opengis.filter.spatial.Overlaps;
+import org.opengis.filter.spatial.Touches;
+
+import com.vividsolutions.jts.geom.Geometry;
+import com.vividsolutions.jts.geom.GeometryCollection;
+
+/**
+ * Custom simplifying filter visitor that also tries to turn multiple or-ed
+ * spatial filters into a single spatial filter (since ArcSDE query cannot
+ * handle or-ed spatial conditions)
+ *
+ * @author Andrea Aime - GeoSolutions
+ */
+public class ArcSdeSimplifyingFilterVisitor extends SimplifyingFilterVisitor {
+ static final FilterFactory2 FF = CommonFactoryFinder.getFilterFactory2(null);
+
+ // this is the list of spatial operations that we can merge upon (that is, it's not the full list)
+ static final Set<Class<? extends BinarySpatialOperator>> SPATIAL_OPERATIONS = new HashSet<Class<? extends BinarySpatialOperator>>();
+ static {
+ SPATIAL_OPERATIONS.add(BBOX.class);
+ SPATIAL_OPERATIONS.add(Intersects.class);
+ SPATIAL_OPERATIONS.add(Crosses.class);
+ SPATIAL_OPERATIONS.add(Overlaps.class);
+ // commented out for the moment, we could merge but only if the distance is the same
+ // SPATIAL_OPERATIONS.add(DWithin.class);
+ // commented out for the moment, we could merge but only if they are not two overlapping
+ // polygons, as the union will remove some borders on that case
+ // SPATIAL_OPERATIONS.add(Touches.class);
+ }
+
+ private SimpleFeatureType schema;
+
+ public ArcSdeSimplifyingFilterVisitor(SimpleFeatureType schema) {
+ this.schema = schema;
+ }
+
+ @Override
+ public Object visit(Or filter, Object extraData) {
+ // perform the standard simplification
+ Filter simplified = (Filter) super.visit(filter, extraData);
+
+ // is it still an Or filter?
+ if(simplified instanceof Or) {
+ // collect spatial filters so that they are separated per attribute
+ Map<String, List<SpatialOperation>> spatialOps = new HashMap<String, List<SpatialOperation>>();
+ List<Filter> otherFilters = new ArrayList<Filter>();
+ List<Filter> children = ((Or) simplified).getChildren();
+ for (Filter child : children) {
+ // we know how to merge only bbox and intersects for the moment
+ if(child instanceof BinarySpatialOperator) {
+ BinarySpatialOperator bso = (BinarySpatialOperator) child;
+ String name = null;
+ SpatialOperation so = null;
+ if(bso.getExpression1() instanceof PropertyName && bso.getExpression2() instanceof Literal) {
+ name = ((PropertyName) bso.getExpression1()).getPropertyName();
+ so = new SpatialOperation(bso);
+ } else if(bso.getExpression2() instanceof PropertyName && bso.getExpression1() instanceof Literal) {
+ name = ((PropertyName) bso.getExpression2()).getPropertyName();
+ so = new SpatialOperation(bso);
+ }
+
+ if(name != null && so != null) {
+ // handle the default geometry case
+ if("".equals(name) && schema.getGeometryDescriptor() != null) {
+ name = schema.getGeometryDescriptor().getLocalName();
+ }
+
+ // collect into the specific geometry list
+ List<SpatialOperation> list = spatialOps.get(name);
+ if(list == null) {
+ list = new ArrayList<ArcSdeSimplifyingFilterVisitor.SpatialOperation>();
+ spatialOps.put(name, list);
+ }
+ list.add(so);
+ } else {
+ // cannot handle this one
+ otherFilters.add(child);
+ }
+ } else {
+ otherFilters.add(child);
+ }
+ }
+
+ // try to merge all filters that work agains the same attribute and perform the same
+ // (or similar enough) operation
+ List<Filter> mergedFilters = new ArrayList<Filter>();
+ for (String property : spatialOps.keySet()) {
+ List<SpatialOperation> propertyFilters = spatialOps.get(property);
+
+ // we perform a reduction on the list of filters, trying to find groups that can be merged
+ while(propertyFilters.size() > 0) {
+ SpatialOperation main = propertyFilters.get(0);
+ List<SpatialOperation> toMerge = new ArrayList<SpatialOperation>();
+ toMerge.add(main);
+ for (int j = 1; j < propertyFilters.size(); ) {
+ SpatialOperation secondary = propertyFilters.get(j);
+ // check if the two operations are compatible
+ if(secondary.operation == main.operation
+ || (secondary.operation == BBOX.class && main.operation == Intersects.class)
+ || (secondary.operation == Intersects.class && main.operation == BBOX.class)) {
+ toMerge.add(secondary);
+ propertyFilters.remove(j);
+ } else {
+ j++;
+ }
+ }
+
+ if(toMerge.size() == 1) {
+ // could not be merged, put in the "others" list
+ otherFilters.add(main.op);
+ } else {
+ try {
+ Filter merged = mergeOperations(property, toMerge);
+ mergedFilters.add(merged);
+ } catch(Exception e) {
+ // the operation can go belly up because of topology exceptions, in
+ // that case we just add back all the operations to the main list
+ for (SpatialOperation so : toMerge) {
+ otherFilters.add(so.op);
+ }
+ }
+ }
+ propertyFilters.remove(0);
+ }
+ }
+
+ // did we manage to squash anything?
+ if(mergedFilters.size() == 1 && otherFilters.size() == 0) {
+ simplified = mergedFilters.get(0);
+ } else if(mergedFilters.size() > 0) {
+ List<Filter> full = new ArrayList<Filter>();
+ full.addAll(mergedFilters);
+ full.addAll(otherFilters);
+ simplified = FF.or(full);
+ }
+ }
+
+ return simplified;
+ }
+
+ private Filter mergeOperations(String propertyName, List<SpatialOperation> ops) {
+ // prepare the property name
+ PropertyName property = FF.property(propertyName);
+
+ // prepare united the geometry
+ Geometry[] geomArray = new Geometry[ops.size()];
+ for (int i = 0; i < geomArray.length; i++) {
+ geomArray[i] = ops.get(i).geometry;
+ }
+ GeometryCollection collection = geomArray[0].getFactory().createGeometryCollection(geomArray);
+ Geometry united = collection.union();
+ Literal geometry = FF.literal(united);
+
+ // rebuild the filter
+ Class operation = ops.get(0).operation;
+ if(BBOX.class.isAssignableFrom(operation) || Intersects.class.isAssignableFrom(operation)) {
+ return FF.intersects(property, geometry);
+ } else if(Crosses.class.isAssignableFrom(operation)) {
+ return FF.crosses(property, geometry);
+ } else if(Overlaps.class.isAssignableFrom(operation)) {
+ return FF.overlaps(property, geometry);
+ } else if(Touches.class.isAssignableFrom(operation)) {
+ return FF.touches(property, geometry);
+ } else {
+ throw new IllegalArgumentException("Cannot merge operation " + operation.getName());
+ }
+ }
+
+
+ static class SpatialOperation {
+ BinarySpatialOperator op;
+ Class operation;
+ Geometry geometry;
+
+ public SpatialOperation(BinarySpatialOperator op) {
+ this.op = op;
+ for (Class iface : op.getClass().getInterfaces()) {
+ if(SPATIAL_OPERATIONS.contains(iface)) {
+ operation = iface;
+ break;
+ }
+ }
+ if(op.getExpression1() instanceof Literal) {
+ geometry = op.getExpression1().evaluate(null, Geometry.class);
+ } else if(op.getExpression2() instanceof Literal) {
+ geometry = op.getExpression2().evaluate(null, Geometry.class);
+ } else {
+ throw new IllegalArgumentException("Cannot find literal geometry in the spatial filter");
+ }
+ }
+ }
+}
Modified: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/filter/GeometryEncoderSDE.java
===================================================================
--- trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/filter/GeometryEncoderSDE.java 2012-02-29 15:44:21 UTC (rev 38589)
+++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/filter/GeometryEncoderSDE.java 2012-02-29 15:46:16 UTC (rev 38590)
@@ -109,7 +109,10 @@
private static FilterCapabilities capabilities = new FilterCapabilities();
static {
- capabilities.addAll(FilterCapabilities.LOGICAL_OPENGIS);
+ capabilities.addType(And.class);
+ capabilities.addType(Not.class);
+ // capabilities.addType(Or.class);
+
capabilities.addType(Id.class);
capabilities.addType(BBOX.class);
@@ -324,7 +327,13 @@
}
public Object visit(Contains filter, Object extraData) {
- addSpatialFilter(filter, SeFilter.METHOD_PC, true, extraData);
+ // SDE can assert only one way, we need to invert from contains to within in case the
+ // assertion is the other way around
+ if (filter.getExpression1() instanceof PropertyName && filter.getExpression2() instanceof Literal) {
+ addSpatialFilter(filter, SeFilter.METHOD_PC, true, extraData);
+ } else {
+ addSpatialFilter(filter, SeFilter.METHOD_SC, true, extraData);
+ }
return extraData;
}
@@ -358,13 +367,23 @@
public Object visit(Overlaps filter, Object extraData) {
addSpatialFilter(filter, SeFilter.METHOD_II, true, extraData);
- addSpatialFilter(filter, SeFilter.METHOD_PC, false, extraData);
- addSpatialFilter(filter, SeFilter.METHOD_SC, false, extraData);
+ // AA: nope, Overlaps definition is The geometries have some but not all points in common,
+ // they have the same dimension, and the intersection of the interiors of the two geometries
+ // has the same dimension as the geometries themselves.
+ // --> that is, one can be contained in the other and they still overlap
+ // addSpatialFilter(filter, SeFilter.METHOD_PC, false, extraData);
+ // addSpatialFilter(filter, SeFilter.METHOD_SC, false, extraData);
return extraData;
}
public Object visit(Within filter, Object extraData) {
- addSpatialFilter(filter, SeFilter.METHOD_SC, true, extraData);
+ // SDE can assert only one way, we need to invert from contains to within in case the
+ // assertion is the other way around
+ if (filter.getExpression1() instanceof PropertyName && filter.getExpression2() instanceof Literal) {
+ addSpatialFilter(filter, SeFilter.METHOD_SC, true, extraData);
+ } else {
+ addSpatialFilter(filter, SeFilter.METHOD_PC, true, extraData);
+ }
return extraData;
}
Modified: trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/data/FilterTest.java
===================================================================
--- trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/data/FilterTest.java 2012-02-29 15:44:21 UTC (rev 38589)
+++ trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/data/FilterTest.java 2012-02-29 15:46:16 UTC (rev 38590)
@@ -17,8 +17,7 @@
*/
package org.geotools.arcsde.data;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import java.io.IOException;
import java.util.ArrayList;
@@ -49,6 +48,7 @@
import org.opengis.feature.type.PropertyDescriptor;
import org.opengis.filter.Filter;
import org.opengis.filter.FilterFactory2;
+import org.opengis.filter.spatial.BBOX;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
@@ -197,37 +197,49 @@
* TODO: resurrect testDisjointFilter
*/
@Test
- @Ignore
public void testDisjointFilter() throws Exception {
FeatureType ft = this.dataStore.getSchema(testData.getTempTableName());
- // Build the filter
- double minx = -179;
- double maxx = -170;
- double miny = -90;
- double maxy = -80;
- Polygon p = buildPolygon(minx, miny, maxx, maxy);
+ // Build a polygon that intercepts some of the geometries, but not all of them
+ Polygon p = buildPolygon(-180, 0, -160, 90);
Filter filter = ff.not(ff.isNull(ff.property("SHAPE")));
filter = ff.and(filter, ff.disjoint(ff.property("SHAPE"), ff.literal(p)));
- runTestWithFilter(ft, filter);
+ runTestWithFilter(ft, filter, false);
}
@Test
public void testContainsFilter() throws Exception {
FeatureType ft = this.dataStore.getSchema(testData.getTempTableName());
- // Build the filter
- double minx = 106.6666;
- double maxx = 106.6677;
- double miny = -6.1676;
- double maxy = -6.1672;
- Polygon p = buildPolygon(minx, miny, maxx, maxy);
+ // Build the filter with a polygon that is inside POLYGON((-10 -10, -10 10, 10 10, 10 -10, -10 -10))
+ Polygon p = buildPolygon(-9, -9, -8, -8);
+ Filter filter = ff.contains(ff.property("SHAPE"), ff.literal(p));
+ runTestWithFilter(ft, filter, false);
+
+ // now build the opposite filter, the polygon contains the shape
+ p = buildPolygon(-1, -1, 1, 1);
+ filter = ff.contains(ff.literal(p), ff.property("SHAPE"));
+ runTestWithFilter(ft, filter, false);
+ }
+
+ @Test
+ public void testContainsSDESemanticsFilter() throws Exception {
+ FeatureType ft = this.dataStore.getSchema(testData.getTempTableName());
+ // Build a filter so that SDE would actually catch more geometries, it would
+ // actually include "MULTIPOLYGON( ((-1 -1, -1 1, 1 1, 1 -1, -1 -1)), ((-170 -80, -170 -70, -160 -70, -160 -80, -170 -80)) )"
+ // in the results as well. It seems the containment semantics is applied in or to the multigeometry
+ // components. We do in memory post filtering to get the right semantics
+ Polygon p = buildPolygon(-1, -1, 1, 1);
Filter filter = ff.contains(ff.property("SHAPE"), ff.literal(p));
-
- runTestWithFilter(ft, filter);
+ runTestWithFilter(ft, filter, false);
+
+ // now build the opposite filter, the polygon contains the shape
+ p = buildPolygon(-1, -1, 1, 1);
+ filter = ff.contains(ff.literal(p), ff.property("SHAPE"));
+ runTestWithFilter(ft, filter, false);
}
@Test
@@ -235,28 +247,36 @@
FeatureType ft = this.dataStore.getSchema(testData.getTempTableName());
// Build the filter
- double minx = 106.6337;
- double maxx = 106.6381;
- double miny = -6.1794;
- double maxy = -6.1727;
- Filter filter = ff.bbox("SHAPE", minx, miny, maxx, maxy, "EPSG:4326");
+ Filter filter = ff.bbox("SHAPE", -1, -1, 1, 1, "EPSG:4326");
- runTestWithFilter(ft, filter);
+ runTestWithFilter(ft, filter, false);
}
+
+ @Test
+ public void testOrBBoxFilter() throws Exception {
+ FeatureType ft = this.dataStore.getSchema(testData.getTempTableName());
+
+ System.out.println(this.dataStore.getFeatureSource(ft.getName().getLocalPart()).getBounds());
+ // build a or of bbox so that
+ // - the intersection of the bboxes is empty
+ // - the union of the bboxes actually gets more data than necessary
+ BBOX bbox1 = ff.bbox("SHAPE", -171, -90, -169, 90, "EPSG:4326");
+ BBOX bbox2 = ff.bbox("SHAPE", 169, -90, 171, 90, "EPSG:4326");
+ Filter filter = ff.or(bbox1, bbox2);
+
+ runTestWithFilter(ft, filter, false);
+ }
+
@Test
public void testIntersectsFilter() throws Exception {
FeatureType ft = this.dataStore.getSchema(testData.getTempTableName());
// Build the filter
- double minx = 106.6337;
- double maxx = 106.6381;
- double miny = -6.1794;
- double maxy = -6.1727;
- Polygon p = buildPolygon(minx, miny, maxx, maxy);
+ Polygon p = buildPolygon(-1, -1, 1, 1);
Filter filter = ff.intersects(ff.property("SHAPE"), ff.literal(p));
- runTestWithFilter(ft, filter);
+ runTestWithFilter(ft, filter, false);
}
@Test
@@ -264,14 +284,10 @@
FeatureType ft = this.dataStore.getSchema(testData.getTempTableName());
// Build the filter
- double minx = 106.6337;
- double maxx = 106.6381;
- double miny = -6.1794;
- double maxy = -6.1727;
- Polygon p = buildPolygon(minx, miny, maxx, maxy);
+ Polygon p = buildPolygon(-10, -10, -8, -8);
Filter filter = ff.overlaps(ff.property("SHAPE"), ff.literal(p));
- runTestWithFilter(ft, filter);
+ runTestWithFilter(ft, filter, false);
}
@Test
@@ -279,14 +295,16 @@
FeatureType ft = this.dataStore.getSchema(testData.getTempTableName());
// Build the filter
- double minx = 106.6337;
- double maxx = 106.6381;
- double miny = -6.1794;
- double maxy = -6.1727;
- Polygon p = buildPolygon(minx, miny, maxx, maxy);
- Filter filter = ff.within(ff.property("SHAPE"), ff.literal(p));
+ Polygon p = buildPolygon(-9, -9, -8, -8);
+ Filter filter = ff.within(ff.literal(p), ff.property("SHAPE"));
+ runTestWithFilter(ft, filter, false);
+
+ // now build the opposite filter, the polygon contains the shape
+ p = buildPolygon(-1, -1, 1, 1);
+ filter = ff.within(ff.property("SHAPE"), ff.literal(p));
+ runTestWithFilter(ft, filter, false);
- runTestWithFilter(ft, filter);
+ runTestWithFilter(ft, filter, false);
}
@Test
@@ -294,14 +312,10 @@
FeatureType ft = this.dataStore.getSchema(testData.getTempTableName());
// Build the filter
- double minx = 106.6337;
- double maxx = 106.6381;
- double miny = -6.1794;
- double maxy = -6.1727;
- LineString ls = buildSegment(minx, miny, maxx, maxy);
+ LineString ls = buildSegment(-12, -12, 12, 12);
Filter filter = ff.crosses(ff.property("SHAPE"), ff.literal(ls));
- runTestWithFilter(ft, filter);
+ runTestWithFilter(ft, filter, false);
}
/**
@@ -326,10 +340,10 @@
// Build the filter
Filter filter = ff.equal(ff.property("SHAPE"), ff.literal(g));
- runTestWithFilter(ft, filter);
+ runTestWithFilter(ft, filter, false);
}
- private void runTestWithFilter(FeatureType ft, Filter filter) throws Exception {
+ private void runTestWithFilter(FeatureType ft, Filter filter, boolean empty) throws Exception {
System.err.println("****************");
System.err.println("**");
System.err.println("** TESTING FILTER: " + filter);
@@ -365,8 +379,15 @@
fr.close();
endTime = System.currentTimeMillis();
System.err.println("Fast read took " + (endTime - startTime) + " milliseconds.");
+
+ assertFeatureListsSimilar(slowResults, fastResults);
+
+ if(empty) {
+ assertEquals("Result was supposed to be empty", 0, fastResults.size());
+ } else {
+ assertTrue("Result was supposed to be non empty", fastResults.size() > 0);
+ }
- assertFeatureListsSimilar(slowResults, fastResults);
}
private String[] safePropertyNames(FeatureType ft) {
Modified: trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/data/TestData.java
===================================================================
--- trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/data/TestData.java 2012-02-29 15:44:21 UTC (rev 38589)
+++ trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/data/TestData.java 2012-02-29 15:46:16 UTC (rev 38590)
@@ -557,13 +557,13 @@
* <li>7. Shape - values:
* <ul>
* <li> <code>POINT(0 0)</code>
- * <li> <code>MULTIPOINT(0 0, 180 0)</code>
- * <li> <code>LINESTRING(0 0, 180 90)</code>
- * <li> <code>MULTILINESTRING((-180 -90, 180 90), (-180 90, 180 -90))</code>
+ * <li> <code>MULTIPOINT(0 0, 170 0)</code>
+ * <li> <code>LINESTRING(0 0, 170 80)</code>
+ * <li> <code>"MULTILINESTRING((-170 -80, 170 80), (-170 80, 170 -80))"</code>
* <li> <code>POLYGON((-10 -10, -10 10, 10 10, 10 -10, -10 -10))</code>
* <li>
- * <code>MULTIPOLYGON( ((-1 -1, -1 1, 1 1, 1 -1, -1 -1)), ((-180 -90, -180 -80, -170 -80, -170 -90, -180 -90)) )</code>
- * <li> <code>GEOMETRYCOLLECTION(POINT(1 1), LINESTRING(0 0, 180 90))</code>
+ * <code>MULTIPOLYGON( "MULTIPOLYGON( ((-1 -1, -1 1, 1 1, 1 -1, -1 -1)), ((-170 -80, -170 -70, -160 -70, -160 -80, -170 -80)) )" )</code>
+ * <li> <code>POINT EMPTY</code>
* <li> <code>null</code>
* </ul>
* </li>
|
Author: aaime
Date: 2012-02-29 07:44:21 -0800 (Wed, 29 Feb 2012)
New Revision: 38589
Added:
branches/2.7.x/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/filter/ArcSdeSimplifyingFilterVisitor.java
Modified:
branches/2.7.x/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEQuery.java
branches/2.7.x/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/filter/GeometryEncoderSDE.java
branches/2.7.x/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/data/FilterTest.java
branches/2.7.x/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/data/TestData.java
Log:
[GEOT-4051] ArcSDE store does not properly handle or-ed spatial filters
Modified: branches/2.7.x/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEQuery.java
===================================================================
--- branches/2.7.x/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEQuery.java 2012-02-29 15:37:37 UTC (rev 38588)
+++ branches/2.7.x/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEQuery.java 2012-02-29 15:44:21 UTC (rev 38589)
@@ -33,6 +33,7 @@
import org.geotools.arcsde.ArcSdeException;
import org.geotools.arcsde.data.FIDReader.SdeManagedFidReader;
import org.geotools.arcsde.data.FIDReader.UserManagedFidReader;
+import org.geotools.arcsde.filter.ArcSdeSimplifyingFilterVisitor;
import org.geotools.arcsde.filter.FilterToSQLSDE;
import org.geotools.arcsde.filter.GeometryEncoderException;
import org.geotools.arcsde.filter.GeometryEncoderSDE;
@@ -952,10 +953,15 @@
*/
private void createGeotoolsFilters() {
FilterToSQLSDE sqlEncoder = getSqlEncoder();
-
+
+ // first off, simplify the filter
+ ArcSdeSimplifyingFilterVisitor visitor = new ArcSdeSimplifyingFilterVisitor(featureType);
+ Filter simplified = (Filter) sourceFilter.accept(visitor, null);
+
+ // then perform the splits
PostPreProcessFilterSplittingVisitor unpacker = new PostPreProcessFilterSplittingVisitor(
sqlEncoder.getCapabilities(), featureType, null);
- sourceFilter.accept(unpacker, null);
+ simplified.accept(unpacker, null);
SimplifyingFilterVisitor filterSimplifier = new SimplifyingFilterVisitor();
final String typeName = this.featureType.getTypeName();
@@ -980,8 +986,9 @@
if (LOGGER.isLoggable(Level.FINE) && geometryFilter != null)
LOGGER.fine("Spatial-Filter portion of SDE Query: '" + geometryFilter + "'");
- this.unsupportedFilter = unpacker.getFilterPost();
- this.unsupportedFilter = (Filter) this.unsupportedFilter.accept(filterSimplifier, null);
+ // SDE geometry filters are setup to be same or less restrictive than the JTS ones,
+ // so we do post filterin in memory with the full filter (it's fast anyways)
+ this.unsupportedFilter = remainingFilter;
if (LOGGER.isLoggable(Level.FINE) && unsupportedFilter != null)
LOGGER.fine("Unsupported (and therefore ignored) portion of SDE Query: '"
+ unsupportedFilter + "'");
Added: branches/2.7.x/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/filter/ArcSdeSimplifyingFilterVisitor.java
===================================================================
--- branches/2.7.x/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/filter/ArcSdeSimplifyingFilterVisitor.java (rev 0)
+++ branches/2.7.x/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/filter/ArcSdeSimplifyingFilterVisitor.java 2012-02-29 15:44:21 UTC (rev 38589)
@@ -0,0 +1,230 @@
+/*
+ * GeoTools - The Open Source Java GIS Toolkit
+ * http://geotools.org
+ *
+ * (C) 2002-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.arcsde.filter;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.geotools.factory.CommonFactoryFinder;
+import org.geotools.filter.visitor.SimplifyingFilterVisitor;
+import org.opengis.feature.simple.SimpleFeatureType;
+import org.opengis.filter.Filter;
+import org.opengis.filter.FilterFactory2;
+import org.opengis.filter.Or;
+import org.opengis.filter.expression.Literal;
+import org.opengis.filter.expression.PropertyName;
+import org.opengis.filter.spatial.BBOX;
+import org.opengis.filter.spatial.BinarySpatialOperator;
+import org.opengis.filter.spatial.Crosses;
+import org.opengis.filter.spatial.Intersects;
+import org.opengis.filter.spatial.Overlaps;
+import org.opengis.filter.spatial.Touches;
+
+import com.vividsolutions.jts.geom.Geometry;
+import com.vividsolutions.jts.geom.GeometryCollection;
+
+/**
+ * Custom simplifying filter visitor that also tries to turn multiple or-ed
+ * spatial filters into a single spatial filter (since ArcSDE query cannot
+ * handle or-ed spatial conditions)
+ *
+ * @author Andrea Aime - GeoSolutions
+ */
+public class ArcSdeSimplifyingFilterVisitor extends SimplifyingFilterVisitor {
+ static final FilterFactory2 FF = CommonFactoryFinder.getFilterFactory2(null);
+
+ // this is the list of spatial operations that we can merge upon (that is, it's not the full list)
+ static final Set<Class<? extends BinarySpatialOperator>> SPATIAL_OPERATIONS = new HashSet<Class<? extends BinarySpatialOperator>>();
+ static {
+ SPATIAL_OPERATIONS.add(BBOX.class);
+ SPATIAL_OPERATIONS.add(Intersects.class);
+ SPATIAL_OPERATIONS.add(Crosses.class);
+ SPATIAL_OPERATIONS.add(Overlaps.class);
+ // commented out for the moment, we could merge but only if the distance is the same
+ // SPATIAL_OPERATIONS.add(DWithin.class);
+ // commented out for the moment, we could merge but only if they are not two overlapping
+ // polygons, as the union will remove some borders on that case
+ // SPATIAL_OPERATIONS.add(Touches.class);
+ }
+
+ private SimpleFeatureType schema;
+
+ public ArcSdeSimplifyingFilterVisitor(SimpleFeatureType schema) {
+ this.schema = schema;
+ }
+
+ @Override
+ public Object visit(Or filter, Object extraData) {
+ // perform the standard simplification
+ Filter simplified = (Filter) super.visit(filter, extraData);
+
+ // is it still an Or filter?
+ if(simplified instanceof Or) {
+ // collect spatial filters so that they are separated per attribute
+ Map<String, List<SpatialOperation>> spatialOps = new HashMap<String, List<SpatialOperation>>();
+ List<Filter> otherFilters = new ArrayList<Filter>();
+ List<Filter> children = ((Or) simplified).getChildren();
+ for (Filter child : children) {
+ // we know how to merge only bbox and intersects for the moment
+ if(child instanceof BinarySpatialOperator) {
+ BinarySpatialOperator bso = (BinarySpatialOperator) child;
+ String name = null;
+ SpatialOperation so = null;
+ if(bso.getExpression1() instanceof PropertyName && bso.getExpression2() instanceof Literal) {
+ name = ((PropertyName) bso.getExpression1()).getPropertyName();
+ so = new SpatialOperation(bso);
+ } else if(bso.getExpression2() instanceof PropertyName && bso.getExpression1() instanceof Literal) {
+ name = ((PropertyName) bso.getExpression2()).getPropertyName();
+ so = new SpatialOperation(bso);
+ }
+
+ if(name != null && so != null) {
+ // handle the default geometry case
+ if("".equals(name) && schema.getGeometryDescriptor() != null) {
+ name = schema.getGeometryDescriptor().getLocalName();
+ }
+
+ // collect into the specific geometry list
+ List<SpatialOperation> list = spatialOps.get(name);
+ if(list == null) {
+ list = new ArrayList<ArcSdeSimplifyingFilterVisitor.SpatialOperation>();
+ spatialOps.put(name, list);
+ }
+ list.add(so);
+ } else {
+ // cannot handle this one
+ otherFilters.add(child);
+ }
+ } else {
+ otherFilters.add(child);
+ }
+ }
+
+ // try to merge all filters that work agains the same attribute and perform the same
+ // (or similar enough) operation
+ List<Filter> mergedFilters = new ArrayList<Filter>();
+ for (String property : spatialOps.keySet()) {
+ List<SpatialOperation> propertyFilters = spatialOps.get(property);
+
+ // we perform a reduction on the list of filters, trying to find groups that can be merged
+ while(propertyFilters.size() > 0) {
+ SpatialOperation main = propertyFilters.get(0);
+ List<SpatialOperation> toMerge = new ArrayList<SpatialOperation>();
+ toMerge.add(main);
+ for (int j = 1; j < propertyFilters.size(); ) {
+ SpatialOperation secondary = propertyFilters.get(j);
+ // check if the two operations are compatible
+ if(secondary.operation == main.operation
+ || (secondary.operation == BBOX.class && main.operation == Intersects.class)
+ || (secondary.operation == Intersects.class && main.operation == BBOX.class)) {
+ toMerge.add(secondary);
+ propertyFilters.remove(j);
+ } else {
+ j++;
+ }
+ }
+
+ if(toMerge.size() == 1) {
+ // could not be merged, put in the "others" list
+ otherFilters.add(main.op);
+ } else {
+ try {
+ Filter merged = mergeOperations(property, toMerge);
+ mergedFilters.add(merged);
+ } catch(Exception e) {
+ // the operation can go belly up because of topology exceptions, in
+ // that case we just add back all the operations to the main list
+ for (SpatialOperation so : toMerge) {
+ otherFilters.add(so.op);
+ }
+ }
+ }
+ propertyFilters.remove(0);
+ }
+ }
+
+ // did we manage to squash anything?
+ if(mergedFilters.size() == 1 && otherFilters.size() == 0) {
+ simplified = mergedFilters.get(0);
+ } else if(mergedFilters.size() > 0) {
+ List<Filter> full = new ArrayList<Filter>();
+ full.addAll(mergedFilters);
+ full.addAll(otherFilters);
+ simplified = FF.or(full);
+ }
+ }
+
+ return simplified;
+ }
+
+ private Filter mergeOperations(String propertyName, List<SpatialOperation> ops) {
+ // prepare the property name
+ PropertyName property = FF.property(propertyName);
+
+ // prepare united the geometry
+ Geometry[] geomArray = new Geometry[ops.size()];
+ for (int i = 0; i < geomArray.length; i++) {
+ geomArray[i] = ops.get(i).geometry;
+ }
+ GeometryCollection collection = geomArray[0].getFactory().createGeometryCollection(geomArray);
+ Geometry united = collection.union();
+ Literal geometry = FF.literal(united);
+
+ // rebuild the filter
+ Class operation = ops.get(0).operation;
+ if(BBOX.class.isAssignableFrom(operation) || Intersects.class.isAssignableFrom(operation)) {
+ return FF.intersects(property, geometry);
+ } else if(Crosses.class.isAssignableFrom(operation)) {
+ return FF.crosses(property, geometry);
+ } else if(Overlaps.class.isAssignableFrom(operation)) {
+ return FF.overlaps(property, geometry);
+ } else if(Touches.class.isAssignableFrom(operation)) {
+ return FF.touches(property, geometry);
+ } else {
+ throw new IllegalArgumentException("Cannot merge operation " + operation.getName());
+ }
+ }
+
+
+ static class SpatialOperation {
+ BinarySpatialOperator op;
+ Class operation;
+ Geometry geometry;
+
+ public SpatialOperation(BinarySpatialOperator op) {
+ this.op = op;
+ for (Class iface : op.getClass().getInterfaces()) {
+ if(SPATIAL_OPERATIONS.contains(iface)) {
+ operation = iface;
+ break;
+ }
+ }
+ if(op.getExpression1() instanceof Literal) {
+ geometry = op.getExpression1().evaluate(null, Geometry.class);
+ } else if(op.getExpression2() instanceof Literal) {
+ geometry = op.getExpression2().evaluate(null, Geometry.class);
+ } else {
+ throw new IllegalArgumentException("Cannot find literal geometry in the spatial filter");
+ }
+ }
+ }
+}
Modified: branches/2.7.x/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/filter/GeometryEncoderSDE.java
===================================================================
--- branches/2.7.x/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/filter/GeometryEncoderSDE.java 2012-02-29 15:37:37 UTC (rev 38588)
+++ branches/2.7.x/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/filter/GeometryEncoderSDE.java 2012-02-29 15:44:21 UTC (rev 38589)
@@ -92,7 +92,10 @@
private static FilterCapabilities capabilities = new FilterCapabilities();
static {
- capabilities.addAll(FilterCapabilities.LOGICAL_OPENGIS);
+ capabilities.addType(And.class);
+ capabilities.addType(Not.class);
+ // capabilities.addType(Or.class);
+
capabilities.addType(Id.class);
capabilities.addType(BBOX.class);
@@ -307,7 +310,13 @@
}
public Object visit(Contains filter, Object extraData) {
- addSpatialFilter(filter, SeFilter.METHOD_PC, true, extraData);
+ // SDE can assert only one way, we need to invert from contains to within in case the
+ // assertion is the other way around
+ if (filter.getExpression1() instanceof PropertyName && filter.getExpression2() instanceof Literal) {
+ addSpatialFilter(filter, SeFilter.METHOD_PC, true, extraData);
+ } else {
+ addSpatialFilter(filter, SeFilter.METHOD_SC, true, extraData);
+ }
return extraData;
}
@@ -341,13 +350,23 @@
public Object visit(Overlaps filter, Object extraData) {
addSpatialFilter(filter, SeFilter.METHOD_II, true, extraData);
- addSpatialFilter(filter, SeFilter.METHOD_PC, false, extraData);
- addSpatialFilter(filter, SeFilter.METHOD_SC, false, extraData);
+ // AA: nope, Overlaps definition is The geometries have some but not all points in common,
+ // they have the same dimension, and the intersection of the interiors of the two geometries
+ // has the same dimension as the geometries themselves.
+ // --> that is, one can be contained in the other and they still overlap
+ // addSpatialFilter(filter, SeFilter.METHOD_PC, false, extraData);
+ // addSpatialFilter(filter, SeFilter.METHOD_SC, false, extraData);
return extraData;
}
public Object visit(Within filter, Object extraData) {
- addSpatialFilter(filter, SeFilter.METHOD_SC, true, extraData);
+ // SDE can assert only one way, we need to invert from contains to within in case the
+ // assertion is the other way around
+ if (filter.getExpression1() instanceof PropertyName && filter.getExpression2() instanceof Literal) {
+ addSpatialFilter(filter, SeFilter.METHOD_SC, true, extraData);
+ } else {
+ addSpatialFilter(filter, SeFilter.METHOD_PC, true, extraData);
+ }
return extraData;
}
Modified: branches/2.7.x/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/data/FilterTest.java
===================================================================
--- branches/2.7.x/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/data/FilterTest.java 2012-02-29 15:37:37 UTC (rev 38588)
+++ branches/2.7.x/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/data/FilterTest.java 2012-02-29 15:44:21 UTC (rev 38589)
@@ -17,8 +17,7 @@
*/
package org.geotools.arcsde.data;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import java.io.IOException;
import java.util.ArrayList;
@@ -49,6 +48,7 @@
import org.opengis.feature.type.PropertyDescriptor;
import org.opengis.filter.Filter;
import org.opengis.filter.FilterFactory2;
+import org.opengis.filter.spatial.BBOX;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
@@ -196,37 +196,49 @@
* TODO: resurrect testDisjointFilter
*/
@Test
- @Ignore
public void testDisjointFilter() throws Exception {
FeatureType ft = this.dataStore.getSchema(testData.getTempTableName());
- // Build the filter
- double minx = -179;
- double maxx = -170;
- double miny = -90;
- double maxy = -80;
- Polygon p = buildPolygon(minx, miny, maxx, maxy);
+ // Build a polygon that intercepts some of the geometries, but not all of them
+ Polygon p = buildPolygon(-180, 0, -160, 90);
Filter filter = ff.not(ff.isNull(ff.property("SHAPE")));
filter = ff.and(filter, ff.disjoint(ff.property("SHAPE"), ff.literal(p)));
- runTestWithFilter(ft, filter);
+ runTestWithFilter(ft, filter, false);
}
@Test
public void testContainsFilter() throws Exception {
FeatureType ft = this.dataStore.getSchema(testData.getTempTableName());
- // Build the filter
- double minx = 106.6666;
- double maxx = 106.6677;
- double miny = -6.1676;
- double maxy = -6.1672;
- Polygon p = buildPolygon(minx, miny, maxx, maxy);
+ // Build the filter with a polygon that is inside POLYGON((-10 -10, -10 10, 10 10, 10 -10, -10 -10))
+ Polygon p = buildPolygon(-9, -9, -8, -8);
+ Filter filter = ff.contains(ff.property("SHAPE"), ff.literal(p));
+ runTestWithFilter(ft, filter, false);
+
+ // now build the opposite filter, the polygon contains the shape
+ p = buildPolygon(-1, -1, 1, 1);
+ filter = ff.contains(ff.literal(p), ff.property("SHAPE"));
+ runTestWithFilter(ft, filter, false);
+ }
+
+ @Test
+ public void testContainsSDESemanticsFilter() throws Exception {
+ FeatureType ft = this.dataStore.getSchema(testData.getTempTableName());
+ // Build a filter so that SDE would actually catch more geometries, it would
+ // actually include "MULTIPOLYGON( ((-1 -1, -1 1, 1 1, 1 -1, -1 -1)), ((-170 -80, -170 -70, -160 -70, -160 -80, -170 -80)) )"
+ // in the results as well. It seems the containment semantics is applied in or to the multigeometry
+ // components. We do in memory post filtering to get the right semantics
+ Polygon p = buildPolygon(-1, -1, 1, 1);
Filter filter = ff.contains(ff.property("SHAPE"), ff.literal(p));
-
- runTestWithFilter(ft, filter);
+ runTestWithFilter(ft, filter, false);
+
+ // now build the opposite filter, the polygon contains the shape
+ p = buildPolygon(-1, -1, 1, 1);
+ filter = ff.contains(ff.literal(p), ff.property("SHAPE"));
+ runTestWithFilter(ft, filter, false);
}
@Test
@@ -234,28 +246,36 @@
FeatureType ft = this.dataStore.getSchema(testData.getTempTableName());
// Build the filter
- double minx = 106.6337;
- double maxx = 106.6381;
- double miny = -6.1794;
- double maxy = -6.1727;
- Filter filter = ff.bbox("SHAPE", minx, miny, maxx, maxy, "EPSG:4326");
+ Filter filter = ff.bbox("SHAPE", -1, -1, 1, 1, "EPSG:4326");
- runTestWithFilter(ft, filter);
+ runTestWithFilter(ft, filter, false);
}
+
+ @Test
+ public void testOrBBoxFilter() throws Exception {
+ FeatureType ft = this.dataStore.getSchema(testData.getTempTableName());
+
+ System.out.println(this.dataStore.getFeatureSource(ft.getName().getLocalPart()).getBounds());
+ // build a or of bbox so that
+ // - the intersection of the bboxes is empty
+ // - the union of the bboxes actually gets more data than necessary
+ BBOX bbox1 = ff.bbox("SHAPE", -171, -90, -169, 90, "EPSG:4326");
+ BBOX bbox2 = ff.bbox("SHAPE", 169, -90, 171, 90, "EPSG:4326");
+ Filter filter = ff.or(bbox1, bbox2);
+
+ runTestWithFilter(ft, filter, false);
+ }
+
@Test
public void testIntersectsFilter() throws Exception {
FeatureType ft = this.dataStore.getSchema(testData.getTempTableName());
// Build the filter
- double minx = 106.6337;
- double maxx = 106.6381;
- double miny = -6.1794;
- double maxy = -6.1727;
- Polygon p = buildPolygon(minx, miny, maxx, maxy);
+ Polygon p = buildPolygon(-1, -1, 1, 1);
Filter filter = ff.intersects(ff.property("SHAPE"), ff.literal(p));
- runTestWithFilter(ft, filter);
+ runTestWithFilter(ft, filter, false);
}
@Test
@@ -263,14 +283,10 @@
FeatureType ft = this.dataStore.getSchema(testData.getTempTableName());
// Build the filter
- double minx = 106.6337;
- double maxx = 106.6381;
- double miny = -6.1794;
- double maxy = -6.1727;
- Polygon p = buildPolygon(minx, miny, maxx, maxy);
+ Polygon p = buildPolygon(-10, -10, -8, -8);
Filter filter = ff.overlaps(ff.property("SHAPE"), ff.literal(p));
- runTestWithFilter(ft, filter);
+ runTestWithFilter(ft, filter, false);
}
@Test
@@ -278,14 +294,16 @@
FeatureType ft = this.dataStore.getSchema(testData.getTempTableName());
// Build the filter
- double minx = 106.6337;
- double maxx = 106.6381;
- double miny = -6.1794;
- double maxy = -6.1727;
- Polygon p = buildPolygon(minx, miny, maxx, maxy);
- Filter filter = ff.within(ff.property("SHAPE"), ff.literal(p));
+ Polygon p = buildPolygon(-9, -9, -8, -8);
+ Filter filter = ff.within(ff.literal(p), ff.property("SHAPE"));
+ runTestWithFilter(ft, filter, false);
+
+ // now build the opposite filter, the polygon contains the shape
+ p = buildPolygon(-1, -1, 1, 1);
+ filter = ff.within(ff.property("SHAPE"), ff.literal(p));
+ runTestWithFilter(ft, filter, false);
- runTestWithFilter(ft, filter);
+ runTestWithFilter(ft, filter, false);
}
@Test
@@ -293,14 +311,10 @@
FeatureType ft = this.dataStore.getSchema(testData.getTempTableName());
// Build the filter
- double minx = 106.6337;
- double maxx = 106.6381;
- double miny = -6.1794;
- double maxy = -6.1727;
- LineString ls = buildSegment(minx, miny, maxx, maxy);
+ LineString ls = buildSegment(-12, -12, 12, 12);
Filter filter = ff.crosses(ff.property("SHAPE"), ff.literal(ls));
- runTestWithFilter(ft, filter);
+ runTestWithFilter(ft, filter, false);
}
/**
@@ -325,10 +339,10 @@
// Build the filter
Filter filter = ff.equal(ff.property("SHAPE"), ff.literal(g));
- runTestWithFilter(ft, filter);
+ runTestWithFilter(ft, filter, false);
}
- private void runTestWithFilter(FeatureType ft, Filter filter) throws Exception {
+ private void runTestWithFilter(FeatureType ft, Filter filter, boolean empty) throws Exception {
System.err.println("****************");
System.err.println("**");
System.err.println("** TESTING FILTER: " + filter);
@@ -364,8 +378,15 @@
fr.close();
endTime = System.currentTimeMillis();
System.err.println("Fast read took " + (endTime - startTime) + " milliseconds.");
+
+ assertFeatureListsSimilar(slowResults, fastResults);
+
+ if(empty) {
+ assertEquals("Result was supposed to be empty", 0, fastResults.size());
+ } else {
+ assertTrue("Result was supposed to be non empty", fastResults.size() > 0);
+ }
- assertFeatureListsSimilar(slowResults, fastResults);
}
private String[] safePropertyNames(FeatureType ft) {
Modified: branches/2.7.x/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/data/TestData.java
===================================================================
--- branches/2.7.x/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/data/TestData.java 2012-02-29 15:37:37 UTC (rev 38588)
+++ branches/2.7.x/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/data/TestData.java 2012-02-29 15:44:21 UTC (rev 38589)
@@ -556,13 +556,13 @@
* <li>7. Shape - values:
* <ul>
* <li> <code>POINT(0 0)</code>
- * <li> <code>MULTIPOINT(0 0, 180 0)</code>
- * <li> <code>LINESTRING(0 0, 180 90)</code>
- * <li> <code>MULTILINESTRING((-180 -90, 180 90), (-180 90, 180 -90))</code>
+ * <li> <code>MULTIPOINT(0 0, 170 0)</code>
+ * <li> <code>LINESTRING(0 0, 170 80)</code>
+ * <li> <code>"MULTILINESTRING((-170 -80, 170 80), (-170 80, 170 -80))"</code>
* <li> <code>POLYGON((-10 -10, -10 10, 10 10, 10 -10, -10 -10))</code>
* <li>
- * <code>MULTIPOLYGON( ((-1 -1, -1 1, 1 1, 1 -1, -1 -1)), ((-180 -90, -180 -80, -170 -80, -170 -90, -180 -90)) )</code>
- * <li> <code>GEOMETRYCOLLECTION(POINT(1 1), LINESTRING(0 0, 180 90))</code>
+ * <code>MULTIPOLYGON( "MULTIPOLYGON( ((-1 -1, -1 1, 1 1, 1 -1, -1 -1)), ((-170 -80, -170 -70, -160 -70, -160 -80, -170 -80)) )" )</code>
+ * <li> <code>POINT EMPTY</code>
* <li> <code>null</code>
* </ul>
* </li>
|
|
From: <svn...@os...> - 2012-02-29 15:37:43
|
Author: groldan
Date: 2012-02-29 07:37:37 -0800 (Wed, 29 Feb 2012)
New Revision: 38588
Modified:
trunk/modules/plugin/arcsde/sde-dummy/src/main/java/com/esri/sde/sdk/client/SeDBMSInfo.java
Log:
add missing dummy constant in SeDBMSInfo
Modified: trunk/modules/plugin/arcsde/sde-dummy/src/main/java/com/esri/sde/sdk/client/SeDBMSInfo.java
===================================================================
--- trunk/modules/plugin/arcsde/sde-dummy/src/main/java/com/esri/sde/sdk/client/SeDBMSInfo.java 2012-02-29 15:37:03 UTC (rev 38587)
+++ trunk/modules/plugin/arcsde/sde-dummy/src/main/java/com/esri/sde/sdk/client/SeDBMSInfo.java 2012-02-29 15:37:37 UTC (rev 38588)
@@ -8,6 +8,7 @@
public class SeDBMSInfo {
public static int SE_DBMS_IS_SQLSERVER = 0;
+ public static int SE_DBMS_IS_ORACLE = 1;
public int dbmsId;
}
|
|
From: <svn...@os...> - 2012-02-29 15:37:14
|
Author: groldan
Date: 2012-02-29 07:37:03 -0800 (Wed, 29 Feb 2012)
New Revision: 38587
Modified:
trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEQuery.java
trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/filter/FilterToSQLSDE.java
Log:
always qualify attribute names, versioned layers may be doing internal joins and fail otherwise
Modified: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEQuery.java
===================================================================
--- trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEQuery.java 2012-02-29 15:36:27 UTC (rev 38586)
+++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEQuery.java 2012-02-29 15:37:03 UTC (rev 38587)
@@ -575,11 +575,16 @@
final SimpleFeatureType schema = this.schema;
final String colName;
- if (fidReader.getFidColumn() == null) {
- colName = schema.getDescriptor(0).getLocalName();
- } else {
- colName = fidReader.getFidColumn();
+ {
+ String fidAtt;
+ if (fidReader.getFidColumn() == null) {
+ fidAtt = schema.getDescriptor(0).getLocalName();
+ } else {
+ fidAtt = fidReader.getFidColumn();
+ }
+ colName = filters.getSqlEncoder().getColumnDefinition(fidAtt);
}
+
final SeQueryInfo qInfo = filters.getQueryInfo(new String[] { colName });
final SeFilter[] spatialFilters = filters.getSpatialFilters();
@@ -589,6 +594,8 @@
public Integer execute(ISession session, SeConnection connection) throws SeException,
IOException {
+ final SeQueryInfo queryInfo = qInfo;
+
SeQuery query = new SeQuery(connection);
try {
@@ -616,7 +623,7 @@
*/
}
- query.prepareQueryInfo(qInfo);
+ query.prepareQueryInfo(queryInfo);
query.execute();
int count = 0;
while (query.fetch() != null) {
@@ -628,7 +635,7 @@
final int defaultMaxDistinctValues = 0;
final SeTable.SeTableStats tableStats;
tableStats = query.calculateTableStatistics(colName,
- SeTable.SeTableStats.SE_COUNT_STATS, qInfo, defaultMaxDistinctValues);
+ SeTable.SeTableStats.SE_COUNT_STATS, queryInfo, defaultMaxDistinctValues);
int actualCount = tableStats.getCount();
return new Integer(actualCount);
@@ -657,7 +664,13 @@
public SeExtent execute(ISession session, SeConnection connection)
throws SeException, IOException {
- final String[] spatialCol = { schema.getGeometryDescriptor().getLocalName() };
+ final String[] spatialCol;
+ {
+ String geomCol = schema.getGeometryDescriptor().getLocalName();
+ geomCol = filters.getSqlEncoder().getColumnDefinition(geomCol);
+ spatialCol = new String[] { geomCol };
+ }
+
// fullConstruct may hold information about multiple tables in case of an
// in-process view
final SeSqlConstruct fullConstruct = filters.getQueryInfo(spatialCol)
Modified: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/filter/FilterToSQLSDE.java
===================================================================
--- trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/filter/FilterToSQLSDE.java 2012-02-29 15:36:27 UTC (rev 38586)
+++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/filter/FilterToSQLSDE.java 2012-02-29 15:37:03 UTC (rev 38587)
@@ -233,10 +233,8 @@
return unused;
}
- String fidField = layerFidFieldName;
-
try {
- String sql = buildFilter(fids, fidField + " IN(", ")", ",", 1000, " OR ");
+ String sql = buildFidFilter(fids, layerFidFieldName, " IN(", ")", ",", 1000, " OR ");
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.finer("added fid filter: " + sql);
@@ -250,16 +248,20 @@
}
// return a string
- private String buildFilter(long[] fids, String prefix, String suffix, String separator,
- int groupSize, String groupSeparator) {
+ private String buildFidFilter(long[] fids, String fidAttribute, String prefix, String suffix,
+ String separator, int groupSize, String groupSeparator) {
final int count = fids.length;
final int groups = count / groupSize;
final int remainder = count % groupSize;
final StringBuilder sql = new StringBuilder();
+
+ final String encodedFidAttribute = getColumnDefinition(fidAttribute);
+
for (int i = 0; i < groups; i++) {
if (i > 0) {
sql.append(groupSeparator);
}
+ sql.append(encodedFidAttribute);
sql.append(prefix);
addSubList(sql, fids, i * groupSize, (i + 1) * groupSize, separator);
sql.append(suffix);
@@ -268,6 +270,7 @@
if (groups > 0) {
sql.append(groupSeparator);
}
+ sql.append(encodedFidAttribute);
sql.append(prefix);
addSubList(sql, fids, count - remainder, count, separator);
sql.append(suffix);
|
|
From: <svn...@os...> - 2012-02-29 15:36:39
|
Author: groldan
Date: 2012-02-29 07:36:27 -0800 (Wed, 29 Feb 2012)
New Revision: 38586
Modified:
trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEQuery.java
Log:
workaround for arcsde+oracle+versioned layers error when calculating table statistics
Modified: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEQuery.java
===================================================================
--- trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEQuery.java 2012-02-29 15:35:47 UTC (rev 38585)
+++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEQuery.java 2012-02-29 15:36:27 UTC (rev 38586)
@@ -60,6 +60,7 @@
import org.opengis.filter.sort.SortOrder;
import com.esri.sde.sdk.client.SeConnection;
+import com.esri.sde.sdk.client.SeDBMSInfo;
import com.esri.sde.sdk.client.SeException;
import com.esri.sde.sdk.client.SeExtent;
import com.esri.sde.sdk.client.SeFilter;
@@ -489,7 +490,8 @@
* Convenient method to just calculate the result count of a given query.
*/
public static int calculateResultCount(final ISession session, final FeatureTypeInfo typeInfo,
- final Query query, final ArcSdeVersionHandler versioningHandler) throws IOException {
+ final Query query, final ArcSdeVersionHandler versioningHandler) throws IOException,
+ UnsupportedOperationException {
ArcSDEQuery countQuery = null;
final int count;
@@ -568,17 +570,15 @@
* the result is traversed counting the number of rows inside a while loop
*
*/
- public int calculateResultCount() throws IOException {
+ public int calculateResultCount() throws IOException, UnsupportedOperationException {
final SimpleFeatureType schema = this.schema;
- final GeometryDescriptor geometryDescriptor = schema.getGeometryDescriptor();
final String colName;
- if (geometryDescriptor == null) {
- // gemetryless type, use any other column for the query
+ if (fidReader.getFidColumn() == null) {
colName = schema.getDescriptor(0).getLocalName();
} else {
- colName = geometryDescriptor.getLocalName();
+ colName = fidReader.getFidColumn();
}
final SeQueryInfo qInfo = filters.getQueryInfo(new String[] { colName });
@@ -590,15 +590,45 @@
IOException {
SeQuery query = new SeQuery(connection);
+
try {
versioningHandler.setUpStream(session, query);
if (spatialFilters != null && spatialFilters.length > 0) {
- query.setSpatialConstraints(SeQuery.SE_OPTIMIZE, true, spatialFilters);
+
+ final boolean calcMasks = true;// use the spatial query to calculate
+ // statistics.
+ final short searchOrder = SeQuery.SE_OPTIMIZE;
+ query.setSpatialConstraints(searchOrder, calcMasks, spatialFilters);
+
+ final SeDBMSInfo dbmsInfo = connection.getDBMSInfo();
+ final boolean unsupported = versioningHandler != ArcSdeVersionHandler.NONVERSIONED_HANDLER
+ && dbmsInfo.dbmsId == SeDBMSInfo.SE_DBMS_IS_ORACLE;
+
+ if (unsupported) {
+ LOGGER.fine("ArcSDE on Oracle can't calculate count statistics "
+ + "on versioned layers with spatial filters");
+ /*
+ * Despite the FeatureSource.getCount() contract saying it's ok to
+ * return -1 if count is too expensive to calculate, the GeoServer
+ * codebase is plagued of FeatureCollection.size() calls depending on
+ * actual result counts or some operations don't work at all. return -1;
+ */
+ }
+
+ query.prepareQueryInfo(qInfo);
+ query.execute();
+ int count = 0;
+ while (query.fetch() != null) {
+ count++;
+ }
+ return count;
}
- SeTable.SeTableStats tableStats = query.calculateTableStatistics("*",
- SeTable.SeTableStats.SE_COUNT_STATS, qInfo, 0);
+ final int defaultMaxDistinctValues = 0;
+ final SeTable.SeTableStats tableStats;
+ tableStats = query.calculateTableStatistics(colName,
+ SeTable.SeTableStats.SE_COUNT_STATS, qInfo, defaultMaxDistinctValues);
int actualCount = tableStats.getCount();
return new Integer(actualCount);
@@ -828,8 +858,8 @@
* @author $author$
*
*
- *
- * @source $URL$
+ *
+ * @source $URL$
* http://svn.osgeo.org/geotools/trunk/modules/plugin/arcsde/datastore/src/main/java
* /org/geotools/arcsde/data/ArcSDEQuery.java $
* @version $Revision: 1.9 $
|
|
From: <svn...@os...> - 2012-02-29 15:35:58
|
Author: groldan
Date: 2012-02-29 07:35:47 -0800 (Wed, 29 Feb 2012)
New Revision: 38585
Modified:
branches/2.7.x/modules/plugin/arcsde/sde-dummy/src/main/java/com/esri/sde/sdk/client/SeDBMSInfo.java
Log:
add missing dummy constant in SeDBMSInfo
Modified: branches/2.7.x/modules/plugin/arcsde/sde-dummy/src/main/java/com/esri/sde/sdk/client/SeDBMSInfo.java
===================================================================
--- branches/2.7.x/modules/plugin/arcsde/sde-dummy/src/main/java/com/esri/sde/sdk/client/SeDBMSInfo.java 2012-02-29 15:35:12 UTC (rev 38584)
+++ branches/2.7.x/modules/plugin/arcsde/sde-dummy/src/main/java/com/esri/sde/sdk/client/SeDBMSInfo.java 2012-02-29 15:35:47 UTC (rev 38585)
@@ -3,6 +3,7 @@
public class SeDBMSInfo {
public static int SE_DBMS_IS_SQLSERVER = 0;
+ public static int SE_DBMS_IS_ORACLE = 1;
public int dbmsId;
}
|
|
From: <svn...@os...> - 2012-02-29 15:35:25
|
Author: groldan
Date: 2012-02-29 07:35:12 -0800 (Wed, 29 Feb 2012)
New Revision: 38584
Modified:
branches/2.7.x/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEQuery.java
branches/2.7.x/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/filter/FilterToSQLSDE.java
Log:
always qualify attribute names, versioned layers may be doing internal joins and fail otherwise
Modified: branches/2.7.x/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEQuery.java
===================================================================
--- branches/2.7.x/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEQuery.java 2012-02-29 15:34:33 UTC (rev 38583)
+++ branches/2.7.x/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEQuery.java 2012-02-29 15:35:12 UTC (rev 38584)
@@ -575,11 +575,16 @@
final SimpleFeatureType schema = this.schema;
final String colName;
- if (fidReader.getFidColumn() == null) {
- colName = schema.getDescriptor(0).getLocalName();
- } else {
- colName = fidReader.getFidColumn();
+ {
+ String fidAtt;
+ if (fidReader.getFidColumn() == null) {
+ fidAtt = schema.getDescriptor(0).getLocalName();
+ } else {
+ fidAtt = fidReader.getFidColumn();
+ }
+ colName = filters.getSqlEncoder().getColumnDefinition(fidAtt);
}
+
final SeQueryInfo qInfo = filters.getQueryInfo(new String[] { colName });
final SeFilter[] spatialFilters = filters.getSpatialFilters();
@@ -589,6 +594,8 @@
public Integer execute(ISession session, SeConnection connection) throws SeException,
IOException {
+ final SeQueryInfo queryInfo = qInfo;
+
SeQuery query = new SeQuery(connection);
try {
@@ -616,7 +623,7 @@
*/
}
- query.prepareQueryInfo(qInfo);
+ query.prepareQueryInfo(queryInfo);
query.execute();
int count = 0;
while (query.fetch() != null) {
@@ -628,7 +635,7 @@
final int defaultMaxDistinctValues = 0;
final SeTable.SeTableStats tableStats;
tableStats = query.calculateTableStatistics(colName,
- SeTable.SeTableStats.SE_COUNT_STATS, qInfo, defaultMaxDistinctValues);
+ SeTable.SeTableStats.SE_COUNT_STATS, queryInfo, defaultMaxDistinctValues);
int actualCount = tableStats.getCount();
return new Integer(actualCount);
@@ -657,7 +664,13 @@
public SeExtent execute(ISession session, SeConnection connection)
throws SeException, IOException {
- final String[] spatialCol = { schema.getGeometryDescriptor().getLocalName() };
+ final String[] spatialCol;
+ {
+ String geomCol = schema.getGeometryDescriptor().getLocalName();
+ geomCol = filters.getSqlEncoder().getColumnDefinition(geomCol);
+ spatialCol = new String[] { geomCol };
+ }
+
// fullConstruct may hold information about multiple tables in case of an
// in-process view
final SeSqlConstruct fullConstruct = filters.getQueryInfo(spatialCol)
Modified: branches/2.7.x/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/filter/FilterToSQLSDE.java
===================================================================
--- branches/2.7.x/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/filter/FilterToSQLSDE.java 2012-02-29 15:34:33 UTC (rev 38583)
+++ branches/2.7.x/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/filter/FilterToSQLSDE.java 2012-02-29 15:35:12 UTC (rev 38584)
@@ -232,10 +232,8 @@
return unused;
}
- String fidField = layerFidFieldName;
-
try {
- String sql = buildFilter(fids, fidField + " IN(", ")", ",", 1000, " OR ");
+ String sql = buildFidFilter(fids, layerFidFieldName, " IN(", ")", ",", 1000, " OR ");
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.finer("added fid filter: " + sql);
@@ -249,16 +247,20 @@
}
// return a string
- private String buildFilter(long[] fids, String prefix, String suffix, String separator,
- int groupSize, String groupSeparator) {
+ private String buildFidFilter(long[] fids, String fidAttribute, String prefix, String suffix,
+ String separator, int groupSize, String groupSeparator) {
final int count = fids.length;
final int groups = count / groupSize;
final int remainder = count % groupSize;
final StringBuilder sql = new StringBuilder();
+
+ final String encodedFidAttribute = getColumnDefinition(fidAttribute);
+
for (int i = 0; i < groups; i++) {
if (i > 0) {
sql.append(groupSeparator);
}
+ sql.append(encodedFidAttribute);
sql.append(prefix);
addSubList(sql, fids, i * groupSize, (i + 1) * groupSize, separator);
sql.append(suffix);
@@ -267,6 +269,7 @@
if (groups > 0) {
sql.append(groupSeparator);
}
+ sql.append(encodedFidAttribute);
sql.append(prefix);
addSubList(sql, fids, count - remainder, count, separator);
sql.append(suffix);
|
|
From: <svn...@os...> - 2012-02-29 15:34:45
|
Author: groldan
Date: 2012-02-29 07:34:33 -0800 (Wed, 29 Feb 2012)
New Revision: 38583
Modified:
branches/2.7.x/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEQuery.java
Log:
workaround for arcsde+oracle+versioned layers error when calculating table statistics
Modified: branches/2.7.x/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEQuery.java
===================================================================
--- branches/2.7.x/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEQuery.java 2012-02-29 15:20:37 UTC (rev 38582)
+++ branches/2.7.x/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEQuery.java 2012-02-29 15:34:33 UTC (rev 38583)
@@ -60,6 +60,7 @@
import org.opengis.filter.sort.SortOrder;
import com.esri.sde.sdk.client.SeConnection;
+import com.esri.sde.sdk.client.SeDBMSInfo;
import com.esri.sde.sdk.client.SeException;
import com.esri.sde.sdk.client.SeExtent;
import com.esri.sde.sdk.client.SeFilter;
@@ -489,7 +490,8 @@
* Convenient method to just calculate the result count of a given query.
*/
public static int calculateResultCount(final ISession session, final FeatureTypeInfo typeInfo,
- final Query query, final ArcSdeVersionHandler versioningHandler) throws IOException {
+ final Query query, final ArcSdeVersionHandler versioningHandler) throws IOException,
+ UnsupportedOperationException {
ArcSDEQuery countQuery = null;
final int count;
@@ -568,17 +570,15 @@
* the result is traversed counting the number of rows inside a while loop
*
*/
- public int calculateResultCount() throws IOException {
+ public int calculateResultCount() throws IOException, UnsupportedOperationException {
final SimpleFeatureType schema = this.schema;
- final GeometryDescriptor geometryDescriptor = schema.getGeometryDescriptor();
final String colName;
- if (geometryDescriptor == null) {
- // gemetryless type, use any other column for the query
+ if (fidReader.getFidColumn() == null) {
colName = schema.getDescriptor(0).getLocalName();
} else {
- colName = geometryDescriptor.getLocalName();
+ colName = fidReader.getFidColumn();
}
final SeQueryInfo qInfo = filters.getQueryInfo(new String[] { colName });
@@ -590,15 +590,45 @@
IOException {
SeQuery query = new SeQuery(connection);
+
try {
versioningHandler.setUpStream(session, query);
if (spatialFilters != null && spatialFilters.length > 0) {
- query.setSpatialConstraints(SeQuery.SE_OPTIMIZE, true, spatialFilters);
+
+ final boolean calcMasks = true;// use the spatial query to calculate
+ // statistics.
+ final short searchOrder = SeQuery.SE_OPTIMIZE;
+ query.setSpatialConstraints(searchOrder, calcMasks, spatialFilters);
+
+ final SeDBMSInfo dbmsInfo = connection.getDBMSInfo();
+ final boolean unsupported = versioningHandler != ArcSdeVersionHandler.NONVERSIONED_HANDLER
+ && dbmsInfo.dbmsId == SeDBMSInfo.SE_DBMS_IS_ORACLE;
+
+ if (unsupported) {
+ LOGGER.fine("ArcSDE on Oracle can't calculate count statistics "
+ + "on versioned layers with spatial filters");
+ /*
+ * Despite the FeatureSource.getCount() contract saying it's ok to
+ * return -1 if count is too expensive to calculate, the GeoServer
+ * codebase is plagued of FeatureCollection.size() calls depending on
+ * actual result counts or some operations don't work at all. return -1;
+ */
+ }
+
+ query.prepareQueryInfo(qInfo);
+ query.execute();
+ int count = 0;
+ while (query.fetch() != null) {
+ count++;
+ }
+ return count;
}
- SeTable.SeTableStats tableStats = query.calculateTableStatistics("*",
- SeTable.SeTableStats.SE_COUNT_STATS, qInfo, 0);
+ final int defaultMaxDistinctValues = 0;
+ final SeTable.SeTableStats tableStats;
+ tableStats = query.calculateTableStatistics(colName,
+ SeTable.SeTableStats.SE_COUNT_STATS, qInfo, defaultMaxDistinctValues);
int actualCount = tableStats.getCount();
return new Integer(actualCount);
@@ -828,6 +858,7 @@
* @author $author$
*
*
+ *
* @source $URL$
* http://svn.osgeo.org/geotools/trunk/modules/plugin/arcsde/datastore/src/main/java
* /org/geotools/arcsde/data/ArcSDEQuery.java $
|
|
From: <svn...@os...> - 2012-02-29 15:20:48
|
Author: groldan
Date: 2012-02-29 07:20:37 -0800 (Wed, 29 Feb 2012)
New Revision: 38582
Modified:
trunk/modules/unsupported/wfs/pom.xml
trunk/modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_1_0/parsers/XmlSimpleFeatureParser.java
trunk/pom.xml
Log:
use xpp3_min instead of the full xpp3 dependency in wfs. The later has a QName class that conflicts with the one in the JDK
Modified: trunk/modules/unsupported/wfs/pom.xml
===================================================================
--- trunk/modules/unsupported/wfs/pom.xml 2012-02-29 15:18:45 UTC (rev 38581)
+++ trunk/modules/unsupported/wfs/pom.xml 2012-02-29 15:20:37 UTC (rev 38582)
@@ -113,7 +113,7 @@
</dependency>
<dependency>
<groupId>xpp3</groupId>
- <artifactId>xpp3</artifactId>
+ <artifactId>xpp3_min</artifactId>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
Modified: trunk/modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_1_0/parsers/XmlSimpleFeatureParser.java
===================================================================
--- trunk/modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_1_0/parsers/XmlSimpleFeatureParser.java 2012-02-29 15:18:45 UTC (rev 38581)
+++ trunk/modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_1_0/parsers/XmlSimpleFeatureParser.java 2012-02-29 15:20:37 UTC (rev 38582)
@@ -45,9 +45,9 @@
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.NoSuchAuthorityCodeException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.xmlpull.mxp1.MXParser;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
-import org.xmlpull.v1.XmlPullParserFactory;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
@@ -104,14 +104,10 @@
this.targetType = targetType;
this.builder = new SimpleFeatureBuilder(targetType);
- XmlPullParserFactory factory;
try {
- factory = XmlPullParserFactory.newInstance();
- factory.setNamespaceAware(true);
- factory.setValidating(false);
-
// parse root element
- parser = factory.newPullParser();
+ parser = new MXParser();
+ parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
parser.setInput(inputStream, "UTF-8");
parser.nextTag();
parser.require(XmlPullParser.START_TAG, WFS.NAMESPACE, WFS.FeatureCollection
@@ -551,7 +547,7 @@
parser.nextTag();
tagName = parser.getName();
eventType = parser.getEventType();
- } while (eventType == XmlPullParser.START_TAG && tagName == GML.pos.getLocalPart());
+ } while (eventType == XmlPullParser.START_TAG && GML.pos.getLocalPart().equals(tagName));
shellCoords = coords.toArray(new Coordinate[coords.size()]);
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-02-29 15:18:45 UTC (rev 38581)
+++ trunk/pom.xml 2012-02-29 15:20:37 UTC (rev 38582)
@@ -904,6 +904,11 @@
<artifactId>xpp3</artifactId>
<version>1.1.3.4.O</version>
</dependency>
+ <dependency>
+ <groupId>xpp3</groupId>
+ <artifactId>xpp3_min</artifactId>
+ <version>1.1.4c</version>
+ </dependency>
<!-- Databases -->
<dependency>
|
|
From: <svn...@os...> - 2012-02-29 15:18:57
|
Author: groldan
Date: 2012-02-29 07:18:45 -0800 (Wed, 29 Feb 2012)
New Revision: 38581
Modified:
branches/2.7.x/modules/unsupported/wfs/pom.xml
branches/2.7.x/modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_1_0/parsers/XmlSimpleFeatureParser.java
branches/2.7.x/pom.xml
Log:
use xpp3_min instead of the full xpp3 dependency in wfs. The later has a QName class that conflicts with the one in the JDK
Modified: branches/2.7.x/modules/unsupported/wfs/pom.xml
===================================================================
--- branches/2.7.x/modules/unsupported/wfs/pom.xml 2012-02-29 08:07:52 UTC (rev 38580)
+++ branches/2.7.x/modules/unsupported/wfs/pom.xml 2012-02-29 15:18:45 UTC (rev 38581)
@@ -113,7 +113,7 @@
</dependency>
<dependency>
<groupId>xpp3</groupId>
- <artifactId>xpp3</artifactId>
+ <artifactId>xpp3_min</artifactId>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
Modified: branches/2.7.x/modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_1_0/parsers/XmlSimpleFeatureParser.java
===================================================================
--- branches/2.7.x/modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_1_0/parsers/XmlSimpleFeatureParser.java 2012-02-29 08:07:52 UTC (rev 38580)
+++ branches/2.7.x/modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_1_0/parsers/XmlSimpleFeatureParser.java 2012-02-29 15:18:45 UTC (rev 38581)
@@ -45,9 +45,9 @@
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.NoSuchAuthorityCodeException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.xmlpull.mxp1.MXParser;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
-import org.xmlpull.v1.XmlPullParserFactory;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
@@ -102,14 +102,10 @@
this.targetType = targetType;
this.builder = new SimpleFeatureBuilder(targetType);
- XmlPullParserFactory factory;
try {
- factory = XmlPullParserFactory.newInstance();
- factory.setNamespaceAware(true);
- factory.setValidating(false);
-
// parse root element
- parser = factory.newPullParser();
+ parser = new MXParser();
+ parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
parser.setInput(inputStream, "UTF-8");
parser.nextTag();
parser.require(XmlPullParser.START_TAG, WFS.NAMESPACE, WFS.FeatureCollection
@@ -549,7 +545,7 @@
parser.nextTag();
tagName = parser.getName();
eventType = parser.getEventType();
- } while (eventType == XmlPullParser.START_TAG && tagName == GML.pos.getLocalPart());
+ } while (eventType == XmlPullParser.START_TAG && GML.pos.getLocalPart().equals(tagName));
shellCoords = coords.toArray(new Coordinate[coords.size()]);
Modified: branches/2.7.x/pom.xml
===================================================================
--- branches/2.7.x/pom.xml 2012-02-29 08:07:52 UTC (rev 38580)
+++ branches/2.7.x/pom.xml 2012-02-29 15:18:45 UTC (rev 38581)
@@ -825,6 +825,11 @@
<artifactId>xpp3</artifactId>
<version>1.1.3.4.O</version>
</dependency>
+ <dependency>
+ <groupId>xpp3</groupId>
+ <artifactId>xpp3_min</artifactId>
+ <version>1.1.4c</version>
+ </dependency>
<!-- Databases -->
<dependency>
|
|
From: <svn...@os...> - 2012-02-29 08:08:04
|
Author: jive
Date: 2012-02-29 00:07:52 -0800 (Wed, 29 Feb 2012)
New Revision: 38580
Added:
trunk/modules/unsupported/process-feature/src/main/java/org/geotools/process/feature/gs/ReShapeProcess.java
Modified:
trunk/modules/unsupported/process-feature/src/main/java/org/geotools/process/feature/gs/FeatureGSProcessFactory.java
Log:
port reshape from udig
Modified: trunk/modules/unsupported/process-feature/src/main/java/org/geotools/process/feature/gs/FeatureGSProcessFactory.java
===================================================================
--- trunk/modules/unsupported/process-feature/src/main/java/org/geotools/process/feature/gs/FeatureGSProcessFactory.java 2012-02-29 02:41:35 UTC (rev 38579)
+++ trunk/modules/unsupported/process-feature/src/main/java/org/geotools/process/feature/gs/FeatureGSProcessFactory.java 2012-02-29 08:07:52 UTC (rev 38580)
@@ -58,7 +58,8 @@
SnapProcess.class,
UnionFeatureCollection.class,
UniqueProcess.class,
- VectorZonalStatistics.class);
+ VectorZonalStatistics.class,
+ ReShapeProcess.class);
}
}
Added: trunk/modules/unsupported/process-feature/src/main/java/org/geotools/process/feature/gs/ReShapeProcess.java
===================================================================
--- trunk/modules/unsupported/process-feature/src/main/java/org/geotools/process/feature/gs/ReShapeProcess.java (rev 0)
+++ trunk/modules/unsupported/process-feature/src/main/java/org/geotools/process/feature/gs/ReShapeProcess.java 2012-02-29 08:07:52 UTC (rev 38580)
@@ -0,0 +1,306 @@
+/*
+ * GeoTools - The Open Source Java GIS Toolkit
+ * http://geotools.org
+ *
+ * (C) 2011, Open Source Geospatial Foundation (OSGeo)
+ * (C) 2007-2011 Refractions Research
+ *
+ * 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.process.feature.gs;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+import org.geotools.data.simple.SimpleFeatureCollection;
+import org.geotools.data.simple.SimpleFeatureIterator;
+import org.geotools.feature.collection.DecoratingSimpleFeatureCollection;
+import org.geotools.feature.simple.SimpleFeatureBuilder;
+import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
+import org.geotools.filter.text.cql2.CQL;
+import org.geotools.filter.text.cql2.CQLException;
+import org.geotools.filter.text.ecql.ECQL;
+import org.geotools.process.ProcessException;
+import org.geotools.process.factory.DescribeParameter;
+import org.geotools.process.factory.DescribeProcess;
+import org.geotools.process.factory.DescribeResult;
+import org.geotools.process.gs.GSProcess;
+import org.geotools.process.gs.WrappingIterator;
+import org.opengis.feature.simple.SimpleFeature;
+import org.opengis.feature.simple.SimpleFeatureType;
+import org.opengis.feature.type.AttributeDescriptor;
+import org.opengis.feature.type.AttributeType;
+import org.opengis.feature.type.GeometryType;
+import org.opengis.filter.expression.Expression;
+import org.opengis.filter.expression.PropertyName;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+
+import com.vividsolutions.jts.geom.Geometry;
+import com.vividsolutions.jts.simplify.DouglasPeuckerSimplifier;
+import com.vividsolutions.jts.simplify.TopologyPreservingSimplifier;
+
+/**
+ * Used to reshape a feature collection as defined using a series of expressions.
+ * <p>
+ * This is a port of the uDig Reshape operation to the GeoTools process framework.
+ * <p>
+ * This is a very flexable process which can be used to:
+ * <ul>
+ * <li>Change the order of attribtues - resulting in a new feature type</li>
+ * <li>Rename attribtues - resulting in a new feature type</li>
+ * <li>Process geometry - using functions like "the_geom=simplify( the_geom, 2.0 )" or "the_geom=centriod( the_geom )"</li>
+ * <li>Generate additional attribtues using the form: area=area( the_geom )</li>
+ * </ul>
+ * <p>
+ * The definition of the output feature type can be provided as a data structure or using a simple string format:
+ *
+ * <pre>
+ * the_geom=the_geom
+ * name=name
+ * area=area( the_geom )
+ * </pre>
+ *
+ * @author Jody Garnett (LISAsoft)
+ *
+ * @source $URL$
+ */
+@DescribeProcess(title = "simplify", description = "Simplifies the geometry")
+public class ReShapeProcess implements GSProcess {
+ /**
+ * Definition of an attribute used during reshape.
+ * <p>
+ * Note this definition is terse as we are gathering the details from the origional FeatureType.
+ *
+ * @author jody
+ */
+ public static class Definition {
+ /** Name of the AttribtueDescriptor to generate */
+ public String name;
+
+ /** Expression used to generate the target calue; most simply a PropertyName */
+ public Expression expression;
+
+ /** Class binding (if known) */
+ public Class<?> binding;
+ }
+ @DescribeResult(name = "result", description = "rehaped feature collection")
+ public SimpleFeatureCollection execute(
+ @DescribeParameter(name = "features", description = "The feature collection to rehaped") SimpleFeatureCollection features,
+ @DescribeParameter(name = "definition", description = "Definition of output feature type using attribute=expr pairs") String definition)
+ throws ProcessException {
+ if (definition == null) {
+ return features; // no change
+ }
+ List<Definition> list = toDefinition(definition);
+ return executeList(features, list);
+ }
+
+ @DescribeResult(name = "result", description = "rehaped feature collection")
+ public SimpleFeatureCollection executeList(
+ @DescribeParameter(name = "features", description = "The feature collection to rehaped") SimpleFeatureCollection features,
+ @DescribeParameter(name = "list", description = "List of Definitions for the output feature type") List<Definition> list)
+ throws ProcessException {
+ if (list == null) {
+ return features; // no change
+ }
+ return new ReshapeFeatureCollection(features, list);
+ }
+
+
+ //
+ // helper methods made static for ease of JUnit testing
+ //
+
+ /**
+ * Parse out a list of {@link Definition} from the provided text description.
+ * <p>
+ * The format expected here is one definition per line; using the format "name=...expression..".
+ *
+ * @param definition
+ * @return List of definition
+ */
+ public static List<Definition> toDefinition(String definition) {
+ List<Definition> list = new ArrayList<Definition>();
+ HashSet<String> check = new HashSet<String>();
+
+ // clean up cross platform differences of line feed
+ definition = definition.replaceAll("\r", "\n").replaceAll("[\n\r][\n\r]", "\n");
+
+ for (String line : definition.split("\n")) {
+ int mark = line.indexOf("=");
+ if (mark != -1) {
+ String name = line.substring(0, mark).trim();
+ String expressionDefinition = line.substring(mark + 1).trim();
+
+ if (check.contains(name)) {
+ throw new IllegalArgumentException("ReShape definition " + name
+ + " already in use");
+ }
+ Expression expression;
+ try {
+ expression = ECQL.toExpression(expressionDefinition);
+ } catch (CQLException e) {
+ throw new IllegalArgumentException("Reshape unable to parse " + name + "="
+ + expressionDefinition + " " + e, e);
+ }
+ Definition def = new Definition();
+ def.name = name;
+ def.expression = expression;
+ list.add(def);
+ check.add(name); // to catch duplicates!
+ }
+ }
+ return list;
+ }
+
+ public static SimpleFeatureType toReShapeFeatureType(SimpleFeatureCollection delegate,
+ List<Definition> definitionList) {
+
+ SimpleFeature sample = null;
+ SimpleFeatureIterator iterator = delegate.features();
+ try {
+ if( iterator.hasNext() ){
+ sample = iterator.next();
+ }
+ }
+ finally {
+ iterator.close(); // good bye
+ }
+
+ SimpleFeatureTypeBuilder build = new SimpleFeatureTypeBuilder();
+ SimpleFeatureType origional = delegate.getSchema();
+
+ for( Definition def : definitionList ){
+ String name = def.name;
+ Expression expression = def.expression;
+
+ Object value = null;
+ if( sample != null ){
+ value = expression.evaluate(sample);
+ }
+ Class<?> binding = def.binding; // make use of any default binding hint provided by user
+ if( value == null){
+ if( expression instanceof PropertyName){
+ PropertyName propertyName = (PropertyName)expression;
+ String path = propertyName.getPropertyName();
+ AttributeDescriptor descriptor = origional.getDescriptor( name );
+ AttributeType attributeType = descriptor.getType();
+ binding = attributeType.getBinding();
+ }
+ } else {
+ binding = value.getClass();
+ }
+
+ if( binding ==null ){
+ // note we could consider scanning through additional samples until we get a non null hit
+ throw new IllegalArgumentException("Unable to determine type for "+name);
+ }
+
+ if( Geometry.class.isAssignableFrom( binding )){
+ CoordinateReferenceSystem crs;
+ AttributeType originalAttributeType = origional.getType(name);
+ if( originalAttributeType != null && originalAttributeType instanceof GeometryType ) {
+ GeometryType geometryType = (GeometryType)originalAttributeType;
+ crs = geometryType.getCoordinateReferenceSystem();
+ } else {
+ crs = origional.getCoordinateReferenceSystem();
+ }
+ build.crs(crs);
+ build.add(name, binding);
+ }
+ else {
+ build.add(name, binding);
+ }
+ }
+ build.setName( origional.getTypeName() );
+ return build.buildFeatureType();
+ }
+
+ //
+ // helper classes responsible for most of the work
+ //
+
+ /**
+ * ReshapeFeatureCollection obtaining feature type by processing the list of definitions
+ * against the origional delegate feature collection.
+ * @author jody
+ */
+ static class ReshapeFeatureCollection extends DecoratingSimpleFeatureCollection {
+ List<Definition> definition;
+ SimpleFeatureType schema;
+
+ public ReshapeFeatureCollection(SimpleFeatureCollection delegate, List<Definition> definition) {
+ super(delegate);
+ this.definition = definition;
+ this.schema = toReShapeFeatureType( delegate, definition );
+ }
+
+ @Override
+ public SimpleFeatureIterator features() {
+ return new ReshapeFeatureIterator(delegate.features(), definition, schema);
+ }
+
+ @Override
+ public Iterator<SimpleFeature> iterator() {
+ return new WrappingIterator(features());
+ }
+
+ @Override
+ public void close(Iterator<SimpleFeature> close) {
+ if (close instanceof WrappingIterator) {
+ ((WrappingIterator) close).close();
+ }
+ }
+ }
+ /**
+ * Process one feature at time; obtaining values by evaulating the provided list of definitions.
+ *
+ * @author jody
+ */
+ static class ReshapeFeatureIterator implements SimpleFeatureIterator {
+ SimpleFeatureIterator delegate;
+
+ List<Definition> definition;
+
+ SimpleFeatureBuilder fb;
+
+ public ReshapeFeatureIterator(SimpleFeatureIterator delegate, List<Definition> definition,
+ SimpleFeatureType schema) {
+ this.delegate = delegate;
+ this.definition = definition;
+ fb = new SimpleFeatureBuilder(schema);
+ }
+
+ public void close() {
+ delegate.close();
+ }
+
+ public boolean hasNext() {
+ return delegate.hasNext();
+ }
+
+ public SimpleFeature next() throws NoSuchElementException {
+ SimpleFeature feature = delegate.next();
+
+ for( Definition def : definition ){
+ Object value = def.expression.evaluate(feature);
+ fb.add( value );
+ }
+ SimpleFeature created = fb.buildFeature(feature.getID());
+ return created;
+ }
+
+ }
+
+}
Property changes on: trunk/modules/unsupported/process-feature/src/main/java/org/geotools/process/feature/gs/ReShapeProcess.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
|
|
From: <svn...@os...> - 2012-02-29 02:41:42
|
Author: jdeolive
Date: 2012-02-28 18:41:35 -0800 (Tue, 28 Feb 2012)
New Revision: 38579
Modified:
branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/SQLDialect.java
Log:
GEOT-3609, applying patch for 2.7.x with numeric values to avioid compilation errors
Modified: branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/SQLDialect.java
===================================================================
--- branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/SQLDialect.java 2012-02-28 04:48:20 UTC (rev 38578)
+++ branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/SQLDialect.java 2012-02-29 02:41:35 UTC (rev 38579)
@@ -264,6 +264,8 @@
mappings.put(new Integer(Types.VARCHAR), String.class);
mappings.put(new Integer(Types.CHAR), String.class);
mappings.put(new Integer(Types.LONGVARCHAR), String.class);
+ mappings.put(new Integer(-9), String.class);
+ mappings.put(new Integer(-15), String.class);
mappings.put(new Integer(Types.BIT), Boolean.class);
mappings.put(new Integer(Types.BOOLEAN), Boolean.class);
|
|
From: <svn...@os...> - 2012-02-28 04:48:26
|
Author: jive Date: 2012-02-27 20:48:20 -0800 (Mon, 27 Feb 2012) New Revision: 38578 Modified: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/DataAccessDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/DataStoreDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/DefaultVersionedFeatureCollection.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/FeatureLockingDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/FeatureSourceDecorator.java trunk/modules/unsupported/pom.xml Log: Have a quick run at headers; got stuck and need input from mark. Including back in the unsupported -Dall build Modified: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/DataAccessDecorator.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/DataAccessDecorator.java 2012-02-28 04:48:01 UTC (rev 38577) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/DataAccessDecorator.java 2012-02-28 04:48:20 UTC (rev 38578) @@ -2,7 +2,7 @@ * GeoTools - The Open Source Java GIS Toolkit * http://geotools.org * - * (C) 2002-2011, Open Source Geospatial Foundation (OSGeo) + * (C) 2010, 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 @@ -44,6 +44,13 @@ import com.google.common.base.Throwables; +/** + * Decorator around an unversioned DataAccess allowing it to be used in conjunction + * with a GeoGit repository (for revision information). + * + * @param <T> FeatureType + * @param <F> Feature + */ @SuppressWarnings({ "rawtypes", "unchecked" }) public class DataAccessDecorator<T extends FeatureType, F extends Feature> implements VersioningDataAccess<T, F> { Modified: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/DataStoreDecorator.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/DataStoreDecorator.java 2012-02-28 04:48:01 UTC (rev 38577) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/DataStoreDecorator.java 2012-02-28 04:48:20 UTC (rev 38578) @@ -2,8 +2,8 @@ * GeoTools - The Open Source Java GIS Toolkit * http://geotools.org * - * (C) 2002-2011, Open Source Geospatial Foundation (OSGeo) - * + * (C) 2010, 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; Modified: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/DefaultVersionedFeatureCollection.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/DefaultVersionedFeatureCollection.java 2012-02-28 04:48:01 UTC (rev 38577) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/DefaultVersionedFeatureCollection.java 2012-02-28 04:48:20 UTC (rev 38578) @@ -52,6 +52,9 @@ import org.opengis.filter.sort.SortBy; import org.opengis.geometry.BoundingBox; +/** + * SimpleFeatureCollection accessing revision information. + */ public class DefaultVersionedFeatureCollection implements SimpleFeatureCollection { public DefaultVersionedFeatureCollection( Modified: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/FeatureLockingDecorator.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/FeatureLockingDecorator.java 2012-02-28 04:48:01 UTC (rev 38577) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/FeatureLockingDecorator.java 2012-02-28 04:48:20 UTC (rev 38578) @@ -2,7 +2,7 @@ * GeoTools - The Open Source Java GIS Toolkit * http://geotools.org * - * (C) 2002-2011, Open Source Geospatial Foundation (OSGeo) + * (C) 2010, 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 Modified: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/FeatureSourceDecorator.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/FeatureSourceDecorator.java 2012-02-28 04:48:01 UTC (rev 38577) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/FeatureSourceDecorator.java 2012-02-28 04:48:20 UTC (rev 38578) @@ -2,7 +2,7 @@ * GeoTools - The Open Source Java GIS Toolkit * http://geotools.org * - * (C) 2002-2011, Open Source Geospatial Foundation (OSGeo) + * (C) 2010, 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 Modified: trunk/modules/unsupported/pom.xml =================================================================== --- trunk/modules/unsupported/pom.xml 2012-02-28 04:48:01 UTC (rev 38577) +++ trunk/modules/unsupported/pom.xml 2012-02-28 04:48:20 UTC (rev 38578) @@ -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> |
Author: jive Date: 2012-02-27 20:48:01 -0800 (Mon, 27 Feb 2012) New Revision: 38577 Added: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/geogit/ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/geogit/GeoGitDataStore.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/geogit/GeoGitDataStoreFactory.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/geogit/GeoGitFeatureSource.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/geogit/GeoGitFeatureStore.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/geogit/GeoGitSimpleFeatureCollection.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/geogit/GeoToolsCommitStateResolver.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/geogit/ModifyingFeatureCollection.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/geogit/VersioningTransactionState.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/SimpleVersioningFeatureLocking.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/SimpleVersioningFeatureSource.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/SimpleVersioningFeatureStore.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/VersioningDataAccess.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/VersioningDataStore.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/VersioningFeatureLocking.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/VersioningFeatureSource.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/VersioningFeatureStore.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/DataAccessDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/DataStoreDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/DefaultVersionedFeatureCollection.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/FeatureLockingDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/FeatureSourceDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/FeatureStoreDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/QueryFeatureCollector.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/ResourceIdAssigningFeatureCollection.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/ResourceIdFeatureCollector.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/ResourceIdQueryFeatureCollector.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/SimpleFeatureLockingDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/SimpleFeatureSourceDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/SimpleFeatureStoreDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/SimpleResourceIdAssigningFeatureCollection.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/VersionDetail.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/VersionFilters.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/VersionQuery.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/VersionedFeatureWrapper.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geotools/data/versioning/decorator/VersioningAdapterFactory.java Removed: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitDataStore.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitDataStoreFactory.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitFeatureSource.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitFeatureStore.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitSimpleFeatureCollection.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoToolsCommitStateResolver.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/ModifyingFeatureCollection.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/VersioningTransactionState.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/SimpleVersioningFeatureLocking.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/SimpleVersioningFeatureSource.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/SimpleVersioningFeatureStore.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/VersioningDataAccess.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/VersioningDataStore.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/VersioningFeatureLocking.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/VersioningFeatureSource.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/VersioningFeatureStore.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/DataAccessDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/DataStoreDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/DefaultVersionedFeatureCollection.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/FeatureLockingDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/FeatureSourceDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/FeatureStoreDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/QueryFeatureCollector.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/ResourceIdAssigningFeatureCollection.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/ResourceIdFeatureCollector.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/ResourceIdQueryFeatureCollector.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/SimpleFeatureLockingDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/SimpleFeatureSourceDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/SimpleFeatureStoreDecorator.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/SimpleResourceIdAssigningFeatureCollection.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/VersionDetail.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/VersionFilters.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/VersionQuery.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/VersionedFeatureWrapper.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/VersioningAdapterFactory.java Modified: trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/geogit/GeoGitDataStoreTest.java trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/geogit/GeoGitFeatureSourceTest.java trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/geogit/GeoGitFeatureStoreTest.java trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/VersioningTestSupport.java trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/DecoratedTestCase.java Log: Move to org.geotools package structure Signed-off-by: Jody Garnett <jod...@gm...> Deleted: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitDataStore.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitDataStore.java 2012-02-28 04:46:24 UTC (rev 38576) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitDataStore.java 2012-02-28 04:48:01 UTC (rev 38577) @@ -1,404 +0,0 @@ -/* - * GeoTools - The Open Source Java GIS Toolkit - * http://geotools.org - * - * (C) 2002-2011, 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.geoserver.data.geogit; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.logging.Logger; - -import org.geogit.api.MutableTree; -import org.geogit.api.ObjectId; -import org.geogit.api.Ref; -import org.geogit.api.RevObject.TYPE; -import org.geogit.api.RevTree; -import org.geogit.repository.Repository; -import org.geogit.storage.ObjectDatabase; -import org.geogit.storage.ObjectReader; -import org.geogit.storage.ObjectWriter; -import org.geogit.storage.RefDatabase; -import org.geogit.storage.WrappedSerialisingFactory; -import org.geogit.storage.hessian.HessianSimpleFeatureTypeReader; -import org.geogit.storage.hessian.HessianSimpleFeatureTypeWriter; -import org.geoserver.data.versioning.VersioningDataStore; -import org.geotools.data.DefaultServiceInfo; -import org.geotools.data.FeatureReader; -import org.geotools.data.FeatureWriter; -import org.geotools.data.LockingManager; -import org.geotools.data.Query; -import org.geotools.data.SchemaNotFoundException; -import org.geotools.data.ServiceInfo; -import org.geotools.data.Transaction; -import org.geotools.feature.NameImpl; -import org.geotools.feature.simple.SimpleFeatureTypeBuilder; -import org.geotools.util.logging.Logging; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.feature.type.Name; -import org.opengis.filter.Filter; - -import com.google.common.base.Preconditions; -import com.google.common.base.Throwables; - -public class GeoGitDataStore implements VersioningDataStore { - - private static final Logger LOGGER = Logging - .getLogger(GeoGitDataStore.class); - - public static final String TYPE_NAMES_REF_TREE = "typeNames"; - - private static final String NULL_NAMESPACE = ""; - - private Repository repo; - - private final String defaultNamespace; - - public GeoGitDataStore(final Repository repo) throws IOException { - this(repo, null); - } - - public GeoGitDataStore(final Repository repo, final String defaultNamespace) - throws IOException { - Preconditions.checkNotNull(repo, "repository"); - this.repo = repo; - this.defaultNamespace = defaultNamespace; - init(); - } - - private void init() throws IOException { - final RefDatabase refDatabase = repo.getRefDatabase(); - final ObjectDatabase objectDatabase = repo.getObjectDatabase(); - - Ref typesTreeRef = refDatabase.getRef(TYPE_NAMES_REF_TREE); - if (null == typesTreeRef) { - LOGGER.info("Initializing type name references. Types tree does not exist"); - final RevTree typesTree = objectDatabase.newTree(); - ObjectId typesTreeId; - try { - WrappedSerialisingFactory serialisingFactory; - serialisingFactory = WrappedSerialisingFactory.getInstance(); - ObjectWriter<RevTree> treeWriter = serialisingFactory - .createRevTreeWriter(typesTree); - typesTreeId = objectDatabase.put(treeWriter); - } catch (Exception e) { - throw new IOException(e); - } - typesTreeRef = new Ref(TYPE_NAMES_REF_TREE, typesTreeId, TYPE.TREE); - refDatabase.put(typesTreeRef); - LOGGER.info("Type names tree reference initialized"); - } else { - LOGGER.info("Loading type name references"); - List<Name> names = getNamesInternal(); - LOGGER.fine("Managed types: " + names); - } - - } - - public Repository getRepository() { - return repo; - } - - /** - * @see org.geotools.data.DataAccess#getInfo() - */ - @Override - public ServiceInfo getInfo() { - DefaultServiceInfo si = new DefaultServiceInfo(); - si.setDescription("GeoGIT DataStore"); - si.setTitle("GeoGIT"); - return si; - } - - /** - * @see org.geotools.data.DataAccess#dispose() - */ - @Override - public void dispose() { - // TODO Auto-generated method stub - - } - - private List<Name> getNamesInternal() throws IOException { - final RefDatabase refDatabase = repo.getRefDatabase(); - final ObjectDatabase objectDatabase = repo.getObjectDatabase(); - - final Ref typesTreeRef = refDatabase.getRef(TYPE_NAMES_REF_TREE); - Preconditions.checkState(typesTreeRef != null); - - RevTree namespacesTree = objectDatabase.getTree(typesTreeRef - .getObjectId()); - Preconditions.checkState(null != namespacesTree, - "Referenced types tree does not exist: " + typesTreeRef); - - List<Name> names = new ArrayList<Name>(); - for (Iterator<Ref> namespaces = namespacesTree.iterator(null); namespaces - .hasNext();) { - final Ref namespaceRef = namespaces.next(); - Preconditions.checkState(TYPE.TREE.equals(namespaceRef.getType())); - final String nsUri = namespaceRef.getName(); - final RevTree typesTree = objectDatabase.getTree(namespaceRef - .getObjectId()); - for (Iterator<Ref> simpleNames = typesTree.iterator(null); simpleNames - .hasNext();) { - final Ref typeNameRef = simpleNames.next(); - final String simpleTypeName = typeNameRef.getName(); - names.add(new NameImpl(nsUri, simpleTypeName)); - } - } - - return names; - } - - /** - * @see org.geotools.data.DataAccess#getNames() - */ - @Override - public List<Name> getNames() throws IOException { - return getNamesInternal(); - } - - /** - * @see org.geotools.data.DataStore#getTypeNames() - * @see #getNames() - */ - @Override - public String[] getTypeNames() throws IOException { - final List<Name> names = getNames(); - String[] simpleNames = new String[names.size()]; - for (int i = 0; i < names.size(); i++) { - simpleNames[i] = names.get(i).getLocalPart(); - } - return simpleNames; - } - - /** - * @see org.geotools.data.DataAccess#createSchema(org.opengis.feature.type.FeatureType) - */ - @Override - public void createSchema(final SimpleFeatureType featureType) - throws IOException { - Preconditions.checkNotNull(featureType); - - SimpleFeatureType createType = featureType; - - LOGGER.info("Creating FeatureType " + createType.getName()); - - if (getNames().contains(createType.getName())) { - throw new IOException(createType.getName() + " already exists"); - } - - { - // GeoServer calls createSchema with this namespace but then asks - // for the one passed in - // as the DataStore's namespace parameter - final String ignoreNamespace = "http://www.opengis.net/gml"; - Name name = createType.getName(); - if ((ignoreNamespace.equals(name.getNamespaceURI()) || null == name - .getNamespaceURI()) && null != defaultNamespace) { - LOGGER.info("FeatureType to be created has no namespace, assigning DataStore's default: '" - + defaultNamespace + "'"); - - SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); - builder.setName(createType.getName().getLocalPart()); - builder.setNamespaceURI(defaultNamespace); - builder.addAll(createType.getAttributeDescriptors()); - createType = builder.buildFeatureType(); - } - - } - final Name typeName = createType.getName(); - final RefDatabase refDatabase = repo.getRefDatabase(); - final ObjectDatabase objectDatabase = repo.getObjectDatabase(); - - final Ref typesTreeRef = refDatabase.getRef(TYPE_NAMES_REF_TREE); - Preconditions.checkState(typesTreeRef != null); - - final RevTree namespacesRootTree = objectDatabase.getTree(typesTreeRef - .getObjectId()); - Preconditions.checkState(namespacesRootTree != null); - - final String namespace = null == typeName.getNamespaceURI() ? NULL_NAMESPACE - : typeName.getNamespaceURI(); - final String localName = typeName.getLocalPart(); - - try { - final ObjectId featureTypeBlobId; -// WrappedSerialisingFactory serialisingFactory; -// serialisingFactory = WrappedSerialisingFactory.getInstance(); -// featureTypeBlobId = objectDatabase.put(serialisingFactory -// .createSimpleFeatureTypeWriter(createType)); - featureTypeBlobId = objectDatabase.put(new HessianSimpleFeatureTypeWriter(createType)); - - final List<String> namespaceTreePath = Collections - .singletonList(namespace); - MutableTree namespaceTree = objectDatabase.getOrCreateSubTree( - namespacesRootTree, namespaceTreePath); - - namespaceTree.put(new Ref(localName, featureTypeBlobId, TYPE.BLOB)); - - final MutableTree root = namespacesRootTree.mutable(); - final ObjectId newTypeRefsTreeId; - newTypeRefsTreeId = objectDatabase.writeBack(root, namespaceTree, - namespaceTreePath); - - final Ref newTypesTreeRef = new Ref(TYPE_NAMES_REF_TREE, - newTypeRefsTreeId, TYPE.TREE); - refDatabase.put(newTypesTreeRef); - - } catch (IOException e) { - throw e; - } catch (Exception e) { - Throwables.propagate(e); - } - } - - /** - * @see org.geotools.data.DataAccess#getSchema(org.opengis.feature.type.Name) - */ - @Override - public SimpleFeatureType getSchema(final Name name) throws IOException { - Preconditions.checkNotNull(name); - - final RefDatabase refDatabase = repo.getRefDatabase(); - final ObjectDatabase objectDatabase = repo.getObjectDatabase(); - - final Ref typesTreeRef = refDatabase.getRef(TYPE_NAMES_REF_TREE); - Preconditions.checkState(typesTreeRef != null); - - final RevTree namespacesRootTree = objectDatabase.getTree(typesTreeRef - .getObjectId()); - Preconditions.checkState(namespacesRootTree != null); - - final String[] path = { - name.getNamespaceURI() == null ? NULL_NAMESPACE : name - .getNamespaceURI(), name.getLocalPart() }; - - final Ref typeRef = objectDatabase.getTreeChild(namespacesRootTree, - path); - if (typeRef == null) { - throw new SchemaNotFoundException(name.toString()); - } - Preconditions.checkState(TYPE.BLOB.equals(typeRef.getType())); - final ObjectId objectId = typeRef.getObjectId(); - WrappedSerialisingFactory serialisingFactory; - serialisingFactory = WrappedSerialisingFactory.getInstance(); -// final ObjectReader<SimpleFeatureType> reader = serialisingFactory -// .createSimpleFeatureTypeReader(name); - final ObjectReader<SimpleFeatureType> reader = - new HessianSimpleFeatureTypeReader(name); - final SimpleFeatureType featureType = objectDatabase.get(objectId, - reader); - return featureType; - } - - /** - * @see org.geotools.data.DataStore#getSchema(java.lang.String) - * @see #getSchema(Name) - */ - @Override - public SimpleFeatureType getSchema(final String typeName) - throws IOException { - final List<Name> names = getNames(); - for (Name name : names) { - if (name.getLocalPart().equals(typeName)) { - return getSchema(name); - } - } - throw new SchemaNotFoundException(typeName); - } - - /** - * @see org.geotools.data.DataStore#getFeatureSource(java.lang.String) - * @see #getFeatureSource(Name) - */ - @Override - public GeoGitFeatureSource getFeatureSource(final String typeName) - throws IOException { - final List<Name> names = getNames(); - for (Name name : names) { - if (name.getLocalPart().equals(typeName)) { - return getFeatureSource(name); - } - } - throw new SchemaNotFoundException(typeName); - } - - /** - * @see org.geotools.data.DataStore#getFeatureSource(org.opengis.feature.type.Name) - */ - @Override - public GeoGitFeatureSource getFeatureSource(final Name typeName) - throws IOException { - final SimpleFeatureType featureType = getSchema(typeName); - - return new GeoGitFeatureStore(featureType, this); - } - - @Override - public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader( - Query query, Transaction transaction) throws IOException { - - throw new UnsupportedOperationException("not yet implemented"); - } - - @Override - public FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter( - String typeName, Filter filter, Transaction transaction) - throws IOException { - throw new UnsupportedOperationException("not yet implemented"); - } - - @Override - public FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter( - String typeName, Transaction transaction) throws IOException { - throw new UnsupportedOperationException("not yet implemented"); - } - - @Override - public FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriterAppend( - String typeName, Transaction transaction) throws IOException { - throw new UnsupportedOperationException("not yet implemented"); - } - - @Override - public LockingManager getLockingManager() { - return null; - } - - /** - * @see org.geotools.data.DataAccess#updateSchema(org.opengis.feature.type.Name, - * org.opengis.feature.type.FeatureType) - */ - @Override - public void updateSchema(Name typeName, SimpleFeatureType featureType) - throws IOException { - throw new UnsupportedOperationException("Not yet implemented"); - } - - /** - * @see org.geotools.data.DataStore#updateSchema(java.lang.String, - * org.opengis.feature.simple.SimpleFeatureType) - */ - @Override - public void updateSchema(String typeName, SimpleFeatureType featureType) - throws IOException { - throw new UnsupportedOperationException("Not yet implemented"); - } - -} Deleted: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitDataStoreFactory.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitDataStoreFactory.java 2012-02-28 04:46:24 UTC (rev 38576) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitDataStoreFactory.java 2012-02-28 04:48:01 UTC (rev 38577) @@ -1,143 +0,0 @@ -/* - * GeoTools - The Open Source Java GIS Toolkit - * http://geotools.org - * - * (C) 2002-2011, 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.geoserver.data.geogit; - -import java.awt.RenderingHints.Key; -import java.io.File; -import java.io.IOException; -import java.io.Serializable; -import java.util.Collections; -import java.util.Map; -import java.util.Properties; - -import org.geogit.repository.Repository; -import org.geogit.storage.RepositoryDatabase; -import org.geogit.storage.bdbje.EntityStoreConfig; -import org.geogit.storage.bdbje.EnvironmentBuilder; -import org.geogit.storage.bdbje.JERepositoryDatabase; -import org.geotools.data.DataSourceException; -import org.geotools.data.DataStore; -import org.geotools.data.DataStoreFactorySpi; - -import com.sleepycat.je.Environment; - -public class GeoGitDataStoreFactory implements DataStoreFactorySpi { - - public static final Param USE_EMBEDDED_REPO = new Param("GEOGIT_EMBEDDED", - Boolean.class, "Use Embedded GeoGIT Repository"); - - public static final Param DEFAULT_NAMESPACE = new Param("namespace", - String.class, "Default namespace", false); - - public static final Param DATA_ROOT = new Param("data_root", String.class, - "Root directory for the versioned data store", false); - - public static final Param REPO_PATH = new Param("repo_path", String.class, - "Path, within the data root, for the GeoGIT repository", false); - - public static final Param INDEX_PATH = new Param("index_path", - String.class, - "Path, within the data root, for the GeoGIT index repository", - false); - - @Override - public String getDisplayName() { - return "GeoGIT"; - } - - @Override - public String getDescription() { - return "GeoGIT Versioning DataStore"; - } - - @Override - public Param[] getParametersInfo() { - return new Param[] { USE_EMBEDDED_REPO, DEFAULT_NAMESPACE }; - } - - @Override - public boolean canProcess(Map<String, Serializable> params) { - try { - Object lookUp = USE_EMBEDDED_REPO.lookUp(params); - return Boolean.TRUE.equals(lookUp); - } catch (IOException e) { - // - } - return false; - } - - /** - * @see org.geotools.data.DataAccessFactory#isAvailable() - */ - @Override - public boolean isAvailable() { - return true; - } - - @Override - public Map<Key, ?> getImplementationHints() { - return Collections.emptyMap(); - } - - @Override - public DataStore createDataStore(Map<String, Serializable> params) - throws IOException { - Object lookUp = USE_EMBEDDED_REPO.lookUp(params); - if (!Boolean.TRUE.equals(lookUp)) { - throw new DataSourceException(USE_EMBEDDED_REPO.key - + " is not true"); - } - - String defaultNamespace = (String) DEFAULT_NAMESPACE.lookUp(params); - - String dataRootPath = (String) DATA_ROOT.lookUp(params); - String repoPath = (String) REPO_PATH.lookUp(params); - String indexPath = (String) INDEX_PATH.lookUp(params); - - final File dataRoot = new File(dataRootPath); - final File geogitRepo = new File(dataRoot, repoPath); - final File indexRepo = new File(dataRoot, indexPath); - - EnvironmentBuilder esb = new EnvironmentBuilder(new EntityStoreConfig()); - Properties bdbEnvProperties = null; - Environment geogitEnv = esb.buildEnvironment(geogitRepo, - bdbEnvProperties); - Environment indexEnv = esb - .buildEnvironment(indexRepo, bdbEnvProperties); - - RepositoryDatabase ggitRepoDb = new JERepositoryDatabase(geogitEnv, - indexEnv); - - Repository repository = new Repository(ggitRepoDb, dataRoot); - repository.create(); - - // Repository repository = GEOGIT.get().getRepository(); - GeoGitDataStore store = new GeoGitDataStore(repository, - defaultNamespace); - return store; - } - - /** - * @see org.geotools.data.DataStoreFactorySpi#createNewDataStore(java.util.Map) - */ - @Override - public DataStore createNewDataStore(Map<String, Serializable> params) - throws IOException { - throw new UnsupportedOperationException(); - } - -} Deleted: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitFeatureSource.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitFeatureSource.java 2012-02-28 04:46:24 UTC (rev 38576) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitFeatureSource.java 2012-02-28 04:48:01 UTC (rev 38577) @@ -1,342 +0,0 @@ -/* - * GeoTools - The Open Source Java GIS Toolkit - * http://geotools.org - * - * (C) 2002-2011, 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.geoserver.data.geogit; - -import java.awt.RenderingHints; -import java.awt.RenderingHints.Key; -import java.io.IOException; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import org.geogit.api.ObjectId; -import org.geogit.api.RevTree; -import org.geogit.repository.Repository; -import org.geogit.storage.ObjectDatabase; -import org.geoserver.data.versioning.SimpleVersioningFeatureSource; -import org.geotools.data.DataSourceException; -import org.geotools.data.DefaultResourceInfo; -import org.geotools.data.FeatureListener; -import org.geotools.data.Query; -import org.geotools.data.QueryCapabilities; -import org.geotools.data.ResourceInfo; -import org.geotools.data.simple.SimpleFeatureCollection; -import org.geotools.data.store.EmptyFeatureCollection; -import org.geotools.factory.CommonFactoryFinder; -import org.geotools.factory.Hints; -import org.geotools.filter.spatial.DefaultCRSFilterVisitor; -import org.geotools.filter.spatial.ReprojectingFilterVisitor; -import org.geotools.geometry.jts.ReferencedEnvelope; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.feature.type.GeometryDescriptor; -import org.opengis.feature.type.Name; -import org.opengis.filter.Filter; -import org.opengis.filter.FilterFactory2; -import org.opengis.filter.sort.SortBy; -import org.opengis.referencing.crs.CoordinateReferenceSystem; - -import com.google.common.base.Throwables; - -public class GeoGitFeatureSource implements SimpleVersioningFeatureSource { - - protected final SimpleFeatureType type; - - protected final GeoGitDataStore dataStore; - - /** - * @see #getSupportedHints() - */ - private static final Set<Key> supportedHints = Collections - .unmodifiableSet(new HashSet<Key>(Arrays.asList( - Hints.FEATURE_DETACHED, Hints.JTS_GEOMETRY_FACTORY, - Hints.JTS_COORDINATE_SEQUENCE_FACTORY) - - )); - - public GeoGitFeatureSource(final SimpleFeatureType type, - final GeoGitDataStore dataStore) { - this.type = type; - this.dataStore = dataStore; - } - - /** - * @return the tree of feature references for this type - */ - public RevTree getCurrentVersion() { - // assume HEAD is at MASTER - try { - final Name typeName = this.type.getName(); - Repository repository = dataStore.getRepository(); - RevTree typeTree = repository.getWorkingTree().getHeadVersion( - typeName); - return typeTree; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * @see org.geotools.data.FeatureSource#getName() - */ - @Override - public Name getName() { - return type.getName(); - } - - /** - * @see org.geotools.data.FeatureSource#getInfo() - */ - @Override - public ResourceInfo getInfo() { - DefaultResourceInfo info = new DefaultResourceInfo(); - ReferencedEnvelope bounds; - try { - bounds = getBounds(); - if (bounds != null) { - info.setBounds(bounds); - info.setCRS(bounds.getCoordinateReferenceSystem()); - } - } catch (IOException e) { - Throwables.propagate(e); - } - info.setName(getName().getLocalPart()); - info.setDescription("GeoGit backed Feature Source"); - return info; - } - - /** - * @see org.geotools.data.FeatureSource#getDataStore() - */ - @Override - public GeoGitDataStore getDataStore() { - return dataStore; - } - - /** - * @see org.geotools.data.FeatureSource#getQueryCapabilities() - */ - @Override - public QueryCapabilities getQueryCapabilities() { - QueryCapabilities caps = new QueryCapabilities() { - /** - * @see org.geotools.data.QueryCapabilities#isUseProvidedFIDSupported() - * @return {@code true} - */ - @Override - public boolean isUseProvidedFIDSupported() { - return true; - } - - /** - * @see org.geotools.data.QueryCapabilities#supportsSorting(org.opengis.filter.sort.SortBy[]) - * @return {@code false} - */ - @Override - public boolean supportsSorting(SortBy[] sortAttributes) { - return false; - } - }; - - return caps; - } - - @Override - public void addFeatureListener(FeatureListener listener) { - // TODO Auto-generated method stub - - } - - @Override - public void removeFeatureListener(FeatureListener listener) { - // TODO Auto-generated method stub - - } - - /** - * @see org.geotools.data.FeatureSource#getSchema() - */ - @Override - public SimpleFeatureType getSchema() { - return type; - } - - /** - * @see org.geotools.data.FeatureSource#getBounds() - * @see #getBounds(Query) getBounds(Query.ALL) - */ - @Override - public ReferencedEnvelope getBounds() throws IOException { - return getBounds(Query.ALL); - } - - /** - * @see org.geotools.data.FeatureSource#getBounds(org.geotools.data.Query) - */ - @Override - public ReferencedEnvelope getBounds(final Query query) throws IOException { - // TODO optimize, please - SimpleFeatureCollection features = getFeatures(query); - ReferencedEnvelope bounds = features.getBounds(); - return bounds; - } - - @Override - public int getCount(Query query) throws IOException { - // TODO optimize, please - SimpleFeatureCollection features = getFeatures(query); - int size = features.size(); - return size; - } - - /** - * GeoGit Features are always "detached", so we return the FEATURE_DETACHED - * hint here, as well as the JTS related ones. - * <p> - * The JTS related hints supported are: - * <ul> - * <li>JTS_GEOMETRY_FACTORY - * <li>JTS_COORDINATE_SEQUENCE_FACTORY - * </ul> - * Note, however, that if a {@link GeometryFactory} is provided through the - * {@code JTS_GEOMETRY_FACTORY} hint, that very factory is used and takes - * precedence over all the other ones. - * </p> - * - * @see FeatureSource#getSupportedHints() - * @see Hints#FEATURE_DETACHED - * @see Hints#JTS_GEOMETRY_FACTORY - * @see Hints#JTS_COORDINATE_SEQUENCE_FACTORY - */ - @Override - public final Set<RenderingHints.Key> getSupportedHints() { - return supportedHints; - } - - /** - * @see org.geotools.data.simple.SimpleFeatureSource#getFeatures() - */ - @Override - public SimpleFeatureCollection getFeatures() throws IOException { - return getFeatures(Query.ALL); - } - - @Override - public SimpleFeatureCollection getFeatures(final Filter filter) - throws IOException { - return getFeatures(new Query(getName().getLocalPart(), filter)); - } - - @Override - public SimpleFeatureCollection getFeatures(final Query query) - throws IOException { - Filter filter = query.getFilter(); - if (filter == null) { - filter = Filter.INCLUDE; - } - if (Filter.EXCLUDE.equals(filter)) { - return new EmptyFeatureCollection(type); - } - - final Query query2 = reprojectFilter(query); - filter = query2.getFilter(); - - final ObjectDatabase lookupDatabase = dataStore.getRepository() - .getIndex().getDatabase(); - final RevTree typeTree = getCurrentVersion(); - GeoGitSimpleFeatureCollection featureCollection; - featureCollection = new GeoGitSimpleFeatureCollection(type, filter, - lookupDatabase, typeTree); - - final int maxFeatures = query2.getMaxFeatures(); - if (maxFeatures > 0 && maxFeatures != Query.DEFAULT_MAX) { - featureCollection.setMaxFeatures(maxFeatures); - } - - // if (null != query.getHints().get(Hints.JTS_GEOMETRY_FACTORY)) { - // GeometryFactory gfac = (GeometryFactory) query.getHints().get( - // Hints.JTS_GEOMETRY_FACTORY); - // featureCollection.setGeometryFactory(gfac); - // } else if (null != - // query.getHints().get(Hints.JTS_COORDINATE_SEQUENCE_FACTORY)) { - // CoordinateSequenceFactory csf = (CoordinateSequenceFactory) - // query.getHints().get( - // Hints.JTS_COORDINATE_SEQUENCE_FACTORY); - // GeometryFactory gfac = new GeometryFactory(csf); - // featureCollection.setGeometryFactory(gfac); - // } - - return featureCollection; - } - - /** - * @return the id of the root tree. Defaults to the repository's root, but - * {@link GeoGitFeatureStore} shall override to account for whether - * there's a transaction in progress - */ - protected ObjectId getRootTreeId() { - Repository repository = dataStore.getRepository(); - ObjectId rootTreeId = repository.getRootTreeId(); - return rootTreeId; - } - - private Query reprojectFilter(Query query) throws IOException { - final Filter originalFilter = query.getFilter() != null ? query - .getFilter() : Filter.INCLUDE; - if (Filter.INCLUDE.equals(originalFilter)) { - return query; - } - - final SimpleFeatureType nativeFeatureType = getSchema(); - final GeometryDescriptor geom = nativeFeatureType - .getGeometryDescriptor(); - // if no geometry involved, no reprojection needed - if (geom == null) { - return query; - } - - final FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null); - - try { - CoordinateReferenceSystem nativeCRS = geom - .getCoordinateReferenceSystem(); - - // now we apply a default to all geometries and bbox in the filter - DefaultCRSFilterVisitor defaultCRSVisitor = new DefaultCRSFilterVisitor( - ff, nativeCRS); - final Filter defaultedFilter = (Filter) originalFilter.accept( - defaultCRSVisitor, null); - - // and then we reproject all geometries so that the datastore - // receives - // them in the native projection system (or the forced one, in case - // of force) - ReprojectingFilterVisitor reprojectingVisitor = new ReprojectingFilterVisitor( - ff, nativeFeatureType); - final Filter reprojectedFilter = (Filter) defaultedFilter.accept( - reprojectingVisitor, null); - - Query reprojectedQuery = new Query(query); - reprojectedQuery.setFilter(reprojectedFilter); - return reprojectedQuery; - } catch (Exception e) { - throw new DataSourceException( - "Had troubles handling filter reprojection...", e); - } - } - -} Deleted: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitFeatureStore.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitFeatureStore.java 2012-02-28 04:46:24 UTC (rev 38576) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitFeatureStore.java 2012-02-28 04:48:01 UTC (rev 38577) @@ -1,338 +0,0 @@ -/* - * GeoTools - The Open Source Java GIS Toolkit - * http://geotools.org - * - * (C) 2002-2011, 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.geoserver.data.geogit; - -import static org.geotools.data.Transaction.AUTO_COMMIT; - -import java.io.IOException; -import java.util.List; - -import org.geogit.api.GeoGIT; -import org.geogit.api.ObjectId; -import org.geogit.api.Ref; -import org.geogit.api.RevTree; -import org.geogit.repository.Repository; -import org.geogit.repository.WorkingTree; -import org.geoserver.data.versioning.SimpleVersioningFeatureStore; -import org.geoserver.data.versioning.decorator.VersionFilters; -import org.geoserver.data.versioning.decorator.VersionQuery; -import org.geotools.data.FeatureReader; -import org.geotools.data.Transaction; -import org.geotools.data.simple.SimpleFeatureCollection; -import org.geotools.feature.FeatureCollection; -import org.geotools.feature.NameImpl; -import org.geotools.filter.identity.ResourceIdImpl; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.feature.type.AttributeDescriptor; -import org.opengis.feature.type.Name; -import org.opengis.filter.Filter; -import org.opengis.filter.Id; -import org.opengis.filter.identity.FeatureId; -import org.opengis.filter.identity.Identifier; -import org.opengis.filter.identity.ResourceId; - -import com.google.common.base.Preconditions; -import com.google.common.base.Throwables; -import com.google.common.collect.Lists; - -@SuppressWarnings("rawtypes") -public class GeoGitFeatureStore extends GeoGitFeatureSource implements - SimpleVersioningFeatureStore { - - private Transaction transaction; - - public GeoGitFeatureStore(final SimpleFeatureType type, - final GeoGitDataStore store) { - super(type, store); - transaction = Transaction.AUTO_COMMIT; - } - - /** - * @return the object id of the current HEAD's commit if we're not inside a - * transaction, or {@code null} if we're inside a transaction - */ - @Override - public RevTree getCurrentVersion() { - if (getTransaction() == null - || Transaction.AUTO_COMMIT.equals(getTransaction())) { - return super.getCurrentVersion(); - } - - // assume HEAD is at MASTER - try { - final Name typeName = this.type.getName(); - Repository repository = dataStore.getRepository(); - WorkingTree workingTree = repository.getWorkingTree(); - RevTree typeTree = workingTree.getStagedVersion(typeName); - return typeTree; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - @Override - protected ObjectId getRootTreeId() { - final Transaction transaction = getTransaction(); - if (null == transaction || Transaction.AUTO_COMMIT.equals(transaction)) { - // no transaction in progress, return the repository's root - return super.getRootTreeId(); - } - // transaction in progress, return null to signal querying the index - // first - return null; - // Repository repository = dataStore.getRepository(); - // StagingArea index = repository.getIndex(); - // RevTree staged = index.getStaged(); - // ObjectId stagedRootId = staged.getId(); - // return stagedRootId; - } - - /** - * @see org.geotools.data.FeatureStore#getTransaction() - */ - @Override - public Transaction getTransaction() { - return transaction; - } - - /** - * @see org.geotools.data.FeatureStore#setTransaction(org.geotools.data.Transaction) - */ - @Override - public void setTransaction(final Transaction transaction) { - Preconditions.checkArgument(transaction != null, - "Transaction is null, did you mean Transaction.AUTO_COMMIT?"); - this.transaction = transaction; - } - - /** - * @see org.geotools.data.FeatureStore#addFeatures(org.geotools.feature.FeatureCollection) - */ - @Override - public List<FeatureId> addFeatures( - FeatureCollection<SimpleFeatureType, SimpleFeature> collection) - throws IOException { - Preconditions.checkNotNull(collection); - Preconditions.checkNotNull(collection.getSchema()); - Preconditions.checkArgument(type.getName().equals( - collection.getSchema().getName())); - - checkTransaction(); - - final Name typeName = getSchema().getName(); - final VersioningTransactionState versioningState = getVersioningState(); - - List<FeatureId> insertedResourceIds; - try { - insertedResourceIds = versioningState.stageInsert(typeName, - collection); - } catch (Exception e) { - throw new IOException(e); - } - - return insertedResourceIds; - } - - /** - * @see org.geotools.data.FeatureStore#modifyFeatures(org.opengis.feature.type.Name[], - * java.lang.Object[], org.opengis.filter.Filter) - */ - @Override - public void modifyFeatures(final Name[] attributeNames, - final Object[] attributeValues, final Filter filter) - throws IOException { - - checkTransaction(); - // throws exception if filter has a resourceid that doesn't match the - // current version - checkEditFilterMatchesCurrentVersion(filter); - - final SimpleFeatureCollection affectedFeatures = getFeatures(filter); - final FeatureCollection newValues = new ModifyingFeatureCollection( - affectedFeatures, attributeNames, attributeValues); - - VersioningTransactionState versioningState = getVersioningState(); - try { - versioningState.stageUpdate(type.getName(), newValues); - } catch (Exception e) { - throw new IOException(e); - } - } - - /** - * @see org.geotools.data.FeatureStore#removeFeatures(org.opengis.filter.Filter) - */ - @Override - public void removeFeatures(final Filter filter) throws IOException { - Preconditions.checkNotNull(filter); - - checkTransaction(); - - FeatureCollection removed = getFeatures(filter); - try { - Name typeName = getSchema().getName(); - VersioningTransactionState versioningState = getVersioningState(); - versioningState.stageDelete(typeName, filter, removed); - } catch (Exception e) { - Throwables.propagate(e); - } - } - - /** - * Throws an IllegalArgumentException if {@code filter} contains a resource - * filter that doesn't match the current version of a feature - * - * @param filter original upate filter - */ - private void checkEditFilterMatchesCurrentVersion(final Filter filter) { - final Id versionFilter = VersionFilters.getVersioningFilter(filter); - if (versionFilter == null) { - return; - } - final Repository repository = dataStore.getRepository(); - // don't allow non current versions - GeoGIT ggit = new GeoGIT(repository); - VersionQuery query = new VersionQuery(ggit, getSchema().getName()); - for (Identifier id : versionFilter.getIdentifiers()) { - ResourceId rid = (ResourceId) id; - List<Ref> requested; - List<Ref> current; - try { - requested = Lists.newArrayList(query.get(rid)); - current = Lists.newArrayList(query.get(new ResourceIdImpl(rid - .getID(), null))); - } catch (Exception e) { - throw new RuntimeException(e); - } - if (!current.equals(requested)) { - throw new IllegalArgumentException( - "Requested resource id filter doesn't match curent version for feature " - + rid.getID()); - } - } - } - - /** - * @see org.geotools.data.FeatureStore#setFeatures(org.geotools.data.FeatureReader) - */ - @Override - public void setFeatures( - FeatureReader<SimpleFeatureType, SimpleFeature> reader) - throws IOException { - throw new UnsupportedOperationException("do versioning!"); - } - - private void checkTransaction() { - if (Transaction.AUTO_COMMIT.equals(getTransaction())) { - throw new UnsupportedOperationException( - "AUTO_COMMIT is not supported for versioned Feature Types"); - } - } - - protected VersioningTransactionState getVersioningState() { - Transaction transaction = getTransaction(); - if (AUTO_COMMIT.equals(transaction)) { - return VersioningTransactionState.VOID; - } - - final Object key = GeoGitDataStore.class; - VersioningTransactionState state = (VersioningTransactionState) transaction - .getState(key); - if (state == null) { - Repository repository = dataStore.getRepository(); - state = new VersioningTransactionState(new GeoGIT(repository)); - transaction.putState(key, state); - } - - return state; - } - - /** - * @see org.geotools.data.simple.SimpleFeatureStore#modifyFeatures(java.lang.String, - * java.lang.Object, org.opengis.filter.Filter) - * @see #modifyFeatures(Name[], Object[], Filter) - */ - @Override - public void modifyFeatures(String name, Object attributeValue, Filter filter) - throws IOException { - - Name attributeName = new NameImpl(name); - modifyFeatures(attributeName, attributeValue, filter); - } - - /** - * @see org.geotools.data.simple.SimpleFeatureStore#modifyFeatures(java.lang.String[], - * java.lang.Object[], org.opengis.filter.Filter) - * @see #modifyFeatures(Name[], Object[], Filter) - */ - @Override - public void modifyFeatures(String[] names, Object[] attributeValues, - Filter filter) throws IOException { - - Name[] attributeNames = new Name[names.length]; - for (int i = 0; i < names.length; i++) { - String name = names[i]; - attributeNames[i] = new NameImpl(name); - } - modifyFeatures(attributeNames, attributeValues, filter); - } - - /** - * @see org.geotools.data.FeatureStore#modifyFeatures(org.opengis.feature.type.AttributeDescriptor[], - * java.lang.Object[], org.opengis.filter.Filter) - * @see #modifyFeatures(Name[], Object[], Filter) - */ - @Override - public void modifyFeatures(AttributeDescriptor[] type, Object[] value, - Filter filter) throws IOException { - - Name[] attributeNames = new Name[type.length]; - for (int i = 0; i < type.length; i++) { - attributeNames[i] = type[i].getName(); - } - modifyFeatures(attributeNames, value, filter); - } - - /** - * @see org.geotools.data.FeatureStore#modifyFeatures(org.opengis.feature.type.Name, - * java.lang.Object, org.opengis.filter.Filter) - * @see #modifyFeatures(Name[], Object[], Filter) - */ - @Override - public void modifyFeatures(Name attributeName, Object attributeValue, - Filter filter) throws IOException { - - modifyFeatures(new Name[] { attributeName }, - new Object[] { attributeValue }, filter); - } - - /** - * @see org.geotools.data.FeatureStore#modifyFeatures(org.opengis.feature.type.AttributeDescriptor, - * java.lang.Object, org.opengis.filter.Filter) - * @see #modifyFeatures(Name[], Object[], Filter) - */ - @Override - public void modifyFeatures(AttributeDescriptor type, Object value, - Filter filter) throws IOException { - - modifyFeatures(new Name[] { type.getName() }, new Object[] { value }, - filter); - - } - -} Deleted: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitSimpleFeatureCollection.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitSimpleFeatureCollection.java 2012-02-28 04:46:24 UTC (rev 38576) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitSimpleFeatureCollection.java 2012-02-28 04:48:01 UTC (rev 38577) @@ -1,579 +0,0 @@ -/* - * GeoTools - The Open Source Java GIS Toolkit - * http://geotools.org - * - * (C) 2002-2011, 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.geoserver.data.geogit; - -import java.io.IOException; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.NoSuchElementException; - -import org.geogit.api.ObjectId; -import org.geogit.api.Ref; -import org.geogit.api.RevTree; -import org.geogit.api.SpatialRef; -import org.geogit.storage.ObjectDatabase; -import org.geogit.storage.ObjectReader; -import org.geogit.storage.WrappedSerialisingFactory; -import org.geotools.data.simple.SimpleFeatureCollection; -import org.geotools.data.simple.SimpleFeatureIterator; -import org.geotools.factory.Hints; -import org.geotools.feature.CollectionListener; -import org.geotools.feature.FeatureCollection; -import org.geotools.feature.FeatureIterator; -import org.geotools.geometry.jts.JTS; -import org.geotools.geometry.jts.ReferencedEnvelope; -import org.geotools.referencing.CRS; -import org.opengis.feature.Feature; -import org.opengis.feature.FeatureVisitor; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.feature.type.AttributeDescriptor; -import org.opengis.feature.type.GeometryDescriptor; -import org.opengis.filter.Filter; -import org.opengis.filter.expression.Expression; -import org.opengis.filter.expression.Literal; -import org.opengis.filter.sort.SortBy; -import org.opengis.filter.spatial.BBOX; -import org.opengis.filter.spatial.BinarySpatialOperator; -import org.opengis.filter.spatial.BoundedSpatialOperator; -import org.opengis.geometry.BoundingBox; -import org.opengis.referencing.crs.CoordinateReferenceSystem; -import org.opengis.referencing.operation.MathTransform; -import org.opengis.referencing.operation.TransformException; -import org.opengis.util.ProgressListener; - -import com.google.common.base.Predicate; -import com.google.common.base.Throwables; -import com.google.common.collect.AbstractIterator; -import com.google.common.collect.Iterators; -import com.vividsolutions.jts.geom.Geometry; -import com.vividsolutions.jts.geom.GeometryFactory; - -public class GeoGitSimpleFeatureCollection implements SimpleFeatureCollection { - - private final SimpleFeatureType type; - - private final Filter filter; - - private final ObjectDatabase odb; - - private final FeatureReprojector reprojector; - - private Integer cachedSize; - - private ReferencedEnvelope cachedBounds; - - private GeometryFactory geometryFactory; - - private final RevTree typeTree; - - private Integer maxFeatures; - - public GeoGitSimpleFeatureCollection(final SimpleFeatureType type, - final Filter filter, final ObjectDatabase odb, - final RevTree typeTree) { - this.type = type; - this.filter = filter; - this.odb = odb; - this.typeTree = typeTree; - this.r... [truncated message content] |
|
From: <svn...@os...> - 2012-02-28 04:46:31
|
Author: jive
Date: 2012-02-27 20:46:24 -0800 (Mon, 27 Feb 2012)
New Revision: 38576
Modified:
trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/VersioningAdapterFactory.java
Log:
Remove reference to spring Assert class and replace with a simple null check
Signed-off-by: Jody Garnett <jod...@gm...>
Modified: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/VersioningAdapterFactory.java
===================================================================
--- trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/VersioningAdapterFactory.java 2012-02-17 23:23:14 UTC (rev 38575)
+++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/VersioningAdapterFactory.java 2012-02-28 04:46:24 UTC (rev 38576)
@@ -27,7 +27,6 @@
import org.geotools.data.simple.SimpleFeatureSource;
import org.geotools.data.simple.SimpleFeatureStore;
import org.opengis.feature.type.Name;
-import org.springframework.util.Assert;
public class VersioningAdapterFactory {
@@ -74,7 +73,9 @@
@SuppressWarnings("rawtypes")
public static DataAccess create(final DataAccess subject,
Repository versioningRepo) {
- Assert.notNull(subject);
+ if( subject == null ){
+ throw new NullPointerException("DataAccess subject is required");
+ }
// if (subject instanceof DataStore) {
// return new VersioningDataStore((DataStore) subject, versioningRepo);
|
|
From: <svn...@os...> - 2012-02-17 23:23:21
|
Author: groldan
Date: 2012-02-17 15:23:14 -0800 (Fri, 17 Feb 2012)
New Revision: 38575
Modified:
trunk/modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_0_0/WFSFeatureSource.java
Log:
GEOT-4041: keywords may come as direct string or KeywordType
Modified: trunk/modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_0_0/WFSFeatureSource.java
===================================================================
--- trunk/modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_0_0/WFSFeatureSource.java 2012-02-17 23:21:46 UTC (rev 38574)
+++ trunk/modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_0_0/WFSFeatureSource.java 2012-02-17 23:23:14 UTC (rev 38575)
@@ -126,23 +126,24 @@
return featureSetDescription.getAbstract();
}
- @SuppressWarnings("unchecked")
public Set<String> getKeywords() {
return extractKeywords(featureSetDescription.getKeywords());
}
@SuppressWarnings("unchecked")
- private Set<String> extractKeywords(List<KeywordsType> keywordsList) {
+ private Set<String> extractKeywords(List<?> keywordsList) {
Set<String> keywords = new HashSet<String>();
if (keywordsList != null) {
- for (KeywordsType keys : keywordsList) {
- if (keys != null) {
- List<String> kws = keys.getKeyword();
+ for (Object keys : keywordsList) {
+ if (keys instanceof KeywordsType) {
+ List<String> kws = ((KeywordsType)keys).getKeyword();
for (String kw : kws) {
if (kw != null && kw.trim().length() > 0) {
keywords.add(kw);
}
}
+ } else if (keys instanceof String) {
+ keywords.add((String)keys);
}
}
}
|
|
From: <svn...@os...> - 2012-02-17 23:21:53
|
Author: groldan
Date: 2012-02-17 15:21:46 -0800 (Fri, 17 Feb 2012)
New Revision: 38574
Modified:
branches/2.7.x/modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_0_0/WFSFeatureSource.java
Log:
GEOT-4041: keywords may come as direct string or KeywordType
Modified: branches/2.7.x/modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_0_0/WFSFeatureSource.java
===================================================================
--- branches/2.7.x/modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_0_0/WFSFeatureSource.java 2012-02-15 13:04:15 UTC (rev 38573)
+++ branches/2.7.x/modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_0_0/WFSFeatureSource.java 2012-02-17 23:21:46 UTC (rev 38574)
@@ -123,23 +123,24 @@
return featureSetDescription.getAbstract();
}
- @SuppressWarnings("unchecked")
public Set<String> getKeywords() {
return extractKeywords(featureSetDescription.getKeywords());
}
@SuppressWarnings("unchecked")
- private Set<String> extractKeywords(List<KeywordsType> keywordsList) {
+ private Set<String> extractKeywords(List<?> keywordsList) {
Set<String> keywords = new HashSet<String>();
if (keywordsList != null) {
- for (KeywordsType keys : keywordsList) {
- if (keys != null) {
- List<String> kws = keys.getKeyword();
+ for (Object keys : keywordsList) {
+ if (keys instanceof KeywordsType) {
+ List<String> kws = ((KeywordsType)keys).getKeyword();
for (String kw : kws) {
if (kw != null && kw.trim().length() > 0) {
keywords.add(kw);
}
}
+ } else if (keys instanceof String) {
+ keywords.add((String)keys);
}
}
}
|