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...> - 2011-11-27 11:12:41
|
Author: aaime
Date: 2011-11-27 03:12:34 -0800 (Sun, 27 Nov 2011)
New Revision: 38378
Modified:
trunk/modules/library/render/src/main/java/org/geotools/renderer/crs/WrappingCoordinateFilter.java
trunk/modules/library/render/src/test/java/org/geotools/renderer/crs/ProjectionHandlerTest.java
Log:
[GEOT-3959] Coordinate wrapping code fails if the wrapping heuristic triggers on the very last point of a ring
Modified: trunk/modules/library/render/src/main/java/org/geotools/renderer/crs/WrappingCoordinateFilter.java
===================================================================
--- trunk/modules/library/render/src/main/java/org/geotools/renderer/crs/WrappingCoordinateFilter.java 2011-11-27 09:09:49 UTC (rev 38377)
+++ trunk/modules/library/render/src/main/java/org/geotools/renderer/crs/WrappingCoordinateFilter.java 2011-11-27 11:12:34 UTC (rev 38378)
@@ -20,6 +20,8 @@
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryComponentFilter;
import com.vividsolutions.jts.geom.LineString;
+import com.vividsolutions.jts.geom.LinearRing;
+
import java.util.logging.Level;
import org.geotools.util.logging.Logging;
import org.opengis.referencing.operation.MathTransform;
@@ -69,7 +71,8 @@
if (direction == NOWRAP)
return;
- applyOffset(cs, direction == EAST_TO_WEST ? 0 : wrapLimit * 2);
+ boolean ring = geom instanceof LinearRing || cs.getCoordinate(0).equals(cs.getCoordinate(cs.size() - 1));
+ applyOffset(cs, direction == EAST_TO_WEST ? 0 : wrapLimit * 2, ring);
}
}
@@ -88,10 +91,11 @@
return NOWRAP;
}
- private void applyOffset(CoordinateSequence cs, double offset) {
+ private void applyOffset(CoordinateSequence cs, double offset, boolean ring) {
final double maxWrap = wrapLimit * 1.9;
double lastX = cs.getX(0);
- for (int i = 0; i < cs.size(); i++) {
+ int last = ring ? cs.size() - 1 : cs.size();
+ for (int i = 0; i < last; i++) {
final double x = cs.getX(i);
final double distance = Math.abs(x - lastX);
// heuristic: an object crossing the dateline is not as big as the world, if it
@@ -135,6 +139,9 @@
lastX = x;
}
+ if(ring) {
+ cs.setOrdinate(last, 0, cs.getOrdinate(0, 0));
+ }
}
}
\ No newline at end of file
Modified: trunk/modules/library/render/src/test/java/org/geotools/renderer/crs/ProjectionHandlerTest.java
===================================================================
--- trunk/modules/library/render/src/test/java/org/geotools/renderer/crs/ProjectionHandlerTest.java 2011-11-27 09:09:49 UTC (rev 38377)
+++ trunk/modules/library/render/src/test/java/org/geotools/renderer/crs/ProjectionHandlerTest.java 2011-11-27 11:12:34 UTC (rev 38378)
@@ -218,6 +218,23 @@
}
@Test
+ public void testWrapJumpLast() throws Exception {
+ ReferencedEnvelope world = new ReferencedEnvelope(-180, 180, -90, 90, WGS84);
+ Geometry g = new WKTReader().read("POLYGON((-131 -73.5,0 -90,163 -60,174 -60,-131 -73.5))");
+ Geometry original = new WKTReader().read("POLYGON((-131 -73.5,0 -90,163 -60,174 -60,-131 -73.5))");
+ // make sure the geometry is not wrapped, but it is preserved
+ ProjectionHandler handler = ProjectionHandlerFinder.getHandler(world, true);
+ assertTrue(handler.requiresProcessing(WGS84, g));
+ Geometry preProcessed = handler.preProcess(WGS84, g);
+ // no cutting expected
+ assertEquals(original, preProcessed);
+ // post process (provide identity transform to force wrap heuristic)
+ Geometry postProcessed = handler.postProcess(CRS.findMathTransform(WGS84, WGS84), g);
+ // check the geometry is in the same area as the rendering envelope
+ assertEquals(original, postProcessed);
+ }
+
+ @Test
public void testWrapGeometryWGS84Duplicate() throws Exception {
ReferencedEnvelope world = new ReferencedEnvelope(-200, 200, -90, 90, WGS84);
|
|
From: <svn...@os...> - 2011-11-27 09:09:55
|
Author: aaime
Date: 2011-11-27 01:09:49 -0800 (Sun, 27 Nov 2011)
New Revision: 38377
Modified:
trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/CloseableIteratorWrapper.java
trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapeFileIndexer.java
trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureSource.java
trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureStore.java
trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureWriter.java
trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileSetManager.java
Log:
Mark as package private some classes that do not need to be exposed to the public
Modified: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/CloseableIteratorWrapper.java
===================================================================
--- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/CloseableIteratorWrapper.java 2011-11-27 09:09:29 UTC (rev 38376)
+++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/CloseableIteratorWrapper.java 2011-11-27 09:09:49 UTC (rev 38377)
@@ -24,7 +24,7 @@
/**
* Wraps a plain iterator into a closeable one.
*/
-public class CloseableIteratorWrapper<E> implements CloseableIterator<E> {
+class CloseableIteratorWrapper<E> implements CloseableIterator<E> {
Iterator<E> delegate;
public CloseableIteratorWrapper(Iterator<E> delegate) {
Modified: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapeFileIndexer.java
===================================================================
--- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapeFileIndexer.java 2011-11-27 09:09:29 UTC (rev 38376)
+++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapeFileIndexer.java 2011-11-27 09:09:49 UTC (rev 38377)
@@ -57,7 +57,7 @@
*
* @source $URL$
*/
-public class ShapeFileIndexer implements FileWriter {
+class ShapeFileIndexer implements FileWriter {
private static final Logger LOGGER = Logging.getLogger(ShapeFileIndexer.class);
private int max = -1;
Modified: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureSource.java
===================================================================
--- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureSource.java 2011-11-27 09:09:29 UTC (rev 38376)
+++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureSource.java 2011-11-27 09:09:49 UTC (rev 38377)
@@ -34,6 +34,7 @@
import org.geotools.data.DataSourceException;
import org.geotools.data.EmptyFeatureReader;
import org.geotools.data.FeatureReader;
+import org.geotools.data.FeatureSource;
import org.geotools.data.FilteringFeatureReader;
import org.geotools.data.Query;
import org.geotools.data.ReTypeFeatureReader;
@@ -85,7 +86,12 @@
import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.geom.Polygon;
-public class ShapefileFeatureSource extends ContentFeatureSource {
+/**
+ * A {@link FeatureSource} for shapefiles based on {@link ContentFeatureSource}
+ *
+ * @author Andrea Aime - GeoSolutions
+ */
+class ShapefileFeatureSource extends ContentFeatureSource {
static final Logger LOGGER = Logging.getLogger(ShapefileFeatureSource.class);
Modified: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureStore.java
===================================================================
--- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureStore.java 2011-11-27 09:09:29 UTC (rev 38376)
+++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureStore.java 2011-11-27 09:09:49 UTC (rev 38377)
@@ -37,7 +37,7 @@
import org.opengis.filter.Filter;
/**
- * FeatureStore for the OGR store, based on the {@link ContentFeatureStore} framework
+ * FeatureStore for the Shapefile store, based on the {@link ContentFeatureStore} framework
*
* @author Andrea Aime - GeoSolutions
*/
Modified: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureWriter.java
===================================================================
--- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureWriter.java 2011-11-27 09:09:29 UTC (rev 38376)
+++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureWriter.java 2011-11-27 09:09:49 UTC (rev 38377)
@@ -57,7 +57,7 @@
*
* @source $URL$
*/
-public class ShapefileFeatureWriter implements FeatureWriter<SimpleFeatureType, SimpleFeature> {
+class ShapefileFeatureWriter implements FeatureWriter<SimpleFeatureType, SimpleFeature> {
// the FeatureReader<SimpleFeatureType, SimpleFeature> to obtain the current Feature from
protected ShapefileFeatureReader featureReader;
Modified: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileSetManager.java
===================================================================
--- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileSetManager.java 2011-11-27 09:09:29 UTC (rev 38376)
+++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileSetManager.java 2011-11-27 09:09:49 UTC (rev 38377)
@@ -23,7 +23,7 @@
* @author Andrea Aime - GeoSolutions
*
*/
-public class ShapefileSetManager {
+class ShapefileSetManager {
ShpFiles shpFiles;
|
Author: aaime
Date: 2011-11-27 01:09:29 -0800 (Sun, 27 Nov 2011)
New Revision: 38376
Added:
trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/IndexedShapefileFeatureWriter.java
Removed:
trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/fid/RecordNumberTracker.java
Modified:
trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/IndexManager.java
trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/IndexedShapefileFeatureReader.java
trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureReader.java
trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureSource.java
trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureStore.java
trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/fid/IndexedFidReader.java
trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/fid/IndexedFidWriter.java
trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/fid/FidQueryTest.java
Log:
Adding support for fid index files as well
Modified: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/IndexManager.java
===================================================================
--- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/IndexManager.java 2011-11-24 10:10:44 UTC (rev 38375)
+++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/IndexManager.java 2011-11-27 09:09:29 UTC (rev 38376)
@@ -113,11 +113,11 @@
*
* @return
*/
- boolean hasFidIndex() {
+ boolean hasFidIndex(boolean createIfMissing) {
if (isIndexUseable(FIX)) {
return true;
} else {
- if (shpFiles.isLocal()) {
+ if (shpFiles.isLocal() && (shpFiles.exists(FIX) || createIfMissing)) {
return createFidIndex();
} else {
return false;
Modified: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/IndexedShapefileFeatureReader.java
===================================================================
--- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/IndexedShapefileFeatureReader.java 2011-11-24 10:10:44 UTC (rev 38375)
+++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/IndexedShapefileFeatureReader.java 2011-11-27 09:09:29 UTC (rev 38376)
@@ -21,10 +21,12 @@
import org.geotools.data.shapefile.ng.dbf.DbaseFileReader;
import org.geotools.data.shapefile.ng.dbf.DbaseFileReader.Row;
import org.geotools.data.shapefile.ng.dbf.IndexedDbaseFileReader;
+import org.geotools.data.shapefile.ng.fid.IndexedFidReader;
import org.geotools.data.shapefile.ng.index.CloseableIterator;
import org.geotools.data.shapefile.ng.index.Data;
import org.geotools.data.shapefile.ng.shp.ShapefileReader;
import org.geotools.data.shapefile.ng.shp.ShapefileReader.Record;
+import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
import com.vividsolutions.jts.geom.Envelope;
@@ -42,6 +44,8 @@
private Data next;
+ private IndexedFidReader fidReader;
+
/**
* Create the shape reader
*
@@ -52,9 +56,10 @@
* @param goodRecs Collection of good indexes that match the query.
*/
public IndexedShapefileFeatureReader(SimpleFeatureType schema, ShapefileReader shp,
- DbaseFileReader dbf, CloseableIterator<Data> goodRecs) throws IOException {
- super(schema, shp, dbf);
+ DbaseFileReader dbf, IndexedFidReader fidReader, CloseableIterator<Data> goodRecs) throws IOException {
+ super(schema, shp, dbf, fidReader);
this.goodRecs = goodRecs;
+ this.fidReader = fidReader;
}
public void close() throws IOException {
@@ -120,5 +125,7 @@
return nextFeature != null;
}
+
+
}
Added: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/IndexedShapefileFeatureWriter.java
===================================================================
--- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/IndexedShapefileFeatureWriter.java (rev 0)
+++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/IndexedShapefileFeatureWriter.java 2011-11-27 09:09:29 UTC (rev 38376)
@@ -0,0 +1,146 @@
+/*
+ * GeoTools - The Open Source Java GIS Toolkit
+ * http://geotools.org
+ *
+ * (C) 2008, Open Source Geospatial Foundation (OSGeo)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ */
+package org.geotools.data.shapefile.ng;
+
+import static org.geotools.data.shapefile.ng.files.ShpFileType.*;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.charset.Charset;
+import java.util.TimeZone;
+import java.util.logging.Level;
+
+import org.geotools.data.DataUtilities;
+import org.geotools.data.shapefile.ng.fid.FidIndexer;
+import org.geotools.data.shapefile.ng.fid.IndexedFidWriter;
+import org.geotools.data.shapefile.ng.files.FileWriter;
+import org.geotools.data.shapefile.ng.files.ShpFileType;
+import org.geotools.data.shapefile.ng.files.StorageFile;
+import org.opengis.feature.simple.SimpleFeature;
+
+/**
+ * A FeatureWriter for ShapefileDataStore. Uses a write and annotate technique to avoid buffering
+ * attributes and geometries. Because the shape and dbf require header information which can only be
+ * obtained by reading the entire series of Features, the headers are updated after the initial
+ * write completes.
+ */
+class IndexedShapefileFeatureWriter extends ShapefileFeatureWriter implements FileWriter {
+
+ private IndexedFidWriter fidWriter;
+
+ private String currentFid;
+
+ private IndexManager indexes;
+
+ public IndexedShapefileFeatureWriter(IndexManager indexes,
+ ShapefileFeatureReader featureReader, Charset charset, TimeZone timeZone)
+ throws IOException {
+ super(indexes.shpFiles, featureReader, charset, timeZone);
+ this.indexes = indexes;
+ if (!indexes.shpFiles.isLocal()) {
+ this.fidWriter = IndexedFidWriter.EMPTY_WRITER;
+ } else {
+ StorageFile storageFile = shpFiles.getStorageFile(FIX);
+ storageFiles.put(FIX, storageFile);
+ this.fidWriter = new IndexedFidWriter(shpFiles, storageFile);
+ }
+ }
+
+ @Override
+ public SimpleFeature next() throws IOException {
+ // closed already, error!
+ if (featureReader == null) {
+ throw new IOException("Writer closed");
+ }
+
+ // we have to write the current feature back into the stream
+ if (currentFeature != null) {
+ write();
+ }
+
+ long next = fidWriter.next();
+ currentFid = getFeatureType().getTypeName() + "." + next;
+ SimpleFeature feature = super.next();
+ return feature;
+ }
+
+ @Override
+ protected String nextFeatureId() {
+ return currentFid;
+ }
+
+ @Override
+ public void remove() throws IOException {
+ fidWriter.remove();
+ super.remove();
+ }
+
+ @Override
+ public void write() throws IOException {
+ fidWriter.write();
+ super.write();
+ }
+
+ /**
+ * Release resources and flush the header information.
+ */
+ public void close() throws IOException {
+ super.close();
+ fidWriter.close();
+
+ try {
+ if (shpFiles.isLocal()) {
+ if (indexes.isIndexStale(ShpFileType.FIX)) {
+ FidIndexer.generate(shpFiles);
+ }
+
+ deleteFile(ShpFileType.QIX);
+ }
+ } catch (Throwable e) {
+ ShapefileDataStoreFactory.LOGGER.log(Level.WARNING, "Error creating Spatial index", e);
+ }
+ }
+
+ @Override
+ protected void doClose() throws IOException {
+ super.doClose();
+ try {
+ fidWriter.close();
+ } catch (Throwable e) {
+ ShapefileDataStoreFactory.LOGGER.log(Level.WARNING, "Error creating Feature ID index",
+ e);
+ }
+ }
+
+ private void deleteFile(ShpFileType shpFileType) {
+ URL url = shpFiles.acquireWrite(shpFileType, this);
+ try {
+ File toDelete = DataUtilities.urlToFile(url);
+
+ if (toDelete.exists()) {
+ toDelete.delete();
+ }
+ } finally {
+ shpFiles.unlockWrite(url, this);
+ }
+ }
+
+ public String id() {
+ return getClass().getName();
+ }
+}
Modified: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureReader.java
===================================================================
--- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureReader.java 2011-11-24 10:10:44 UTC (rev 38375)
+++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureReader.java 2011-11-27 09:09:29 UTC (rev 38376)
@@ -25,6 +25,7 @@
import org.geotools.data.shapefile.ng.dbf.DbaseFileHeader;
import org.geotools.data.shapefile.ng.dbf.DbaseFileReader;
import org.geotools.data.shapefile.ng.dbf.DbaseFileReader.Row;
+import org.geotools.data.shapefile.ng.fid.IndexedFidReader;
import org.geotools.data.shapefile.ng.shp.ShapeType;
import org.geotools.data.shapefile.ng.shp.ShapefileReader;
import org.geotools.data.shapefile.ng.shp.ShapefileReader.Record;
@@ -38,7 +39,7 @@
import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry;
-public class ShapefileFeatureReader implements FeatureReader<SimpleFeatureType, SimpleFeature> {
+class ShapefileFeatureReader implements FeatureReader<SimpleFeatureType, SimpleFeature> {
SimpleFeatureType schema;
@@ -62,11 +63,14 @@
int idxBaseLen;
- public ShapefileFeatureReader(SimpleFeatureType schema, ShapefileReader shp, DbaseFileReader dbf)
+ IndexedFidReader fidReader;
+
+ public ShapefileFeatureReader(SimpleFeatureType schema, ShapefileReader shp, DbaseFileReader dbf, IndexedFidReader fidReader)
throws IOException {
this.schema = schema;
this.shp = shp;
this.dbf = dbf;
+ this.fidReader = fidReader;
this.builder = new SimpleFeatureBuilder(schema);
idxBuffer = new StringBuffer(schema.getTypeName());
@@ -217,10 +221,20 @@
builder.add(geometry);
}
// build the feature id
- idxBuffer.delete(idxBaseLen, idxBuffer.length());
- idxBuffer.append(number);
- return builder.buildFeature(idxBuffer.toString());
+ String featureId = buildFeatureId(number);
+ return builder.buildFeature(featureId);
}
+
+ protected String buildFeatureId(int number) throws IOException {
+ if(fidReader == null) {
+ idxBuffer.delete(idxBaseLen, idxBuffer.length());
+ idxBuffer.append(number);
+ return idxBuffer.toString();
+ } else {
+ fidReader.goTo(number - 1);
+ return fidReader.next();
+ }
+ }
@Override
public void close() throws IOException {
Modified: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureSource.java
===================================================================
--- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureSource.java 2011-11-24 10:10:44 UTC (rev 38375)
+++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureSource.java 2011-11-27 09:09:29 UTC (rev 38376)
@@ -39,6 +39,7 @@
import org.geotools.data.ReTypeFeatureReader;
import org.geotools.data.shapefile.ng.dbf.DbaseFileHeader;
import org.geotools.data.shapefile.ng.dbf.DbaseFileReader;
+import org.geotools.data.shapefile.ng.fid.IndexedFidReader;
import org.geotools.data.shapefile.ng.files.FileReader;
import org.geotools.data.shapefile.ng.files.ShpFiles;
import org.geotools.data.shapefile.ng.index.CloseableIterator;
@@ -221,7 +222,7 @@
Filter filter = q != null ? q.getFilter() : null;
IndexManager indexManager = getDataStore().indexManager;
CloseableIterator<Data> goodRecs = null;
- if (getDataStore().isFidIndexed() && filter instanceof Id && indexManager.hasFidIndex()) {
+ if (getDataStore().isFidIndexed() && filter instanceof Id && indexManager.hasFidIndex(false)) {
Id fidFilter = (Id) filter;
List<Data> records = indexManager.queryFidIndex(fidFilter);
if (records != null) {
@@ -242,6 +243,12 @@
goodRecs.close();
return new EmptyFeatureReader<SimpleFeatureType, SimpleFeature>(resultSchema);
}
+
+ // get the .fix file reader, if we have a .fix file
+ IndexedFidReader fidReader = null;
+ if (getDataStore().isFidIndexed() && filter instanceof Id && indexManager.hasFidIndex(false)) {
+ fidReader = new IndexedFidReader(shpFiles);
+ }
// setup the feature readers
ShapefileSetManager shpManager = getDataStore().shpManager;
@@ -256,10 +263,10 @@
}
ShapefileFeatureReader result;
if (goodRecs != null) {
- result = new IndexedShapefileFeatureReader(readSchema, shapeReader, dbfReader,
+ result = new IndexedShapefileFeatureReader(readSchema, shapeReader, dbfReader, fidReader,
goodRecs);
} else {
- result = new ShapefileFeatureReader(readSchema, shapeReader, dbfReader);
+ result = new ShapefileFeatureReader(readSchema, shapeReader, dbfReader, fidReader);
}
// setup the target bbox if any, and the generalization hints if available
Modified: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureStore.java
===================================================================
--- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureStore.java 2011-11-24 10:10:44 UTC (rev 38375)
+++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureStore.java 2011-11-27 09:09:29 UTC (rev 38376)
@@ -60,9 +60,14 @@
ShapefileFeatureReader reader = (ShapefileFeatureReader) delegate
.getReaderInternal(Query.ALL);
- FeatureWriter<SimpleFeatureType, SimpleFeature> writer = new ShapefileFeatureWriter(
- delegate.shpFiles, reader, getDataStore().getCharset(), getDataStore()
- .getTimeZone());
+ FeatureWriter<SimpleFeatureType, SimpleFeature> writer;
+ ShapefileDataStore ds = getDataStore();
+ if(ds.indexManager.hasFidIndex(false) || ds.isFidIndexed() && ds.indexManager.hasFidIndex(true)) {
+ writer = new IndexedShapefileFeatureWriter(ds.indexManager, reader, ds.getCharset(), ds.getTimeZone());
+ } else {
+ writer = new ShapefileFeatureWriter(delegate.shpFiles, reader, ds.getCharset(),
+ ds.getTimeZone());
+ }
// if we only have to add move to the end.
// TODO: just make the code transfer the bytes in bulk instead and start actual writing at
Modified: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/fid/IndexedFidReader.java
===================================================================
--- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/fid/IndexedFidReader.java 2011-11-24 10:10:44 UTC (rev 38375)
+++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/fid/IndexedFidReader.java 2011-11-27 09:09:29 UTC (rev 38376)
@@ -53,7 +53,6 @@
private boolean done;
private int removes;
private int currentShxIndex = -1;
- private RecordNumberTracker reader;
private long currentId;
private StringBuilder fidBuilder;
@@ -70,13 +69,6 @@
init( shpFiles, shpFiles.getReadChannel(FIX, this) );
}
- public IndexedFidReader(ShpFiles shpFiles, RecordNumberTracker reader)
- throws IOException {
- this(shpFiles);
- this.reader = reader;
-
- }
-
public IndexedFidReader( ShpFiles shpFiles, ReadableByteChannel in ) throws IOException {
init(shpFiles, in);
}
@@ -276,12 +268,8 @@
if (buffer != null) {
NIOUtilities.clean(buffer, false);
}
- if (reader != null) {
- reader.close();
- }
} finally {
buffer = null;
- reader = null;
readChannel.close();
streamLogger.close();
}
@@ -308,13 +296,9 @@
}
public String next() throws IOException {
- if (reader != null) {
- goTo(reader.getRecordNumber() - 1);
- }
-
if (!hasNext()) {
throw new NoSuchElementException(
- "Feature could not be read; a the index may be invalid");
+ "FID index could not be read; the index may be invalid");
}
currentId = buffer.getLong();
Modified: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/fid/IndexedFidWriter.java
===================================================================
--- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/fid/IndexedFidWriter.java 2011-11-24 10:10:44 UTC (rev 38375)
+++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/fid/IndexedFidWriter.java 2011-11-27 09:09:29 UTC (rev 38376)
@@ -205,11 +205,13 @@
}
private void finishLastWrite() throws IOException {
- while( hasNext() )
+ while( hasNext() ) {
next();
+ }
- if (current != -1)
+ if (current != -1) {
write();
+ }
drain();
writeHeader();
Deleted: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/fid/RecordNumberTracker.java
===================================================================
--- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/fid/RecordNumberTracker.java 2011-11-24 10:10:44 UTC (rev 38375)
+++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/fid/RecordNumberTracker.java 2011-11-27 09:09:29 UTC (rev 38376)
@@ -1,36 +0,0 @@
-/*
- * GeoTools - The Open Source Java GIS Toolkit
- * http://geotools.org
- *
- * (C) 2005-2008, Open Source Geospatial Foundation (OSGeo)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- */
-package org.geotools.data.shapefile.ng.fid;
-
-import java.io.IOException;
-
-/**
- * A simple interface so that the current feature's record number can be
- * retrieved by the IndexedFidReader
- *
- * @author Jesse
- * @since 1.1.0
- *
- *
- *
- * @source $URL$
- */
-public interface RecordNumberTracker {
- public int getRecordNumber();
-
- public void close() throws IOException;
-}
Modified: trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/fid/FidQueryTest.java
===================================================================
--- trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/fid/FidQueryTest.java 2011-11-24 10:10:44 UTC (rev 38375)
+++ trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/fid/FidQueryTest.java 2011-11-27 09:09:29 UTC (rev 38376)
@@ -205,8 +205,9 @@
query.setFilter(filter);
SimpleFeatureIterator features = featureStore.getFeatures(query).features();
try {
+ assertTrue("Missing feature for fid " + fid, features.hasNext());
SimpleFeature feature = features.next();
- assertFalse(features.hasNext());
+ assertFalse("More than one feature with fid " + fid, features.hasNext());
assertEquals(i + "th feature", entry.getValue(), feature);
} finally {
if (features != null)
|
|
From: <svn...@os...> - 2011-11-24 10:10:58
|
Author: aaime
Date: 2011-11-24 02:10:44 -0800 (Thu, 24 Nov 2011)
New Revision: 38375
Modified:
branches/2.7.x/modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_0_0/WFS_1_0_0_DataStore.java
branches/2.7.x/modules/unsupported/wfs/src/main/java/org/geotools/xml/wfs/WFSBasicComplexTypes.java
Log:
[GEOT-1942] Simplify filters before issuing WFS requests
Modified: branches/2.7.x/modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_0_0/WFS_1_0_0_DataStore.java
===================================================================
--- branches/2.7.x/modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_0_0/WFS_1_0_0_DataStore.java 2011-11-24 10:10:27 UTC (rev 38374)
+++ branches/2.7.x/modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_0_0/WFS_1_0_0_DataStore.java 2011-11-24 10:10:44 UTC (rev 38375)
@@ -74,6 +74,7 @@
import org.geotools.filter.LiteralExpression;
import org.geotools.filter.visitor.DuplicatingFilterVisitor;
import org.geotools.filter.visitor.PostPreProcessFilterSplittingVisitor;
+import org.geotools.filter.visitor.SimplifyingFilterVisitor;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.geotools.referencing.CRS;
import org.geotools.referencing.crs.DefaultGeographicCRS;
@@ -606,6 +607,9 @@
// ogc filter
Map hints = new HashMap();
hints.put(DocumentWriter.BASE_ELEMENT, FilterSchema.getInstance().getElements()[2]); // Filter
+
+ SimplifyingFilterVisitor simplifier = new SimplifyingFilterVisitor();
+ f = (Filter) f.accept(simplifier, null);
StringWriter w = new StringWriter();
Modified: branches/2.7.x/modules/unsupported/wfs/src/main/java/org/geotools/xml/wfs/WFSBasicComplexTypes.java
===================================================================
--- branches/2.7.x/modules/unsupported/wfs/src/main/java/org/geotools/xml/wfs/WFSBasicComplexTypes.java 2011-11-24 10:10:27 UTC (rev 38374)
+++ branches/2.7.x/modules/unsupported/wfs/src/main/java/org/geotools/xml/wfs/WFSBasicComplexTypes.java 2011-11-24 10:10:44 UTC (rev 38375)
@@ -25,6 +25,7 @@
import org.geotools.data.Query;
import org.geotools.filter.Filter;
+import org.geotools.filter.visitor.SimplifyingFilterVisitor;
import org.geotools.xml.PrintHandler;
import org.geotools.xml.filter.FilterSchema;
import org.geotools.xml.gml.GMLComplexTypes;
@@ -583,13 +584,16 @@
}
}
- if (Filter.INCLUDE != query.getFilter()) {
- if ((query.getFilter() != null)
- && elems[1].getType().canEncode(elems[1],
- query.getFilter(), hints)) {
- elems[1].getType().encode(elems[1], query.getFilter(),
+ // simplify the filter before sending it down, it will be faster
+ // and we avoid getting Filter.INCLUDE and Filter.EXCLUDE in and/or
+ // inside the filter (that the encoding code does not know how to handle)
+ org.opengis.filter.Filter filter = query.getFilter();
+ SimplifyingFilterVisitor simplifier = new SimplifyingFilterVisitor();
+ filter = (org.opengis.filter.Filter) filter.accept(simplifier, null);
+ if (Filter.INCLUDE != filter && filter != null && elems[1].getType().canEncode(elems[1],
+ filter, hints)) {
+ elems[1].getType().encode(elems[1], filter,
output, hints);
- }
}
output.endElement(element.getNamespace(), element.getName());
|
|
From: <svn...@os...> - 2011-11-24 10:10:41
|
Author: aaime
Date: 2011-11-24 02:10:27 -0800 (Thu, 24 Nov 2011)
New Revision: 38374
Modified:
branches/2.7.x/modules/library/xml/src/main/java/org/geotools/xml/gml/GMLComplexTypes.java
branches/2.7.x/modules/library/xml/src/test/java/org/geotools/xml/ogc/GeometryEncoderTest.java
Log:
[GEOT-3958] GMLComplexTypes fails to properly encode the SRS for geometries
Modified: branches/2.7.x/modules/library/xml/src/main/java/org/geotools/xml/gml/GMLComplexTypes.java
===================================================================
--- branches/2.7.x/modules/library/xml/src/main/java/org/geotools/xml/gml/GMLComplexTypes.java 2011-11-24 02:17:39 UTC (rev 38373)
+++ branches/2.7.x/modules/library/xml/src/main/java/org/geotools/xml/gml/GMLComplexTypes.java 2011-11-24 10:10:27 UTC (rev 38374)
@@ -65,6 +65,7 @@
import org.opengis.feature.simple.SimpleFeatureType;
import org.opengis.feature.type.AttributeDescriptor;
import org.opengis.feature.type.GeometryDescriptor;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotSupportedException;
@@ -267,19 +268,7 @@
AttributesImpl ai = new AttributesImpl();
- // no GID
- if (g.getUserData() != null) {
- // TODO Fix this when parsing is better ... should be a coord reference system
- ai.addAttribute("", "srsName", "", "anyURI",
- g.getUserData().toString());
- } else {
-// if (g.getSRID() != 0) {
-// // deprecated version
-// ai.addAttribute("", "srsName", "", "anyURI", "" + g.getSRID());
-// } else {
- ai = null;
-// }
- }
+ lookupSrs(g, ai);
if (e == null) {
output.startElement(GMLSchema.NAMESPACE, "Polygon", ai);
@@ -309,18 +298,7 @@
AttributesImpl ai = new AttributesImpl();
- // no GID
- if (g.getUserData() != null) {
- ai.addAttribute("", "srsName", "", "anyURI",
- g.getUserData().toString());
- } else {
- if (g.getSRID() != 0) {
- // deprecated version
- ai.addAttribute("", "srsName", "", "anyURI", "" + g.getSRID());
- } else {
- throw new IOException("srsName required for MultiPoint "+e.getName());
- }
- }
+ lookupSrs(g, ai);
if (e == null) {
output.startElement(GMLSchema.NAMESPACE, "MultiPoint", ai);
@@ -350,18 +328,7 @@
AttributesImpl ai = new AttributesImpl();
- // no GID
- if (g.getUserData() != null) {
- ai.addAttribute("", "srsName", "", "anyURI",
- g.getUserData().toString());
- } else {
- if (g.getSRID() != 0) {
- // deprecated version
- ai.addAttribute("", "srsName", "", "anyURI", "" + g.getSRID());
- } else {
- throw new IOException("srsName required for MultiPoint "+(e==null?"":e.getName()));
- }
- }
+ lookupSrs(g, ai);
if (e == null) {
output.startElement(GMLSchema.NAMESPACE, "MultiLineString", ai);
@@ -390,23 +357,7 @@
AttributesImpl ai = new AttributesImpl();
- // no GID
- if (g.getUserData() != null) {
- ai.addAttribute("", "srsName", "", "anyURI",
- g.getUserData().toString());
- } else {
- if (g.getSRID() != 0) {
- // deprecated version
- ai.addAttribute("", "srsName", "", "anyURI", "" + g.getSRID());
- } else {
- if( e == null ){
- throw new IOException("srsName required for MultiPolygon" );
- }
- else {
- throw new IOException("srsName required for MultiPolygon "+e.getName());
- }
- }
- }
+ lookupSrs(g, ai);
if (e == null) {
output.startElement(GMLSchema.NAMESPACE, "MultiPolygon", ai);
@@ -435,19 +386,7 @@
AttributesImpl ai = new AttributesImpl();
- // no GID
- if (g.getUserData() != null) {
- // TODO Fix this when parsing is better ... should be a coord reference system
- ai.addAttribute("", "srsName", "", "anyURI",
- g.getUserData().toString());
- } else {
-// if (g.getSRID() != 0) {
-// // deprecated version
-// ai.addAttribute("", "srsName", "", "anyURI", "" + g.getSRID());
-// } else {
- ai = null;
-// }
- }
+ lookupSrs(g, ai);
if (e == null) {
output.startElement(GMLSchema.NAMESPACE, "MultiGeometry", ai);
@@ -468,6 +407,26 @@
}
}
+ private static void lookupSrs(Geometry g, AttributesImpl ai) {
+ // no GID
+ if (g.getUserData() instanceof CoordinateReferenceSystem) {
+ try {
+ CoordinateReferenceSystem crs = (CoordinateReferenceSystem) g.getUserData();
+ Integer code = CRS.lookupEpsgCode(crs, false);
+ if(code != null) {
+ ai.addAttribute("", "srsName", "", "anyURI", "http://www.opengis.net/gml/srs/epsg.xml#" + code);
+ }
+ } catch(Exception ex) {
+ logger.log(Level.SEVERE, "Failed to encode geometry CRS", ex);
+ }
+ } else {
+ if (g.getSRID() > 0) {
+ // deprecated version
+ ai.addAttribute("", "srsName", "", "anyURI", "http://www.opengis.net/gml/srs/epsg.xml#" + g.getSRID());
+ }
+ }
+ }
+
static void encodeCoord(Element e, Coordinate coord, PrintHandler output)
throws IOException {
if (coord == null) {
Modified: branches/2.7.x/modules/library/xml/src/test/java/org/geotools/xml/ogc/GeometryEncoderTest.java
===================================================================
--- branches/2.7.x/modules/library/xml/src/test/java/org/geotools/xml/ogc/GeometryEncoderTest.java 2011-11-24 02:17:39 UTC (rev 38373)
+++ branches/2.7.x/modules/library/xml/src/test/java/org/geotools/xml/ogc/GeometryEncoderTest.java 2011-11-24 10:10:27 UTC (rev 38374)
@@ -29,6 +29,8 @@
import junit.framework.TestCase;
import org.geotools.TestData;
+import org.geotools.referencing.CRS;
+import org.geotools.referencing.crs.DefaultGeographicCRS;
import org.geotools.xml.PrintHandler;
import org.geotools.xml.XSISAXHandler;
import org.geotools.xml.schema.Element;
@@ -76,9 +78,9 @@
new Coordinate(0,0)
});
Polygon polygon = factory.createPolygon(ring, new LinearRing[0]);
- polygon.setUserData("EPSG:4326");
+ polygon.setUserData(CRS.decode("EPSG:4326"));
MultiPolygon geom = factory.createMultiPolygon(new Polygon[]{polygon});
- geom.setUserData("EPSG:4326");
+ geom.setUserData(CRS.decode("EPSG:4326"));
final StringWriter writer = new StringWriter();
// DocumentWriter.writeDocument(geom, schema, writer, new HashMap());
@@ -136,7 +138,8 @@
};
geomElement.getType().encode(geomElement, geom, output, new HashMap());
- String expected="<GEOM><MultiPolygon srsName=EPSG:4326><polygonMember><Polygon srsName=EPSG:4326><outerBoundaryIs><LinearRing><coordinates decimal=. cs=, ts= >0.0,0.0 10.0,0.0 0.0,10.0 0.0,0.0</coordinates></LinearRing></outerBoundaryIs></Polygon></polygonMember></MultiPolygon></GEOM>";
+ String expected="<GEOM><MultiPolygon srsName=http://www.opengis.net/gml/srs/epsg.xml#4326><polygonMember><Polygon srsName=http://www.opengis.net/gml/srs/epsg.xml#4326><outerBoundaryIs><LinearRing><coordinates decimal=. cs=, ts= >0.0,0.0 10.0,0.0 0.0,10.0 0.0,0.0</coordinates></LinearRing></outerBoundaryIs></Polygon></polygonMember></MultiPolygon></GEOM>";
+ System.out.println(writer.toString());
assertEquals(expected, writer.toString());
}
|
Author: mleslie Date: 2011-11-23 18:17:39 -0800 (Wed, 23 Nov 2011) New Revision: 38373 Added: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geogit/ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geogit/storage/ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geogit/storage/hessian/ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geogit/storage/hessian/GtEntityType.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geogit/storage/hessian/HessianSimpleFeatureTypeReader.java trunk/modules/unsupported/geogit-versioned/src/main/java/org/geogit/storage/hessian/HessianSimpleFeatureTypeWriter.java trunk/modules/unsupported/geogit-versioned/src/test/java/org/geotools/ trunk/modules/unsupported/geogit-versioned/src/test/java/org/geotools/data/ trunk/modules/unsupported/geogit-versioned/src/test/java/org/geotools/data/geogit/ Modified: trunk/modules/unsupported/geogit-versioned/pom.xml trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitDataStore.java 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/versioning/decorator/DecoratedTestCase.java trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/UnversionedTest.java Log: Adding feature type serialisation to fix the build. Modified: trunk/modules/unsupported/geogit-versioned/pom.xml =================================================================== --- trunk/modules/unsupported/geogit-versioned/pom.xml 2011-11-23 06:24:16 UTC (rev 38372) +++ trunk/modules/unsupported/geogit-versioned/pom.xml 2011-11-24 02:17:39 UTC (rev 38373) @@ -123,7 +123,23 @@ <groupId>org.geotools</groupId> <artifactId>gt-property</artifactId> <version>8-SNAPSHOT</version> + <scope>test</scope> </dependency> </dependencies> - + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>2.2</version> + <executions> + <execution> + <goals> + <goal>test-jar</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> </project> Added: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geogit/storage/hessian/GtEntityType.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/main/java/org/geogit/storage/hessian/GtEntityType.java (rev 0) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geogit/storage/hessian/GtEntityType.java 2011-11-24 02:17:39 UTC (rev 38373) @@ -0,0 +1,125 @@ +/* Copyright (c) 2011 TOPP - www.openplans.org. All rights reserved. + * This code is licensed under the LGPL 2.0 license, available at the root + * application directory. + */ +package org.geogit.storage.hessian; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.math.BigInteger; + +import com.vividsolutions.jts.geom.Geometry; + +/** + * This enum describes the data type of each encoded feature attribute. + * + * The integer value of each data type should never be changed, for backwards compatibility + * purposes. If the method of encoding of an attribute type is changed, a new type should be + * created, with a new value, and the writers updated to use it. The readers should continue to + * support both the old and new versions. + * + * @author mleslie + */ +enum GtEntityType implements Serializable { + STRING(0, String.class), BOOLEAN(1, Boolean.class), BYTE(2, Byte.class), DOUBLE(3, Double.class), + BIGDECIMAL(4, BigDecimal.class), FLOAT(5, Float.class), INT(6, Integer.class), + BIGINT(7, BigInteger.class), LONG(8, Long.class), BOOLEAN_ARRAY(11, boolean[].class), + BYTE_ARRAY(12, byte[].class), CHAR_ARRAY(13, char[].class), DOUBLE_ARRAY(14, double[].class), + FLOAT_ARRAY(15, float[].class), INT_ARRAY(16, int[].class), LONG_ARRAY(17, long[].class), + GEOMETRY(9, Geometry.class), NULL(10, null), UNKNOWN_SERIALISABLE(18, Serializable.class), + UNKNOWN(19, null), UUID(20, java.util.UUID.class); + + public static GtEntityType determineType(Object value) { + if (value == null) + return NULL; + if (value instanceof String) + return STRING; + if (value instanceof Boolean) + return BOOLEAN; + if (value instanceof Byte) + return BYTE; + if (value instanceof Double) + return DOUBLE; + if (value instanceof BigDecimal) + return BIGDECIMAL; + if (value instanceof Float) + return FLOAT; + if (value instanceof Integer) + return INT; + if (value instanceof BigInteger) + return BIGINT; + if (value instanceof Long) + return LONG; + if (value instanceof boolean[]) + return BOOLEAN_ARRAY; + if (value instanceof byte[]) + return BYTE_ARRAY; + if (value instanceof char[]) + return CHAR_ARRAY; + if (value instanceof double[]) + return DOUBLE_ARRAY; + if (value instanceof float[]) + return FLOAT_ARRAY; + if (value instanceof int[]) + return INT_ARRAY; + if (value instanceof long[]) + return LONG_ARRAY; + if (value instanceof java.util.UUID) + return UUID; + if (value instanceof Geometry) + return GEOMETRY; + if (value instanceof Serializable) + return UNKNOWN_SERIALISABLE; + return UNKNOWN; + } + + private int value; + private Class binding; + + private GtEntityType(int value, Class binding) { + this.value = value; + this.binding = binding; + } + + public int getValue() { + return this.value; + } + + public Class getBinding() { + return this.binding; + } + + public static GtEntityType fromBinding(Class cls) { + if(cls == null) + return NULL; + /* + * We're handling equality first, as some entity types are top-level + * catch-alls, and we can't rely on processing order to ensure the + * more specific cases are handled first. + */ + for (GtEntityType type : GtEntityType.values()) { + if(type.binding != null && type.binding.equals(cls)) + return type; + } + for (GtEntityType type : GtEntityType.values()) { + if(type.binding != null && type.binding.isAssignableFrom(cls)) + return type; + } + return UNKNOWN; + } + + /** + * Determines the EntityType given its integer value. + * + * @param value The value of the desired EntityType, as read from the blob + * @return The correct EntityType for the value, or null if none is found. + */ + public static GtEntityType fromValue(int value) { + for (GtEntityType type : GtEntityType.values()) { + if (type.value == value) { + return type; + } + } + return null; + } +} \ No newline at end of file Added: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geogit/storage/hessian/HessianSimpleFeatureTypeReader.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/main/java/org/geogit/storage/hessian/HessianSimpleFeatureTypeReader.java (rev 0) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geogit/storage/hessian/HessianSimpleFeatureTypeReader.java 2011-11-24 02:17:39 UTC (rev 38373) @@ -0,0 +1,148 @@ +package org.geogit.storage.hessian; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +import org.geogit.api.ObjectId; +import org.geogit.storage.ObjectReader; +import org.geotools.feature.NameImpl; +import org.geotools.feature.simple.SimpleFeatureTypeBuilder; +import org.geotools.referencing.CRS; +import org.opengis.feature.simple.SimpleFeatureType; +import org.opengis.feature.type.AttributeDescriptor; +import org.opengis.feature.type.AttributeType; +import org.opengis.feature.type.FeatureTypeFactory; +import org.opengis.feature.type.GeometryType; +import org.opengis.feature.type.Name; +import org.opengis.filter.Filter; +import org.opengis.referencing.FactoryException; +import org.opengis.referencing.crs.CoordinateReferenceSystem; +import org.opengis.util.InternationalString; + +import com.caucho.hessian.io.Hessian2Input; +import com.google.common.base.Preconditions; +import com.google.common.base.Throwables; +import com.vividsolutions.jts.geom.Geometry; + +public class HessianSimpleFeatureTypeReader implements ObjectReader<SimpleFeatureType> { + + private Name typeName; + private SimpleFeatureTypeBuilder builder; + private FeatureTypeFactory typeFactory; + + public HessianSimpleFeatureTypeReader(final Name typeName) { + Preconditions.checkNotNull(typeName); + this.typeName = typeName; + this.builder = new SimpleFeatureTypeBuilder(); + this.typeFactory = builder.getFeatureTypeFactory(); + } + + @Override + public SimpleFeatureType read(ObjectId id, InputStream rawData) + throws IOException { + Hessian2Input hin = new Hessian2Input(rawData); + try { + hin.startMessage(); + String typeNamespace = hin.readString(); + String typeName = hin.readString(); + int attributeCount = hin.readInt(); + SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); + for(int i = 0; i < attributeCount; i++) { + try { + builder.add(readDescriptor(hin)); + } catch(FactoryException ex) { + Throwables.propagate(ex); + } + } + hin.completeMessage(); + + builder.setName(new NameImpl( + "".equals(typeNamespace) ? null : typeNamespace, typeName)); + SimpleFeatureType type = builder.buildFeatureType(); + return type; + } finally { + hin.close(); + } + } + + /** + * The format will be written as follows: + * <ol> + * <li>EntityType - int</li> + * <li>nillable - boolean</li> + * <li>property namespace - String</li> + * <li>property name - String</li> + * <li>max - int</li> + * <li>min - int</li> + * <li>type namespace - String</li> + * <li>type name - String</li> + * </ol> + * If the entity type is a geometry, then there is an additional (srid - String) field at the end. + * + * @param hout + */ + private AttributeDescriptor readDescriptor(Hessian2Input hin) throws IOException, FactoryException { + int typeValue = hin.readInt(); + GtEntityType type = GtEntityType.fromValue(typeValue); + Class binding = type.getBinding(); + boolean nillable = hin.readBoolean(); + String pNamespace = hin.readString(); + String pName = hin.readString(); + int maxOccurs = hin.readInt(); + int minOccurs = hin.readInt(); + String tNamespace = hin.readString(); + String tName = hin.readString(); + String geomTypeName = null; + String crsText = null; + boolean crsCode = false; + if(GtEntityType.GEOMETRY.equals(type)) { + Object bObj = hin.readObject(); + if(bObj instanceof Class) { + binding = (Class)bObj; + } + crsCode = hin.readBoolean(); + crsText = hin.readString(); + } + + /* + * Default values that are currently not encoded. + */ + boolean isIdentifiable = false; + boolean isAbstract = false; + List<Filter> restrictions = null; + AttributeType superType = null; + InternationalString description = null; + Object defaultValue = null; + + + Name propertyName = new NameImpl( + "".equals(pNamespace) ? null : pNamespace, pName); + Name typeName = new NameImpl( + "".equals(tNamespace) ? null : tNamespace, tName); + + AttributeType attributeType; + AttributeDescriptor attributeDescriptor; + if(GtEntityType.GEOMETRY.equals(type)) { + CoordinateReferenceSystem crs; + if(crsCode) { + if("urn:ogc:def:crs:EPSG::0".equals(crsText)) { + crs = null; + } else { + crs = CRS.decode(crsText); + } + } else { + crs = CRS.parseWKT(crsText); + } + attributeType = typeFactory.createGeometryType(typeName, binding, crs, isIdentifiable, isAbstract, restrictions, superType, description); + attributeDescriptor = typeFactory.createGeometryDescriptor((GeometryType)attributeType, propertyName, minOccurs, maxOccurs, nillable, defaultValue); + } else { + attributeType = typeFactory.createAttributeType(typeName, binding, isIdentifiable, isAbstract, restrictions, superType, description); + attributeDescriptor = typeFactory.createAttributeDescriptor(attributeType, propertyName, minOccurs, maxOccurs, nillable, defaultValue); + } + return attributeDescriptor; + + } + +} Added: trunk/modules/unsupported/geogit-versioned/src/main/java/org/geogit/storage/hessian/HessianSimpleFeatureTypeWriter.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/main/java/org/geogit/storage/hessian/HessianSimpleFeatureTypeWriter.java (rev 0) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geogit/storage/hessian/HessianSimpleFeatureTypeWriter.java 2011-11-24 02:17:39 UTC (rev 38373) @@ -0,0 +1,110 @@ +package org.geogit.storage.hessian; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.List; + +import org.geogit.storage.ObjectWriter; +import org.geotools.referencing.CRS; +import org.geotools.referencing.wkt.Formattable; +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.feature.type.Name; +import org.opengis.referencing.crs.CoordinateReferenceSystem; + +import com.caucho.hessian.io.Hessian2Output; +import com.google.common.base.Preconditions; + +public class HessianSimpleFeatureTypeWriter implements + ObjectWriter<SimpleFeatureType> { + + private SimpleFeatureType type; + + public HessianSimpleFeatureTypeWriter(final SimpleFeatureType type) { + Preconditions.checkNotNull(type); + this.type = type; + } + + @Override + public void write(OutputStream out) throws IOException { + Hessian2Output hout = new Hessian2Output(out); + try { + hout.startMessage(); + Name typeName = type.getName(); + hout.writeString(typeName.getNamespaceURI() == null ? "" : typeName.getNamespaceURI()); + hout.writeString(typeName.getLocalPart()); + List<AttributeDescriptor> descriptors = type.getAttributeDescriptors(); + hout.writeInt(descriptors.size()); + for(AttributeDescriptor descriptor : descriptors) { + writeDescriptor(hout, descriptor); + } + + hout.completeMessage(); + } finally { + hout.flush(); + hout.close(); + } + } + + /** + * The format will be written as follows: + * <ol> + * <li>EntityType - int</li> + * <li>nillable - boolean</li> + * <li>property namespace - String</li> + * <li>property name - String</li> + * <li>max - int</li> + * <li>min - int</li> + * <li>type namespace - String</li> + * <li>type name - String</li> + * </ol> + * If the entity type is a geometry, then there are additional fields, + * <ol> + * <li>geometry type - String</li> + * <li>crs code - boolean</li> + * <li>crs text - String</li> + * </ol> + * + * @param hout + */ + private void writeDescriptor(Hessian2Output hout, AttributeDescriptor descriptor) throws IOException { + AttributeType attrType = descriptor.getType(); + GtEntityType type = GtEntityType.fromBinding(attrType.getBinding()); + hout.writeInt(type.getValue()); + hout.writeBoolean(descriptor.isNillable()); + Name propertyName = descriptor.getName(); + hout.writeString(propertyName.getNamespaceURI() == null ? "" : propertyName.getNamespaceURI()); + hout.writeString(propertyName.getLocalPart()); + hout.writeInt(descriptor.getMaxOccurs()); + hout.writeInt(descriptor.getMinOccurs()); + Name typeName = attrType.getName(); + hout.writeString(typeName.getNamespaceURI() == null ? "" : typeName.getNamespaceURI()); + hout.writeString(typeName.getLocalPart()); + if(type.equals(GtEntityType.GEOMETRY) && attrType instanceof GeometryType) { + GeometryType gt = (GeometryType)attrType; + hout.writeObject(gt.getBinding()); + CoordinateReferenceSystem crs = gt.getCoordinateReferenceSystem(); + String srsName; + if(crs == null) { + srsName = "urn:ogc:def:crs:EPSG::0"; + } else { + srsName = CRS.toSRS(crs); + } + if(srsName != null) { + hout.writeBoolean(true); + hout.writeString(srsName); + } else { + String wkt; + if(crs instanceof Formattable) { + wkt = ((Formattable)crs).toWKT(Formattable.SINGLE_LINE); + } else { + wkt = crs.toWKT(); + } + hout.writeBoolean(false); + hout.writeString(wkt); + } + } + } +} Modified: 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 2011-11-23 06:24:16 UTC (rev 38372) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitDataStore.java 2011-11-24 02:17:39 UTC (rev 38373) @@ -34,6 +34,8 @@ 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; @@ -237,10 +239,11 @@ try { final ObjectId featureTypeBlobId; - WrappedSerialisingFactory serialisingFactory; - serialisingFactory = WrappedSerialisingFactory.getInstance(); - featureTypeBlobId = objectDatabase.put(serialisingFactory - .createSimpleFeatureTypeWriter(createType)); +// WrappedSerialisingFactory serialisingFactory; +// serialisingFactory = WrappedSerialisingFactory.getInstance(); +// featureTypeBlobId = objectDatabase.put(serialisingFactory +// .createSimpleFeatureTypeWriter(createType)); + featureTypeBlobId = objectDatabase.put(new HessianSimpleFeatureTypeWriter(createType)); final List<String> namespaceTreePath = Collections .singletonList(namespace); @@ -295,8 +298,10 @@ final ObjectId objectId = typeRef.getObjectId(); WrappedSerialisingFactory serialisingFactory; serialisingFactory = WrappedSerialisingFactory.getInstance(); - final ObjectReader<SimpleFeatureType> reader = serialisingFactory - .createSimpleFeatureTypeReader(name); +// final ObjectReader<SimpleFeatureType> reader = serialisingFactory +// .createSimpleFeatureTypeReader(name); + final ObjectReader<SimpleFeatureType> reader = + new HessianSimpleFeatureTypeReader(name); final SimpleFeatureType featureType = objectDatabase.get(objectId, reader); return featureType; 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/GeoGitDataStoreTest.java 2011-11-23 06:24:16 UTC (rev 38372) +++ trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/geogit/GeoGitDataStoreTest.java 2011-11-24 02:17:39 UTC (rev 38373) @@ -29,6 +29,7 @@ import org.geogit.storage.ObjectDatabase; import org.geogit.storage.RefDatabase; import org.geogit.storage.WrappedSerialisingFactory; +import org.geogit.storage.hessian.HessianSimpleFeatureTypeReader; import org.geogit.test.RepositoryTestCase; import org.geotools.data.SchemaNotFoundException; import org.geotools.data.simple.SimpleFeatureSource; @@ -91,9 +92,11 @@ WrappedSerialisingFactory serialisingFactory; serialisingFactory = WrappedSerialisingFactory.getInstance(); - SimpleFeatureType readType = objectDatabase.get(typeRef - .getObjectId(), serialisingFactory - .createSimpleFeatureTypeReader(featureType.getName())); +// SimpleFeatureType readType = objectDatabase.get(typeRef +// .getObjectId(), serialisingFactory +// .createSimpleFeatureTypeReader(featureType.getName())); + SimpleFeatureType readType = objectDatabase.get(typeRef.getObjectId(), + new HessianSimpleFeatureTypeReader(featureType.getName())); assertEquals(featureType, readType); Modified: trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/DecoratedTestCase.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/DecoratedTestCase.java 2011-11-23 06:24:16 UTC (rev 38372) +++ trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/DecoratedTestCase.java 2011-11-24 02:17:39 UTC (rev 38373) @@ -17,9 +17,7 @@ package org.geoserver.data.versioning.decorator; import java.io.File; -import java.io.IOException; import java.util.ArrayList; -import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -32,18 +30,17 @@ import org.geotools.data.DataUtilities; import org.geotools.data.DefaultTransaction; import org.geotools.data.Transaction; -import org.geotools.data.property.PropertyDataStore; import org.geotools.data.property.PropertyDataStoreFactory; import org.geotools.data.simple.SimpleFeatureStore; import org.geotools.factory.Hints; import org.geotools.feature.DefaultFeatureCollection; -import org.geotools.feature.FeatureCollection; +import org.geotools.feature.NameImpl; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.filter.FilterFactoryImpl; import org.geotools.util.logging.Logging; -import org.opengis.feature.Feature; import org.opengis.feature.simple.SimpleFeature; import org.opengis.feature.simple.SimpleFeatureType; +import org.opengis.feature.type.Name; import org.opengis.filter.Filter; import org.opengis.filter.FilterFactory2; import org.opengis.filter.identity.FeatureId; @@ -69,6 +66,8 @@ private static String newString3 = "Third iteration change."; protected SimpleFeatureType sampleType; + + protected Name sampleTypeName = new NameImpl(sampleNs, sampleName); protected SimpleFeature sample1; @@ -99,6 +98,8 @@ protected static final String testTypeSpec = "st:String,ln:LineString:srid=4326,it:Integer"; protected SimpleFeatureType testType; + + protected Name testTypeName = new NameImpl(sampleNs, sampleName); protected SimpleFeature test1; @@ -123,7 +124,7 @@ * Holds a reference to the decorated datastore that will track versioning * info in the backing geogit repository. */ - protected DataStore versioned; + protected DataStoreDecorator versioned; private Integer newInt = new Integer(0); @@ -408,12 +409,12 @@ /** * This function is meant to compare feature contents with test features, * and as such, needs to ignore featureVersion or rid information - * in FeatureId's. + * in FeatureId's, as this won't be available during initial creation. * @param feat * @param otherFeat * @return */ - private boolean compareFeature(SimpleFeature feat, SimpleFeature otherFeat) { + protected boolean compareFeature(SimpleFeature feat, SimpleFeature otherFeat) { FeatureId fid = feat.getIdentifier(); FeatureId otherFid = otherFeat.getIdentifier(); if(!fid.equalsFID(otherFid)) { Modified: trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/UnversionedTest.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/UnversionedTest.java 2011-11-23 06:24:16 UTC (rev 38372) +++ trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/UnversionedTest.java 2011-11-24 02:17:39 UTC (rev 38373) @@ -148,7 +148,7 @@ assertTrue(feats.hasNext()); SimpleFeature feat = feats.next(); assertNotNull(feat); - assertTrue(feat.equals(expectedFeature)); + compareFeature(feat, expectedFeature); assertFalse(feats.hasNext()); } finally { if (feats != null) |
|
From: <svn...@os...> - 2011-11-23 06:24:25
|
Author: jive Date: 2011-11-22 22:24:16 -0800 (Tue, 22 Nov 2011) New Revision: 38372 Removed: trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyAttributeWriter.java trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyDataStore.java trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyDataStoreFactory.java trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyFeatureReader.java trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyFeatureSource.java trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyFeatureStore.java trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyFeatureWriter.java trunk/modules/unsupported/property-ng/src/test/java/org/geotools/data/property/PropertyDataStore2Test.java trunk/modules/unsupported/property-ng/src/test/java/org/geotools/data/property/PropertyDataStoreTest.java trunk/modules/unsupported/property-ng/src/test/java/org/geotools/data/property/PropertyExamples.java Log: moved to property ng Deleted: trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyAttributeWriter.java =================================================================== --- trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyAttributeWriter.java 2011-11-23 06:23:55 UTC (rev 38371) +++ trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyAttributeWriter.java 2011-11-23 06:24:16 UTC (rev 38372) @@ -1,152 +0,0 @@ -/* - * GeoTools - The Open Source Java GIS Toolkit - * http://geotools.org - * - * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ -package org.geotools.data.property; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; - -import org.geotools.data.AttributeWriter; -import org.geotools.data.DataUtilities; -import org.geotools.util.Converters; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.feature.type.AttributeDescriptor; - -import com.vividsolutions.jts.geom.Geometry; - -/** - * Simple AttributeWriter that produces Java properties files. - * <p> - * This AttributeWriter is part of the geotools2 DataStore tutorial, and should - * be considered a Toy. - * </p> - * <p> - * The content produced witll start with the property "_" with the value being - * the typeSpec describing the featureType. Thereafter each line will represent - * a Features with FeatureID as the property and the attribtues as the value - * separated by | characters. - * </p> - * - * <pre> - * <code> - * _=id:Integer|name:String|geom:Geometry - * fid1=1|Jody|<i>well known text</i> - * fid2=2|Brent|<i>well known text</i> - * fid3=3|Dave|<i>well known text</i> - * </code> - * </pre> - * - * @author Jody Garnett - * - * - * @source $URL$ - */ -public class PropertyAttributeWriter implements AttributeWriter { - BufferedWriter writer; - - SimpleFeatureType type; - - public PropertyAttributeWriter(File file, SimpleFeatureType featureType) - throws IOException { - writer = new BufferedWriter(new FileWriter(file)); - type = featureType; - writer.write("_="); - writer.write(DataUtilities.spec(type)); - } - - public int getAttributeCount() { - return type.getAttributeCount(); - } - - public AttributeDescriptor getAttributeType(int index) - throws ArrayIndexOutOfBoundsException { - return type.getDescriptor(index); - } - // constructor end - // next start - public boolean hasNext() throws IOException { - return false; - } - - public void next() throws IOException { - if (writer == null) { - throw new IOException("Writer has been closed"); - } - writer.newLine(); - writer.flush(); - } - // next end - - // writeFeatureID start - public void writeFeatureID(String fid) throws IOException { - if (writer == null) { - throw new IOException("Writer has been closed"); - } - writer.write(fid); - } - // writeFeatureID end - - // write start - public void write(int position, Object attribute) throws IOException { - if (writer == null) { - throw new IOException("Writer has been closed"); - } - writer.write(position == 0 ? "=" : "|"); - if (attribute == null) { - writer.write("<null>"); // nothing! - } else if( attribute instanceof String){ - // encode newlines - String txt = (String) attribute; - txt = txt.replace("\n", "\\n"); - txt = txt.replace("\r", "\\r"); - writer.write( txt ); - } else if (attribute instanceof Geometry) { - Geometry geometry = (Geometry) attribute; - writer.write( geometry.toText() ); - } else { - String txt = Converters.convert( attribute, String.class ); - if( txt == null ){ // could not convert? - txt = attribute.toString(); - } - writer.write( txt ); - } - } - // write end - - // close start - public void close() throws IOException { - if (writer == null) { - throw new IOException("Writer has already been closed"); - } - writer.close(); - writer = null; - type = null; - } - // close end - // echoLine start - public void echoLine(String line) throws IOException { - if (writer == null) { - throw new IOException("Writer has been closed"); - } - if (line == null) { - return; - } - writer.write(line); - } - // echoLine end -} Deleted: trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyDataStore.java =================================================================== --- trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyDataStore.java 2011-11-23 06:23:55 UTC (rev 38371) +++ trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyDataStore.java 2011-11-23 06:24:16 UTC (rev 38372) @@ -1,144 +0,0 @@ -/* - * GeoTools - The Open Source Java GIS Toolkit - * http://geotools.org - * - * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ -package org.geotools.data.property; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileWriter; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.List; - -import org.geotools.data.DataUtilities; -import org.geotools.data.DefaultServiceInfo; -import org.geotools.data.Query; -import org.geotools.data.ServiceInfo; -import org.geotools.data.store.ContentDataStore; -import org.geotools.data.store.ContentEntry; -import org.geotools.data.store.ContentFeatureSource; -import org.geotools.factory.CommonFactoryFinder; -import org.geotools.feature.FeatureTypes; -import org.geotools.feature.NameImpl; -import org.geotools.feature.type.FeatureTypeFactoryImpl; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.feature.type.Name; - -import com.vividsolutions.jts.geom.GeometryFactory; - -/** - * Sample DataStore implementation, please see formal tutorial included with - * users docs. - * - * @author Jody Garnett, Refractions Research Inc. - * - * - * @source $URL$ - */ -public class PropertyDataStore extends ContentDataStore { - protected File file; - - public PropertyDataStore(File dir) { - this(dir, null); - } - - // constructor start - public PropertyDataStore(File file, String namespaceURI) { - if (file.isDirectory()) { - throw new IllegalArgumentException(file + " must be a property file"); - } - if (namespaceURI == null) { - if( file.getParent() != null ){ - namespaceURI = file.getParentFile().getName(); - } - } - this.file = file; - setNamespaceURI(namespaceURI); - // - // factories - setFilterFactory(CommonFactoryFinder.getFilterFactory(null)); - setGeometryFactory(new GeometryFactory()); - setFeatureTypeFactory(new FeatureTypeFactoryImpl()); - setFeatureFactory(CommonFactoryFinder.getFeatureFactory(null)); - } - // constructor end - - // createSchema start - public void createSchema(SimpleFeatureType featureType) throws IOException { - if( file.exists() ){ - throw new FileNotFoundException("Unable to create a new property file: file exists "+file); - } - String typeName = featureType.getTypeName(); - BufferedWriter writer = new BufferedWriter(new FileWriter(file)); - writer.write("_="); - writer.write(DataUtilities.spec(featureType)); - writer.flush(); - writer.close(); - } - - // createSchema end - - // info start - public ServiceInfo getInfo() { - DefaultServiceInfo info = new DefaultServiceInfo(); - info.setDescription("Features from " + file ); - info.setSchema(FeatureTypes.DEFAULT_NAMESPACE); - info.setSource(file.toURI()); - try { - info.setPublisher(new URI(System.getProperty("user.name"))); - } catch (URISyntaxException e) { - } - return info; - } - - // info end - - public void setNamespaceURI(String namespaceURI) { - this.namespaceURI = namespaceURI; - } - - protected java.util.List<Name> createTypeNames() throws IOException { - String name = file.getName(); - String typeName = name.substring(0,name.lastIndexOf('.')); - List<Name> typeNames = new ArrayList<Name>(); - typeNames.add( new NameImpl(namespaceURI, typeName)); - return typeNames; - } - - public List<Name> getNames() throws IOException { - String[] typeNames = getTypeNames(); - List<Name> names = new ArrayList<Name>(typeNames.length); - for (String typeName : typeNames) { - names.add(new NameImpl(namespaceURI, typeName)); - } - return names; - } - - @Override - protected ContentFeatureSource createFeatureSource(ContentEntry entry) throws IOException { - if( file.canWrite() ){ - return new PropertyFeatureStore( entry, Query.ALL ); - } - else { - return new PropertyFeatureSource( entry, Query.ALL ); - } - } - - -} Deleted: trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyDataStoreFactory.java =================================================================== --- trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyDataStoreFactory.java 2011-11-23 06:23:55 UTC (rev 38371) +++ trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyDataStoreFactory.java 2011-11-23 06:24:16 UTC (rev 38372) @@ -1,162 +0,0 @@ -/* - * GeoTools - The Open Source Java GIS Toolkit - * http://geotools.org - * - * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ -package org.geotools.data.property; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Map; -import java.util.logging.Logger; - -import org.geotools.data.DataStore; -import org.geotools.data.DataStoreFactorySpi; - - -/** - * DataStore factory that creates {@linkplain org.geotools.data.property.PropertyDataStore}s - * - * @author Jody garnett - * - * - * @source $URL$ - * @version $Id$ - */ -public class PropertyDataStoreFactory implements DataStoreFactorySpi { - // private static final Logger LOGGER = org.geotools.util.logging.Logging.getLogger(PropertyDataStoreFactory.class.getPackage().getName()); - - public static final Param FILE = new Param("file", File.class, - "Property file", true); - - public static final Param NAMESPACE = new Param("namespace", String.class, - "namespace of datastore", false); - - public DataStore createDataStore(Map params) throws IOException { - File dir = fileLookup(params); - String namespaceURI = (String) NAMESPACE.lookUp( params ); - if (dir.exists() && dir.isDirectory()) { - return new PropertyDataStore(dir,namespaceURI); - } else { - throw new IOException("Directory is required"); - } - } - - // createNewDataStore start - public DataStore createNewDataStore(Map params) throws IOException { - File dir = (File)FILE.lookUp(params); - - if (dir.exists()) { - throw new IOException(dir + " already exists"); - } - - String namespaceURI = (String) NAMESPACE.lookUp(params); - return new PropertyDataStore(dir,namespaceURI); - } - // createNewDataStore end - - public String getDisplayName() { - return "Properties NG"; - } - - public String getDescription() { - return "Allows access to Java Property files containing Feature information"; - } - - /** - * @see #DIRECTORY - * @see PropertyDataStoreFactory#NAMESPACE - */ - public Param[] getParametersInfo() { - return new Param[] { FILE, NAMESPACE }; - } - - /** - * Test to see if this datastore is available, if it has all the - * appropriate libraries to construct a datastore. This datastore just - * returns true for now. This method is used for gui apps, so as to not - * advertise data store capabilities they don't actually have. - * - * @return <tt>true</tt> if and only if this factory is available to create - * DataStores. - * - * @task <code>true</code> property datastore is always available - */ - public boolean isAvailable() { - return true; - } - - /** - * Works for a file directory or property file - * - * @param params Connection parameters - * - * @return true for connection parameters indicating a directory or property file - */ - public boolean canProcess(Map params) { - try { - fileLookup(params); - return true; - } catch (Exception erp) { - //can't process, just return false - return false; - } - } - - /** - * No implementation hints are provided at this time. - */ - public Map getImplementationHints(){ - return java.util.Collections.EMPTY_MAP; - } - - /** - * Lookups the property file in the params argument, and - * returns the corresponding <code>java.io.File</code>. - * <p> - * The file is first checked for existence as an absolute path in the filesystem. If - * such a directory is not found, then it is treated as a relative path, taking Java - * system property <code>"user.dir"</code> as the base. - * </p> - * @param params - * @throws IllegalArgumentException if file is a directory. - * @throws FileNotFoundException if directory does not exists - * @throws IOException if {@linkplain #DIRECTORY} doesn't find parameter in <code>params</code> - * file does not exists. - */ - private File fileLookup(Map params) throws IOException, FileNotFoundException, - IllegalArgumentException { - File file = (File) FILE.lookUp(params); - if( file.exists() ){ - if( file.isDirectory() ){ - throw new IllegalArgumentException("Property file is required (not a directory) "+file.getAbsolutePath()); - } - return file; - } - else { - File dir = file.getParentFile(); - if( dir == null || !dir.exists() ){ - // quickly check if it exists relative to the user directory - File currentDir = new File(System.getProperty("user.dir")); - - File file2 = new File(currentDir, file.getPath()); - if (file2.exists()) { - return file2; - } - } - return file; - } - } -} \ No newline at end of file Deleted: trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyFeatureReader.java =================================================================== --- trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyFeatureReader.java 2011-11-23 06:23:55 UTC (rev 38371) +++ trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyFeatureReader.java 2011-11-23 06:24:16 UTC (rev 38372) @@ -1,289 +0,0 @@ -/* - * GeoTools - The Open Source Java GIS Toolkit - * http://geotools.org - * - * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ -package org.geotools.data.property; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.util.NoSuchElementException; -import java.util.Properties; -import java.util.logging.Logger; - -import org.geotools.data.DataSourceException; -import org.geotools.data.DataUtilities; -import org.geotools.data.FeatureReader; -import org.geotools.feature.SchemaException; -import org.geotools.feature.simple.SimpleFeatureBuilder; -import org.geotools.util.Converters; -import org.geotools.util.logging.Logging; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.feature.type.AttributeDescriptor; -import org.opengis.feature.type.GeometryType; -import org.opengis.referencing.crs.CoordinateReferenceSystem; - -import com.vividsolutions.jts.geom.Geometry; - -/** - * Read a property file directly. - * <p> - * This implementation does not perform any filtering or processing; it leaves that up to wrappers to manipulate the content into the format or - * projection requested by the user. - * <p> - * - * <p> - * The content of this file should start with a the property "_" with the value being the typeSpec describing the featureType. Thereafter each line - * will should have a FeatureID as the property and the attribtues as the value separated by | characters. - * </p> - * - * <pre> - * <code> - * _=id:Integer|name:String|geom:Geometry - * fid1=1|Jody|<i>well known text</i> - * fid2=2|Brent|<i>well known text</i> - * fid3=3|Dave|<i>well known text</i> - * </code> - * </pre> - * - * <p> - * Many values may be represented by a special tag: <code><null></code>. An empty element: <code>||</code> is interpreted as the empty string: - * </p> - * - * <pre> - * <code> - * fid4=4||<null> -> Feature( id=2, name="", geom=null ) - * </code> - * </pre> - * - * @author Jody Garnett (LISAsoft) - * - * @source $URL$ - * @version $Id - * @since 8.0 - */ -public class PropertyFeatureReader implements FeatureReader<SimpleFeatureType, SimpleFeature> { - private static final Logger LOGGER = Logging.getLogger("org.geotools.data.property"); - - BufferedReader reader; - - SimpleFeatureType type; - - String line; - - String next; - - String[] text; - - String fid; - - public PropertyFeatureReader(String namespace, File file) throws IOException { - reader = new BufferedReader(new FileReader(file)); - - // read until "_="; - while ((line = reader.readLine()) != null) { - if (line.startsWith("_=")) - break; - } - - if ((line == null) || !line.startsWith("_=")) { - throw new IOException("Property file schema not available found"); - } - String typeSpec = line.substring(2); - String name = file.getName(); - String typeName = name.substring(0,name.lastIndexOf('.')); - try { - type = DataUtilities.createType(namespace, typeName, typeSpec); - } catch (SchemaException e) { - throw new DataSourceException(typeName + " schema not available", e); - } - line = null; - next = null; - } - - public SimpleFeatureType getFeatureType() { - return type; - } - - /** - * Grab the next feature from the property file. - * - * @return feature - * - * @throws IOException - * @throws NoSuchElementException Check hasNext() to avoid reading off the end of the file - */ - public SimpleFeature next() throws IOException, NoSuchElementException { - if (hasNext()) { - line = next; - next = null; - - int split = line.indexOf('='); - fid = line.substring(0, split); - text = line.substring(split + 1).split("\\|", -1);// use -1 as limit to include empty trailing spaces - if (type.getAttributeCount() != text.length) - throw new DataSourceException("Format error: expected " + type.getAttributeCount() - + " attributes, but found " + text.length + ". [" + line + "]"); - } else { - throw new NoSuchElementException(); - } - Object[] values = new Object[type.getAttributeCount()]; - - for (int i = 0; i < type.getAttributeCount(); i++) { - try { - values[i] = read(i); - } catch (RuntimeException e) { - values[i] = null; - } catch (IOException e) { - throw e; - } - } - return SimpleFeatureBuilder.build(type, values, fid); - } - - /** - * Read attribute in position marked by <code>index</code>. - * - * @param index Attribute position to read - * - * @return Value for the attribtue in position <code>index</code> - * - * @throws IOException - * @throws ArrayIndexOutOfBoundsException - */ - public Object read(int index) throws IOException, ArrayIndexOutOfBoundsException { - if (line == null) { - throw new IOException("No content available - did you remeber to call next?"); - } - - AttributeDescriptor attType = type.getDescriptor(index); - - String stringValue = null; - try { - // read the value - stringValue = text[index]; - } catch (RuntimeException e1) { - e1.printStackTrace(); - stringValue = null; - } - // check for special <null> flag - if ("<null>".equals(stringValue)) { - stringValue = null; - } - if (stringValue == null) { - if (attType.isNillable()) { - return null; // it was an explicit "<null>" - } - } - // Use of Converters to convert from String to requested java binding - Object value = Converters.convert(stringValue, attType.getType().getBinding()); - - if (attType.getType() instanceof GeometryType) { - // this is to be passed on in the geometry objects so the srs name gets encoded - CoordinateReferenceSystem crs = ((GeometryType) attType.getType()) - .getCoordinateReferenceSystem(); - if (crs != null) { - // must be geometry, but check anyway - if (value != null && value instanceof Geometry) { - ((Geometry) value).setUserData(crs); - } - } - } - return value; - } - - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - * - * @throws IOException DOCUMENT ME! - */ - public boolean hasNext() throws IOException { - if (next != null) { - return true; - } - next = readLine(); - return next != null; - } - - String readLine() throws IOException { - StringBuilder buffer = new StringBuilder(); - while (true) { - String txt = reader.readLine(); - if (txt == null) { - break; - } - if (txt.startsWith("#") || txt.startsWith("!")) { - continue; // skip content - } - txt = trimLeft(txt); - if (txt.endsWith("\\")) { - buffer.append(txt.substring(0, txt.length() - 1)); - buffer.append("\n"); - continue; - } else { - buffer.append(txt); - break; - } - } - if (buffer.length() == 0) { - return null; // there is no line - } - String raw = buffer.toString(); - raw = raw.replace("\\n", "\n"); - raw = raw.replace("\\r", "\r"); - raw = raw.replace("\\t", "\t"); - return raw; - } - - /** - * Trim leading white space as described Properties. - * - * @see Properties#load(java.io.Reader) - * @param txt - * @return txt leading whitespace removed - */ - String trimLeft(String txt) { - // trim - int start = 0; - WHITESPACE: for (int i = 0; i < txt.length(); i++) { - char ch = txt.charAt(i); - if (Character.isWhitespace(ch)) { - continue; - } else { - start = i; - break WHITESPACE; - } - } - return txt.substring(start); - } - - /** - * Be sure to call close when you are finished with this reader; as it must close the file it has open. - * - * @throws IOException - */ - public void close() throws IOException { - if (reader == null) { - LOGGER.warning("Stream seems to be already closed."); - } else { - reader.close(); - } - reader = null; - } -} Deleted: trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyFeatureSource.java =================================================================== --- trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyFeatureSource.java 2011-11-23 06:23:55 UTC (rev 38371) +++ trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyFeatureSource.java 2011-11-23 06:24:16 UTC (rev 38372) @@ -1,126 +0,0 @@ -/* - * GeoTools - The Open Source Java GIS Toolkit - * http://geotools.org - * - * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ -package org.geotools.data.property; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; - -import org.geotools.data.DataSourceException; -import org.geotools.data.DataUtilities; -import org.geotools.data.FeatureReader; -import org.geotools.data.Query; -import org.geotools.data.QueryCapabilities; -import org.geotools.data.store.ContentEntry; -import org.geotools.data.store.ContentFeatureSource; -import org.geotools.feature.SchemaException; -import org.geotools.geometry.jts.ReferencedEnvelope; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; - -import com.sun.jdi.connect.spi.TransportService.Capabilities; - -/** - * - * - * @source $URL$ - */ -public class PropertyFeatureSource extends ContentFeatureSource { - public PropertyFeatureSource(ContentEntry entry, Query query) { - super(entry, query); - } - @Override - protected QueryCapabilities buildQueryCapabilities() { - return new QueryCapabilities(){ - public boolean isUseProvidedFIDSupported() { - return true; - } - }; - } - - @Override - protected ReferencedEnvelope getBoundsInternal(Query query) throws IOException { - ReferencedEnvelope bounds = new ReferencedEnvelope(getSchema() - .getCoordinateReferenceSystem()); - - FeatureReader<SimpleFeatureType, SimpleFeature> featureReader = getReaderInternal(query); - try { - while (featureReader.hasNext()) { - SimpleFeature feature = featureReader.next(); - bounds.include(feature.getBounds()); - } - } finally { - featureReader.close(); - } - return bounds; - } - - @Override - protected int getCountInternal(Query query) throws IOException { - int count = 0; - FeatureReader<SimpleFeatureType, SimpleFeature> featureReader = getReaderInternal(query); - try { - while (featureReader.hasNext()) { - featureReader.next(); - count++; - } - } finally { - featureReader.close(); - } - return count; - } - - @Override - protected SimpleFeatureType buildFeatureType() throws IOException { - String typeName = getEntry().getTypeName(); - String namespace = getEntry().getName().getNamespaceURI(); - - String typeSpec = property("_"); - try { - return DataUtilities.createType(namespace, typeName, typeSpec); - } catch (SchemaException e) { - e.printStackTrace(); - throw new DataSourceException(typeName + " schema not available", e); - } - } - - private String property(String key) throws IOException { - PropertyDataStore dataStore = (PropertyDataStore) getEntry().getDataStore(); - File file = dataStore.file; - - BufferedReader reader = new BufferedReader(new FileReader(file)); - try { - for (String line = reader.readLine(); line != null; line = reader.readLine()) { - if (line.startsWith(key + "=")) { - return line.substring(key.length() + 1); - } - } - } finally { - reader.close(); - } - return null; - } - - - @Override - protected FeatureReader<SimpleFeatureType, SimpleFeature> getReaderInternal(Query query) - throws IOException { - PropertyDataStore dataStore = (PropertyDataStore) getEntry().getDataStore(); - return new PropertyFeatureReader(dataStore.getNamespaceURI(),dataStore.file); - } -} \ No newline at end of file Deleted: trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyFeatureStore.java =================================================================== --- trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyFeatureStore.java 2011-11-23 06:23:55 UTC (rev 38371) +++ trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyFeatureStore.java 2011-11-23 06:24:16 UTC (rev 38372) @@ -1,92 +0,0 @@ -/* - * GeoTools - The Open Source Java GIS Toolkit - * http://geotools.org - * - * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ -package org.geotools.data.property; - -import java.io.IOException; - -import org.geotools.data.FeatureReader; -import org.geotools.data.FeatureWriter; -import org.geotools.data.Query; -import org.geotools.data.QueryCapabilities; -import org.geotools.data.store.ContentEntry; -import org.geotools.data.store.ContentFeatureStore; -import org.geotools.geometry.jts.ReferencedEnvelope; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; - -/** - * Implementation used for writeable property files. - * Supports limited caching of number of features and bounds. - * - * - * @source $URL$ - */ -public class PropertyFeatureStore extends ContentFeatureStore { - - String typeName; - SimpleFeatureType featureType; - PropertyDataStore store; - PropertyFeatureSource delegate; - - PropertyFeatureStore( ContentEntry entry, Query query ) throws IOException{ - super( entry, query ); - delegate = new PropertyFeatureSource(entry, query ); - this.store = (PropertyDataStore) entry.getDataStore(); - this.typeName = entry.getTypeName(); - } - - protected QueryCapabilities buildQueryCapabilities() { - return new QueryCapabilities(){ - public boolean isUseProvidedFIDSupported() { - return true; - } - }; - } - - - public PropertyDataStore getDataStore() { - return (PropertyDataStore) super.getDataStore(); - } - - @Override - protected FeatureWriter<SimpleFeatureType, SimpleFeature> getWriterInternal(Query query, - int flags) throws IOException { - return new PropertyFeatureWriter(this,getState(), query, (flags | WRITER_ADD) == WRITER_ADD); - } - - @Override - protected ReferencedEnvelope getBoundsInternal(Query query) throws IOException { - return delegate.getBoundsInternal(query); - } - - @Override - protected int getCountInternal(Query query) throws IOException { - return delegate.getCountInternal(query); - } - - @Override - protected FeatureReader<SimpleFeatureType, SimpleFeature> getReaderInternal(Query query) - throws IOException { - return delegate.getReaderInternal(query); - } - - @Override - protected SimpleFeatureType buildFeatureType() throws IOException { - return delegate.buildFeatureType(); - } - -} Deleted: trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyFeatureWriter.java =================================================================== --- trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyFeatureWriter.java 2011-11-23 06:23:55 UTC (rev 38371) +++ trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/PropertyFeatureWriter.java 2011-11-23 06:24:16 UTC (rev 38372) @@ -1,288 +0,0 @@ -/* - * GeoTools - The Open Source Java GIS Toolkit - * http://geotools.org - * - * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ -package org.geotools.data.property; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.nio.channels.FileChannel; - -import org.geotools.data.DataSourceException; -import org.geotools.data.DataUtilities; -import org.geotools.data.FeatureWriter; -import org.geotools.data.Query; -import org.geotools.data.Transaction; -import org.geotools.data.store.ContentFeatureSource; -import org.geotools.data.store.ContentState; -import org.geotools.factory.Hints; -import org.geotools.feature.simple.SimpleFeatureBuilder; -import org.geotools.geometry.jts.ReferencedEnvelope; -import org.geotools.util.Converters; -import org.opengis.feature.IllegalAttributeException; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; - -import com.vividsolutions.jts.geom.Geometry; - -/** - * Uses PropertyAttributeWriter to generate a property file on disk. - * - * - * @source $URL$ - */ -public class PropertyFeatureWriter implements FeatureWriter<SimpleFeatureType, SimpleFeature> { - - PropertyDataStore store; - ContentFeatureSource featureSource; - File read; - PropertyFeatureReader reader; - File write; - BufferedWriter writer; - SimpleFeatureType type; - - SimpleFeature origional = null; - SimpleFeature live = null; - private ContentState state; - - public PropertyFeatureWriter(ContentFeatureSource source, ContentState contentState, Query query, boolean append) throws IOException { - this.state = contentState; - this.featureSource = source; - PropertyDataStore store = (PropertyDataStore) contentState.getEntry().getDataStore(); - String namespaceURI = store.getNamespaceURI(); - String typeName = query.getTypeName(); - - read = store.file; - File dir = read.getParentFile(); - write = File.createTempFile(typeName + System.currentTimeMillis(),null, dir); - - // start reading - reader = new PropertyFeatureReader(namespaceURI, read ); - - type = reader.getFeatureType(); - - // open writer - writer = new BufferedWriter(new FileWriter(write)); - // write header - writer.write("_="); - writer.write(DataUtilities.spec(type)); - } - - // constructor end - - // getFeatureType start - public SimpleFeatureType getFeatureType() { - return reader.getFeatureType(); - } - - // getFeatureType end - // hasNext start - public boolean hasNext() throws IOException { - if (writer == null) { - throw new IOException("Writer has been closed"); - } - if (live != null && origional != null) { - // we have returned something to the user, - // and it has not been writen out or removed - // - writeImplementation(origional); - origional = null; - live = null; - } - return reader.hasNext(); - } - - // hasNext end - // writeImplementation start - private void writeImplementation(SimpleFeature f) throws IOException { - if (writer == null) { - throw new IOException("Writer has been closed"); - } - writer.newLine(); - writer.flush(); - String fid = f.getID(); - if( Boolean.TRUE.equals( f.getUserData().get(Hints.USE_PROVIDED_FID) ) ){ - if( f.getUserData().containsKey(Hints.PROVIDED_FID)){ - fid = (String) f.getUserData().get(Hints.PROVIDED_FID); - } - } - writeFeatureID(fid); - for (int i = 0; i < f.getAttributeCount(); i++) { - Object value = f.getAttribute(i); - write(i, value ); - } - } - public void writeFeatureID(String fid) throws IOException { - if (writer == null) { - throw new IOException("Writer has been closed"); - } - writer.write(fid); - } - public void write(int position, Object attribute) throws IOException { - if (writer == null) { - throw new IOException("Writer has been closed"); - } - writer.write(position == 0 ? "=" : "|"); - if (attribute == null) { - writer.write("<null>"); // nothing! - } else if( attribute instanceof String){ - // encode newlines - String txt = (String) attribute; - txt = txt.replace("\n", "\\n"); - txt = txt.replace("\r", "\\r"); - writer.write( txt ); - } else if (attribute instanceof Geometry) { - Geometry geometry = (Geometry) attribute; - writer.write( geometry.toText() ); - } else { - String txt = Converters.convert( attribute, String.class ); - if( txt == null ){ // could not convert? - txt = attribute.toString(); - } - writer.write( txt ); - } - } - // writeImplementation end - // next start - public SimpleFeature next() throws IOException { - if (writer == null) { - throw new IOException("Writer has been closed"); - } - String fid = null; - try { - if (hasNext()) { - reader.next(); // grab next line - - fid = reader.fid; - Object values[] = new Object[type.getAttributeCount()]; - for (int i = 0; i < type.getAttributeCount(); i++) { - values[i] = reader.read(i); - } - - origional = SimpleFeatureBuilder.build(type, values, fid); - live = SimpleFeatureBuilder.copy(origional); - return live; - } else { - fid = type.getTypeName() + "." + System.currentTimeMillis(); - Object values[] = DataUtilities.defaultValues(type); - - origional = null; - live = SimpleFeatureBuilder.build(type, values, fid); - return live; - } - } catch (IllegalAttributeException e) { - String message = "Problem creating feature " - + (fid != null ? fid : ""); - throw new DataSourceException(message, e); - } - } - - // next end - // write start - public void write() throws IOException { - if (live == null) { - throw new IOException("No current feature to write"); - } - if (live.equals(origional)) { - writeImplementation(origional); - } else { - writeImplementation(live); - String typeName = live.getFeatureType().getTypeName(); - Transaction autoCommit = Transaction.AUTO_COMMIT; - if (origional != null) { - ReferencedEnvelope bounds = new ReferencedEnvelope(); - bounds.include(live.getBounds()); - bounds.include(origional.getBounds()); - state.fireFeatureUpdated(featureSource, live, bounds); - //store.listenerManager.fireFeaturesChanged(typeName, autoCommit, bounds, false); - } else { - state.fireFeatureAdded(featureSource, live); - // store.listenerManager.fireFeaturesAdded(typeName, autoCommit, ReferencedEnvelope.reference(live.getBounds()), false); - } - } - origional = null; - live = null; - } - - // write end - // remove start - public void remove() throws IOException { - if (live == null) { - throw new IOException("No current feature to remove"); - } - if (origional != null) { - String typeName = live.getFeatureType().getTypeName(); - Transaction autoCommit = Transaction.AUTO_COMMIT; - state.fireFeatureRemoved(featureSource,origional); - //store.listenerManager.fireFeaturesRemoved(typeName, autoCommit,ReferencedEnvelope.reference(origional.getBounds()), false); - } - origional = null; - live = null; // prevent live and remove from being written out - } - // remove end - - // close start - public void close() throws IOException { - if (writer == null) { - throw new IOException("writer already closed"); - } - // write out remaining contents from reader - // if applicable - while (reader.hasNext()) { - reader.next(); // advance - writer.newLine(); - writer.flush(); - echoLine(reader.line); // echo unchanged - } - writer.close(); - reader.close(); - writer = null; - reader = null; - read.delete(); - - if (write.exists() && !write.renameTo(read)) { - FileChannel out = new FileOutputStream(read).getChannel(); - FileChannel in = new FileInputStream(write).getChannel(); - try { - long len = in.size(); - long copied = out.transferFrom(in, 0, in.size()); - - if (len != copied) { - throw new IOException("unable to complete write"); - } - } finally { - in.close(); - out.close(); - } - } - read = null; - write = null; - store = null; - } - public void echoLine(String line) throws IOException { - if (writer == null) { - throw new IOException("Writer has been closed"); - } - if (line == null) { - return; - } - writer.write(line); - } - // close end -} Deleted: trunk/modules/unsupported/property-ng/src/test/java/org/geotools/data/property/PropertyDataStore2Test.java =================================================================== --- trunk/modules/unsupported/property-ng/src/test/java/org/geotools/data/property/PropertyDataStore2Test.java 2011-11-23 06:23:55 UTC (rev 38371) +++ trunk/modules/unsupported/property-ng/src/test/java/org/geotools/data/property/PropertyDataStore2Test.java 2011-11-23 06:24:16 UTC (rev 38372) @@ -1,190 +0,0 @@ -/* - * GeoTools - The Open Source Java GIS Toolkit - * http://geotools.org - * - * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ -package org.geotools.data.property; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; - -import junit.framework.TestCase; - -import org.geotools.data.DefaultQuery; -import org.geotools.data.simple.SimpleFeatureCollection; -import org.geotools.data.simple.SimpleFeatureIterator; -import org.geotools.data.simple.SimpleFeatureSource; -import org.geotools.referencing.CRS; -import org.opengis.feature.Property; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.feature.type.GeometryDescriptor; -import org.opengis.feature.type.GeometryType; -import org.opengis.filter.Filter; -import org.opengis.referencing.crs.CoordinateReferenceSystem; - -import com.vividsolutions.jts.geom.Geometry; - -/** - * Test non functionality of PropertyDataStore. - * - * @author Jody Garnett, Refractions Research Inc. - * - * - * @source $URL$ - */ -public class PropertyDataStore2Test extends TestCase { - PropertyDataStore store; - - PropertyDataStore sridStore; - /** - * Constructor for SimpleDataStoreTest. - * @param arg0 - */ - public PropertyDataStore2Test(String arg0) { - super(arg0); - } - protected void setUp() throws Exception { - File dir = new File(".", "propertyTestData" ); - dir.mkdir(); - - File file = new File( dir ,"road.properties"); - if( file.exists()){ - file.delete(); - } - BufferedWriter writer = new BufferedWriter( new FileWriter( file ) ); - writer.write("_=id:Integer,*geom:Geometry,name:String"); writer.newLine(); - writer.write("fid1=1|LINESTRING(0 0,10 10)|jody"); writer.newLine(); - writer.write("fid2=2|LINESTRING(20 20,30 30)|brent"); writer.newLine(); - writer.write("fid3=3|LINESTRING(5 0, 5 10)|dave"); writer.newLine(); - writer.write("fid4=4|LINESTRING(0 5, 5 0, 10 5, 5 10, 0 5)|justin"); - writer.close(); - store = new PropertyDataStore( file, "propertyTestData" ); - - // Create a similar data store but with srid in the geometry column - File dir2 = new File(".", "propertyTestData2"); - dir2.mkdir(); - File file2 = new File(dir2, "road2.properties"); - if (file2.exists()) { - file2.delete(); - } - BufferedWriter writer2 = new BufferedWriter(new FileWriter(file2)); - writer2.write("_=id:Integer,geom:Geometry:srid=4283"); - writer2.newLine(); - writer2.write("fid1=1|LINESTRING(0 0,10 10)"); - writer2.newLine(); - writer2.write("fid2=2|LINESTRING(20 20,30 30)"); - writer2.newLine(); - writer2.write("fid3=3|LINESTRING(5 0, 5 10)"); - writer2.newLine(); - writer2.write("fid4=4|LINESTRING(0 5, 5 0, 10 5, 5 10, 0 5)"); - writer2.close(); - sridStore = new PropertyDataStore( file2, "propertyTestData2" ); - - super.setUp(); - } - protected void tearDown() throws Exception { - File dir = new File( "propertyTestData" ); - File list[]=dir.listFiles(); - for( int i=0; i<list.length;i++){ - list[i].delete(); - } - dir.delete(); - - dir = new File( "propertyTestData2" ); - File list2[] = dir.listFiles(); - for( int i=0; i<list2.length;i++){ - list2[i].delete(); - } - dir.delete(); - - super.tearDown(); - } - - /** - * Test CRS being passed into Geometry user data. - * - * @throws Exception - */ - public void testCRS() throws Exception { - SimpleFeatureSource road = sridStore.getFeatureSource("road2"); - SimpleFeatureCollection features = road.getFeatures(); - assertEquals(4, features.size()); - - SimpleFeature feature; - Geometry geom; - Property prop; - GeometryType geomType; - SimpleFeatureIterator iterator = features.features(); - while (iterator.hasNext()) { - feature = iterator.next(); - prop = feature.getProperty("geom"); - assertTrue(prop.getType() instanceof GeometryType); - geomType = (GeometryType) prop.getType(); - - Object val = prop.getValue(); - assertTrue(val != null && val instanceof Geometry); - geom = (Geometry) val; - - Object userData = geom.getUserData(); - assertTrue(userData != null && userData instanceof CoordinateReferenceSystem); - // ensure the same CRS is passed on to userData for encoding - assertEquals(userData, geomType.getCoordinateReferenceSystem()); - } - } - - public void testSimple() throws Exception { - SimpleFeatureSource road = store.getFeatureSource( "road" ); - SimpleFeatureCollection features = road.getFeatures(); - - //assertEquals( 1, features.getFeatureType().getAttributeCount() ); - assertEquals( 4, features.size() ); - } - public void testQuery() throws Exception { - SimpleFeatureSource road = store.getFeatureSource( "road" ); - - DefaultQuery query = new DefaultQuery( "road", Filter.INCLUDE, - new String[]{ "name" } ); - - SimpleFeatureCollection features = road.getFeatures( query ); - assertEquals( 4, features.size() ); - //assertEquals( 1, features.getFeatureType().getAttributeCount() ); - } - - public void testQueryReproject() throws Exception { - CoordinateReferenceSystem world = CRS.decode("EPSG:4326"); // world lon/lat - CoordinateReferenceSystem local = CRS.decode("EPSG:3005"); // british columbia - - - SimpleFeatureSource road = store.getFeatureSource( "road" ); - SimpleFeatureType origionalType = road.getSchema(); - - Query query = new Query( "road", Filter.INCLUDE, - new String[]{ "geom", "name" } ); - - query.setCoordinateSystem( local ); // FROM - query.setCoordinateSystemReproject( world ); // TO - - SimpleFeatureCollection features = road.getFeatures( query ); - SimpleFeatureType resultType = features.getSchema(); - - assertNotNull( resultType ); - assertNotSame( resultType, origionalType ); - - assertEquals( world, resultType.getCoordinateReferenceSystem() ); - - GeometryDescriptor geometryDescriptor = resultType.getGeometryDescriptor(); - } -} Deleted: trunk/modules/unsupported/property-ng/src/test/java/org/geotools/data/property/PropertyDataStoreTest.java =================================================================== --- trunk/modules/unsupported/property-ng/src/test/java/org/geotools/data/property/PropertyDataStoreTest.java 2011-11-23 06:23:55 UTC (rev 38371) +++ trunk/modules/unsupported/property-ng/src/test/java/org/geotools/data/property/PropertyDataStoreTest.java 2011-11-23 06:24:16 UTC (rev 38372) @@ -1,598 +0,0 @@ -/* - * GeoTools - The Open Source Java GIS Toolkit - * http://geotools.org - * - * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - */ -package org.geotools.data.property; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.NoSuchElementException; -import java.util.Set; - -import junit.framework.TestCase; - -import org.geotools.data.DataUtilities; -import org.geotools.data.DefaultQuery; -import org.geotools.data.DefaultTransaction; -import org.geotools.data.FeatureReader; -import org.geotools.data.FeatureWriter; -import org.geotools.data.Query; -import org.geotools.data.Transaction; -import org.geotools.data.simple.SimpleFeatureCollection; -import org.geotools.data.simple.SimpleFeatureIterator; -import org.geotools.data.simple.SimpleFeatureSource; -import org.geotools.data.simple.SimpleFeatureStore; -import org.geotools.data.store.ContentFeatureStore; -import org.geotools.factory.CommonFactoryFinder; -import org.geotools.factory.Hints; -import org.geotools.feature.simple.SimpleFeatureBuilder; -import org.geotools.filter.identity.FeatureIdImpl; -import org.opengis.feature.Feature; -import org.opengis.feature.FeatureVisitor; -import org.opengis.feature.IllegalAttributeException; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.feature.type.AttributeDescriptor; -import org.opengis.filter.Filter; -import org.opengis.filter.FilterFactory2; -import org.opengis.filter.identity.FeatureId; - -/** - * Test functioning of PropertyDataStore. - * - * @author Jody Garnett, Refractions Research Inc. - * - * - * @source $URL$ - */ -public class PropertyDataStoreTest extends TestCase { - private PropertyDataStore store; - - private PropertyDataStore storeDots; - - private PropertyDataStore storeMultiline; - - private PropertyDataStore storeTable; - - static FilterFactory2 ff = (FilterFactory2) CommonFactoryFinder.getFilterFactory(null); - - /** - * Constructor for SimpleDataStoreTest. - * @param arg0 - */ - public PropertyDataStoreTest(String arg0) { - super(arg0); - } - protected void setUp() throws Exception { - File dir = new File(".", "propertyTestData" ); - dir.mkdir(); - - File file = new File( dir ,"road.properties"); - if( file.exists()){ - file.delete(); - } - BufferedWriter writer = new BufferedWriter( new FileWriter( file ) ); - writer.write("_=id:Integer,name:String"); writer.newLine(); - writer.write("fid1=1|jody"); writer.newLine(); - writer.write("fid2=2|brent"); writer.newLine(); - writer.write("fid3=3|dave"); writer.newLine(); - writer.write("fid4=4|justin"); writer.newLine(); - writer.write("fid5=5|"); - writer.close(); - store = new PropertyDataStore( file, "propertyTestData" ); - - file = new File( dir ,"dots.in.name.properties"); - if( file.exists()){ - file.delete(); - } - writer = new BufferedWriter( new FileWriter( file ) ); - writer.write("_=id:Integer,name:String"); writer.newLine(); - writer.write("fid1=1|jody"); writer.newLine(); - writer.write("fid2=2|brent"); writer.newLine(); - writer.write("fid3=3|dave"); writer.newLine(); - writer.write("fid4=4|justin"); - writer.close(); - storeDots = new PropertyDataStore( file, "propertyTestData" ); - - file = new File( dir ,"multiline.properties"); - if( file.exists()){ - file.delete(); - } - writer = new BufferedWriter( new FileWriter( file ) ); - writer.write("_=id:Integer,name:String"); writer.newLine(); - writer.write("fid1=1|jody \\"); writer.newLine(); - writer.write(" garnett"); writer.newLine(); - writer.write("fid2=2|brent"); writer.newLine(); - writer.write("fid3=3|dave"); writer.newLine(); - writer.write("fid4=4|justin\\\n"); - writer.close(); - storeMultiline = new PropertyDataStore( file, "propertyTestData" ); - - file = new File( dir ,"table.properties"); - if( file.exists()){ - file.delete(); - } - writer = new BufferedWriter( new FileWriter( file ) ); - writer.write("_=description:String,name:String"); writer.newLine(); - writer.write("GenericEntity.f004=description-f004|name-f004"); writer.newLine(); - writer.write("GenericEntity.f003=descriptio... [truncated message content] |
|
From: <svn...@os...> - 2011-11-23 06:24:04
|
Author: jive
Date: 2011-11-22 22:23:55 -0800 (Tue, 22 Nov 2011)
New Revision: 38371
Modified:
trunk/docs/developer/conventions/test/test.rst
Log:
command line test coverage
Modified: trunk/docs/developer/conventions/test/test.rst
===================================================================
--- trunk/docs/developer/conventions/test/test.rst 2011-11-23 06:23:42 UTC (rev 38370)
+++ trunk/docs/developer/conventions/test/test.rst 2011-11-23 06:23:55 UTC (rev 38371)
@@ -51,13 +51,16 @@
Code Coverage vs Regression Testing
------------------------------------
-Code Coverage reports are available via::
+1. Code Coverage reports are available via::
- mvn clean install
- mvn cobertura:cobertura
+ mvn -o clean cobertura:cobertura
+2. The result is available for each module:
+
+ target/site/cobertura/index.html
+
The percentage reported is based on the lines of code your test cases manage to test, please limit
-this to "real" tests - although we demand 40% test coverage for supported modules we would much
+this to "real" tests - although we ask for 40% test coverage for supported modules we would much
rather this is produced honestly.
Creating boiler plate tests that just call assertEquals against every method, and cutting and
|
Author: jive Date: 2011-11-22 22:23:42 -0800 (Tue, 22 Nov 2011) New Revision: 38370 Added: trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/ trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyAttributeWriter.java trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyDataStore.java trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyDataStoreFactory.java trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyFeatureReader.java trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyFeatureSource.java trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyFeatureStore.java trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyFeatureWriter.java trunk/modules/unsupported/property-ng/src/test/java/org/geotools/data/property/ng/ trunk/modules/unsupported/property-ng/src/test/java/org/geotools/data/property/ng/PropertyDataStore2Test.java trunk/modules/unsupported/property-ng/src/test/java/org/geotools/data/property/ng/PropertyDataStoreTest.java trunk/modules/unsupported/property-ng/src/test/java/org/geotools/data/property/ng/PropertyExamples.java Log: moved into property/ng folder Added: trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyAttributeWriter.java =================================================================== --- trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyAttributeWriter.java (rev 0) +++ trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyAttributeWriter.java 2011-11-23 06:23:42 UTC (rev 38370) @@ -0,0 +1,152 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package org.geotools.data.property.ng; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +import org.geotools.data.AttributeWriter; +import org.geotools.data.DataUtilities; +import org.geotools.util.Converters; +import org.opengis.feature.simple.SimpleFeatureType; +import org.opengis.feature.type.AttributeDescriptor; + +import com.vividsolutions.jts.geom.Geometry; + +/** + * Simple AttributeWriter that produces Java properties files. + * <p> + * This AttributeWriter is part of the geotools2 DataStore tutorial, and should + * be considered a Toy. + * </p> + * <p> + * The content produced witll start with the property "_" with the value being + * the typeSpec describing the featureType. Thereafter each line will represent + * a Features with FeatureID as the property and the attribtues as the value + * separated by | characters. + * </p> + * + * <pre> + * <code> + * _=id:Integer|name:String|geom:Geometry + * fid1=1|Jody|<i>well known text</i> + * fid2=2|Brent|<i>well known text</i> + * fid3=3|Dave|<i>well known text</i> + * </code> + * </pre> + * + * @author Jody Garnett + * + * + * @source $URL$ + */ +public class PropertyAttributeWriter implements AttributeWriter { + BufferedWriter writer; + + SimpleFeatureType type; + + public PropertyAttributeWriter(File file, SimpleFeatureType featureType) + throws IOException { + writer = new BufferedWriter(new FileWriter(file)); + type = featureType; + writer.write("_="); + writer.write(DataUtilities.spec(type)); + } + + public int getAttributeCount() { + return type.getAttributeCount(); + } + + public AttributeDescriptor getAttributeType(int index) + throws ArrayIndexOutOfBoundsException { + return type.getDescriptor(index); + } + // constructor end + // next start + public boolean hasNext() throws IOException { + return false; + } + + public void next() throws IOException { + if (writer == null) { + throw new IOException("Writer has been closed"); + } + writer.newLine(); + writer.flush(); + } + // next end + + // writeFeatureID start + public void writeFeatureID(String fid) throws IOException { + if (writer == null) { + throw new IOException("Writer has been closed"); + } + writer.write(fid); + } + // writeFeatureID end + + // write start + public void write(int position, Object attribute) throws IOException { + if (writer == null) { + throw new IOException("Writer has been closed"); + } + writer.write(position == 0 ? "=" : "|"); + if (attribute == null) { + writer.write("<null>"); // nothing! + } else if( attribute instanceof String){ + // encode newlines + String txt = (String) attribute; + txt = txt.replace("\n", "\\n"); + txt = txt.replace("\r", "\\r"); + writer.write( txt ); + } else if (attribute instanceof Geometry) { + Geometry geometry = (Geometry) attribute; + writer.write( geometry.toText() ); + } else { + String txt = Converters.convert( attribute, String.class ); + if( txt == null ){ // could not convert? + txt = attribute.toString(); + } + writer.write( txt ); + } + } + // write end + + // close start + public void close() throws IOException { + if (writer == null) { + throw new IOException("Writer has already been closed"); + } + writer.close(); + writer = null; + type = null; + } + // close end + // echoLine start + public void echoLine(String line) throws IOException { + if (writer == null) { + throw new IOException("Writer has been closed"); + } + if (line == null) { + return; + } + writer.write(line); + } + // echoLine end +} Added: trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyDataStore.java =================================================================== --- trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyDataStore.java (rev 0) +++ trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyDataStore.java 2011-11-23 06:23:42 UTC (rev 38370) @@ -0,0 +1,144 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package org.geotools.data.property.ng; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.List; + +import org.geotools.data.DataUtilities; +import org.geotools.data.DefaultServiceInfo; +import org.geotools.data.Query; +import org.geotools.data.ServiceInfo; +import org.geotools.data.store.ContentDataStore; +import org.geotools.data.store.ContentEntry; +import org.geotools.data.store.ContentFeatureSource; +import org.geotools.factory.CommonFactoryFinder; +import org.geotools.feature.FeatureTypes; +import org.geotools.feature.NameImpl; +import org.geotools.feature.type.FeatureTypeFactoryImpl; +import org.opengis.feature.simple.SimpleFeatureType; +import org.opengis.feature.type.Name; + +import com.vividsolutions.jts.geom.GeometryFactory; + +/** + * Sample DataStore implementation, please see formal tutorial included with + * users docs. + * + * @author Jody Garnett, Refractions Research Inc. + * + * + * @source $URL$ + */ +public class PropertyDataStore extends ContentDataStore { + protected File file; + + public PropertyDataStore(File dir) { + this(dir, null); + } + + // constructor start + public PropertyDataStore(File file, String namespaceURI) { + if (file.isDirectory()) { + throw new IllegalArgumentException(file + " must be a property file"); + } + if (namespaceURI == null) { + if( file.getParent() != null ){ + namespaceURI = file.getParentFile().getName(); + } + } + this.file = file; + setNamespaceURI(namespaceURI); + // + // factories + setFilterFactory(CommonFactoryFinder.getFilterFactory(null)); + setGeometryFactory(new GeometryFactory()); + setFeatureTypeFactory(new FeatureTypeFactoryImpl()); + setFeatureFactory(CommonFactoryFinder.getFeatureFactory(null)); + } + // constructor end + + // createSchema start + public void createSchema(SimpleFeatureType featureType) throws IOException { + if( file.exists() ){ + throw new FileNotFoundException("Unable to create a new property file: file exists "+file); + } + String typeName = featureType.getTypeName(); + BufferedWriter writer = new BufferedWriter(new FileWriter(file)); + writer.write("_="); + writer.write(DataUtilities.spec(featureType)); + writer.flush(); + writer.close(); + } + + // createSchema end + + // info start + public ServiceInfo getInfo() { + DefaultServiceInfo info = new DefaultServiceInfo(); + info.setDescription("Features from " + file ); + info.setSchema(FeatureTypes.DEFAULT_NAMESPACE); + info.setSource(file.toURI()); + try { + info.setPublisher(new URI(System.getProperty("user.name"))); + } catch (URISyntaxException e) { + } + return info; + } + + // info end + + public void setNamespaceURI(String namespaceURI) { + this.namespaceURI = namespaceURI; + } + + protected java.util.List<Name> createTypeNames() throws IOException { + String name = file.getName(); + String typeName = name.substring(0,name.lastIndexOf('.')); + List<Name> typeNames = new ArrayList<Name>(); + typeNames.add( new NameImpl(namespaceURI, typeName)); + return typeNames; + } + + public List<Name> getNames() throws IOException { + String[] typeNames = getTypeNames(); + List<Name> names = new ArrayList<Name>(typeNames.length); + for (String typeName : typeNames) { + names.add(new NameImpl(namespaceURI, typeName)); + } + return names; + } + + @Override + protected ContentFeatureSource createFeatureSource(ContentEntry entry) throws IOException { + if( file.canWrite() ){ + return new PropertyFeatureStore( entry, Query.ALL ); + } + else { + return new PropertyFeatureSource( entry, Query.ALL ); + } + } + + +} Added: trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyDataStoreFactory.java =================================================================== --- trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyDataStoreFactory.java (rev 0) +++ trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyDataStoreFactory.java 2011-11-23 06:23:42 UTC (rev 38370) @@ -0,0 +1,162 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package org.geotools.data.property.ng; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Map; +import java.util.logging.Logger; + +import org.geotools.data.DataStore; +import org.geotools.data.DataStoreFactorySpi; + + +/** + * DataStore factory that creates {@linkplain org.geotools.data.property.ng.PropertyDataStore}s + * + * @author Jody garnett + * + * + * @source $URL$ + * @version $Id$ + */ +public class PropertyDataStoreFactory implements DataStoreFactorySpi { + // private static final Logger LOGGER = org.geotools.util.logging.Logging.getLogger(PropertyDataStoreFactory.class.getPackage().getName()); + + public static final Param FILE = new Param("file", File.class, + "Property file", true); + + public static final Param NAMESPACE = new Param("namespace", String.class, + "namespace of datastore", false); + + public DataStore createDataStore(Map params) throws IOException { + File dir = fileLookup(params); + String namespaceURI = (String) NAMESPACE.lookUp( params ); + if (dir.exists() && dir.isDirectory()) { + return new PropertyDataStore(dir,namespaceURI); + } else { + throw new IOException("Directory is required"); + } + } + + // createNewDataStore start + public DataStore createNewDataStore(Map params) throws IOException { + File dir = (File)FILE.lookUp(params); + + if (dir.exists()) { + throw new IOException(dir + " already exists"); + } + + String namespaceURI = (String) NAMESPACE.lookUp(params); + return new PropertyDataStore(dir,namespaceURI); + } + // createNewDataStore end + + public String getDisplayName() { + return "Properties NG"; + } + + public String getDescription() { + return "Allows access to Java Property files containing Feature information"; + } + + /** + * @see #DIRECTORY + * @see PropertyDataStoreFactory#NAMESPACE + */ + public Param[] getParametersInfo() { + return new Param[] { FILE, NAMESPACE }; + } + + /** + * Test to see if this datastore is available, if it has all the + * appropriate libraries to construct a datastore. This datastore just + * returns true for now. This method is used for gui apps, so as to not + * advertise data store capabilities they don't actually have. + * + * @return <tt>true</tt> if and only if this factory is available to create + * DataStores. + * + * @task <code>true</code> property datastore is always available + */ + public boolean isAvailable() { + return true; + } + + /** + * Works for a file directory or property file + * + * @param params Connection parameters + * + * @return true for connection parameters indicating a directory or property file + */ + public boolean canProcess(Map params) { + try { + fileLookup(params); + return true; + } catch (Exception erp) { + //can't process, just return false + return false; + } + } + + /** + * No implementation hints are provided at this time. + */ + public Map getImplementationHints(){ + return java.util.Collections.EMPTY_MAP; + } + + /** + * Lookups the property file in the params argument, and + * returns the corresponding <code>java.io.File</code>. + * <p> + * The file is first checked for existence as an absolute path in the filesystem. If + * such a directory is not found, then it is treated as a relative path, taking Java + * system property <code>"user.dir"</code> as the base. + * </p> + * @param params + * @throws IllegalArgumentException if file is a directory. + * @throws FileNotFoundException if directory does not exists + * @throws IOException if {@linkplain #DIRECTORY} doesn't find parameter in <code>params</code> + * file does not exists. + */ + private File fileLookup(Map params) throws IOException, FileNotFoundException, + IllegalArgumentException { + File file = (File) FILE.lookUp(params); + if( file.exists() ){ + if( file.isDirectory() ){ + throw new IllegalArgumentException("Property file is required (not a directory) "+file.getAbsolutePath()); + } + return file; + } + else { + File dir = file.getParentFile(); + if( dir == null || !dir.exists() ){ + // quickly check if it exists relative to the user directory + File currentDir = new File(System.getProperty("user.dir")); + + File file2 = new File(currentDir, file.getPath()); + if (file2.exists()) { + return file2; + } + } + return file; + } + } +} \ No newline at end of file Added: trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyFeatureReader.java =================================================================== --- trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyFeatureReader.java (rev 0) +++ trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyFeatureReader.java 2011-11-23 06:23:42 UTC (rev 38370) @@ -0,0 +1,289 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package org.geotools.data.property.ng; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.NoSuchElementException; +import java.util.Properties; +import java.util.logging.Logger; + +import org.geotools.data.DataSourceException; +import org.geotools.data.DataUtilities; +import org.geotools.data.FeatureReader; +import org.geotools.feature.SchemaException; +import org.geotools.feature.simple.SimpleFeatureBuilder; +import org.geotools.util.Converters; +import org.geotools.util.logging.Logging; +import org.opengis.feature.simple.SimpleFeature; +import org.opengis.feature.simple.SimpleFeatureType; +import org.opengis.feature.type.AttributeDescriptor; +import org.opengis.feature.type.GeometryType; +import org.opengis.referencing.crs.CoordinateReferenceSystem; + +import com.vividsolutions.jts.geom.Geometry; + +/** + * Read a property file directly. + * <p> + * This implementation does not perform any filtering or processing; it leaves that up to wrappers to manipulate the content into the format or + * projection requested by the user. + * <p> + * + * <p> + * The content of this file should start with a the property "_" with the value being the typeSpec describing the featureType. Thereafter each line + * will should have a FeatureID as the property and the attribtues as the value separated by | characters. + * </p> + * + * <pre> + * <code> + * _=id:Integer|name:String|geom:Geometry + * fid1=1|Jody|<i>well known text</i> + * fid2=2|Brent|<i>well known text</i> + * fid3=3|Dave|<i>well known text</i> + * </code> + * </pre> + * + * <p> + * Many values may be represented by a special tag: <code><null></code>. An empty element: <code>||</code> is interpreted as the empty string: + * </p> + * + * <pre> + * <code> + * fid4=4||<null> -> Feature( id=2, name="", geom=null ) + * </code> + * </pre> + * + * @author Jody Garnett (LISAsoft) + * + * @source $URL$ + * @version $Id + * @since 8.0 + */ +public class PropertyFeatureReader implements FeatureReader<SimpleFeatureType, SimpleFeature> { + private static final Logger LOGGER = Logging.getLogger("org.geotools.data.property"); + + BufferedReader reader; + + SimpleFeatureType type; + + String line; + + String next; + + String[] text; + + String fid; + + public PropertyFeatureReader(String namespace, File file) throws IOException { + reader = new BufferedReader(new FileReader(file)); + + // read until "_="; + while ((line = reader.readLine()) != null) { + if (line.startsWith("_=")) + break; + } + + if ((line == null) || !line.startsWith("_=")) { + throw new IOException("Property file schema not available found"); + } + String typeSpec = line.substring(2); + String name = file.getName(); + String typeName = name.substring(0,name.lastIndexOf('.')); + try { + type = DataUtilities.createType(namespace, typeName, typeSpec); + } catch (SchemaException e) { + throw new DataSourceException(typeName + " schema not available", e); + } + line = null; + next = null; + } + + public SimpleFeatureType getFeatureType() { + return type; + } + + /** + * Grab the next feature from the property file. + * + * @return feature + * + * @throws IOException + * @throws NoSuchElementException Check hasNext() to avoid reading off the end of the file + */ + public SimpleFeature next() throws IOException, NoSuchElementException { + if (hasNext()) { + line = next; + next = null; + + int split = line.indexOf('='); + fid = line.substring(0, split); + text = line.substring(split + 1).split("\\|", -1);// use -1 as limit to include empty trailing spaces + if (type.getAttributeCount() != text.length) + throw new DataSourceException("Format error: expected " + type.getAttributeCount() + + " attributes, but found " + text.length + ". [" + line + "]"); + } else { + throw new NoSuchElementException(); + } + Object[] values = new Object[type.getAttributeCount()]; + + for (int i = 0; i < type.getAttributeCount(); i++) { + try { + values[i] = read(i); + } catch (RuntimeException e) { + values[i] = null; + } catch (IOException e) { + throw e; + } + } + return SimpleFeatureBuilder.build(type, values, fid); + } + + /** + * Read attribute in position marked by <code>index</code>. + * + * @param index Attribute position to read + * + * @return Value for the attribtue in position <code>index</code> + * + * @throws IOException + * @throws ArrayIndexOutOfBoundsException + */ + public Object read(int index) throws IOException, ArrayIndexOutOfBoundsException { + if (line == null) { + throw new IOException("No content available - did you remeber to call next?"); + } + + AttributeDescriptor attType = type.getDescriptor(index); + + String stringValue = null; + try { + // read the value + stringValue = text[index]; + } catch (RuntimeException e1) { + e1.printStackTrace(); + stringValue = null; + } + // check for special <null> flag + if ("<null>".equals(stringValue)) { + stringValue = null; + } + if (stringValue == null) { + if (attType.isNillable()) { + return null; // it was an explicit "<null>" + } + } + // Use of Converters to convert from String to requested java binding + Object value = Converters.convert(stringValue, attType.getType().getBinding()); + + if (attType.getType() instanceof GeometryType) { + // this is to be passed on in the geometry objects so the srs name gets encoded + CoordinateReferenceSystem crs = ((GeometryType) attType.getType()) + .getCoordinateReferenceSystem(); + if (crs != null) { + // must be geometry, but check anyway + if (value != null && value instanceof Geometry) { + ((Geometry) value).setUserData(crs); + } + } + } + return value; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + * + * @throws IOException DOCUMENT ME! + */ + public boolean hasNext() throws IOException { + if (next != null) { + return true; + } + next = readLine(); + return next != null; + } + + String readLine() throws IOException { + StringBuilder buffer = new StringBuilder(); + while (true) { + String txt = reader.readLine(); + if (txt == null) { + break; + } + if (txt.startsWith("#") || txt.startsWith("!")) { + continue; // skip content + } + txt = trimLeft(txt); + if (txt.endsWith("\\")) { + buffer.append(txt.substring(0, txt.length() - 1)); + buffer.append("\n"); + continue; + } else { + buffer.append(txt); + break; + } + } + if (buffer.length() == 0) { + return null; // there is no line + } + String raw = buffer.toString(); + raw = raw.replace("\\n", "\n"); + raw = raw.replace("\\r", "\r"); + raw = raw.replace("\\t", "\t"); + return raw; + } + + /** + * Trim leading white space as described Properties. + * + * @see Properties#load(java.io.Reader) + * @param txt + * @return txt leading whitespace removed + */ + String trimLeft(String txt) { + // trim + int start = 0; + WHITESPACE: for (int i = 0; i < txt.length(); i++) { + char ch = txt.charAt(i); + if (Character.isWhitespace(ch)) { + continue; + } else { + start = i; + break WHITESPACE; + } + } + return txt.substring(start); + } + + /** + * Be sure to call close when you are finished with this reader; as it must close the file it has open. + * + * @throws IOException + */ + public void close() throws IOException { + if (reader == null) { + LOGGER.warning("Stream seems to be already closed."); + } else { + reader.close(); + } + reader = null; + } +} Added: trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyFeatureSource.java =================================================================== --- trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyFeatureSource.java (rev 0) +++ trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyFeatureSource.java 2011-11-23 06:23:42 UTC (rev 38370) @@ -0,0 +1,126 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package org.geotools.data.property.ng; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; + +import org.geotools.data.DataSourceException; +import org.geotools.data.DataUtilities; +import org.geotools.data.FeatureReader; +import org.geotools.data.Query; +import org.geotools.data.QueryCapabilities; +import org.geotools.data.store.ContentEntry; +import org.geotools.data.store.ContentFeatureSource; +import org.geotools.feature.SchemaException; +import org.geotools.geometry.jts.ReferencedEnvelope; +import org.opengis.feature.simple.SimpleFeature; +import org.opengis.feature.simple.SimpleFeatureType; + +import com.sun.jdi.connect.spi.TransportService.Capabilities; + +/** + * + * + * @source $URL$ + */ +public class PropertyFeatureSource extends ContentFeatureSource { + public PropertyFeatureSource(ContentEntry entry, Query query) { + super(entry, query); + } + @Override + protected QueryCapabilities buildQueryCapabilities() { + return new QueryCapabilities(){ + public boolean isUseProvidedFIDSupported() { + return true; + } + }; + } + + @Override + protected ReferencedEnvelope getBoundsInternal(Query query) throws IOException { + ReferencedEnvelope bounds = new ReferencedEnvelope(getSchema() + .getCoordinateReferenceSystem()); + + FeatureReader<SimpleFeatureType, SimpleFeature> featureReader = getReaderInternal(query); + try { + while (featureReader.hasNext()) { + SimpleFeature feature = featureReader.next(); + bounds.include(feature.getBounds()); + } + } finally { + featureReader.close(); + } + return bounds; + } + + @Override + protected int getCountInternal(Query query) throws IOException { + int count = 0; + FeatureReader<SimpleFeatureType, SimpleFeature> featureReader = getReaderInternal(query); + try { + while (featureReader.hasNext()) { + featureReader.next(); + count++; + } + } finally { + featureReader.close(); + } + return count; + } + + @Override + protected SimpleFeatureType buildFeatureType() throws IOException { + String typeName = getEntry().getTypeName(); + String namespace = getEntry().getName().getNamespaceURI(); + + String typeSpec = property("_"); + try { + return DataUtilities.createType(namespace, typeName, typeSpec); + } catch (SchemaException e) { + e.printStackTrace(); + throw new DataSourceException(typeName + " schema not available", e); + } + } + + private String property(String key) throws IOException { + PropertyDataStore dataStore = (PropertyDataStore) getEntry().getDataStore(); + File file = dataStore.file; + + BufferedReader reader = new BufferedReader(new FileReader(file)); + try { + for (String line = reader.readLine(); line != null; line = reader.readLine()) { + if (line.startsWith(key + "=")) { + return line.substring(key.length() + 1); + } + } + } finally { + reader.close(); + } + return null; + } + + + @Override + protected FeatureReader<SimpleFeatureType, SimpleFeature> getReaderInternal(Query query) + throws IOException { + PropertyDataStore dataStore = (PropertyDataStore) getEntry().getDataStore(); + return new PropertyFeatureReader(dataStore.getNamespaceURI(),dataStore.file); + } +} \ No newline at end of file Added: trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyFeatureStore.java =================================================================== --- trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyFeatureStore.java (rev 0) +++ trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyFeatureStore.java 2011-11-23 06:23:42 UTC (rev 38370) @@ -0,0 +1,92 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package org.geotools.data.property.ng; + +import java.io.IOException; + +import org.geotools.data.FeatureReader; +import org.geotools.data.FeatureWriter; +import org.geotools.data.Query; +import org.geotools.data.QueryCapabilities; +import org.geotools.data.store.ContentEntry; +import org.geotools.data.store.ContentFeatureStore; +import org.geotools.geometry.jts.ReferencedEnvelope; +import org.opengis.feature.simple.SimpleFeature; +import org.opengis.feature.simple.SimpleFeatureType; + +/** + * Implementation used for writeable property files. + * Supports limited caching of number of features and bounds. + * + * + * @source $URL$ + */ +public class PropertyFeatureStore extends ContentFeatureStore { + + String typeName; + SimpleFeatureType featureType; + PropertyDataStore store; + PropertyFeatureSource delegate; + + PropertyFeatureStore( ContentEntry entry, Query query ) throws IOException{ + super( entry, query ); + delegate = new PropertyFeatureSource(entry, query ); + this.store = (PropertyDataStore) entry.getDataStore(); + this.typeName = entry.getTypeName(); + } + + protected QueryCapabilities buildQueryCapabilities() { + return new QueryCapabilities(){ + public boolean isUseProvidedFIDSupported() { + return true; + } + }; + } + + + public PropertyDataStore getDataStore() { + return (PropertyDataStore) super.getDataStore(); + } + + @Override + protected FeatureWriter<SimpleFeatureType, SimpleFeature> getWriterInternal(Query query, + int flags) throws IOException { + return new PropertyFeatureWriter(this,getState(), query, (flags | WRITER_ADD) == WRITER_ADD); + } + + @Override + protected ReferencedEnvelope getBoundsInternal(Query query) throws IOException { + return delegate.getBoundsInternal(query); + } + + @Override + protected int getCountInternal(Query query) throws IOException { + return delegate.getCountInternal(query); + } + + @Override + protected FeatureReader<SimpleFeatureType, SimpleFeature> getReaderInternal(Query query) + throws IOException { + return delegate.getReaderInternal(query); + } + + @Override + protected SimpleFeatureType buildFeatureType() throws IOException { + return delegate.buildFeatureType(); + } + +} Added: trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyFeatureWriter.java =================================================================== --- trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyFeatureWriter.java (rev 0) +++ trunk/modules/unsupported/property-ng/src/main/java/org/geotools/data/property/ng/PropertyFeatureWriter.java 2011-11-23 06:23:42 UTC (rev 38370) @@ -0,0 +1,288 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package org.geotools.data.property.ng; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.channels.FileChannel; + +import org.geotools.data.DataSourceException; +import org.geotools.data.DataUtilities; +import org.geotools.data.FeatureWriter; +import org.geotools.data.Query; +import org.geotools.data.Transaction; +import org.geotools.data.store.ContentFeatureSource; +import org.geotools.data.store.ContentState; +import org.geotools.factory.Hints; +import org.geotools.feature.simple.SimpleFeatureBuilder; +import org.geotools.geometry.jts.ReferencedEnvelope; +import org.geotools.util.Converters; +import org.opengis.feature.IllegalAttributeException; +import org.opengis.feature.simple.SimpleFeature; +import org.opengis.feature.simple.SimpleFeatureType; + +import com.vividsolutions.jts.geom.Geometry; + +/** + * Uses PropertyAttributeWriter to generate a property file on disk. + * + * + * @source $URL$ + */ +public class PropertyFeatureWriter implements FeatureWriter<SimpleFeatureType, SimpleFeature> { + + PropertyDataStore store; + ContentFeatureSource featureSource; + File read; + PropertyFeatureReader reader; + File write; + BufferedWriter writer; + SimpleFeatureType type; + + SimpleFeature origional = null; + SimpleFeature live = null; + private ContentState state; + + public PropertyFeatureWriter(ContentFeatureSource source, ContentState contentState, Query query, boolean append) throws IOException { + this.state = contentState; + this.featureSource = source; + PropertyDataStore store = (PropertyDataStore) contentState.getEntry().getDataStore(); + String namespaceURI = store.getNamespaceURI(); + String typeName = query.getTypeName(); + + read = store.file; + File dir = read.getParentFile(); + write = File.createTempFile(typeName + System.currentTimeMillis(),null, dir); + + // start reading + reader = new PropertyFeatureReader(namespaceURI, read ); + + type = reader.getFeatureType(); + + // open writer + writer = new BufferedWriter(new FileWriter(write)); + // write header + writer.write("_="); + writer.write(DataUtilities.spec(type)); + } + + // constructor end + + // getFeatureType start + public SimpleFeatureType getFeatureType() { + return reader.getFeatureType(); + } + + // getFeatureType end + // hasNext start + public boolean hasNext() throws IOException { + if (writer == null) { + throw new IOException("Writer has been closed"); + } + if (live != null && origional != null) { + // we have returned something to the user, + // and it has not been writen out or removed + // + writeImplementation(origional); + origional = null; + live = null; + } + return reader.hasNext(); + } + + // hasNext end + // writeImplementation start + private void writeImplementation(SimpleFeature f) throws IOException { + if (writer == null) { + throw new IOException("Writer has been closed"); + } + writer.newLine(); + writer.flush(); + String fid = f.getID(); + if( Boolean.TRUE.equals( f.getUserData().get(Hints.USE_PROVIDED_FID) ) ){ + if( f.getUserData().containsKey(Hints.PROVIDED_FID)){ + fid = (String) f.getUserData().get(Hints.PROVIDED_FID); + } + } + writeFeatureID(fid); + for (int i = 0; i < f.getAttributeCount(); i++) { + Object value = f.getAttribute(i); + write(i, value ); + } + } + public void writeFeatureID(String fid) throws IOException { + if (writer == null) { + throw new IOException("Writer has been closed"); + } + writer.write(fid); + } + public void write(int position, Object attribute) throws IOException { + if (writer == null) { + throw new IOException("Writer has been closed"); + } + writer.write(position == 0 ? "=" : "|"); + if (attribute == null) { + writer.write("<null>"); // nothing! + } else if( attribute instanceof String){ + // encode newlines + String txt = (String) attribute; + txt = txt.replace("\n", "\\n"); + txt = txt.replace("\r", "\\r"); + writer.write( txt ); + } else if (attribute instanceof Geometry) { + Geometry geometry = (Geometry) attribute; + writer.write( geometry.toText() ); + } else { + String txt = Converters.convert( attribute, String.class ); + if( txt == null ){ // could not convert? + txt = attribute.toString(); + } + writer.write( txt ); + } + } + // writeImplementation end + // next start + public SimpleFeature next() throws IOException { + if (writer == null) { + throw new IOException("Writer has been closed"); + } + String fid = null; + try { + if (hasNext()) { + reader.next(); // grab next line + + fid = reader.fid; + Object values[] = new Object[type.getAttributeCount()]; + for (int i = 0; i < type.getAttributeCount(); i++) { + values[i] = reader.read(i); + } + + origional = SimpleFeatureBuilder.build(type, values, fid); + live = SimpleFeatureBuilder.copy(origional); + return live; + } else { + fid = type.getTypeName() + "." + System.currentTimeMillis(); + Object values[] = DataUtilities.defaultValues(type); + + origional = null; + live = SimpleFeatureBuilder.build(type, values, fid); + return live; + } + } catch (IllegalAttributeException e) { + String message = "Problem creating feature " + + (fid != null ? fid : ""); + throw new DataSourceException(message, e); + } + } + + // next end + // write start + public void write() throws IOException { + if (live == null) { + throw new IOException("No current feature to write"); + } + if (live.equals(origional)) { + writeImplementation(origional); + } else { + writeImplementation(live); + String typeName = live.getFeatureType().getTypeName(); + Transaction autoCommit = Transaction.AUTO_COMMIT; + if (origional != null) { + ReferencedEnvelope bounds = new ReferencedEnvelope(); + bounds.include(live.getBounds()); + bounds.include(origional.getBounds()); + state.fireFeatureUpdated(featureSource, live, bounds); + //store.listenerManager.fireFeaturesChanged(typeName, autoCommit, bounds, false); + } else { + state.fireFeatureAdded(featureSource, live); + // store.listenerManager.fireFeaturesAdded(typeName, autoCommit, ReferencedEnvelope.reference(live.getBounds()), false); + } + } + origional = null; + live = null; + } + + // write end + // remove start + public void remove() throws IOException { + if (live == null) { + throw new IOException("No current feature to remove"); + } + if (origional != null) { + String typeName = live.getFeatureType().getTypeName(); + Transaction autoCommit = Transaction.AUTO_COMMIT; + state.fireFeatureRemoved(featureSource,origional); + //store.listenerManager.fireFeaturesRemoved(typeName, autoCommit,ReferencedEnvelope.reference(origional.getBounds()), false); + } + origional = null; + live = null; // prevent live and remove from being written out + } + // remove end + + // close start + public void close() throws IOException { + if (writer == null) { + throw new IOException("writer already closed"); + } + // write out remaining contents from reader + // if applicable + while (reader.hasNext()) { + reader.next(); // advance + writer.newLine(); + writer.flush(); + echoLine(reader.line); // echo unchanged + } + writer.close(); + reader.close(); + writer = null; + reader = null; + read.delete(); + + if (write.exists() && !write.renameTo(read)) { + FileChannel out = new FileOutputStream(read).getChannel(); + FileChannel in = new FileInputStream(write).getChannel(); + try { + long len = in.size(); + long copied = out.transferFrom(in, 0, in.size()); + + if (len != copied) { + throw new IOException("unable to complete write"); + } + } finally { + in.close(); + out.close(); + } + } + read = null; + write = null; + store = null; + } + public void echoLine(String line) throws IOException { + if (writer == null) { + throw new IOException("Writer has been closed"); + } + if (line == null) { + return; + } + writer.write(line); + } + // close end +} Added: trunk/modules/unsupported/property-ng/src/test/java/org/geotools/data/property/ng/PropertyDataStore2Test.java =================================================================== --- trunk/modules/unsupported/property-ng/src/test/java/org/geotools/data/property/ng/PropertyDataStore2Test.java (rev 0) +++ trunk/modules/unsupported/property-ng/src/test/java/org/geotools/data/property/ng/PropertyDataStore2Test.java 2011-11-23 06:23:42 UTC (rev 38370) @@ -0,0 +1,192 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package org.geotools.data.property.ng; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; + +import junit.framework.TestCase; + +import org.geotools.data.DefaultQuery; +import org.geotools.data.Query; +import org.geotools.data.property.ng.PropertyDataStore; +import org.geotools.data.simple.SimpleFeatureCollection; +import org.geotools.data.simple.SimpleFeatureIterator; +import org.geotools.data.simple.SimpleFeatureSource; +import org.geotools.referencing.CRS; +import org.opengis.feature.Property; +import org.opengis.feature.simple.SimpleFeature; +import org.opengis.feature.simple.SimpleFeatureType; +import org.opengis.feature.type.GeometryDescriptor; +import org.opengis.feature.type.GeometryType; +import org.opengis.filter.Filter; +import org.opengis.referencing.crs.CoordinateReferenceSystem; + +import com.vividsolutions.jts.geom.Geometry; + +/** + * Test non functionality of PropertyDataStore. + * + * @author Jody Garnett, Refractions Research Inc. + * + * + * @source $URL$ + */ +public class PropertyDataStore2Test extends TestCase { + PropertyDataStore store; + + PropertyDataStore sridStore; + /** + * Constructor for SimpleDataStoreTest. + * @param arg0 + */ + public PropertyDataStore2Test(String arg0) { + super(arg0); + } + protected void setUp() throws Exception { + File dir = new File(".", "propertyTestData" ); + dir.mkdir(); + + File file = new File( dir ,"road.properties"); + if( file.exists()){ + file.delete(); + } + BufferedWriter writer = new BufferedWriter( new FileWriter( file ) ); + writer.write("_=id:Integer,*geom:Geometry,name:String"); writer.newLine(); + writer.write("fid1=1|LINESTRING(0 0,10 10)|jody"); writer.newLine(); + writer.write("fid2=2|LINESTRING(20 20,30 30)|brent"); writer.newLine(); + writer.write("fid3=3|LINESTRING(5 0, 5 10)|dave"); writer.newLine(); + writer.write("fid4=4|LINESTRING(0 5, 5 0, 10 5, 5 10, 0 5)|justin"); + writer.close(); + store = new PropertyDataStore( file, "propertyTestData" ); + + // Create a similar data store but with srid in the geometry column + File dir2 = new File(".", "propertyTestData2"); + dir2.mkdir(); + File file2 = new File(dir2, "road2.properties"); + if (file2.exists()) { + file2.delete(); + } + BufferedWriter writer2 = new BufferedWriter(new FileWriter(file2)); + writer2.write("_=id:Integer,geom:Geometry:srid=4283"); + writer2.newLine(); + writer2.write("fid1=1|LINESTRING(0 0,10 10)"); + writer2.newLine(); + writer2.write("fid2=2|LINESTRING(20 20,30 30)"); + writer2.newLine(); + writer2.write("fid3=3|LINESTRING(5 0, 5 10)"); + writer2.newLine(); + writer2.write("fid4=4|LINESTRING(0 5, 5 0, 10 5, 5 10, 0 5)"); + writer2.close(); + sridStore = new PropertyDataStore( file2, "propertyTestData2" ); + + super.setUp(); + } + protected void tearDown() throws Exception { + File dir = new File( "propertyTestData" ); + File list[]=dir.listFiles(); + for( int i=0; i<list.length;i++){ + list[i].delete(); + } + dir.delete(); + + dir = new File( "propertyTestData2" ); + File list2[] = dir.listFiles(); + for( int i=0; i<list2.length;i++){ + list2[i].delete(); + } + dir.delete(); + + super.tearDown(); + } + + /** + * Test CRS being passed into Geometry user data. + * + * @throws Exception + */ + public void testCRS() throws Exception { + SimpleFeatureSource road = sridStore.getFeatureSource("road2"); + SimpleFeatureCollection features = road.getFeatures(); + assertEquals(4, features.size()); + + SimpleFeature feature; + Geometry geom; + Property prop; + GeometryType geomType; + SimpleFeatureIterator iterator = features.features(); + while (iterator.hasNext()) { + feature = iterator.next(); + prop = feature.getProperty("geom"); + assertTrue(prop.getType() instanceof GeometryType); + geomType = (GeometryType) prop.getType(); + + Object val = prop.getValue(); + assertTrue(val != null && val instanceof Geometry); + geom = (Geometry) val; + + Object userData = geom.getUserData(); + assertTrue(userData != null && userData instanceof CoordinateReferenceSystem); + // ensure the same CRS is passed on to userData for encoding + assertEquals(userData, geomType.getCoordinateReferenceSystem()); + } + } + + public void testSimple() throws Exception { + SimpleFeatureSource road = store.getFeatureSource( "road" ); + SimpleFeatureCollection features = road.getFeatures(); + + //assertEquals( 1, features.getFeatureType().getAttributeCount() ); + assertEquals( 4, features.size() ); + } + public void testQuery() throws Exception { + SimpleFeatureSource road = store.getFeatureSource( "road" ); + + DefaultQuery query = new DefaultQuery( "road", Filter.INCLUDE, + new String[]{ "name" } ); + + SimpleFeatureCollection features = road.getFeatures( query ); + assertEquals( 4, features.size() ); + //assertEquals( 1, features.getFeatureType().getAttributeCount() ); + } + + public void testQueryReproject() throws Exception { + CoordinateReferenceSystem world = CRS.decode("EPSG:4326"); // world lon/lat + CoordinateReferenceSystem local = CRS.decode("EPSG:3005"); // british columbia + + + SimpleFeatureSource road = store.getFeatureSource( "road" ); + SimpleFeatureType origionalType = road.getSchema(); + + Query query = new Query( "road", Filter.INCLUDE, + new String[]{ "geom", "name" } ); + + query.setCoordinateSystem( local ); // FROM + query.setCoordinateSystemReproject( world ); // TO + + SimpleFeatureCollection features = road.getFeatures( query ); + SimpleFeatureType resultType = features.getSchema(); + + assertNotNull( resultType ); + assertNotSame( resultType, origionalType ); + + assertEquals( world, resultType.getCoordinateReferenceSystem() ); + + GeometryDescriptor geometryDescriptor = resultType.getGeometryDescriptor(); + } +} Added: trunk/modules/unsupported/property-ng/src/test/java/org/geotools/data/property/ng/PropertyDataStoreTest.java =================================================================== --- trunk/modules/unsupported/property-ng/src/test/java/org/geotools/data/property/ng/PropertyDataStoreTest.java (rev 0) +++ trunk/modules/unsupported/property-ng/src/test/java/org/geotools/data/property/ng/PropertyDataStoreTest.java 2011-11-23 06:23:42 UTC (rev 38370) @@ -0,0 +1,601 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package org.geotools.data.property.ng; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.Set; + +import junit.framework.TestCase; + +import org.geotools.data.DataUtilities; +import org.geotools.data.DefaultQuery; +import org.geotools.data.DefaultTransaction; +import org.geotools.data.FeatureReader; +import org.geotools.data.FeatureWriter; +import org.geotools.data.Query; +import org.geotools.data.Transaction; +import org.geotools.data.property.ng.PropertyDataStore; +import org.geotools.data.property.ng.PropertyFeatureStore; +import org.geotools.data.property.ng.PropertyFeatureWriter; +import org.geotools.data.simple.SimpleFeatureCollection; +import org.geotools.data.simple.SimpleFeatureIterator; +import org.geotools.data.simple.SimpleFeatureSource; +import org.geotools.data.simple.SimpleFeatureStore; +import org.geotools.data.store.ContentFeatureStore; +import org.geotools.factory.CommonFactoryFinder; +import org.geotools.factory.Hints; +import org.geotools.feature.simple.SimpleFeatureBuilder; +import org.geotools.filter.identity.FeatureIdImpl; +import org.opengis.feature.Feature; +import org.opengis.feature.FeatureVisitor; +import org.opengis.feature.IllegalAttributeException; +import org.opengis.feature.simple.SimpleFeature; +import org.opengis.feature.simple.SimpleFeatureType; +import org.opengis.feature.type.AttributeDescriptor; +import org.opengis.filter.Filter; +import org.opengis.filter.FilterFactory2; +import org.opengis.filter.identity.FeatureId; + +/** + * Test functioning of PropertyDataStore. + * + * @author Jody Garnett, Refractions Research Inc. + * + * + * @source $URL$ + */ +public class PropertyDataStoreTest extends TestCase { + private PropertyDataStore store; + + private PropertyDataStore storeDots; + + private PropertyDataStore storeMultiline; + + private PropertyDataStore storeTable; + + static FilterFactory2 ff = (FilterFactory2) CommonFactoryFinder.getFilterFactory(null); + + /** + * Constructor for SimpleDataStoreTest. + * @param arg0 + */ + public PropertyDataStoreTest(String arg0) { + super(arg0); + } + protected void setUp() throws Exception { + File dir = new File(".", "propertyTestData" ); + dir.mkdir(); + + File file = new File( dir ,"road.properties"); + if( file.exists()){ + file.delete(); + } + BufferedWriter writer = new BufferedWriter( new FileWriter( file ) ); + writer.write("_=id:Integer,name:String"); writer.newLine(); + writer.write("fid1=1|jody"); writer.newLine(); + writer.write("fid2=2|brent"); writer.newLine(); + writer.write("fid3=3|dave"); writer.newLine(); + writer.write("fid4=4|justin"); writer.newLine(); + writer.write("fid5=5|"); + writer.close(); + store = new PropertyDataStore( file, "propertyTestData" ); + + file = new File( dir ,"dots.in.name.properties"); + if( file.exists()){ + file.delete(); + } + writer = new BufferedWriter( new FileWriter( file ) ); + writer.write("_=id:Integer,name:String"); writer.newLine(); + writer.write("fid1=1|jody"); writer.newLine(); + writer.write("fid2=2|brent"); writer.newLine(); + writer.write("fid3=3|dave"); writer.newLine(); + writer.write("fid4=4|justin"); + writer.close(); + storeDots = new PropertyDataStore( file, "propertyTestData" ); + + file = new File( dir ,"multiline.properties"); + if( file.exists()){ + file.delete(); + } + writer = new BufferedWriter( new FileWriter( file ) ); + writer.write("_=id:Integer,name:String"); writer.newLine(); + writer.write("fid1=1|jody \\"); writer.newLine(); + writer.write(" garnett"); writer.newLine(); + writer.write("fid2=2|brent"); writer.newLine(); + writer.write("fid3=3|dave"); writer.newLine(); + writer.write("fi... [truncated message content] |
|
From: <svn...@os...> - 2011-11-21 13:24:40
|
Author: aaime
Date: 2011-11-21 05:24:33 -0800 (Mon, 21 Nov 2011)
New Revision: 38369
Modified:
branches/2.7.x/modules/extension/xsd/xsd-core/src/main/java/org/geotools/xs/bindings/XSDateTimeBinding.java
branches/2.7.x/modules/extension/xsd/xsd-core/src/test/java/org/geotools/xs/bindings/XSDateTimeStrategyTest.java
Log:
[GEOT-3957] Regression: XSDateTimeBinding cannot handle calendar anymore
Modified: branches/2.7.x/modules/extension/xsd/xsd-core/src/main/java/org/geotools/xs/bindings/XSDateTimeBinding.java
===================================================================
--- branches/2.7.x/modules/extension/xsd/xsd-core/src/main/java/org/geotools/xs/bindings/XSDateTimeBinding.java 2011-11-21 13:22:49 UTC (rev 38368)
+++ branches/2.7.x/modules/extension/xsd/xsd-core/src/main/java/org/geotools/xs/bindings/XSDateTimeBinding.java 2011-11-21 13:24:33 UTC (rev 38369)
@@ -22,6 +22,8 @@
import java.util.TimeZone;
import javax.xml.namespace.QName;
+
+import org.geotools.util.Converters;
import org.geotools.xml.InstanceComponent;
import org.geotools.xml.SimpleBinding;
import org.geotools.xml.impl.DatatypeConverterImpl;
@@ -116,8 +118,7 @@
* @generated modifiable
*/
public String encode(Object object, String value) {
- final Date timestamp = (Date) object;// lets catch up java.util.Date as well as
- // java.sql.Timestamp
+ final Date timestamp = Converters.convert(object, Date.class);
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
cal.clear();
cal.setTimeInMillis(timestamp.getTime());
Modified: branches/2.7.x/modules/extension/xsd/xsd-core/src/test/java/org/geotools/xs/bindings/XSDateTimeStrategyTest.java
===================================================================
--- branches/2.7.x/modules/extension/xsd/xsd-core/src/test/java/org/geotools/xs/bindings/XSDateTimeStrategyTest.java 2011-11-21 13:22:49 UTC (rev 38368)
+++ branches/2.7.x/modules/extension/xsd/xsd-core/src/test/java/org/geotools/xs/bindings/XSDateTimeStrategyTest.java 2011-11-21 13:24:33 UTC (rev 38369)
@@ -158,6 +158,16 @@
cal = calendar(2011, 9, 24, 10, 53, 31, 999);
testEncodeCalendar(cal, TEST.DATETIME, "2011-10-24T10:53:31.999Z");
}
+
+ public void testDirectlyEncodeCalendarDateTime() throws Exception {
+ Calendar cal = calendar(2011, 9, 24, 10, 53, 31);
+ String encoded = new XSDateTimeBinding().encode(cal, null);
+ assertEquals("2011-10-24T10:53:31Z", encoded);
+
+ cal = calendar(2011, 9, 24, 10, 53, 31, 999);
+ encoded = new XSDateTimeBinding().encode(cal, null);
+ assertEquals("2011-10-24T10:53:31.999Z", encoded);
+ }
private void testEncodeCalendar(Calendar cal, QName qname, String expected) throws Exception {
Encoder encoder = new Encoder(new TestConfiguration());
|
|
From: <svn...@os...> - 2011-11-21 13:23:01
|
Author: aaime
Date: 2011-11-21 05:22:49 -0800 (Mon, 21 Nov 2011)
New Revision: 38368
Modified:
trunk/modules/extension/xsd/xsd-core/src/main/java/org/geotools/xs/bindings/XSDateTimeBinding.java
trunk/modules/extension/xsd/xsd-core/src/test/java/org/geotools/xs/bindings/XSDateTimeStrategyTest.java
Log:
[GEOT-3957] Regression: XSDateTimeBinding cannot handle calendar anymore
Modified: trunk/modules/extension/xsd/xsd-core/src/main/java/org/geotools/xs/bindings/XSDateTimeBinding.java
===================================================================
--- trunk/modules/extension/xsd/xsd-core/src/main/java/org/geotools/xs/bindings/XSDateTimeBinding.java 2011-11-20 17:49:07 UTC (rev 38367)
+++ trunk/modules/extension/xsd/xsd-core/src/main/java/org/geotools/xs/bindings/XSDateTimeBinding.java 2011-11-21 13:22:49 UTC (rev 38368)
@@ -22,6 +22,8 @@
import java.util.TimeZone;
import javax.xml.namespace.QName;
+
+import org.geotools.util.Converters;
import org.geotools.xml.InstanceComponent;
import org.geotools.xml.SimpleBinding;
import org.geotools.xml.impl.DatatypeConverterImpl;
@@ -116,8 +118,7 @@
* @generated modifiable
*/
public String encode(Object object, String value) {
- final Date timestamp = (Date) object;// lets catch up java.util.Date as well as
- // java.sql.Timestamp
+ final Date timestamp = Converters.convert(object, Date.class);
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
cal.clear();
cal.setTimeInMillis(timestamp.getTime());
Modified: trunk/modules/extension/xsd/xsd-core/src/test/java/org/geotools/xs/bindings/XSDateTimeStrategyTest.java
===================================================================
--- trunk/modules/extension/xsd/xsd-core/src/test/java/org/geotools/xs/bindings/XSDateTimeStrategyTest.java 2011-11-20 17:49:07 UTC (rev 38367)
+++ trunk/modules/extension/xsd/xsd-core/src/test/java/org/geotools/xs/bindings/XSDateTimeStrategyTest.java 2011-11-21 13:22:49 UTC (rev 38368)
@@ -158,6 +158,16 @@
cal = calendar(2011, 9, 24, 10, 53, 31, 999);
testEncodeCalendar(cal, TEST.DATETIME, "2011-10-24T10:53:31.999Z");
}
+
+ public void testDirectlyEncodeCalendarDateTime() throws Exception {
+ Calendar cal = calendar(2011, 9, 24, 10, 53, 31);
+ String encoded = new XSDateTimeBinding().encode(cal, null);
+ assertEquals("2011-10-24T10:53:31Z", encoded);
+
+ cal = calendar(2011, 9, 24, 10, 53, 31, 999);
+ encoded = new XSDateTimeBinding().encode(cal, null);
+ assertEquals("2011-10-24T10:53:31.999Z", encoded);
+ }
private void testEncodeCalendar(Calendar cal, QName qname, String expected) throws Exception {
Encoder encoder = new Encoder(new TestConfiguration());
|
Author: aaime Date: 2011-11-20 09:49:07 -0800 (Sun, 20 Nov 2011) New Revision: 38367 Added: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/CloseableIteratorWrapper.java trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/IdentifierComparator.java trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/IndexManager.java trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/IndexedShapefileFeatureReader.java trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapeFileIndexer.java trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileSetManager.java trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/fid/ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/fid/FidIndexer.java trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/fid/IndexedFidReader.java trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/fid/IndexedFidWriter.java trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/fid/RecordNumberTracker.java trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/fid/ trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/fid/FIDTestCase.java trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/fid/FidIndexerTest.java trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/fid/FidQueryTest.java trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/fid/IndexedFidReaderTest.java trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/fid/IndexedFidWriterTest.java Modified: trunk/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/indexed/IndexedShapefileDataStore.java trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileDataStore.java trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactory.java trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureReader.java trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureSource.java trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureStore.java trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/dbf/IndexedDbaseFileReader.java trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/files/ShpFileType.java trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/prj/PrjFileReader.java trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/shp/ShapefileReader.java trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileDataStoreTest.java Log: Adding support for spatial and fid index, copyright headers, more tests and other improvements. Still fails at transaction isolation and does not supports events Modified: trunk/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/indexed/IndexedShapefileDataStore.java =================================================================== --- trunk/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/indexed/IndexedShapefileDataStore.java 2011-11-20 17:48:20 UTC (rev 38366) +++ trunk/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/indexed/IndexedShapefileDataStore.java 2011-11-20 17:49:07 UTC (rev 38367) @@ -16,11 +16,7 @@ */ package org.geotools.data.shapefile.indexed; -import static org.geotools.data.shapefile.ShpFileType.DBF; -import static org.geotools.data.shapefile.ShpFileType.FIX; -import static org.geotools.data.shapefile.ShpFileType.QIX; -import static org.geotools.data.shapefile.ShpFileType.SHP; -import static org.geotools.data.shapefile.ShpFileType.SHX; +import static org.geotools.data.shapefile.ShpFileType.*; import java.io.File; import java.io.IOException; @@ -37,7 +33,6 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -import java.util.TimeZone; import java.util.TreeSet; import java.util.logging.Level; Added: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/CloseableIteratorWrapper.java =================================================================== --- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/CloseableIteratorWrapper.java (rev 0) +++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/CloseableIteratorWrapper.java 2011-11-20 17:49:07 UTC (rev 38367) @@ -0,0 +1,50 @@ +/* + * 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.geotools.data.shapefile.ng; + +import java.io.IOException; +import java.util.Iterator; + +import org.geotools.data.shapefile.ng.index.CloseableIterator; + +/** + * Wraps a plain iterator into a closeable one. + */ +public class CloseableIteratorWrapper<E> implements CloseableIterator<E> { + Iterator<E> delegate; + + public CloseableIteratorWrapper(Iterator<E> delegate) { + this.delegate = delegate; + } + + public boolean hasNext() { + return delegate.hasNext(); + } + + public E next() { + return delegate.next(); + } + + public void remove() { + delegate.remove(); + } + + public void close() throws IOException { + // Just makes the API happy, the delegate does not really have a close method + } + +} Added: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/IdentifierComparator.java =================================================================== --- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/IdentifierComparator.java (rev 0) +++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/IdentifierComparator.java 2011-11-20 17:49:07 UTC (rev 38367) @@ -0,0 +1,50 @@ +/* + * 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.geotools.data.shapefile.ng; + +import java.util.Comparator; + +import org.opengis.filter.identity.Identifier; + +/** + * Compares two filter identifiers + * + * @author Andrea Aime - GeoSolutions + */ +class IdentifierComparator implements Comparator<Identifier> { + + String prefix; + + public IdentifierComparator(String typeName) { + this.prefix = typeName + "."; + } + + public int compare(Identifier o1, Identifier o2) { + String s1 = o1.toString(); + String s2 = o2.toString(); + if (s1.startsWith(prefix) && s2.startsWith(prefix)) { + try { + int i1 = Integer.parseInt(s1.substring(prefix.length())); + int i2 = Integer.parseInt(s2.substring(prefix.length())); + return i1 - i2; + } catch (NumberFormatException e) { + // it's ok, we want to fall back to string comparison + } + } + return s1.compareTo(s2); + } +} \ No newline at end of file Added: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/IndexManager.java =================================================================== --- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/IndexManager.java (rev 0) +++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/IndexManager.java 2011-11-20 17:49:07 UTC (rev 38367) @@ -0,0 +1,369 @@ +package org.geotools.data.shapefile.ng; + +import static org.geotools.data.shapefile.ng.files.ShpFileType.*; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.nio.channels.ReadableByteChannel; +import java.util.ArrayList; +import java.util.List; +import java.util.TreeSet; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.geotools.data.DataSourceException; +import org.geotools.data.DataUtilities; +import org.geotools.data.shapefile.ng.fid.FidIndexer; +import org.geotools.data.shapefile.ng.fid.IndexedFidReader; +import org.geotools.data.shapefile.ng.files.FileWriter; +import org.geotools.data.shapefile.ng.files.ShpFileType; +import org.geotools.data.shapefile.ng.files.ShpFiles; +import org.geotools.data.shapefile.ng.index.CachedQuadTree; +import org.geotools.data.shapefile.ng.index.CloseableIterator; +import org.geotools.data.shapefile.ng.index.Data; +import org.geotools.data.shapefile.ng.index.DataDefinition; +import org.geotools.data.shapefile.ng.index.TreeException; +import org.geotools.data.shapefile.ng.index.quadtree.QuadTree; +import org.geotools.data.shapefile.ng.index.quadtree.StoreException; +import org.geotools.data.shapefile.ng.index.quadtree.fs.FileSystemIndexStore; +import org.geotools.data.shapefile.ng.shp.IndexFile; +import org.geotools.util.NullProgressListener; +import org.geotools.util.logging.Logging; +import org.opengis.filter.Id; +import org.opengis.filter.identity.Identifier; + +import com.vividsolutions.jts.geom.Envelope; + +/** + * Manages the index files on behalf of the the {@link ShapefileDataStore} + * + * @author Andrea Aime - GeoSolutions + */ +class IndexManager { + + static final Logger LOGGER = Logging.getLogger(IndexManager.class); + + static final int DEFAULT_MAX_QIX_CACHE_SIZE; + + ShpFiles shpFiles; + + int maxQixCacheSize = DEFAULT_MAX_QIX_CACHE_SIZE; + + CachedQuadTree cachedTree; + + ShapefileDataStore store; + + /** + * Used to lock the files when doing accesses to check indexes and the like + */ + FileWriter writer = new FileWriter() { + + @Override + public String id() { + return "ShapefileDataStore-" + store.getTypeName().getLocalPart(); + } + }; + + static { + int max = -1; + try { + String smax = System.getProperty("org.geotools.shapefile.maxQixCacheSize"); + if (smax != null) { + max = Integer.parseInt(smax); + } + } catch (Throwable t) { + LOGGER.log(Level.SEVERE, "Could not set the max qix cache size", t); + } + DEFAULT_MAX_QIX_CACHE_SIZE = max; + } + + public IndexManager(ShpFiles shpFiles, ShapefileDataStore store) { + this.shpFiles = shpFiles; + this.store = store; + } + + /** + * Creates the spatial index is appropriate. + * + * @param force Forces the index re-creation even if the spatial index seems to be up to date + * @return true if the spatial index has been created/updated + */ + public boolean createSpatialIndex(boolean force) { + // create index as needed + try { + if (shpFiles.isLocal() && (isIndexStale(QIX) || force)) { + ShapefileDataStoreFactory.LOGGER.fine("Creating spatial index for " + + shpFiles.get(SHP)); + + ShapeFileIndexer indexer = new ShapeFileIndexer(); + indexer.setShapeFileName(shpFiles); + indexer.index(false, new NullProgressListener()); + + return true; + } + } catch (Throwable t) { + ShapefileDataStoreFactory.LOGGER.log(Level.SEVERE, t.getLocalizedMessage(), t); + } + return false; + } + + /** + * If the fid index can be used and it is missing this method will try to create it + * + * @return + */ + boolean hasFidIndex() { + if (isIndexUseable(FIX)) { + return true; + } else { + if (shpFiles.isLocal()) { + return createFidIndex(); + } else { + return false; + } + + } + } + + public boolean createFidIndex() { + try { + FidIndexer.generate(shpFiles); + return true; + } catch (IOException e) { + LOGGER.log(Level.WARNING, "Failed to create fid index"); + return false; + } + } + + /** + * Returns true if the specified index exists, is up to date, and can be read + * + * @param indexType + * @return + */ + boolean isIndexUseable(ShpFileType indexType) { + if (shpFiles.isLocal()) { + if (isIndexStale(indexType) || !shpFiles.exists(indexType)) { + return false; + } + } else { + + ReadableByteChannel read = null; + try { + read = shpFiles.getReadChannel(indexType, writer); + } catch (IOException e) { + return false; + } finally { + if (read != null) { + try { + read.close(); + } catch (IOException e) { + ShapefileDataStoreFactory.LOGGER.log(Level.WARNING, + "could not close stream", e); + } + } + } + } + + return true; + } + + /** + * Returns true if the specified index file is outdated compared to the shapefile .shp and .shx + * files + * + * @param indexType + * @return + */ + boolean isIndexStale(ShpFileType indexType) { + if (!shpFiles.isLocal()) + throw new IllegalStateException( + "This method only applies if the files are local and the file can be created"); + + URL indexURL = shpFiles.acquireRead(indexType, writer); + URL shpURL = shpFiles.acquireRead(SHP, writer); + try { + + if (indexURL == null) { + return true; + } + // indexes require both the SHP and SHX so if either or missing then + // you don't need to + // index + if (!shpFiles.exists(SHX) || !shpFiles.exists(SHP)) { + return false; + } + + File indexFile = DataUtilities.urlToFile(indexURL); + File shpFile = DataUtilities.urlToFile(shpURL); + long indexLastModified = indexFile.lastModified(); + long shpLastModified = shpFile.lastModified(); + boolean shpChangedMoreRecently = indexLastModified < shpLastModified; + return !indexFile.exists() || shpChangedMoreRecently; + } finally { + if (shpURL != null) { + shpFiles.unlockRead(shpURL, writer); + } + if (indexURL != null) { + shpFiles.unlockRead(indexURL, writer); + } + } + } + + /** + * Uses the Fid index to quickly lookup the shp offset and the record number for the list of + * fids + * + * @param fids the fid filter identifying the ids + * @return a list of Data objects + * @throws IOException + * @throws TreeException + */ + List<Data> queryFidIndex(Id fidFilter) throws IOException { + // sort by fid to increase performance and allow skipping on natural order + TreeSet<Identifier> idsSet = new TreeSet<Identifier>(new IdentifierComparator(store.getTypeName().getLocalPart())); + idsSet.addAll(fidFilter.getIdentifiers()); + + IndexedFidReader reader = new IndexedFidReader(shpFiles); + + List<Data> records = new ArrayList(idsSet.size()); + try { + IndexFile shx = store.shpManager.openIndexFile(); + try { + + DataDefinition def = new DataDefinition("US-ASCII"); + def.addField(Integer.class); + def.addField(Long.class); + for (Identifier identifier : idsSet) { + String fid = identifier.toString(); + long recno = reader.findFid(fid); + if (recno == -1) { + if (LOGGER.isLoggable(Level.FINEST)) { + LOGGER.finest("fid " + fid + + " not found in index, continuing with next queried fid..."); + } + continue; + } + try { + Data data = new Data(def); + data.addValue(new Integer((int) recno + 1)); + data.addValue(new Long(shx.getOffsetInBytes((int) recno))); + if (LOGGER.isLoggable(Level.FINEST)) { + LOGGER.finest("fid " + fid + " found for record #" + data.getValue(0) + + " at index file offset " + data.getValue(1)); + } + records.add(data); + } catch (Exception e) { + IOException exception = new IOException(); + exception.initCause(e); + throw exception; + } + } + } finally { + shx.close(); + } + } finally { + reader.close(); + } + + return records; + } + + /** + * Queries the spatial index for features available in the specified bbox + * + * @param bbox + * + * + * @throws DataSourceException + * @throws IOException + * @throws TreeException DOCUMENT ME! + */ + protected CloseableIterator<Data> querySpatialIndex(Envelope bbox) throws DataSourceException, + IOException, TreeException { + CloseableIterator<Data> tmp = null; + + // check if the spatial index needs recreating + createSpatialIndex(false); + + if (cachedTree == null) { + boolean canCache = false; + URL treeURL = shpFiles.acquireRead(QIX, writer); + try { + File treeFile = DataUtilities.urlToFile(treeURL); + + if (treeFile != null && treeFile.exists() && treeFile.length() < 1024 * maxQixCacheSize) { + canCache = true; + } + } finally { + shpFiles.unlockRead(treeURL, writer); + } + + if (canCache) { + QuadTree quadTree = openQuadTree(); + if (quadTree != null) { + LOGGER.warning("Experimental: loading in memory the quadtree for " + + shpFiles.get(SHP)); + cachedTree = new CachedQuadTree(quadTree); + quadTree.close(); + } + } + } + if (cachedTree != null) { + if (!bbox.contains(cachedTree.getBounds())) { + return cachedTree.search(bbox); + } else { + return null; + } + } else { + try { + QuadTree quadTree = openQuadTree(); + if ((quadTree != null) && !bbox.contains(quadTree.getRoot().getBounds())) { + tmp = quadTree.search(bbox); + } + if (tmp == null && quadTree != null) { + quadTree.close(); + } + } catch (Exception e) { + throw new DataSourceException("Error querying QuadTree", e); + } + } + + return tmp; + } + + /** + * Convenience method for opening a QuadTree index. + * + * @return A new QuadTree + * + * @throws StoreException + */ + protected QuadTree openQuadTree() throws StoreException { + if (!shpFiles.isLocal()) { + return null; + } + URL treeURL = shpFiles.acquireRead(QIX, writer); + try { + File treeFile = DataUtilities.urlToFile(treeURL); + + if (!treeFile.exists() || (treeFile.length() == 0)) { + return null; + } + + try { + FileSystemIndexStore idxStore = new FileSystemIndexStore(treeFile); + return idxStore.load(store.shpManager.openIndexFile(), store.isMemoryMapped()); + } catch (IOException e) { + throw new StoreException(e); + } + } finally { + shpFiles.unlockRead(treeURL, writer); + } + } + + public void dispose() { + this.cachedTree = null; + } +} Added: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/IndexedShapefileFeatureReader.java =================================================================== --- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/IndexedShapefileFeatureReader.java (rev 0) +++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/IndexedShapefileFeatureReader.java 2011-11-20 17:49:07 UTC (rev 38367) @@ -0,0 +1,124 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2008, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package org.geotools.data.shapefile.ng; + +import java.io.IOException; + +import org.geotools.data.shapefile.ng.dbf.DbaseFileReader; +import org.geotools.data.shapefile.ng.dbf.DbaseFileReader.Row; +import org.geotools.data.shapefile.ng.dbf.IndexedDbaseFileReader; +import org.geotools.data.shapefile.ng.index.CloseableIterator; +import org.geotools.data.shapefile.ng.index.Data; +import org.geotools.data.shapefile.ng.shp.ShapefileReader; +import org.geotools.data.shapefile.ng.shp.ShapefileReader.Record; +import org.opengis.feature.simple.SimpleFeatureType; + +import com.vividsolutions.jts.geom.Envelope; +import com.vividsolutions.jts.geom.Geometry; + +/** + * The indexed version of the shapefile feature reader, will only read the records specified in the + * constructor + * + * @source $URL$ + */ +class IndexedShapefileFeatureReader extends ShapefileFeatureReader { + + protected CloseableIterator<Data> goodRecs; + + private Data next; + + /** + * Create the shape reader + * + * @param atts - the attributes that we are going to read. + * @param shp - the shape reader, required + * @param dbf - the dbf file reader. May be null, in this case no attributes will be read from + * the dbf file + * @param goodRecs Collection of good indexes that match the query. + */ + public IndexedShapefileFeatureReader(SimpleFeatureType schema, ShapefileReader shp, + DbaseFileReader dbf, CloseableIterator<Data> goodRecs) throws IOException { + super(schema, shp, dbf); + this.goodRecs = goodRecs; + } + + public void close() throws IOException { + try { + super.close(); + } finally { + if (goodRecs != null) { + goodRecs.close(); + } + goodRecs = null; + } + } + + public boolean hasNext() throws IOException { + while (nextFeature == null && this.goodRecs.hasNext()) { + next = (Data) goodRecs.next(); + + Long l = (Long) next.getValue(1); + shp.goTo((int) l.longValue()); + + Record record = shp.nextRecord(); + + // read the geometry, so that we can decide if this row is to be skipped or not + Envelope envelope = record.envelope(); + Geometry geometry = null; + + if(schema.getGeometryDescriptor() != null) { + // ... if geometry is out of the target bbox, skip both geom and row + if (targetBBox != null && !targetBBox.isNull() && !targetBBox.intersects(envelope)) { + continue; + // ... if the geometry is awfully small avoid reading it (unless it's a point) + } else if (simplificationDistance > 0 && envelope.getWidth() < simplificationDistance + && envelope.getHeight() < simplificationDistance) { + try { + if (screenMap != null && screenMap.checkAndSet(envelope)) { + continue; + } else { + // if we are using the screenmap better provide a slightly modified + // version of the geometry bounds or we'll end up with many holes + // in the rendering + geometry = (Geometry) record.getSimplifiedShape(screenMap); + } + } catch (Exception e) { + geometry = (Geometry) record.getSimplifiedShape(); + } + // ... otherwise business as usual + } else { + geometry = (Geometry) record.shape(); + } + } + + // read the dbf only if the geometry was not skipped + Row row; + if (dbf != null) { + ((IndexedDbaseFileReader) dbf).goTo(record.number); + row = dbf.readRow(); + } else { + row = null; + } + + nextFeature = buildFeature(record.number, geometry, row); + } + + return nextFeature != null; + } + +} Added: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapeFileIndexer.java =================================================================== --- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapeFileIndexer.java (rev 0) +++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapeFileIndexer.java 2011-11-20 17:49:07 UTC (rev 38367) @@ -0,0 +1,435 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package org.geotools.data.shapefile.ng; + +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.geotools.data.shapefile.ng.files.FileWriter; +import org.geotools.data.shapefile.ng.files.ShpFileType; +import org.geotools.data.shapefile.ng.files.ShpFiles; +import org.geotools.data.shapefile.ng.files.StorageFile; +import org.geotools.data.shapefile.ng.index.LockTimeoutException; +import org.geotools.data.shapefile.ng.index.TreeException; +import org.geotools.data.shapefile.ng.index.quadtree.Node; +import org.geotools.data.shapefile.ng.index.quadtree.QuadTree; +import org.geotools.data.shapefile.ng.index.quadtree.StoreException; +import org.geotools.data.shapefile.ng.index.quadtree.fs.FileSystemIndexStore; +import org.geotools.data.shapefile.ng.index.quadtree.fs.IndexHeader; +import org.geotools.data.shapefile.ng.shp.IndexFile; +import org.geotools.data.shapefile.ng.shp.ShapefileHeader; +import org.geotools.data.shapefile.ng.shp.ShapefileReader; +import org.geotools.data.shapefile.ng.shp.ShapefileReader.Record; +import org.geotools.util.NullProgressListener; +import org.geotools.util.logging.Logging; +import org.opengis.util.ProgressListener; + +import com.vividsolutions.jts.geom.Envelope; +import com.vividsolutions.jts.geom.GeometryFactory; + +/** + * Utility class for Shapefile spatial indexing + * + * @author Tommaso Nolli + * + * + * @source $URL$ + */ +public class ShapeFileIndexer implements FileWriter { + private static final Logger LOGGER = Logging.getLogger(ShapeFileIndexer.class); + + private int max = -1; + private int leafSize = 16; + + private String byteOrder; + private boolean interactive = false; + private ShpFiles shpFiles; + + public static void main(String[] args) throws IOException { + if ((args.length < 1) || (((args.length - 1) % 2) != 0)) { + usage(); + } + + long start = System.currentTimeMillis(); + + ShapeFileIndexer idx = new ShapeFileIndexer(); + idx.interactive = true; + + for (int i = 0; i < args.length; i++) { + if (args[i].equals("-t")) { + // idx.setIdxType(IndexType.valueOf(args[++i])); + // just skip it for backwards compatibility + i++; + } else if (args[i].equals("-M")) { + idx.setMax(Integer.parseInt(args[++i])); + } else if (args[i].equals("-s")) { + idx.setLeafSize(Integer.parseInt(args[++i])); + } else if (args[i].equals("-b")) { + idx.setByteOrder(args[++i]); + } else { + if (!args[i].toLowerCase().endsWith(".shp")) { + System.out.println("File extension must be '.shp'"); + System.exit(1); + } + + idx.setShapeFileName(new ShpFiles(args[i])); + } + } + + try { + System.out.print("Indexing "); + + int cnt = idx.index(true, new NullProgressListener()); + System.out.println(); + System.out.print(cnt + " features indexed "); + System.out.println("in " + (System.currentTimeMillis() - start) + + "ms."); + System.out.println(); + } catch (Exception e) { + e.printStackTrace(); + usage(); + System.exit(1); + } + } + + private static void usage() { + System.out.println("Usage: ShapeFileIndexer " + "-t <QIX> " + + "[-M <max tree depth>] " + + "[-b <byte order NL | NM>] " + "<shape file>" + + "[-s <max number of items in a leaf>]"); + + System.out.println(); + + System.out.println("Options:"); + System.out.println("\t-t Index type: RTREE or QUADTREE"); + System.out.println(); + System.out.println("Following options apllies only to QUADTREE:"); + System.out.println("\t-b byte order to use: NL = LSB; " + + "NM = MSB (default)"); + + System.exit(1); + } + + /** + * Index the shapefile denoted by setShapeFileName(String fileName) If when + * a thread starts, another thread is indexing the same file, this thread + * will wait that the first thread ends indexing; in this case <b>zero</b> + * is reurned as result of the indexing process. + * + * @param verbose + * enable/disable printing of dots every 500 indexed records + * @param listener + * DOCUMENT ME! + * + * @return The number of indexed records (or zero) + * + * @throws MalformedURLException + * @throws IOException + * @throws TreeException + * @throws StoreException + * DOCUMENT ME! + * @throws LockTimeoutException + */ + public int index(boolean verbose, ProgressListener listener) + throws MalformedURLException, IOException, TreeException, + StoreException, LockTimeoutException { + + if (this.shpFiles == null) { + throw new IOException("You have to set a shape file name!"); + } + + int cnt = 0; + + ShapefileReader reader = null; + + // Temporary file for building... + StorageFile storage = shpFiles.getStorageFile(ShpFileType.QIX); + File treeFile = storage.getFile(); + + try { + reader = new ShapefileReader(shpFiles, true, false, new GeometryFactory()); + + if(max == -1) { + // compute a reasonable index max depth, considering a fully developed + // 10 levels one already contains 200k index nodes, good for indexing up + // to 3M features without consuming too much memory + int features = reader.getCount(0); + max = 1; + int nodes = 1; + while(nodes * leafSize < features) { + max++; + nodes *= 4; + } + if(max < 10) { + max = 10; + } + + reader.close(); + reader = new ShapefileReader(shpFiles, true, false, new GeometryFactory()); + } + + cnt = this.buildQuadTree(reader, treeFile, verbose); + } finally { + if (reader != null) + reader.close(); + } + + // Final index file + storage.replaceOriginal(); + + return cnt; + } + + private int buildQuadTree(ShapefileReader reader, File file, boolean verbose) + throws IOException, StoreException { + LOGGER.fine("Building quadtree spatial index with depth " + max + " for file " + file.getAbsolutePath()); + + byte order = 0; + + if ((this.byteOrder == null) || this.byteOrder.equalsIgnoreCase("NM")) { + order = IndexHeader.NEW_MSB_ORDER; + } else if (this.byteOrder.equalsIgnoreCase("NL")) { + order = IndexHeader.NEW_LSB_ORDER; + } else { + throw new StoreException("Asked byte order '" + this.byteOrder + + "' must be 'NL' or 'NM'!"); + } + + IndexFile shpIndex = new IndexFile(shpFiles, false); + QuadTree tree = null; + int cnt = 0; + int numRecs = shpIndex.getRecordCount(); + ShapefileHeader header = reader.getHeader(); + Envelope bounds = new Envelope(header.minX(), header.maxX(), header + .minY(), header.maxY()); + + tree = new QuadTree(numRecs, max, bounds, shpIndex); + try { + Record rec = null; + + while (reader.hasNext()) { + rec = reader.nextRecord(); + tree.insert(cnt++, new Envelope(rec.minX, rec.maxX, rec.minY, + rec.maxY)); + + if (verbose && ((cnt % 1000) == 0)) { + System.out.print('.'); + } + if (cnt % 100000 == 0) + System.out.print('\n'); + } + if (verbose) + System.out.println("done"); + FileSystemIndexStore store = new FileSystemIndexStore(file, order); + + if(leafSize > 0) { + if (LOGGER.isLoggable(Level.FINE)) { + LOGGER.fine("Optimizing the tree (this might take some time)"); + } + optimizeTree(tree, tree.getRoot(), 0, reader, shpIndex); + if (LOGGER.isLoggable(Level.FINE)) { + LOGGER.fine("Tree optimized"); + } + } + + if(LOGGER.isLoggable(Level.FINE)) { + printStats(tree); + } + store.store(tree); + } finally { + tree.close(); + } + return cnt; + } + + private Node optimizeTree(QuadTree tree, Node node, int level, ShapefileReader reader, IndexFile index) throws StoreException, IOException { + // recurse, with a check to avoid too deep recursion due to odd data that has a + if(node.getNumShapeIds() > leafSize && node.getNumSubNodes() == 0 && level < max * 2) { + // ok, we need to split this baby further + int[] shapeIds = node.getShapesId(); + int numShapesId = node.getNumShapeIds(); + node.clean(); + + // get an estimate on how many more levels we need + int extraLevels = 2; + int nodes = 4; + while(nodes * leafSize < numShapesId) { + extraLevels++; + nodes *= 4; + } + + for (int i = 0; i < numShapesId; i++) { + final int shapeId = shapeIds[i]; + int offset = index.getOffsetInBytes(shapeId); + reader.goTo(offset); + Record rec = reader.nextRecord(); + Envelope env = new Envelope(rec.minX, rec.maxX, rec.minY, rec.maxY); + tree.insert(node, shapeId, env, extraLevels); + } + } + + // pack the arrays to use less memory (the optimization often makes the tree grow) + node.pack(); + + // recurse + for (int i = 0; i < node.getNumSubNodes(); i++) { + optimizeTree(tree, node.getSubNode(i), level + 1, reader, index); + } + + // prune empty subnodes + for (int i = 0; i < node.getNumSubNodes();) { + Node child = node.getSubNode(i); + if(child != null && child.getNumShapeIds() == 0 && child.getNumSubNodes() == 0) { + // empty child, we don't need it, clean it up + node.removeSubNode(child); + } else { + i++; + } + } + + // handle degenerate chains, we pop up the nodes to the top by keeping + // their shape ids _and_ their bounds (as it's the only area that has something) + if(node.getNumSubNodes() == 1 && node.getNumShapeIds() == 0) { + Node subnode = node.getSubNode(0); + node.clearSubNodes(); + node.setShapesId(subnode); + node.setBounds(subnode.getBounds()); + for (int i = 0; i < subnode.getNumSubNodes(); i++) { + node.addSubNode(subnode.getSubNode(i)); + } + } else { + // limit this node area to the effective child area + Envelope bounds = new Envelope(); + if(node.getNumShapeIds() > 0) { + int[] shapeIds = node.getShapesId(); + for (int i = 0; i < shapeIds.length; i++) { + final int shapeId = shapeIds[i]; + int offset = index.getOffsetInBytes(shapeId); + reader.goTo(offset); + Record rec = reader.nextRecord(); + Envelope env = new Envelope(rec.minX, rec.maxX, rec.minY, rec.maxY); + bounds.expandToInclude(env); + } + } + if(node.getNumSubNodes() > 0) { + for (int i = 0; i < node.getNumSubNodes(); i++) { + bounds.expandToInclude(node.getSubNode(i).getBounds()); + } + } + node.setBounds(bounds); + + // can we shrink? + int count = node.getNumShapeIds(); + for (int i = 0; i < node.getNumSubNodes(); i++) { + Node child = node.getSubNode(i); + if(child.getNumSubNodes() > 0) { + count = Integer.MAX_VALUE; + break; + } else { + count += child.getNumShapeIds(); + } + } + if(count < leafSize) { + for (int i = 0; i < node.getNumSubNodes(); i++) { + Node child = node.getSubNode(i); + int[] shapesId = child.getShapesId(); + for (int j = 0; j < child.getNumShapeIds(); j++) { + node.addShapeId(shapesId[j]); + } + } + node.clearSubNodes(); + } + } + + return node; + } + + private void printStats(QuadTree tree) throws StoreException { + Map<Integer, Integer> stats = new HashMap<Integer, Integer>(); + gatherStats(tree.getRoot(), stats); + + List<Integer> nums = new ArrayList<Integer>(stats.keySet()); + Collections.sort(nums); + LOGGER.log(Level.FINE, "Index statistics"); + for (Integer num : nums) { + LOGGER.log(Level.FINE, num + " -> " + stats.get(num)); + } + + } + + void gatherStats(Node node, Map<Integer, Integer> stats) throws StoreException { + int num = node.getNumShapeIds(); + Integer count = stats.get(num); + if(count == null) { + stats.put(num, 1); + } else { + stats.put(num, count + 1); + } + for (int i = 0; i < node.getNumSubNodes(); i++) { + gatherStats(node.getSubNode(i), stats); + } + } + + /** + * For quad tree this is the max depth. I don't know what it is for RTree + * + * @param i + */ + public void setMax(int i) { + max = i; + } + + /** + * DOCUMENT ME! + * + * @param shpFiles + */ + public void setShapeFileName(ShpFiles shpFiles) { + this.shpFiles = shpFiles; + } + + + /** + * DOCUMENT ME! + * + * @param byteOrder + * The byteOrder to set. + */ + public void setByteOrder(String byteOrder) { + this.byteOrder = byteOrder; + } + + public String id() { + return getClass().getName(); + } + + public int getLeafSize() { + return leafSize; + } + + public void setLeafSize(int leafSize) { + this.leafSize = leafSize; + } +} Modified: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileDataStore.java =================================================================== --- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileDataStore.java 2011-11-20 17:48:20 UTC (rev 38366) +++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileDataStore.java 2011-11-20 17:49:07 UTC (rev 38367) @@ -1,3 +1,19 @@ +/* + * 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.geotools.data.shapefile.ng; import static org.geotools.data.shapefile.ng.files.ShpFileType.*; @@ -54,16 +70,19 @@ public static final String ORIGINAL_FIELD_DUPLICITY_COUNT = "count"; - public static final Charset DEFAULT_STRING_CHARSET = (Charset) ShapefileDataStoreFactory.DBFCHARSET.getDefaultValue(); - - public static final TimeZone DEFAULT_TIMEZONE = (TimeZone) ShapefileDataStoreFactory.DBFTIMEZONE.getDefaultValue(); - + public static final Charset DEFAULT_STRING_CHARSET = (Charset) ShapefileDataStoreFactory.DBFCHARSET + .getDefaultValue(); + + public static final TimeZone DEFAULT_TIMEZONE = (TimeZone) ShapefileDataStoreFactory.DBFTIMEZONE + .getDefaultValue(); + /** - * When true, the stack trace that got a lock that wasn't released is recorded and then - * printed out when warning the user about this. + * When true, the stack trace that got a lock that wasn't released is recorded and then printed + * out when warning the user about this. */ - protected static final Boolean TRACE_ENABLED = "true".equalsIgnoreCase(System.getProperty("gt2.shapefile.trace")); - + protected static final Boolean TRACE_ENABLED = "true".equalsIgnoreCase(System + .getProperty("gt2.shapefile.trace")); + /** * The stack trace used to track code that grabs the data store without disposing it */ @@ -81,12 +100,20 @@ boolean indexed = true; + boolean fidIndexed = true; + + IndexManager indexManager; + + ShapefileSetManager shpManager; + public ShapefileDataStore(URL url) { shpFiles = new ShpFiles(url); - if(TRACE_ENABLED) { + if (TRACE_ENABLED) { trace = new Exception(); trace.fillInStackTrace(); } + shpManager = new ShapefileSetManager(shpFiles, this); + indexManager = new IndexManager(shpFiles, this); } @Override @@ -94,7 +121,7 @@ return Collections.singletonList(getTypeName()); } - private Name getTypeName() { + Name getTypeName() { return new NameImpl(namespaceURI, shpFiles.getTypeName()); } @@ -105,7 +132,7 @@ public ContentFeatureSource getFeatureSource() throws IOException { ContentEntry entry = ensureEntry(getTypeName()); - if(shpFiles.isWritable()) { + if (shpFiles.isWritable()) { return new ShapefileFeatureStore(entry, shpFiles); } else { return new ShapefileFeatureSource(entry, shpFiles); @@ -157,36 +184,32 @@ } public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader() throws IOException { - return super.getFeatureReader(new Query(getTypeName().getLocalPart()), Transaction.AUTO_COMMIT); + return super.getFeatureReader(new Query(getTypeName().getLocalPart()), + Transaction.AUTO_COMMIT); } public long getCount(Query query) throws IOException { return getFeatureSource().getCount(query); } - + /** - * Set the FeatureType of this DataStore. This method will delete any - * existing local resources or throw an IOException if the DataStore is - * remote. + * Set the FeatureType of this DataStore. This method will delete any existing local resources + * or throw an IOException if the DataStore is remote. * - * @param featureType - * The desired FeatureType. + * @param featureType The desired FeatureType. * - * @throws IOException - * If the DataStore is remote. + * @throws IOException If the DataStore is remote. */ public void createSchema(SimpleFeatureType featureType) throws IOException { if (!shpFiles.isLocal()) { - throw new IOException( - "Cannot create FeatureType on remote or in-classpath shapefile"); + throw new IOException("Cannot create FeatureType on remote or in-classpath shapefile"); } shpFiles.delete(); CoordinateReferenceSystem crs = featureType.getGeometryDescriptor() .getCoordinateReferenceSystem(); - final Class<?> geomType = featureType.getGeometryDescriptor().getType() - .getBinding(); + final Class<?> geomType = featureType.getGeometryDescriptor().getType().getBinding(); final ShapeType shapeType; if (Point.class.isAssignableFrom(geomType)) { @@ -200,9 +223,8 @@ || MultiPolygon.class.isAssignableFrom(geomType)) { shapeType = ShapeType.POLYGON; } else { - throw new DataSourceException( - "Cannot create a shapefile whose geometry type is " - + geomType); + throw new DataSourceException("Cannot create a shapefile whose geometry type is " + + geomType); } StorageFile shpStoragefile = shpFiles.getStorageFile(SHP); @@ -248,31 +270,26 @@ } finally { prjWriter.close(); } - } - else { + } else { LOGGER.warning("PRJ file not generated for null CoordinateReferenceSystem"); } - StorageFile.replaceOriginals(shpStoragefile, shxStoragefile, - dbfStoragefile, prjStoragefile); + StorageFile + .replaceOriginals(shpStoragefile, shxStoragefile, dbfStoragefile, prjStoragefile); } - + /** - * Attempt to create a DbaseFileHeader for the FeatureType. Note, we cannot - * set the number of records until the write has completed. + * Attempt to create a DbaseFileHeader for the FeatureType. Note, we cannot set the number of + * records until the write has completed. * - * @param featureType - * DOCUMENT ME! + * @param featureType DOCUMENT ME! * * @return DOCUMENT ME! * - * @throws IOException - * DOCUMENT ME! - * @throws DbaseFileException - * DOCUMENT ME! + * @throws IOException DOCUMENT ME! + * @throws DbaseFileException DOCUMENT ME! */ - protected static DbaseFileHeader createDbaseHeader( - SimpleFeatureType featureType) throws IOException, - DbaseFileException { + protected static DbaseFileHeader createDbaseHeader(SimpleFeatureType featureType) + throws IOException, DbaseFileException { DbaseFileHeader header = new DbaseFileHeader(); @@ -285,8 +302,7 @@ int fieldLen = FeatureTypes.getFieldLength(type); if (fieldLen == FeatureTypes.ANY_LENGTH) fieldLen = 255; - if ((colType == Integer.class) || (colType == Short.class) - || (colType == Byte.class)) { + if ((colType == Integer.class) || (colType == Short.class) || (colType == Byte.class)) { header.addColumn(colName, 'N', Math.min(fieldLen, 9), 0); } else if (colType == Long.class) { header.addColumn(colName, 'N', Math.min(fieldLen, 19), 0); @@ -296,15 +312,14 @@ int l = Math.min(fieldLen, 33); int d = Math.max(l - 2, 0); header.addColumn(colName, 'N', l, d); - // This check has to come before the Date one or it is never reached - // also, this field is only activated with the following system property: - // org.geotools.shapefile.datetime=true + // This check has to come before the Date one or it is never reached + // also, this field is only activated with the following system property: + // org.geotools.shapefile.datetime=true } else if (java.util.Date.class.isAssignableFrom(colType) - && Boolean.getBoolean("org.geotools.shapefile.datetime")) - { + && Boolean.getBoolean("org.geotools.shapefile.datetime")) { header.addColumn(colName, '@', fieldLen, 0); - } else if (java.util.Date.class.isAssignableFrom(colType) || - Calendar.class.isAssignableFrom(colType)) { + } else if (java.util.Date.class.isAssignableFrom(colType) + || Calendar.class.isAssignableFrom(colType)) { header.addColumn(colName, 'D', fieldLen, 0); } else if (colType == Boolean.class) { header.addColumn(colName, 'L', 1, 0); @@ -321,20 +336,18 @@ return header; } - + /** * This method is used to force the creation of a .prj file. * <p> - * The internally cached FeatureType will be removed, so the next call to - * getSchema() will read in the created file. This method is not thread safe - * and will have dire consequences for any other thread making use of the - * shapefile. + * The internally cached FeatureType will be removed, so the next call to getSchema() will read + * in the created file. This method is not thread safe and will have dire consequences for any + * other thread making use of the shapefile. * <p> * * @param crs */ - public void forceSchemaCRS(CoordinateReferenceSystem crs) - throws IOException { + public void forceSchemaCRS(CoordinateReferenceSystem crs) throws IOException { if (crs == null) throw new NullPointerException("CRS required for .prj file"); @@ -351,24 +364,55 @@ storageFile.replaceOriginal(); entries.clear(); } - + @Override public void dispose() { super.dispose(); - if(shpFiles != null) { + if (shpFiles != null) { shpFiles.dispose(); shpFiles = null; } } - + @Override protected void finalize() throws Throwable { super.finalize(); - if(shpFiles != null && trace != null) { - LOGGER.log(Level.SEVERE, "Undisposed of shapefile, you should call dispose() on all shapefile stores", trace); + if (shpFiles != null && trace != null) { + LOGGER.log(Level.SEVERE, + "Undisposed of shapefile, you should call dispose() on all shapefile stores", + trace); } dispose(); } + /** + * Returns true if the store uses the .fix index file for feature ids. The .fix file speeds up + * filters by feature id and allows for stable ids in face of feature removals, without it the + * feature id is simply the position of the feature in the shapefile, something which changes + * when data is removed + * + * @return + */ + public boolean isFidIndexed() { + return fidIndexed; + } + /** + * Enables/disables the feature id index. The index is enabled by default + * @param fidIndexed + */ + public void setFidIndexed(boolean fidIndexed) { + this.fidIndexed = fidIndexed; + } + + @Override + public String toString() { + return "ShapefileDataStore [file=" + shpFiles.get(SHP) + ", charset=" + charset + ", timeZone=" + timeZone + + ", memoryMapped=" + memoryMapped + ", bufferCachingEnabled=" + + bufferCachingEnabled + ", indexed=" + indexed + ", fidIndexed=" + fidIndexed + + "]"; + } + + + } Modified: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactory.java =================================================================== --- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactory.java 2011-11-20 17:48:20 UTC (rev 38366) +++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileDataStoreFactory.java 2011-11-20 17:49:07 UTC (rev 38367) @@ -2,7 +2,7 @@ * GeoTools - The Open Source Java GIS Toolkit * http://geotools.org * - * (C) 2002-2009, Open Source Geospatial Foundation (OSGeo) + * (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 Modified: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureReader.java =================================================================== --- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureReader.java 2011-11-20 17:48:20 UTC (rev 38366) +++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureReader.java 2011-11-20 17:49:07 UTC (rev 38367) @@ -1,3 +1,19 @@ +/* + * 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.geotools.data.shapefile.ng; import java.io.IOException; @@ -9,11 +25,9 @@ import org.geotools.data.shapefile.ng.dbf.DbaseFileHeader; import org.geotools.data.shapefile.ng.dbf.DbaseFileReader; import org.geotools.data.shapefile.ng.dbf.DbaseFileReader.Row; -import org.geotools.data.shapefile.ng.dbf.DbaseFileWriter; import org.geotools.data.shapefile.ng.shp.ShapeType; import org.geotools.data.shapefile.ng.shp.ShapefileReader; import org.geotools.data.shapefile.ng.shp.ShapefileReader.Record; -import org.geotools.data.shapefile.ng.shp.ShapefileWriter; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.renderer.ScreenMap; import org.opengis.feature.simple.SimpleFeature; @@ -21,7 +35,6 @@ import org.opengis.feature.type.AttributeDescriptor; import org.opengis.feature.type.GeometryDescriptor; -import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jts.geom.Geometry; @@ -45,12 +58,20 @@ ScreenMap screenMap; + StringBuffer idxBuffer; + + int idxBaseLen; + public ShapefileFeatureReader(SimpleFeatureType schema, ShapefileReader shp, DbaseFileReader dbf) throws IOException { this.schema = schema; this.shp = shp; this.dbf = dbf; this.builder = new SimpleFeatureBuilder(schema); + + idxBuffer = new StringBuffer(schema.getTypeName()); + idxBuffer.append('.'); + idxBaseLen = idxBuffer.length(); if (dbf != null) { // build the list of dbf indexes we have to read taking into consideration the @@ -136,30 +157,31 @@ // read the geometry, so that we can decide if this row is to be skipped or not Envelope envelope = record.envelope(); boolean skip = false; - Geometry geometry; - // ... if geometry is out of the target bbox, skip both geom and row - if (targetBBox != null && !targetBBox.isNull() && !targetBBox.intersects(envelope)) { - geometry = null; - skip = true; - // ... if the geometry is awfully small avoid reading it (unless it's a point) - } else if (simplificationDistance > 0 && envelope.getWidth() < simplificationDistance - && envelope.getHeight() < simplificationDistance) { - try { - if (screenMap != null && screenMap.checkAndSet(envelope)) { - ... [truncated message content] |
|
From: <svn...@os...> - 2011-11-20 17:48:28
|
Author: aaime
Date: 2011-11-20 09:48:20 -0800 (Sun, 20 Nov 2011)
New Revision: 38366
Modified:
trunk/modules/library/data/src/main/java/org/geotools/data/directory/DirectoryDataStore.java
Log:
Have directory data store work with both shapefile stores
Modified: trunk/modules/library/data/src/main/java/org/geotools/data/directory/DirectoryDataStore.java
===================================================================
--- trunk/modules/library/data/src/main/java/org/geotools/data/directory/DirectoryDataStore.java 2011-11-20 17:48:07 UTC (rev 38365)
+++ trunk/modules/library/data/src/main/java/org/geotools/data/directory/DirectoryDataStore.java 2011-11-20 17:48:20 UTC (rev 38366)
@@ -18,14 +18,19 @@
import java.io.File;
import java.io.IOException;
+import java.io.Serializable;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.geotools.data.DataStore;
+import org.geotools.data.DataStoreFinder;
+import org.geotools.data.DataUtilities;
import org.geotools.data.DefaultServiceInfo;
import org.geotools.data.FeatureReader;
import org.geotools.data.FeatureStore;
@@ -116,18 +121,23 @@
public void createSchema(SimpleFeatureType featureType) throws IOException {
File f = new File(cache.directory, featureType.getTypeName()+".shp");
- String shpDataStoreClassName = "org.geotools.data.shapefile.ShapefileDataStore";
+ Map<String, Serializable> params = new HashMap<String, Serializable>();
+ params.put("url", DataUtilities.fileToURL(f));
+ params.put("filetype", "shapefile");
DataStore ds = null;
try {
- ds = (DataStore) Class.forName(shpDataStoreClassName).getConstructor(URL.class)
- .newInstance(f.toURL());
- ds.createSchema(featureType);
- ds.dispose();
- cache.refreshCacheContents();
- }
- catch(Exception e) {
+ ds = DataStoreFinder.getDataStore(params);
+ if(ds != null) {
+ ds.createSchema(featureType);
+ ds.dispose();
+ cache.refreshCacheContents();
+ }
+ } catch(Exception e) {
throw (IOException) new IOException("Error creating new data store").initCause(e);
}
+ if(ds == null) {
+ throw new IOException("Could not find the shapefile data store in the classpath");
+ }
}
public void dispose() {
|
Author: aaime
Date: 2011-11-20 09:48:07 -0800 (Sun, 20 Nov 2011)
New Revision: 38365
Added:
trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileQuadTreeReadWriteTest.java
Removed:
trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ShapefileQuadTreeReadWriteTest.java
Modified:
trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureStore.java
trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureWriter.java
Log:
Fix writer appending
Modified: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureStore.java
===================================================================
--- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureStore.java 2011-11-20 17:47:38 UTC (rev 38364)
+++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureStore.java 2011-11-20 17:48:07 UTC (rev 38365)
@@ -52,9 +52,24 @@
@Override
protected FeatureWriter<SimpleFeatureType, SimpleFeature> getWriterInternal(Query query,
int flags) throws IOException {
+ if (flags == 0) {
+ throw new IllegalArgumentException("no write flags set");
+ }
+
ShapefileFeatureReader reader = (ShapefileFeatureReader) delegate.getReaderInternal(query);
- return new ShapefileFeatureWriter(delegate.shpFiles, reader, getDataStore().getCharset(),
- getDataStore().getTimeZone());
+ ShapefileFeatureWriter writer = new ShapefileFeatureWriter(delegate.shpFiles, reader,
+ getDataStore().getCharset(), getDataStore().getTimeZone());
+
+ // if we only have to add move to the end.
+ // TODO: just make the code transfer the bytes in bulk instead and start actual writing at
+ // the end
+ if ((flags | WRITER_ADD) == WRITER_ADD) {
+ while (writer.hasNext()) {
+ writer.next();
+ }
+ }
+
+ return writer;
}
// ----------------------------------------------------------------------------------------
Modified: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureWriter.java
===================================================================
--- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureWriter.java 2011-11-20 17:47:38 UTC (rev 38364)
+++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileFeatureWriter.java 2011-11-20 17:48:07 UTC (rev 38365)
@@ -109,6 +109,8 @@
private GeometryFactory gf = new GeometryFactory();
+ private boolean guessShapeType;
+
public ShapefileFeatureWriter(ShpFiles shpFiles, ShapefileFeatureReader featureReader,
Charset charset, TimeZone timezone) throws IOException {
this.shpFiles = shpFiles;
@@ -151,6 +153,7 @@
// don't try to read a shx file we're writing to in parallel
featureReader.disableShxUsage();
+ guessShapeType = !featureReader.hasNext();
shapeType = featureReader.getShapeType();
handler = shapeType.getShapeHandler(new GeometryFactory());
shpWriter.writeHeaders(bounds, shapeType, records, shapefileLength);
@@ -226,7 +229,6 @@
// additional tail-end file flushing to do if the Writer was closed
// before the end of the file
if (featureReader != null) {
- shapeType = featureReader.shp.getHeader().getShapeType();
handler = shapeType.getShapeHandler(gf);
// handle the case where zero records have been written, but the
@@ -343,7 +345,7 @@
Geometry g = (Geometry) currentFeature.getDefaultGeometry();
// if this is the first Geometry, find the shapeType and handler
- if (shapeType == null) {
+ if (guessShapeType) {
try {
if (g != null) {
int dims = JTSUtilities.guessCoorinateDims(g.getCoordinates());
@@ -356,6 +358,7 @@
// we must go back and annotate this after writing
shpWriter.writeHeaders(new Envelope(), shapeType, 0, 0);
handler = shapeType.getShapeHandler(gf);
+ guessShapeType = false;
} catch (ShapefileException se) {
throw new RuntimeException("Unexpected Error", se);
}
Deleted: trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ShapefileQuadTreeReadWriteTest.java
===================================================================
--- trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ShapefileQuadTreeReadWriteTest.java 2011-11-20 17:47:38 UTC (rev 38364)
+++ trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ShapefileQuadTreeReadWriteTest.java 2011-11-20 17:48:07 UTC (rev 38365)
@@ -1,268 +0,0 @@
-/*
- * GeoTools - The Open Source Java GIS Toolkit
- * http://geotools.org
- *
- * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- */
-package org.geotools.data.shapefile;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.AssertionFailedError;
-
-import org.geotools.TestData;
-import org.geotools.data.DataStore;
-import org.geotools.data.DefaultQuery;
-import org.geotools.data.Query;
-import org.geotools.data.shapefile.ng.ShapefileDataStore;
-import org.geotools.data.shapefile.ng.ShapefileDataStoreFactory;
-import org.geotools.data.shapefile.ng.TestCaseSupport;
-import org.geotools.data.shapefile.ng.index.CloseableIterator;
-import org.geotools.data.shapefile.ng.index.Data;
-import org.geotools.data.simple.SimpleFeatureCollection;
-import org.geotools.data.simple.SimpleFeatureIterator;
-import org.geotools.data.simple.SimpleFeatureSource;
-import org.geotools.data.simple.SimpleFeatureStore;
-import org.geotools.factory.CommonFactoryFinder;
-import org.geotools.factory.GeoTools;
-import org.geotools.geometry.jts.ReferencedEnvelope;
-import org.opengis.feature.simple.SimpleFeature;
-import org.opengis.feature.simple.SimpleFeatureType;
-import org.opengis.filter.FilterFactory2;
-import org.opengis.filter.Id;
-import org.opengis.filter.identity.FeatureId;
-
-import com.vividsolutions.jts.geom.Envelope;
-import com.vividsolutions.jts.geom.Geometry;
-
-/**
- *
- *
- * @source $URL$
- * @version $Id$
- * @author Ian Schneider
- */
-public class ShapefileQuadTreeReadWriteTest extends TestCaseSupport {
- final String[] files = { "shapes/statepop.shp", "shapes/polygontest.shp",
- "shapes/pointtest.shp", "shapes/holeTouchEdge.shp", "shapes/stream.shp" };
-
- boolean readStarted = false;
-
- Exception exception = null;
-
- /**
- * Creates a new instance of ShapefileReadWriteTest
- */
- public ShapefileQuadTreeReadWriteTest(String name) throws IOException {
- super(name);
- }
-
- public void testAll() throws Throwable {
- for (int i = 0, ii = files.length; i < ii; i++) {
- test(files[i]);
- }
-
- }
-
- public void fail(String message, Throwable cause) throws Throwable {
- Throwable fail = new AssertionFailedError(message);
- fail.initCause(cause);
- throw fail;
- }
-
- public void testReadOutside() throws Exception {
- File f = copyShapefiles("shapes/statepop.shp");
- ShapefileDataStoreFactory fac = new ShapefileDataStoreFactory();
- ShapefileDataStore ds = (ShapefileDataStore) createDataStore(fac, f.toURI().toURL(), true);
- Query q = new Query(ds.getTypeNames()[0]);
- FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
- q.setFilter(ff.bbox("the_geom", -62, -61, 23, 22, null));
- assertEquals(0, ds.getFeatureSource().getFeatures(q).size());
- ds.dispose();
- }
-
- public void testWriteTwice() throws Exception {
- copyShapefiles("shapes/stream.shp");
- ShapefileDataStoreFactory fac = new ShapefileDataStoreFactory();
- DataStore s1 = createDataStore(fac,
- TestData.url(TestCaseSupport.class, "shapes/stream.shp"), true);
- String typeName = s1.getTypeNames()[0];
- SimpleFeatureSource source = s1.getFeatureSource(typeName);
- SimpleFeatureType type = source.getSchema();
- SimpleFeatureCollection
-
- ShapefileDataStoreFactory maker = new ShapefileDataStoreFactory();
-
- doubleWrite(type, one, getTempFile(), maker, false);
- doubleWrite(type, one, getTempFile(), maker, true);
- s1.dispose();
- }
-
- private DataStore createDataStore(ShapefileDataStoreFactory fac, URL url, boolean memoryMapped)
- throws IOException {
- Map params = new HashMap();
- params.put(ShapefileDataStoreFactory.URLP.key, url);
- params.put(ShapefileDataStoreFactory.CREATE_SPATIAL_INDEX.key, new Boolean(true));
- DataStore createDataStore = fac.createDataStore(params);
- return createDataStore;
- }
-
- private void doubleWrite(SimpleFeatureType type, SimpleFeatureCollection one, File tmp,
- ShapefileDataStoreFactory maker, boolean memorymapped) throws IOException,
- MalformedURLException {
- DataStore s;
- s = createDataStore(maker, tmp.toURI().toURL(), memorymapped);
-
- s.createSchema(type);
- SimpleFeatureStore store = (SimpleFeatureStore) s.getFeatureSource(s.getTypeNames()[0]);
-
- assertEquals(0, store.getCount(Query.ALL));
- store.addFeatures(one);
- assertEquals(one.size(), store.getCount(Query.ALL));
- store.addFeatures(one);
-
- assertEquals(one.size() * 2, store.getCount(Query.ALL));
- s.dispose();
- }
-
- void test(String f) throws Exception {
- File file = copyShapefiles(f); // Work on File rather than URL from
- // JAR.
- DataStore s = createDataStore(new ShapefileDataStoreFactory(), file.toURI().toURL(), true);
- String typeName = s.getTypeNames()[0];
- SimpleFeatureSource source = s.getFeatureSource(typeName);
- SimpleFeatureType type = source.getSchema();
- SimpleFeatureCollection
-
- ShapefileDataStoreFactory maker = new ShapefileDataStoreFactory();
- test(type, one, getTempFile(), maker, false);
- test(type, one, getTempFile(), maker, true);
- s.dispose();
- }
-
- private void test(SimpleFeatureType type, SimpleFeatureCollection one, File tmp,
- ShapefileDataStoreFactory maker, boolean memorymapped) throws IOException,
- MalformedURLException, Exception {
- DataStore s;
- String typeName;
- s = createDataStore(maker, tmp.toURI().toURL(), memorymapped);
-
- s.createSchema(type);
-
- SimpleFeatureStore store = (SimpleFeatureStore) s.getFeatureSource(s.getTypeNames()[0]);
-
- store.addFeatures(one);
- s.dispose();
-
- s = createDataStore(new ShapefileDataStoreFactory(), tmp.toURI().toURL(), true);
- typeName = s.getTypeNames()[0];
-
- SimpleFeatureCollection two = s.getFeatureSource(typeName).getFeatures();
-
- compare(one.features(), two.features());
- s.dispose();
- }
-
- static void compare(SimpleFeatureIterator fs1, SimpleFeatureIterator fs2) throws Exception {
- try {
- while (fs1.hasNext()) {
- SimpleFeature f1 = fs1.next();
- SimpleFeature f2 = fs2.next();
-
- compare(f1, f2);
- }
-
- } finally {
- fs1.close();
- fs2.close();
- }
- }
-
- static void compare(SimpleFeature f1, SimpleFeature f2) throws Exception {
- if (f1.getAttributeCount() != f2.getAttributeCount()) {
- throw new Exception("Unequal number of attributes");
- }
-
- for (int i = 0; i < f1.getAttributeCount(); i++) {
- Object att1 = f1.getAttribute(i);
- Object att2 = f2.getAttribute(i);
-
- if (att1 instanceof Geometry && att2 instanceof Geometry) {
- Geometry g1 = ((Geometry) att1);
- Geometry g2 = ((Geometry) att2);
- g1.normalize();
- g2.normalize();
-
- if (!g1.equalsExact(g2)) {
- throw new Exception("Different geometries (" + i + "):\n" + g1 + "\n" + g2);
- }
- } else {
- if (!att1.equals(att2)) {
- throw new Exception("Different attribute (" + i + "): [" + att1 + "] - ["
- + att2 + "]");
- }
- }
- }
- }
-
- /**
- * Test optimized getBounds(). Testing when filter is a bbox filter and a fidfilter
- *
- * @throws Exception
- */
- public void testGetBoundsQuery() throws Exception {
- File file = copyShapefiles("shapes/streams.shp");
-
- ShapefileDataStoreFactory fac = new ShapefileDataStoreFactory();
-
- Map params = new HashMap();
- params.put(ShapefileDataStoreFactory.URLP.key, file.toURI().toURL());
- params.put(ShapefileDataStoreFactory.CREATE_SPATIAL_INDEX.key, new Boolean(true));
- ShapefileDataStore ds = (ShapefileDataStore) fac.createDataStore(params);
-
- FilterFactory2 ff = (FilterFactory2) CommonFactoryFinder.getFilterFactory(GeoTools
- .getDefaultHints());
-
- FeatureId featureId = ff.featureId("streams.84");
- Id filter = ff.id(Collections.singleton(featureId));
- SimpleFeatureCollection features = ds.getFeatureSource().getFeatures(filter);
-
- SimpleFeatureIterator iter = features.features();
- ReferencedEnvelope bounds;
- try {
- bounds = new ReferencedEnvelope(iter.next().getBounds());
- } finally {
- iter.close();
- }
-
- FeatureId id = featureId;
- filter = ff.id(Collections.singleton(id));
-
- Query query = new DefaultQuery(ds.getTypeNames()[0], filter);
-
- Envelope result = ds.getFeatureSource().getBounds(query);
-
- assertTrue(result.equals(bounds));
- ds.dispose();
- }
-
- public static final void main(String[] args) throws Exception {
- junit.textui.TestRunner.run(suite(ShapefileQuadTreeReadWriteTest.class));
- }
-}
Copied: trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileQuadTreeReadWriteTest.java (from rev 38364, trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ShapefileQuadTreeReadWriteTest.java)
===================================================================
--- trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileQuadTreeReadWriteTest.java (rev 0)
+++ trunk/modules/unsupported/shapefile-ng/src/test/java/org/geotools/data/shapefile/ng/ShapefileQuadTreeReadWriteTest.java 2011-11-20 17:48:07 UTC (rev 38365)
@@ -0,0 +1,267 @@
+/*
+ * GeoTools - The Open Source Java GIS Toolkit
+ * http://geotools.org
+ *
+ * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ */
+package org.geotools.data.shapefile.ng;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.AssertionFailedError;
+
+import org.geotools.TestData;
+import org.geotools.data.DataStore;
+import org.geotools.data.DefaultQuery;
+import org.geotools.data.Query;
+import org.geotools.data.shapefile.ng.ShapefileDataStore;
+import org.geotools.data.shapefile.ng.ShapefileDataStoreFactory;
+import org.geotools.data.shapefile.ng.index.CloseableIterator;
+import org.geotools.data.shapefile.ng.index.Data;
+import org.geotools.data.simple.SimpleFeatureCollection;
+import org.geotools.data.simple.SimpleFeatureIterator;
+import org.geotools.data.simple.SimpleFeatureSource;
+import org.geotools.data.simple.SimpleFeatureStore;
+import org.geotools.factory.CommonFactoryFinder;
+import org.geotools.factory.GeoTools;
+import org.geotools.geometry.jts.ReferencedEnvelope;
+import org.opengis.feature.simple.SimpleFeature;
+import org.opengis.feature.simple.SimpleFeatureType;
+import org.opengis.filter.FilterFactory2;
+import org.opengis.filter.Id;
+import org.opengis.filter.identity.FeatureId;
+
+import com.vividsolutions.jts.geom.Envelope;
+import com.vividsolutions.jts.geom.Geometry;
+
+/**
+ *
+ *
+ * @source $URL$
+ * @version $Id$
+ * @author Ian Schneider
+ */
+public class ShapefileQuadTreeReadWriteTest extends TestCaseSupport {
+ final String[] files = { "shapes/statepop.shp", "shapes/polygontest.shp",
+ "shapes/pointtest.shp", "shapes/holeTouchEdge.shp", "shapes/stream.shp" };
+
+ boolean readStarted = false;
+
+ Exception exception = null;
+
+ /**
+ * Creates a new instance of ShapefileReadWriteTest
+ */
+ public ShapefileQuadTreeReadWriteTest(String name) throws IOException {
+ super(name);
+ }
+
+ public void testAll() throws Throwable {
+ for (int i = 0, ii = files.length; i < ii; i++) {
+ test(files[i]);
+ }
+
+ }
+
+ public void fail(String message, Throwable cause) throws Throwable {
+ Throwable fail = new AssertionFailedError(message);
+ fail.initCause(cause);
+ throw fail;
+ }
+
+ public void testReadOutside() throws Exception {
+ File f = copyShapefiles("shapes/statepop.shp");
+ ShapefileDataStoreFactory fac = new ShapefileDataStoreFactory();
+ ShapefileDataStore ds = (ShapefileDataStore) createDataStore(fac, f.toURI().toURL(), true);
+ Query q = new Query(ds.getTypeNames()[0]);
+ FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
+ q.setFilter(ff.bbox("the_geom", -62, -61, 23, 22, null));
+ assertEquals(0, ds.getFeatureSource().getFeatures(q).size());
+ ds.dispose();
+ }
+
+ public void testWriteTwice() throws Exception {
+ copyShapefiles("shapes/stream.shp");
+ ShapefileDataStoreFactory fac = new ShapefileDataStoreFactory();
+ DataStore s1 = createDataStore(fac,
+ TestData.url(TestCaseSupport.class, "shapes/stream.shp"), true);
+ String typeName = s1.getTypeNames()[0];
+ SimpleFeatureSource source = s1.getFeatureSource(typeName);
+ SimpleFeatureType type = source.getSchema();
+ SimpleFeatureCollection
+
+ ShapefileDataStoreFactory maker = new ShapefileDataStoreFactory();
+
+ doubleWrite(type, one, getTempFile(), maker, false);
+ doubleWrite(type, one, getTempFile(), maker, true);
+ s1.dispose();
+ }
+
+ private DataStore createDataStore(ShapefileDataStoreFactory fac, URL url, boolean memoryMapped)
+ throws IOException {
+ Map params = new HashMap();
+ params.put(ShapefileDataStoreFactory.URLP.key, url);
+ params.put(ShapefileDataStoreFactory.CREATE_SPATIAL_INDEX.key, new Boolean(true));
+ DataStore createDataStore = fac.createDataStore(params);
+ return createDataStore;
+ }
+
+ private void doubleWrite(SimpleFeatureType type, SimpleFeatureCollection one, File tmp,
+ ShapefileDataStoreFactory maker, boolean memorymapped) throws IOException,
+ MalformedURLException {
+ DataStore s;
+ s = createDataStore(maker, tmp.toURI().toURL(), memorymapped);
+
+ s.createSchema(type);
+ SimpleFeatureStore store = (SimpleFeatureStore) s.getFeatureSource(s.getTypeNames()[0]);
+
+ assertEquals(0, store.getCount(Query.ALL));
+ store.addFeatures(one);
+ assertEquals(one.size(), store.getCount(Query.ALL));
+ store.addFeatures(one);
+
+ assertEquals(one.size() * 2, store.getCount(Query.ALL));
+ s.dispose();
+ }
+
+ void test(String f) throws Exception {
+ File file = copyShapefiles(f); // Work on File rather than URL from
+ // JAR.
+ DataStore s = createDataStore(new ShapefileDataStoreFactory(), file.toURI().toURL(), true);
+ String typeName = s.getTypeNames()[0];
+ SimpleFeatureSource source = s.getFeatureSource(typeName);
+ SimpleFeatureType type = source.getSchema();
+ SimpleFeatureCollection
+
+ ShapefileDataStoreFactory maker = new ShapefileDataStoreFactory();
+ test(type, one, getTempFile(), maker, false);
+ test(type, one, getTempFile(), maker, true);
+ s.dispose();
+ }
+
+ private void test(SimpleFeatureType type, SimpleFeatureCollection one, File tmp,
+ ShapefileDataStoreFactory maker, boolean memorymapped) throws IOException,
+ MalformedURLException, Exception {
+ DataStore s;
+ String typeName;
+ s = createDataStore(maker, tmp.toURI().toURL(), memorymapped);
+
+ s.createSchema(type);
+
+ SimpleFeatureStore store = (SimpleFeatureStore) s.getFeatureSource(s.getTypeNames()[0]);
+
+ store.addFeatures(one);
+ s.dispose();
+
+ s = createDataStore(new ShapefileDataStoreFactory(), tmp.toURI().toURL(), true);
+ typeName = s.getTypeNames()[0];
+
+ SimpleFeatureCollection two = s.getFeatureSource(typeName).getFeatures();
+
+ compare(one.features(), two.features());
+ s.dispose();
+ }
+
+ static void compare(SimpleFeatureIterator fs1, SimpleFeatureIterator fs2) throws Exception {
+ try {
+ while (fs1.hasNext()) {
+ SimpleFeature f1 = fs1.next();
+ SimpleFeature f2 = fs2.next();
+
+ compare(f1, f2);
+ }
+
+ } finally {
+ fs1.close();
+ fs2.close();
+ }
+ }
+
+ static void compare(SimpleFeature f1, SimpleFeature f2) throws Exception {
+ if (f1.getAttributeCount() != f2.getAttributeCount()) {
+ throw new Exception("Unequal number of attributes");
+ }
+
+ for (int i = 0; i < f1.getAttributeCount(); i++) {
+ Object att1 = f1.getAttribute(i);
+ Object att2 = f2.getAttribute(i);
+
+ if (att1 instanceof Geometry && att2 instanceof Geometry) {
+ Geometry g1 = ((Geometry) att1);
+ Geometry g2 = ((Geometry) att2);
+ g1.normalize();
+ g2.normalize();
+
+ if (!g1.equalsExact(g2)) {
+ throw new Exception("Different geometries (" + i + "):\n" + g1 + "\n" + g2);
+ }
+ } else {
+ if (!att1.equals(att2)) {
+ throw new Exception("Different attribute (" + i + "): [" + att1 + "] - ["
+ + att2 + "]");
+ }
+ }
+ }
+ }
+
+ /**
+ * Test optimized getBounds(). Testing when filter is a bbox filter and a fidfilter
+ *
+ * @throws Exception
+ */
+ public void testGetBoundsQuery() throws Exception {
+ File file = copyShapefiles("shapes/streams.shp");
+
+ ShapefileDataStoreFactory fac = new ShapefileDataStoreFactory();
+
+ Map params = new HashMap();
+ params.put(ShapefileDataStoreFactory.URLP.key, file.toURI().toURL());
+ params.put(ShapefileDataStoreFactory.CREATE_SPATIAL_INDEX.key, new Boolean(true));
+ ShapefileDataStore ds = (ShapefileDataStore) fac.createDataStore(params);
+
+ FilterFactory2 ff = (FilterFactory2) CommonFactoryFinder.getFilterFactory(GeoTools
+ .getDefaultHints());
+
+ FeatureId featureId = ff.featureId("streams.84");
+ Id filter = ff.id(Collections.singleton(featureId));
+ SimpleFeatureCollection features = ds.getFeatureSource().getFeatures(filter);
+
+ SimpleFeatureIterator iter = features.features();
+ ReferencedEnvelope bounds;
+ try {
+ bounds = new ReferencedEnvelope(iter.next().getBounds());
+ } finally {
+ iter.close();
+ }
+
+ FeatureId id = featureId;
+ filter = ff.id(Collections.singleton(id));
+
+ Query query = new DefaultQuery(ds.getTypeNames()[0], filter);
+
+ Envelope result = ds.getFeatureSource().getBounds(query);
+
+ assertTrue(result == null || result.equals(bounds));
+ ds.dispose();
+ }
+
+ public static final void main(String[] args) throws Exception {
+ junit.textui.TestRunner.run(suite(ShapefileQuadTreeReadWriteTest.class));
+ }
+}
|
|
From: <svn...@os...> - 2011-11-20 17:47:45
|
Author: aaime
Date: 2011-11-20 09:47:38 -0800 (Sun, 20 Nov 2011)
New Revision: 38364
Modified:
trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileDataStore.java
Log:
Adding dispose and dispose tracking
Modified: trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileDataStore.java
===================================================================
--- trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileDataStore.java 2011-11-20 03:19:04 UTC (rev 38363)
+++ trunk/modules/unsupported/shapefile-ng/src/main/java/org/geotools/data/shapefile/ng/ShapefileDataStore.java 2011-11-20 17:47:38 UTC (rev 38364)
@@ -13,6 +13,7 @@
import java.util.Collections;
import java.util.List;
import java.util.TimeZone;
+import java.util.logging.Level;
import org.geotools.data.DataSourceException;
import org.geotools.data.FeatureReader;
@@ -56,6 +57,17 @@
public static final Charset DEFAULT_STRING_CHARSET = (Charset) ShapefileDataStoreFactory.DBFCHARSET.getDefaultValue();
public static final TimeZone DEFAULT_TIMEZONE = (TimeZone) ShapefileDataStoreFactory.DBFTIMEZONE.getDefaultValue();
+
+ /**
+ * When true, the stack trace that got a lock that wasn't released is recorded and then
+ * printed out when warning the user about this.
+ */
+ protected static final Boolean TRACE_ENABLED = "true".equalsIgnoreCase(System.getProperty("gt2.shapefile.trace"));
+
+ /**
+ * The stack trace used to track code that grabs the data store without disposing it
+ */
+ Exception trace;
ShpFiles shpFiles;
@@ -71,6 +83,10 @@
public ShapefileDataStore(URL url) {
shpFiles = new ShpFiles(url);
+ if(TRACE_ENABLED) {
+ trace = new Exception();
+ trace.fillInStackTrace();
+ }
}
@Override
@@ -335,5 +351,24 @@
storageFile.replaceOriginal();
entries.clear();
}
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ if(shpFiles != null) {
+ shpFiles.dispose();
+ shpFiles = null;
+ }
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ super.finalize();
+ if(shpFiles != null && trace != null) {
+ LOGGER.log(Level.SEVERE, "Undisposed of shapefile, you should call dispose() on all shapefile stores", trace);
+ }
+ dispose();
+ }
+
}
|
|
From: <svn...@os...> - 2011-11-20 03:19:12
|
Author: jive
Date: 2011-11-19 19:19:04 -0800 (Sat, 19 Nov 2011)
New Revision: 38363
Modified:
trunk/docs/developer/procedures/release.rst
Log:
update release instructions to downplay the roll of the wiki
Modified: trunk/docs/developer/procedures/release.rst
===================================================================
--- trunk/docs/developer/procedures/release.rst 2011-11-19 23:24:19 UTC (rev 38362)
+++ trunk/docs/developer/procedures/release.rst 2011-11-20 03:19:04 UTC (rev 38363)
@@ -553,14 +553,12 @@
zip -9 -r ../../../target/geotools-2.7-M1-doc.zip apidocs/
cd ../../..
-6. The javadoc plugin usage and configuration is explained in more details there.
-
7. Generate sphinx documentation::
cd docs
mvn install
cd target/user
- zip -9 -r ../../../target/geotools-2.6.5-userguide.zip html/
+ zip -9 -r ../../../target/geotools-8.0-RC1-userguide.zip html/
Test the src release
^^^^^^^^^^^^^^^^^^^^
@@ -579,20 +577,11 @@
mvn install
-Export out the User Guide from the wiki
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-1. Login to confluence and visit the user guide: http://docs.codehaus.org/display/GEOTDOC/Home
-2. go to the Browse Space > Advanced
-3. Choose Export Space
-4. Select HTML and don't include the comments
-5. It will take a few moments for the zip file to be ready
-6. Rename this zip to gt-2.6-M4-guide.zip for later upload
-
Update JIRA and create a changelog
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-Any unresolved issues that did not make the release version need to be bumped back to the next release. Fortunately, JIRA allows you to do this en masse:
+Any unresolved issues that did not make the release version need to be bumped back to the next
+release. Fortunately, JIRA allows you to do this en masse:
1. Login to Jira and head to the administration screen for the GeoTools project
2. Click on manage versions
@@ -602,7 +591,7 @@
* it will ask you where you want to move unresolved issues
select the next release number you created above.
- In this example 2.6-M5
+ In this example 8.0-RC1
5. This will update the changelog file to show what has been fixed since the last release.
@@ -638,97 +627,81 @@
2. As the last sanity check email the geotools list and ask people to try it out.
-Update the Downloads Page
-^^^^^^^^^^^^^^^^^^^^^^^^^
+Anounce on GeoTools Blog
+^^^^^^^^^^^^^^^^^^^^^^^^
-1. Navigate to the Downloads Page; and choose the download page for the version you are releasing
-2. Press Add Child Page
-3. Enter in the title of the release (it is important to use '.' and '-' correctly for the sorting order)
+1. Navigate to the GeoTools blog; and sign in: http://geotoolsnews.blogspot.com/
+2. Create a new blog post anouncing your release; you can cut and paste the following as a starting
+ point::
- ======= ==================================================================================
- 2.7-M4 Milestone release - adding a planned feature from a RnD branch
- 2.7-RC2 Release candidate - feature complete, waiting on fixes, docs and QA checks
- 2.7.0 Major release - formal release we API committed to supporting
- 2.2.1 Patch release - remember that support? this is an examples of fixes
- ======= ==================================================================================
+ The GeoTools community is pleased to announce the availability of GeoTools 8.0-M3 for <a
+ href="https://sourceforge.net/projects/geotools/files/GeoTools%208.0%20Releases/8.0-M3/">download
+ from source forge</a>:
+ <ul>
+ <li><a href="http://sourceforge.net/projects/geotools/files/GeoTools%208.0%20Releases/8.0-M3/geotools-8.0-M3-bin.zip/download">geotools-8.0-M3-bin.zip</a></li>
+ <li><a href="http://sourceforge.net/projects/geotools/files/GeoTools%208.0%20Releases/8.0-M3/geotools-8.0-M3-doc.zip/download">geotools-8.0-M3-doc.zip</a></li>
+ <li><a href="http://sourceforge.net/projects/geotools/files/GeoTools%208.0%20Releases/8.0-M3/geotools-8.0-M3-userguide.zip/download">geotools-2.7.3-userguide.zip</a></li>
+ <li><a href="http://sourceforge.net/projects/geotools/files/GeoTools%208.0%20Releases/8.0-M3/geotools-8.0-M3-project.zip/download">geotools-8.0-M3-project.zip/download</a></li>
+ </ul>
+ If you are using Maven this release is deployed to our OSGeo Maven Repository: For more information on setting up your project with Maven
+ see the <a href="http://docs.geotools.org/latest/userguide/tutorial/quickstart/index.html">Quickstart</a> (included
+ in the userguide documentation pack above).
+ <br/>
+ <br/>
+ This is a milestone release made in conjunction with the (OPTIONAL LINK TO PRODUCT, CONFERENCE).
+ <br/>
+ <br/>BLURB ABOUT RELEASE CONTENTS<br/>
+ <ul>
+ <li>THANKS LINKING TO ANY BLOG POSTS, DOCS OR JIRA</li>
+ <li>THANKS LINKING TO ANY BLOG POSTS, DOCS OR JIRA</li>
+ <li></li>
+ <li>And XX more
+ in the <a href="https://jira.codehaus.org/secure/ReleaseNote.jspa?projectId=10270&version=17864">GeoTools
+ 8.0-M3 Release Notes</a></li>
+ </ul>
+ Finally thanks to YOU and ORGANISATION for putting this release out.
+
+ <br/>Enjoy,
+ <br/>The GeoTools Community
+ <br/><a href="http://geotools.org/">http://geotools.org</a>
-4. Press the 'select a template page' link and choose Geotools Release from the list
-5. Press next to view the generated page
6. You will need to correct the following information:
- * Update the date (between the excerpt macros).
* Update the Source forge links above to reflect the release by following this link
- * Update the Release Notes by choosing the the correct version from this link.
- * Fill in a blurb about the release
- * List any completed proposals or interesting new features provided by the release
-
+ * Update the Release Notes by choosing the the correct version from `JIRA <https://jira.codehaus.org/browse/GEOT#selectedTab=com.atlassian.jira.plugin.system.project:changelog-panel&allVersions=false>`_
+ * Fill in the BLURB ABOUT RELEASE CONTENTS
+ * Thank those involved with the relese (listing any completed proposals, docs or jira items)
+
Tell the World
^^^^^^^^^^^^^^
After the list has had a chance to try things out - make an announcement.
-Here is an example; we try to include download links to the release artifacts, the release notes
-and documentation associated with the release.::
-
- The GeoTools 2.6-M4 release is now available for download:
-
- geotools-2.6-M4-bin.zip
- geotools-2.6-M4-project.zip
- geotools-2.6-M4-doc.zip
- geotools-2.6-M4-welcome.zip
- geotools-2.6-M4-guide.zip
-
- This is a bug fix release made in conjunction with uDig 1.2-RC3.
-
- This release adds support for Oracle Georaster access as the result of a productive
- collaboration between Christian and Baskar. It is great to see developers from different
- organisations combine forces.
-
- There are many small but interesting improvements in the release notes. I am exited by the
- new interpolate functions which will be very useful when styling maps, generated SLD files
- no longer write out "default" values which will make for a more readable result.
-
- For more information please review the Release Notes:
-
- http://jira.codehaus.org/secure/ConfigureReleaseNote.jspa?projectId=10270&version=16316
-
- http://geotools.org
- http://docs.codehaus.org/display/GEOTOOLS/2.6.x
- http://docs.codehaus.org/display/GEOTOOLS/Upgrade+to+2.6
-
- Enjoy,
- The GeoTools Community
+Cut and paste from the blog post to the following:
1. geo...@li...
* To: geo...@li...
- * Subject: 2.6-M4 Released
+ * Subject: 8.0-RC1 Released
-2. http://geotoolsnews.blogspot.com/
+2. geo...@li...
- Sign in and make a new blog post.
-
- * News Title: GeoTools 2.6-M4 released
- * Content: allows wiki links
-
-3. geo...@li...
-
Let the user list know:
* To: geo...@li...
- * Subject: GeoTools 2.6-M4 Released
+ * Subject: GeoTools 8.0-RC1 Released
-4. Open Source Geospatial Foundation
+3. Open Source Geospatial Foundation
Only to be used for "significant" releases (Major release only, not for milestone
or point releases)
https://www.osgeo.org/content/news/submit_news.html
-5. Post a message to the osgeo news email list (you are subscribed right?)
+4. Post a message to the osgeo news email list (you are subscribed right?)
* To: new...@os...
- * Subject: GeoTools 2.6-M4 Released
+ * Subject: GeoTools 8.0-RC1 Released
Tell More of the World!
^^^^^^^^^^^^^^^^^^^^^^^
@@ -783,7 +756,7 @@
Submit a news article
- * Use form at: http://slashgisrs.org/submit.pl (gotta login!)
+ * Use form at: http://slashgeo.org/ (gotta login!)
* Use your profile page (example: http://docs.codehaus.org/display/~jive) for Home page
* Section: Technology Topic: Open Source Community
* Warning: You may wish to change to HTML Formatted, and insert a few links in!
|
Author: jive Date: 2011-11-19 15:24:19 -0800 (Sat, 19 Nov 2011) New Revision: 38362 Modified: trunk/docs/developer/communication.rst trunk/docs/developer/conventions/code/assumptions.rst trunk/docs/developer/conventions/code/javadocutils.rst trunk/docs/developer/conventions/code/style.rst trunk/docs/developer/procedures/proposal.rst trunk/docs/user/advanced/build/install/jdk.rst trunk/docs/user/advanced/build/install/mvn.rst trunk/docs/user/advanced/integration.rst trunk/docs/user/extension/graph/index.rst trunk/docs/user/extension/wms/wms.rst trunk/docs/user/library/api/datastore.rst trunk/docs/user/library/api/envelope.rst trunk/docs/user/library/api/sld.rst trunk/docs/user/library/coverage/grid.rst trunk/docs/user/library/coverage/image.rst trunk/docs/user/library/data/pregeneralized.rst trunk/docs/user/library/jts/geometry.rst trunk/docs/user/library/main/repository.rst trunk/docs/user/library/opengis/filter.rst trunk/docs/user/library/referencing/crs.rst trunk/docs/user/library/referencing/extension.rst trunk/docs/user/library/referencing/faq.rst trunk/docs/user/library/referencing/h2.rst trunk/docs/user/library/referencing/hsql.rst trunk/docs/user/library/referencing/transform.rst trunk/docs/user/library/referencing/wkt.rst trunk/docs/user/library/render/gtrenderer.rst trunk/docs/user/library/render/style.rst trunk/docs/user/library/xml/geometry.rst trunk/docs/user/library/xml/style.rst trunk/docs/user/tutorial/advanced/abstractdatastore.rst trunk/docs/user/tutorial/feature/csv2shp.rst trunk/docs/user/tutorial/index.rst trunk/docs/user/tutorial/map/style.rst trunk/docs/user/unsupported/geometry/build.rst trunk/docs/user/unsupported/index.rst trunk/docs/user/unsupported/jts-wrapper.rst trunk/docs/user/unsupported/swt/rcp.rst trunk/docs/user/unsupported/wps.rst trunk/docs/user/welcome/eclipse.rst trunk/docs/user/welcome/upgrade.rst Log: simply explained GEOT-3954 Modified: trunk/docs/developer/communication.rst =================================================================== --- trunk/docs/developer/communication.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/developer/communication.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -69,8 +69,9 @@ GeoTools developers use an IRC channel for real time collaboration (for situations where email is too slow) - this is also a suitable venue for questions. -If you are new to IRC, you will need to find an IRC client. The later versions of Netscape and -Mozilla have IRC built in, and you can connect to a GeoTools meeting simply by using the URL: +If you are new to IRC, you will need to find an IRC client. If you have configured your browser +to support IRC (Firefox can use the Chatzilla plugin for example), and you can connect to a +GeoTools meeting by clicking on the following URL: irc://irc.freenode.net/geotools. The information you need to configure your IRC client are: Modified: trunk/docs/developer/conventions/code/assumptions.rst =================================================================== --- trunk/docs/developer/conventions/code/assumptions.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/developer/conventions/code/assumptions.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -37,7 +37,8 @@ map.put(NO_DATA, value); value = map.get(NO_DATA); -Note this static constant can still be used for generating human readable messages; it is simply used as a key to look up the appropriate translation. +Note this static constant can still be used for generating human readable messages; it is +used as a key to look up the appropriate translation. Use AffineTransform mathematic ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Modified: trunk/docs/developer/conventions/code/javadocutils.rst =================================================================== --- trunk/docs/developer/conventions/code/javadocutils.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/developer/conventions/code/javadocutils.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -55,7 +55,7 @@ ``--fix`` The utility will attempt to fix any existing tags that have been incorrectly split across two - lines by auto-formatting. The default is to simply report files with such tags. + lines by auto-formatting. The default is to report files with such tags. ``--svn`` The tag content will be enclosed in svn keyword delimiters ``$URL`` and ``$`` to be used for Modified: trunk/docs/developer/conventions/code/style.rst =================================================================== --- trunk/docs/developer/conventions/code/style.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/developer/conventions/code/style.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -98,7 +98,7 @@ * Example of Reusing Code under another license - The simple rule of thumb here is to not modify the initial header at all; and simply + The simple rule of thumb here is to not modify the initial header at all; and stick the geotools header on top. * :download:`DateUtil.java </../../modules/library/main/src/main/java/org/geotools/feature/type/DateUtil.java>` Modified: trunk/docs/developer/procedures/proposal.rst =================================================================== --- trunk/docs/developer/procedures/proposal.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/developer/procedures/proposal.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -192,9 +192,13 @@ Documentation ------------- -You will need to update all test cases and demo code to use the new API; since our test cases are often used by those learning the library this is especially important (also leaving deprecated code in the test cases simply assures us of a broken build one release cycle later when the plug is pulled). +You will need to update all test cases and demo code to use the new API; since our test cases are +often used by those learning the library this is especially important (also leaving deprecated code +in the test cases assures us of a broken build one release cycle later when the plug is pulled). -The User Guide, and User Manual are often the target of documentation updates. The developers guide tries to stick to library architecture and only needs updating if you are changing the scope and/or focus of one of the core modules. +The User Guide, and User Manual are often the target of documentation updates. The developers guide +tries to stick to library architecture and only needs updating if you are changing the scope and/or +focus of one of the core modules. Release ------- Modified: trunk/docs/user/advanced/build/install/jdk.rst =================================================================== --- trunk/docs/user/advanced/build/install/jdk.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/advanced/build/install/jdk.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -38,22 +38,25 @@ Why JAVA_HOME does not work on Windows '''''''''''''''''''''''''''''''''''''' -How to Build using Java 5 and run using Java 6 on windows. +How to use different versions of Java for building and running on windows. -Several projects expect to make use of a JRE 6 runtime environment (simply for the speed benefit). If your computer is set up with both a JDK 1.5 for building GeoTools; and a JDK 6 for your other projects you will need to sort out how to switch between them. +Several projects expect to make use of the latest JRE runtime environment +(for speed or new features). If your computer is set up with both a stable JDK for buildin +GeoTools; and an experimental JDK for your other projects you will need to sort out how +to switch between them. One technique is to set up a batch file similar to the following: 1. Hunt down the cmd.exe ( Start menu > Accessories > Command Prompt) and right click to send it to the desktop 2. Edit the desktop cmd.exe short cut and change the target to:: - %SystemRoot%\system32\cmd.exe /k C:\java\java15.bat + %SystemRoot%\system32\cmd.exe /k C:\java\java6.bat -3. Create the C:\java\java15.bat file mentioned above:: +3. Create the C:\java\java6.bat file mentioned above:: set ANT_HOME=C:\java\apache-ant-1.6.5 set M2_HOME=C:\java\maven-2.0.9 - set JAVA_HOME=C:\Program Files\Java\jdk1.5.0_19 + set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_29 set PATH=%JAVA_HOME%\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Subversion\bin;%M2_HOME%\bin;%ANT_HOME%\bin Modified: trunk/docs/user/advanced/build/install/mvn.rst =================================================================== --- trunk/docs/user/advanced/build/install/mvn.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/advanced/build/install/mvn.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -1,8 +1,8 @@ Maven Install ------------- -We use Maven for our build environment, this page simply set's it up for you. Actual build -instructions will happen later. +We use Maven for our build environment, this page describes the development environment and +configuration. Actual build instructions will happen later. Reference: Modified: trunk/docs/user/advanced/integration.rst =================================================================== --- trunk/docs/user/advanced/integration.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/advanced/integration.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -124,7 +124,7 @@ Single Plugin ''''''''''''' -The udig project uses this technique as a stopgap solution, simply placing all the GeoTools jars +The udig project uses this technique as a stopgap solution: place all the GeoTools jars into a single plugin will allow the Factory SPI system to function. The Eclipse environment uses OSGi to manage the loading and unloading of "bundles" of resources, @@ -147,11 +147,19 @@ One Bundle per Jar '''''''''''''''''' -In most cases, OSGi bundles are delivered as JAR files. The only difference between an OSGi bundle and a plain old JAR file is a number of special headers in the manifest required by the OSGi standard. Given a plain old JAR, you can simply wrap it in a bundle by creating an OSGi compliant manifest, putting your JAR on the Bundle-Classpath and creating a bundle JAR containing your new manifest and the plain old JAR. +In most cases, OSGi bundles are delivered as JAR files. The only difference between an OSGi bundle +and a plain old JAR file is a number of special headers in the manifest required by the OSGi +standard. Given a plain old JAR, you can wrap it in a bundle by creating an OSGi compliant +manifest, putting your JAR on the Bundle-Classpath and creating a bundle JAR containing your +new manifest and the plain old JAR. -However, this is not recommended, since a JAR-in-a-JAR means extra work for the classloader to retrieve classes from the inner JAR. To make a plain old JAR OSGi-compliant, you can simply unzip the JAR, add the required OSGi headers to the manifest and then rezip the whole lot. +However, this is not recommended, since a JAR-in-a-JAR means extra work for the classloader +to retrieve classes from the inner JAR. To make a plain old JAR OSGi-compliant, you can unzip +the JAR, add the required OSGi headers to the manifest and then rezip the whole lot. -After rebundling, any resources from the plain old JAR are now first-class citizens of the bundle JAR. This includes any files in META-INF/services, and this is in fact the first step to make the Factory SPI system work. +After rebundling, any resources from the plain old JAR are now first-class citizens of the bundle +JAR. This includes any files in META-INF/services, and this is in fact the first step to make the +Factory SPI system work. .. note:: @@ -218,21 +226,33 @@ work in an OSGi environment in a way that is backward compatible, i.e. you can still use your bundle JARs as plain old JARs on the classpath. -If at some point in future Geotools should decide to go the OSGi way (and allow itself to become dependent on OSGi), the Factory SPI approach should be dropped in favour of the OSGi service registry. Service providers would simply register their services under the class name of the implemented interface. Clients would use the OSGi service registry to look up the available services for an interface, possibly using additional parameters to select a specific implementation. +If at some point in future Geotools should decide to go the OSGi way (and allow itself to become +dependent on OSGi), the Factory SPI approach should be dropped in favour of the OSGi service +registry. Service providers would register their services under the class name of the implemented +interface. Clients would use the OSGi service registry to look up the available services for an +interface, possibly using additional parameters to select a specific implementation. Third-Party Dependencies '''''''''''''''''''''''' -In either approach, all-in-one or bundle-per-JAR, you also have to deal with external dependencies of Geotools, like vecmath, jdom, geoapi, and many others. +In either approach, all-in-one or bundle-per-JAR, you also have to deal with external dependencies +of Geotools, like vecmath, jdom, geoapi, and many others. -You could further blow up your all-in-one bundle by also including the JARs for these external dependencies. Chances are high that some of these are also used by other non-Geotools bundles in your application, so this is likely to cause classloader problems, say if you already have a jdom bundle in your system. +You could further blow up your all-in-one bundle by also including the JARs for these external +dependencies. Chances are high that some of these are also used by other non-Geotools bundles in +your application, so this is likely to cause classloader problems, say if you already have a JDOM +bundle in your system. -Thus, you should really follow the bundle-per-JAR approach and OSGify each third-party dependency into a separate bundle. Actually, there is no need to do all the work on your own: The SpringSource Enterprise Bundle Repository provides OSGified versions of many popular Java libraries. +Thus, you should really follow the bundle-per-JAR approach and OSGify each third-party dependency +into a separate bundle. Actually, there is no need to do all the work on your own: The SpringSource +Enterprise Bundle Repository provides OSGified versions of many popular Java libraries. Eclipse-BuddyPolicy: ext '''''''''''''''''''''''' -The GeoTools library makes use of Java Advanced Imaging - which is a Java extension. Just as OSGi is very careful about dependencies between bundles; it is also careful to ensure you do not accidentally depend on a Java extension that may not be present. +The GeoTools library makes use of Java Advanced Imaging - which is a Java extension. Just as OSGi +is very careful about dependencies between bundles; it is also careful to ensure you do not +accidentally depend on a Java extension that may not be present. A normal application works like this: Modified: trunk/docs/user/extension/graph/index.rst =================================================================== --- trunk/docs/user/extension/graph/index.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/extension/graph/index.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -52,7 +52,8 @@ **Graph** -The core graph data structure is simply a collection of nodes and edges, a range of methods are available allowing access using visitors. +The core graph data structure is a collection of nodes and edges, a range of methods are available +allowing access using visitors. **Node** @@ -112,7 +113,7 @@ * **GraphWalker**: walker being iterated over the graph (usually to accomplish a specific goal) GeoTools provides out of the box implementations for many common problems: finding the the - shortest path, partition a graph into sections, or simply visiting all the elements. + shortest path, partition a graph into sections, or visiting all the elements. Directed Graph ^^^^^^^^^^^^^^ Modified: trunk/docs/user/extension/wms/wms.rst =================================================================== --- trunk/docs/user/extension/wms/wms.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/extension/wms/wms.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -5,8 +5,7 @@ This page contains examples how how to connect and use the GeoTools WebMapServer class. WebMapServer acts as a proxy for a remote "Web Map Server" and can be used to examine and retrieve published information in the forms of descriptive java beans, and raw images. -* To begin communicating with a server, simply pass in a URL pointing to - a WMS Capabilities document. +* To begin communicating with a server, pass in a URL pointing to a WMS Capabilities document. Constructing a WebMapServer object:: Modified: trunk/docs/user/library/api/datastore.rst =================================================================== --- trunk/docs/user/library/api/datastore.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/library/api/datastore.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -450,8 +450,8 @@ they can be processed into a DataStore. Note the DataStore may still not work (if for example the username and password were incorrect). - This method simply confirms the required information - is available. + + This method confirms the required information is available. * DataAccessFactory.isAvailable() Modified: trunk/docs/user/library/api/envelope.rst =================================================================== --- trunk/docs/user/library/api/envelope.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/library/api/envelope.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -51,9 +51,14 @@ :start-after: // transformReferencedEnvelope start :end-before: // transformReferencedEnvelope end -**ReferencedEnvelope** is used in a lot of GeoTools interfaces, basically anywhere we can get away with it. Simply put without knowing the the CoordinateReferenceSystem a raw JTS Envelope is incomplete; and difficult to use safely without making assumptions. +**ReferencedEnvelope** is used in a lot of GeoTools interfaces, basically anywhere we can get away +with it. Using a raw JTS Envelope without knowing the the CoordinateReferenceSystem is difficult to +use as the information is incomplete forcing client code to make assumptions. Some code assumes +the envelope is in WGS84 while other code assumes it is in the same Coordinate Reference System as +the data being worked on. -Some of our older interfaces that you are forced to read the javadocs in order to figure out the CoordinateReferenceSystem for a returned Envelope. +Some of our older interfaces that you are forced to read the javadocs in order to figure out the +CoordinateReferenceSystem for a returned Envelope. * Using a FeatureSource without ReferencedEnvelope example:: Modified: trunk/docs/user/library/api/sld.rst =================================================================== --- trunk/docs/user/library/api/sld.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/library/api/sld.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -79,7 +79,7 @@ * TextSymbolizer.getPriority() Priority used to determine precedence when labels collisions occur during rendering. The label with the highest priority - "wins" with the others being moved out of the way (within a tolerance) or simply not displayed. + "wins" with the others being moved out of the way (within a tolerance) or just not displayed. * TextSymbolizer.getOption(String) Modified: trunk/docs/user/library/coverage/grid.rst =================================================================== --- trunk/docs/user/library/coverage/grid.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/library/coverage/grid.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -101,9 +101,13 @@ Operations ^^^^^^^^^^ -The Operations class provides a default instance with a series of methods to perform operations on a grid coverage. We use the static instance Operations.DEFAULT which acts merely as a convenience wrapper around the DefaultProcessor.doOperation(..) method and provides type safety and a simpler argument list. +The Operations class provides a default instance with a series of methods to perform operations on +a grid coverage. We use the static instance Operations.DEFAULT which acts merely as a convenience +wrapper around the DefaultProcessor.doOperation(..) method and provides type safety and a simpler +argument list. -For all the methods which return Coverages, when using the GeoTools implementation we can simply cast them to the GridCoverage2D. +When using GeoTools implementations of operations; for any methods which return a Coverage we can +safely cast them to a GridCoverage2D. resample '''''''' Modified: trunk/docs/user/library/coverage/image.rst =================================================================== --- trunk/docs/user/library/coverage/image.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/library/coverage/image.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -3,7 +3,7 @@ The image module in the plugin group provides access to the 'world plus image' file formats. -This is the quickest way to get a GIF or JEPG onto a map display - simply add a small text +This is the quickest way to get a GIF or JEPG onto a map display - add a small text file along side the image defining the image's extend and use this plugin. **References** Modified: trunk/docs/user/library/data/pregeneralized.rst =================================================================== --- trunk/docs/user/library/data/pregeneralized.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/library/data/pregeneralized.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -1,9 +1,12 @@ Pregeneralized Plugin --------------------- -This plugin offers the the possibility to use pregeneralized features to reduce cpu and memory usage at runtime. The effect for the client is simply a better response time. +This plugin offers the the possibility to use pregeneralized features to reduce cpu and memory +usage at runtime. The effect is used to improve the response time for client code. -This is an advanced plugin that is great for eking the greatest performance out of the GeoTools rendering system. This plugin allows you to smoothly switch between data at different levels of simplification when rendering at different levels. +This is an advanced plugin that is great for eking the greatest performance out of the GeoTools +rendering system. This plugin allows you to smoothly switch between data at different levels of +simplification when rendering at different levels. Consider it something like an image pyramid for raster data operating at different zoom levels. Modified: trunk/docs/user/library/jts/geometry.rst =================================================================== --- trunk/docs/user/library/jts/geometry.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/library/jts/geometry.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -96,7 +96,8 @@ return shapeFactory.createCircle(); } -Even though "GeometricShapeFactory" is provided out of the box from JTS; there is nothing fancy about the code. It simply creates a series of coordinates in a circle. +Even though "GeometricShapeFactory" is provided out of the box from JTS; there is nothing fancy +about the code. It creates a series of coordinates in a circle. Another approach is to create a curve or shape object with one of Java's handy Shape classes and then extract the coordinates from that object to create your geometry. Modified: trunk/docs/user/library/main/repository.rst =================================================================== --- trunk/docs/user/library/main/repository.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/library/main/repository.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -19,7 +19,8 @@ An alternative approach for applications using more than one or a few DataStores, is to create a map structure with 'singleton' code to both ensure this singleton access to the data and easily grab the right DataStore when it is needed. The Map relates some identifier for the data store (the ID) with the DataStore class accessing that resource. URLs are often used for the ID. -This second approach is so common that GeoTools developed the **Repository** interface along with two implementations to handle this situation. +This second approach is so common that GeoTools developed the **Repository** interface along with +two implementations to handle this situation. A more sophisticated approach "Catalog" approached is used by GeoServer and uDig in order to track large numbers of data sources (and lazily create DataStores as needed). @@ -27,7 +28,8 @@ Singleton ^^^^^^^^^ -A simple application may simply track its use of DataStores on its own. Ideally, it will create a singleton structure around each DataStore to ensure that it only accesses the DataStore once.:: +A simple application may track its use of DataStores on its own. Ideally, it will create a +singleton structure around each DataStore to ensure that it only accesses the DataStore once.:: class MyApp { public static DataStore store; Modified: trunk/docs/user/library/opengis/filter.rst =================================================================== --- trunk/docs/user/library/opengis/filter.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/library/opengis/filter.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -362,7 +362,7 @@ .. image:: /images/filter_id.PNG -The most common test is simply against FeatureId: +The most common test is against FeatureId: .. literalinclude:: /../src/main/java/org/geotools/opengis/FilterExamples.java :language: java Modified: trunk/docs/user/library/referencing/crs.rst =================================================================== --- trunk/docs/user/library/referencing/crs.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/library/referencing/crs.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -9,9 +9,11 @@ *Before you Start* -The most conservative way to deal with the definition of a **CoordinateReferenceSystem** is not to. Instead make use of an authority that provides complete definitions defined by a simple code. +The most conservative way to deal with the definition of a **CoordinateReferenceSystem** is not +to. Instead make use of an authority that provides complete definitions defined by a simple code. -To hook this up simply make sure you have one of the **gt-epsg** plugins on your CLASSPATH. The **gt-epsg-hsql** plugin is recommended. +To hook this up make sure you have one of the **gt-epsg** plugins on your CLASSPATH. The +**gt-epsg-hsql** plugin is recommended. Defining a CoordinateReferenceSystem ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +26,8 @@ The example above assumes you have **gt-epsg-hsql** jar on your CLASSPATH. -Depending on the jars you have on your CLASSPATH a range of authorities are available to define a coordinate reference system for you. +Depending on the jars you have on your CLASSPATH a range of authorities are available to define a +coordinate reference system for you. Using the "OGC URN" syntax:: Modified: trunk/docs/user/library/referencing/extension.rst =================================================================== --- trunk/docs/user/library/referencing/extension.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/library/referencing/extension.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -6,7 +6,7 @@ This plugin is compatible with a restricted environment and does not require disk access. -The Plugin will work out of the box, simply drop it on your path. +The Plugin will work out of the box, inlcude it in your CLASSPATH path. **References** Modified: trunk/docs/user/library/referencing/faq.rst =================================================================== --- trunk/docs/user/library/referencing/faq.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/library/referencing/faq.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -264,7 +264,7 @@ with any of the other gt-epsg-h2, or gt-epsg-hsql plugins as they will end up in conflict. -If you simply want to add a few more definitions over and above those provided by the +If you want to add a few more definitions over and above those provided by the official database (ie epsg-hsql or epsg-h2) please use the following (taken from the uDig application):: Modified: trunk/docs/user/library/referencing/h2.rst =================================================================== --- trunk/docs/user/library/referencing/h2.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/library/referencing/h2.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -3,6 +3,6 @@ This plugin works out of the box (as a pure java database with its own copy of the EPSG database included). -To use simply place the gt-epsg-h2 jar on your CLASSPATH. +To use place the gt-epsg-h2 jar on your CLASSPATH. Although this plugin is not supported, it is a drop in replacement for the gt-epsg-hsql plugin and is well suited if you are already using h2 and do not want a second pure java database dependency in your application. \ No newline at end of file Modified: trunk/docs/user/library/referencing/hsql.rst =================================================================== --- trunk/docs/user/library/referencing/hsql.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/library/referencing/hsql.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -5,7 +5,7 @@ The plugin includes it's own copy of the EPSG database that has been converted from the original Microsoft Access. -To use this plugin simply include it on your CLASSPATH. +To use this plugin include it on your CLASSPATH. Database Creation ^^^^^^^^^^^^^^^^^ Modified: trunk/docs/user/library/referencing/transform.rst =================================================================== --- trunk/docs/user/library/referencing/transform.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/library/referencing/transform.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -174,8 +174,8 @@ Notes about projections in ESRI's ArcGIS 8.x -* The "Mercator_1SP" and "Mercator_2SP" are simply called the "Mercator" in ArcGIS. The distinction between the 1 and 2 standard parallel cases is determined based on the "standard_parallel_1" parameter. -* "Lambert_Conformal_Conic_1SP" and "Lambert_Conformal_Conic_2SP" are simply called the "Lambert_Conformal_Conic". The distinction is based on the values of the "standard_parallel_1" and "standard_parallel_2" parameters. Note that the "Lambert_Conformal_Conic" will NOT use the "latitude_of_origin" as the standard_parallel in the 1 SP case: you must also specify a "standard_parallel_1" parameter. +* The "Mercator_1SP" and "Mercator_2SP" are called the "Mercator" in ArcGIS. The distinction between the 1 and 2 standard parallel cases is determined based on the "standard_parallel_1" parameter. +* "Lambert_Conformal_Conic_1SP" and "Lambert_Conformal_Conic_2SP" are called the "Lambert_Conformal_Conic". The distinction is based on the values of the "standard_parallel_1" and "standard_parallel_2" parameters. Note that the "Lambert_Conformal_Conic" will NOT use the "latitude_of_origin" as the standard_parallel in the 1 SP case: you must also specify a "standard_parallel_1" parameter. * The "Albers_Conic_Equal_Area" is called the "Albers" in ArcGIS. Other Math Transform Parameters Modified: trunk/docs/user/library/referencing/wkt.rst =================================================================== --- trunk/docs/user/library/referencing/wkt.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/library/referencing/wkt.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -12,9 +12,10 @@ EPSG Definitions '''''''''''''''' -The range of represented EPSG codes is not complete, it is limited by the projections supported by GeoTools, and allowances have been made to go with the axis order used by WMS 1.1.1. +The range of represented EPSG codes is not complete, it is limited by the projections supported by +GeoTools, and allowances have been made to go with the axis order used by WMS 1.1.1. -The Plugin will work out of the box, simply drop it on your path. +The Plugin will work out of the box, include it in your CLASSPATH. Beyond EPSG Database '''''''''''''''''''' Modified: trunk/docs/user/library/render/gtrenderer.rst =================================================================== --- trunk/docs/user/library/render/gtrenderer.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/library/render/gtrenderer.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -18,9 +18,12 @@ draw.paint(g2d, outputArea, map.getLayerBounds() ); -If you have completed the Quickstart, this is the approach used by the JMapPane class we use in a lot of our tutorials. +If you have completed the Quickstart, this is the approach used by the JMapPane class we use in a +lot of our tutorials. -The important part of the above example is that GTRenderer works on the Java2D class **Graphics2D**. You can find many implementations of Graphics2D allowing GeoTools to work with a range of graphics systems beyond simply the screen. +The important part of the above example is that GTRenderer works on the Java2D class +**Graphics2D**. You can find many implementations of Graphics2D allowing GeoTools to work with a +range of graphics systems beyond the screen. Swing ^^^^^ Modified: trunk/docs/user/library/render/style.rst =================================================================== --- trunk/docs/user/library/render/style.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/library/render/style.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -497,7 +497,7 @@ The generic StyleVisitor interface is everything you would expect from the Gang of Four Visitor pattern, it has a visit methods one for each significant interface in a Style object. -To use a StyleVisitor simply pass it to a style (or any style object):: +To use a StyleVisitor pass it to a Style (or any style object) using the accepts method:: style.accepts( styleVisitor ); Modified: trunk/docs/user/library/xml/geometry.rst =================================================================== --- trunk/docs/user/library/xml/geometry.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/library/xml/geometry.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -47,7 +47,7 @@ encode.setBaseURL(new URL("http://localhost/")); encode.encode(out, TYPE); -This does simply write out an XSD file for the FeatureType and can be combined with the WFS 1.0 XSD file when writing feature collections. +This writes out an XSD file for the FeatureType and can be combined with the WFS 1.0 XSD file when writing feature collections. FeatureCollection ''''''''''''''''' @@ -208,7 +208,7 @@ GML gml = new GML(Version.WFS1_0); SimpleFeatureCollection featureCollection = gml.decodeFeatureCollection(in); -Or for a more responsive user experience (or simply to work with large content) you can parse one feature at a time:: +Or for a more responsive user experience (or to work with large content) you can parse one feature at a time:: URL url = TestData.getResource(this,"states.xml"); InputStream in = url.openStream(); Modified: trunk/docs/user/library/xml/style.rst =================================================================== --- trunk/docs/user/library/xml/style.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/library/xml/style.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -107,7 +107,7 @@ SLDParser stylereader = new SLDParser(styleFactory, inputStream ); StyledLayerDescriptor sld = stylereader.parseSLD(); -Or you can skip all of that and simply extract the defined Style objects:: +Or you can skip all of that and extract the defined Style objects as an array:: SLDParser stylereader = new SLDParser( styleFactory, url); Style styles[] = stylereader.readXML(); Modified: trunk/docs/user/tutorial/advanced/abstractdatastore.rst =================================================================== --- trunk/docs/user/tutorial/advanced/abstractdatastore.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/tutorial/advanced/abstractdatastore.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -742,7 +742,7 @@ :start-after: // createNewDataStore start :end-before: // createNewDataStore end - No surprises here; the code simply creates a directory for PropertyDataStore to work in. + No surprises here; the code creates a directory for PropertyDataStore to work in. PropertyDataStore ^^^^^^^^^^^^^^^^^ @@ -866,7 +866,7 @@ :start-after: // remove start :end-before: // remove end - To implement remove, we simply won't write out the original Feature. + To implement remove, we will skip over the origional feature (and just won't write it out). Most of the method is devoted to gathering up the information needed to issue a feature removed event. @@ -879,7 +879,7 @@ To implement close() we must remember to write out any remaining features in the DataStore before closing our new file. To implement this we have performed a small optimization: we - simply echo the line acquired by the PropertyFeatureReader. + echo the line acquired by the PropertyFeatureReader. The last thing our FeatureWriter must do is replace the existing File with our new one. @@ -910,7 +910,7 @@ JDBC ResultSets or random access file may use hasNext() to indicate that they are streaming over existing result set. - Our implementation of next() will simply start a newLine for the feature that is about to be written. + Our implementation of next() will start a newLine for the feature that is about to be written. 3. Add writeFeatureID(): @@ -1028,7 +1028,7 @@ This is shown after t1 commit, where transaction t2 is seeing 4 features (ie the current file contents plus the one feature that has been added on t2). - * This really shows that FeatureSource and FeatureStore are simply "views" into your data. + * This really shows that FeatureSource and FeatureStore are "views" into your data. * If you configure two FeatureStores with the same transaction they will act the same. * Transaction is important and represents what you are working on @@ -1289,7 +1289,7 @@ * PropertyDatastore.getFeatureSource( typeName ); -By default the implementations returned are based simply on FeatureReader and FeatureWriter. +By default the implementations returned are based on FeatureReader and FeatureWriter. Override this method to return your own subclasses that are tuned for your data format. FeatureStore Optimisation Modified: trunk/docs/user/tutorial/feature/csv2shp.rst =================================================================== --- trunk/docs/user/tutorial/feature/csv2shp.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/tutorial/feature/csv2shp.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -255,7 +255,7 @@ You can also draw ideas like urban growth or predicted rain fall. -A feature is quite simply something that can be drawn on a map. The strict definition is that a +A feature is something that can be drawn on a map. The strict definition is that a feature is something in the real world – a feature of the landscape - Mt Everest, the Eiffel Tower, or even something that moves around like your great aunt Alice. @@ -319,7 +319,7 @@ SimpleFeature. At the Java level the Feature API provided by GeoTools is similar to how java.util.Map is used – it -is simply a data structure used to hold information. You can look up attribute values by key; and +is a Java data structure used to hold information. You can look up attribute values by key; and the list of keys is provided by the FeatureType. Geometry Modified: trunk/docs/user/tutorial/index.rst =================================================================== --- trunk/docs/user/tutorial/index.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/tutorial/index.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -6,13 +6,12 @@ Welcome to the GeoTools tutorial material. These workbooks are provided as part of an introduction to GIS workshop making use of examples from GeoTools and other Java libraries. -.. sidebar:: OSDC +.. sidebar:: Geospatial for Java - Have you signed up for the `Open Source Developers Conference 2011 <http://osdc.com.au/>`_ Canberra and - the `GeoTools Mini Conference <http://osdc.com.au/miniconfs/#geotools>`_? + If you are working through these tutorials as part of workshop please check with your + instructor. Many of the download materials should be available on a DVD in order to save + time. - This course will be run on *November 14* and we hope to see you there! - .. toctree:: :maxdepth: 1 Modified: trunk/docs/user/tutorial/map/style.rst =================================================================== --- trunk/docs/user/tutorial/map/style.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/tutorial/map/style.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -225,7 +225,7 @@ --------------------------------------- Once the method above has worked out which features were selected, if any, it passes their FeatureIds to the -**displaySelected** method. This simply calls one of two Style creating methods and then redisplays the map with the +**displaySelected** method. This calls one of two Style creating methods and then redisplays the map with the updated Style: .. literalinclude:: /../src/main/java/org/geotools/tutorial/style/SelectionLab.java Modified: trunk/docs/user/unsupported/geometry/build.rst =================================================================== --- trunk/docs/user/unsupported/geometry/build.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/unsupported/geometry/build.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -91,7 +91,7 @@ PrimitiveFactory primF = cont.getComponentInstanceOfType( PrimitiveFactory.class ); GeometryFactory geomF = cont.getComponentInstanceOfType( GeometryFactory.class ); -Here we simply asked the container to give us the factories of the different types we would need. +Here we asked the container to give us the factories of the different types we would need. Creating a Point ^^^^^^^^^^^^^^^^ Modified: trunk/docs/user/unsupported/index.rst =================================================================== --- trunk/docs/user/unsupported/index.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/unsupported/index.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -92,7 +92,7 @@ GeoTools community taking care, fixing bugs and providing documentation. In some cases these modules are the work of students, in others a commercial company that donated the code (but in both cases more resources are needed to make the module usable and trustworthy). - In the past we simply threw out such work - we are trying a change of policy here by letting you see what can be done + In the past we threw out such work - we are trying a change of policy here by letting you see what can be done (and has been done). If you really do need one of these modules cleaned up, perhaps for a deadline, please check out our support page - a Modified: trunk/docs/user/unsupported/jts-wrapper.rst =================================================================== --- trunk/docs/user/unsupported/jts-wrapper.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/unsupported/jts-wrapper.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -29,7 +29,8 @@ Using JTS Wrapper ----------------- -The JTS Wrapper is a pure plugin and does not define any additional API. Simply place it on your CLASSPATH and the GeoTools GeometryFactory will be able to pick up this implementation and use it. +The JTS Wrapper is a pure plugin and does not define any additional API. Place it on your +CLASSPATH and the GeoTools GeometryFactory will be able to pick up this implementation and use it. It is recommended to use a GeometryBuilder in order to set up a group of factories to work together:: Modified: trunk/docs/user/unsupported/swt/rcp.rst =================================================================== --- trunk/docs/user/unsupported/swt/rcp.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/unsupported/swt/rcp.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -20,7 +20,7 @@ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The source of the rcp application has been bundeled together with all the needed geotools libs and -uploaded here. Simply import the project into eclipse and you are ready to go. +uploaded here. From here import the project into eclipse and you are ready to go. * http://jgrasstools.googlecode.com/files/rcp-gt-swt.tar.gz Modified: trunk/docs/user/unsupported/wps.rst =================================================================== --- trunk/docs/user/unsupported/wps.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/unsupported/wps.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -30,7 +30,7 @@ The main object of the design is the WebProcessingService class. WebProcessingService acts as a proxy for a remote WPS Server and can be used to examine and retrieve information from the server, - and to execute processes the server provides. To begin communicating with a server, simply pass + and to execute processes the server provides. To begin communicating with a server, pass in a URL pointing to a WPS Capabilities document (view examples below). * WPSFactory Modified: trunk/docs/user/welcome/eclipse.rst =================================================================== --- trunk/docs/user/welcome/eclipse.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/welcome/eclipse.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -3,7 +3,7 @@ Eclipse is a popular integrated development environment for Java development. Since GeoTools is a Java library we would really like it to work out of the box for you. -Our Eclipse Quickstart provides an excellent introduction to setting up eclipse for use with GeoTools covering the M2Eclipse project, command line maven or simply downloading GeoTools and using the jars in a project. +Our Eclipse Quickstart provides an excellent introduction to setting up eclipse for use with GeoTools covering the M2Eclipse project, command line maven or downloading GeoTools and using the jars in a project. Making Associations with the SRC download ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Modified: trunk/docs/user/welcome/upgrade.rst =================================================================== --- trunk/docs/user/welcome/upgrade.rst 2011-11-19 14:08:32 UTC (rev 38361) +++ trunk/docs/user/welcome/upgrade.rst 2011-11-19 23:24:19 UTC (rev 38362) @@ -178,7 +178,7 @@ The changes from GeoTools 2.6 to GeoTools 2.7 focus on making your code more readible; you will find a number of optional changes (such as using Query rather than DefaultQuery) which will -simply make your code easier to follow. +simplify make your code easier to follow. Query |
Author: aaime
Date: 2011-11-19 06:08:32 -0800 (Sat, 19 Nov 2011)
New Revision: 38361
Modified:
trunk/modules/library/main/src/main/java/org/geotools/styling/SLDParser.java
trunk/modules/library/main/src/main/java/org/geotools/styling/SLDTransformer.java
trunk/modules/library/main/src/main/java/org/geotools/styling/visitor/DuplicatingStyleVisitor.java
trunk/modules/library/main/src/test/java/org/geotools/styling/SLDTransformerTest.java
trunk/modules/library/main/src/test/java/org/geotools/styling/visitor/DuplicatorStyleVisitorTest.java
Log:
[GEOT-3912] PerpendicularOffset for LineSymbolizer unsupported, encoding/decoding patches provided by Stefan Tzeggai
Modified: trunk/modules/library/main/src/main/java/org/geotools/styling/SLDParser.java
===================================================================
--- trunk/modules/library/main/src/main/java/org/geotools/styling/SLDParser.java 2011-11-19 13:39:18 UTC (rev 38360)
+++ trunk/modules/library/main/src/main/java/org/geotools/styling/SLDParser.java 2011-11-19 14:08:32 UTC (rev 38361)
@@ -96,10 +96,13 @@
private static final String VendorOptionString = "VendorOption";
+ private static final String PerpendicularOffsetString = "PerpendicularOffset";
+
private static final Pattern WHITESPACES = Pattern.compile("\\s+", Pattern.MULTILINE);
private static final Pattern LEADING_WHITESPACES = Pattern.compile("^\\s+");
private static final Pattern TRAILING_WHITESPACES = Pattern.compile("\\s+$");
+
private FilterFactory ff;
// protected java.io.InputStream instream;
@@ -944,6 +947,9 @@
symbol.setStroke(parseStroke(child));
} else if (childName.equalsIgnoreCase(VendorOptionString)) {
parseVendorOption(symbol, child);
+ } else if (childName.equalsIgnoreCase(PerpendicularOffsetString)) {
+ final String offsetValue = getFirstChildValue(child);
+ symbol.setPerpendicularOffset((ff.literal(Double.parseDouble(offsetValue))));
}
}
Modified: trunk/modules/library/main/src/main/java/org/geotools/styling/SLDTransformer.java
===================================================================
--- trunk/modules/library/main/src/main/java/org/geotools/styling/SLDTransformer.java 2011-11-19 13:39:18 UTC (rev 38360)
+++ trunk/modules/library/main/src/main/java/org/geotools/styling/SLDTransformer.java 2011-11-19 14:08:32 UTC (rev 38361)
@@ -620,6 +620,10 @@
if (line.getOptions() != null) {
encodeVendorOptions(line.getOptions());
}
+ if (line.getPerpendicularOffset()!=null){
+ element("PerpendicularOffset",
+ line.getPerpendicularOffset() + "");
+ }
end("LineSymbolizer");
}
Modified: trunk/modules/library/main/src/main/java/org/geotools/styling/visitor/DuplicatingStyleVisitor.java
===================================================================
--- trunk/modules/library/main/src/main/java/org/geotools/styling/visitor/DuplicatingStyleVisitor.java 2011-11-19 13:39:18 UTC (rev 38360)
+++ trunk/modules/library/main/src/main/java/org/geotools/styling/visitor/DuplicatingStyleVisitor.java 2011-11-19 14:08:32 UTC (rev 38361)
@@ -677,6 +677,7 @@
copy.setUnitOfMeasure(line.getUnitOfMeasure());
copy.setStroke( copy( line.getStroke()));
copy.getOptions().putAll(line.getOptions());
+ copy.setPerpendicularOffset(line.getPerpendicularOffset());
if( STRICT && !copy.equals( line )){
throw new IllegalStateException("Was unable to duplicate provided LineSymbolizer:"+line );
Modified: trunk/modules/library/main/src/test/java/org/geotools/styling/SLDTransformerTest.java
===================================================================
--- trunk/modules/library/main/src/test/java/org/geotools/styling/SLDTransformerTest.java 2011-11-19 13:39:18 UTC (rev 38360)
+++ trunk/modules/library/main/src/test/java/org/geotools/styling/SLDTransformerTest.java 2011-11-19 14:08:32 UTC (rev 38361)
@@ -967,4 +967,34 @@
.getOtherText().getText());
}
+
+ /**
+ * Test that perpendicularOffset for LineSymbolizer is correctly exported and reimported
+ *
+ * @throws TransformerException
+ * @throws SAXException
+ * @throws IOException
+ * @throws XpathException
+ */
+ @Test
+ public void testLineSymbolizerWithPerpendicularOffset() throws TransformerException, SAXException, IOException, XpathException {
+ StyleBuilder sb = new StyleBuilder();
+ LineSymbolizer ls = sb.createLineSymbolizer();
+ ls.setPerpendicularOffset(ff.literal(0.77));
+
+ //check XML
+ Document doc = buildTestDocument(transformer.transform(ls));
+ assertXpathEvaluatesTo("1", "count(/sld:LineSymbolizer/sld:PerpendicularOffset)", doc);
+
+ // Transform, reimport and compare
+ String xml = transformer.transform(sb.createStyle(ls));
+
+ SLDParser sldParser = new SLDParser(sf);
+ sldParser.setInput(new StringReader(xml));
+ Style importedStyle = (Style) sldParser.readXML()[0];
+ LineSymbolizer copy = (LineSymbolizer) importedStyle.featureTypeStyles().get(0).rules().get(0).symbolizers().get(0);
+
+ // compare
+ assertEquals("Perpendicular offset of LineSymbolizer has not been correctly ex- and reimported",ls.getPerpendicularOffset(),copy.getPerpendicularOffset());
+ }
}
Modified: trunk/modules/library/main/src/test/java/org/geotools/styling/visitor/DuplicatorStyleVisitorTest.java
===================================================================
--- trunk/modules/library/main/src/test/java/org/geotools/styling/visitor/DuplicatorStyleVisitorTest.java 2011-11-19 13:39:18 UTC (rev 38360)
+++ trunk/modules/library/main/src/test/java/org/geotools/styling/visitor/DuplicatorStyleVisitorTest.java 2011-11-19 14:08:32 UTC (rev 38361)
@@ -776,4 +776,18 @@
assertEquals("OtherText of TextSymbolizer2 has not been correctly duplicated", otherText.getText(), copy
.getOtherText().getText());
}
+
+ /*
+ * Tests that perpendicularOffset for LineSymbolizer is duplicated correctly
+ */
+ public void testLineSymbolizerWithPerpendicularOffset(){
+ LineSymbolizer ls = sf.createLineSymbolizer();
+ ls.setPerpendicularOffset(ff.literal(0.88));
+
+ //copy
+ LineSymbolizer copy = (LineSymbolizer) visitor.copy(ls);
+
+ //compare
+ assertEquals("PerpendicularOffset of LineSymbolizer has not been correctly duplicated",ls.getPerpendicularOffset(),copy.getPerpendicularOffset());
+ }
}
|
Author: aaime
Date: 2011-11-19 05:39:18 -0800 (Sat, 19 Nov 2011)
New Revision: 38360
Added:
branches/2.7.x/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBCUuidTest.java
branches/2.7.x/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBCUuidTestSetup.java
branches/2.7.x/modules/library/main/src/main/java/org/geotools/util/UuidConverterFactory.java
branches/2.7.x/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2UuidTest.java
branches/2.7.x/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2UuidTestSetup.java
branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGISUuidTest.java
branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGISUuidTestSetup.java
branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/ps/PostgisUuidTest.java
Modified:
branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/HeuristicPrimaryKeyFinder.java
branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/PreparedStatementSQLDialect.java
branches/2.7.x/modules/library/main/src/main/resources/META-INF/services/org.geotools.util.ConverterFactory
branches/2.7.x/modules/plugin/jdbc/jdbc-h2/src/main/java/org/geotools/data/h2/H2Dialect.java
branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISDialect.java
Log:
[GEOT-3016] Add support for UUID primary keys in PostGIS
Modified: branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/HeuristicPrimaryKeyFinder.java
===================================================================
--- branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/HeuristicPrimaryKeyFinder.java 2011-11-19 11:46:43 UTC (rev 38359)
+++ branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/HeuristicPrimaryKeyFinder.java 2011-11-19 13:39:18 UTC (rev 38360)
@@ -101,14 +101,18 @@
ResultSet columns = metaData.getColumns(null, databaseSchema, tableName, columnName);
columns.next();
- int binding = columns.getInt("DATA_TYPE");
- Class columnType = store.getMapping(binding);
-
- if (columnType == null) {
- LOGGER.warning("No class for sql type " + binding);
- columnType = Object.class;
+ Class columnType = store.getSQLDialect().getMapping(columns, cx);
+ if(columnType == null) {
+ int binding = columns.getInt("DATA_TYPE");
+ columnType = store.getMapping(binding);
+ if (columnType == null) {
+ LOGGER.warning("No class for sql type " + binding);
+ columnType = Object.class;
+ }
}
+
+
// determine which type of primary key we have
PrimaryKeyColumn col = null;
Modified: branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/PreparedStatementSQLDialect.java
===================================================================
--- branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/PreparedStatementSQLDialect.java 2011-11-19 11:46:43 UTC (rev 38359)
+++ branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/PreparedStatementSQLDialect.java 2011-11-19 13:39:18 UTC (rev 38360)
@@ -154,7 +154,7 @@
ps.setCharacterStream(column, new StringReader(string), string.length());
break;
default:
- ps.setObject( column, value );
+ ps.setObject( column, value, Types.OTHER );
}
}
Added: branches/2.7.x/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBCUuidTest.java
===================================================================
--- branches/2.7.x/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBCUuidTest.java (rev 0)
+++ branches/2.7.x/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBCUuidTest.java 2011-11-19 13:39:18 UTC (rev 38360)
@@ -0,0 +1,137 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.geotools.jdbc;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.UUID;
+
+import org.geotools.data.DataUtilities;
+import org.geotools.data.DefaultTransaction;
+import org.geotools.data.FeatureReader;
+import org.geotools.data.FeatureWriter;
+import org.geotools.data.Query;
+import org.geotools.data.Transaction;
+import org.geotools.data.simple.SimpleFeatureCollection;
+import org.geotools.data.simple.SimpleFeatureStore;
+import org.geotools.factory.CommonFactoryFinder;
+import org.geotools.factory.Hints;
+import org.geotools.feature.simple.SimpleFeatureBuilder;
+import org.opengis.feature.simple.SimpleFeature;
+import org.opengis.feature.simple.SimpleFeatureType;
+import org.opengis.filter.Filter;
+import org.opengis.filter.FilterFactory2;
+import org.opengis.filter.identity.FeatureId;
+
+import com.vividsolutions.jts.geom.Coordinate;
+import com.vividsolutions.jts.geom.GeometryFactory;
+import com.vividsolutions.jts.geom.Point;
+
+/**
+ *
+ * @author kbyte
+ */
+public abstract class JDBCUuidTest extends JDBCTestSupport {
+
+ @Override
+ protected abstract JDBCUuidTestSetup createTestSetup();
+
+ protected UUID uuid1 = UUID.fromString("c563f527-507e-4b80-a30b-4cab189d4dba");
+
+ protected UUID uuid2 = UUID.fromString("cae47178-2e84-4319-a5ba-8d4089c9d80d");
+
+ protected UUID uuid3 = UUID.fromString("34362328-9842-2385-8926-000000000003");
+
+ public void testGetSchema() throws Exception {
+ SimpleFeatureType ft = dataStore.getSchema(tname("guid"));
+ assertEquals(UUID.class, ft.getDescriptor(aname("uuidProperty")).getType().getBinding());
+ }
+
+ public void testGetFeatures() throws Exception {
+ FeatureReader<SimpleFeatureType, SimpleFeature> r = dataStore.getFeatureReader(new Query(tname(("guid"))),
+ Transaction.AUTO_COMMIT);
+ r.hasNext();
+
+ Set<UUID> uuids = new HashSet<UUID>();
+ uuids.add(uuid1);
+ uuids.add(uuid2);
+ while(r.hasNext()) {
+ SimpleFeature f = (SimpleFeature) r.next();
+ assertNotNull(uuids.remove(f.getAttribute(aname("uuidProperty"))));
+ }
+ assertTrue(uuids.isEmpty());
+
+ r.close();
+ }
+
+ public void testInsertFeatures() throws Exception {
+ Transaction transaction = new DefaultTransaction();
+ SimpleFeatureStore featureStore = (SimpleFeatureStore) dataStore.getFeatureSource(tname("guid"));
+ featureStore.setTransaction(transaction);
+ assertEquals(featureStore.getCount(Query.ALL),2);
+
+ SimpleFeatureType type = dataStore.getSchema(tname("guid"));
+ SimpleFeature feature = SimpleFeatureBuilder.build(type, new Object[] { uuid3 }, "guid.3");
+
+ SimpleFeatureCollection collection = DataUtilities.collection(feature);
+ featureStore.addFeatures(collection);
+ transaction.commit();
+ assertEquals(featureStore.getCount(Query.ALL),3);
+ transaction.close();
+ }
+
+ public void testModifyFeatures() throws Exception {
+ FeatureWriter<SimpleFeatureType, SimpleFeature> w = dataStore.getFeatureWriter(tname("guid"),Transaction.AUTO_COMMIT);
+ w.hasNext();
+ SimpleFeature f = w.next();
+ f.setAttribute(aname("uuidProperty"), uuid2);
+ assertEquals(uuid2, f.getAttribute(aname("uuidProperty")));
+ w.write();
+ w.close();
+ }
+
+ public void testRemoveFeatures() throws Exception {
+ SimpleFeatureStore featureStore = (SimpleFeatureStore) dataStore.getFeatureSource(tname("guid"));
+
+ final FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
+
+ Filter filter = ff.equals(ff.property(aname("uuidProperty")), ff.literal(uuid1));
+
+ featureStore.removeFeatures(filter);
+
+ assertEquals(1, featureStore.getCount(Query.ALL));
+ }
+
+ public void testUUIDAsPrimaryKey() throws Exception {
+ Transaction transaction = new DefaultTransaction();
+ SimpleFeatureStore featureStore = (SimpleFeatureStore) dataStore.getFeatureSource(tname("uuidt"));
+ featureStore.setTransaction(transaction);
+
+ featureStore.addFeatures(createFeatureCollection());
+
+ transaction.commit();
+ assertEquals(3, featureStore.getCount(Query.ALL));
+ transaction.close();
+ }
+
+ private SimpleFeatureCollection createFeatureCollection() throws Exception {
+ SimpleFeatureType type = dataStore.getSchema(tname("uuidt"));
+
+ GeometryFactory gf = new GeometryFactory();
+ Point p = gf.createPoint(new Coordinate(138.6, -34.93));
+
+ SimpleFeature feature1 = SimpleFeatureBuilder.build(type, new Object[] { p }, uuid1.toString());
+ feature1.getUserData().put(Hints.USE_PROVIDED_FID, true);
+
+ SimpleFeature feature2 = SimpleFeatureBuilder.build(type, new Object[] { p }, uuid2.toString());
+ feature2.getUserData().put(Hints.USE_PROVIDED_FID, true);
+
+ SimpleFeature feature3 = SimpleFeatureBuilder.build(type, new Object[] { p }, uuid3.toString());
+ feature3.getUserData().put(Hints.USE_PROVIDED_FID, true);
+
+ return DataUtilities.collection(new SimpleFeature[]{feature1, feature2, feature3});
+ }
+}
Added: branches/2.7.x/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBCUuidTestSetup.java
===================================================================
--- branches/2.7.x/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBCUuidTestSetup.java (rev 0)
+++ branches/2.7.x/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBCUuidTestSetup.java 2011-11-19 13:39:18 UTC (rev 38360)
@@ -0,0 +1,60 @@
+/*
+ * GeoTools - The Open Source Java GIS Toolkit
+ * http://geotools.org
+ *
+ * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ */
+package org.geotools.jdbc;
+
+import java.sql.SQLException;
+import java.util.UUID;
+
+public abstract class JDBCUuidTestSetup extends JDBCDelegatingTestSetup {
+
+ protected UUID uuid1 = UUID.fromString("c563f527-507e-4b80-a30b-4cab189d4dba");
+ protected UUID uuid2 = UUID.fromString("cae47178-2e84-4319-a5ba-8d4089c9d80d");
+
+ protected JDBCUuidTestSetup(JDBCTestSetup delegate) {
+ super(delegate);
+ }
+
+ protected final void setUpData() throws Exception {
+ //kill all the data
+ try {
+ dropUuidTable();
+ } catch (SQLException e) {
+ }
+
+ //create all the data
+ createUuidTable();
+ }
+
+ /**
+ * Creates a table with the following schema:
+ * <p>
+ * b( id:Integer; boolProperty: Boolean)
+ * </p>
+ * <p>
+ * The table should contain the following data.
+ * 0 | false
+ * 1 | true
+ * </p>
+ */
+ protected abstract void createUuidTable() throws Exception;
+
+ /**
+ * Drops the "b" table previously created
+ */
+ protected abstract void dropUuidTable() throws Exception;
+
+}
Added: branches/2.7.x/modules/library/main/src/main/java/org/geotools/util/UuidConverterFactory.java
===================================================================
--- branches/2.7.x/modules/library/main/src/main/java/org/geotools/util/UuidConverterFactory.java (rev 0)
+++ branches/2.7.x/modules/library/main/src/main/java/org/geotools/util/UuidConverterFactory.java 2011-11-19 13:39:18 UTC (rev 38360)
@@ -0,0 +1,65 @@
+/*
+ * 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.geotools.util;
+
+import java.util.UUID;
+import org.geotools.factory.Hints;
+
+/**
+ * ConverterFactory for handling uuid (uniqueidentifier) conversions.
+ * <p>
+ * Supported conversions:
+ * <ul>
+ * <li>string -> UUID
+ * <li>byte[] -> UUID
+ * </ul>
+ * </p>
+ * @author Andrea Briganti <kb...@ci...>
+ *
+ */
+public class UuidConverterFactory implements ConverterFactory {
+
+ public Converter createConverter(Class source, Class target, Hints hints) {
+ if ( target.equals( UUID.class ) ) {
+
+ //string to boolean
+ if ( source.equals( String.class ) ) {
+ return new Converter() {
+
+ public Object convert(Object source, Class target) throws Exception {
+ return UUID.fromString((String)source);
+ }
+ };
+ }
+
+ //integer to boolean
+ if ( source.equals( byte[].class ) ) {
+ return new Converter() {
+
+ public Object convert(Object source, Class target) throws Exception {
+ return UUID.nameUUIDFromBytes((byte[])source);
+ }
+
+ };
+ }
+
+ }
+
+ return null;
+ }
+
+}
Modified: branches/2.7.x/modules/library/main/src/main/resources/META-INF/services/org.geotools.util.ConverterFactory
===================================================================
--- branches/2.7.x/modules/library/main/src/main/resources/META-INF/services/org.geotools.util.ConverterFactory 2011-11-19 11:46:43 UTC (rev 38359)
+++ branches/2.7.x/modules/library/main/src/main/resources/META-INF/services/org.geotools.util.ConverterFactory 2011-11-19 13:39:18 UTC (rev 38360)
@@ -7,3 +7,4 @@
org.geotools.util.ColorConverterFactory
org.geotools.util.CollectionConverterFactory
org.geotools.util.CharsetConverterFactory
+org.geotools.util.UuidConverterFactory
\ No newline at end of file
Modified: branches/2.7.x/modules/plugin/jdbc/jdbc-h2/src/main/java/org/geotools/data/h2/H2Dialect.java
===================================================================
--- branches/2.7.x/modules/plugin/jdbc/jdbc-h2/src/main/java/org/geotools/data/h2/H2Dialect.java 2011-11-19 11:46:43 UTC (rev 38359)
+++ branches/2.7.x/modules/plugin/jdbc/jdbc-h2/src/main/java/org/geotools/data/h2/H2Dialect.java 2011-11-19 13:39:18 UTC (rev 38360)
@@ -29,6 +29,7 @@
import java.sql.Statement;
import java.sql.Types;
import java.util.Map;
+import java.util.UUID;
import java.util.logging.Level;
import org.geotools.geometry.jts.Geometries;
@@ -103,7 +104,9 @@
throws SQLException {
String typeName = columnMetaData.getString("TYPE_NAME");
- if ("BLOB".equalsIgnoreCase(typeName)) {
+ if("UUID".equalsIgnoreCase(typeName)) {
+ return UUID.class;
+ } else if ("BLOB".equalsIgnoreCase(typeName)) {
String schemaName = columnMetaData.getString("TABLE_SCHEM");
String tableName = columnMetaData.getString("TABLE_NAME");
String columnName = columnMetaData.getString("COLUMN_NAME");
Added: branches/2.7.x/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2UuidTest.java
===================================================================
--- branches/2.7.x/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2UuidTest.java (rev 0)
+++ branches/2.7.x/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2UuidTest.java 2011-11-19 13:39:18 UTC (rev 38360)
@@ -0,0 +1,19 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.geotools.data.h2;
+
+import org.geotools.jdbc.JDBCUuidTest;
+import org.geotools.jdbc.JDBCUuidTestSetup;
+
+public class H2UuidTest extends JDBCUuidTest {
+
+ @Override
+ protected JDBCUuidTestSetup createTestSetup() {
+ return new H2UuidTestSetup(new H2UuidTestSetup(new H2TestSetup()));
+ }
+
+}
+
Added: branches/2.7.x/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2UuidTestSetup.java
===================================================================
--- branches/2.7.x/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2UuidTestSetup.java (rev 0)
+++ branches/2.7.x/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2UuidTestSetup.java 2011-11-19 13:39:18 UTC (rev 38360)
@@ -0,0 +1,47 @@
+/*
+ * GeoTools - The Open Source Java GIS Toolkit
+ * http://geotools.org
+ *
+ * (C) 2002-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;
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ */
+package org.geotools.data.h2;
+
+import org.geotools.jdbc.JDBCTestSetup;
+import org.geotools.jdbc.JDBCUuidTestSetup;
+
+
+public class H2UuidTestSetup extends JDBCUuidTestSetup {
+
+ public H2UuidTestSetup(JDBCTestSetup delegate) {
+ super(delegate);
+ }
+
+ @Override
+ protected void createUuidTable() throws Exception {
+ run( "CREATE TABLE \"geotools\".\"guid\" ( \"id\" serial PRIMARY KEY, \"uuidProperty\" uuid)" );
+ run( "INSERT INTO \"geotools\".\"guid\" (\"uuidProperty\") VALUES ('" + uuid1 + "')");
+ run( "INSERT INTO \"geotools\".\"guid\" (\"uuidProperty\") VALUES ('" + uuid2 + "')");
+
+ /*
+ * A table with UUID as primary key
+ */
+ run( "CREATE TABLE \"geotools\".\"uuidt\" ( \"id\" uuid PRIMARY KEY, \"the_geom\" POINT)" );
+ run( "CALL AddGeometryColumn('geotools', 'uuidt', 'the_geom', 4326, 'POINT', 2)" );
+ }
+
+ @Override
+ protected void dropUuidTable() throws Exception {
+ run("DROP TABLE \"geotools\".\"guid\"");
+ run("DROP TABLE \"geotools\".\"uuidt\"");
+ }
+}
Modified: branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISDialect.java
===================================================================
--- branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISDialect.java 2011-11-19 11:46:43 UTC (rev 38359)
+++ branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISDialect.java 2011-11-19 13:39:18 UTC (rev 38360)
@@ -29,6 +29,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.UUID;
import java.util.logging.Level;
import org.geotools.data.jdbc.FilterToSQL;
@@ -279,6 +280,10 @@
throws SQLException {
String typeName = columnMetaData.getString("TYPE_NAME");
+ if("uuid".equalsIgnoreCase(typeName)) {
+ return UUID.class;
+ }
+
String gType = null;
if ("geometry".equalsIgnoreCase(typeName)) {
gType = lookupGeometryType(columnMetaData, cx, "geometry_columns", "f_geometry_column");
Added: branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGISUuidTest.java
===================================================================
--- branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGISUuidTest.java (rev 0)
+++ branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGISUuidTest.java 2011-11-19 13:39:18 UTC (rev 38360)
@@ -0,0 +1,23 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.geotools.data.postgis;
+
+import org.geotools.jdbc.JDBCUuidTest;
+import org.geotools.jdbc.JDBCUuidTestSetup;
+
+/**
+ *
+ * @author kbyte
+ */
+public class PostGISUuidTest extends JDBCUuidTest {
+
+ @Override
+ protected JDBCUuidTestSetup createTestSetup() {
+ return new PostGISUuidTestSetup(new PostGISTestSetup());
+ }
+
+}
+
Added: branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGISUuidTestSetup.java
===================================================================
--- branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGISUuidTestSetup.java (rev 0)
+++ branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGISUuidTestSetup.java 2011-11-19 13:39:18 UTC (rev 38360)
@@ -0,0 +1,46 @@
+/*
+ * GeoTools - The Open Source Java GIS Toolkit
+ * http://geotools.org
+ *
+ * (C) 2002-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;
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ */
+package org.geotools.data.postgis;
+
+import org.geotools.jdbc.JDBCTestSetup;
+import org.geotools.jdbc.JDBCUuidTestSetup;
+
+
+public class PostGISUuidTestSetup extends JDBCUuidTestSetup {
+
+ public PostGISUuidTestSetup(JDBCTestSetup delegate) {
+ super(delegate);
+ }
+
+ @Override
+ protected void createUuidTable() throws Exception {
+ run( "CREATE TABLE \"guid\" ( \"id\" serial PRIMARY KEY, \"uuidProperty\" uuid)" );
+ run( "INSERT INTO \"guid\" (\"uuidProperty\") VALUES ('" + uuid1 + "')");
+ run( "INSERT INTO \"guid\" (\"uuidProperty\") VALUES ('" + uuid2 + "')");
+
+ /*
+ * A table with UUID as primary key
+ */
+ run( "CREATE TABLE \"uuidt\" ( \"id\" uuid PRIMARY KEY, \"the_geom\" geometry)" );
+ }
+
+ @Override
+ protected void dropUuidTable() throws Exception {
+ run("DROP TABLE \"guid\"");
+ run("DROP TABLE \"uuidt\"");
+ }
+}
Added: branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/ps/PostgisUuidTest.java
===================================================================
--- branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/ps/PostgisUuidTest.java (rev 0)
+++ branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/ps/PostgisUuidTest.java 2011-11-19 13:39:18 UTC (rev 38360)
@@ -0,0 +1,30 @@
+/*
+ * GeoTools - The Open Source Java GIS Toolkit
+ * http://geotools.org
+ *
+ * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ */
+package org.geotools.data.postgis.ps;
+
+import org.geotools.data.postgis.PostGISUuidTestSetup;
+import org.geotools.jdbc.JDBCUuidTestSetup;
+import org.geotools.jdbc.JDBCUuidTest;
+
+public class PostgisUuidTest extends JDBCUuidTest {
+
+ @Override
+ protected JDBCUuidTestSetup createTestSetup() {
+ return new PostGISUuidTestSetup(new PostGISPSTestSetup());
+ }
+
+}
|
Author: aaime
Date: 2011-11-19 03:46:43 -0800 (Sat, 19 Nov 2011)
New Revision: 38359
Added:
trunk/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBCUuidTest.java
trunk/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBCUuidTestSetup.java
trunk/modules/library/main/src/main/java/org/geotools/util/UuidConverterFactory.java
trunk/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2UuidTest.java
trunk/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2UuidTestSetup.java
trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGISUuidTest.java
trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGISUuidTestSetup.java
trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/ps/PostgisUuidTest.java
Modified:
trunk/modules/library/jdbc/src/main/java/org/geotools/jdbc/HeuristicPrimaryKeyFinder.java
trunk/modules/library/jdbc/src/main/java/org/geotools/jdbc/PreparedStatementSQLDialect.java
trunk/modules/library/main/src/main/resources/META-INF/services/org.geotools.util.ConverterFactory
trunk/modules/plugin/jdbc/jdbc-h2/src/main/java/org/geotools/data/h2/H2Dialect.java
trunk/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISDialect.java
Log:
[GEOT-3016] Add support for UUID primary keys in PostGIS
Modified: trunk/modules/library/jdbc/src/main/java/org/geotools/jdbc/HeuristicPrimaryKeyFinder.java
===================================================================
--- trunk/modules/library/jdbc/src/main/java/org/geotools/jdbc/HeuristicPrimaryKeyFinder.java 2011-11-17 05:25:15 UTC (rev 38358)
+++ trunk/modules/library/jdbc/src/main/java/org/geotools/jdbc/HeuristicPrimaryKeyFinder.java 2011-11-19 11:46:43 UTC (rev 38359)
@@ -102,14 +102,18 @@
ResultSet columns = metaData.getColumns(null, databaseSchema, tableName, columnName);
columns.next();
- int binding = columns.getInt("DATA_TYPE");
- Class columnType = store.getMapping(binding);
-
- if (columnType == null) {
- LOGGER.warning("No class for sql type " + binding);
- columnType = Object.class;
+ Class columnType = store.getSQLDialect().getMapping(columns, cx);
+ if(columnType == null) {
+ int binding = columns.getInt("DATA_TYPE");
+ columnType = store.getMapping(binding);
+ if (columnType == null) {
+ LOGGER.warning("No class for sql type " + binding);
+ columnType = Object.class;
+ }
}
+
+
// determine which type of primary key we have
PrimaryKeyColumn col = null;
Modified: trunk/modules/library/jdbc/src/main/java/org/geotools/jdbc/PreparedStatementSQLDialect.java
===================================================================
--- trunk/modules/library/jdbc/src/main/java/org/geotools/jdbc/PreparedStatementSQLDialect.java 2011-11-17 05:25:15 UTC (rev 38358)
+++ trunk/modules/library/jdbc/src/main/java/org/geotools/jdbc/PreparedStatementSQLDialect.java 2011-11-19 11:46:43 UTC (rev 38359)
@@ -155,7 +155,7 @@
ps.setCharacterStream(column, new StringReader(string), string.length());
break;
default:
- ps.setObject( column, value );
+ ps.setObject( column, value, Types.OTHER );
}
}
Added: trunk/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBCUuidTest.java
===================================================================
--- trunk/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBCUuidTest.java (rev 0)
+++ trunk/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBCUuidTest.java 2011-11-19 11:46:43 UTC (rev 38359)
@@ -0,0 +1,140 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.geotools.jdbc;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.UUID;
+
+import org.geotools.data.DataUtilities;
+import org.geotools.data.DefaultTransaction;
+import org.geotools.data.FeatureReader;
+import org.geotools.data.FeatureWriter;
+import org.geotools.data.Query;
+import org.geotools.data.Transaction;
+import org.geotools.data.simple.SimpleFeatureCollection;
+import org.geotools.data.simple.SimpleFeatureStore;
+import org.geotools.factory.CommonFactoryFinder;
+import org.geotools.factory.Hints;
+import org.geotools.feature.simple.SimpleFeatureBuilder;
+import org.opengis.feature.simple.SimpleFeature;
+import org.opengis.feature.simple.SimpleFeatureType;
+import org.opengis.filter.Filter;
+import org.opengis.filter.FilterFactory2;
+import org.opengis.filter.identity.FeatureId;
+
+import com.vividsolutions.jts.geom.Coordinate;
+import com.vividsolutions.jts.geom.GeometryFactory;
+import com.vividsolutions.jts.geom.Point;
+
+/**
+ *
+ * @author kbyte
+ */
+public abstract class JDBCUuidTest extends JDBCTestSupport {
+
+ @Override
+ protected abstract JDBCUuidTestSetup createTestSetup();
+
+ protected UUID uuid1 = UUID.fromString("c563f527-507e-4b80-a30b-4cab189d4dba");
+
+ protected UUID uuid2 = UUID.fromString("cae47178-2e84-4319-a5ba-8d4089c9d80d");
+
+ protected UUID uuid3 = UUID.fromString("34362328-9842-2385-8926-000000000003");
+
+ public void testGetSchema() throws Exception {
+ SimpleFeatureType ft = dataStore.getSchema(tname("guid"));
+ assertEquals(UUID.class, ft.getDescriptor(aname("uuidProperty")).getType().getBinding());
+ }
+
+ public void testGetFeatures() throws Exception {
+ FeatureReader<SimpleFeatureType, SimpleFeature> r = dataStore.getFeatureReader(new Query(tname(("guid"))),
+ Transaction.AUTO_COMMIT);
+ r.hasNext();
+
+ Set<UUID> uuids = new HashSet<UUID>();
+ uuids.add(uuid1);
+ uuids.add(uuid2);
+ while(r.hasNext()) {
+ SimpleFeature f = (SimpleFeature) r.next();
+ assertNotNull(uuids.remove(f.getAttribute(aname("uuidProperty"))));
+ }
+ assertTrue(uuids.isEmpty());
+
+ r.close();
+ }
+
+ public void testInsertFeatures() throws Exception {
+ Transaction transaction = new DefaultTransaction();
+ SimpleFeatureStore featureStore = (SimpleFeatureStore) dataStore.getFeatureSource(tname("guid"));
+ featureStore.setTransaction(transaction);
+ assertEquals(featureStore.getCount(Query.ALL),2);
+
+ SimpleFeatureType type = dataStore.getSchema(tname("guid"));
+ SimpleFeature feature = SimpleFeatureBuilder.build(type, new Object[] { uuid3 }, "guid.3");
+
+ SimpleFeatureCollection collection = DataUtilities.collection(feature);
+ featureStore.addFeatures(collection);
+ transaction.commit();
+ assertEquals(featureStore.getCount(Query.ALL),3);
+ transaction.close();
+ }
+
+ public void testModifyFeatures() throws Exception {
+ FeatureWriter<SimpleFeatureType, SimpleFeature> w = dataStore.getFeatureWriter(tname("guid"),Transaction.AUTO_COMMIT);
+ w.hasNext();
+ SimpleFeature f = w.next();
+ f.setAttribute(aname("uuidProperty"), uuid2);
+ assertEquals(uuid2, f.getAttribute(aname("uuidProperty")));
+ w.write();
+ w.close();
+ }
+
+ public void testRemoveFeatures() throws Exception {
+ SimpleFeatureStore featureStore = (SimpleFeatureStore) dataStore.getFeatureSource(tname("guid"));
+
+ final FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
+
+ Filter filter = ff.equals(ff.property(aname("uuidProperty")), ff.literal(uuid1));
+
+ featureStore.removeFeatures(filter);
+
+ assertEquals(1, featureStore.getCount(Query.ALL));
+ }
+
+ public void testUUIDAsPrimaryKey() throws Exception {
+ Transaction transaction = new DefaultTransaction();
+ SimpleFeatureStore featureStore = (SimpleFeatureStore) dataStore.getFeatureSource(tname("uuidt"));
+ featureStore.setTransaction(transaction);
+
+ featureStore.addFeatures(createFeatureCollection());
+
+ transaction.commit();
+ assertEquals(3, featureStore.getCount(Query.ALL));
+ transaction.close();
+ }
+
+ private SimpleFeatureCollection createFeatureCollection() throws Exception {
+ SimpleFeatureType type = dataStore.getSchema(tname("uuidt"));
+
+ GeometryFactory gf = new GeometryFactory();
+ Point p = gf.createPoint(new Coordinate(138.6, -34.93));
+
+ SimpleFeature feature1 = SimpleFeatureBuilder.build(type, new Object[] { p }, uuid1.toString());
+ feature1.getUserData().put(Hints.USE_PROVIDED_FID, true);
+ feature1.getUserData().put(Hints.PROVIDED_FID, uuid1);
+
+ SimpleFeature feature2 = SimpleFeatureBuilder.build(type, new Object[] { p }, uuid2.toString());
+ feature2.getUserData().put(Hints.USE_PROVIDED_FID, true);
+ feature2.getUserData().put(Hints.PROVIDED_FID, uuid2);
+
+ SimpleFeature feature3 = SimpleFeatureBuilder.build(type, new Object[] { p }, uuid3.toString());
+ feature3.getUserData().put(Hints.USE_PROVIDED_FID, true);
+ feature3.getUserData().put(Hints.PROVIDED_FID, uuid3);
+
+ return DataUtilities.collection(new SimpleFeature[]{feature1, feature2, feature3});
+ }
+}
Added: trunk/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBCUuidTestSetup.java
===================================================================
--- trunk/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBCUuidTestSetup.java (rev 0)
+++ trunk/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBCUuidTestSetup.java 2011-11-19 11:46:43 UTC (rev 38359)
@@ -0,0 +1,60 @@
+/*
+ * GeoTools - The Open Source Java GIS Toolkit
+ * http://geotools.org
+ *
+ * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ */
+package org.geotools.jdbc;
+
+import java.sql.SQLException;
+import java.util.UUID;
+
+public abstract class JDBCUuidTestSetup extends JDBCDelegatingTestSetup {
+
+ protected UUID uuid1 = UUID.fromString("c563f527-507e-4b80-a30b-4cab189d4dba");
+ protected UUID uuid2 = UUID.fromString("cae47178-2e84-4319-a5ba-8d4089c9d80d");
+
+ protected JDBCUuidTestSetup(JDBCTestSetup delegate) {
+ super(delegate);
+ }
+
+ protected final void setUpData() throws Exception {
+ //kill all the data
+ try {
+ dropUuidTable();
+ } catch (SQLException e) {
+ }
+
+ //create all the data
+ createUuidTable();
+ }
+
+ /**
+ * Creates a table with the following schema:
+ * <p>
+ * b( id:Integer; boolProperty: Boolean)
+ * </p>
+ * <p>
+ * The table should contain the following data.
+ * 0 | false
+ * 1 | true
+ * </p>
+ */
+ protected abstract void createUuidTable() throws Exception;
+
+ /**
+ * Drops the "b" table previously created
+ */
+ protected abstract void dropUuidTable() throws Exception;
+
+}
Added: trunk/modules/library/main/src/main/java/org/geotools/util/UuidConverterFactory.java
===================================================================
--- trunk/modules/library/main/src/main/java/org/geotools/util/UuidConverterFactory.java (rev 0)
+++ trunk/modules/library/main/src/main/java/org/geotools/util/UuidConverterFactory.java 2011-11-19 11:46:43 UTC (rev 38359)
@@ -0,0 +1,65 @@
+/*
+ * GeoTools - The Open Source Java GIS Toolkit
+ * http://geotools.org
+ *
+ * (C) 2002-20010, 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.util;
+
+import java.util.UUID;
+import org.geotools.factory.Hints;
+
+/**
+ * ConverterFactory for handling uuid (uniqueidentifier) conversions.
+ * <p>
+ * Supported conversions:
+ * <ul>
+ * <li>string -> UUID
+ * <li>byte[] -> UUID
+ * </ul>
+ * </p>
+ * @author Andrea Briganti <kb...@ci...>
+ *
+ */
+public class UuidConverterFactory implements ConverterFactory {
+
+ public Converter createConverter(Class source, Class target, Hints hints) {
+ if ( target.equals( UUID.class ) ) {
+
+ //string to boolean
+ if ( source.equals( String.class ) ) {
+ return new Converter() {
+
+ public Object convert(Object source, Class target) throws Exception {
+ return UUID.fromString((String)source);
+ }
+ };
+ }
+
+ //integer to boolean
+ if ( source.equals( byte[].class ) ) {
+ return new Converter() {
+
+ public Object convert(Object source, Class target) throws Exception {
+ return UUID.nameUUIDFromBytes((byte[])source);
+ }
+
+ };
+ }
+
+ }
+
+ return null;
+ }
+
+}
Modified: trunk/modules/library/main/src/main/resources/META-INF/services/org.geotools.util.ConverterFactory
===================================================================
--- trunk/modules/library/main/src/main/resources/META-INF/services/org.geotools.util.ConverterFactory 2011-11-17 05:25:15 UTC (rev 38358)
+++ trunk/modules/library/main/src/main/resources/META-INF/services/org.geotools.util.ConverterFactory 2011-11-19 11:46:43 UTC (rev 38359)
@@ -7,4 +7,5 @@
org.geotools.util.ColorConverterFactory
org.geotools.util.CollectionConverterFactory
org.geotools.util.CharsetConverterFactory
+org.geotools.util.UuidConverterFactory
org.geotools.temporal.TemporalConverterFactory
Modified: trunk/modules/plugin/jdbc/jdbc-h2/src/main/java/org/geotools/data/h2/H2Dialect.java
===================================================================
--- trunk/modules/plugin/jdbc/jdbc-h2/src/main/java/org/geotools/data/h2/H2Dialect.java 2011-11-17 05:25:15 UTC (rev 38358)
+++ trunk/modules/plugin/jdbc/jdbc-h2/src/main/java/org/geotools/data/h2/H2Dialect.java 2011-11-19 11:46:43 UTC (rev 38359)
@@ -29,6 +29,7 @@
import java.sql.Statement;
import java.sql.Types;
import java.util.Map;
+import java.util.UUID;
import java.util.logging.Level;
import org.geotools.geometry.jts.Geometries;
@@ -104,7 +105,9 @@
throws SQLException {
String typeName = columnMetaData.getString("TYPE_NAME");
- if ("BLOB".equalsIgnoreCase(typeName)) {
+ if("UUID".equalsIgnoreCase(typeName)) {
+ return UUID.class;
+ } else if ("BLOB".equalsIgnoreCase(typeName)) {
String schemaName = columnMetaData.getString("TABLE_SCHEM");
String tableName = columnMetaData.getString("TABLE_NAME");
String columnName = columnMetaData.getString("COLUMN_NAME");
Added: trunk/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2UuidTest.java
===================================================================
--- trunk/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2UuidTest.java (rev 0)
+++ trunk/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2UuidTest.java 2011-11-19 11:46:43 UTC (rev 38359)
@@ -0,0 +1,19 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.geotools.data.h2;
+
+import org.geotools.jdbc.JDBCUuidTest;
+import org.geotools.jdbc.JDBCUuidTestSetup;
+
+public class H2UuidTest extends JDBCUuidTest {
+
+ @Override
+ protected JDBCUuidTestSetup createTestSetup() {
+ return new H2UuidTestSetup(new H2UuidTestSetup(new H2TestSetup()));
+ }
+
+}
+
Added: trunk/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2UuidTestSetup.java
===================================================================
--- trunk/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2UuidTestSetup.java (rev 0)
+++ trunk/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2UuidTestSetup.java 2011-11-19 11:46:43 UTC (rev 38359)
@@ -0,0 +1,47 @@
+/*
+ * GeoTools - The Open Source Java GIS Toolkit
+ * http://geotools.org
+ *
+ * (C) 2002-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;
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ */
+package org.geotools.data.h2;
+
+import org.geotools.jdbc.JDBCTestSetup;
+import org.geotools.jdbc.JDBCUuidTestSetup;
+
+
+public class H2UuidTestSetup extends JDBCUuidTestSetup {
+
+ public H2UuidTestSetup(JDBCTestSetup delegate) {
+ super(delegate);
+ }
+
+ @Override
+ protected void createUuidTable() throws Exception {
+ run( "CREATE TABLE \"geotools\".\"guid\" ( \"id\" serial PRIMARY KEY, \"uuidProperty\" uuid)" );
+ run( "INSERT INTO \"geotools\".\"guid\" (\"uuidProperty\") VALUES ('" + uuid1 + "')");
+ run( "INSERT INTO \"geotools\".\"guid\" (\"uuidProperty\") VALUES ('" + uuid2 + "')");
+
+ /*
+ * A table with UUID as primary key
+ */
+ run( "CREATE TABLE \"geotools\".\"uuidt\" ( \"id\" uuid PRIMARY KEY, \"the_geom\" POINT)" );
+ run( "CALL AddGeometryColumn('geotools', 'uuidt', 'the_geom', 4326, 'POINT', 2)" );
+ }
+
+ @Override
+ protected void dropUuidTable() throws Exception {
+ run("DROP TABLE \"geotools\".\"guid\"");
+ run("DROP TABLE \"geotools\".\"uuidt\"");
+ }
+}
Modified: trunk/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISDialect.java
===================================================================
--- trunk/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISDialect.java 2011-11-17 05:25:15 UTC (rev 38358)
+++ trunk/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISDialect.java 2011-11-19 11:46:43 UTC (rev 38359)
@@ -29,6 +29,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.UUID;
import java.util.logging.Level;
import org.geotools.data.jdbc.FilterToSQL;
@@ -297,6 +298,10 @@
throws SQLException {
String typeName = columnMetaData.getString("TYPE_NAME");
+ if("uuid".equalsIgnoreCase(typeName)) {
+ return UUID.class;
+ }
+
String gType = null;
if ("geometry".equalsIgnoreCase(typeName)) {
gType = lookupGeometryType(columnMetaData, cx, "geometry_columns", "f_geometry_column");
Added: trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGISUuidTest.java
===================================================================
--- trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGISUuidTest.java (rev 0)
+++ trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGISUuidTest.java 2011-11-19 11:46:43 UTC (rev 38359)
@@ -0,0 +1,23 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.geotools.data.postgis;
+
+import org.geotools.jdbc.JDBCUuidTest;
+import org.geotools.jdbc.JDBCUuidTestSetup;
+
+/**
+ *
+ * @author kbyte
+ */
+public class PostGISUuidTest extends JDBCUuidTest {
+
+ @Override
+ protected JDBCUuidTestSetup createTestSetup() {
+ return new PostGISUuidTestSetup(new PostGISTestSetup());
+ }
+
+}
+
Added: trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGISUuidTestSetup.java
===================================================================
--- trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGISUuidTestSetup.java (rev 0)
+++ trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGISUuidTestSetup.java 2011-11-19 11:46:43 UTC (rev 38359)
@@ -0,0 +1,46 @@
+/*
+ * GeoTools - The Open Source Java GIS Toolkit
+ * http://geotools.org
+ *
+ * (C) 2002-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;
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ */
+package org.geotools.data.postgis;
+
+import org.geotools.jdbc.JDBCTestSetup;
+import org.geotools.jdbc.JDBCUuidTestSetup;
+
+
+public class PostGISUuidTestSetup extends JDBCUuidTestSetup {
+
+ public PostGISUuidTestSetup(JDBCTestSetup delegate) {
+ super(delegate);
+ }
+
+ @Override
+ protected void createUuidTable() throws Exception {
+ run( "CREATE TABLE \"guid\" ( \"id\" serial PRIMARY KEY, \"uuidProperty\" uuid)" );
+ run( "INSERT INTO \"guid\" (\"uuidProperty\") VALUES ('" + uuid1 + "')");
+ run( "INSERT INTO \"guid\" (\"uuidProperty\") VALUES ('" + uuid2 + "')");
+
+ /*
+ * A table with UUID as primary key
+ */
+ run( "CREATE TABLE \"uuidt\" ( \"id\" uuid PRIMARY KEY, \"the_geom\" geometry)" );
+ }
+
+ @Override
+ protected void dropUuidTable() throws Exception {
+ run("DROP TABLE \"guid\"");
+ run("DROP TABLE \"uuidt\"");
+ }
+}
Added: trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/ps/PostgisUuidTest.java
===================================================================
--- trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/ps/PostgisUuidTest.java (rev 0)
+++ trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/ps/PostgisUuidTest.java 2011-11-19 11:46:43 UTC (rev 38359)
@@ -0,0 +1,30 @@
+/*
+ * GeoTools - The Open Source Java GIS Toolkit
+ * http://geotools.org
+ *
+ * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ */
+package org.geotools.data.postgis.ps;
+
+import org.geotools.data.postgis.PostGISUuidTestSetup;
+import org.geotools.jdbc.JDBCUuidTestSetup;
+import org.geotools.jdbc.JDBCUuidTest;
+
+public class PostgisUuidTest extends JDBCUuidTest {
+
+ @Override
+ protected JDBCUuidTestSetup createTestSetup() {
+ return new PostGISUuidTestSetup(new PostGISPSTestSetup());
+ }
+
+}
|
|
From: <svn...@os...> - 2011-11-17 05:25:22
|
Author: mleslie Date: 2011-11-16 21:25:15 -0800 (Wed, 16 Nov 2011) New Revision: 38358 Modified: trunk/modules/unsupported/geogit-versioned/pom.xml trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/DecoratedTestCase.java trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/VersionedTest.java Log: Adding some more extensive testing of the decorator query delegation. Modified: trunk/modules/unsupported/geogit-versioned/pom.xml =================================================================== --- trunk/modules/unsupported/geogit-versioned/pom.xml 2011-11-16 03:57:14 UTC (rev 38357) +++ trunk/modules/unsupported/geogit-versioned/pom.xml 2011-11-17 05:25:15 UTC (rev 38358) @@ -48,8 +48,24 @@ <id>groldan</id> <email></email> </developer> + <developer> + <name>Mark Leslie</name> + <id>mleslie</id> + <email>mar...@li...</email> + </developer> </developers> + <repositories> + <repository> + <id>oracle</id> + <name>Oracles Maven Repository</name> + <url>http://download.oracle.com/maven/</url> + <snapshots> + <enabled>false</enabled> + </snapshots> + </repository> + </repositories> + <dependencies> <dependency> <groupId>com.fasterxml.uuid</groupId> @@ -77,13 +93,11 @@ </dependency> <!-- Berkeley DB JE --> - <!-- <dependency> <groupId>com.sleepycat</groupId> <artifactId>je</artifactId> <version>4.1.7</version> </dependency> - --> <!-- Test scope dependencies --> <dependency> Modified: trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/DecoratedTestCase.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/DecoratedTestCase.java 2011-11-16 03:57:14 UTC (rev 38357) +++ trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/DecoratedTestCase.java 2011-11-17 05:25:15 UTC (rev 38358) @@ -383,14 +383,60 @@ return featList; } + /** + * This function uses the custom comparison function compareFeature + * in order to ignore any featureVersion information held by the identifier. + * @param feat + * @param list + * @return + */ protected boolean containsFeature(SimpleFeature feat, List<SimpleFeature> list) { + if(feat == null) + return false; Iterator<SimpleFeature> it = list.iterator(); while (it.hasNext()) { - if (feat.equals(it.next())) + SimpleFeature otherFeat = it.next(); + if(compareFeature(feat, otherFeat)) { return true; + } } LOGGER.info("Could not match feature to list: " + feat); return false; } + + /** + * This function is meant to compare feature contents with test features, + * and as such, needs to ignore featureVersion or rid information + * in FeatureId's. + * @param feat + * @param otherFeat + * @return + */ + private boolean compareFeature(SimpleFeature feat, SimpleFeature otherFeat) { + FeatureId fid = feat.getIdentifier(); + FeatureId otherFid = otherFeat.getIdentifier(); + if(!fid.equalsFID(otherFid)) { + return false; + } + if(!feat.getFeatureType().equals(otherFeat.getFeatureType())) { + return false; + } + for(int i = 0; i < feat.getAttributeCount(); i++) { + Object attr = feat.getAttribute(i); + Object otherAttr = otherFeat.getAttribute(i); + if(attr == null) { + if(otherAttr != null) { + return false; + } + } else { + if(otherAttr == null) { + return false; + } else if(!attr.equals(otherAttr)) { + return false; + } + } + } + return true; + } } Modified: trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/VersionedTest.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/VersionedTest.java 2011-11-16 03:57:14 UTC (rev 38357) +++ trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/VersionedTest.java 2011-11-17 05:25:15 UTC (rev 38358) @@ -17,14 +17,29 @@ package org.geoserver.data.versioning.decorator; import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; import java.util.List; +import java.util.Set; +import java.util.TreeSet; +import org.geogit.api.LogOp; +import org.geogit.api.ObjectId; +import org.geogit.api.Ref; +import org.geogit.api.RevCommit; +import org.geogit.api.RevTree; +import org.geogit.storage.ObjectReader; +import org.geogit.storage.WrappedSerialisingFactory; import org.geotools.data.Query; import org.geotools.data.simple.SimpleFeatureCollection; import org.geotools.data.simple.SimpleFeatureIterator; import org.geotools.data.simple.SimpleFeatureSource; import org.geotools.filter.FilterFactoryImpl; +import org.opengis.feature.Feature; import org.opengis.feature.simple.SimpleFeature; +import org.opengis.feature.simple.SimpleFeatureType; +import org.opengis.feature.type.Name; import org.opengis.filter.Filter; import org.opengis.filter.FilterFactory2; import org.opengis.filter.identity.Version; @@ -308,5 +323,145 @@ feats.close(); } } + + public void testConsistencyNoHistory() throws Exception { + verifyVersionedConsistency(); + verifyUnversionedConsistency(); + } + + public void testConsistencyHistory() throws Exception { + updateTestFeatures(); + updateSampleFeatures(); + finalTestFeatureUpdate(); + verifyVersionedConsistency(); + verifyUnversionedConsistency(); + } + + private void verifyUnversionedConsistency() throws Exception { + SimpleFeatureIterator feats = null; + try { + List<SimpleFeature> decoratedFeatures = new ArrayList<SimpleFeature>(); + + SimpleFeatureSource source = unversioned.getFeatureSource(testName); + assertNotNull(source); + + Query query = new Query(testName); + SimpleFeatureCollection collection = source.getFeatures(query); + assertNotNull(collection); + feats = collection.features(); + assertNotNull(feats); + while(feats.hasNext()) { + SimpleFeature feat = feats.next(); + assertNotNull(feat); + decoratedFeatures.add(feat); + } + + List<SimpleFeature> versionedFeatures = getLatestFeatures(testType); + compareFeatureLists(decoratedFeatures, versionedFeatures); + + } finally { + if(feats != null) + feats.close(); + } + + } + + private void verifyVersionedConsistency() throws Exception { + SimpleFeatureIterator feats = null; + try { + List<SimpleFeature> decoratedFeatures = new ArrayList<SimpleFeature>(); + SimpleFeatureSource source = versioned.getFeatureSource(testName); + assertNotNull(source); + + Query query = new Query(testName); + query.setVersion("ALL"); + + SimpleFeatureCollection collection = source.getFeatures(query); + assertNotNull(collection); + feats = collection.features(); + assertNotNull(feats); + while(feats.hasNext()) { + SimpleFeature feat = feats.next(); + assertNotNull(feat); + decoratedFeatures.add(feat); + } + + List<SimpleFeature> versionedFeatures = getAllFeatures(testType); + compareFeatureLists(decoratedFeatures, versionedFeatures); + + } finally { + if(feats != null) + feats.close(); + } + } + + private void compareFeatureLists(List<SimpleFeature> left, List<SimpleFeature> right) { + assertEquals(left.size(), right.size()); + Iterator<SimpleFeature> it = left.iterator(); + while(it.hasNext()) { + SimpleFeature lfeat = it.next(); + LOGGER.info(lfeat.toString()); + assertTrue(containsFeature(lfeat, right)); + } + } + + private List<SimpleFeature> getLatestFeatures(SimpleFeatureType featureType) { + Name typeName = featureType.getName(); + + LogOp logOp = new LogOp(repo); + logOp.addPath(typeName.getNamespaceURI(), typeName.getLocalPart()).setLimit(1); + return getFeaturesFromLog(logOp, featureType); + } + + private List<SimpleFeature> getAllFeatures(SimpleFeatureType featureType) { + Name typeName = featureType.getName(); + + LogOp logOp = new LogOp(repo); + logOp.addPath(typeName.getNamespaceURI(), typeName.getLocalPart()); + return getFeaturesFromLog(logOp, featureType); + } + + private List<SimpleFeature> getFeaturesFromLog(LogOp logOp, SimpleFeatureType featureType) { + Name typeName = featureType.getName(); + try { + Set<Ref> refs = new HashSet<Ref>(); + Iterator<RevCommit> featureCommits = logOp.call(); + while(featureCommits.hasNext()) { + RevCommit cmt = featureCommits.next(); + refs.addAll(getRefsByCommit(cmt, typeName)); + } + List<SimpleFeature> feats = new ArrayList<SimpleFeature>(); + for(Ref ref : refs) { + SimpleFeature feat = (SimpleFeature)repo.getFeature(featureType, ref.getName(), ref.getObjectId()); + feats.add(feat); + } + return feats; + } catch (Exception ex) { + /* + * Need some logging. + */ + return Collections.emptyList(); + } + } + + private List<Ref> getRefsByCommit(RevCommit commit, Name typeName) { + List<Ref> treeRefs = new ArrayList<Ref>(); + if (commit != null) { + ObjectId commitTreeId = commit.getTreeId(); + RevTree commitTree = repo.getTree(commitTreeId); + Ref nsRef = commitTree.get(typeName.getNamespaceURI()); + RevTree nsTree = repo.getTree(nsRef.getObjectId()); + Ref typeRef = nsTree.get(typeName.getLocalPart()); + RevTree typeTree = repo.getTree( + typeRef.getObjectId()); + Iterator<Ref> it = typeTree.iterator(null); + + while (it.hasNext()) { + Ref nextRef = it.next(); + treeRefs.add(nextRef); + } + } + return treeRefs; + } } |
|
From: <svn...@os...> - 2011-11-16 03:57:25
|
Author: mleslie Date: 2011-11-15 19:57:14 -0800 (Tue, 15 Nov 2011) New Revision: 38357 Modified: 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 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/SimpleMemoryDataAccess.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 trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/UnversionedTest.java trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/VersionedTest.java Log: Adding standard file headers. Modified: 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 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitDataStore.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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; Modified: 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 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitDataStoreFactory.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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; Modified: 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 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitFeatureSource.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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; Modified: 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 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitFeatureStore.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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; Modified: 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 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitSimpleFeatureCollection.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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; Modified: 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/GeoToolsCommitStateResolver.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoToolsCommitStateResolver.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.util.Date; Modified: 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/ModifyingFeatureCollection.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/ModifyingFeatureCollection.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.util.Arrays; Modified: 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/geogit/VersioningTransactionState.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/VersioningTransactionState.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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; Modified: 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/SimpleVersioningFeatureLocking.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/SimpleVersioningFeatureLocking.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning; import org.geotools.data.simple.SimpleFeatureLocking; Modified: 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/SimpleVersioningFeatureSource.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/SimpleVersioningFeatureSource.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning; import org.geotools.data.simple.SimpleFeatureSource; Modified: 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/SimpleVersioningFeatureStore.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/SimpleVersioningFeatureStore.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning; import org.geotools.data.simple.SimpleFeatureStore; Modified: 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/VersioningDataAccess.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/VersioningDataAccess.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning; import org.geotools.data.DataAccess; Modified: 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/VersioningDataStore.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/VersioningDataStore.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning; import org.geotools.data.DataStore; Modified: 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/VersioningFeatureLocking.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/VersioningFeatureLocking.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning; import org.geotools.data.FeatureLocking; Modified: 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/VersioningFeatureSource.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/VersioningFeatureSource.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning; import org.geotools.data.FeatureSource; Modified: 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/VersioningFeatureStore.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/VersioningFeatureStore.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning; import org.geotools.data.FeatureStore; Modified: 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/DataAccessDecorator.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/DataAccessDecorator.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning.decorator; import java.io.IOException; Modified: 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/DataStoreDecorator.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/DataStoreDecorator.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning.decorator; import java.io.IOException; Modified: 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/DefaultVersionedFeatureCollection.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/DefaultVersionedFeatureCollection.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning.decorator; import java.io.IOException; Modified: 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/FeatureLockingDecorator.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/FeatureLockingDecorator.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning.decorator; import java.io.IOException; Modified: 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/FeatureSourceDecorator.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/FeatureSourceDecorator.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning.decorator; import static org.geoserver.data.versioning.decorator.VersionFilters.getUnversioningFilter; Modified: 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/FeatureStoreDecorator.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/FeatureStoreDecorator.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning.decorator; import static org.geotools.data.Transaction.AUTO_COMMIT; Modified: 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/QueryFeatureCollector.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/QueryFeatureCollector.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning.decorator; import java.io.IOException; Modified: 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/ResourceIdAssigningFeatureCollection.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/ResourceIdAssigningFeatureCollection.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning.decorator; import java.util.Iterator; Modified: 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/ResourceIdFeatureCollector.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/ResourceIdFeatureCollector.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning.decorator; import java.io.IOException; Modified: 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/ResourceIdQueryFeatureCollector.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/ResourceIdQueryFeatureCollector.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning.decorator; import java.io.IOException; Modified: 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/SimpleFeatureLockingDecorator.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/SimpleFeatureLockingDecorator.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning.decorator; import java.io.IOException; Modified: 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/SimpleFeatureSourceDecorator.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/SimpleFeatureSourceDecorator.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning.decorator; import java.io.IOException; Modified: 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/SimpleFeatureStoreDecorator.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/SimpleFeatureStoreDecorator.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning.decorator; import java.io.IOException; Modified: 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/SimpleResourceIdAssigningFeatureCollection.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/SimpleResourceIdAssigningFeatureCollection.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning.decorator; import java.util.NoSuchElementException; Modified: 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/VersionDetail.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/VersionDetail.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning.decorator; import java.text.DateFormat; Modified: 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/VersionFilters.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/VersionFilters.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning.decorator; import java.util.HashSet; Modified: 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/VersionQuery.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/VersionQuery.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning.decorator; import java.util.ArrayList; Modified: 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/VersionedFeatureWrapper.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/VersionedFeatureWrapper.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning.decorator; import org.geotools.factory.CommonFactoryFinder; 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 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/versioning/decorator/VersioningAdapterFactory.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning.decorator; import org.geogit.repository.Repository; 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/GeoGitDataStoreTest.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/geogit/GeoGitDataStoreTest.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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; Modified: 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/GeoGitFeatureSourceTest.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/geogit/GeoGitFeatureSourceTest.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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; Modified: 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/geogit/GeoGitFeatureStoreTest.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/geogit/GeoGitFeatureStoreTest.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.util.Arrays; Modified: trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/SimpleMemoryDataAccess.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/SimpleMemoryDataAccess.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/SimpleMemoryDataAccess.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning; import java.io.IOException; Modified: 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/VersioningTestSupport.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/VersioningTestSupport.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning; import org.geogit.test.RepositoryTestCase; Modified: trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/DecoratedTestCase.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/DecoratedTestCase.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/DecoratedTestCase.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning.decorator; import java.io.File; Modified: trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/UnversionedTest.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/UnversionedTest.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/UnversionedTest.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning.decorator; import java.io.IOException; Modified: trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/VersionedTest.java =================================================================== --- trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/VersionedTest.java 2011-11-16 03:49:16 UTC (rev 38356) +++ trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/VersionedTest.java 2011-11-16 03:57:14 UTC (rev 38357) @@ -1,3 +1,19 @@ +/* + * 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.versioning.decorator; import java.util.ArrayList; |
Author: mleslie Date: 2011-11-15 19:49:16 -0800 (Tue, 15 Nov 2011) New Revision: 38356 Added: trunk/modules/unsupported/geogit-versioned/ trunk/modules/unsupported/geogit-versioned/pom.xml trunk/modules/unsupported/geogit-versioned/src/ trunk/modules/unsupported/geogit-versioned/src/main/ trunk/modules/unsupported/geogit-versioned/src/main/java/ trunk/modules/unsupported/geogit-versioned/src/main/java/org/ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/ 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/ 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/ 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 trunk/modules/unsupported/geogit-versioned/src/main/resources/ trunk/modules/unsupported/geogit-versioned/src/test/ trunk/modules/unsupported/geogit-versioned/src/test/java/ trunk/modules/unsupported/geogit-versioned/src/test/java/org/ trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/ trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/ trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/geogit/ 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/ trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/SimpleMemoryDataAccess.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/ trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/DecoratedTestCase.java trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/UnversionedTest.java trunk/modules/unsupported/geogit-versioned/src/test/java/org/geoserver/data/versioning/decorator/VersionedTest.java trunk/modules/unsupported/geogit-versioned/src/test/resources/ Modified: trunk/modules/unsupported/pom.xml Log: Creation of an unsupported module for GeoGIT-based datastore versioning. Added: trunk/modules/unsupported/geogit-versioned/pom.xml =================================================================== --- trunk/modules/unsupported/geogit-versioned/pom.xml (rev 0) +++ trunk/modules/unsupported/geogit-versioned/pom.xml 2011-11-16 03:49:16 UTC (rev 38356) @@ -0,0 +1,115 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- ======================================================================= + Maven Project Configuration File The Geotools Project http://www.geotools.org/ + Version: $Id$ ======================================================================= --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 + http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.geotools</groupId> + <artifactId>unsupported</artifactId> + <version>8-SNAPSHOT</version> + </parent> + + + <!-- =========================================================== --> + <!-- Module Description --> + <!-- =========================================================== --> + <groupId>org.geotools.unsupported</groupId> + <artifactId>gt-geogit-versioned</artifactId> + <packaging>jar</packaging> + <name>GeoGIT DataStore</name> + + <scm> + <connection> + scm:svn:http://svn.osgeo.org/geotools/trunk/modules/unsupported/geogit-versioned + </connection> + <url>http://svn.osgeo.org/geotools/trunk/modules/unsupported/geogit-versioned</url> + </scm> + + <description></description> + + <licenses> + <license> + <name>Lesser General Public License (LGPL)</name> + <url>http://www.gnu.org/copyleft/lesser.txt</url> + <distribution>repo</distribution> + </license> + </licenses> + + <!-- =========================================================== --> + <!-- Developers and Contributors --> + <!-- =========================================================== --> + <developers> + <developer> + <name>Gabriel Roldan</name> + <id>groldan</id> + <email></email> + </developer> + </developers> + + <dependencies> + <dependency> + <groupId>com.fasterxml.uuid</groupId> + <artifactId>java-uuid-generator</artifactId> + <version>3.1.2</version> + </dependency> + <dependency> + <groupId>org.geogit</groupId> + <artifactId>geogit</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt-cql</artifactId> + <version>8-SNAPSHOT</version> + </dependency> + + + <dependency> + <!-- Google Common Libraries. Featuring com.google.collect collection + classes --> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <version>r09</version> + </dependency> + + <!-- Berkeley DB JE --> + <!-- + <dependency> + <groupId>com.sleepycat</groupId> + <artifactId>je</artifactId> + <version>4.1.7</version> + </dependency> + --> + + <!-- Test scope dependencies --> + <dependency> + <groupId>org.geogit</groupId> + <artifactId>geogit</artifactId> + <version>1.0-SNAPSHOT</version> + <classifier>tests</classifier> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-all</artifactId> + <version>1.8.5</version> + <scope>test</scope> + </dependency> + + + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </dependency> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt-property</artifactId> + <version>8-SNAPSHOT</version> + </dependency> + </dependencies> + +</project> Added: 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 (rev 0) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitDataStore.java 2011-11-16 03:49:16 UTC (rev 38356) @@ -0,0 +1,383 @@ +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.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)); + + 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 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"); + } + +} Added: 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 (rev 0) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitDataStoreFactory.java 2011-11-16 03:49:16 UTC (rev 38356) @@ -0,0 +1,127 @@ +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(); + } + +} Added: 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 (rev 0) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitFeatureSource.java 2011-11-16 03:49:16 UTC (rev 38356) @@ -0,0 +1,326 @@ +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); + } + } + +} Added: 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 (rev 0) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitFeatureStore.java 2011-11-16 03:49:16 UTC (rev 38356) @@ -0,0 +1,322 @@ +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); + + } + +} Added: 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 (rev 0) +++ trunk/modules/unsupported/geogit-versioned/src/main/java/org/geoserver/data/geogit/GeoGitSimpleFeatureCollection.java 2011-11-16 03:49:16 UTC (rev 38356) @@ -0,0 +1,563 @@ +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.reprojector = new FeatureReprojector(type); + } + + public void setGeometryFactory(GeometryFactory geometryFactory) { + this.geometryFactory = geometryFactory; + } + + public void setMaxFeatures(Integer maxFeatures) { + this.maxFeatures = maxFeatures; + } + + private static class FeatureReprojector { + + private final GeometryDescriptor[] geometryDescriptors; + + private GeometryDescriptor mainGeometry; + + public FeatureReprojector(final SimpleFeatureType type) { + this.mainGeometry = type.getGeometryDescriptor(); + + List<GeometryDescriptor> list = new ArrayList<GeometryDescriptor>(2); + for (AttributeDescriptor att : type.getAttributeDescriptors()) { + if (att instanceof GeometryDescriptor) { + list.add((GeometryDescriptor) att); + } + } + this.geometryDescriptors = list.toArray(new GeometryDescriptor[list + .size()]); + } + + /** + * Expands {@code bounds} to include {@code featureBounds} + * + * @throws TransformException + */ + public void expandToInclude(ReferencedEnvelope target, + final BoundingBox featureBounds) throws TransformException { + final CoordinateReferenceSystem crs = target + .getCoordinateReferenceSystem(); + final BoundingBox reprojected = ensureCompatibleCrs(featureBounds, + crs); + target.include(reprojected); + } + + public BoundingBox ensureCompatibleCrs(final BoundingBox featureBounds, + final CoordinateReferenceSystem targetCrs) + throws TransformException { + + final CoordinateReferenceSystem featureCrs = featureBounds + .getCoordinateReferenceSystem(); + if (CRS.equalsIgnoreMetadata(targetCrs, featureCrs)) { + return featureBounds; + } + + return featureBounds.toBounds(targetCrs); + } + + public SimpleFeature reproject(SimpleFeature feature) throws Exception { + GeometryDescriptor geometryDescriptor; + CoordinateReferenceSystem sourceCrs; + CoordinateReferenceSystem targetCrs; + String name; + for (int i = 0; i < geometryDescriptors.length; i++) { + geometryDescriptor = geometryDescriptors[i]; + targetCrs = geometryDescriptor.getCoordinateReferenceSystem(); + name = geometryDescriptor.getLocalName(); + Geometry geometry = (Geometry) feature.getAttribute(name); + if (geometry != null) { + sourceCrs = (CoordinateReferenceSystem) geometry + .getUserData(); + if (sourceCrs != null + ... [truncated message content] |
Author: aaime
Date: 2011-11-14 02:29:39 -0800 (Mon, 14 Nov 2011)
New Revision: 38355
Added:
branches/2.7.x/modules/plugin/imagemosaic/src/test/java/org/geotools/gce/imagemosaic/RasterLayerRequestTest.java
Modified:
branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerRequest.java
branches/2.7.x/modules/plugin/jp2k/src/main/java/org/geotools/coverageio/jp2k/RasterLayerRequest.java
Log:
[GEOT-3950] ImageMosaic might choose the wrong overview in case of reprojection
Modified: branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerRequest.java
===================================================================
--- branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerRequest.java 2011-11-14 10:28:32 UTC (rev 38354)
+++ branches/2.7.x/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerRequest.java 2011-11-14 10:29:39 UTC (rev 38355)
@@ -1071,7 +1071,7 @@
- final GridToEnvelopeMapper geMapper= new GridToEnvelopeMapper(new GridEnvelope2D(requestedRasterArea),cropBBox);
+ final GridToEnvelopeMapper geMapper= new GridToEnvelopeMapper(new GridEnvelope2D(destinationRasterArea),cropBBox);
final AffineTransform tempTransform = geMapper.createAffineTransform();
// final double scaleX=XAffineTransform.getScaleX0((AffineTransform) requestedGridToWorld)/XAffineTransform.getScaleX0(tempTransform);
// final double scaleY=XAffineTransform.getScaleY0((AffineTransform) requestedGridToWorld)/XAffineTransform.getScaleY0(tempTransform);
Added: branches/2.7.x/modules/plugin/imagemosaic/src/test/java/org/geotools/gce/imagemosaic/RasterLayerRequestTest.java
===================================================================
--- branches/2.7.x/modules/plugin/imagemosaic/src/test/java/org/geotools/gce/imagemosaic/RasterLayerRequestTest.java (rev 0)
+++ branches/2.7.x/modules/plugin/imagemosaic/src/test/java/org/geotools/gce/imagemosaic/RasterLayerRequestTest.java 2011-11-14 10:29:39 UTC (rev 38355)
@@ -0,0 +1,59 @@
+package org.geotools.gce.imagemosaic;
+
+import static org.junit.Assert.*;
+
+import java.awt.Rectangle;
+import java.io.File;
+import java.util.Arrays;
+
+import org.geotools.coverage.grid.GridEnvelope2D;
+import org.geotools.coverage.grid.GridGeometry2D;
+import org.geotools.coverage.grid.io.AbstractGridFormat;
+import org.geotools.geometry.GeneralEnvelope;
+import org.geotools.referencing.CRS;
+import org.geotools.test.TestData;
+import org.junit.Test;
+import org.opengis.geometry.Envelope;
+import org.opengis.parameter.GeneralParameterValue;
+import org.opengis.parameter.ParameterValue;
+
+public class RasterLayerRequestTest {
+
+ @Test
+ public void testResolutions() throws Exception {
+ // get some test data
+ final File testMosaic = TestData.file(this, "/overview/0");
+ assertTrue(testMosaic.exists());
+
+ // build the objects we need to get to build a raster layer request
+ final ImageMosaicReader reader = (ImageMosaicReader) new ImageMosaicFormat().getReader(
+ testMosaic, null);
+ final RasterManager manager = new RasterManager(reader);
+
+ GeneralEnvelope oe = reader.getOriginalEnvelope();
+ System.out.println(oe);
+ double offset = oe.getSpan(0) * 0.9;
+ GeneralEnvelope reNative = new GeneralEnvelope(oe);
+ reNative.setRange(0, oe.getMinimum(0) - offset, oe.getMaximum(0) - offset);
+ Envelope reTransformed = CRS.transform(reNative, CRS.decode("EPSG:3857", true));
+ // System.out.println(reader.getOriginalGridRange());
+ // the raster has bands like this, let's ask for the coarser grained overview
+ // Band 1 Block=140x58 Type=Byte, ColorInterp=Gray
+ // Overviews: 70x94, 35x47
+ GridGeometry2D gg = new GridGeometry2D(new GridEnvelope2D(0, 0, 35, 47), reTransformed);
+
+ ParameterValue<GridGeometry2D> ggParam = AbstractGridFormat.READ_GRIDGEOMETRY2D
+ .createValue();
+ ggParam.setValue(gg);
+
+ // Creating a request
+ final RasterLayerRequest request = new RasterLayerRequest(
+ new GeneralParameterValue[] { ggParam }, manager);
+ double[] rr = request.getRequestedResolution();
+ // System.out.println(Arrays.toString(rr));
+ double resolution = Math.min(rr[0], rr[1]);
+ // System.out.println(resolution);
+ // native resolution is ~16, overviews are at 32 and 64, the request really needs 64
+ assertTrue(resolution > 60);
+ }
+}
Modified: branches/2.7.x/modules/plugin/jp2k/src/main/java/org/geotools/coverageio/jp2k/RasterLayerRequest.java
===================================================================
--- branches/2.7.x/modules/plugin/jp2k/src/main/java/org/geotools/coverageio/jp2k/RasterLayerRequest.java 2011-11-14 10:28:32 UTC (rev 38354)
+++ branches/2.7.x/modules/plugin/jp2k/src/main/java/org/geotools/coverageio/jp2k/RasterLayerRequest.java 2011-11-14 10:29:39 UTC (rev 38355)
@@ -753,7 +753,7 @@
//
requestedResolution=null;
- final GridToEnvelopeMapper geMapper = new GridToEnvelopeMapper(new GridEnvelope2D(requestedRasterArea),cropBBox);
+ final GridToEnvelopeMapper geMapper = new GridToEnvelopeMapper(new GridEnvelope2D(destinationRasterArea),cropBBox);
final AffineTransform tempTransform = geMapper.createAffineTransform();
requestedResolution= new double[] {
XAffineTransform.getScaleX0(tempTransform),
|
Author: aaime
Date: 2011-11-14 02:28:32 -0800 (Mon, 14 Nov 2011)
New Revision: 38354
Added:
trunk/modules/plugin/imagemosaic/src/test/java/org/geotools/gce/imagemosaic/RasterLayerRequestTest.java
Modified:
trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerRequest.java
trunk/modules/plugin/jp2k/src/main/java/org/geotools/coverageio/jp2k/RasterLayerRequest.java
Log:
[GEOT-3950] ImageMosaic might choose the wrong overview in case of reprojection
Modified: trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerRequest.java
===================================================================
--- trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerRequest.java 2011-11-13 16:49:55 UTC (rev 38353)
+++ trunk/modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/RasterLayerRequest.java 2011-11-14 10:28:32 UTC (rev 38354)
@@ -1071,7 +1071,7 @@
- final GridToEnvelopeMapper geMapper= new GridToEnvelopeMapper(new GridEnvelope2D(requestedRasterArea),cropBBox);
+ final GridToEnvelopeMapper geMapper= new GridToEnvelopeMapper(new GridEnvelope2D(destinationRasterArea),cropBBox);
final AffineTransform tempTransform = geMapper.createAffineTransform();
// final double scaleX=XAffineTransform.getScaleX0((AffineTransform) requestedGridToWorld)/XAffineTransform.getScaleX0(tempTransform);
// final double scaleY=XAffineTransform.getScaleY0((AffineTransform) requestedGridToWorld)/XAffineTransform.getScaleY0(tempTransform);
Added: trunk/modules/plugin/imagemosaic/src/test/java/org/geotools/gce/imagemosaic/RasterLayerRequestTest.java
===================================================================
--- trunk/modules/plugin/imagemosaic/src/test/java/org/geotools/gce/imagemosaic/RasterLayerRequestTest.java (rev 0)
+++ trunk/modules/plugin/imagemosaic/src/test/java/org/geotools/gce/imagemosaic/RasterLayerRequestTest.java 2011-11-14 10:28:32 UTC (rev 38354)
@@ -0,0 +1,59 @@
+package org.geotools.gce.imagemosaic;
+
+import static org.junit.Assert.*;
+
+import java.awt.Rectangle;
+import java.io.File;
+import java.util.Arrays;
+
+import org.geotools.coverage.grid.GridEnvelope2D;
+import org.geotools.coverage.grid.GridGeometry2D;
+import org.geotools.coverage.grid.io.AbstractGridFormat;
+import org.geotools.geometry.GeneralEnvelope;
+import org.geotools.referencing.CRS;
+import org.geotools.test.TestData;
+import org.junit.Test;
+import org.opengis.geometry.Envelope;
+import org.opengis.parameter.GeneralParameterValue;
+import org.opengis.parameter.ParameterValue;
+
+public class RasterLayerRequestTest {
+
+ @Test
+ public void testResolutions() throws Exception {
+ // get some test data
+ final File testMosaic = TestData.file(this, "/overview/0");
+ assertTrue(testMosaic.exists());
+
+ // build the objects we need to get to build a raster layer request
+ final ImageMosaicReader reader = (ImageMosaicReader) new ImageMosaicFormat().getReader(
+ testMosaic, null);
+ final RasterManager manager = new RasterManager(reader);
+
+ GeneralEnvelope oe = reader.getOriginalEnvelope();
+ System.out.println(oe);
+ double offset = oe.getSpan(0) * 0.9;
+ GeneralEnvelope reNative = new GeneralEnvelope(oe);
+ reNative.setRange(0, oe.getMinimum(0) - offset, oe.getMaximum(0) - offset);
+ Envelope reTransformed = CRS.transform(reNative, CRS.decode("EPSG:3857", true));
+ // System.out.println(reader.getOriginalGridRange());
+ // the raster has bands like this, let's ask for the coarser grained overview
+ // Band 1 Block=140x58 Type=Byte, ColorInterp=Gray
+ // Overviews: 70x94, 35x47
+ GridGeometry2D gg = new GridGeometry2D(new GridEnvelope2D(0, 0, 35, 47), reTransformed);
+
+ ParameterValue<GridGeometry2D> ggParam = AbstractGridFormat.READ_GRIDGEOMETRY2D
+ .createValue();
+ ggParam.setValue(gg);
+
+ // Creating a request
+ final RasterLayerRequest request = new RasterLayerRequest(
+ new GeneralParameterValue[] { ggParam }, manager);
+ double[] rr = request.getRequestedResolution();
+ // System.out.println(Arrays.toString(rr));
+ double resolution = Math.min(rr[0], rr[1]);
+ // System.out.println(resolution);
+ // native resolution is ~16, overviews are at 32 and 64, the request really needs 64
+ assertTrue(resolution > 60);
+ }
+}
Modified: trunk/modules/plugin/jp2k/src/main/java/org/geotools/coverageio/jp2k/RasterLayerRequest.java
===================================================================
--- trunk/modules/plugin/jp2k/src/main/java/org/geotools/coverageio/jp2k/RasterLayerRequest.java 2011-11-13 16:49:55 UTC (rev 38353)
+++ trunk/modules/plugin/jp2k/src/main/java/org/geotools/coverageio/jp2k/RasterLayerRequest.java 2011-11-14 10:28:32 UTC (rev 38354)
@@ -753,7 +753,7 @@
//
requestedResolution=null;
- final GridToEnvelopeMapper geMapper = new GridToEnvelopeMapper(new GridEnvelope2D(requestedRasterArea),cropBBox);
+ final GridToEnvelopeMapper geMapper = new GridToEnvelopeMapper(new GridEnvelope2D(destinationRasterArea),cropBBox);
final AffineTransform tempTransform = geMapper.createAffineTransform();
requestedResolution= new double[] {
XAffineTransform.getScaleX0(tempTransform),
|