You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(39) |
Dec
(70) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(52) |
Feb
(168) |
Mar
(248) |
Apr
(143) |
May
(418) |
Jun
(558) |
Jul
(702) |
Aug
(311) |
Sep
(141) |
Oct
(350) |
Nov
(172) |
Dec
(182) |
2003 |
Jan
(320) |
Feb
(362) |
Mar
(356) |
Apr
(218) |
May
(447) |
Jun
(203) |
Jul
(745) |
Aug
(494) |
Sep
(175) |
Oct
(422) |
Nov
(554) |
Dec
(162) |
2004 |
Jan
(217) |
Feb
(353) |
Mar
(228) |
Apr
(407) |
May
(211) |
Jun
(270) |
Jul
(264) |
Aug
(198) |
Sep
(268) |
Oct
(227) |
Nov
(118) |
Dec
(47) |
2005 |
Jan
(207) |
Feb
(243) |
Mar
(297) |
Apr
(197) |
May
(281) |
Jun
(166) |
Jul
(164) |
Aug
(92) |
Sep
(155) |
Oct
(196) |
Nov
(189) |
Dec
(114) |
2006 |
Jan
(129) |
Feb
(219) |
Mar
(274) |
Apr
(213) |
May
(245) |
Jun
(220) |
Jul
(376) |
Aug
(347) |
Sep
(179) |
Oct
(493) |
Nov
(448) |
Dec
(339) |
2007 |
Jan
(304) |
Feb
(273) |
Mar
(237) |
Apr
(186) |
May
(215) |
Jun
(320) |
Jul
(229) |
Aug
(313) |
Sep
(331) |
Oct
(279) |
Nov
(347) |
Dec
(266) |
2008 |
Jan
(332) |
Feb
(280) |
Mar
(203) |
Apr
(277) |
May
(301) |
Jun
(356) |
Jul
(292) |
Aug
(203) |
Sep
(277) |
Oct
(142) |
Nov
(210) |
Dec
(239) |
2009 |
Jan
(250) |
Feb
(193) |
Mar
(174) |
Apr
(183) |
May
(342) |
Jun
(230) |
Jul
(292) |
Aug
(161) |
Sep
(204) |
Oct
(280) |
Nov
(281) |
Dec
(175) |
2010 |
Jan
(113) |
Feb
(106) |
Mar
(199) |
Apr
(166) |
May
(298) |
Jun
(147) |
Jul
(175) |
Aug
(192) |
Sep
(71) |
Oct
(79) |
Nov
(58) |
Dec
(55) |
2011 |
Jan
(83) |
Feb
(169) |
Mar
(142) |
Apr
(207) |
May
(311) |
Jun
(183) |
Jul
(218) |
Aug
(190) |
Sep
(158) |
Oct
(197) |
Nov
(93) |
Dec
(74) |
2012 |
Jan
(92) |
Feb
(50) |
Mar
(64) |
Apr
(45) |
May
(100) |
Jun
(70) |
Jul
(3) |
Aug
(1) |
Sep
(2) |
Oct
(5) |
Nov
(7) |
Dec
(4) |
2013 |
Jan
(6) |
Feb
(2) |
Mar
(2) |
Apr
(4) |
May
(3) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
2014 |
Jan
(2) |
Feb
(2) |
Mar
(2) |
Apr
(3) |
May
(3) |
Jun
(1) |
Jul
|
Aug
(4) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(1) |
Dec
(1) |
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
(1) |
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
2017 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <svn...@os...> - 2012-05-24 02:39:13
|
Author: bencaradocdavies Date: 2012-05-23 19:39:06 -0700 (Wed, 23 May 2012) New Revision: 38746 Added: trunk/modules/library/data/src/test/java/org/ trunk/modules/library/data/src/test/java/org/geotools/ trunk/modules/library/data/src/test/java/org/geotools/data/ trunk/modules/library/data/src/test/java/org/geotools/data/store/ trunk/modules/library/data/src/test/java/org/geotools/data/store/ContentFeatureSourcePagingTest.java Modified: trunk/modules/library/data/src/main/java/org/geotools/data/store/ContentFeatureSource.java trunk/modules/ogc/net.opengis.wfs/src/net/opengis/wfs20/impl/GetFeatureTypeImpl.java Log: GEOS-5085: WFS 2.0 paging returns wrong features for startindex=0 Modified: trunk/modules/library/data/src/main/java/org/geotools/data/store/ContentFeatureSource.java =================================================================== --- trunk/modules/library/data/src/main/java/org/geotools/data/store/ContentFeatureSource.java 2012-05-20 14:24:21 UTC (rev 38745) +++ trunk/modules/library/data/src/main/java/org/geotools/data/store/ContentFeatureSource.java 2012-05-24 02:39:06 UTC (rev 38746) @@ -547,10 +547,10 @@ query = resolvePropertyNames(query); // see if we need to enable native sorting in order to support stable paging - final int offset = query.getStartIndex() != null ? query.getStartIndex() : 0; - if(offset > 0 & query.getSortBy() == null) { + if (query.getStartIndex() != null + && (query.getSortBy() == null || query.getSortBy().length == 0)) { Query dq = new Query(query); - dq.setSortBy(new SortBy[] {SortBy.NATURAL_ORDER}); + dq.setSortBy(new SortBy[] { SortBy.NATURAL_ORDER }); query = dq; } @@ -601,6 +601,7 @@ // offset + int offset = query.getStartIndex() != null ? query.getStartIndex() : 0; if( !canOffset() && offset > 0 ) { // skip the first n records for(int i = 0; i < offset && reader.hasNext(); i++) { Added: trunk/modules/library/data/src/test/java/org/geotools/data/store/ContentFeatureSourcePagingTest.java =================================================================== --- trunk/modules/library/data/src/test/java/org/geotools/data/store/ContentFeatureSourcePagingTest.java (rev 0) +++ trunk/modules/library/data/src/test/java/org/geotools/data/store/ContentFeatureSourcePagingTest.java 2012-05-24 02:39:06 UTC (rev 38746) @@ -0,0 +1,447 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2012, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + +package org.geotools.data.store; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.NoSuchElementException; + +import org.geotools.data.DataStore; +import org.geotools.data.FeatureReader; +import org.geotools.data.Query; +import org.geotools.data.simple.SimpleFeatureCollection; +import org.geotools.data.simple.SimpleFeatureIterator; +import org.geotools.data.simple.SimpleFeatureReader; +import org.geotools.feature.NameImpl; +import org.geotools.feature.simple.SimpleFeatureBuilder; +import org.geotools.feature.simple.SimpleFeatureTypeBuilder; +import org.geotools.geometry.jts.ReferencedEnvelope; +import org.junit.Assert; +import org.junit.Test; +import org.opengis.feature.simple.SimpleFeature; +import org.opengis.feature.simple.SimpleFeatureType; +import org.opengis.feature.type.Name; +import org.opengis.filter.sort.SortBy; + +/** + * Test the paging behaviour of {@link ContentFeatureSource}. To establish inter-page consistency, + * if no sorting order is specified in the query, the feature source should impose natural sorting. + * + * @author Ben Caradoc-Davies (CSIRO Earth Science and Resource Engineering) + */ +public class ContentFeatureSourcePagingTest { + + /** + * Mock feature type name. + */ + private static final Name TYPENAME = new NameImpl("Mock"); + + /** + * Mock feature type. + */ + private static final SimpleFeatureType TYPE = buildType(); + + /** + * The list of features on which paging is tested. + */ + @SuppressWarnings("serial") + private static final List<SimpleFeature> FEATURES = new ArrayList<SimpleFeature>() { + { + add(buildFeature("mock.3")); + add(buildFeature("mock.1")); + add(buildFeature("mock.2")); + } + }; + + /** + * Test that the default query returns all features unsorted. + */ + @Test + public void defaultFeatures() { + Query query = new Query(); + List<SimpleFeature> features = readFeatures(query); + Assert.assertEquals(3, features.size()); + Assert.assertEquals("mock.3", features.get(0).getID()); + Assert.assertEquals("mock.1", features.get(1).getID()); + Assert.assertEquals("mock.2", features.get(2).getID()); + } + + /** + * Test natural sorting. + */ + @Test + public void naturalSortedFeatures() { + Query query = new Query(); + query.setSortBy(new SortBy[] { SortBy.NATURAL_ORDER }); + List<SimpleFeature> features = readFeatures(query); + Assert.assertEquals(3, features.size()); + Assert.assertEquals("mock.1", features.get(0).getID()); + Assert.assertEquals("mock.2", features.get(1).getID()); + Assert.assertEquals("mock.3", features.get(2).getID()); + } + + /** + * Test reverse sorting. + */ + @Test + public void reverseSortedFeatures() { + Query query = new Query(); + query.setSortBy(new SortBy[] { SortBy.REVERSE_ORDER }); + List<SimpleFeature> features = readFeatures(query); + Assert.assertEquals(3, features.size()); + Assert.assertEquals("mock.3", features.get(0).getID()); + Assert.assertEquals("mock.2", features.get(1).getID()); + Assert.assertEquals("mock.1", features.get(2).getID()); + } + + /** + * Test the first page of one feature per page. + */ + @Test + public void oneFeatureFirstPage() { + Query query = new Query(); + query.setMaxFeatures(1); + query.setStartIndex(0); + List<SimpleFeature> features = readFeatures(query); + Assert.assertEquals(1, features.size()); + Assert.assertEquals("mock.1", features.get(0).getID()); + } + + /** + * Test the second page of one feature per page. + */ + @Test + public void oneFeatureSecondPage() { + Query query = new Query(); + query.setMaxFeatures(1); + query.setStartIndex(1); + List<SimpleFeature> features = readFeatures(query); + Assert.assertEquals(1, features.size()); + Assert.assertEquals("mock.2", features.get(0).getID()); + } + + /** + * Test the third page of one feature per page. + */ + @Test + public void oneFeatureThirdPage() { + Query query = new Query(); + query.setMaxFeatures(1); + query.setStartIndex(2); + List<SimpleFeature> features = readFeatures(query); + Assert.assertEquals(1, features.size()); + Assert.assertEquals("mock.3", features.get(0).getID()); + } + + /** + * Test the first page of one feature per page with natural sorting. + */ + @Test + public void naturalSortedOneFeatureFirstPage() { + Query query = new Query(); + query.setSortBy(new SortBy[] { SortBy.NATURAL_ORDER }); + query.setMaxFeatures(1); + query.setStartIndex(0); + List<SimpleFeature> features = readFeatures(query); + Assert.assertEquals(1, features.size()); + Assert.assertEquals("mock.1", features.get(0).getID()); + } + + /** + * Test the second page of one feature per page with natural sorting. + */ + @Test + public void naturalSortedOneFeatureSecondPage() { + Query query = new Query(); + query.setSortBy(new SortBy[] { SortBy.NATURAL_ORDER }); + query.setMaxFeatures(1); + query.setStartIndex(1); + List<SimpleFeature> features = readFeatures(query); + Assert.assertEquals(1, features.size()); + Assert.assertEquals("mock.2", features.get(0).getID()); + } + + /** + * Test the third page of one feature per page with natural sorting. + */ + @Test + public void naturalSortedOneFeatureThirdPage() { + Query query = new Query(); + query.setSortBy(new SortBy[] { SortBy.NATURAL_ORDER }); + query.setMaxFeatures(1); + query.setStartIndex(2); + List<SimpleFeature> features = readFeatures(query); + Assert.assertEquals(1, features.size()); + Assert.assertEquals("mock.3", features.get(0).getID()); + } + + /** + * Test the first page of one feature per page with reverse sorting. + */ + @Test + public void reverseSortedOneFeatureFirstPage() { + Query query = new Query(); + query.setSortBy(new SortBy[] { SortBy.REVERSE_ORDER }); + query.setMaxFeatures(1); + query.setStartIndex(0); + List<SimpleFeature> features = readFeatures(query); + Assert.assertEquals(1, features.size()); + Assert.assertEquals("mock.3", features.get(0).getID()); + } + + /** + * Test the second page of one feature per page with reverse sorting. + */ + @Test + public void reverseSortedOneFeatureSecondPage() { + Query query = new Query(); + query.setSortBy(new SortBy[] { SortBy.REVERSE_ORDER }); + query.setMaxFeatures(1); + query.setStartIndex(1); + List<SimpleFeature> features = readFeatures(query); + Assert.assertEquals(1, features.size()); + Assert.assertEquals("mock.2", features.get(0).getID()); + } + + /** + * Test the third page of one feature per page with reverse sorting. + */ + @Test + public void reverseSortedOneFeatureThirdPage() { + Query query = new Query(); + query.setSortBy(new SortBy[] { SortBy.REVERSE_ORDER }); + query.setMaxFeatures(1); + query.setStartIndex(2); + List<SimpleFeature> features = readFeatures(query); + Assert.assertEquals(1, features.size()); + Assert.assertEquals("mock.1", features.get(0).getID()); + } + + /** + * Test the first page of two features per page. + */ + @Test + public void twoFeaturesFirstPage() { + Query query = new Query(); + query.setMaxFeatures(2); + query.setStartIndex(0); + List<SimpleFeature> features = readFeatures(query); + Assert.assertEquals(2, features.size()); + Assert.assertEquals("mock.1", features.get(0).getID()); + Assert.assertEquals("mock.2", features.get(1).getID()); + } + + /** + * Test the page of two features per page that should contain the last two features. + */ + @Test + public void twoFeaturesLastPage() { + Query query = new Query(); + query.setMaxFeatures(2); + query.setStartIndex(1); + List<SimpleFeature> features = readFeatures(query); + Assert.assertEquals(2, features.size()); + Assert.assertEquals("mock.2", features.get(0).getID()); + Assert.assertEquals("mock.3", features.get(1).getID()); + } + + /** + * Test a page of two features that only contains one because startindex is too close to the + * end. + */ + @Test + public void twoFeaturesReturnOne() { + Query query = new Query(); + query.setMaxFeatures(2); + query.setStartIndex(2); + List<SimpleFeature> features = readFeatures(query); + Assert.assertEquals(1, features.size()); + Assert.assertEquals("mock.3", features.get(0).getID()); + } + + /** + * Test a single page with three features. + */ + @Test + public void threeFeatures() { + Query query = new Query(); + query.setMaxFeatures(3); + query.setStartIndex(0); + List<SimpleFeature> features = readFeatures(query); + Assert.assertEquals(3, features.size()); + Assert.assertEquals("mock.1", features.get(0).getID()); + Assert.assertEquals("mock.2", features.get(1).getID()); + Assert.assertEquals("mock.3", features.get(2).getID()); + } + + /** + * Read all the test features into a list, using the specified query. + */ + private List<SimpleFeature> readFeatures(Query query) { + List<SimpleFeature> features = new ArrayList<SimpleFeature>(); + DataStore store = new MockContentDataStore(); + SimpleFeatureCollection collection; + try { + collection = store.getFeatureSource(TYPENAME).getFeatures(query); + } catch (IOException e) { + throw new RuntimeException(e); + } + for (SimpleFeatureIterator iterator = collection.features(); iterator.hasNext();) { + features.add(iterator.next()); + } + return features; + } + + /** + * Build the test type. + */ + private static SimpleFeatureType buildType() { + SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); + builder.setName(TYPENAME); + return builder.buildFeatureType(); + } + + /** + * Build a test feature with the specified id. + */ + private static SimpleFeature buildFeature(String id) { + SimpleFeatureBuilder builder = new SimpleFeatureBuilder(TYPE); + return builder.buildFeature(id); + } + + /** + * {@link ContentDataStore} for the test features. + * + */ + private static class MockContentDataStore extends ContentDataStore { + + /** + * @see org.geotools.data.store.ContentDataStore#createTypeNames() + */ + @SuppressWarnings("serial") + @Override + protected List<Name> createTypeNames() throws IOException { + return new ArrayList<Name>() { + { + add(TYPENAME); + } + }; + } + + /** + * @see org.geotools.data.store.ContentDataStore#createFeatureSource(org.geotools.data.store.ContentEntry) + */ + @Override + protected ContentFeatureSource createFeatureSource(ContentEntry entry) throws IOException { + return new MockContentFeatureSource(entry, null); + } + + } + + /** + * {@link ContentFeatureSource} that returns the test features. + */ + @SuppressWarnings("unchecked") + private static class MockContentFeatureSource extends ContentFeatureSource { + + public MockContentFeatureSource(ContentEntry entry, Query query) { + super(entry, query); + } + + /** + * Not implemented. + */ + @Override + protected ReferencedEnvelope getBoundsInternal(Query query) throws IOException { + throw new UnsupportedOperationException(); + } + + /** + * Not implemented. + */ + @Override + protected int getCountInternal(Query query) throws IOException { + throw new UnsupportedOperationException(); + } + + /** + * @see org.geotools.data.store.ContentFeatureSource#getReaderInternal(org.geotools.data.Query) + */ + @Override + protected FeatureReader<SimpleFeatureType, SimpleFeature> getReaderInternal(Query query) + throws IOException { + return new MockSimpleFeatureReader(); + } + + /** + * @see org.geotools.data.store.ContentFeatureSource#buildFeatureType() + */ + @Override + protected SimpleFeatureType buildFeatureType() throws IOException { + return TYPE; + } + + } + + /** + * Decorate the list of test features as a {@link SimpleFeatureReader}. + */ + private static class MockSimpleFeatureReader implements SimpleFeatureReader { + + /** + * Index of the next test feature to be returned. + */ + private int index = 0; + + /** + * @see org.geotools.data.FeatureReader#getFeatureType() + */ + @Override + public SimpleFeatureType getFeatureType() { + return TYPE; + } + + /** + * @see org.geotools.data.FeatureReader#next() + */ + @Override + public SimpleFeature next() throws IOException, IllegalArgumentException, + NoSuchElementException { + return FEATURES.get(index++); + } + + /** + * @see org.geotools.data.FeatureReader#hasNext() + */ + @Override + public boolean hasNext() throws IOException { + return index < FEATURES.size(); + } + + /** + * @see org.geotools.data.FeatureReader#close() + */ + @Override + public void close() throws IOException { + // ignored + } + + } + +} Property changes on: trunk/modules/library/data/src/test/java/org/geotools/data/store/ContentFeatureSourcePagingTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id URL Added: svn:eol-style + native Modified: trunk/modules/ogc/net.opengis.wfs/src/net/opengis/wfs20/impl/GetFeatureTypeImpl.java =================================================================== --- trunk/modules/ogc/net.opengis.wfs/src/net/opengis/wfs20/impl/GetFeatureTypeImpl.java 2012-05-20 14:24:21 UTC (rev 38745) +++ trunk/modules/ogc/net.opengis.wfs/src/net/opengis/wfs20/impl/GetFeatureTypeImpl.java 2012-05-24 02:39:06 UTC (rev 38746) @@ -240,7 +240,7 @@ * @generated * @ordered */ - protected static final BigInteger START_INDEX_EDEFAULT = new BigInteger("0"); + protected static final BigInteger START_INDEX_EDEFAULT = null; /** * The cached value of the '{@link #getStartIndex() <em>Start Index</em>}' attribute. |
From: <svn...@os...> - 2012-05-20 14:24:28
|
Author: jive Date: 2012-05-20 07:24:21 -0700 (Sun, 20 May 2012) New Revision: 38745 Modified: trunk/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2EmptyTestSetup.java Log: Thanks for fix Brett, clear tables from previous run as part of H2EmptyTest see GEOT-4146 for details Modified: trunk/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2EmptyTestSetup.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2EmptyTestSetup.java 2012-05-18 06:05:12 UTC (rev 38744) +++ trunk/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2EmptyTestSetup.java 2012-05-20 14:24:21 UTC (rev 38745) @@ -20,7 +20,6 @@ import org.geotools.jdbc.JDBCEmptyTestSetup; /** - * * * @source $URL$ */ @@ -33,20 +32,16 @@ @Override protected void setUpDataStore(JDBCDataStore dataStore) { super.setUpDataStore(dataStore); - - dataStore.setDatabaseSchema( null ); } - + @Override protected void createEmptyTable() throws Exception { - run("DELETE FROM geometry_columns WHERE f_table_name = 'empty'"); - run( "CREATE TABLE \"empty\" (id int,geom blob)"); - + run( "CREATE TABLE \"geotools\".\"empty\" (id int, geom blob)"); } @Override protected void dropEmptyTable() throws Exception { - runSafe( "DROP TABLE \"empty\"" ); + runSafe( "DELETE FROM geometry_columns WHERE f_table_name = 'empty'" ); + runSafe( "DROP TABLE \"geotools\".\"empty\"" ); } - } |
From: <svn...@os...> - 2012-05-18 06:05:24
|
Author: aaime Date: 2012-05-17 23:05:12 -0700 (Thu, 17 May 2012) New Revision: 38744 Modified: trunk/modules/library/coverage/src/test/java/org/geotools/image/ImageWorkerTest.java Log: Make the test work on Jody's OSX (it apparently worked fine on Justin's one?) Modified: trunk/modules/library/coverage/src/test/java/org/geotools/image/ImageWorkerTest.java =================================================================== --- trunk/modules/library/coverage/src/test/java/org/geotools/image/ImageWorkerTest.java 2012-05-17 17:33:16 UTC (rev 38743) +++ trunk/modules/library/coverage/src/test/java/org/geotools/image/ImageWorkerTest.java 2012-05-18 06:05:12 UTC (rev 38744) @@ -18,6 +18,8 @@ import static org.junit.Assert.*; +import it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReaderSpi; + import java.awt.Color; import java.awt.Transparency; import java.awt.color.ColorSpace; @@ -41,6 +43,8 @@ import java.util.zip.GZIPInputStream; import javax.imageio.ImageIO; +import javax.imageio.ImageReader; +import javax.imageio.stream.ImageInputStream; import javax.media.jai.ImageLayout; import javax.media.jai.JAI; import javax.media.jai.RasterFactory; @@ -56,6 +60,7 @@ import org.junit.Test; import com.sun.media.imageioimpl.common.PackageUtil; +import com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader; /** @@ -401,7 +406,10 @@ InputStream gzippedStream = ImageWorkerTest.class.getResource("test-data/sf-sfdem.tif.gz").openStream(); GZIPInputStream is = new GZIPInputStream(gzippedStream); try { - BufferedImage bi = ImageIO.read(is); + ImageInputStream iis = ImageIO.createImageInputStream(is); + ImageReader reader = new TIFFImageReaderSpi().createReaderInstance(iis); + reader.setInput(iis); + BufferedImage bi = reader.read(0); IndexColorModel icm = (IndexColorModel) bi.getColorModel(); assertEquals(65536, icm.getMapSize()); |
From: <svn...@os...> - 2012-05-17 17:33:27
|
Author: jdeolive Date: 2012-05-17 10:33:16 -0700 (Thu, 17 May 2012) New Revision: 38743 Modified: branches/2.7.x/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBC3DTest.java branches/2.7.x/modules/library/main/src/main/java/org/geotools/geometry/jts/LiteCoordinateSequenceFactory.java branches/2.7.x/modules/plugin/jdbc/jdbc-oracle/src/main/java/org/geotools/data/oracle/sdo/Coordinates.java branches/2.7.x/modules/plugin/jdbc/jdbc-oracle/src/test/java/org/geotools/data/oracle/Oracle3DTest.java branches/2.7.x/modules/plugin/jdbc/jdbc-oracle/src/test/java/org/geotools/data/oracle/OracleTestSetup.java Log: GEOT-4140, Fix for Oracle not handling read/write of 3D Polygons correctly Modified: branches/2.7.x/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBC3DTest.java =================================================================== --- branches/2.7.x/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBC3DTest.java 2012-05-17 17:01:52 UTC (rev 38742) +++ branches/2.7.x/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBC3DTest.java 2012-05-17 17:33:16 UTC (rev 38743) @@ -16,13 +16,17 @@ */ package org.geotools.jdbc; +import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import org.geotools.data.DataUtilities; import org.geotools.data.DefaultQuery; 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; @@ -32,6 +36,7 @@ import org.geotools.factory.Hints; import org.geotools.feature.FeatureCollection; import org.geotools.feature.simple.SimpleFeatureBuilder; +import org.geotools.geometry.jts.LiteCoordinateSequence; import org.geotools.geometry.jts.LiteCoordinateSequenceFactory; import org.geotools.geometry.jts.ReferencedEnvelope; import org.geotools.referencing.CRS; @@ -43,6 +48,7 @@ import org.opengis.referencing.crs.CoordinateReferenceSystem; import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.CoordinateSequenceFactory; import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryFactory; @@ -55,12 +61,12 @@ * Tests the ability of the datastore to cope with 3D data * * @author Andrea Aime - OpenGeo + * @author Martin Davis - OpenGeo * - * * @source $URL$ */ public abstract class JDBC3DTest extends JDBCTestSupport { - + protected static final String LINE3D = "line3d"; protected static final String POLY3D = "poly3d"; @@ -78,12 +84,10 @@ protected SimpleFeatureType poly3DType; protected SimpleFeatureType line3DType; - + protected CoordinateReferenceSystem epsg4326; protected abstract JDBC3DTestSetup createTestSetup(); - - @Override protected void connect() throws Exception { @@ -96,22 +100,21 @@ poly3DType = DataUtilities.createType(dataStore.getNamespaceURI() + "." + tname(POLY3D), aname(ID) + ":0," + aname(GEOM) + ":Polygon:srid=4326," + aname(NAME) + ":String"); poly3DType.getGeometryDescriptor().getUserData().put(Hints.COORDINATE_DIMENSION, 3); - + epsg4326 = CRS.decode("EPSG:4326"); } - protected Integer getNativeSRID() { return new Integer(4326); } - + public void testSchema() throws Exception { SimpleFeatureType schema = dataStore.getSchema(tname(LINE3D)); CoordinateReferenceSystem crs = schema.getGeometryDescriptor() .getCoordinateReferenceSystem(); assertEquals(new Integer(4326), CRS.lookupEpsgCode(crs, false)); - assertEquals(getNativeSRID(), schema.getGeometryDescriptor().getUserData().get( - JDBCDataStore.JDBC_NATIVE_SRID)); + assertEquals(getNativeSRID(), + schema.getGeometryDescriptor().getUserData().get(JDBCDataStore.JDBC_NATIVE_SRID)); } public void testReadPoint() throws Exception { @@ -124,7 +127,7 @@ } public void testReadLine() throws Exception { - SimpleFeatureCollection fc = dataStore.getFeatureSource(tname(LINE3D)).getFeatures(); + SimpleFeatureCollection fc = dataStore.getFeatureSource(tname(LINE3D)).getFeatures(); SimpleFeatureIterator fr = fc.features(); assertTrue(fr.hasNext()); LineString ls = (LineString) fr.next().getDefaultGeometry(); @@ -148,40 +151,82 @@ "l3" }, null); // insert it - SimpleFeatureStore fs = (SimpleFeatureStore) dataStore - .getFeatureSource(tname(LINE3D), Transaction.AUTO_COMMIT); + SimpleFeatureStore fs = (SimpleFeatureStore) dataStore.getFeatureSource(tname(LINE3D), + Transaction.AUTO_COMMIT); List<FeatureId> fids = fs.addFeatures(DataUtilities.collection(newFeature)); // retrieve it back - SimpleFeatureIterator fi = fs.getFeatures(FF.id(new HashSet<FeatureId>(fids))) - .features(); + SimpleFeatureIterator fi = fs.getFeatures(FF.id(new HashSet<FeatureId>(fids))).features(); assertTrue(fi.hasNext()); SimpleFeature f = fi.next(); assertTrue(ls.equals((Geometry) f.getDefaultGeometry())); fi.close(); } + public void testCreateSchemaAndInsertPolyTriangle() throws Exception { + LiteCoordinateSequenceFactory csf = new LiteCoordinateSequenceFactory(); + GeometryFactory gf = new GeometryFactory(csf); + + LinearRing shell = gf.createLinearRing(csf.create(new double[] { 0, 0, 99, 1, 0, 33, 1, 1, + 66, 0, 0, 99 }, 3)); + Polygon poly = gf.createPolygon(shell, null); + + checkCreateSchemaAndInsert(poly); + } + + public void testCreateSchemaAndInsertPolyRectangle() throws Exception { + LiteCoordinateSequenceFactory csf = new LiteCoordinateSequenceFactory(); + GeometryFactory gf = new GeometryFactory(csf); + + LinearRing shell = gf.createLinearRing(csf.create(new double[] { 0, 0, 99, 1, 0, 33, 1, 1, + 66, 0, 1, 33, 0, 0, 99 }, 3)); + Polygon poly = gf.createPolygon(shell, null); + + checkCreateSchemaAndInsert(poly); + } + + public void testCreateSchemaAndInsertPolyRectangleWithHole() throws Exception { + LiteCoordinateSequenceFactory csf = new LiteCoordinateSequenceFactory(); + GeometryFactory gf = new GeometryFactory(csf); + + LinearRing shell = gf.createLinearRing(csf.create(new double[] { 0, 0, 99, 10, 0, 33, 10, + 10, 66, 0, 10, 66, 0, 0, 99 }, 3)); + LinearRing hole = gf.createLinearRing(csf.create(new double[] { 2, 2, 99, 3, 2, 44, 3, 3, + 99, 2, 3, 99, 2, 2, 99 }, 3)); + Polygon poly = gf.createPolygon(shell, new LinearRing[] { hole }); + + checkCreateSchemaAndInsert(poly); + } + + public void testCreateSchemaAndInsertPolyWithHoleCW() throws Exception { + LiteCoordinateSequenceFactory csf = new LiteCoordinateSequenceFactory(); + GeometryFactory gf = new GeometryFactory(csf); + + LinearRing shell = gf.createLinearRing(csf.create(new double[] { 1, 1, 99, 10, 1, 33, + 10, 10, 66, 1, 10, 66, 1, 1, 99 }, 3)); + LinearRing hole = gf.createLinearRing(csf.create(new double[] { 2, 2, 99, 8, 2, 44, 8, 8, + 99, 2, 8, 99, 2, 2, 99 }, 3)); + Polygon poly = gf.createPolygon(shell, new LinearRing[] { hole }); + + checkCreateSchemaAndInsert(poly); + } + /** - * Creates the polygon schema and then inserts a 3D geometry into the - * datastore and retrieves it back to make sure 3d data is really handled as - * such + * Creates the polygon schema, inserts a 3D geometry into the datastore, + * and retrieves it back to make sure 3d data is preserved. * * @throws Exception */ - public void testCreateSchemaAndInsert() throws Exception { + private void checkCreateSchemaAndInsert(Geometry poly) throws Exception { dataStore.createSchema(poly3DType); SimpleFeatureType actualSchema = dataStore.getSchema(tname(POLY3D)); assertFeatureTypesEqual(poly3DType, actualSchema); - assertEquals(getNativeSRID(), actualSchema.getGeometryDescriptor().getUserData().get( - JDBCDataStore.JDBC_NATIVE_SRID)); + assertEquals( + getNativeSRID(), + actualSchema.getGeometryDescriptor().getUserData() + .get(JDBCDataStore.JDBC_NATIVE_SRID)); - // build a 3d polygon (ordinates in ccw order) - GeometryFactory gf = new GeometryFactory(); - LinearRing shell = gf.createLinearRing(new Coordinate[] { new Coordinate(0, 0, 0), - new Coordinate(1, 1, 1), new Coordinate(1, 0, 1), new Coordinate(0, 0, 0) }); - Polygon poly = gf.createPolygon(shell, null); - - // insert it + // insert the feature FeatureWriter<SimpleFeatureType, SimpleFeature> fw = dataStore.getFeatureWriterAppend( tname(POLY3D), Transaction.AUTO_COMMIT); SimpleFeature f = fw.next(); @@ -191,20 +236,62 @@ fw.write(); fw.close(); - // read id back and compare + // read feature back + + /** + * Use a LiteCoordinateSequence, since this mimics GeoServer behaviour better, + * and it exposes bugs in CoordinateSequence handling. + */ + final Hints hints = new Hints(); + hints.put(Hints.JTS_COORDINATE_SEQUENCE_FACTORY, new LiteCoordinateSequenceFactory()); + Query query = new DefaultQuery(tname(POLY3D)); + query.setHints(hints); + FeatureReader<SimpleFeatureType, SimpleFeature> fr = dataStore.getFeatureReader( - new DefaultQuery(tname(POLY3D)), Transaction.AUTO_COMMIT); + query, Transaction.AUTO_COMMIT); assertTrue(fr.hasNext()); f = fr.next(); - // this unfortunately checks only the first 2d, but at the same time - // a coordinate by coordinate check is not possible since the ring orientation - // can be modified by the store - assertTrue(poly.equals((Geometry) f.getDefaultGeometry())); - + + /** + * Check the geometries are topologically equal. + * Check that the Z values are preserved + */ + Geometry fgeom = (Geometry) f.getDefaultGeometry(); + assertTrue("2D topology does not match", poly.equals(fgeom)); + assertTrue("Z values do not match", hasMatchingZValues(poly, fgeom)); fr.close(); } /** + * Tests whether two geometries have the same Z values for coordinates with identical 2D locations. Requires that each geometry is internally + * location-consistent in Z; that is, if two coordinates are identical in location, then the Z values are equal. This should always be the case + * for valid data. + * + * @param g1 + * @param g2 + * @return true if the geometries are location-equal in Z + */ + private static boolean hasMatchingZValues(Geometry g1, Geometry g2) { + Coordinate[] pt1 = g1.getCoordinates(); + Map<Coordinate, Double> coordZMap = new HashMap<Coordinate, Double>(); + for (int i = 0; i < pt1.length; i++) { + coordZMap.put(pt1[i], pt1[i].z); + } + + Coordinate[] pt2 = g2.getCoordinates(); + + for (int i2 = 0; i2 < pt2.length; i2++) { + Coordinate p2 = pt2[i2]; + double z = coordZMap.get(p2); + boolean isEqualZ = p2.z == z || (Double.isNaN(p2.z) && Double.isNaN(z)); + if (!isEqualZ) + return false; + } + + return true; + } + + /** * Make sure we can properly retrieve the bounds of 3d layers * * @throws Exception @@ -232,11 +319,11 @@ new LiteCoordinateSequenceFactory()); q.setHints(hints); - // check the srs you get is the expected one - FeatureCollection fc = fs.getFeatures(q); - FeatureType fcSchema = fc.getSchema(); + // check the srs you get is the expected one + FeatureCollection fc = fs.getFeatures(q); + FeatureType fcSchema = fc.getSchema(); assertEquals(epsg4326, fcSchema.getCoordinateReferenceSystem()); - assertEquals(epsg4326, fcSchema.getGeometryDescriptor().getCoordinateReferenceSystem()); + assertEquals(epsg4326, fcSchema.getGeometryDescriptor().getCoordinateReferenceSystem()); // build up the reference 2d line, the 3d one is (1 1 0, 2 2 0, 4 2 1, 5 // 1 1) @@ -245,7 +332,8 @@ new Coordinate(5, 1) }); // check feature reader and the schema - FeatureReader<SimpleFeatureType, SimpleFeature> fr = dataStore.getFeatureReader(q, Transaction.AUTO_COMMIT); + FeatureReader<SimpleFeatureType, SimpleFeature> fr = dataStore.getFeatureReader(q, + Transaction.AUTO_COMMIT); assertEquals(epsg4326, fr.getFeatureType().getCoordinateReferenceSystem()); assertEquals(epsg4326, fr.getFeatureType().getGeometryDescriptor() .getCoordinateReferenceSystem()); Modified: branches/2.7.x/modules/library/main/src/main/java/org/geotools/geometry/jts/LiteCoordinateSequenceFactory.java =================================================================== --- branches/2.7.x/modules/library/main/src/main/java/org/geotools/geometry/jts/LiteCoordinateSequenceFactory.java 2012-05-17 17:01:52 UTC (rev 38742) +++ branches/2.7.x/modules/library/main/src/main/java/org/geotools/geometry/jts/LiteCoordinateSequenceFactory.java 2012-05-17 17:33:16 UTC (rev 38743) @@ -41,6 +41,12 @@ * @see com.vividsolutions.jts.geom.CoordinateSequenceFactory#create(com.vividsolutions.jts.geom.CoordinateSequence) */ public CoordinateSequence create(CoordinateSequence coordSeq) { + /** + * If copying a LiteCoordinateSequence, use the copy constructor + * to preserve dimensionality information. + */ + if (coordSeq instanceof LiteCoordinateSequence) + return new LiteCoordinateSequence((LiteCoordinateSequence) coordSeq); return new LiteCoordinateSequence(coordSeq.toCoordinateArray()); } Modified: branches/2.7.x/modules/plugin/jdbc/jdbc-oracle/src/main/java/org/geotools/data/oracle/sdo/Coordinates.java =================================================================== --- branches/2.7.x/modules/plugin/jdbc/jdbc-oracle/src/main/java/org/geotools/data/oracle/sdo/Coordinates.java 2012-05-17 17:01:52 UTC (rev 38742) +++ branches/2.7.x/modules/plugin/jdbc/jdbc-oracle/src/main/java/org/geotools/data/oracle/sdo/Coordinates.java 2012-05-17 17:33:16 UTC (rev 38743) @@ -26,6 +26,7 @@ import com.vividsolutions.jts.geom.CoordinateList; import com.vividsolutions.jts.geom.CoordinateSequence; import com.vividsolutions.jts.geom.CoordinateSequenceFactory; +import com.vividsolutions.jts.geom.CoordinateSequences; import com.vividsolutions.jts.geom.PrecisionModel; @@ -172,15 +173,13 @@ return c; } - Coordinate[] array = new Coordinate[toIndex - fromIndex]; - int index = 0; - for(int i = fromIndex; i < toIndex; i++, index++) { - array[index] = sequence.getCoordinate(i); - } + // handle coordinate sequence dimension correctly + int size = toIndex - fromIndex; + CoordinateSequence newSeq = factory.create(size, sequence.getDimension()); + CoordinateSequences.copy(sequence, fromIndex, newSeq, 0, size); + return newSeq; + } - return factory.create(array); - } - /** * DOCUMENT ME! * @@ -213,11 +212,11 @@ return c; } else // else CoordinateSequence - { - CoordinateList list = new CoordinateList(sequence.toCoordinateArray()); - Collections.reverse(list); - - return factory.create(list.toCoordinateArray()); + { + // handle coordinate sequence dimension correctly + CoordinateSequence revSeq = factory.create(sequence); + CoordinateSequences.reverse(revSeq); + return revSeq; } } Modified: branches/2.7.x/modules/plugin/jdbc/jdbc-oracle/src/test/java/org/geotools/data/oracle/Oracle3DTest.java =================================================================== --- branches/2.7.x/modules/plugin/jdbc/jdbc-oracle/src/test/java/org/geotools/data/oracle/Oracle3DTest.java 2012-05-17 17:01:52 UTC (rev 38742) +++ branches/2.7.x/modules/plugin/jdbc/jdbc-oracle/src/test/java/org/geotools/data/oracle/Oracle3DTest.java 2012-05-17 17:33:16 UTC (rev 38743) @@ -26,5 +26,13 @@ return new Oracle3DTestSetup(); } + /** + * This test is overriden to disable it, since it is a known issue. + * The issue is that the Oracle driver writes Rectangles as Oracle SDO Rectangle structures, which don't preserve 3D + * See GEOT-4133 + */ + @Override + public void testCreateSchemaAndInsertPolyRectangle() throws Exception { + } } Modified: branches/2.7.x/modules/plugin/jdbc/jdbc-oracle/src/test/java/org/geotools/data/oracle/OracleTestSetup.java =================================================================== --- branches/2.7.x/modules/plugin/jdbc/jdbc-oracle/src/test/java/org/geotools/data/oracle/OracleTestSetup.java 2012-05-17 17:01:52 UTC (rev 38742) +++ branches/2.7.x/modules/plugin/jdbc/jdbc-oracle/src/test/java/org/geotools/data/oracle/OracleTestSetup.java 2012-05-17 17:33:16 UTC (rev 38743) @@ -54,7 +54,8 @@ fixture.put("host", "192.168.1.200"); fixture.put("port", "1521"); fixture.put("database", "xe"); - fixture.put("username", "geoserver"); + fixture.put("usernamegit ", "geoserver"); + fixture.put("user", "geoserver"); fixture.put("password", "postgis"); fixture.put("dbtype", "Oracle" ); return fixture; |
From: <svn...@os...> - 2012-05-17 17:02:07
|
Author: mdavis Date: 2012-05-17 10:01:52 -0700 (Thu, 17 May 2012) New Revision: 38742 Modified: trunk/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBC3DTest.java trunk/modules/library/main/src/main/java/org/geotools/geometry/jts/LiteCoordinateSequenceFactory.java trunk/modules/plugin/jdbc/jdbc-oracle/src/main/java/org/geotools/data/oracle/sdo/Coordinates.java trunk/modules/plugin/jdbc/jdbc-oracle/src/test/java/org/geotools/data/oracle/Oracle3DTest.java trunk/modules/plugin/jdbc/jdbc-oracle/src/test/java/org/geotools/data/oracle/OracleTestSetup.java Log: GEOT-4140, Fix for Oracle not handling read/write of 3D Polygons correctly Modified: trunk/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBC3DTest.java =================================================================== --- trunk/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBC3DTest.java 2012-05-16 14:05:34 UTC (rev 38741) +++ trunk/modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBC3DTest.java 2012-05-17 17:01:52 UTC (rev 38742) @@ -16,13 +16,17 @@ */ package org.geotools.jdbc; +import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import org.geotools.data.DataUtilities; import org.geotools.data.DefaultQuery; 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; @@ -32,6 +36,7 @@ import org.geotools.factory.Hints; import org.geotools.feature.FeatureCollection; import org.geotools.feature.simple.SimpleFeatureBuilder; +import org.geotools.geometry.jts.LiteCoordinateSequence; import org.geotools.geometry.jts.LiteCoordinateSequenceFactory; import org.geotools.geometry.jts.ReferencedEnvelope; import org.geotools.referencing.CRS; @@ -43,6 +48,7 @@ import org.opengis.referencing.crs.CoordinateReferenceSystem; import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.CoordinateSequenceFactory; import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryFactory; @@ -55,13 +61,14 @@ * Tests the ability of the datastore to cope with 3D data * * @author Andrea Aime - OpenGeo - * - * - * + * @author Martin Davis - OpenGeo + * + * + * * @source $URL$ */ public abstract class JDBC3DTest extends JDBCTestSupport { - + protected static final String LINE3D = "line3d"; protected static final String POLY3D = "poly3d"; @@ -79,12 +86,10 @@ protected SimpleFeatureType poly3DType; protected SimpleFeatureType line3DType; - + protected CoordinateReferenceSystem epsg4326; protected abstract JDBC3DTestSetup createTestSetup(); - - @Override protected void connect() throws Exception { @@ -97,22 +102,21 @@ poly3DType = DataUtilities.createType(dataStore.getNamespaceURI() + "." + tname(POLY3D), aname(ID) + ":0," + aname(GEOM) + ":Polygon:srid=4326," + aname(NAME) + ":String"); poly3DType.getGeometryDescriptor().getUserData().put(Hints.COORDINATE_DIMENSION, 3); - + epsg4326 = CRS.decode("EPSG:4326"); } - protected Integer getNativeSRID() { return new Integer(4326); } - + public void testSchema() throws Exception { SimpleFeatureType schema = dataStore.getSchema(tname(LINE3D)); CoordinateReferenceSystem crs = schema.getGeometryDescriptor() .getCoordinateReferenceSystem(); assertEquals(new Integer(4326), CRS.lookupEpsgCode(crs, false)); - assertEquals(getNativeSRID(), schema.getGeometryDescriptor().getUserData().get( - JDBCDataStore.JDBC_NATIVE_SRID)); + assertEquals(getNativeSRID(), + schema.getGeometryDescriptor().getUserData().get(JDBCDataStore.JDBC_NATIVE_SRID)); } public void testReadPoint() throws Exception { @@ -125,7 +129,7 @@ } public void testReadLine() throws Exception { - SimpleFeatureCollection fc = dataStore.getFeatureSource(tname(LINE3D)).getFeatures(); + SimpleFeatureCollection fc = dataStore.getFeatureSource(tname(LINE3D)).getFeatures(); SimpleFeatureIterator fr = fc.features(); assertTrue(fr.hasNext()); LineString ls = (LineString) fr.next().getDefaultGeometry(); @@ -149,40 +153,82 @@ "l3" }, null); // insert it - SimpleFeatureStore fs = (SimpleFeatureStore) dataStore - .getFeatureSource(tname(LINE3D), Transaction.AUTO_COMMIT); + SimpleFeatureStore fs = (SimpleFeatureStore) dataStore.getFeatureSource(tname(LINE3D), + Transaction.AUTO_COMMIT); List<FeatureId> fids = fs.addFeatures(DataUtilities.collection(newFeature)); // retrieve it back - SimpleFeatureIterator fi = fs.getFeatures(FF.id(new HashSet<FeatureId>(fids))) - .features(); + SimpleFeatureIterator fi = fs.getFeatures(FF.id(new HashSet<FeatureId>(fids))).features(); assertTrue(fi.hasNext()); SimpleFeature f = fi.next(); assertTrue(ls.equalsExact((Geometry) f.getDefaultGeometry())); fi.close(); } + public void testCreateSchemaAndInsertPolyTriangle() throws Exception { + LiteCoordinateSequenceFactory csf = new LiteCoordinateSequenceFactory(); + GeometryFactory gf = new GeometryFactory(csf); + + LinearRing shell = gf.createLinearRing(csf.create(new double[] { 0, 0, 99, 1, 0, 33, 1, 1, + 66, 0, 0, 99 }, 3)); + Polygon poly = gf.createPolygon(shell, null); + + checkCreateSchemaAndInsert(poly); + } + + public void testCreateSchemaAndInsertPolyRectangle() throws Exception { + LiteCoordinateSequenceFactory csf = new LiteCoordinateSequenceFactory(); + GeometryFactory gf = new GeometryFactory(csf); + + LinearRing shell = gf.createLinearRing(csf.create(new double[] { 0, 0, 99, 1, 0, 33, 1, 1, + 66, 0, 1, 33, 0, 0, 99 }, 3)); + Polygon poly = gf.createPolygon(shell, null); + + checkCreateSchemaAndInsert(poly); + } + + public void testCreateSchemaAndInsertPolyRectangleWithHole() throws Exception { + LiteCoordinateSequenceFactory csf = new LiteCoordinateSequenceFactory(); + GeometryFactory gf = new GeometryFactory(csf); + + LinearRing shell = gf.createLinearRing(csf.create(new double[] { 0, 0, 99, 10, 0, 33, 10, + 10, 66, 0, 10, 66, 0, 0, 99 }, 3)); + LinearRing hole = gf.createLinearRing(csf.create(new double[] { 2, 2, 99, 3, 2, 44, 3, 3, + 99, 2, 3, 99, 2, 2, 99 }, 3)); + Polygon poly = gf.createPolygon(shell, new LinearRing[] { hole }); + + checkCreateSchemaAndInsert(poly); + } + + public void testCreateSchemaAndInsertPolyWithHoleCW() throws Exception { + LiteCoordinateSequenceFactory csf = new LiteCoordinateSequenceFactory(); + GeometryFactory gf = new GeometryFactory(csf); + + LinearRing shell = gf.createLinearRing(csf.create(new double[] { 1, 1, 99, 10, 1, 33, + 10, 10, 66, 1, 10, 66, 1, 1, 99 }, 3)); + LinearRing hole = gf.createLinearRing(csf.create(new double[] { 2, 2, 99, 8, 2, 44, 8, 8, + 99, 2, 8, 99, 2, 2, 99 }, 3)); + Polygon poly = gf.createPolygon(shell, new LinearRing[] { hole }); + + checkCreateSchemaAndInsert(poly); + } + /** - * Creates the polygon schema and then inserts a 3D geometry into the - * datastore and retrieves it back to make sure 3d data is really handled as - * such + * Creates the polygon schema, inserts a 3D geometry into the datastore, + * and retrieves it back to make sure 3d data is preserved. * * @throws Exception */ - public void testCreateSchemaAndInsert() throws Exception { + private void checkCreateSchemaAndInsert(Geometry poly) throws Exception { dataStore.createSchema(poly3DType); SimpleFeatureType actualSchema = dataStore.getSchema(tname(POLY3D)); assertFeatureTypesEqual(poly3DType, actualSchema); - assertEquals(getNativeSRID(), actualSchema.getGeometryDescriptor().getUserData().get( - JDBCDataStore.JDBC_NATIVE_SRID)); + assertEquals( + getNativeSRID(), + actualSchema.getGeometryDescriptor().getUserData() + .get(JDBCDataStore.JDBC_NATIVE_SRID)); - // build a 3d polygon (ordinates in ccw order) - GeometryFactory gf = new GeometryFactory(); - LinearRing shell = gf.createLinearRing(new Coordinate[] { new Coordinate(0, 0, 0), - new Coordinate(1, 1, 1), new Coordinate(1, 0, 1), new Coordinate(0, 0, 0) }); - Polygon poly = gf.createPolygon(shell, null); - - // insert it + // insert the feature FeatureWriter<SimpleFeatureType, SimpleFeature> fw = dataStore.getFeatureWriterAppend( tname(POLY3D), Transaction.AUTO_COMMIT); SimpleFeature f = fw.next(); @@ -192,20 +238,62 @@ fw.write(); fw.close(); - // read id back and compare + // read feature back + + /** + * Use a LiteCoordinateSequence, since this mimics GeoServer behaviour better, + * and it exposes bugs in CoordinateSequence handling. + */ + final Hints hints = new Hints(); + hints.put(Hints.JTS_COORDINATE_SEQUENCE_FACTORY, new LiteCoordinateSequenceFactory()); + Query query = new DefaultQuery(tname(POLY3D)); + query.setHints(hints); + FeatureReader<SimpleFeatureType, SimpleFeature> fr = dataStore.getFeatureReader( - new DefaultQuery(tname(POLY3D)), Transaction.AUTO_COMMIT); + query, Transaction.AUTO_COMMIT); assertTrue(fr.hasNext()); f = fr.next(); - // this unfortunately checks only the first 2d, but at the same time - // a coordinate by coordinate check is not possible since the ring orientation - // can be modified by the store - assertTrue(poly.equalsTopo((Geometry) f.getDefaultGeometry())); - + + /** + * Check the geometries are topologically equal. + * Check that the Z values are preserved + */ + Geometry fgeom = (Geometry) f.getDefaultGeometry(); + assertTrue("2D topology does not match", poly.equalsTopo(fgeom)); + assertTrue("Z values do not match", hasMatchingZValues(poly, fgeom)); fr.close(); } /** + * Tests whether two geometries have the same Z values for coordinates with identical 2D locations. Requires that each geometry is internally + * location-consistent in Z; that is, if two coordinates are identical in location, then the Z values are equal. This should always be the case + * for valid data. + * + * @param g1 + * @param g2 + * @return true if the geometries are location-equal in Z + */ + private static boolean hasMatchingZValues(Geometry g1, Geometry g2) { + Coordinate[] pt1 = g1.getCoordinates(); + Map<Coordinate, Double> coordZMap = new HashMap<Coordinate, Double>(); + for (int i = 0; i < pt1.length; i++) { + coordZMap.put(pt1[i], pt1[i].z); + } + + Coordinate[] pt2 = g2.getCoordinates(); + + for (int i2 = 0; i2 < pt2.length; i2++) { + Coordinate p2 = pt2[i2]; + double z = coordZMap.get(p2); + boolean isEqualZ = p2.z == z || (Double.isNaN(p2.z) && Double.isNaN(z)); + if (!isEqualZ) + return false; + } + + return true; + } + + /** * Make sure we can properly retrieve the bounds of 3d layers * * @throws Exception @@ -233,11 +321,11 @@ new LiteCoordinateSequenceFactory()); q.setHints(hints); - // check the srs you get is the expected one - FeatureCollection fc = fs.getFeatures(q); - FeatureType fcSchema = fc.getSchema(); + // check the srs you get is the expected one + FeatureCollection fc = fs.getFeatures(q); + FeatureType fcSchema = fc.getSchema(); assertEquals(epsg4326, fcSchema.getCoordinateReferenceSystem()); - assertEquals(epsg4326, fcSchema.getGeometryDescriptor().getCoordinateReferenceSystem()); + assertEquals(epsg4326, fcSchema.getGeometryDescriptor().getCoordinateReferenceSystem()); // build up the reference 2d line, the 3d one is (1 1 0, 2 2 0, 4 2 1, 5 // 1 1) @@ -246,7 +334,8 @@ new Coordinate(5, 1) }); // check feature reader and the schema - FeatureReader<SimpleFeatureType, SimpleFeature> fr = dataStore.getFeatureReader(q, Transaction.AUTO_COMMIT); + FeatureReader<SimpleFeatureType, SimpleFeature> fr = dataStore.getFeatureReader(q, + Transaction.AUTO_COMMIT); assertEquals(epsg4326, fr.getFeatureType().getCoordinateReferenceSystem()); assertEquals(epsg4326, fr.getFeatureType().getGeometryDescriptor() .getCoordinateReferenceSystem()); Modified: trunk/modules/library/main/src/main/java/org/geotools/geometry/jts/LiteCoordinateSequenceFactory.java =================================================================== --- trunk/modules/library/main/src/main/java/org/geotools/geometry/jts/LiteCoordinateSequenceFactory.java 2012-05-16 14:05:34 UTC (rev 38741) +++ trunk/modules/library/main/src/main/java/org/geotools/geometry/jts/LiteCoordinateSequenceFactory.java 2012-05-17 17:01:52 UTC (rev 38742) @@ -42,6 +42,12 @@ * @see com.vividsolutions.jts.geom.CoordinateSequenceFactory#create(com.vividsolutions.jts.geom.CoordinateSequence) */ public CoordinateSequence create(CoordinateSequence coordSeq) { + /** + * If copying a LiteCoordinateSequence, use the copy constructor + * to preserve dimensionality information. + */ + if (coordSeq instanceof LiteCoordinateSequence) + return new LiteCoordinateSequence((LiteCoordinateSequence) coordSeq); return new LiteCoordinateSequence(coordSeq.toCoordinateArray()); } Modified: trunk/modules/plugin/jdbc/jdbc-oracle/src/main/java/org/geotools/data/oracle/sdo/Coordinates.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-oracle/src/main/java/org/geotools/data/oracle/sdo/Coordinates.java 2012-05-16 14:05:34 UTC (rev 38741) +++ trunk/modules/plugin/jdbc/jdbc-oracle/src/main/java/org/geotools/data/oracle/sdo/Coordinates.java 2012-05-17 17:01:52 UTC (rev 38742) @@ -26,6 +26,7 @@ import com.vividsolutions.jts.geom.CoordinateList; import com.vividsolutions.jts.geom.CoordinateSequence; import com.vividsolutions.jts.geom.CoordinateSequenceFactory; +import com.vividsolutions.jts.geom.CoordinateSequences; import com.vividsolutions.jts.geom.PrecisionModel; @@ -173,15 +174,13 @@ return c; } - Coordinate[] array = new Coordinate[toIndex - fromIndex]; - int index = 0; - for(int i = fromIndex; i < toIndex; i++, index++) { - array[index] = sequence.getCoordinate(i); - } + // handle coordinate sequence dimension correctly + int size = toIndex - fromIndex; + CoordinateSequence newSeq = factory.create(size, sequence.getDimension()); + CoordinateSequences.copy(sequence, fromIndex, newSeq, 0, size); + return newSeq; + } - return factory.create(array); - } - /** * DOCUMENT ME! * @@ -214,11 +213,11 @@ return c; } else // else CoordinateSequence - { - CoordinateList list = new CoordinateList(sequence.toCoordinateArray()); - Collections.reverse(list); - - return factory.create(list.toCoordinateArray()); + { + // handle coordinate sequence dimension correctly + CoordinateSequence revSeq = factory.create(sequence); + CoordinateSequences.reverse(revSeq); + return revSeq; } } Modified: trunk/modules/plugin/jdbc/jdbc-oracle/src/test/java/org/geotools/data/oracle/Oracle3DTest.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-oracle/src/test/java/org/geotools/data/oracle/Oracle3DTest.java 2012-05-16 14:05:34 UTC (rev 38741) +++ trunk/modules/plugin/jdbc/jdbc-oracle/src/test/java/org/geotools/data/oracle/Oracle3DTest.java 2012-05-17 17:01:52 UTC (rev 38742) @@ -31,5 +31,13 @@ return new Oracle3DTestSetup(); } + /** + * This test is overriden to disable it, since it is a known issue. + * The issue is that the Oracle driver writes Rectangles as Oracle SDO Rectangle structures, which don't preserve 3D + * See GEOT-4133 + */ + @Override + public void testCreateSchemaAndInsertPolyRectangle() throws Exception { + } } Modified: trunk/modules/plugin/jdbc/jdbc-oracle/src/test/java/org/geotools/data/oracle/OracleTestSetup.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-oracle/src/test/java/org/geotools/data/oracle/OracleTestSetup.java 2012-05-16 14:05:34 UTC (rev 38741) +++ trunk/modules/plugin/jdbc/jdbc-oracle/src/test/java/org/geotools/data/oracle/OracleTestSetup.java 2012-05-17 17:01:52 UTC (rev 38742) @@ -59,7 +59,8 @@ fixture.put("host", "192.168.1.200"); fixture.put("port", "1521"); fixture.put("database", "xe"); - fixture.put("username", "geoserver"); + fixture.put("usernamegit ", "geoserver"); + fixture.put("user", "geoserver"); fixture.put("password", "postgis"); fixture.put("dbtype", "Oracle" ); return fixture; |
From: <svn...@os...> - 2012-05-16 14:05:44
|
Author: aaime Date: 2012-05-16 07:05:34 -0700 (Wed, 16 May 2012) New Revision: 38741 Modified: trunk/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2EmptyTestSetup.java Log: And yet another attempt to clean up things Modified: trunk/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2EmptyTestSetup.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2EmptyTestSetup.java 2012-05-16 14:01:33 UTC (rev 38740) +++ trunk/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2EmptyTestSetup.java 2012-05-16 14:05:34 UTC (rev 38741) @@ -39,6 +39,7 @@ @Override protected void createEmptyTable() throws Exception { + run("DELETE FROM geometry_columns WHERE f_table_name = 'empty'"); run( "CREATE TABLE \"empty\" (id int,geom blob)"); } |
From: <svn...@os...> - 2012-05-16 14:01:44
|
Author: aaime Date: 2012-05-16 07:01:33 -0700 (Wed, 16 May 2012) New Revision: 38740 Modified: trunk/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2EmptyGeometryTestSetup.java Log: Delete geometry columsn another way, is this working better on OSX? Modified: trunk/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2EmptyGeometryTestSetup.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2EmptyGeometryTestSetup.java 2012-05-16 13:53:25 UTC (rev 38739) +++ trunk/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2EmptyGeometryTestSetup.java 2012-05-16 14:01:33 UTC (rev 38740) @@ -55,14 +55,8 @@ @Override protected void dropEmptyGeometryTable() throws Exception { - run("CALL DropGeometryColumn('geotools', 'empty', 'geom_point')"); - run("CALL DropGeometryColumn('geotools', 'empty', 'geom_linestring')"); - run("CALL DropGeometryColumn('geotools', 'empty', 'geom_polygon')"); - run("CALL DropGeometryColumn('geotools', 'empty', 'geom_multipoint')"); - run("CALL DropGeometryColumn('geotools', 'empty', 'geom_multilinestring')"); - run("CALL DropGeometryColumn('geotools', 'empty', 'geom_multipolygon')"); + run("DELETE FROM geometry_columns WHERE f_table_name = 'empty'"); run( "DROP TABLE \"geotools\".\"empty\""); - } |
From: <svn...@os...> - 2012-05-16 13:53:37
|
Author: aaime Date: 2012-05-16 06:53:25 -0700 (Wed, 16 May 2012) New Revision: 38739 Modified: branches/2.7.x/modules/library/coverage/src/test/java/org/geotools/image/ImageWorkerTest.java Log: Make this test work on OSX Modified: branches/2.7.x/modules/library/coverage/src/test/java/org/geotools/image/ImageWorkerTest.java =================================================================== --- branches/2.7.x/modules/library/coverage/src/test/java/org/geotools/image/ImageWorkerTest.java 2012-05-16 12:32:48 UTC (rev 38738) +++ branches/2.7.x/modules/library/coverage/src/test/java/org/geotools/image/ImageWorkerTest.java 2012-05-16 13:53:25 UTC (rev 38739) @@ -18,6 +18,8 @@ import static org.junit.Assert.*; +import it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReaderSpi; + import java.awt.Color; import java.awt.Transparency; import java.awt.color.ColorSpace; @@ -41,6 +43,8 @@ import java.util.zip.GZIPInputStream; import javax.imageio.ImageIO; +import javax.imageio.ImageReader; +import javax.imageio.stream.ImageInputStream; import javax.media.jai.ImageLayout; import javax.media.jai.JAI; import javax.media.jai.RasterFactory; @@ -56,6 +60,7 @@ import org.junit.Test; import com.sun.media.imageioimpl.common.PackageUtil; +import com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader; /** @@ -400,7 +405,10 @@ InputStream gzippedStream = ImageWorkerTest.class.getResource("test-data/sf-sfdem.tif.gz").openStream(); GZIPInputStream is = new GZIPInputStream(gzippedStream); try { - BufferedImage bi = ImageIO.read(is); + ImageInputStream iis = ImageIO.createImageInputStream(is); + ImageReader reader = new TIFFImageReaderSpi().createReaderInstance(iis); + reader.setInput(iis); + BufferedImage bi = reader.read(0); IndexColorModel icm = (IndexColorModel) bi.getColorModel(); assertEquals(65536, icm.getMapSize()); |
Author: jive Date: 2012-05-16 05:32:48 -0700 (Wed, 16 May 2012) New Revision: 38738 Modified: tags/8.0-RC1/README.html tags/8.0-RC1/build/maven/jar-collector/pom.xml tags/8.0-RC1/build/maven/javadoc/pom.xml tags/8.0-RC1/build/maven/jjtree-javacc/pom.xml tags/8.0-RC1/build/maven/pom.xml tags/8.0-RC1/build/maven/xmlcodegen/pom.xml tags/8.0-RC1/build/pom.xml tags/8.0-RC1/build/rename.xml tags/8.0-RC1/docs/pom.xml tags/8.0-RC1/modules/extension/app-schema/app-schema-example/pom.xml tags/8.0-RC1/modules/extension/app-schema/app-schema-packages/pom.xml tags/8.0-RC1/modules/extension/app-schema/app-schema-resolver/pom.xml tags/8.0-RC1/modules/extension/app-schema/app-schema/pom.xml tags/8.0-RC1/modules/extension/app-schema/pom.xml tags/8.0-RC1/modules/extension/app-schema/sample-data-access/pom.xml tags/8.0-RC1/modules/extension/brewer/pom.xml tags/8.0-RC1/modules/extension/graph/pom.xml tags/8.0-RC1/modules/extension/pom.xml tags/8.0-RC1/modules/extension/validation/pom.xml tags/8.0-RC1/modules/extension/wms/pom.xml tags/8.0-RC1/modules/extension/xsd/pom.xml tags/8.0-RC1/modules/extension/xsd/xsd-core/pom.xml tags/8.0-RC1/modules/extension/xsd/xsd-fes/pom.xml tags/8.0-RC1/modules/extension/xsd/xsd-filter/pom.xml tags/8.0-RC1/modules/extension/xsd/xsd-gml2/pom.xml tags/8.0-RC1/modules/extension/xsd/xsd-gml3/pom.xml tags/8.0-RC1/modules/extension/xsd/xsd-kml/pom.xml tags/8.0-RC1/modules/extension/xsd/xsd-ows/pom.xml tags/8.0-RC1/modules/extension/xsd/xsd-sld/pom.xml tags/8.0-RC1/modules/extension/xsd/xsd-wcs/pom.xml tags/8.0-RC1/modules/extension/xsd/xsd-wfs/pom.xml tags/8.0-RC1/modules/extension/xsd/xsd-wms/pom.xml tags/8.0-RC1/modules/extension/xsd/xsd-wps/pom.xml tags/8.0-RC1/modules/library/api/pom.xml tags/8.0-RC1/modules/library/coverage/pom.xml tags/8.0-RC1/modules/library/coverage/src/test/java/org/geotools/image/ImageWorkerTest.java tags/8.0-RC1/modules/library/cql/pom.xml tags/8.0-RC1/modules/library/data/pom.xml tags/8.0-RC1/modules/library/jdbc/pom.xml tags/8.0-RC1/modules/library/main/pom.xml tags/8.0-RC1/modules/library/metadata/pom.xml tags/8.0-RC1/modules/library/metadata/src/main/java/org/geotools/factory/GeoTools.java tags/8.0-RC1/modules/library/opengis/pom.xml tags/8.0-RC1/modules/library/pom.xml tags/8.0-RC1/modules/library/referencing/pom.xml tags/8.0-RC1/modules/library/render/pom.xml tags/8.0-RC1/modules/library/sample-data/pom.xml tags/8.0-RC1/modules/library/xml/pom.xml tags/8.0-RC1/modules/ogc/net.opengis.fes/pom.xml tags/8.0-RC1/modules/ogc/net.opengis.ows/pom.xml tags/8.0-RC1/modules/ogc/net.opengis.wcs/pom.xml tags/8.0-RC1/modules/ogc/net.opengis.wfs/pom.xml tags/8.0-RC1/modules/ogc/net.opengis.wfsv/pom.xml tags/8.0-RC1/modules/ogc/net.opengis.wps/pom.xml tags/8.0-RC1/modules/ogc/org.w3.xlink/pom.xml tags/8.0-RC1/modules/ogc/pom.xml tags/8.0-RC1/modules/plugin/arcgrid/pom.xml tags/8.0-RC1/modules/plugin/arcsde/common/pom.xml tags/8.0-RC1/modules/plugin/arcsde/datastore/pom.xml tags/8.0-RC1/modules/plugin/arcsde/pom.xml tags/8.0-RC1/modules/plugin/arcsde/sde-dummy/pom.xml tags/8.0-RC1/modules/plugin/charts/pom.xml tags/8.0-RC1/modules/plugin/epsg-extension/pom.xml tags/8.0-RC1/modules/plugin/epsg-hsql/pom.xml tags/8.0-RC1/modules/plugin/epsg-postgresql/pom.xml tags/8.0-RC1/modules/plugin/epsg-wkt/pom.xml tags/8.0-RC1/modules/plugin/feature-pregeneralized/pom.xml tags/8.0-RC1/modules/plugin/geotiff/pom.xml tags/8.0-RC1/modules/plugin/grassraster/pom.xml tags/8.0-RC1/modules/plugin/gtopo30/pom.xml tags/8.0-RC1/modules/plugin/image/pom.xml tags/8.0-RC1/modules/plugin/imageio-ext-gdal/pom.xml tags/8.0-RC1/modules/plugin/imagemosaic-jdbc/pom.xml tags/8.0-RC1/modules/plugin/imagemosaic/pom.xml tags/8.0-RC1/modules/plugin/imagepyramid/pom.xml tags/8.0-RC1/modules/plugin/jdbc/jdbc-db2/pom.xml tags/8.0-RC1/modules/plugin/jdbc/jdbc-h2/pom.xml tags/8.0-RC1/modules/plugin/jdbc/jdbc-mysql/pom.xml tags/8.0-RC1/modules/plugin/jdbc/jdbc-oracle/pom.xml tags/8.0-RC1/modules/plugin/jdbc/jdbc-postgis/pom.xml tags/8.0-RC1/modules/plugin/jdbc/jdbc-spatialite/pom.xml tags/8.0-RC1/modules/plugin/jdbc/jdbc-sqlserver/pom.xml tags/8.0-RC1/modules/plugin/jdbc/jdbc-teradata/pom.xml tags/8.0-RC1/modules/plugin/jdbc/pom.xml tags/8.0-RC1/modules/plugin/jp2k/pom.xml tags/8.0-RC1/modules/plugin/pom.xml tags/8.0-RC1/modules/plugin/property/pom.xml tags/8.0-RC1/modules/plugin/referencing3D/pom.xml tags/8.0-RC1/modules/plugin/shapefile/pom.xml tags/8.0-RC1/modules/plugin/svg/pom.xml tags/8.0-RC1/modules/pom.xml tags/8.0-RC1/modules/unsupported/app-schema/pom.xml tags/8.0-RC1/modules/unsupported/app-schema/webservice/pom.xml tags/8.0-RC1/modules/unsupported/caching/pom.xml tags/8.0-RC1/modules/unsupported/couchdb/pom.xml tags/8.0-RC1/modules/unsupported/coverage-experiment/coverage-api/pom.xml tags/8.0-RC1/modules/unsupported/coverage-experiment/coverage-core/pom.xml tags/8.0-RC1/modules/unsupported/coverage-experiment/grib1/pom.xml tags/8.0-RC1/modules/unsupported/coverage-experiment/hdf4/pom.xml tags/8.0-RC1/modules/unsupported/coverage-experiment/netcdf/pom.xml tags/8.0-RC1/modules/unsupported/coverage-experiment/pom.xml tags/8.0-RC1/modules/unsupported/coveragetools/pom.xml tags/8.0-RC1/modules/unsupported/csv/pom.xml tags/8.0-RC1/modules/unsupported/dxf/pom.xml tags/8.0-RC1/modules/unsupported/edigeo/pom.xml tags/8.0-RC1/modules/unsupported/efeature/pom.xml tags/8.0-RC1/modules/unsupported/epsg-oracle/pom.xml tags/8.0-RC1/modules/unsupported/example/pom.xml tags/8.0-RC1/modules/unsupported/excel/pom.xml tags/8.0-RC1/modules/unsupported/feature-aggregate/pom.xml tags/8.0-RC1/modules/unsupported/geogit-versioned/pom.xml tags/8.0-RC1/modules/unsupported/geojson/pom.xml tags/8.0-RC1/modules/unsupported/geometry/pom.xml tags/8.0-RC1/modules/unsupported/georest/pom.xml tags/8.0-RC1/modules/unsupported/geotiff_new/pom.xml tags/8.0-RC1/modules/unsupported/grid/pom.xml tags/8.0-RC1/modules/unsupported/imagecollection/pom.xml tags/8.0-RC1/modules/unsupported/jdbc-ng/jdbc-ingres/pom.xml tags/8.0-RC1/modules/unsupported/jdbc-ng/pom.xml tags/8.0-RC1/modules/unsupported/jts-wrapper/pom.xml tags/8.0-RC1/modules/unsupported/mark-wkt/pom.xml tags/8.0-RC1/modules/unsupported/matfile5/pom.xml tags/8.0-RC1/modules/unsupported/mongodb/pom.xml tags/8.0-RC1/modules/unsupported/ogr/pom.xml tags/8.0-RC1/modules/unsupported/pom.xml tags/8.0-RC1/modules/unsupported/postgis-versioned/pom.xml tags/8.0-RC1/modules/unsupported/process-feature/pom.xml tags/8.0-RC1/modules/unsupported/process-geometry/pom.xml tags/8.0-RC1/modules/unsupported/process-raster/pom.xml tags/8.0-RC1/modules/unsupported/process/pom.xml tags/8.0-RC1/modules/unsupported/property-ng/pom.xml tags/8.0-RC1/modules/unsupported/sfs/pom.xml tags/8.0-RC1/modules/unsupported/shapefile-ng/pom.xml tags/8.0-RC1/modules/unsupported/shapefile-renderer/pom.xml tags/8.0-RC1/modules/unsupported/swing/pom.xml tags/8.0-RC1/modules/unsupported/swt/pom.xml tags/8.0-RC1/modules/unsupported/vpf/pom.xml tags/8.0-RC1/modules/unsupported/wfs-ng/pom.xml tags/8.0-RC1/modules/unsupported/wfs/pom.xml tags/8.0-RC1/modules/unsupported/wps/pom.xml tags/8.0-RC1/pom.xml tags/8.0-RC1/spike/jan/gsoc-transformations/pom.xml tags/8.0-RC1/spike/mauro/ogr/pom.xml Log: switch over to 8.0-RC1 project version Modified: tags/8.0-RC1/README.html =================================================================== --- tags/8.0-RC1/README.html 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/README.html 2012-05-16 12:32:48 UTC (rev 38738) @@ -2,7 +2,7 @@ <HTML> <HEAD> <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> - <TITLE>GeoTools @RELEASE@ README</TITLE> + <TITLE>GeoTools 8.0-RC1 README</TITLE> <META NAME="GENERATOR" CONTENT="LibreOffice 3.3 (Linux)"> <META NAME="CREATED" CONTENT="0;0"> <META NAME="CHANGEDBY" CONTENT="Jody Garnett"> @@ -23,9 +23,9 @@ </HEAD> <BODY LANG="en-AU" DIR="LTR"> <a href="http://geotools.org"><img src="geotools-logo.png"></a> -<H1 CLASS="western">GeoTools @RELEASE@</H1> -<P>Thank you for downloading GeoTools @RELEASE@. This release was -created on @DATE@.</P> +<H1 CLASS="western">GeoTools 8.0-RC1</H1> +<P>Thank you for downloading GeoTools 8.0-RC1. This release was +created on May, 16th, 2012.</P> <P>This release contains only a subset of the current GeoTools code base. The full GeoTools code base contains additional unsupported Modified: tags/8.0-RC1/build/maven/jar-collector/pom.xml =================================================================== --- tags/8.0-RC1/build/maven/jar-collector/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/build/maven/jar-collector/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools.maven</groupId> <artifactId>maven</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/build/maven/javadoc/pom.xml =================================================================== --- tags/8.0-RC1/build/maven/javadoc/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/build/maven/javadoc/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools.maven</groupId> <artifactId>maven</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/build/maven/jjtree-javacc/pom.xml =================================================================== --- tags/8.0-RC1/build/maven/jjtree-javacc/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/build/maven/jjtree-javacc/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools.maven</groupId> <artifactId>maven</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/build/maven/pom.xml =================================================================== --- tags/8.0-RC1/build/maven/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/build/maven/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools.maven</groupId> <artifactId>build</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/build/maven/xmlcodegen/pom.xml =================================================================== --- tags/8.0-RC1/build/maven/xmlcodegen/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/build/maven/xmlcodegen/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools.maven</groupId> <artifactId>maven</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/build/pom.xml =================================================================== --- tags/8.0-RC1/build/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/build/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>geotools</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/build/rename.xml =================================================================== --- tags/8.0-RC1/build/rename.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/build/rename.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -9,13 +9,13 @@ <replace dir=".."> <include name="**/pom.xml"/> <replacefilter token="<version>8-SNAPSHOT</version>" - value="<version>8.0-M5</version>"/> + value="<version>8.0-RC1</version>"/> </replace> <replace dir="../modules/library/metadata/src/main/java/org/geotools/factory"> <include name="GeoTools.java"/> <replacefilter token="8-SNAPSHOT" - value="8.0-M5"/> + value="8.0-RC1"/> </replace> </target> @@ -23,21 +23,21 @@ <replace dir="../docs/user/tutorial/"> <include name="**/pom.xml"/> <replacefilter token="<geotools.version>8-SNAPSHOT</geotools.version>" - value="<geotools.version>8.0-M5</geotools.version>"/> + value="<geotools.version>8.0-RC1</geotools.version>"/> </replace> <replace dir="../docs/"> <include name="pom.xml"/> <replacefilter token="8-SNAPSHOT" - value="8.0-M5"/> + value="8.0-RC1"/> </replace> </target> <target name="readme"> <replace file="../README.html"> <replacefilter token="@RELEASE@" - value="8.0-M5"/> + value="8.0-RC1"/> <replacefilter token="@DATE@" - value="Dec, 8th, 2011"/> + value="May, 16th, 2012"/> </replace> </target> Modified: tags/8.0-RC1/docs/pom.xml =================================================================== --- tags/8.0-RC1/docs/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/docs/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -13,7 +13,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>geotools</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/extension/app-schema/app-schema/pom.xml =================================================================== --- tags/8.0-RC1/modules/extension/app-schema/app-schema/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/extension/app-schema/app-schema/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -7,7 +7,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>app-schema</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <groupId>org.geotools</groupId> Modified: tags/8.0-RC1/modules/extension/app-schema/app-schema-example/pom.xml =================================================================== --- tags/8.0-RC1/modules/extension/app-schema/app-schema-example/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/extension/app-schema/app-schema-example/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -7,7 +7,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>app-schema</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/extension/app-schema/app-schema-packages/pom.xml =================================================================== --- tags/8.0-RC1/modules/extension/app-schema/app-schema-packages/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/extension/app-schema/app-schema-packages/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -7,7 +7,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>app-schema</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <groupId>org.geotools</groupId> Modified: tags/8.0-RC1/modules/extension/app-schema/app-schema-resolver/pom.xml =================================================================== --- tags/8.0-RC1/modules/extension/app-schema/app-schema-resolver/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/extension/app-schema/app-schema-resolver/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -7,7 +7,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>app-schema</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <groupId>org.geotools</groupId> Modified: tags/8.0-RC1/modules/extension/app-schema/pom.xml =================================================================== --- tags/8.0-RC1/modules/extension/app-schema/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/extension/app-schema/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -7,7 +7,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>extension</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <groupId>org.geotools</groupId> Modified: tags/8.0-RC1/modules/extension/app-schema/sample-data-access/pom.xml =================================================================== --- tags/8.0-RC1/modules/extension/app-schema/sample-data-access/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/extension/app-schema/sample-data-access/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -7,7 +7,7 @@ <parent> <artifactId>app-schema</artifactId> <groupId>org.geotools</groupId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <groupId>org.geotools</groupId> Modified: tags/8.0-RC1/modules/extension/brewer/pom.xml =================================================================== --- tags/8.0-RC1/modules/extension/brewer/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/extension/brewer/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>extension</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/extension/graph/pom.xml =================================================================== --- tags/8.0-RC1/modules/extension/graph/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/extension/graph/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>extension</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/extension/pom.xml =================================================================== --- tags/8.0-RC1/modules/extension/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/extension/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>modules</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/extension/validation/pom.xml =================================================================== --- tags/8.0-RC1/modules/extension/validation/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/extension/validation/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>extension</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/extension/wms/pom.xml =================================================================== --- tags/8.0-RC1/modules/extension/wms/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/extension/wms/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>extension</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/extension/xsd/pom.xml =================================================================== --- tags/8.0-RC1/modules/extension/xsd/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/extension/xsd/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>extension</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/extension/xsd/xsd-core/pom.xml =================================================================== --- tags/8.0-RC1/modules/extension/xsd/xsd-core/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/extension/xsd/xsd-core/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools.xsd</groupId> <artifactId>xsd</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/extension/xsd/xsd-fes/pom.xml =================================================================== --- tags/8.0-RC1/modules/extension/xsd/xsd-fes/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/extension/xsd/xsd-fes/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools.xsd</groupId> <artifactId>xsd</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/extension/xsd/xsd-filter/pom.xml =================================================================== --- tags/8.0-RC1/modules/extension/xsd/xsd-filter/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/extension/xsd/xsd-filter/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools.xsd</groupId> <artifactId>xsd</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/extension/xsd/xsd-gml2/pom.xml =================================================================== --- tags/8.0-RC1/modules/extension/xsd/xsd-gml2/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/extension/xsd/xsd-gml2/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools.xsd</groupId> <artifactId>xsd</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <!-- =========================================================== --> Modified: tags/8.0-RC1/modules/extension/xsd/xsd-gml3/pom.xml =================================================================== --- tags/8.0-RC1/modules/extension/xsd/xsd-gml3/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/extension/xsd/xsd-gml3/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools.xsd</groupId> <artifactId>xsd</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/extension/xsd/xsd-kml/pom.xml =================================================================== --- tags/8.0-RC1/modules/extension/xsd/xsd-kml/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/extension/xsd/xsd-kml/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools.xsd</groupId> <artifactId>xsd</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <!-- =========================================================== --> Modified: tags/8.0-RC1/modules/extension/xsd/xsd-ows/pom.xml =================================================================== --- tags/8.0-RC1/modules/extension/xsd/xsd-ows/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/extension/xsd/xsd-ows/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools.xsd</groupId> <artifactId>xsd</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <!-- =========================================================== --> @@ -71,7 +71,7 @@ <dependency> <groupId>org.geotools.ogc</groupId> <artifactId>net.opengis.ows</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </dependency> <dependency> <groupId>org.geotools.xsd</groupId> Modified: tags/8.0-RC1/modules/extension/xsd/xsd-sld/pom.xml =================================================================== --- tags/8.0-RC1/modules/extension/xsd/xsd-sld/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/extension/xsd/xsd-sld/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools.xsd</groupId> <artifactId>xsd</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/extension/xsd/xsd-wcs/pom.xml =================================================================== --- tags/8.0-RC1/modules/extension/xsd/xsd-wcs/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/extension/xsd/xsd-wcs/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools.xsd</groupId> <artifactId>xsd</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <!-- =========================================================== --> Modified: tags/8.0-RC1/modules/extension/xsd/xsd-wfs/pom.xml =================================================================== --- tags/8.0-RC1/modules/extension/xsd/xsd-wfs/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/extension/xsd/xsd-wfs/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools.xsd</groupId> <artifactId>xsd</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <!-- =========================================================== --> Modified: tags/8.0-RC1/modules/extension/xsd/xsd-wms/pom.xml =================================================================== --- tags/8.0-RC1/modules/extension/xsd/xsd-wms/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/extension/xsd/xsd-wms/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools.xsd</groupId> <artifactId>xsd</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <!-- =========================================================== --> Modified: tags/8.0-RC1/modules/extension/xsd/xsd-wps/pom.xml =================================================================== --- tags/8.0-RC1/modules/extension/xsd/xsd-wps/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/extension/xsd/xsd-wps/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools.xsd</groupId> <artifactId>xsd</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <!-- =========================================================== --> Modified: tags/8.0-RC1/modules/library/api/pom.xml =================================================================== --- tags/8.0-RC1/modules/library/api/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/library/api/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>library</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/library/coverage/pom.xml =================================================================== --- tags/8.0-RC1/modules/library/coverage/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/library/coverage/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>library</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/library/coverage/src/test/java/org/geotools/image/ImageWorkerTest.java =================================================================== --- tags/8.0-RC1/modules/library/coverage/src/test/java/org/geotools/image/ImageWorkerTest.java 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/library/coverage/src/test/java/org/geotools/image/ImageWorkerTest.java 2012-05-16 12:32:48 UTC (rev 38738) @@ -18,6 +18,8 @@ import static org.junit.Assert.*; +import it.geosolutions.imageioimpl.plugins.tiff.TIFFImageReaderSpi; + import java.awt.Color; import java.awt.Transparency; import java.awt.color.ColorSpace; @@ -41,6 +43,8 @@ import java.util.zip.GZIPInputStream; import javax.imageio.ImageIO; +import javax.imageio.ImageReader; +import javax.imageio.stream.ImageInputStream; import javax.media.jai.ImageLayout; import javax.media.jai.JAI; import javax.media.jai.RasterFactory; @@ -56,8 +60,8 @@ import org.junit.Test; import com.sun.media.imageioimpl.common.PackageUtil; +import com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader; - /** * Tests the {@link ImageWorker} implementation. * @@ -401,7 +405,13 @@ InputStream gzippedStream = ImageWorkerTest.class.getResource("test-data/sf-sfdem.tif.gz").openStream(); GZIPInputStream is = new GZIPInputStream(gzippedStream); try { - BufferedImage bi = ImageIO.read(is); + // BufferedImage bi = ImageIO.read(is); + + ImageInputStream iis = ImageIO.createImageInputStream(is); + ImageReader reader = new TIFFImageReaderSpi().createReaderInstance(iis); + reader.setInput(iis); + BufferedImage bi = reader.read(0); + IndexColorModel icm = (IndexColorModel) bi.getColorModel(); assertEquals(65536, icm.getMapSize()); Modified: tags/8.0-RC1/modules/library/cql/pom.xml =================================================================== --- tags/8.0-RC1/modules/library/cql/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/library/cql/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>library</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/library/data/pom.xml =================================================================== --- tags/8.0-RC1/modules/library/data/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/library/data/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>library</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/library/jdbc/pom.xml =================================================================== --- tags/8.0-RC1/modules/library/jdbc/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/library/jdbc/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>library</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/library/main/pom.xml =================================================================== --- tags/8.0-RC1/modules/library/main/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/library/main/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>library</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/library/metadata/pom.xml =================================================================== --- tags/8.0-RC1/modules/library/metadata/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/library/metadata/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>library</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/library/metadata/src/main/java/org/geotools/factory/GeoTools.java =================================================================== --- tags/8.0-RC1/modules/library/metadata/src/main/java/org/geotools/factory/GeoTools.java 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/library/metadata/src/main/java/org/geotools/factory/GeoTools.java 2012-05-16 12:32:48 UTC (rev 38738) @@ -96,7 +96,7 @@ /** * The current GeoTools version. The separator character must be the dot. */ - private static final Version VERSION = new Version(PROPS.getProperty("version", "8-SNAPSHOT")); + private static final Version VERSION = new Version(PROPS.getProperty("version", "8.0-RC1")); /** * The version control (svn) revision at which this version of geotools was built. Modified: tags/8.0-RC1/modules/library/opengis/pom.xml =================================================================== --- tags/8.0-RC1/modules/library/opengis/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/library/opengis/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>library</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/library/pom.xml =================================================================== --- tags/8.0-RC1/modules/library/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/library/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>modules</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/library/referencing/pom.xml =================================================================== --- tags/8.0-RC1/modules/library/referencing/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/library/referencing/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>library</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/library/render/pom.xml =================================================================== --- tags/8.0-RC1/modules/library/render/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/library/render/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>library</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/library/sample-data/pom.xml =================================================================== --- tags/8.0-RC1/modules/library/sample-data/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/library/sample-data/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>library</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/library/xml/pom.xml =================================================================== --- tags/8.0-RC1/modules/library/xml/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/library/xml/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>library</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/ogc/net.opengis.fes/pom.xml =================================================================== --- tags/8.0-RC1/modules/ogc/net.opengis.fes/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/ogc/net.opengis.fes/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -5,7 +5,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>ogc</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <groupId>org.geotools.ogc</groupId> Modified: tags/8.0-RC1/modules/ogc/net.opengis.ows/pom.xml =================================================================== --- tags/8.0-RC1/modules/ogc/net.opengis.ows/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/ogc/net.opengis.ows/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -5,7 +5,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>ogc</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <groupId>org.geotools.ogc</groupId> @@ -28,7 +28,7 @@ <dependency> <groupId>org.geotools.ogc</groupId> <artifactId>org.w3.xlink</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </dependency> </dependencies> Modified: tags/8.0-RC1/modules/ogc/net.opengis.wcs/pom.xml =================================================================== --- tags/8.0-RC1/modules/ogc/net.opengis.wcs/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/ogc/net.opengis.wcs/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -5,7 +5,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>ogc</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <groupId>org.geotools.ogc</groupId> Modified: tags/8.0-RC1/modules/ogc/net.opengis.wfs/pom.xml =================================================================== --- tags/8.0-RC1/modules/ogc/net.opengis.wfs/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/ogc/net.opengis.wfs/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -5,7 +5,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>ogc</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <groupId>org.geotools.ogc</groupId> Modified: tags/8.0-RC1/modules/ogc/net.opengis.wfsv/pom.xml =================================================================== --- tags/8.0-RC1/modules/ogc/net.opengis.wfsv/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/ogc/net.opengis.wfsv/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -5,7 +5,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>ogc</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <groupId>org.geotools.ogc</groupId> @@ -28,7 +28,7 @@ <dependency> <groupId>org.geotools.ogc</groupId> <artifactId>net.opengis.wfs</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </dependency> </dependencies> Modified: tags/8.0-RC1/modules/ogc/net.opengis.wps/pom.xml =================================================================== --- tags/8.0-RC1/modules/ogc/net.opengis.wps/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/ogc/net.opengis.wps/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -5,7 +5,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>ogc</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <groupId>org.geotools.ogc</groupId> Modified: tags/8.0-RC1/modules/ogc/org.w3.xlink/pom.xml =================================================================== --- tags/8.0-RC1/modules/ogc/org.w3.xlink/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/ogc/org.w3.xlink/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -5,7 +5,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>ogc</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <groupId>org.geotools.ogc</groupId> Modified: tags/8.0-RC1/modules/ogc/pom.xml =================================================================== --- tags/8.0-RC1/modules/ogc/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/ogc/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -5,7 +5,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>modules</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <groupId>org.geotools</groupId> Modified: tags/8.0-RC1/modules/plugin/arcgrid/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/arcgrid/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/arcgrid/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>plugin</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/arcsde/common/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/arcsde/common/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/arcsde/common/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -13,7 +13,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>arcsde-plugin</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/arcsde/datastore/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/arcsde/datastore/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/arcsde/datastore/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -13,7 +13,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>arcsde-plugin</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/arcsde/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/arcsde/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/arcsde/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -13,7 +13,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>plugin</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/arcsde/sde-dummy/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/arcsde/sde-dummy/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/arcsde/sde-dummy/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>arcsde-plugin</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/charts/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/charts/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/charts/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>plugin</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/epsg-extension/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/epsg-extension/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/epsg-extension/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>plugin</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/epsg-hsql/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/epsg-hsql/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/epsg-hsql/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>plugin</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/epsg-postgresql/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/epsg-postgresql/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/epsg-postgresql/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>plugin</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/epsg-wkt/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/epsg-wkt/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/epsg-wkt/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>plugin</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/feature-pregeneralized/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/feature-pregeneralized/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/feature-pregeneralized/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>plugin</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/geotiff/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/geotiff/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/geotiff/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>plugin</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/grassraster/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/grassraster/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/grassraster/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>plugin</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/gtopo30/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/gtopo30/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/gtopo30/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>plugin</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/image/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/image/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/image/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>plugin</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/imageio-ext-gdal/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/imageio-ext-gdal/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/imageio-ext-gdal/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>plugin</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <!-- =========================================================== --> Modified: tags/8.0-RC1/modules/plugin/imagemosaic/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/imagemosaic/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/imagemosaic/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>plugin</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/imagemosaic-jdbc/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/imagemosaic-jdbc/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/imagemosaic-jdbc/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>plugin</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/imagepyramid/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/imagepyramid/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/imagepyramid/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>plugin</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <!--properties> Modified: tags/8.0-RC1/modules/plugin/jdbc/jdbc-db2/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/jdbc/jdbc-db2/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/jdbc/jdbc-db2/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools.jdbc</groupId> <artifactId>gt-jdbc</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/jdbc/jdbc-h2/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/jdbc/jdbc-h2/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/jdbc/jdbc-h2/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools.jdbc</groupId> <artifactId>gt-jdbc</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/jdbc/jdbc-mysql/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/jdbc/jdbc-mysql/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/jdbc/jdbc-mysql/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools.jdbc</groupId> <artifactId>gt-jdbc</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/jdbc/jdbc-oracle/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/jdbc/jdbc-oracle/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/jdbc/jdbc-oracle/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools.jdbc</groupId> <artifactId>gt-jdbc</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/jdbc/jdbc-postgis/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/jdbc/jdbc-postgis/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/jdbc/jdbc-postgis/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools.jdbc</groupId> <artifactId>gt-jdbc</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/jdbc/jdbc-spatialite/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/jdbc/jdbc-spatialite/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/jdbc/jdbc-spatialite/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools.jdbc</groupId> <artifactId>gt-jdbc</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/jdbc/jdbc-sqlserver/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/jdbc/jdbc-sqlserver/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/jdbc/jdbc-sqlserver/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools.jdbc</groupId> <artifactId>gt-jdbc</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/jdbc/jdbc-teradata/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/jdbc/jdbc-teradata/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/jdbc/jdbc-teradata/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools.jdbc</groupId> <artifactId>gt-jdbc</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/jdbc/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/jdbc/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/jdbc/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>plugin</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/jp2k/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/jp2k/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/jp2k/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -15,7 +15,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>plugin</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>modules</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <!-- =========================================================== --> Modified: tags/8.0-RC1/modules/plugin/property/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/property/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/property/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>plugin</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/referencing3D/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/referencing3D/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/referencing3D/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>plugin</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/shapefile/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/shapefile/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/shapefile/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>plugin</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/plugin/svg/pom.xml =================================================================== --- tags/8.0-RC1/modules/plugin/svg/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/plugin/svg/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>plugin</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/pom.xml =================================================================== --- tags/8.0-RC1/modules/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>geotools</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/unsupported/app-schema/pom.xml =================================================================== --- tags/8.0-RC1/modules/unsupported/app-schema/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/unsupported/app-schema/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -7,7 +7,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>unsupported</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <groupId>org.geotools</groupId> Modified: tags/8.0-RC1/modules/unsupported/app-schema/webservice/pom.xml =================================================================== --- tags/8.0-RC1/modules/unsupported/app-schema/webservice/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/unsupported/app-schema/webservice/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -7,7 +7,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>app-schema-unsupported</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <groupId>org.geotools</groupId> Modified: tags/8.0-RC1/modules/unsupported/caching/pom.xml =================================================================== --- tags/8.0-RC1/modules/unsupported/caching/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/unsupported/caching/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -16,7 +16,7 @@ <parent> <groupId>org.geotools</groupId> <artifactId>unsupported</artifactId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> Modified: tags/8.0-RC1/modules/unsupported/couchdb/pom.xml =================================================================== --- tags/8.0-RC1/modules/unsupported/couchdb/pom.xml 2012-05-16 08:47:40 UTC (rev 38737) +++ tags/8.0-RC1/modules/unsupported/couchdb/pom.xml 2012-05-16 12:32:48 UTC (rev 38738) @@ -5,12 +5,12 @@ <parent> <artifactId>unsupported</artifactId> <groupId>org.geotools</groupId> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> </parent> <groupId>org.geotools</groupId> <artifactId>gt-couchdb</artifactId> <packaging>jar</packaging> - <version>8-SNAPSHOT</version> + <version>8.0-RC1</version> <name>Couchdb Data Store</name> <url>http://maven.apache.org</url> <description>CouchDB DataStore</description> @@ -28,7 +28,7 @@ <dependency> <groupId>org.geotools</groupId> <artifactId>gt-geojson</artifactId> - <version>8-SNAPSHOT</ve... [truncated message content] |
From: <svn...@os...> - 2012-05-16 08:47:53
|
Author: jive Date: 2012-05-16 01:47:40 -0700 (Wed, 16 May 2012) New Revision: 38737 Added: tags/8.0-RC1/ Log: Tag 8.0-M2 for release Property changes on: tags/8.0-RC1 ___________________________________________________________________ Added: svn:ignore + .project .settings .classpath .jetproperties .wtpmodules target bin cobertura.ser nbproject nbactions.xml target.list .featurelock.patch.swp Added: svn:mergeinfo + /branches/simple-features:35278-35308 |
From: <svn...@os...> - 2012-05-16 05:16:00
|
Author: ang05a Date: 2012-05-15 22:15:52 -0700 (Tue, 15 May 2012) New Revision: 38736 Modified: trunk/modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/MappingAttributeIterator.java trunk/modules/extension/app-schema/app-schema/src/test/java/org/geotools/util/ComplexAttributeConverterFactoryTest.java trunk/modules/unsupported/app-schema/webservice/pom.xml trunk/modules/unsupported/app-schema/webservice/src/main/java/org/geotools/filter/AsXpathFunctionExpression.java Log: Fix svn properties for some app-schema files. Modified: trunk/modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/MappingAttributeIterator.java =================================================================== --- trunk/modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/MappingAttributeIterator.java 2012-05-16 01:36:44 UTC (rev 38735) +++ trunk/modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/MappingAttributeIterator.java 2012-05-16 05:15:52 UTC (rev 38736) @@ -1,85 +1,85 @@ -/* - * GeoTools - The Open Source Java GIS Toolkit - * http://geotools.org - * - * (C) 2007-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.complex; - -import java.io.IOException; -import java.util.Iterator; - -import org.geotools.data.Query; -import org.geotools.data.complex.filter.XPath.StepList; -import org.geotools.feature.Types; -import org.opengis.feature.type.Name; -/** - * A Feature iterator that operates over the FeatureSource of a - * {@linkplain org.geotools.data.complex.FeatureTypeMapping} that is of a simple content type, e.g. - * representing a gml:name element. This is required for feature chaining for such types to reduce - * the need of creating an additional database view when simple element values come from another - * table. Therefore this iterator should have a method that return attributes that are to be chained - * directly in another feature type. - * - * @author Rini Angreani (CSIRO Earth Science and Resource Engineering) - * - * @source $URL: - * http://svn.osgeo.org/geotools/trunk/modules/extension/app-schema/app-schema/src/main - * /java/org/geotools/data/complex/MappingAttributeIterator.java $ - * http://svn.osgeo.org/geotools/trunk/modules/unsupported/app-schema/app-schema/src/main - * /java/org/geotools/data/complex/MappingAttributeIterator.java $ - * @since 2.7 - */ -public class MappingAttributeIterator extends DataAccessMappingFeatureIterator { - /** - * Name of the chained element, e.g. gml:name. - */ - private Name elementName; - - public MappingAttributeIterator(AppSchemaDataAccess store, FeatureTypeMapping mapping, - Query query, Query unrolledQuery) throws IOException { - super(store, mapping, query, unrolledQuery); - elementName = mapping.getTargetFeature().getName(); - checkAttributeMappings(); - } - - private void checkAttributeMappings() { - // there should only be 1 attribute mapping for this element since it's a simple type - // exception for FEATURE_LINK attributes - Iterator<AttributeMapping> mappings = mapping.getAttributeMappings().iterator(); - AttributeMapping rootMapping = null; - while (mappings.hasNext()) { - AttributeMapping att = mappings.next(); - StepList xpath = att.getTargetXPath(); - if (Types.equals(elementName, xpath)) { - if (rootMapping != null) { - throw new RuntimeException("Duplicate AttributeMapping for: '" + elementName - + "' is found in FeatureTypeMapping '" + elementName + "'!"); - } - rootMapping = att; - } else if (!Types.equals(ComplexFeatureConstants.FEATURE_CHAINING_LINK_NAME, xpath)) { - // log warning - String msg = "AttributeMapping for: '" + xpath + "' found in FeatureTypeMapping '" - + elementName - + "' ! This will be ignored as it doesn't belong to the type."; - LOGGER.warning(msg); - } - } - if (rootMapping == null) { - // not found, throw exception - throw new RuntimeException("AttributeMapping for: '" + elementName - + "' is missing in FeatureTypeMapping '" + elementName + "'!"); - } - } -} +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2007-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.complex; + +import java.io.IOException; +import java.util.Iterator; + +import org.geotools.data.Query; +import org.geotools.data.complex.filter.XPath.StepList; +import org.geotools.feature.Types; +import org.opengis.feature.type.Name; +/** + * A Feature iterator that operates over the FeatureSource of a + * {@linkplain org.geotools.data.complex.FeatureTypeMapping} that is of a simple content type, e.g. + * representing a gml:name element. This is required for feature chaining for such types to reduce + * the need of creating an additional database view when simple element values come from another + * table. Therefore this iterator should have a method that return attributes that are to be chained + * directly in another feature type. + * + * @author Rini Angreani (CSIRO Earth Science and Resource Engineering) + * + * @source $URL: + * http://svn.osgeo.org/geotools/trunk/modules/extension/app-schema/app-schema/src/main + * /java/org/geotools/data/complex/MappingAttributeIterator.java $ + * http://svn.osgeo.org/geotools/trunk/modules/unsupported/app-schema/app-schema/src/main + * /java/org/geotools/data/complex/MappingAttributeIterator.java $ + * @since 2.7 + */ +public class MappingAttributeIterator extends DataAccessMappingFeatureIterator { + /** + * Name of the chained element, e.g. gml:name. + */ + private Name elementName; + + public MappingAttributeIterator(AppSchemaDataAccess store, FeatureTypeMapping mapping, + Query query, Query unrolledQuery) throws IOException { + super(store, mapping, query, unrolledQuery); + elementName = mapping.getTargetFeature().getName(); + checkAttributeMappings(); + } + + private void checkAttributeMappings() { + // there should only be 1 attribute mapping for this element since it's a simple type + // exception for FEATURE_LINK attributes + Iterator<AttributeMapping> mappings = mapping.getAttributeMappings().iterator(); + AttributeMapping rootMapping = null; + while (mappings.hasNext()) { + AttributeMapping att = mappings.next(); + StepList xpath = att.getTargetXPath(); + if (Types.equals(elementName, xpath)) { + if (rootMapping != null) { + throw new RuntimeException("Duplicate AttributeMapping for: '" + elementName + + "' is found in FeatureTypeMapping '" + elementName + "'!"); + } + rootMapping = att; + } else if (!Types.equals(ComplexFeatureConstants.FEATURE_CHAINING_LINK_NAME, xpath)) { + // log warning + String msg = "AttributeMapping for: '" + xpath + "' found in FeatureTypeMapping '" + + elementName + + "' ! This will be ignored as it doesn't belong to the type."; + LOGGER.warning(msg); + } + } + if (rootMapping == null) { + // not found, throw exception + throw new RuntimeException("AttributeMapping for: '" + elementName + + "' is missing in FeatureTypeMapping '" + elementName + "'!"); + } + } +} Property changes on: trunk/modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/MappingAttributeIterator.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id URL Added: svn:eol-style + native Modified: trunk/modules/extension/app-schema/app-schema/src/test/java/org/geotools/util/ComplexAttributeConverterFactoryTest.java =================================================================== --- trunk/modules/extension/app-schema/app-schema/src/test/java/org/geotools/util/ComplexAttributeConverterFactoryTest.java 2012-05-16 01:36:44 UTC (rev 38735) +++ trunk/modules/extension/app-schema/app-schema/src/test/java/org/geotools/util/ComplexAttributeConverterFactoryTest.java 2012-05-16 05:15:52 UTC (rev 38736) @@ -1,124 +1,124 @@ -/* - * GeoTools - The Open Source Java GIS Toolkit - * http://geotools.org - * - * (C) 2009-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.ArrayList; -import java.util.Collection; -import java.util.Set; - -import junit.framework.TestCase; - -import org.geotools.data.complex.ComplexFeatureConstants; -import org.geotools.feature.AttributeImpl; -import org.geotools.feature.ComplexAttributeImpl; -import org.geotools.feature.GeometryAttributeImpl; -import org.geotools.feature.NameImpl; -import org.geotools.feature.type.AttributeDescriptorImpl; -import org.geotools.feature.type.GeometryDescriptorImpl; -import org.geotools.feature.type.GeometryTypeImpl; -import org.geotools.gml3.GMLSchema; -import org.geotools.xs.XSSchema; -import org.opengis.feature.Attribute; -import org.opengis.feature.ComplexAttribute; -import org.opengis.feature.GeometryAttribute; -import org.opengis.feature.Property; -import org.opengis.feature.type.AttributeDescriptor; -import org.opengis.filter.identity.FeatureId; -import com.vividsolutions.jts.geom.EmptyGeometry; -import com.vividsolutions.jts.geom.Geometry; - -/** - * Tests for {@link ComplexAttributeConverterFactory}. - * - * @author Rini Angreani (CSIRO Earth Science and Resource Engineering) - * @author Niels Charlier - * - * - * - * - * @source $URL: http://svn.osgeo.org/geotools/trunk/modules/extension/app-schema/app-schema/src/test/java/org/geotools/util/ComplexAttributeConverterFactoryTest.java $ - */ -public class ComplexAttributeConverterFactoryTest extends TestCase { - - /** - * Test extracting complex attribute leaf value should be successful. - */ - public void testLeafComplexAttribute() { - Collection<Property> attributes = new ArrayList<Property>(); - AttributeDescriptor descriptor = new AttributeDescriptorImpl(XSSchema.STRING_TYPE, - ComplexFeatureConstants.SIMPLE_CONTENT, 1, 1, true, (Object) null); - attributes.add(new AttributeImpl("rini", descriptor, null)); - ComplexAttribute gmlName = new ComplexAttributeImpl(attributes, GMLSchema.CODETYPE_TYPE, null); - String nameString = Converters.convert(gmlName, String.class); - assertEquals("rini", nameString); - } - - /** - * Test extracting complex attribute non-leaf value should fail. - */ - public void testParentComplexAttribute() { - Collection<Property> attributes = new ArrayList<Property>(); - AttributeDescriptor descriptor = new AttributeDescriptorImpl(XSSchema.STRING_TYPE, - ComplexFeatureConstants.SIMPLE_CONTENT, 1, 1, true, (Object) null); - attributes.add(new AttributeImpl("rini", descriptor, null)); - ComplexAttribute gmlName = new ComplexAttributeImpl(attributes, GMLSchema.CODETYPE_TYPE, null); - - Collection<Property> parentAttributes = new ArrayList<Property>(); - parentAttributes.add(gmlName); - ComplexAttribute parentAtt = new ComplexAttributeImpl(parentAttributes, GMLSchema.ABSTRACTFEATURETYPE_TYPE, null); - String nameString = Converters.convert(parentAtt, String.class); - - assertEquals(parentAtt.toString(), nameString); - assertNotSame("rini", nameString); - } - - /** - * Test that normal Attribute shouldn't be affected by the converter. - */ - public void testAttribute() { - AttributeDescriptor descriptor = new AttributeDescriptorImpl(XSSchema.STRING_TYPE, - ComplexFeatureConstants.SIMPLE_CONTENT, 1, 1, true, (Object) null); - Attribute att = new AttributeImpl("rini", descriptor, null); - Set<ConverterFactory> factories = Converters.getConverterFactories(att.getClass(), String.class); - for (ConverterFactory factory : factories) { - assertFalse(factory instanceof ComplexAttributeConverterFactory); - } - } - - /** - * Test converting String to FeatureId successful. This is required by feature chaining. - * @throws Exception - */ - public void testFeatureId() throws Exception { - FeatureId id = Converters.convert("blah", FeatureId.class); - assertNotNull(id); - assertEquals(id.getID(), "blah"); - } - - /** - * Test extracting geometry from geometryattribute should be successful. - */ - public void testGeometry() { - Geometry geometry = new EmptyGeometry(); - GeometryAttribute geoatt = new GeometryAttributeImpl(geometry, new GeometryDescriptorImpl(new GeometryTypeImpl(new NameImpl(""), EmptyGeometry.class, null, false, false, null, null, null), new NameImpl(""), 0, 0, false, null), null); - Geometry geometry2 = Converters.convert(geoatt, Geometry.class); - assertTrue(geometry == geometry2); - } - - -} +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2009-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.ArrayList; +import java.util.Collection; +import java.util.Set; + +import junit.framework.TestCase; + +import org.geotools.data.complex.ComplexFeatureConstants; +import org.geotools.feature.AttributeImpl; +import org.geotools.feature.ComplexAttributeImpl; +import org.geotools.feature.GeometryAttributeImpl; +import org.geotools.feature.NameImpl; +import org.geotools.feature.type.AttributeDescriptorImpl; +import org.geotools.feature.type.GeometryDescriptorImpl; +import org.geotools.feature.type.GeometryTypeImpl; +import org.geotools.gml3.GMLSchema; +import org.geotools.xs.XSSchema; +import org.opengis.feature.Attribute; +import org.opengis.feature.ComplexAttribute; +import org.opengis.feature.GeometryAttribute; +import org.opengis.feature.Property; +import org.opengis.feature.type.AttributeDescriptor; +import org.opengis.filter.identity.FeatureId; +import com.vividsolutions.jts.geom.EmptyGeometry; +import com.vividsolutions.jts.geom.Geometry; + +/** + * Tests for {@link ComplexAttributeConverterFactory}. + * + * @author Rini Angreani (CSIRO Earth Science and Resource Engineering) + * @author Niels Charlier + * + * + * + * + * @source $URL$ + */ +public class ComplexAttributeConverterFactoryTest extends TestCase { + + /** + * Test extracting complex attribute leaf value should be successful. + */ + public void testLeafComplexAttribute() { + Collection<Property> attributes = new ArrayList<Property>(); + AttributeDescriptor descriptor = new AttributeDescriptorImpl(XSSchema.STRING_TYPE, + ComplexFeatureConstants.SIMPLE_CONTENT, 1, 1, true, (Object) null); + attributes.add(new AttributeImpl("rini", descriptor, null)); + ComplexAttribute gmlName = new ComplexAttributeImpl(attributes, GMLSchema.CODETYPE_TYPE, null); + String nameString = Converters.convert(gmlName, String.class); + assertEquals("rini", nameString); + } + + /** + * Test extracting complex attribute non-leaf value should fail. + */ + public void testParentComplexAttribute() { + Collection<Property> attributes = new ArrayList<Property>(); + AttributeDescriptor descriptor = new AttributeDescriptorImpl(XSSchema.STRING_TYPE, + ComplexFeatureConstants.SIMPLE_CONTENT, 1, 1, true, (Object) null); + attributes.add(new AttributeImpl("rini", descriptor, null)); + ComplexAttribute gmlName = new ComplexAttributeImpl(attributes, GMLSchema.CODETYPE_TYPE, null); + + Collection<Property> parentAttributes = new ArrayList<Property>(); + parentAttributes.add(gmlName); + ComplexAttribute parentAtt = new ComplexAttributeImpl(parentAttributes, GMLSchema.ABSTRACTFEATURETYPE_TYPE, null); + String nameString = Converters.convert(parentAtt, String.class); + + assertEquals(parentAtt.toString(), nameString); + assertNotSame("rini", nameString); + } + + /** + * Test that normal Attribute shouldn't be affected by the converter. + */ + public void testAttribute() { + AttributeDescriptor descriptor = new AttributeDescriptorImpl(XSSchema.STRING_TYPE, + ComplexFeatureConstants.SIMPLE_CONTENT, 1, 1, true, (Object) null); + Attribute att = new AttributeImpl("rini", descriptor, null); + Set<ConverterFactory> factories = Converters.getConverterFactories(att.getClass(), String.class); + for (ConverterFactory factory : factories) { + assertFalse(factory instanceof ComplexAttributeConverterFactory); + } + } + + /** + * Test converting String to FeatureId successful. This is required by feature chaining. + * @throws Exception + */ + public void testFeatureId() throws Exception { + FeatureId id = Converters.convert("blah", FeatureId.class); + assertNotNull(id); + assertEquals(id.getID(), "blah"); + } + + /** + * Test extracting geometry from geometryattribute should be successful. + */ + public void testGeometry() { + Geometry geometry = new EmptyGeometry(); + GeometryAttribute geoatt = new GeometryAttributeImpl(geometry, new GeometryDescriptorImpl(new GeometryTypeImpl(new NameImpl(""), EmptyGeometry.class, null, false, false, null, null, null), new NameImpl(""), 0, 0, false, null), null); + Geometry geometry2 = Converters.convert(geoatt, Geometry.class); + assertTrue(geometry == geometry2); + } + + +} Property changes on: trunk/modules/extension/app-schema/app-schema/src/test/java/org/geotools/util/ComplexAttributeConverterFactoryTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id URL Added: svn:eol-style + native Property changes on: trunk/modules/unsupported/app-schema/webservice/pom.xml ___________________________________________________________________ Modified: svn:keywords - Id + Id URL Property changes on: trunk/modules/unsupported/app-schema/webservice/src/main/java/org/geotools/filter/AsXpathFunctionExpression.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native |
Author: jdeolive Date: 2012-05-15 18:36:44 -0700 (Tue, 15 May 2012) New Revision: 38735 Added: trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGIS3DTest.java trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGIS3DTestSetup.java Modified: trunk/modules/library/jdbc/src/main/java/org/geotools/jdbc/JDBCDataStore.java trunk/modules/library/jdbc/src/main/java/org/geotools/jdbc/SQLDialect.java trunk/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialect.java trunk/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialectBasic.java trunk/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialectPrepared.java trunk/modules/plugin/jdbc/jdbc-mysql/src/main/java/org/geotools/data/mysql/MySQLDialect.java trunk/modules/plugin/jdbc/jdbc-mysql/src/main/java/org/geotools/data/mysql/MySQLDialectBasic.java trunk/modules/plugin/jdbc/jdbc-mysql/src/main/java/org/geotools/data/mysql/MySQLDialectPrepared.java 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/PostGISPSDialect.java trunk/modules/plugin/jdbc/jdbc-spatialite/src/main/java/org/geotools/data/spatialite/SpatiaLiteDialect.java trunk/modules/plugin/jdbc/jdbc-sqlserver/src/main/java/org/geotools/data/sqlserver/SQLServerDialect.java Log: GEOT-4129, updated dialect api to handle hints when encoding geometry, and updated postgis to respect Feature2D hint Modified: trunk/modules/library/jdbc/src/main/java/org/geotools/jdbc/JDBCDataStore.java =================================================================== --- trunk/modules/library/jdbc/src/main/java/org/geotools/jdbc/JDBCDataStore.java 2012-05-16 01:35:03 UTC (rev 38734) +++ trunk/modules/library/jdbc/src/main/java/org/geotools/jdbc/JDBCDataStore.java 2012-05-16 01:36:44 UTC (rev 38735) @@ -4369,6 +4369,7 @@ protected void encodeGeometryColumn(GeometryDescriptor gatt, StringBuffer sql,Hints hints) { encodeGeometryColumn(gatt, null, sql, hints); } + protected void encodeGeometryColumn(GeometryDescriptor gatt, String prefix, StringBuffer sql,Hints hints) { int srid = getDescriptorSRID(gatt); @@ -4384,7 +4385,7 @@ return; } - dialect.encodeGeometryColumn(gatt,prefix,srid, sql); + dialect.encodeGeometryColumn(gatt,prefix,srid, hints, sql); } /** Modified: trunk/modules/library/jdbc/src/main/java/org/geotools/jdbc/SQLDialect.java =================================================================== --- trunk/modules/library/jdbc/src/main/java/org/geotools/jdbc/SQLDialect.java 2012-05-16 01:35:03 UTC (rev 38734) +++ trunk/modules/library/jdbc/src/main/java/org/geotools/jdbc/SQLDialect.java 2012-05-16 01:36:44 UTC (rev 38735) @@ -705,11 +705,51 @@ * This default implementation simply uses the column name without any * wrapping function, subclasses must override. * </p> + * + * @deprecated use {@link #encodeGeometryColumn(GeometryDescriptor, String, int, Hints, StringBuffer)} */ public void encodeGeometryColumn(GeometryDescriptor gatt, String prefix, int srid, StringBuffer sql) { encodeColumnName(prefix, gatt.getLocalName(), sql); } + + /** + * Encodes the name of a geometry column in a SELECT statement. + * <p> + * This method should wrap the column name in any functions that are used to + * retrieve its value. For instance, often it is necessary to use the function + * <code>asText</code>, or <code>asWKB</code> when fetching a geometry. + * </p> + * <p> + * This method must also be sure to properly encode the name of the column with + * the {@link #encodeColumnName(String, String, StringBuffer)} function. + * </p> + * <p> + * Example: + * </p> + * + * <pre> + * <code> + * sql.append( "asText(" ); + * column( gatt.getLocalName(), sql ); + * sql.append( ")" ); + * </code> + * </pre> + * + * </p> + * <p> + * This default implementation calls the deprecated + * {@link #encodeGeometryColumn(GeometryDescriptor, String, int, StringBuffer)} version of + * this method for backward compatibility reasons. + * </p> + * + */ + public void encodeGeometryColumn(GeometryDescriptor gatt, String prefix, + int srid, Hints hints, StringBuffer sql) { + //call previously deprecated + encodeGeometryColumn(gatt, prefix, srid, sql); + } + /** * Encodes a generalized geometry using a DB provided SQL function if available * If not supported, subclasses should not implement Modified: trunk/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialect.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialect.java 2012-05-16 01:35:03 UTC (rev 38734) +++ trunk/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialect.java 2012-05-16 01:36:44 UTC (rev 38735) @@ -245,11 +245,11 @@ } @Override - public void encodeGeometryColumn(GeometryDescriptor gatt, String prefix, int srid, - StringBuffer sql) { + public void encodeGeometryColumn(GeometryDescriptor gatt, String prefix, + int srid, Hints hints, StringBuffer sql) { encodeGeometryColumn(gatt, prefix, sql); } - + public void encodeGeometryColumn(GeometryDescriptor gatt, String prefix, StringBuffer sql) { sql.append("db2gse.ST_AsBinary("); encodeColumnName(prefix, gatt.getLocalName(), sql); Modified: trunk/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialectBasic.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialectBasic.java 2012-05-16 01:35:03 UTC (rev 38734) +++ trunk/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialectBasic.java 2012-05-16 01:36:44 UTC (rev 38735) @@ -110,6 +110,12 @@ delegate.encodeGeometryColumn(gatt, prefix, srid, sql); } + @Override + public void encodeGeometryColumn(GeometryDescriptor gatt, String prefix, + int srid, Hints hints, StringBuffer sql) { + delegate.encodeGeometryColumn(gatt, prefix, srid, hints, sql); + } + @Override public void encodeGeometryEnvelope(String tableName,String geometryColumn, StringBuffer sql) { delegate.encodeGeometryEnvelope(tableName, geometryColumn, sql); Modified: trunk/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialectPrepared.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialectPrepared.java 2012-05-16 01:35:03 UTC (rev 38734) +++ trunk/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialectPrepared.java 2012-05-16 01:36:44 UTC (rev 38735) @@ -26,6 +26,7 @@ import java.util.Set; import org.geotools.data.jdbc.FilterToSQL; +import org.geotools.factory.Hints; import org.geotools.factory.Hints.Key; import org.geotools.jdbc.JDBCDataStore; import org.geotools.jdbc.PreparedFilterToSQL; @@ -112,6 +113,12 @@ delegate.encodeGeometryColumn(gatt, prefix, srid, sql); } + @Override + public void encodeGeometryColumn(GeometryDescriptor gatt, String prefix, + int srid, Hints hints, StringBuffer sql) { + delegate.encodeGeometryColumn(gatt, prefix, srid, hints, sql); + } + @Override public void encodeGeometryEnvelope(String tableName,String geometryColumn, StringBuffer sql) { delegate.encodeGeometryEnvelope(tableName, geometryColumn, sql); Modified: trunk/modules/plugin/jdbc/jdbc-mysql/src/main/java/org/geotools/data/mysql/MySQLDialect.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-mysql/src/main/java/org/geotools/data/mysql/MySQLDialect.java 2012-05-16 01:35:03 UTC (rev 38734) +++ trunk/modules/plugin/jdbc/jdbc-mysql/src/main/java/org/geotools/data/mysql/MySQLDialect.java 2012-05-16 01:36:44 UTC (rev 38735) @@ -26,6 +26,7 @@ import java.util.Map; import java.util.logging.Level; +import org.geotools.factory.Hints; import org.geotools.geometry.jts.Geometries; import org.geotools.jdbc.JDBCDataStore; import org.geotools.jdbc.SQLDialect; @@ -222,13 +223,13 @@ } @Override - public void encodeGeometryColumn(GeometryDescriptor gatt, String prefix, int srid, - StringBuffer sql) { + public void encodeGeometryColumn(GeometryDescriptor gatt, String prefix, + int srid, Hints hints, StringBuffer sql) { sql.append("asWKB("); encodeColumnName(prefix, gatt.getLocalName(), sql); sql.append(")"); } - + public void encodeGeometryEnvelope(String tableName, String geometryColumn, StringBuffer sql) { sql.append("asWKB("); sql.append("envelope("); Modified: trunk/modules/plugin/jdbc/jdbc-mysql/src/main/java/org/geotools/data/mysql/MySQLDialectBasic.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-mysql/src/main/java/org/geotools/data/mysql/MySQLDialectBasic.java 2012-05-16 01:35:03 UTC (rev 38734) +++ trunk/modules/plugin/jdbc/jdbc-mysql/src/main/java/org/geotools/data/mysql/MySQLDialectBasic.java 2012-05-16 01:36:44 UTC (rev 38735) @@ -23,6 +23,7 @@ import java.util.Map; import org.geotools.data.jdbc.FilterToSQL; +import org.geotools.factory.Hints; import org.geotools.jdbc.BasicSQLDialect; import org.geotools.jdbc.JDBCDataStore; import org.opengis.feature.simple.SimpleFeatureType; @@ -92,8 +93,14 @@ StringBuffer sql) { delegate.encodeGeometryColumn(gatt, prefix, srid, sql); } - + @Override + public void encodeGeometryColumn(GeometryDescriptor gatt, String prefix, + int srid, Hints hints, StringBuffer sql) { + delegate.encodeGeometryColumn(gatt, prefix, srid, hints, sql); + } + + @Override public void encodeColumnType(String sqlTypeName, StringBuffer sql) { delegate.encodeColumnType(sqlTypeName, sql); } Modified: trunk/modules/plugin/jdbc/jdbc-mysql/src/main/java/org/geotools/data/mysql/MySQLDialectPrepared.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-mysql/src/main/java/org/geotools/data/mysql/MySQLDialectPrepared.java 2012-05-16 01:35:03 UTC (rev 38734) +++ trunk/modules/plugin/jdbc/jdbc-mysql/src/main/java/org/geotools/data/mysql/MySQLDialectPrepared.java 2012-05-16 01:36:44 UTC (rev 38735) @@ -24,6 +24,7 @@ import java.sql.Types; import java.util.Map; +import org.geotools.factory.Hints; import org.geotools.jdbc.JDBCDataStore; import org.geotools.jdbc.PreparedStatementSQLDialect; import org.opengis.feature.simple.SimpleFeatureType; @@ -97,6 +98,13 @@ } @Override + public void encodeGeometryColumn(GeometryDescriptor gatt, String prefix, + int srid, Hints hints, StringBuffer sql) { + delegate.encodeGeometryColumn(gatt, prefix, srid, hints, sql); + } + + + @Override public void registerClassToSqlMappings(Map<Class<?>, Integer> mappings) { delegate.registerClassToSqlMappings(mappings); } Modified: trunk/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISDialect.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISDialect.java 2012-05-16 01:35:03 UTC (rev 38734) +++ trunk/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISDialect.java 2012-05-16 01:36:44 UTC (rev 38735) @@ -33,6 +33,7 @@ import java.util.logging.Level; import org.geotools.data.jdbc.FilterToSQL; +import org.geotools.factory.Hints; import org.geotools.geometry.jts.ReferencedEnvelope; import org.geotools.jdbc.BasicSQLDialect; import org.geotools.jdbc.ColumnMetadata; @@ -191,20 +192,35 @@ @Override public void encodeGeometryColumn(GeometryDescriptor gatt, String prefix, int srid, StringBuffer sql) { - - boolean geography = "geography".equals(gatt.getUserData().get(JDBCDataStore.JDBC_NATIVE_TYPENAME)); - - sql.append("encode("); - sql.append("ST_AsBinary("); - if (!geography) { - sql.append("ST_Force_2D("); + encodeGeometryColumn(gatt, prefix, srid, null, sql); + } + + @Override + public void encodeGeometryColumn(GeometryDescriptor gatt, String prefix, int srid, Hints hints, + StringBuffer sql) { + + boolean geography = "geography".equals(gatt.getUserData().get( + JDBCDataStore.JDBC_NATIVE_TYPENAME)); + + if (geography) { + sql.append("encode(ST_AsBinary("); + encodeColumnName(prefix, gatt.getLocalName(), sql); + sql.append("),'base64')"); } - - encodeColumnName(prefix, gatt.getLocalName(), sql); - if (!geography) { - sql.append(")"); + else { + boolean force2D = hints != null && hints.containsKey(Hints.FEATURE_2D) && + Boolean.TRUE.equals(hints.get(Hints.FEATURE_2D)); + + if (force2D) { + sql.append("encode(ST_AsBinary(ST_Force_2D("); + encodeColumnName(prefix, gatt.getLocalName(), sql); + sql.append(")),'base64')"); + } else { + sql.append("encode(ST_AsEWKB("); + encodeColumnName(prefix, gatt.getLocalName(), sql); + sql.append("),'base64')"); + } } - sql.append("),'base64')"); } @Override Modified: trunk/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISPSDialect.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISPSDialect.java 2012-05-16 01:35:03 UTC (rev 38734) +++ trunk/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISPSDialect.java 2012-05-16 01:36:44 UTC (rev 38735) @@ -24,6 +24,7 @@ import java.sql.Types; import java.util.Map; +import org.geotools.factory.Hints; import org.geotools.jdbc.ColumnMetadata; import org.geotools.jdbc.JDBCDataStore; import org.geotools.jdbc.PreparedFilterToSQL; @@ -84,6 +85,12 @@ delegate.encodeGeometryColumn(gatt, prefix, srid, sql); } + @Override + public void encodeGeometryColumn(GeometryDescriptor gatt, String prefix, + int srid, Hints hints, StringBuffer sql) { + delegate.encodeGeometryColumn(gatt, prefix, srid, hints, sql); + } + public void encodeGeometryEnvelope(String tableName, String geometryColumn, StringBuffer sql) { delegate.encodeGeometryEnvelope(tableName, geometryColumn, sql); Added: trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGIS3DTest.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGIS3DTest.java (rev 0) +++ trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGIS3DTest.java 2012-05-16 01:36:44 UTC (rev 38735) @@ -0,0 +1,34 @@ +/* + * 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; + +import org.geotools.jdbc.JDBC3DTest; +import org.geotools.jdbc.JDBC3DTestSetup; + +/** + * + * + * @source $URL$ + */ +public class PostGIS3DTest extends JDBC3DTest { + + @Override + protected JDBC3DTestSetup createTestSetup() { + return new PostGIS3DTestSetup(); + } + +} Added: trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGIS3DTestSetup.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGIS3DTestSetup.java (rev 0) +++ trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGIS3DTestSetup.java 2012-05-16 01:36:44 UTC (rev 38735) @@ -0,0 +1,83 @@ +/* + * 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; + +import org.geotools.jdbc.JDBC3DTestSetup; + +/** + * + * + * @source $URL$ + */ +public class PostGIS3DTestSetup extends JDBC3DTestSetup { + + protected PostGIS3DTestSetup() { + super(new PostGISTestSetup()); + + } + + @Override + protected void createLine3DTable() throws Exception { + // setup table + run("CREATE TABLE \"line3d\"(\"fid\" serial PRIMARY KEY, \"id\" int, " + + "\"geom\" geometry, \"name\" varchar )"); + run("INSERT INTO GEOMETRY_COLUMNS VALUES('', 'public', 'line3d', 'geom', 3, '4326', 'LINESTRING')"); + run("CREATE INDEX line3d_GEOM_IDX ON \"line3d\" USING GIST (\"geom\") "); + + // insert data + run("INSERT INTO \"line3d\" (\"id\",\"geom\",\"name\") VALUES (0," + + "GeomFromText('LINESTRING(1 1 0, 2 2 0, 4 2 1, 5 1 1)', 4326)," + + "'l1')"); + run("INSERT INTO \"line3d\" (\"id\",\"geom\",\"name\") VALUES (1," + + "GeomFromText('LINESTRING(3 0 1, 3 2 2, 3 3 3, 3 4 5)', 4326)," + + "'l2')"); + } + + @Override + protected void createPoint3DTable() throws Exception { + // setup table + run("CREATE TABLE \"point3d\"(\"fid\" serial PRIMARY KEY, \"id\" int, " + + "\"geom\" geometry, \"name\" varchar )"); + run("INSERT INTO GEOMETRY_COLUMNS VALUES('', 'public', 'point3d', 'geom', 3, '4326', 'POINT')"); + run("CREATE INDEX POINT3D_GEOM_IDX ON \"point3d\" USING GIST (\"geom\") "); + + // insert data + run("INSERT INTO \"point3d\" (\"id\",\"geom\",\"name\") VALUES (0," + + "GeomFromText('POINT(1 1 1)', 4326)," + "'p1')"); + run("INSERT INTO \"point3d\" (\"id\",\"geom\",\"name\") VALUES (1," + + "GeomFromText('POINT(3 0 1)', 4326)," + "'p2')"); + } + + @Override + protected void dropLine3DTable() throws Exception { + run("DELETE FROM GEOMETRY_COLUMNS WHERE F_TABLE_NAME = 'line3d'"); + run("DROP TABLE \"line3d\""); + } + + @Override + protected void dropPoly3DTable() throws Exception { + run("DELETE FROM GEOMETRY_COLUMNS WHERE F_TABLE_NAME = 'poly3d'"); + run("DROP TABLE \"poly3d\""); + } + + @Override + protected void dropPoint3DTable() throws Exception { + run("DELETE FROM GEOMETRY_COLUMNS WHERE F_TABLE_NAME = 'point3d'"); + run("DROP TABLE \"point3d\""); + } + +} Modified: trunk/modules/plugin/jdbc/jdbc-spatialite/src/main/java/org/geotools/data/spatialite/SpatiaLiteDialect.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-spatialite/src/main/java/org/geotools/data/spatialite/SpatiaLiteDialect.java 2012-05-16 01:35:03 UTC (rev 38734) +++ trunk/modules/plugin/jdbc/jdbc-spatialite/src/main/java/org/geotools/data/spatialite/SpatiaLiteDialect.java 2012-05-16 01:36:44 UTC (rev 38735) @@ -33,6 +33,7 @@ import java.util.Map; import org.geotools.data.jdbc.FilterToSQL; +import org.geotools.factory.Hints; import org.geotools.geometry.jts.Geometries; import org.geotools.jdbc.BasicSQLDialect; import org.geotools.jdbc.JDBCDataStore; @@ -197,14 +198,15 @@ return super.getGeometrySRID(schemaName, tableName, columnName, cx); } - + @Override - public void encodeGeometryColumn(GeometryDescriptor gatt, String prefix, int srid, StringBuffer sql) { + public void encodeGeometryColumn(GeometryDescriptor gatt, String prefix, + int srid, Hints hints, StringBuffer sql) { sql.append( "AsText("); encodeColumnName( prefix, gatt.getLocalName(), sql); sql.append( ")||';").append(srid).append("'"); } - + @Override public Geometry decodeGeometryValue(GeometryDescriptor descriptor, ResultSet rs, int column, GeometryFactory factory, Connection cx) throws IOException, SQLException { Modified: trunk/modules/plugin/jdbc/jdbc-sqlserver/src/main/java/org/geotools/data/sqlserver/SQLServerDialect.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-sqlserver/src/main/java/org/geotools/data/sqlserver/SQLServerDialect.java 2012-05-16 01:35:03 UTC (rev 38734) +++ trunk/modules/plugin/jdbc/jdbc-sqlserver/src/main/java/org/geotools/data/sqlserver/SQLServerDialect.java 2012-05-16 01:36:44 UTC (rev 38735) @@ -28,6 +28,7 @@ import java.util.UUID; import org.geotools.data.jdbc.FilterToSQL; +import org.geotools.factory.Hints; import org.geotools.geometry.jts.ReferencedEnvelope; import org.geotools.jdbc.BasicSQLDialect; import org.geotools.jdbc.JDBCDataStore; @@ -184,13 +185,14 @@ dataStore.closeSafe( st ); } } - + @Override - public void encodeGeometryColumn(GeometryDescriptor gatt, String prefix, int srid, StringBuffer sql) { + public void encodeGeometryColumn(GeometryDescriptor gatt, String prefix, + int srid, Hints hints, StringBuffer sql) { encodeColumnName( prefix, gatt.getLocalName(), sql ); sql.append( ".STAsBinary()"); } - + @Override public void encodeGeometryValue(Geometry value, int srid, StringBuffer sql) throws IOException { |
Author: jdeolive Date: 2012-05-15 18:35:03 -0700 (Tue, 15 May 2012) New Revision: 38734 Added: branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGIS3DTest.java branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGIS3DTestSetup.java Modified: branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/JDBCDataStore.java branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/SQLDialect.java branches/2.7.x/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialect.java branches/2.7.x/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialectBasic.java branches/2.7.x/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialectPrepared.java branches/2.7.x/modules/plugin/jdbc/jdbc-mysql/src/main/java/org/geotools/data/mysql/MySQLDialect.java branches/2.7.x/modules/plugin/jdbc/jdbc-mysql/src/main/java/org/geotools/data/mysql/MySQLDialectBasic.java branches/2.7.x/modules/plugin/jdbc/jdbc-mysql/src/main/java/org/geotools/data/mysql/MySQLDialectPrepared.java 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/PostGISPSDialect.java branches/2.7.x/modules/plugin/jdbc/jdbc-spatialite/src/main/java/org/geotools/data/spatialite/SpatiaLiteDialect.java branches/2.7.x/modules/plugin/jdbc/jdbc-sqlserver/src/main/java/org/geotools/data/sqlserver/SQLServerDialect.java Log: GEOT-4129, updated dialect api to handle hints when encoding geometry, and updated postgis to respect Feature2D hint Modified: branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/JDBCDataStore.java =================================================================== --- branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/JDBCDataStore.java 2012-05-15 21:21:56 UTC (rev 38733) +++ branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/JDBCDataStore.java 2012-05-16 01:35:03 UTC (rev 38734) @@ -4193,7 +4193,6 @@ * @param hints , may be null */ protected void encodeGeometryColumn(GeometryDescriptor gatt, StringBuffer sql,Hints hints) { - int srid = getDescriptorSRID(gatt); if (isGeneralizationRequired(hints, gatt)==true) { Double distance = (Double) hints.get(Hints.GEOMETRY_GENERALIZATION); @@ -4206,8 +4205,9 @@ dialect.encodeGeometryColumnSimplified(gatt,srid, sql,distance); return; } - - dialect.encodeGeometryColumn(gatt,srid, sql); + + dialect.encodeGeometryColumn(gatt,srid,hints,sql); + } /** Modified: branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/SQLDialect.java =================================================================== --- branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/SQLDialect.java 2012-05-15 21:21:56 UTC (rev 38733) +++ branches/2.7.x/modules/library/jdbc/src/main/java/org/geotools/jdbc/SQLDialect.java 2012-05-16 01:35:03 UTC (rev 38734) @@ -649,12 +649,50 @@ * This default implementation simply uses the column name without any * wrapping function, subclasses must override. * </p> + * @deprecated use {@link #encodeGeometryColumn(GeometryDescriptor, String, int, Hints, StringBuffer)} */ public void encodeGeometryColumn(GeometryDescriptor gatt, int srid, StringBuffer sql) { encodeColumnName(gatt.getLocalName(), sql); } - + /** + * Encodes the name of a geometry column in a SELECT statement. + * <p> + * This method should wrap the column name in any functions that are used to + * retrieve its value. For instance, often it is necessary to use the function + * <code>asText</code>, or <code>asWKB</code> when fetching a geometry. + * </p> + * <p> + * This method must also be sure to properly encode the name of the column with + * the {@link #encodeColumnName(String, String, StringBuffer)} function. + * </p> + * <p> + * Example: + * </p> + * + * <pre> + * <code> + * sql.append( "asText(" ); + * column( gatt.getLocalName(), sql ); + * sql.append( ")" ); + * </code> + * </pre> + * + * </p> + * <p> + * This default implementation calls the deprecated + * {@link #encodeGeometryColumn(GeometryDescriptor, int, StringBuffer)} version of + * this method for backward compatibility reasons. + * </p> + * + */ + public void encodeGeometryColumn(GeometryDescriptor gatt, int srid, Hints hints, StringBuffer sql) { + + //call previously deprecated + encodeGeometryColumn(gatt, srid, sql); + } + + /** * Encodes a generalized geometry using a DB provided SQL function if available * If not supported, subclasses should not implement * Only called if {@link Hints#GEOMETRY_GENERALIZATION is supported} Modified: branches/2.7.x/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialect.java =================================================================== --- branches/2.7.x/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialect.java 2012-05-15 21:21:56 UTC (rev 38733) +++ branches/2.7.x/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialect.java 2012-05-16 01:35:03 UTC (rev 38734) @@ -231,12 +231,14 @@ return srid; } - public void encodeGeometryColumn(GeometryDescriptor gatt, int srid, StringBuffer sql) { encodeGeometryColumn(gatt, sql); } - + public void encodeGeometryColumn(GeometryDescriptor gatt, int srid, Hints hints, StringBuffer sql) { + encodeGeometryColumn(gatt, sql); + } + public void encodeGeometryColumn(GeometryDescriptor gatt, StringBuffer sql) { sql.append("db2gse.ST_AsBinary("); encodeColumnName(gatt.getLocalName(), sql); Modified: branches/2.7.x/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialectBasic.java =================================================================== --- branches/2.7.x/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialectBasic.java 2012-05-15 21:21:56 UTC (rev 38733) +++ branches/2.7.x/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialectBasic.java 2012-05-16 01:35:03 UTC (rev 38734) @@ -103,6 +103,10 @@ delegate.encodeGeometryColumn(gatt, srid, sql); } + @Override + public void encodeGeometryColumn(GeometryDescriptor gatt, int srid, Hints hints, StringBuffer sql) { + delegate.encodeGeometryColumn(gatt, srid, hints, sql); + } @Override public void encodeGeometryEnvelope(String tableName,String geometryColumn, StringBuffer sql) { Modified: branches/2.7.x/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialectPrepared.java =================================================================== --- branches/2.7.x/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialectPrepared.java 2012-05-15 21:21:56 UTC (rev 38733) +++ branches/2.7.x/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialectPrepared.java 2012-05-16 01:35:03 UTC (rev 38734) @@ -24,6 +24,8 @@ import java.util.Map; import java.util.Set; +import org.geotools.data.jdbc.FilterToSQL; +import org.geotools.factory.Hints; import org.geotools.factory.Hints.Key; import org.geotools.jdbc.JDBCDataStore; import org.geotools.jdbc.PreparedFilterToSQL; @@ -99,6 +101,10 @@ delegate.encodeGeometryColumn(gatt, srid, sql); } + @Override + public void encodeGeometryColumn(GeometryDescriptor gatt, int srid, Hints hints, StringBuffer sql) { + delegate.encodeGeometryColumn(gatt, srid, hints, sql); + } @Override public void encodeGeometryEnvelope(String tableName,String geometryColumn, StringBuffer sql) { Modified: branches/2.7.x/modules/plugin/jdbc/jdbc-mysql/src/main/java/org/geotools/data/mysql/MySQLDialect.java =================================================================== --- branches/2.7.x/modules/plugin/jdbc/jdbc-mysql/src/main/java/org/geotools/data/mysql/MySQLDialect.java 2012-05-15 21:21:56 UTC (rev 38733) +++ branches/2.7.x/modules/plugin/jdbc/jdbc-mysql/src/main/java/org/geotools/data/mysql/MySQLDialect.java 2012-05-16 01:35:03 UTC (rev 38734) @@ -26,6 +26,7 @@ import java.util.Map; import java.util.logging.Level; +import org.geotools.factory.Hints; import org.geotools.geometry.jts.Geometries; import org.geotools.jdbc.JDBCDataStore; import org.geotools.jdbc.SQLDialect; @@ -212,6 +213,7 @@ } public void encodeGeometryColumn(GeometryDescriptor gatt, int srid, StringBuffer sql) { + sql.append("asWKB("); encodeColumnName(gatt.getLocalName(), sql); sql.append(")"); Modified: branches/2.7.x/modules/plugin/jdbc/jdbc-mysql/src/main/java/org/geotools/data/mysql/MySQLDialectBasic.java =================================================================== --- branches/2.7.x/modules/plugin/jdbc/jdbc-mysql/src/main/java/org/geotools/data/mysql/MySQLDialectBasic.java 2012-05-15 21:21:56 UTC (rev 38733) +++ branches/2.7.x/modules/plugin/jdbc/jdbc-mysql/src/main/java/org/geotools/data/mysql/MySQLDialectBasic.java 2012-05-16 01:35:03 UTC (rev 38734) @@ -23,6 +23,7 @@ import java.util.Map; import org.geotools.data.jdbc.FilterToSQL; +import org.geotools.factory.Hints; import org.geotools.jdbc.BasicSQLDialect; import org.geotools.jdbc.JDBCDataStore; import org.opengis.feature.simple.SimpleFeatureType; @@ -84,8 +85,13 @@ public void encodeGeometryColumn(GeometryDescriptor gatt, int srid, StringBuffer sql) { delegate.encodeGeometryColumn(gatt, srid, sql); } - + @Override + public void encodeGeometryColumn(GeometryDescriptor gatt, int srid, Hints hints, StringBuffer sql) { + delegate.encodeGeometryColumn(gatt, srid, hints, sql); + } + + @Override public void encodeColumnType(String sqlTypeName, StringBuffer sql) { delegate.encodeColumnType(sqlTypeName, sql); } Modified: branches/2.7.x/modules/plugin/jdbc/jdbc-mysql/src/main/java/org/geotools/data/mysql/MySQLDialectPrepared.java =================================================================== --- branches/2.7.x/modules/plugin/jdbc/jdbc-mysql/src/main/java/org/geotools/data/mysql/MySQLDialectPrepared.java 2012-05-15 21:21:56 UTC (rev 38733) +++ branches/2.7.x/modules/plugin/jdbc/jdbc-mysql/src/main/java/org/geotools/data/mysql/MySQLDialectPrepared.java 2012-05-16 01:35:03 UTC (rev 38734) @@ -24,6 +24,7 @@ import java.sql.Types; import java.util.Map; +import org.geotools.factory.Hints; import org.geotools.jdbc.JDBCDataStore; import org.geotools.jdbc.PreparedStatementSQLDialect; import org.opengis.feature.simple.SimpleFeatureType; @@ -90,6 +91,12 @@ } @Override + public void encodeGeometryColumn(GeometryDescriptor gatt, int srid, Hints hints, StringBuffer sql) { + delegate.encodeGeometryColumn(gatt, srid, hints, sql); + } + + + @Override public void registerClassToSqlMappings(Map<Class<?>, Integer> mappings) { delegate.registerClassToSqlMappings(mappings); } Modified: branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISDialect.java =================================================================== --- branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISDialect.java 2012-05-15 21:21:56 UTC (rev 38733) +++ branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISDialect.java 2012-05-16 01:35:03 UTC (rev 38734) @@ -33,6 +33,7 @@ import java.util.logging.Level; import org.geotools.data.jdbc.FilterToSQL; +import org.geotools.factory.Hints; import org.geotools.geometry.jts.ReferencedEnvelope; import org.geotools.jdbc.BasicSQLDialect; import org.geotools.jdbc.ColumnMetadata; @@ -173,20 +174,35 @@ @Override public void encodeGeometryColumn(GeometryDescriptor gatt, int srid, StringBuffer sql) { - - boolean geography = "geography".equals(gatt.getUserData().get(JDBCDataStore.JDBC_NATIVE_TYPENAME)); - - sql.append("encode("); - sql.append("ST_AsBinary("); - if (!geography) { - sql.append("ST_Force_2D("); + encodeGeometryColumn(gatt,srid, null, sql); + } + + @Override + public void encodeGeometryColumn(GeometryDescriptor gatt, int srid, Hints hints, + StringBuffer sql) { + + boolean geography = "geography".equals(gatt.getUserData().get( + JDBCDataStore.JDBC_NATIVE_TYPENAME)); + + if (geography) { + sql.append("encode(ST_AsBinary("); + encodeColumnName(gatt.getLocalName(), sql); + sql.append("),'base64')"); } - - encodeColumnName(gatt.getLocalName(), sql); - if (!geography) { - sql.append(")"); + else { + boolean force2D = hints != null && hints.containsKey(Hints.FEATURE_2D) && + Boolean.TRUE.equals(hints.get(Hints.FEATURE_2D)); + + if (force2D) { + sql.append("encode(ST_AsBinary(ST_Force_2D("); + encodeColumnName(gatt.getLocalName(), sql); + sql.append(")),'base64')"); + } else { + sql.append("encode(ST_AsEWKB("); + encodeColumnName(gatt.getLocalName(), sql); + sql.append("),'base64')"); + } } - sql.append("),'base64')"); } @Override Modified: branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISPSDialect.java =================================================================== --- branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISPSDialect.java 2012-05-15 21:21:56 UTC (rev 38733) +++ branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISPSDialect.java 2012-05-16 01:35:03 UTC (rev 38734) @@ -24,6 +24,7 @@ import java.sql.Types; import java.util.Map; +import org.geotools.factory.Hints; import org.geotools.jdbc.ColumnMetadata; import org.geotools.jdbc.JDBCDataStore; import org.geotools.jdbc.PreparedFilterToSQL; @@ -79,6 +80,10 @@ delegate.encodeGeometryColumn(gatt, srid, sql); } + @Override + public void encodeGeometryColumn(GeometryDescriptor gatt, int srid, Hints hints, StringBuffer sql) { + delegate.encodeGeometryColumn(gatt, srid, hints, sql); + } public void encodeGeometryEnvelope(String tableName, String geometryColumn, StringBuffer sql) { Added: branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGIS3DTest.java =================================================================== --- branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGIS3DTest.java (rev 0) +++ branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGIS3DTest.java 2012-05-16 01:35:03 UTC (rev 38734) @@ -0,0 +1,34 @@ +/* + * 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; + +import org.geotools.jdbc.JDBC3DTest; +import org.geotools.jdbc.JDBC3DTestSetup; + +/** + * + * + * @source $URL$ + */ +public class PostGIS3DTest extends JDBC3DTest { + + @Override + protected JDBC3DTestSetup createTestSetup() { + return new PostGIS3DTestSetup(); + } + +} Added: branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGIS3DTestSetup.java =================================================================== --- branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGIS3DTestSetup.java (rev 0) +++ branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGIS3DTestSetup.java 2012-05-16 01:35:03 UTC (rev 38734) @@ -0,0 +1,83 @@ +/* + * 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; + +import org.geotools.jdbc.JDBC3DTestSetup; + +/** + * + * + * @source $URL$ + */ +public class PostGIS3DTestSetup extends JDBC3DTestSetup { + + protected PostGIS3DTestSetup() { + super(new PostGISTestSetup()); + + } + + @Override + protected void createLine3DTable() throws Exception { + // setup table + run("CREATE TABLE \"line3d\"(\"fid\" serial PRIMARY KEY, \"id\" int, " + + "\"geom\" geometry, \"name\" varchar )"); + run("INSERT INTO GEOMETRY_COLUMNS VALUES('', 'public', 'line3d', 'geom', 3, '4326', 'LINESTRING')"); + run("CREATE INDEX line3d_GEOM_IDX ON \"line3d\" USING GIST (\"geom\") "); + + // insert data + run("INSERT INTO \"line3d\" (\"id\",\"geom\",\"name\") VALUES (0," + + "GeomFromText('LINESTRING(1 1 0, 2 2 0, 4 2 1, 5 1 1)', 4326)," + + "'l1')"); + run("INSERT INTO \"line3d\" (\"id\",\"geom\",\"name\") VALUES (1," + + "GeomFromText('LINESTRING(3 0 1, 3 2 2, 3 3 3, 3 4 5)', 4326)," + + "'l2')"); + } + + @Override + protected void createPoint3DTable() throws Exception { + // setup table + run("CREATE TABLE \"point3d\"(\"fid\" serial PRIMARY KEY, \"id\" int, " + + "\"geom\" geometry, \"name\" varchar )"); + run("INSERT INTO GEOMETRY_COLUMNS VALUES('', 'public', 'point3d', 'geom', 3, '4326', 'POINT')"); + run("CREATE INDEX POINT3D_GEOM_IDX ON \"point3d\" USING GIST (\"geom\") "); + + // insert data + run("INSERT INTO \"point3d\" (\"id\",\"geom\",\"name\") VALUES (0," + + "GeomFromText('POINT(1 1 1)', 4326)," + "'p1')"); + run("INSERT INTO \"point3d\" (\"id\",\"geom\",\"name\") VALUES (1," + + "GeomFromText('POINT(3 0 1)', 4326)," + "'p2')"); + } + + @Override + protected void dropLine3DTable() throws Exception { + run("DELETE FROM GEOMETRY_COLUMNS WHERE F_TABLE_NAME = 'line3d'"); + run("DROP TABLE \"line3d\""); + } + + @Override + protected void dropPoly3DTable() throws Exception { + run("DELETE FROM GEOMETRY_COLUMNS WHERE F_TABLE_NAME = 'poly3d'"); + run("DROP TABLE \"poly3d\""); + } + + @Override + protected void dropPoint3DTable() throws Exception { + run("DELETE FROM GEOMETRY_COLUMNS WHERE F_TABLE_NAME = 'point3d'"); + run("DROP TABLE \"point3d\""); + } + +} Modified: branches/2.7.x/modules/plugin/jdbc/jdbc-spatialite/src/main/java/org/geotools/data/spatialite/SpatiaLiteDialect.java =================================================================== --- branches/2.7.x/modules/plugin/jdbc/jdbc-spatialite/src/main/java/org/geotools/data/spatialite/SpatiaLiteDialect.java 2012-05-15 21:21:56 UTC (rev 38733) +++ branches/2.7.x/modules/plugin/jdbc/jdbc-spatialite/src/main/java/org/geotools/data/spatialite/SpatiaLiteDialect.java 2012-05-16 01:35:03 UTC (rev 38734) @@ -33,6 +33,7 @@ import java.util.Map; import org.geotools.data.jdbc.FilterToSQL; +import org.geotools.factory.Hints; import org.geotools.geometry.jts.Geometries; import org.geotools.jdbc.BasicSQLDialect; import org.geotools.jdbc.JDBCDataStore; @@ -196,14 +197,14 @@ return super.getGeometrySRID(schemaName, tableName, columnName, cx); } - + @Override public void encodeGeometryColumn(GeometryDescriptor gatt, int srid, StringBuffer sql) { sql.append( "AsText("); encodeColumnName( gatt.getLocalName(), sql); sql.append( ")||';").append(srid).append("'"); } - + @Override public Geometry decodeGeometryValue(GeometryDescriptor descriptor, ResultSet rs, int column, GeometryFactory factory, Connection cx) throws IOException, SQLException { Modified: branches/2.7.x/modules/plugin/jdbc/jdbc-sqlserver/src/main/java/org/geotools/data/sqlserver/SQLServerDialect.java =================================================================== --- branches/2.7.x/modules/plugin/jdbc/jdbc-sqlserver/src/main/java/org/geotools/data/sqlserver/SQLServerDialect.java 2012-05-15 21:21:56 UTC (rev 38733) +++ branches/2.7.x/modules/plugin/jdbc/jdbc-sqlserver/src/main/java/org/geotools/data/sqlserver/SQLServerDialect.java 2012-05-16 01:35:03 UTC (rev 38734) @@ -28,6 +28,7 @@ import java.util.UUID; import org.geotools.data.jdbc.FilterToSQL; +import org.geotools.factory.Hints; import org.geotools.geometry.jts.ReferencedEnvelope; import org.geotools.jdbc.BasicSQLDialect; import org.geotools.jdbc.JDBCDataStore; @@ -183,13 +184,13 @@ dataStore.closeSafe( st ); } } - + @Override public void encodeGeometryColumn(GeometryDescriptor gatt, int srid, StringBuffer sql) { encodeColumnName( gatt.getLocalName(), sql ); sql.append( ".STAsBinary()"); } - + @Override public void encodeGeometryValue(Geometry value, int srid, StringBuffer sql) throws IOException { |
Author: mdavis Date: 2012-05-15 14:21:56 -0700 (Tue, 15 May 2012) New Revision: 38733 Added: trunk/modules/library/main/src/test/java/org/geotools/geometry/jts/coordinatesequence/ trunk/modules/library/main/src/test/java/org/geotools/geometry/jts/coordinatesequence/CoordinateSequencesTest.java Modified: trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/AbstractGeometryTypeBinding.java trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/DirectPositionListTypeBinding.java trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/DirectPositionTypeBinding.java trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/EnvelopeTypeBinding.java trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/GML3EncodingUtils.java trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/PointTypeBinding.java trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/GML3TestSupport.java trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/DirectPositionListTypeBindingTest.java trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/DirectPositionTypeBindingTest.java trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/GML3MockData.java trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/LineStringTypeBindingTest.java trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiLineStringTypeBindingTest.java trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/PointTypeBindingTest.java trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/PolygonTypeBindingTest.java trunk/modules/library/main/src/main/java/org/geotools/geometry/jts/coordinatesequence/CoordinateSequences.java trunk/modules/library/xml/src/test/java/org/geotools/GMLTest.java Log: GEOT-4136, handling 3D data in gml3 encoding Modified: trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/AbstractGeometryTypeBinding.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/AbstractGeometryTypeBinding.java 2012-05-15 21:21:38 UTC (rev 38732) +++ trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/AbstractGeometryTypeBinding.java 2012-05-15 21:21:56 UTC (rev 38733) @@ -18,6 +18,7 @@ import javax.xml.namespace.QName; +import org.geotools.geometry.jts.coordinatesequence.CoordinateSequences; import org.geotools.gml3.GML; import org.geotools.xml.AbstractComplexBinding; import org.geotools.xml.ElementInstance; @@ -116,10 +117,12 @@ } if ("srsDimension".equals(name.getLocalPart())) { - CoordinateReferenceSystem crs = GML3EncodingUtils.getCRS(geometry); - if (crs != null) { - return crs.getCoordinateSystem().getDimension(); - } + /** + * For the dimension, use the actual dimension of the geometry. Using + * the dimension of the CRS is not sufficient, since currently CRSes + * don't support 3D. + */ + return CoordinateSequences.coordinateDimension(geometry); } // FIXME: should be gml:id, but which GML? Modified: trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/DirectPositionListTypeBinding.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/DirectPositionListTypeBinding.java 2012-05-15 21:21:38 UTC (rev 38732) +++ trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/DirectPositionListTypeBinding.java 2012-05-15 21:21:56 UTC (rev 38733) @@ -22,6 +22,7 @@ import org.geotools.geometry.DirectPosition1D; import org.geotools.geometry.DirectPosition2D; +import org.geotools.geometry.jts.coordinatesequence.CoordinateSequences; import org.geotools.gml3.GML; import org.geotools.xml.AbstractComplexBinding; import org.geotools.xml.ElementInstance; @@ -31,6 +32,8 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; +import com.vividsolutions.jts.geom.CoordinateSequence; + /** * Binding object for the type * http://www.opengis.net/gml:DirectPositionListType. @@ -86,7 +89,7 @@ * @generated modifiable */ public Class getType() { - return DirectPosition[].class; + return CoordinateSequence.class; } /** @@ -144,21 +147,36 @@ return dps; } + /** + * + * @param object a CoordinateSequence + * + * @see org.geotools.xml.AbstractComplexBinding#encode(java.lang.Object, org.w3c.dom.Document, org.w3c.dom.Element) + */ public Element encode(Object object, Document document, Element value) throws Exception { // TODO: remove this when the parser can do lists - DirectPosition[] dps = (DirectPosition[]) object; + CoordinateSequence cs = (CoordinateSequence) object; StringBuffer sb = new StringBuffer(); - for (int i = 0; i < dps.length; i++) { - sb.append(dps[i].getOrdinate(0) + " " + dps[i].getOrdinate(1)); + int dim = CoordinateSequences.coordinateDimension(cs); + int size = cs.size(); + int nOrdWithSpace = size * dim - 1; + int count = 0; + for (int i = 0; i < size; i++) { + for (int d = 0; d < dim; d++) { + sb.append(cs.getOrdinate(i, d)); + + if (count < nOrdWithSpace) { + sb.append(" "); + } + count++; - if (i < (dps.length - 1)) { - sb.append(" "); - } + } } value.appendChild(document.createTextNode(sb.toString())); return value; } + } Modified: trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/DirectPositionTypeBinding.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/DirectPositionTypeBinding.java 2012-05-15 21:21:38 UTC (rev 38732) +++ trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/DirectPositionTypeBinding.java 2012-05-15 21:21:56 UTC (rev 38733) @@ -29,6 +29,7 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; +import com.vividsolutions.jts.geom.CoordinateSequence; import com.vividsolutions.jts.geom.GeometryFactory; @@ -87,7 +88,7 @@ * @generated modifiable */ public Class getType() { - return DirectPosition2D.class; + return CoordinateSequence.class; } /** @@ -118,21 +119,27 @@ public Element encode(Object object, Document document, Element value) throws Exception { - DirectPosition dp = (DirectPosition) object; + CoordinateSequence cs = (CoordinateSequence) object; - double[] coordinates = dp.getCoordinate(); - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < coordinates.length; i++) { - sb.append(String.valueOf(coordinates[i])); + // assume either zero or one coordinate + if (cs.size() >= 1) { + int dim = cs.getDimension(); + for (int d = 0; d < dim; d++) { + double v = cs.getOrdinate(0, d); + if (Double.isNaN(v) && d > 1) { + continue; + } - if (i != (coordinates.length - 1)) { - sb.append(" "); + // separator char is a blank + sb.append(String.valueOf(v)).append(" "); } + if (dim > 0) { + sb.setLength(sb.length()-1); + } } - //Element pos = document.createElementNS(GML.pos.getNamespaceURI(), GML.pos.getLocalPart()); value.appendChild(document.createTextNode(sb.toString())); return value; Modified: trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/EnvelopeTypeBinding.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/EnvelopeTypeBinding.java 2012-05-15 21:21:38 UTC (rev 38732) +++ trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/EnvelopeTypeBinding.java 2012-05-15 21:21:56 UTC (rev 38733) @@ -20,7 +20,7 @@ import javax.xml.namespace.QName; -import org.geotools.geometry.DirectPosition2D; +import org.geotools.geometry.jts.LiteCoordinateSequence; import org.geotools.geometry.jts.ReferencedEnvelope; import org.geotools.gml3.GML; import org.geotools.xml.AbstractComplexBinding; @@ -166,11 +166,11 @@ } if (name.getLocalPart().equals("lowerCorner")) { - return new DirectPosition2D(envelope.getMinX(), envelope.getMinY()); + return new LiteCoordinateSequence(new double[] { envelope.getMinX(), envelope.getMinY() }, 2); } if (name.getLocalPart().equals("upperCorner")) { - return new DirectPosition2D(envelope.getMaxX(), envelope.getMaxY()); + return new LiteCoordinateSequence(new double[] { envelope.getMaxX(), envelope.getMaxY() }, 2); } if (envelope instanceof ReferencedEnvelope) { Modified: trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/GML3EncodingUtils.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/GML3EncodingUtils.java 2012-05-15 21:21:38 UTC (rev 38732) +++ trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/GML3EncodingUtils.java 2012-05-15 21:21:56 UTC (rev 38733) @@ -28,7 +28,6 @@ import org.eclipse.xsd.XSDElementDeclaration; import org.geotools.feature.NameImpl; -import org.geotools.geometry.DirectPosition2D; import org.geotools.gml2.bindings.GML2EncodingUtils; import org.geotools.gml2.bindings.GMLEncodingUtils; import org.geotools.gml3.GML; @@ -45,7 +44,6 @@ import org.opengis.feature.simple.SimpleFeature; import org.opengis.feature.type.Name; import org.opengis.filter.identity.FeatureId; -import org.opengis.geometry.DirectPosition; import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -85,20 +83,8 @@ e = new GMLEncodingUtils(gml); } - static DirectPosition[] positions(LineString line) { - CoordinateSequence coordinates = line.getCoordinateSequence(); - DirectPosition[] dps = new DirectPosition[coordinates.size()]; - - double x; - double y; - - for (int i = 0; i < dps.length; i++) { - x = coordinates.getOrdinate(i, 0); - y = coordinates.getOrdinate(i, 1); - dps[i] = new DirectPosition2D(x, y); - } - - return dps; + static CoordinateSequence positions(LineString line) { + return line.getCoordinateSequence(); } static URI toURI(CoordinateReferenceSystem crs) { Modified: trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/PointTypeBinding.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/PointTypeBinding.java 2012-05-15 21:21:38 UTC (rev 38732) +++ trunk/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/PointTypeBinding.java 2012-05-15 21:21:56 UTC (rev 38733) @@ -143,12 +143,7 @@ if ("pos".equals(name.getLocalPart())) { Point point = (Point) object; - - DirectPosition2D dp = new DirectPosition2D(); - dp.setOrdinate(0, point.getX()); - dp.setOrdinate(1, point.getY()); - - return dp; + return point.getCoordinateSequence(); } return null; Modified: trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/GML3TestSupport.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/GML3TestSupport.java 2012-05-15 21:21:38 UTC (rev 38732) +++ trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/GML3TestSupport.java 2012-05-15 21:21:56 UTC (rev 38733) @@ -18,8 +18,11 @@ import org.geotools.xml.Configuration; import org.geotools.xml.test.XMLTestSupport; +import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /* * Test bindings by extending this class with test cases that follow this pattern: @@ -80,7 +83,53 @@ protected Configuration createConfiguration() { return new GMLConfiguration(enableExtendedArcSurfaceSupport()); } + + protected void checkPosOrdinates(Document doc, int expectedNumOrdinates) + { + checkOrdinates(doc, GML.pos.getLocalPart(), expectedNumOrdinates); + } + protected void checkPosListOrdinates(Document doc, int expectedNumOrdinates) + { + checkOrdinates(doc, GML.posList.getLocalPart(), expectedNumOrdinates); + } + + + /** + * Checks that a posList exists, has a string as content, + * and the string encodes nOrdinates ordinates correctly + * (i.e. blank-separated). + * + * @param doc + * @param expectedNumOrdinates + */ + private void checkOrdinates(Document doc, String ordTag, int expectedNumOrdinates) { + NodeList nl = doc.getElementsByTagNameNS(GML.NAMESPACE, ordTag); + Node posListNode = nl.item(0); + assertEquals(1, posListNode.getChildNodes().getLength()); + String content = posListNode.getChildNodes().item(0).getNodeValue(); + String[] ord = content.split("\\s+"); + assertEquals(expectedNumOrdinates, ord.length); + } + + /** + * Checks that a given geometry element has an srsDimension attribute with an expected value + * + * @param doc + * @param tag + * @param expectedDim + */ + protected void checkDimension(Document doc, String tag, int expectedDim) { + NodeList lsNL = doc.getElementsByTagNameNS(GML.NAMESPACE, tag); + Node geomNode = lsNL.item(0); + NamedNodeMap attrMap = geomNode.getAttributes(); + Node dimNode = attrMap.getNamedItem("srsDimension"); + assertNotNull(dimNode); + String dimStr = dimNode.getChildNodes().item(0).getNodeValue(); + int dim = Integer.parseInt(dimStr); + assertEquals(dim, expectedDim); + } + /* * To be overriden by subclasses that require the extended arc/surface bindings * enabled. Modified: trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/DirectPositionListTypeBindingTest.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/DirectPositionListTypeBindingTest.java 2012-05-15 21:21:38 UTC (rev 38732) +++ trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/DirectPositionListTypeBindingTest.java 2012-05-15 21:21:56 UTC (rev 38733) @@ -21,8 +21,12 @@ import org.geotools.gml3.GML; import org.geotools.gml3.GML3TestSupport; import org.opengis.geometry.DirectPosition; +import org.w3c.dom.Document; +import com.vividsolutions.jts.geom.CoordinateSequence; +import com.vividsolutions.jts.geom.LineString; + /** * * @@ -80,4 +84,18 @@ assertEquals(3d, dps[1].getOrdinate(0), 0d); assertEquals(4d, dps[1].getOrdinate(1), 0d); } + + public void testEncode2D() throws Exception { + LineString line = GML3MockData.lineStringLite2D(); + CoordinateSequence seq = line.getCoordinateSequence(); + Document doc = encode(seq, GML.posList); + checkPosListOrdinates(doc, 2 * line.getNumPoints()); + } + + public void testEncode3D() throws Exception { + LineString line = GML3MockData.lineStringLite3D(); + CoordinateSequence seq = line.getCoordinateSequence(); + Document doc = encode(seq, GML.posList); + checkPosListOrdinates(doc, 3 * line.getNumPoints()); + } } Modified: trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/DirectPositionTypeBindingTest.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/DirectPositionTypeBindingTest.java 2012-05-15 21:21:38 UTC (rev 38732) +++ trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/DirectPositionTypeBindingTest.java 2012-05-15 21:21:56 UTC (rev 38733) @@ -21,8 +21,13 @@ import org.geotools.gml3.GML; import org.geotools.gml3.GML3TestSupport; import org.opengis.geometry.DirectPosition; +import org.w3c.dom.Document; +import com.vividsolutions.jts.geom.CoordinateSequence; +import com.vividsolutions.jts.geom.LineString; +import com.vividsolutions.jts.geom.Point; + /** * * @@ -53,4 +58,20 @@ assertEquals(pos.getOrdinate(0), 1.0, 0); assertEquals(pos.getOrdinate(1), 2.0, 0); } + + public void testEncode2D() throws Exception { + Point point = GML3MockData.pointLite2D(); + CoordinateSequence seq = point.getCoordinateSequence(); + Document doc = encode(seq, GML.pos); + checkPosOrdinates(doc, 2); + } + + public void testEncode3D() throws Exception { + Point point = GML3MockData.pointLite3D(); + CoordinateSequence seq = point.getCoordinateSequence(); + Document doc = encode(seq, GML.pos); + checkPosOrdinates(doc, 3); + } + + } Modified: trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/GML3MockData.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/GML3MockData.java 2012-05-15 21:21:38 UTC (rev 38732) +++ trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/GML3MockData.java 2012-05-15 21:21:56 UTC (rev 38733) @@ -22,6 +22,8 @@ import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; +import org.geotools.geometry.jts.LiteCoordinateSequence; +import org.geotools.geometry.jts.LiteCoordinateSequenceFactory; import org.geotools.geometry.jts.ReferencedEnvelope; import org.geotools.gml3.GML; import org.geotools.referencing.CRS; @@ -34,6 +36,7 @@ import org.w3c.dom.Node; import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.CoordinateSequenceFactory; import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryCollection; @@ -59,6 +62,10 @@ */ public class GML3MockData { static GeometryFactory gf = new GeometryFactory(); + + static LiteCoordinateSequenceFactory liteCSF = new LiteCoordinateSequenceFactory(); + static GeometryFactory liteGF = new GeometryFactory(liteCSF); + static XSD gml = GML.getInstance(); public static void setGML(XSD gml) { @@ -97,10 +104,64 @@ return p; } + /** + * Creates a Point using a LiteCoordinateSequence + * with a 2D coordinate. + * + * @return a 2D Point + */ + public static Point pointLite2D() { + return liteGF.createPoint(new LiteCoordinateSequence(new double[] { 1, 2}, 2)); + } + + /** + * Creates a Point using a LiteCoordinateSequence + * with a 2D coordinate. + * + * @return a 2D Point + */ + public static Point pointLite3D() { + return liteGF.createPoint(new LiteCoordinateSequence(new double[] { 1, 2, 100}, 3)); + } + public static LineString lineString() { return gf.createLineString(new Coordinate[] { new Coordinate(1, 2), new Coordinate(3, 4) }); } + /** + * Creates a LineString using a LiteCoordinateSequence + * with 2 2D coordinates. + * + * @return a 2D LineString + */ + public static LineString lineStringLite2D() { + return liteGF.createLineString(new Coordinate[] { new Coordinate(1, 2), new Coordinate(3, 4) }); + } + + /** + * Creates a LineString using a LiteCoordinateSequence + * with 2 2D coordinates. + * + * @return a 2D LineString + */ + public static LineString lineStringLite2D(int size) { + Coordinate[] coords = new Coordinate[size]; + for (int i = 0; i < size; i++) { + coords[i] = new Coordinate(i, i+1); + } + return liteGF.createLineString(coords); + } + + /** + * Creates a LineString using a LiteCoordinateSequence + * with 2 3D coordinates. + * + * @return a 3D LineString + */ + public static LineString lineStringLite3D() { + return liteGF.createLineString(liteCSF.create(new double[] { 1, 2, 100, 3, 4, 200}, 3)); + } + public static Element lineString(Document document, Node parent) { return lineStringWithPos(document, parent); } @@ -193,6 +254,32 @@ return gf.createPolygon(linearRing(), null); } + /** + * Creates a Polygon using a LiteCoordinateSequence + * with 2D coordinates. + * + * @return a 2D Polygon + */ + public static Polygon polygonLite2D() { + return liteGF.createPolygon( + liteGF.createLinearRing(liteCSF.create( + new double[] { 1,1, 2,1, 2,2, 1,2, 1,1 }, 2 )), + null); + } + + /** + * Creates a Polygon using a LiteCoordinateSequence + * with 3D coordinates. + * + * @return a 3D Polygon + */ + public static Polygon polygonLite3D() { + return liteGF.createPolygon( + liteGF.createLinearRing(liteCSF.create( + new double[] { 1,1,100, 2,1,99, 2,2,98, 1,2,97, 1,1,100}, 3)), + null); + } + public static Element polygon(Document document, Node parent) { return polygon(document,parent,qName("Polygon"),false); } Modified: trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/LineStringTypeBindingTest.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/LineStringTypeBindingTest.java 2012-05-15 21:21:38 UTC (rev 38732) +++ trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/LineStringTypeBindingTest.java 2012-05-15 21:21:56 UTC (rev 38733) @@ -16,7 +16,9 @@ */ package org.geotools.gml3.bindings; +import org.geotools.gml3.GML; import org.geotools.gml3.GML3TestSupport; +import org.w3c.dom.Document; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.LineString; @@ -47,4 +49,48 @@ assertEquals(new Coordinate(1d, 2d), line.getPointN(0).getCoordinate()); assertEquals(new Coordinate(3d, 4d), line.getPointN(1).getCoordinate()); } + + /** + * Tests encoding using a CoordinateArraySequence + * (which requires special logic to get the dimension correct) + * @throws Exception + */ + public void testEncodeLineString() throws Exception { + LineString line = GML3MockData.lineString(); + Document doc = encode(line, GML.LineString); + + checkDimension(doc, GML.LineString.getLocalPart(), 2); + checkPosListOrdinates(doc, 2 * line.getNumPoints()); + } + + public void testEncodeLite2D() throws Exception { + LineString line = GML3MockData.lineStringLite2D(); + Document doc = encode(line, GML.LineString); + + checkDimension(doc, GML.LineString.getLocalPart(), 2); + checkPosListOrdinates(doc, 2 * line.getNumPoints()); + } + + public void testEncodeLite3D() throws Exception { + LineString line = GML3MockData.lineStringLite3D(); + Document doc = encode(line, GML.LineString); + + checkDimension(doc, GML.LineString.getLocalPart(), 3); + checkPosListOrdinates(doc, 3 * line.getNumPoints()); + } + + /** + * Test a long LineString to catch problems that only show up with large numbers of ordinates + * + * @throws Exception + */ + public void testEncode2DLong() throws Exception { + LineString line = GML3MockData.lineStringLite2D(10); + Document doc = encode(line, GML.LineString); + + checkDimension(doc, GML.LineString.getLocalPart(), 2); + checkPosListOrdinates(doc, 2 * line.getNumPoints()); + } + + } Modified: trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiLineStringTypeBindingTest.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiLineStringTypeBindingTest.java 2012-05-15 21:21:38 UTC (rev 38732) +++ trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiLineStringTypeBindingTest.java 2012-05-15 21:21:56 UTC (rev 38733) @@ -51,6 +51,9 @@ assertEquals(2, children.getLength()); assertEquals("geometry.1", getID(children.item(0))); assertEquals("geometry.2", getID(children.item(1))); + + checkDimension(dom, GML.MultiLineString.getLocalPart(), 2); + checkDimension(dom, GML.LineString.getLocalPart(), 2); + checkPosListOrdinates(dom, 2 * geometry.getGeometryN(0).getNumPoints()); } - } Modified: trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/PointTypeBindingTest.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/PointTypeBindingTest.java 2012-05-15 21:21:38 UTC (rev 38732) +++ trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/PointTypeBindingTest.java 2012-05-15 21:21:56 UTC (rev 38733) @@ -22,6 +22,7 @@ import org.w3c.dom.Document; import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.LineString; import com.vividsolutions.jts.geom.Point; @@ -50,4 +51,21 @@ //assertEquals("urn:x-ogc:def:crs:EPSG:6.11.2:4326", assertEquals("urn:x-ogc:def:crs:EPSG:4326", dom.getDocumentElement().getAttribute("srsName")); } + + public void testEncode2D() throws Exception { + Point point = GML3MockData.pointLite2D(); + Document doc = encode(point, GML.Point); + + checkDimension(doc, GML.Point.getLocalPart(), 2); + checkPosOrdinates(doc, 2); + } + + public void testEncode3D() throws Exception { + Point point = GML3MockData.pointLite3D(); + Document doc = encode(point, GML.Point); + + checkDimension(doc, GML.Point.getLocalPart(), 3); + checkPosOrdinates(doc, 3); + } + } Modified: trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/PolygonTypeBindingTest.java =================================================================== --- trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/PolygonTypeBindingTest.java 2012-05-15 21:21:38 UTC (rev 38732) +++ trunk/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/PolygonTypeBindingTest.java 2012-05-15 21:21:56 UTC (rev 38733) @@ -16,8 +16,11 @@ */ package org.geotools.gml3.bindings; +import org.geotools.gml3.GML; import org.geotools.gml3.GML3TestSupport; +import org.w3c.dom.Document; +import com.vividsolutions.jts.geom.LineString; import com.vividsolutions.jts.geom.Polygon; @@ -33,4 +36,22 @@ Polygon polygon = (Polygon) parse(); assertNotNull(polygon); } + + public void testEncode3D() throws Exception { + Polygon poly = GML3MockData.polygonLite3D(); + Document doc = encode(poly, GML.Polygon); + + checkDimension(doc, GML.Polygon.getLocalPart(), 3); + checkPosListOrdinates(doc, 3 * poly.getNumPoints()); + } + + public void testEncode2D() throws Exception { + Polygon poly = GML3MockData.polygonLite2D(); + Document doc = encode(poly, GML.Polygon); + + checkDimension(doc, GML.Polygon.getLocalPart(), 2); + checkPosListOrdinates(doc, 2 * poly.getNumPoints()); + } + + } Modified: trunk/modules/library/main/src/main/java/org/geotools/geometry/jts/coordinatesequence/CoordinateSequences.java =================================================================== --- trunk/modules/library/main/src/main/java/org/geotools/geometry/jts/coordinatesequence/CoordinateSequences.java 2012-05-15 21:21:38 UTC (rev 38732) +++ trunk/modules/library/main/src/main/java/org/geotools/geometry/jts/coordinatesequence/CoordinateSequences.java 2012-05-15 21:21:56 UTC (rev 38733) @@ -21,10 +21,17 @@ import com.vividsolutions.jts.algorithm.RobustDeterminant; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.CoordinateSequence; +import com.vividsolutions.jts.geom.CoordinateSequenceFilter; +import com.vividsolutions.jts.geom.Geometry; +import com.vividsolutions.jts.geom.LineString; +import com.vividsolutions.jts.geom.Point; +import com.vividsolutions.jts.geom.Polygon; +import com.vividsolutions.jts.geom.impl.CoordinateArraySequence; /** * Utility functions for coordinate sequences (extends the same named JTS class) * @author Andrea Aime - OpenGeo + * @author Martin Davis - OpenGeo * * * @source $URL$ @@ -125,4 +132,90 @@ return RobustDeterminant.signOfDet2x2(dx1, dy1, dx2, dy2); } + + /** + * Gets the dimension of the coordinates in a {@link Geometry}, + * by reading it from a component {@link CoordinateSequence}. + * This will be usually either 2 or 3. + * + * @param g a Geometry + * @return the dimension of the coordinates in the Geometry + */ + public static int coordinateDimension(Geometry g) + { + // common fast cases + if (g instanceof Point) + return coordinateDimension(((Point) g).getCoordinateSequence()); + if (g instanceof LineString) + return coordinateDimension(((LineString) g).getCoordinateSequence()); + if (g instanceof Polygon) + return coordinateDimension(((Polygon) g).getExteriorRing() + .getCoordinateSequence()); + + // dig down to find a CS + CoordinateSequence cs = CoordinateSequenceFinder.find(g); + return coordinateDimension(cs); + } + + /** + * Gets the effective dimension of a CoordinateSequence. + * This is a workaround for the issue that CoordinateArraySequence + * does not keep an accurate dimension - it always + * reports dim=3, even if there is no Z ordinate (ie they are NaN). + * This method checks for that case and reports dim=2. + * Only the first coordinate is checked. + * <p> + * There is one small hole: if a CoordinateArraySequence is empty, + * the dimension will be reported as 3. + * + * @param seq a CoordinateSequence + * @return the effective dimension of the coordinate sequence + */ + public static int coordinateDimension(CoordinateSequence seq) + { + int dim = seq.getDimension(); + if (dim != 3) + return dim; + + // hack to handle issue that CoordinateArraySequence always reports + // dimension = 3 + // check if a Z value is NaN - if so, assume dim is 2 + if (seq instanceof CoordinateArraySequence) { + if (seq.size() > 0) { + if (Double.isNaN(seq.getOrdinate(0, CoordinateSequence.Z))) + return 2; + } + } + return 3; + } + + private static class CoordinateSequenceFinder implements CoordinateSequenceFilter { + + public static CoordinateSequence find(Geometry g) { + CoordinateSequenceFinder finder = new CoordinateSequenceFinder(); + g.apply(finder); + return finder.getSeq(); + } + + private CoordinateSequence firstSeqFound = null; + + public CoordinateSequence getSeq() { + return firstSeqFound; + } + + public void filter(CoordinateSequence seq, int i) { + if (firstSeqFound == null) + firstSeqFound = seq; + + } + + public boolean isDone() { + return firstSeqFound != null; + } + + public boolean isGeometryChanged() { + return false; + } + + } } Added: trunk/modules/library/main/src/test/java/org/geotools/geometry/jts/coordinatesequence/CoordinateSequencesTest.java =================================================================== --- trunk/modules/library/main/src/test/java/org/geotools/geometry/jts/coordinatesequence/CoordinateSequencesTest.java (rev 0) +++ trunk/modules/library/main/src/test/java/org/geotools/geometry/jts/coordinatesequence/CoordinateSequencesTest.java 2012-05-15 21:21:56 UTC (rev 38733) @@ -0,0 +1,63 @@ +package org.geotools.geometry.jts.coordinatesequence; + +import static org.junit.Assert.assertEquals; + +import org.geotools.geometry.jts.LiteCoordinateSequence; +import org.geotools.geometry.jts.LiteCoordinateSequenceFactory; +import org.junit.Test; + +import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.Geometry; +import com.vividsolutions.jts.geom.GeometryFactory; + +public class CoordinateSequencesTest { + + static GeometryFactory gf = new GeometryFactory(); + + static LiteCoordinateSequenceFactory liteCSF = new LiteCoordinateSequenceFactory(); + static GeometryFactory liteGF = new GeometryFactory(liteCSF); + + + @Test + public void testCoordinateDimensionPointLite2D() + { + Geometry geom = liteGF.createPoint(new LiteCoordinateSequence(new double[] { 1, 2}, 2)); + assertEquals(2, CoordinateSequences.coordinateDimension(geom)); + } + @Test + public void testCoordinateDimensionPointLite3D() + { + Geometry geom = liteGF.createPoint(new LiteCoordinateSequence(new double[] { 1, 2, 99}, 3)); + assertEquals(3, CoordinateSequences.coordinateDimension(geom)); + } + @Test + public void testCoordinateDimensionLineString2D() + { + Geometry geom = gf.createLineString(new Coordinate[] { new Coordinate(1, 2), new Coordinate(3, 4) }); + assertEquals(2, CoordinateSequences.coordinateDimension(geom)); + } + @Test + public void testCoordinateDimensionLineStringLite3D() + { + Geometry geom = liteGF.createLineString(liteCSF.create(new double[] { 1, 2, 100, 3, 4, 200}, 3)); + assertEquals(3, CoordinateSequences.coordinateDimension(geom)); + } + @Test + public void testCoordinateDimensionPolygonLite2D() + { + Geometry geom = liteGF.createPolygon( + liteGF.createLinearRing(liteCSF.create( + new double[] { 1,1, 2,1, 2,2, 1,2, 1,1 }, 2 )), + null); + assertEquals(2, CoordinateSequences.coordinateDimension(geom)); + } + @Test + public void testCoordinateDimensionPolygonLite3D() + { + Geometry geom = liteGF.createPolygon( + liteGF.createLinearRing(liteCSF.create( + new double[] { 1,1,100, 2,1,99, 2,2,98, 1,2,97, 1,1,100}, 3)), + null); + assertEquals(3, CoordinateSequences.coordinateDimension(geom)); + } +} Modified: trunk/modules/library/xml/src/test/java/org/geotools/GMLTest.java =================================================================== --- trunk/modules/library/xml/src/test/java/org/geotools/GMLTest.java 2012-05-15 21:21:38 UTC (rev 38732) +++ trunk/modules/library/xml/src/test/java/org/geotools/GMLTest.java 2012-05-15 21:21:56 UTC (rev 38733) @@ -191,7 +191,7 @@ out.close(); String gml = out.toString(); - assertTrue(gml.indexOf("<gml:Point>") != -1); + assertTrue(gml.indexOf("<gml:Point") != -1); } // |
From: <svn...@os...> - 2012-05-15 21:21:46
|
Author: mdavis Date: 2012-05-15 14:21:38 -0700 (Tue, 15 May 2012) New Revision: 38732 Added: trunk/modules/library/main/src/test/java/org/geotools/geometry/jts/GeometryCoordinateSequenceTransformerTest.java Modified: trunk/modules/library/api/src/main/java/org/geotools/geometry/jts/GeometryCoordinateSequenceTransformer.java Log: GEOT-4130, GeometryCoordinateSequenceTransformer now uses input CoordinateSequenceFactory by default Modified: trunk/modules/library/api/src/main/java/org/geotools/geometry/jts/GeometryCoordinateSequenceTransformer.java =================================================================== --- trunk/modules/library/api/src/main/java/org/geotools/geometry/jts/GeometryCoordinateSequenceTransformer.java 2012-05-15 21:21:30 UTC (rev 38731) +++ trunk/modules/library/api/src/main/java/org/geotools/geometry/jts/GeometryCoordinateSequenceTransformer.java 2012-05-15 21:21:38 UTC (rev 38732) @@ -17,6 +17,7 @@ package org.geotools.geometry.jts; import com.vividsolutions.jts.geom.CoordinateSequence; +import com.vividsolutions.jts.geom.CoordinateSequenceFactory; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryCollection; import com.vividsolutions.jts.geom.GeometryFactory; @@ -34,24 +35,51 @@ /** - * Service object that takes a geometry an applies a MathTransform on top - * of it. + * Service object that takes a geometry and applies a {@link MathTransform} + * to the coordinates it contains, creating a new + * geometry as the transformed output. + * <p> + * The standard usage pattern is + * to supply a {@link MathTransform} and @link CoordinateReferenceSystem} explicitly. + * The {@link #transform(Geometry)} method can then be + * used to construct transformed geometries using the {@link GeometryFactory} + * and {@link CoordinateSequenceFactory} of the input geometry. + * * @author Andrea Aime + * @author Martin Davis * * * @source $URL$ */ public class GeometryCoordinateSequenceTransformer { - private MathTransform transform; - private CoordinateSequenceTransformer csTransformer; + private MathTransform transform = null; private CoordinateReferenceSystem crs; + private CoordinateSequenceTransformer inputCSTransformer = null; + private CoordinateSequenceTransformer csTransformer = null; + private GeometryFactory currGeometryFactory = null; + /** + * Creates a transformer which uses the {@link CoordinateSequenceFactory} + * of the source geometries. + */ public GeometryCoordinateSequenceTransformer() { - csTransformer = new DefaultCoordinateSequenceTransformer(); + // the csTransformer is initialized from the first geometry + // and the supplied transform } + /** + * Creates a transformer which uses a client-specified + * {@link CoordinateSequenceTransformer}. + * <p> + * <b>WARNING:</b> The CoordinateSequenceTransformer must use + * the same {@link CoordinateSequenceFactory} as the output + * GeometryFactory, so that geometries are constructed consistently. + * + * @param transformer + */ public GeometryCoordinateSequenceTransformer(CoordinateSequenceTransformer transformer) { - csTransformer = transformer; + inputCSTransformer = transformer; + csTransformer = transformer; } /** @@ -62,7 +90,6 @@ this.transform = transform; } - /** * Sets the target coordinate reference system. * <p> @@ -76,14 +103,40 @@ } /** - * Applies the transform to the provided geometry, given - * @param g + * Initializes the internal CoordinateSequenceTransformer + * if not specified explicitly. + * + * @param gf the factory to use + */ + private void init(GeometryFactory gf) + { + // don't init if csTransformer already exists + if (inputCSTransformer != null) + return; + // don't reinit if gf is the same (the usual case) + if (currGeometryFactory == gf) + return; + + currGeometryFactory = gf; + CoordinateSequenceFactory csf = gf.getCoordinateSequenceFactory(); + csTransformer = new DefaultCoordinateSequenceTransformer(csf); + } + + /** + * Applies the transform to the provided geometry, + * creating a new transformed geometry. + * + * @param g the geometry to transform + * @return a new transformed geometry * @throws TransformException */ public Geometry transform(Geometry g) throws TransformException { GeometryFactory factory = g.getFactory(); Geometry transformed = null; + // lazily init csTransformer using geometry's CSFactory + init(factory); + if (g instanceof Point) { transformed = transformPoint((Point) g, factory); } else if (g instanceof MultiPoint) { @@ -130,8 +183,8 @@ throw new IllegalArgumentException("Unsupported geometry type " + g.getClass()); } - //copy over user data, do a special check for coordinate reference - // systme + //copy over user data + // do a special check for coordinate reference system transformed.setUserData(g.getUserData()); if ((g.getUserData() == null) || g.getUserData() instanceof CoordinateReferenceSystem) { @@ -150,6 +203,10 @@ */ public LineString transformLineString(LineString ls, GeometryFactory gf) throws TransformException { + + // if required, init csTransformer using geometry's CSFactory + init(gf); + CoordinateSequence cs = projectCoordinateSequence(ls.getCoordinateSequence()); LineString transformed = null; @@ -170,8 +227,12 @@ */ public Point transformPoint(Point point, GeometryFactory gf) throws TransformException { + + // if required, init csTransformer using geometry's CSFactory + init(gf); + CoordinateSequence cs = projectCoordinateSequence(point.getCoordinateSequence()); - Point transformed = gf.createPoint(cs);; + Point transformed = gf.createPoint(cs); transformed.setUserData( point.getUserData() ); return transformed; } @@ -181,7 +242,7 @@ * * @throws TransformException */ - public CoordinateSequence projectCoordinateSequence(CoordinateSequence cs) + private CoordinateSequence projectCoordinateSequence(CoordinateSequence cs) throws TransformException { return csTransformer.transform(cs, transform); } Added: trunk/modules/library/main/src/test/java/org/geotools/geometry/jts/GeometryCoordinateSequenceTransformerTest.java =================================================================== --- trunk/modules/library/main/src/test/java/org/geotools/geometry/jts/GeometryCoordinateSequenceTransformerTest.java (rev 0) +++ trunk/modules/library/main/src/test/java/org/geotools/geometry/jts/GeometryCoordinateSequenceTransformerTest.java 2012-05-15 21:21:38 UTC (rev 38732) @@ -0,0 +1,211 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2004-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.geometry.jts; + +// J2SE dependencies +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import org.geotools.referencing.crs.DefaultGeographicCRS; +import org.geotools.referencing.operation.transform.ProjectiveTransform; +import org.junit.Test; +import org.opengis.referencing.operation.MathTransform; +import org.opengis.referencing.operation.TransformException; + +import com.vividsolutions.jts.geom.CoordinateSequence; +import com.vividsolutions.jts.geom.CoordinateSequenceFilter; +import com.vividsolutions.jts.geom.Geometry; +import com.vividsolutions.jts.geom.GeometryFactory; + +/** + * Tests the {@link GeometryCoordinateSequenceTransformer} implementation. + * + * @since 2.2 + * + * + * @source $URL$ + * @version $Id$ + * @author Martin Davis + */ +public class GeometryCoordinateSequenceTransformerTest { + + private GeometryFactory geomFact = new GeometryFactory( + new LiteCoordinateSequenceFactory()); + + private GeometryBuilder gb = new GeometryBuilder(geomFact); + + @Test + public void testLineString() throws Exception { + checkTransform(gb.lineStringZ(10, 11, 1, 20, 21, 2)); + checkTransform(gb.lineString(10, 11, 20, 21)); + } + + @Test + public void testPoint() throws Exception { + checkTransform(gb.point(10, 11)); + checkTransform(gb.pointZ(10, 11, 1)); + } + + @Test + public void testPolygon() throws Exception { + checkTransform(gb.circle(10, 10, 5, 20)); + checkTransform(gb.boxZ(10, 10, 20, 20, 99)); + checkTransform(gb.polygon(gb.boxZ(10, 10, 20, 20, 99), + gb.boxZ(11, 11, 19, 19, 99))); + } + + @Test + public void testMulti() throws Exception { + checkTransform(gb.multiPoint(10, 10, 5, 20)); + checkTransform(gb.multiLineString(gb.lineString(10, 10, 20, 20), + gb.lineString(10, 10, 20, 20))); + checkTransform(gb.multiPolygon(gb.boxZ(10, 10, 20, 20, 99), + gb.boxZ(11, 11, 19, 19, 99))); + } + + @Test + public void testGeometryCollection() throws Exception { + checkTransform(gb.geometryCollection(gb.point(10, 11), + gb.lineString(10, 10, 20, 20), gb.box(10, 10, 20, 20))); + } + + /** + * Confirm that testing method is accurate! + * + * @throws Exception + */ + @Test + public void testDifferentDimensionsFailure() throws Exception { + Geometry g1 = gb.box(10, 10, 20, 20); + Geometry g2 = gb.boxZ(10, 10, 20, 20, 99); + assertFalse(hasSameValuesAndStructure(g1, g2)); + } + + private static final double ORD_TOLERANCE = 1.0e-6; + + /** + * Check transformation correctness by transforming forwards and backwards using + * inverse MathTransforms. + * + * @param g + * @throws TransformException + */ + private void checkTransform(Geometry g) throws TransformException { + GeometryCoordinateSequenceTransformer gcsTrans = new GeometryCoordinateSequenceTransformer(); + gcsTrans.setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84); + MathTransform trans = ProjectiveTransform.createTranslation(2, 100); + gcsTrans.setMathTransform(trans); + + GeometryCoordinateSequenceTransformer gcsTransInv = new GeometryCoordinateSequenceTransformer(); + gcsTransInv.setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84); + MathTransform transInv = ProjectiveTransform.createTranslation(2, -100); + gcsTransInv.setMathTransform(transInv); + + Geometry gTrans = gcsTrans.transform(g); + Geometry g2 = gcsTransInv.transform(gTrans); + + // result better be a different geometry + assertTrue(g != g2); + assertTrue(hasSameValuesAndStructure(g, g2)); + } + + boolean hasSameValuesAndStructure(Geometry g1, Geometry g2) { + if (!g1.equalsExact(g2, ORD_TOLERANCE)) + return false; + if (g1.getFactory() != g2.getFactory()) + return false; + + CoordinateSequence seq = CoordinateSequenceFinder.find(g1); + if (!CoordinateSequenceSchemaChecker.check(g2, seq.getClass(), + seq.getDimension())) + return false; + return true; + } + + static class CoordinateSequenceFinder implements CoordinateSequenceFilter { + + public static CoordinateSequence find(Geometry g) { + CoordinateSequenceFinder finder = new CoordinateSequenceFinder(); + g.apply(finder); + return finder.getSeq(); + } + + private CoordinateSequence firstSeqFound = null; + + public CoordinateSequence getSeq() { + return firstSeqFound; + } + + public void filter(CoordinateSequence seq, int i) { + if (firstSeqFound == null) + firstSeqFound = seq; + + } + + public boolean isDone() { + return firstSeqFound != null; + } + + public boolean isGeometryChanged() { + return false; + } + } + + static class CoordinateSequenceSchemaChecker implements + CoordinateSequenceFilter { + + public static boolean check(Geometry g, Class coordSeqClass, int dimension) { + CoordinateSequenceSchemaChecker checkCS = new CoordinateSequenceSchemaChecker( + coordSeqClass, dimension); + g.apply(checkCS); + return checkCS.isSame(); + } + + private Class coordSeqClass; + + private int dimension; + + private boolean isSame = true; + + public CoordinateSequenceSchemaChecker(Class coordSeqClass, int dimension) { + this.coordSeqClass = coordSeqClass; + this.dimension = dimension; + } + + public boolean isSame() { + return isSame; + } + + public void filter(CoordinateSequence seq, int i) { + if (seq.getClass() != coordSeqClass) + isSame = false; + if (seq.getDimension() != dimension) + isSame = false; + } + + public boolean isDone() { + return !isSame; + } + + + public boolean isGeometryChanged() { + return false; + } + + } + +} |
From: <svn...@os...> - 2012-05-15 21:21:37
|
Author: mdavis Date: 2012-05-15 14:21:30 -0700 (Tue, 15 May 2012) New Revision: 38731 Added: trunk/modules/library/main/src/main/java/org/geotools/geometry/jts/GeometryBuilder.java Log: GEOT-4145, Added GeometryBuilder for easier creation of JTS geometries Added: trunk/modules/library/main/src/main/java/org/geotools/geometry/jts/GeometryBuilder.java =================================================================== --- trunk/modules/library/main/src/main/java/org/geotools/geometry/jts/GeometryBuilder.java (rev 0) +++ trunk/modules/library/main/src/main/java/org/geotools/geometry/jts/GeometryBuilder.java 2012-05-15 21:21:30 UTC (rev 38731) @@ -0,0 +1,466 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2004-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.geometry.jts; + +import com.vividsolutions.jts.geom.CoordinateSequence; +import com.vividsolutions.jts.geom.CoordinateSequenceFactory; +import com.vividsolutions.jts.geom.Geometry; +import com.vividsolutions.jts.geom.GeometryCollection; +import com.vividsolutions.jts.geom.GeometryFactory; +import com.vividsolutions.jts.geom.LineString; +import com.vividsolutions.jts.geom.LinearRing; +import com.vividsolutions.jts.geom.MultiLineString; +import com.vividsolutions.jts.geom.MultiPoint; +import com.vividsolutions.jts.geom.MultiPolygon; +import com.vividsolutions.jts.geom.Point; +import com.vividsolutions.jts.geom.Polygon; + +/** + * A builder for {@link Geometry} objects. Primarily intended to + * support fluent programming in test code. + * <p> + * Features include: + * <ul> + * <li>Both 2D and 3D coordinate dimensions are supported + * (assuming the provided {@link CoordinateSequenceFactory} supports them) + * <li>Sequences of ordinate values can be supplied in a number of ways + * <li>Rings do not need to be explicitly closed; a closing point will be + * supplied if needed + * <li>Empty geometries of all types can be created + * <li>Composite geometries are validated to ensure they have a consistent + * GeometryFactory and coordinate sequence dimension + * <p> + * Examples of intended usage are: + * + * <pre> + * GeometryBuilder gb = new GeometryBuilder(geomFact); + * LineString line = gb.linestring(1,2, 3,4); + * Polygon poly = gb.polygon(0,0, 0,1, 1,1, 1,0); + * Polygon box = gb.box(0,0, 1,1); + * Polygon hexagon = gb.circle(0,0, 1,1, 6); + * Polygon polyhole = gb.polygon(gb.linearring(0,0, 0,10, 10,10, 10,0), gb.linearring(1,1, 1,9, 9,9, 9,1)) + * </pre> + * + * @author Martin Davis - OpenGeo + * + */ +public class GeometryBuilder { + + private GeometryFactory geomFact; + + private CoordinateSequenceFactory csFact; + + /** + * Create a new instance using the default {@link GeometryFactory}. + */ + public GeometryBuilder() { + this(new GeometryFactory()); + } + + /** + * Creates a new instance using a provided GeometryFactory. + * + * @param geomFact the factory to use + */ + public GeometryBuilder(GeometryFactory geomFact) { + this.geomFact = geomFact; + csFact = geomFact.getCoordinateSequenceFactory(); + } + + /** + * Creates an empty Point + * + * @return an empty Point + */ + public Point point() { + return geomFact.createPoint(createCS(new double[0], 2)); + } + + /** + * Creates an empty Point with coordinate dimension = 3. + * + * @return an empty Point + */ + public Point pointZ() { + return geomFact.createPoint(createCS(new double[0], 3)); + } + + /** + * Creates a 2D Point. + * + * @param x the X ordinate + * @param y the Y ordinate + * @return a Point + */ + public Point point(double x, double y) { + return geomFact.createPoint(createCS(new double[] { x, y }, 2)); + } + + /** + * Creates a 3D Point. + * + * @param x the X ordinate + * @param y the Y ordinate + * @param z the Z ordinate + * @return a Point + */ + public Point pointZ(double x, double y, double z) { + return geomFact.createPoint(createCS(new double[] { x, y, z }, 3)); + } + + /** + * Creates an empty 2D LineString + * + * @return an empty LineString + */ + public LineString lineString() { + return geomFact.createLineString(createCS(new double[0], 2)); + } + + /** + * Creates an empty 3D LineString + * + * @return an empty LineString + */ + public LineString lineStringZ() { + return geomFact.createLineString(createCS(new double[0], 3)); + } + + /** + * Creates a 2D LineString. + * + * @param ord the XY ordinates + * @return a LineString + */ + public LineString lineString(double... ord) { + return geomFact.createLineString(createCS(ord, 2)); + } + + /** + * Creates a 3D LineString. + * + * @param ord the XYZ ordinates + * @return a LineString + */ + public LineString lineStringZ(double... ord) { + return geomFact.createLineString(createCS(ord, 3)); + } + + /** + * Creates an empty 2D LinearRing + * + * @return an empty LinearRing + */ + public LinearRing linearRing() { + return geomFact.createLinearRing(createRingCS(new double[0], 2)); + } + + /** + * Creates an empty 3D LinearRing + * + * @return an empty LinearRing + */ + public LinearRing linearRingZ() { + return geomFact.createLinearRing(createRingCS(new double[0], 3)); + } + + /** + * Creates a 2D LinearRing. If the supplied coordinate list is not closed, a + * closing coordinate is added. + * + * @param ord + * @return a LinearRing + */ + public LinearRing linearRing(double... ord) { + return geomFact.createLinearRing(createRingCS(ord, 2)); + } + + /** + * Creates a 3D LinearRing. If the supplied coordinate list is not closed, a + * closing coordinate is added. + * + * @param ord the XYZ ordinates + * @return a LinearRing + */ + public LinearRing linearRingZ(double... ord) { + return geomFact.createLinearRing(createRingCS(ord, 3)); + } + + /** + * Creates an empty 2D Polygon. + * + * @return an empty Polygon + */ + public Polygon polygon() { + return geomFact.createPolygon(linearRing(), null); + } + + /** + * Creates an empty 3D Polygon. + * + * @return an empty Polygon + */ + public Polygon polygonZ() { + return geomFact.createPolygon(linearRingZ(), null); + } + + /** + * Creates a Polygon from a list of XY coordinates. + * + * @param ord a list of XY ordinates + * @return a Polygon + */ + public Polygon polygon(double... ord) { + return geomFact.createPolygon(linearRing(ord), null); + } + + /** + * Creates a Polygon from a list of XYZ coordinates. + * + * @param ord a list of XYZ ordinates + * @return a Polygon + */ + public Polygon polygonZ(double... ord) { + return geomFact.createPolygon(linearRingZ(ord), null); + } + + /** + * Creates a Polygon from an exterior ring. The coordinate dimension of the + * Polygon is the dimension of the LinearRing. + * + * @param shell the exterior ring + * @return a Polygon + */ + public Polygon polygon(LinearRing shell) { + return geomFact.createPolygon(shell, null); + } + + /** + * Creates a Polygon with a hole from an exterior ring and an interior ring. + * + * @param shell the exterior ring + * @param hole the interior ring + * @return a Polygon with a hole + */ + public Polygon polygon(LinearRing shell, LinearRing hole) { + return geomFact.createPolygon(shell, new LinearRing[] { hole }); + } + + /** + * Creates a Polygon with a hole from an exterior ring and an interior ring + * supplied by the rings of Polygons. + * + * @param shell the exterior ring + * @param hole the interior ring + * @return a Polygon with a hole + */ + public Polygon polygon(Polygon shell, Polygon hole) { + return geomFact.createPolygon((LinearRing) shell.getExteriorRing(), + new LinearRing[] { (LinearRing) hole.getExteriorRing() }); + } + + /** + * Creates a rectangular 2D Polygon from X and Y bounds. + * + * @param x1 the lower X bound + * @param y1 the lower Y bound + * @param x2 the upper X bound + * @param y2 the upper Y bound + * @return a 2D Polygon + */ + public Polygon box(double x1, double y1, double x2, double y2) { + double[] ord = new double[] { x1, y1, x1, y2, x2, y2, x2, y1, x1, y1 }; + return polygon(ord); + } + + /** + * Creates a rectangular 3D Polygon from X and Y bounds. + * + * @param x1 the lower X bound + * @param y1 the lower Y bound + * @param x2 the upper X bound + * @param y2 the upper Y bound + * @param z the Z value for all coordinates + * @return a 3D Polygon + */ + public Polygon boxZ(double x1, double y1, double x2, double y2, double z) { + double[] ord = new double[] { x1, y1, z, x1, y2, z, x2, y2, z, x2, y1, z, + x1, y1, z }; + return polygonZ(ord); + } + + /** + * Creates an elliptical Polygon from a bounding box with a given number of + * sides. + * + * @param x1 + * @param y1 + * @param x2 + * @param y2 + * @param nsides + * @return a 2D Polygon + */ + public Polygon ellipse(double x1, double y1, double x2, double y2, int nsides) { + double rx = Math.abs(x2 - x1) / 2; + double ry = Math.abs(y2 - y1) / 2; + double cx = Math.min(x1, x2) + rx; + double cy = Math.min(x1, x2) + ry; + + double[] ord = new double[2 * nsides + 2]; + double angInc = 2 * Math.PI / nsides; + // create ring in CW order + for (int i = 0; i < nsides; i++) { + double ang = -(i * angInc); + ord[2 * i] = cx + rx * Math.cos(ang); + ord[2 * i + 1] = cy + ry * Math.sin(ang); + } + ord[2 * nsides] = ord[0]; + ord[2 * nsides + 1] = ord[1]; + return polygon(ord); + } + + /** + * Creates a circular Polygon with a given center, radius and number of sides. + * + * @param x the center X ordinate + * @param y the center Y ordinate + * @param radius the radius + * @param nsides the number of sides + * @return a 2D Polygon + */ + public Polygon circle(double x, double y, double radius, int nsides) { + return ellipse(x - radius, y - radius, x + radius, y + radius, nsides); + } + + /** + * Creates a MultiPoint with 2 2D Points. + * + * @param x1 the X ordinate of the first point + * @param y1 the Y ordinate of the first point + * @param x2 the X ordinate of the second point + * @param y2 the Y ordinate of the second point + * @return A MultiPoint + */ + public MultiPoint multiPoint(double x1, double y1, double x2, double y2) { + return geomFact + .createMultiPoint(new Point[] { point(x1, y1), point(x2, y2) }); + } + + /** + * Creates a MultiPoint with 2 3D Points. + * + * @param x1 the X ordinate of the first point + * @param y1 the Y ordinate of the first point + * @param z1 the Z ordinate of the first point + * @param x2 the X ordinate of the second point + * @param y2 the Y ordinate of the second point + * @param z2 the Z ordinate of the second point + * @return A 3D MultiPoint + */ + public MultiPoint multiPointZ(double x1, double y1, double z1, double x2, + double y2, double z2) { + return geomFact.createMultiPoint(new Point[] { pointZ(x1, y1, z1), + pointZ(x2, y2, z2) }); + } + + /** + * Creates a MultiLineString from a set of LineStrings + * + * @param lines the component LineStrings + * @return a MultiLineString + */ + public MultiLineString multiLineString(LineString... lines) { + return geomFact.createMultiLineString(lines); + } + + /** + * Creates a MultiPolygon from a set of Polygons. + * + * @param polys the component polygons + * @return A MultiPolygon + */ + public MultiPolygon multiPolygon(Polygon... polys) { + return geomFact.createMultiPolygon(polys); + } + + /** + * Creates a GeometryCollection from a set of Geometrys + * + * @param geoms the component Geometrys + * @return a GeometryCollection + */ + public GeometryCollection geometryCollection(Geometry... geoms) { + return geomFact.createGeometryCollection(geoms); + } + + /** + * Tests whether a sequence of ordinates of a given dimension is closed (i.e. + * has the first and last coordinate identical). + * + * @param ord the list of ordinate values + * @param dim the dimension of each coordinate + * @return true if the sequence is closed + */ + private boolean isClosed(double[] ord, int dim) { + int n = ord.length / dim; + if (n == 0) + return true; + + int lastPos = dim * (n - 1); + double lastx = ord[lastPos]; + double lasty = ord[lastPos + 1]; + boolean isClosed = lastx == ord[0] && lasty == ord[1]; + return isClosed; + } + + /** + * @param ord + * @param dim + * @return + */ + private CoordinateSequence createRingCS(double[] ord, int dim) { + if (isClosed(ord, dim)) + return createCS(ord, dim); + double[] ord2 = new double[ord.length + dim]; + System.arraycopy(ord, 0, ord2, 0, ord.length); + // copy first coord to last + int n = ord2.length / dim; + int lastPos = dim * n; + for (int i = 0; i < dim; i++) { + ord2[lastPos + i] = ord2[i]; + } + return createCS(ord2, dim); + } + + /** + * @param ord + * @param dim + * @return + */ + private CoordinateSequence createCS(double[] ord, int dim) { + if (ord.length % dim != 0) + throw new IllegalArgumentException("Ordinate array length " + + ord.length + " is not a multiple of dimension " + dim); + int n = ord.length / dim; + CoordinateSequence cs = csFact.create(n, dim); + for (int i = 0; i < n; i++) { + for (int d = 0; d < dim; d++) + cs.setOrdinate(i, d, ord[dim * i + d]); + } + return cs; + } +} |
From: <svn...@os...> - 2012-05-15 20:12:54
|
Author: jdeolive Date: 2012-05-15 13:12:45 -0700 (Tue, 15 May 2012) New Revision: 38730 Modified: branches/2.7.x/modules/library/api/src/main/java/org/geotools/geometry/jts/GeometryCoordinateSequenceTransformer.java Log: fixing last patch to GeometryCoordinateSequenceTransformer.java, out of date version was applied, GEOT-4130 Modified: branches/2.7.x/modules/library/api/src/main/java/org/geotools/geometry/jts/GeometryCoordinateSequenceTransformer.java =================================================================== --- branches/2.7.x/modules/library/api/src/main/java/org/geotools/geometry/jts/GeometryCoordinateSequenceTransformer.java 2012-05-15 18:01:22 UTC (rev 38729) +++ branches/2.7.x/modules/library/api/src/main/java/org/geotools/geometry/jts/GeometryCoordinateSequenceTransformer.java 2012-05-15 20:12:45 UTC (rev 38730) @@ -35,40 +35,46 @@ /** - * Service object that takes a geometry and applies a {@link MathTransform} to the coordinates it - * contains. + * Service object that takes a geometry and applies a {@link MathTransform} + * to the coordinates it contains, creating a new + * geometry as the transformed output. * <p> - * New geometries are constructed using the {@link GeometryFactory} of the input geometries. - * By default, this will use the same {@link CoordinateSequenceFactory} as the input geometries. - * </p> + * The standard usage pattern is to supply a {@link MathTransform} and + * @link CoordinateReferenceSystem} explicitly. The {@link #transform(Geometry)} method can then be + * used to construct transformed geometries using the {@link GeometryFactory} and + * {@link CoordinateSequenceFactory} of the input geometry. + * * @author Andrea Aime * @author Martin Davis - * - * @source $URL$ */ public class GeometryCoordinateSequenceTransformer { - private MathTransform transform; - private CoordinateSequenceTransformer csTransformer; + private MathTransform transform = null; private CoordinateReferenceSystem crs; + private CoordinateSequenceTransformer inputCSTransformer = null; + private CoordinateSequenceTransformer csTransformer = null; + private GeometryFactory currGeometryFactory = null; /** * Creates a transformer which uses the {@link CoordinateSequenceFactory} * of the source geometries. */ public GeometryCoordinateSequenceTransformer() { - // the csTransformer is initialized from the first geometry + // the csTransformer is initialized from the first geometry + // and the supplied transform } /** * Creates a transformer which uses a client-specified {@link CoordinateSequenceTransformer}. * <p> - * <b>WARNING:</b> The CoordinateSequenceTransformer must use the same CoordinateSequenceFactory - * as the input geometries, so that geometries are constructed consistently. - * + * <b>WARNING:</b> The CoordinateSequenceTransformer must use the same + * {@link CoordinateSequenceFactory} as the output GeometryFactory, so that geometries are + * constructed consistently. + * </p> * @param transformer */ public GeometryCoordinateSequenceTransformer(CoordinateSequenceTransformer transformer) { - csTransformer = transformer; + inputCSTransformer = transformer; + csTransformer = transformer; } /** @@ -79,7 +85,6 @@ this.transform = transform; } - /** * Sets the target coordinate reference system. * <p> @@ -91,22 +96,42 @@ public void setCoordinateReferenceSystem(CoordinateReferenceSystem crs) { this.crs = crs; } - + /** - * Applies the transform to the provided geometry, given - * @param g + * Initializes the internal CoordinateSequenceTransformer + * if not specified explicitly. + * + * @param gf the factory to use + */ + private void init(GeometryFactory gf) + { + // don't init if csTransformer already exists + if (inputCSTransformer != null) + return; + // don't reinit if gf is the same (the usual case) + if (currGeometryFactory == gf) + return; + + currGeometryFactory = gf; + CoordinateSequenceFactory csf = gf.getCoordinateSequenceFactory(); + csTransformer = new DefaultCoordinateSequenceTransformer(csf); + } + + /** + * Applies the transform to the provided geometry, + * creating a new transformed geometry. + * + * @param g the geometry to transform + * @return a new transformed geometry * @throws TransformException */ public Geometry transform(Geometry g) throws TransformException { GeometryFactory factory = g.getFactory(); Geometry transformed = null; - - // if required, lazily init csTransformer using geometry's CSFactory - if (csTransformer == null) { - CoordinateSequenceFactory csf = g.getFactory().getCoordinateSequenceFactory(); - csTransformer = new DefaultCoordinateSequenceTransformer(csf); - } - + + // lazily init csTransformer using geometry's CSFactory + init(factory); + if (g instanceof Point) { transformed = transformPoint((Point) g, factory); } else if (g instanceof MultiPoint) { @@ -153,8 +178,8 @@ throw new IllegalArgumentException("Unsupported geometry type " + g.getClass()); } - //copy over user data, do a special check for coordinate reference - // systme + //copy over user data + //do a special check for coordinate reference system transformed.setUserData(g.getUserData()); if ((g.getUserData() == null) || g.getUserData() instanceof CoordinateReferenceSystem) { @@ -171,8 +196,12 @@ * * @throws TransformException */ - private LineString transformLineString(LineString ls, GeometryFactory gf) + public LineString transformLineString(LineString ls, GeometryFactory gf) throws TransformException { + + // if required, init csTransformer using geometry's CSFactory + init(gf); + CoordinateSequence cs = projectCoordinateSequence(ls.getCoordinateSequence()); LineString transformed = null; @@ -191,10 +220,14 @@ * * @throws TransformException */ - private Point transformPoint(Point point, GeometryFactory gf) + public Point transformPoint(Point point, GeometryFactory gf) throws TransformException { + + // if required, init csTransformer using geometry's CSFactory + init(gf); + CoordinateSequence cs = projectCoordinateSequence(point.getCoordinateSequence()); - Point transformed = gf.createPoint(cs);; + Point transformed = gf.createPoint(cs); transformed.setUserData( point.getUserData() ); return transformed; } @@ -204,7 +237,7 @@ * * @throws TransformException */ - private CoordinateSequence projectCoordinateSequence(CoordinateSequence cs) + public CoordinateSequence projectCoordinateSequence(CoordinateSequence cs) throws TransformException { return csTransformer.transform(cs, transform); } @@ -213,7 +246,7 @@ * @param polygon * @throws TransformException */ - private Polygon transformPolygon(Polygon polygon, GeometryFactory gf) + public Polygon transformPolygon(Polygon polygon, GeometryFactory gf) throws TransformException { LinearRing exterior = (LinearRing) transformLineString(polygon.getExteriorRing(), gf); LinearRing[] interiors = new LinearRing[polygon.getNumInteriorRing()]; |
From: <svn...@os...> - 2012-05-15 18:01:34
|
Author: mdavis Date: 2012-05-15 11:01:22 -0700 (Tue, 15 May 2012) New Revision: 38729 Added: branches/2.7.x/modules/library/main/src/test/java/org/geotools/geometry/jts/coordinatesequence/ branches/2.7.x/modules/library/main/src/test/java/org/geotools/geometry/jts/coordinatesequence/CoordinateSequencesTest.java Log: GEOT-4136, handling 3D data in gml3 encoding (added test) Added: branches/2.7.x/modules/library/main/src/test/java/org/geotools/geometry/jts/coordinatesequence/CoordinateSequencesTest.java =================================================================== --- branches/2.7.x/modules/library/main/src/test/java/org/geotools/geometry/jts/coordinatesequence/CoordinateSequencesTest.java (rev 0) +++ branches/2.7.x/modules/library/main/src/test/java/org/geotools/geometry/jts/coordinatesequence/CoordinateSequencesTest.java 2012-05-15 18:01:22 UTC (rev 38729) @@ -0,0 +1,63 @@ +package org.geotools.geometry.jts.coordinatesequence; + +import static org.junit.Assert.assertEquals; + +import org.geotools.geometry.jts.LiteCoordinateSequence; +import org.geotools.geometry.jts.LiteCoordinateSequenceFactory; +import org.junit.Test; + +import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.Geometry; +import com.vividsolutions.jts.geom.GeometryFactory; + +public class CoordinateSequencesTest { + + static GeometryFactory gf = new GeometryFactory(); + + static LiteCoordinateSequenceFactory liteCSF = new LiteCoordinateSequenceFactory(); + static GeometryFactory liteGF = new GeometryFactory(liteCSF); + + + @Test + public void testCoordinateDimensionPointLite2D() + { + Geometry geom = liteGF.createPoint(new LiteCoordinateSequence(new double[] { 1, 2}, 2)); + assertEquals(2, CoordinateSequences.coordinateDimension(geom)); + } + @Test + public void testCoordinateDimensionPointLite3D() + { + Geometry geom = liteGF.createPoint(new LiteCoordinateSequence(new double[] { 1, 2, 99}, 3)); + assertEquals(3, CoordinateSequences.coordinateDimension(geom)); + } + @Test + public void testCoordinateDimensionLineString2D() + { + Geometry geom = gf.createLineString(new Coordinate[] { new Coordinate(1, 2), new Coordinate(3, 4) }); + assertEquals(2, CoordinateSequences.coordinateDimension(geom)); + } + @Test + public void testCoordinateDimensionLineStringLite3D() + { + Geometry geom = liteGF.createLineString(liteCSF.create(new double[] { 1, 2, 100, 3, 4, 200}, 3)); + assertEquals(3, CoordinateSequences.coordinateDimension(geom)); + } + @Test + public void testCoordinateDimensionPolygonLite2D() + { + Geometry geom = liteGF.createPolygon( + liteGF.createLinearRing(liteCSF.create( + new double[] { 1,1, 2,1, 2,2, 1,2, 1,1 }, 2 )), + null); + assertEquals(2, CoordinateSequences.coordinateDimension(geom)); + } + @Test + public void testCoordinateDimensionPolygonLite3D() + { + Geometry geom = liteGF.createPolygon( + liteGF.createLinearRing(liteCSF.create( + new double[] { 1,1,100, 2,1,99, 2,2,98, 1,2,97, 1,1,100}, 3)), + null); + assertEquals(3, CoordinateSequences.coordinateDimension(geom)); + } +} |
From: <svn...@os...> - 2012-05-15 17:58:25
|
Author: mdavis Date: 2012-05-15 10:58:13 -0700 (Tue, 15 May 2012) New Revision: 38728 Modified: branches/2.7.x/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/AbstractGeometryTypeBinding.java branches/2.7.x/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/DirectPositionListTypeBinding.java branches/2.7.x/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/DirectPositionTypeBinding.java branches/2.7.x/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/EnvelopeTypeBinding.java branches/2.7.x/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/GML3EncodingUtils.java branches/2.7.x/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/PointTypeBinding.java branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/GML3TestSupport.java branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/DirectPositionListTypeBindingTest.java branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/DirectPositionTypeBindingTest.java branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/GML3MockData.java branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/LineStringTypeBindingTest.java branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiLineStringTypeBindingTest.java branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/PointTypeBindingTest.java branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/PolygonTypeBindingTest.java branches/2.7.x/modules/library/main/src/main/java/org/geotools/geometry/jts/coordinatesequence/CoordinateSequences.java branches/2.7.x/modules/library/xml/src/test/java/org/geotools/GMLTest.java Log: GEOT-4136, handling 3D data in gml3 encoding Modified: branches/2.7.x/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/AbstractGeometryTypeBinding.java =================================================================== --- branches/2.7.x/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/AbstractGeometryTypeBinding.java 2012-05-15 17:57:59 UTC (rev 38727) +++ branches/2.7.x/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/AbstractGeometryTypeBinding.java 2012-05-15 17:58:13 UTC (rev 38728) @@ -18,6 +18,7 @@ import javax.xml.namespace.QName; +import org.geotools.geometry.jts.coordinatesequence.CoordinateSequences; import org.geotools.gml3.GML; import org.geotools.xml.AbstractComplexBinding; import org.geotools.xml.ElementInstance; @@ -115,10 +116,12 @@ } if ("srsDimension".equals(name.getLocalPart())) { - CoordinateReferenceSystem crs = GML3EncodingUtils.getCRS(geometry); - if (crs != null) { - return crs.getCoordinateSystem().getDimension(); - } + /** + * For the dimension, use the actual dimension of the geometry. Using + * the dimension of the CRS is not sufficient, since currently CRSes + * don't support 3D. + */ + return CoordinateSequences.coordinateDimension(geometry); } if (GML.id.equals(name)) { Modified: branches/2.7.x/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/DirectPositionListTypeBinding.java =================================================================== --- branches/2.7.x/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/DirectPositionListTypeBinding.java 2012-05-15 17:57:59 UTC (rev 38727) +++ branches/2.7.x/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/DirectPositionListTypeBinding.java 2012-05-15 17:58:13 UTC (rev 38728) @@ -22,6 +22,7 @@ import org.geotools.geometry.DirectPosition1D; import org.geotools.geometry.DirectPosition2D; +import org.geotools.geometry.jts.coordinatesequence.CoordinateSequences; import org.geotools.gml3.GML; import org.geotools.xml.AbstractComplexBinding; import org.geotools.xml.ElementInstance; @@ -31,6 +32,8 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; +import com.vividsolutions.jts.geom.CoordinateSequence; + /** * Binding object for the type * http://www.opengis.net/gml:DirectPositionListType. @@ -85,7 +88,7 @@ * @generated modifiable */ public Class getType() { - return DirectPosition[].class; + return CoordinateSequence.class; } /** @@ -143,21 +146,36 @@ return dps; } + /** + * + * @param object a CoordinateSequence + * + * @see org.geotools.xml.AbstractComplexBinding#encode(java.lang.Object, org.w3c.dom.Document, org.w3c.dom.Element) + */ public Element encode(Object object, Document document, Element value) throws Exception { // TODO: remove this when the parser can do lists - DirectPosition[] dps = (DirectPosition[]) object; + CoordinateSequence cs = (CoordinateSequence) object; StringBuffer sb = new StringBuffer(); - for (int i = 0; i < dps.length; i++) { - sb.append(dps[i].getOrdinate(0) + " " + dps[i].getOrdinate(1)); + int dim = CoordinateSequences.coordinateDimension(cs); + int size = cs.size(); + int nOrdWithSpace = size * dim - 1; + int count = 0; + for (int i = 0; i < size; i++) { + for (int d = 0; d < dim; d++) { + sb.append(cs.getOrdinate(i, d)); + + if (count < nOrdWithSpace) { + sb.append(" "); + } + count++; - if (i < (dps.length - 1)) { - sb.append(" "); - } + } } value.appendChild(document.createTextNode(sb.toString())); return value; } + } Modified: branches/2.7.x/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/DirectPositionTypeBinding.java =================================================================== --- branches/2.7.x/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/DirectPositionTypeBinding.java 2012-05-15 17:57:59 UTC (rev 38727) +++ branches/2.7.x/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/DirectPositionTypeBinding.java 2012-05-15 17:58:13 UTC (rev 38728) @@ -29,6 +29,7 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; +import com.vividsolutions.jts.geom.CoordinateSequence; import com.vividsolutions.jts.geom.GeometryFactory; @@ -86,7 +87,7 @@ * @generated modifiable */ public Class getType() { - return DirectPosition2D.class; + return CoordinateSequence.class; } /** @@ -117,21 +118,27 @@ public Element encode(Object object, Document document, Element value) throws Exception { - DirectPosition dp = (DirectPosition) object; + CoordinateSequence cs = (CoordinateSequence) object; - double[] coordinates = dp.getCoordinates(); - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < coordinates.length; i++) { - sb.append(String.valueOf(coordinates[i])); + // assume either zero or one coordinate + if (cs.size() >= 1) { + int dim = cs.getDimension(); + for (int d = 0; d < dim; d++) { + double v = cs.getOrdinate(0, d); + if (Double.isNaN(v) && d > 1) { + continue; + } - if (i != (coordinates.length - 1)) { - sb.append(" "); + // separator char is a blank + sb.append(String.valueOf(v)).append(" "); } + if (dim > 0) { + sb.setLength(sb.length()-1); + } } - //Element pos = document.createElementNS(GML.pos.getNamespaceURI(), GML.pos.getLocalPart()); value.appendChild(document.createTextNode(sb.toString())); return value; Modified: branches/2.7.x/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/EnvelopeTypeBinding.java =================================================================== --- branches/2.7.x/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/EnvelopeTypeBinding.java 2012-05-15 17:57:59 UTC (rev 38727) +++ branches/2.7.x/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/EnvelopeTypeBinding.java 2012-05-15 17:58:13 UTC (rev 38728) @@ -20,7 +20,7 @@ import javax.xml.namespace.QName; -import org.geotools.geometry.DirectPosition2D; +import org.geotools.geometry.jts.LiteCoordinateSequence; import org.geotools.geometry.jts.ReferencedEnvelope; import org.geotools.gml3.GML; import org.geotools.xml.AbstractComplexBinding; @@ -165,11 +165,11 @@ } if (name.getLocalPart().equals("lowerCorner")) { - return new DirectPosition2D(envelope.getMinX(), envelope.getMinY()); + return new LiteCoordinateSequence(new double[] { envelope.getMinX(), envelope.getMinY() }, 2); } if (name.getLocalPart().equals("upperCorner")) { - return new DirectPosition2D(envelope.getMaxX(), envelope.getMaxY()); + return new LiteCoordinateSequence(new double[] { envelope.getMaxX(), envelope.getMaxY() }, 2); } if (envelope instanceof ReferencedEnvelope) { Modified: branches/2.7.x/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/GML3EncodingUtils.java =================================================================== --- branches/2.7.x/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/GML3EncodingUtils.java 2012-05-15 17:57:59 UTC (rev 38727) +++ branches/2.7.x/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/GML3EncodingUtils.java 2012-05-15 17:58:13 UTC (rev 38728) @@ -29,7 +29,6 @@ import org.eclipse.xsd.XSDElementDeclaration; import org.geotools.feature.NameImpl; -import org.geotools.geometry.DirectPosition2D; import org.geotools.gml2.bindings.GML2EncodingUtils; import org.geotools.gml2.bindings.GMLEncodingUtils; //import org.geotools.gml3.GML; @@ -46,7 +45,6 @@ import org.opengis.feature.Property; import org.opengis.feature.simple.SimpleFeature; import org.opengis.feature.type.Name; -import org.opengis.geometry.DirectPosition; import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -85,20 +83,8 @@ e = new GMLEncodingUtils(gml); } - static DirectPosition[] positions(LineString line) { - CoordinateSequence coordinates = line.getCoordinateSequence(); - DirectPosition[] dps = new DirectPosition[coordinates.size()]; - - double x; - double y; - - for (int i = 0; i < dps.length; i++) { - x = coordinates.getOrdinate(i, 0); - y = coordinates.getOrdinate(i, 1); - dps[i] = new DirectPosition2D(x, y); - } - - return dps; + static CoordinateSequence positions(LineString line) { + return line.getCoordinateSequence(); } static URI toURI(CoordinateReferenceSystem crs) { Modified: branches/2.7.x/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/PointTypeBinding.java =================================================================== --- branches/2.7.x/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/PointTypeBinding.java 2012-05-15 17:57:59 UTC (rev 38727) +++ branches/2.7.x/modules/extension/xsd/xsd-gml3/src/main/java/org/geotools/gml3/bindings/PointTypeBinding.java 2012-05-15 17:58:13 UTC (rev 38728) @@ -142,12 +142,7 @@ if ("pos".equals(name.getLocalPart())) { Point point = (Point) object; - - DirectPosition2D dp = new DirectPosition2D(); - dp.setOrdinate(0, point.getX()); - dp.setOrdinate(1, point.getY()); - - return dp; + return point.getCoordinateSequence(); } return null; Modified: branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/GML3TestSupport.java =================================================================== --- branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/GML3TestSupport.java 2012-05-15 17:57:59 UTC (rev 38727) +++ branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/GML3TestSupport.java 2012-05-15 17:58:13 UTC (rev 38728) @@ -18,7 +18,11 @@ import org.geotools.xml.Configuration; import org.geotools.xml.test.XMLTestSupport; +import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /* * Test bindings by extending this class with test cases that follow this pattern: @@ -74,7 +78,53 @@ protected Configuration createConfiguration() { return new GMLConfiguration(enableExtendedArcSurfaceSupport()); } + + protected void checkPosOrdinates(Document doc, int expectedNumOrdinates) + { + checkOrdinates(doc, GML.pos.getLocalPart(), expectedNumOrdinates); + } + protected void checkPosListOrdinates(Document doc, int expectedNumOrdinates) + { + checkOrdinates(doc, GML.posList.getLocalPart(), expectedNumOrdinates); + } + + + /** + * Checks that a posList exists, has a string as content, + * and the string encodes nOrdinates ordinates correctly + * (i.e. blank-separated). + * + * @param doc + * @param expectedNumOrdinates + */ + private void checkOrdinates(Document doc, String ordTag, int expectedNumOrdinates) { + NodeList nl = doc.getElementsByTagNameNS(GML.NAMESPACE, ordTag); + Node posListNode = nl.item(0); + assertEquals(1, posListNode.getChildNodes().getLength()); + String content = posListNode.getChildNodes().item(0).getNodeValue(); + String[] ord = content.split("\\s+"); + assertEquals(expectedNumOrdinates, ord.length); + } + + /** + * Checks that a given geometry element has an srsDimension attribute with an expected value + * + * @param doc + * @param tag + * @param expectedDim + */ + protected void checkDimension(Document doc, String tag, int expectedDim) { + NodeList lsNL = doc.getElementsByTagNameNS(GML.NAMESPACE, tag); + Node geomNode = lsNL.item(0); + NamedNodeMap attrMap = geomNode.getAttributes(); + Node dimNode = attrMap.getNamedItem("srsDimension"); + assertNotNull(dimNode); + String dimStr = dimNode.getChildNodes().item(0).getNodeValue(); + int dim = Integer.parseInt(dimStr); + assertEquals(dim, expectedDim); + } + /* * To be overriden by subclasses that require the extended arc/surface bindings * enabled. Modified: branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/DirectPositionListTypeBindingTest.java =================================================================== --- branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/DirectPositionListTypeBindingTest.java 2012-05-15 17:57:59 UTC (rev 38727) +++ branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/DirectPositionListTypeBindingTest.java 2012-05-15 17:58:13 UTC (rev 38728) @@ -21,8 +21,12 @@ import org.geotools.gml3.GML; import org.geotools.gml3.GML3TestSupport; import org.opengis.geometry.DirectPosition; +import org.w3c.dom.Document; +import com.vividsolutions.jts.geom.CoordinateSequence; +import com.vividsolutions.jts.geom.LineString; + public class DirectPositionListTypeBindingTest extends GML3TestSupport { public void test1D() throws Exception { GML3MockData.element(GML.posList, document, document); @@ -75,4 +79,18 @@ assertEquals(3d, dps[1].getOrdinate(0), 0d); assertEquals(4d, dps[1].getOrdinate(1), 0d); } + + public void testEncode2D() throws Exception { + LineString line = GML3MockData.lineStringLite2D(); + CoordinateSequence seq = line.getCoordinateSequence(); + Document doc = encode(seq, GML.posList); + checkPosListOrdinates(doc, 2 * line.getNumPoints()); + } + + public void testEncode3D() throws Exception { + LineString line = GML3MockData.lineStringLite3D(); + CoordinateSequence seq = line.getCoordinateSequence(); + Document doc = encode(seq, GML.posList); + checkPosListOrdinates(doc, 3 * line.getNumPoints()); + } } Modified: branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/DirectPositionTypeBindingTest.java =================================================================== --- branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/DirectPositionTypeBindingTest.java 2012-05-15 17:57:59 UTC (rev 38727) +++ branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/DirectPositionTypeBindingTest.java 2012-05-15 17:58:13 UTC (rev 38728) @@ -21,8 +21,13 @@ import org.geotools.gml3.GML; import org.geotools.gml3.GML3TestSupport; import org.opengis.geometry.DirectPosition; +import org.w3c.dom.Document; +import com.vividsolutions.jts.geom.CoordinateSequence; +import com.vividsolutions.jts.geom.LineString; +import com.vividsolutions.jts.geom.Point; + public class DirectPositionTypeBindingTest extends GML3TestSupport { public void test1D() throws Exception { GML3MockData.element(GML.pos, document, document); @@ -48,4 +53,20 @@ assertEquals(pos.getOrdinate(0), 1.0, 0); assertEquals(pos.getOrdinate(1), 2.0, 0); } + + public void testEncode2D() throws Exception { + Point point = GML3MockData.pointLite2D(); + CoordinateSequence seq = point.getCoordinateSequence(); + Document doc = encode(seq, GML.pos); + checkPosOrdinates(doc, 2); + } + + public void testEncode3D() throws Exception { + Point point = GML3MockData.pointLite3D(); + CoordinateSequence seq = point.getCoordinateSequence(); + Document doc = encode(seq, GML.pos); + checkPosOrdinates(doc, 3); + } + + } Modified: branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/GML3MockData.java =================================================================== --- branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/GML3MockData.java 2012-05-15 17:57:59 UTC (rev 38727) +++ branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/GML3MockData.java 2012-05-15 17:58:13 UTC (rev 38728) @@ -22,6 +22,8 @@ import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; +import org.geotools.geometry.jts.LiteCoordinateSequence; +import org.geotools.geometry.jts.LiteCoordinateSequenceFactory; import org.geotools.geometry.jts.ReferencedEnvelope; import org.geotools.gml3.GML; import org.geotools.referencing.CRS; @@ -34,6 +36,7 @@ import org.w3c.dom.Node; import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.CoordinateSequenceFactory; import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryCollection; @@ -58,6 +61,10 @@ */ public class GML3MockData { static GeometryFactory gf = new GeometryFactory(); + + static LiteCoordinateSequenceFactory liteCSF = new LiteCoordinateSequenceFactory(); + static GeometryFactory liteGF = new GeometryFactory(liteCSF); + static XSD gml = GML.getInstance(); public static void setGML(XSD gml) { @@ -96,10 +103,64 @@ return p; } + /** + * Creates a Point using a LiteCoordinateSequence + * with a 2D coordinate. + * + * @return a 2D Point + */ + public static Point pointLite2D() { + return liteGF.createPoint(new LiteCoordinateSequence(new double[] { 1, 2}, 2)); + } + + /** + * Creates a Point using a LiteCoordinateSequence + * with a 2D coordinate. + * + * @return a 2D Point + */ + public static Point pointLite3D() { + return liteGF.createPoint(new LiteCoordinateSequence(new double[] { 1, 2, 100}, 3)); + } + public static LineString lineString() { return gf.createLineString(new Coordinate[] { new Coordinate(1, 2), new Coordinate(3, 4) }); } + /** + * Creates a LineString using a LiteCoordinateSequence + * with 2 2D coordinates. + * + * @return a 2D LineString + */ + public static LineString lineStringLite2D() { + return liteGF.createLineString(new Coordinate[] { new Coordinate(1, 2), new Coordinate(3, 4) }); + } + + /** + * Creates a LineString using a LiteCoordinateSequence + * with 2 2D coordinates. + * + * @return a 2D LineString + */ + public static LineString lineStringLite2D(int size) { + Coordinate[] coords = new Coordinate[size]; + for (int i = 0; i < size; i++) { + coords[i] = new Coordinate(i, i+1); + } + return liteGF.createLineString(coords); + } + + /** + * Creates a LineString using a LiteCoordinateSequence + * with 2 3D coordinates. + * + * @return a 3D LineString + */ + public static LineString lineStringLite3D() { + return liteGF.createLineString(liteCSF.create(new double[] { 1, 2, 100, 3, 4, 200}, 3)); + } + public static Element lineString(Document document, Node parent) { return lineStringWithPos(document, parent); } @@ -192,6 +253,32 @@ return gf.createPolygon(linearRing(), null); } + /** + * Creates a Polygon using a LiteCoordinateSequence + * with 2D coordinates. + * + * @return a 2D Polygon + */ + public static Polygon polygonLite2D() { + return liteGF.createPolygon( + liteGF.createLinearRing(liteCSF.create( + new double[] { 1,1, 2,1, 2,2, 1,2, 1,1 }, 2 )), + null); + } + + /** + * Creates a Polygon using a LiteCoordinateSequence + * with 3D coordinates. + * + * @return a 3D Polygon + */ + public static Polygon polygonLite3D() { + return liteGF.createPolygon( + liteGF.createLinearRing(liteCSF.create( + new double[] { 1,1,100, 2,1,99, 2,2,98, 1,2,97, 1,1,100}, 3)), + null); + } + public static Element polygon(Document document, Node parent) { return polygon(document,parent,qName("Polygon"),false); } Modified: branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/LineStringTypeBindingTest.java =================================================================== --- branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/LineStringTypeBindingTest.java 2012-05-15 17:57:59 UTC (rev 38727) +++ branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/LineStringTypeBindingTest.java 2012-05-15 17:58:13 UTC (rev 38728) @@ -16,7 +16,9 @@ */ package org.geotools.gml3.bindings; +import org.geotools.gml3.GML; import org.geotools.gml3.GML3TestSupport; +import org.w3c.dom.Document; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.LineString; @@ -42,4 +44,48 @@ assertEquals(new Coordinate(1d, 2d), line.getPointN(0).getCoordinate()); assertEquals(new Coordinate(3d, 4d), line.getPointN(1).getCoordinate()); } + + /** + * Tests encoding using a CoordinateArraySequence + * (which requires special logic to get the dimension correct) + * @throws Exception + */ + public void testEncodeLineString() throws Exception { + LineString line = GML3MockData.lineString(); + Document doc = encode(line, GML.LineString); + + checkDimension(doc, GML.LineString.getLocalPart(), 2); + checkPosListOrdinates(doc, 2 * line.getNumPoints()); + } + + public void testEncodeLite2D() throws Exception { + LineString line = GML3MockData.lineStringLite2D(); + Document doc = encode(line, GML.LineString); + + checkDimension(doc, GML.LineString.getLocalPart(), 2); + checkPosListOrdinates(doc, 2 * line.getNumPoints()); + } + + public void testEncodeLite3D() throws Exception { + LineString line = GML3MockData.lineStringLite3D(); + Document doc = encode(line, GML.LineString); + + checkDimension(doc, GML.LineString.getLocalPart(), 3); + checkPosListOrdinates(doc, 3 * line.getNumPoints()); + } + + /** + * Test a long LineString to catch problems that only show up with large numbers of ordinates + * + * @throws Exception + */ + public void testEncode2DLong() throws Exception { + LineString line = GML3MockData.lineStringLite2D(10); + Document doc = encode(line, GML.LineString); + + checkDimension(doc, GML.LineString.getLocalPart(), 2); + checkPosListOrdinates(doc, 2 * line.getNumPoints()); + } + + } Modified: branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiLineStringTypeBindingTest.java =================================================================== --- branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiLineStringTypeBindingTest.java 2012-05-15 17:57:59 UTC (rev 38727) +++ branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/MultiLineStringTypeBindingTest.java 2012-05-15 17:58:13 UTC (rev 38728) @@ -38,5 +38,9 @@ assertEquals(2, dom.getElementsByTagNameNS(GML.NAMESPACE, GML.lineStringMember.getLocalPart()) .getLength()); + + checkDimension(dom, GML.MultiLineString.getLocalPart(), 2); + checkDimension(dom, GML.LineString.getLocalPart(), 2); + //checkPosListOrdinates(dom, 2 * geometry.getGeometryN(0).getNumPoints()); } } Modified: branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/PointTypeBindingTest.java =================================================================== --- branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/PointTypeBindingTest.java 2012-05-15 17:57:59 UTC (rev 38727) +++ branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/PointTypeBindingTest.java 2012-05-15 17:58:13 UTC (rev 38728) @@ -22,6 +22,7 @@ import org.w3c.dom.Document; import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.LineString; import com.vividsolutions.jts.geom.Point; @@ -45,4 +46,21 @@ //assertEquals("urn:x-ogc:def:crs:EPSG:6.11.2:4326", assertEquals("urn:x-ogc:def:crs:EPSG:4326", dom.getDocumentElement().getAttribute("srsName")); } + + public void testEncode2D() throws Exception { + Point point = GML3MockData.pointLite2D(); + Document doc = encode(point, GML.Point); + + checkDimension(doc, GML.Point.getLocalPart(), 2); + checkPosOrdinates(doc, 2); + } + + public void testEncode3D() throws Exception { + Point point = GML3MockData.pointLite3D(); + Document doc = encode(point, GML.Point); + + checkDimension(doc, GML.Point.getLocalPart(), 3); + checkPosOrdinates(doc, 3); + } + } Modified: branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/PolygonTypeBindingTest.java =================================================================== --- branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/PolygonTypeBindingTest.java 2012-05-15 17:57:59 UTC (rev 38727) +++ branches/2.7.x/modules/extension/xsd/xsd-gml3/src/test/java/org/geotools/gml3/bindings/PolygonTypeBindingTest.java 2012-05-15 17:58:13 UTC (rev 38728) @@ -16,8 +16,11 @@ */ package org.geotools.gml3.bindings; +import org.geotools.gml3.GML; import org.geotools.gml3.GML3TestSupport; +import org.w3c.dom.Document; +import com.vividsolutions.jts.geom.LineString; import com.vividsolutions.jts.geom.Polygon; @@ -28,4 +31,22 @@ Polygon polygon = (Polygon) parse(); assertNotNull(polygon); } + + public void testEncode3D() throws Exception { + Polygon poly = GML3MockData.polygonLite3D(); + Document doc = encode(poly, GML.Polygon); + + checkDimension(doc, GML.Polygon.getLocalPart(), 3); + checkPosListOrdinates(doc, 3 * poly.getNumPoints()); + } + + public void testEncode2D() throws Exception { + Polygon poly = GML3MockData.polygonLite2D(); + Document doc = encode(poly, GML.Polygon); + + checkDimension(doc, GML.Polygon.getLocalPart(), 2); + checkPosListOrdinates(doc, 2 * poly.getNumPoints()); + } + + } Modified: branches/2.7.x/modules/library/main/src/main/java/org/geotools/geometry/jts/coordinatesequence/CoordinateSequences.java =================================================================== --- branches/2.7.x/modules/library/main/src/main/java/org/geotools/geometry/jts/coordinatesequence/CoordinateSequences.java 2012-05-15 17:57:59 UTC (rev 38727) +++ branches/2.7.x/modules/library/main/src/main/java/org/geotools/geometry/jts/coordinatesequence/CoordinateSequences.java 2012-05-15 17:58:13 UTC (rev 38728) @@ -21,10 +21,17 @@ import com.vividsolutions.jts.algorithm.RobustDeterminant; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.CoordinateSequence; +import com.vividsolutions.jts.geom.CoordinateSequenceFilter; +import com.vividsolutions.jts.geom.Geometry; +import com.vividsolutions.jts.geom.LineString; +import com.vividsolutions.jts.geom.Point; +import com.vividsolutions.jts.geom.Polygon; +import com.vividsolutions.jts.geom.impl.CoordinateArraySequence; /** * Utility functions for coordinate sequences (extends the same named JTS class) * @author Andrea Aime - OpenGeo + * @author Martin Davis - OpenGeo * * @source $URL: http://svn.osgeo.org/geotools/branches/2.7.x/build/maven/javadoc/../../../modules/library/main/src/main/java/org/geotools/geometry/jts/coordinatesequence/CoordinateSequences.java $ */ @@ -124,4 +131,90 @@ return RobustDeterminant.signOfDet2x2(dx1, dy1, dx2, dy2); } + + /** + * Gets the dimension of the coordinates in a {@link Geometry}, + * by reading it from a component {@link CoordinateSequence}. + * This will be usually either 2 or 3. + * + * @param g a Geometry + * @return the dimension of the coordinates in the Geometry + */ + public static int coordinateDimension(Geometry g) + { + // common fast cases + if (g instanceof Point) + return coordinateDimension(((Point) g).getCoordinateSequence()); + if (g instanceof LineString) + return coordinateDimension(((LineString) g).getCoordinateSequence()); + if (g instanceof Polygon) + return coordinateDimension(((Polygon) g).getExteriorRing() + .getCoordinateSequence()); + + // dig down to find a CS + CoordinateSequence cs = CoordinateSequenceFinder.find(g); + return coordinateDimension(cs); + } + + /** + * Gets the effective dimension of a CoordinateSequence. + * This is a workaround for the issue that CoordinateArraySequence + * does not keep an accurate dimension - it always + * reports dim=3, even if there is no Z ordinate (ie they are NaN). + * This method checks for that case and reports dim=2. + * Only the first coordinate is checked. + * <p> + * There is one small hole: if a CoordinateArraySequence is empty, + * the dimension will be reported as 3. + * + * @param seq a CoordinateSequence + * @return the effective dimension of the coordinate sequence + */ + public static int coordinateDimension(CoordinateSequence seq) + { + int dim = seq.getDimension(); + if (dim != 3) + return dim; + + // hack to handle issue that CoordinateArraySequence always reports + // dimension = 3 + // check if a Z value is NaN - if so, assume dim is 2 + if (seq instanceof CoordinateArraySequence) { + if (seq.size() > 0) { + if (Double.isNaN(seq.getOrdinate(0, CoordinateSequence.Z))) + return 2; + } + } + return 3; + } + + private static class CoordinateSequenceFinder implements CoordinateSequenceFilter { + + public static CoordinateSequence find(Geometry g) { + CoordinateSequenceFinder finder = new CoordinateSequenceFinder(); + g.apply(finder); + return finder.getSeq(); + } + + private CoordinateSequence firstSeqFound = null; + + public CoordinateSequence getSeq() { + return firstSeqFound; + } + + public void filter(CoordinateSequence seq, int i) { + if (firstSeqFound == null) + firstSeqFound = seq; + + } + + public boolean isDone() { + return firstSeqFound != null; + } + + public boolean isGeometryChanged() { + return false; + } + + } } Modified: branches/2.7.x/modules/library/xml/src/test/java/org/geotools/GMLTest.java =================================================================== --- branches/2.7.x/modules/library/xml/src/test/java/org/geotools/GMLTest.java 2012-05-15 17:57:59 UTC (rev 38727) +++ branches/2.7.x/modules/library/xml/src/test/java/org/geotools/GMLTest.java 2012-05-15 17:58:13 UTC (rev 38728) @@ -190,7 +190,7 @@ out.close(); String gml = out.toString(); - assertTrue(gml.indexOf("<gml:Point>") != -1); + assertTrue(gml.indexOf("<gml:Point") != -1); } // |
From: <svn...@os...> - 2012-05-15 17:58:06
|
Author: mdavis Date: 2012-05-15 10:57:59 -0700 (Tue, 15 May 2012) New Revision: 38727 Added: branches/2.7.x/modules/library/main/src/test/java/org/geotools/geometry/jts/GeometryCoordinateSequenceTransformerTest.java Modified: branches/2.7.x/modules/library/api/src/main/java/org/geotools/geometry/jts/GeometryCoordinateSequenceTransformer.java Log: GEOT-4130, GeometryCoordinateSequenceTransformer now uses input CoordinateSequenceFactory by default Modified: branches/2.7.x/modules/library/api/src/main/java/org/geotools/geometry/jts/GeometryCoordinateSequenceTransformer.java =================================================================== --- branches/2.7.x/modules/library/api/src/main/java/org/geotools/geometry/jts/GeometryCoordinateSequenceTransformer.java 2012-05-15 17:57:46 UTC (rev 38726) +++ branches/2.7.x/modules/library/api/src/main/java/org/geotools/geometry/jts/GeometryCoordinateSequenceTransformer.java 2012-05-15 17:57:59 UTC (rev 38727) @@ -17,6 +17,7 @@ package org.geotools.geometry.jts; import com.vividsolutions.jts.geom.CoordinateSequence; +import com.vividsolutions.jts.geom.CoordinateSequenceFactory; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryCollection; import com.vividsolutions.jts.geom.GeometryFactory; @@ -34,9 +35,14 @@ /** - * Service object that takes a geometry an applies a MathTransform on top - * of it. + * Service object that takes a geometry and applies a {@link MathTransform} to the coordinates it + * contains. + * <p> + * New geometries are constructed using the {@link GeometryFactory} of the input geometries. + * By default, this will use the same {@link CoordinateSequenceFactory} as the input geometries. + * </p> * @author Andrea Aime + * @author Martin Davis * * @source $URL$ */ @@ -44,11 +50,23 @@ private MathTransform transform; private CoordinateSequenceTransformer csTransformer; private CoordinateReferenceSystem crs; - + + /** + * Creates a transformer which uses the {@link CoordinateSequenceFactory} + * of the source geometries. + */ public GeometryCoordinateSequenceTransformer() { - csTransformer = new DefaultCoordinateSequenceTransformer(); + // the csTransformer is initialized from the first geometry } + /** + * Creates a transformer which uses a client-specified {@link CoordinateSequenceTransformer}. + * <p> + * <b>WARNING:</b> The CoordinateSequenceTransformer must use the same CoordinateSequenceFactory + * as the input geometries, so that geometries are constructed consistently. + * + * @param transformer + */ public GeometryCoordinateSequenceTransformer(CoordinateSequenceTransformer transformer) { csTransformer = transformer; } @@ -83,6 +101,12 @@ GeometryFactory factory = g.getFactory(); Geometry transformed = null; + // if required, lazily init csTransformer using geometry's CSFactory + if (csTransformer == null) { + CoordinateSequenceFactory csf = g.getFactory().getCoordinateSequenceFactory(); + csTransformer = new DefaultCoordinateSequenceTransformer(csf); + } + if (g instanceof Point) { transformed = transformPoint((Point) g, factory); } else if (g instanceof MultiPoint) { @@ -147,7 +171,7 @@ * * @throws TransformException */ - public LineString transformLineString(LineString ls, GeometryFactory gf) + private LineString transformLineString(LineString ls, GeometryFactory gf) throws TransformException { CoordinateSequence cs = projectCoordinateSequence(ls.getCoordinateSequence()); LineString transformed = null; @@ -167,7 +191,7 @@ * * @throws TransformException */ - public Point transformPoint(Point point, GeometryFactory gf) + private Point transformPoint(Point point, GeometryFactory gf) throws TransformException { CoordinateSequence cs = projectCoordinateSequence(point.getCoordinateSequence()); Point transformed = gf.createPoint(cs);; @@ -180,7 +204,7 @@ * * @throws TransformException */ - public CoordinateSequence projectCoordinateSequence(CoordinateSequence cs) + private CoordinateSequence projectCoordinateSequence(CoordinateSequence cs) throws TransformException { return csTransformer.transform(cs, transform); } @@ -189,7 +213,7 @@ * @param polygon * @throws TransformException */ - public Polygon transformPolygon(Polygon polygon, GeometryFactory gf) + private Polygon transformPolygon(Polygon polygon, GeometryFactory gf) throws TransformException { LinearRing exterior = (LinearRing) transformLineString(polygon.getExteriorRing(), gf); LinearRing[] interiors = new LinearRing[polygon.getNumInteriorRing()]; Added: branches/2.7.x/modules/library/main/src/test/java/org/geotools/geometry/jts/GeometryCoordinateSequenceTransformerTest.java =================================================================== --- branches/2.7.x/modules/library/main/src/test/java/org/geotools/geometry/jts/GeometryCoordinateSequenceTransformerTest.java (rev 0) +++ branches/2.7.x/modules/library/main/src/test/java/org/geotools/geometry/jts/GeometryCoordinateSequenceTransformerTest.java 2012-05-15 17:57:59 UTC (rev 38727) @@ -0,0 +1,211 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2004-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.geometry.jts; + +// J2SE dependencies +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import org.geotools.referencing.crs.DefaultGeographicCRS; +import org.geotools.referencing.operation.transform.ProjectiveTransform; +import org.junit.Test; +import org.opengis.referencing.operation.MathTransform; +import org.opengis.referencing.operation.TransformException; + +import com.vividsolutions.jts.geom.CoordinateSequence; +import com.vividsolutions.jts.geom.CoordinateSequenceFilter; +import com.vividsolutions.jts.geom.Geometry; +import com.vividsolutions.jts.geom.GeometryFactory; + +/** + * Tests the {@link GeometryCoordinateSequenceTransformer} implementation. + * + * @since 2.2 + * + * + * @source $URL$ + * @version $Id$ + * @author Martin Davis + */ +public class GeometryCoordinateSequenceTransformerTest { + + private GeometryFactory geomFact = new GeometryFactory( + new LiteCoordinateSequenceFactory()); + + private GeometryBuilder gb = new GeometryBuilder(geomFact); + + @Test + public void testLineString() throws Exception { + checkTransform(gb.lineStringZ(10, 11, 1, 20, 21, 2)); + checkTransform(gb.lineString(10, 11, 20, 21)); + } + + @Test + public void testPoint() throws Exception { + checkTransform(gb.point(10, 11)); + checkTransform(gb.pointZ(10, 11, 1)); + } + + @Test + public void testPolygon() throws Exception { + checkTransform(gb.circle(10, 10, 5, 20)); + checkTransform(gb.boxZ(10, 10, 20, 20, 99)); + checkTransform(gb.polygon(gb.boxZ(10, 10, 20, 20, 99), + gb.boxZ(11, 11, 19, 19, 99))); + } + + @Test + public void testMulti() throws Exception { + checkTransform(gb.multiPoint(10, 10, 5, 20)); + checkTransform(gb.multiLineString(gb.lineString(10, 10, 20, 20), + gb.lineString(10, 10, 20, 20))); + checkTransform(gb.multiPolygon(gb.boxZ(10, 10, 20, 20, 99), + gb.boxZ(11, 11, 19, 19, 99))); + } + + @Test + public void testGeometryCollection() throws Exception { + checkTransform(gb.geometryCollection(gb.point(10, 11), + gb.lineString(10, 10, 20, 20), gb.box(10, 10, 20, 20))); + } + + /** + * Confirm that testing method is accurate! + * + * @throws Exception + */ + @Test + public void testDifferentDimensionsFailure() throws Exception { + Geometry g1 = gb.box(10, 10, 20, 20); + Geometry g2 = gb.boxZ(10, 10, 20, 20, 99); + assertFalse(hasSameValuesAndStructure(g1, g2)); + } + + private static final double ORD_TOLERANCE = 1.0e-6; + + /** + * Check transformation correctness by transforming forwards and backwards using + * inverse MathTransforms. + * + * @param g + * @throws TransformException + */ + private void checkTransform(Geometry g) throws TransformException { + GeometryCoordinateSequenceTransformer gcsTrans = new GeometryCoordinateSequenceTransformer(); + gcsTrans.setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84); + MathTransform trans = ProjectiveTransform.createTranslation(2, 100); + gcsTrans.setMathTransform(trans); + + GeometryCoordinateSequenceTransformer gcsTransInv = new GeometryCoordinateSequenceTransformer(); + gcsTransInv.setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84); + MathTransform transInv = ProjectiveTransform.createTranslation(2, -100); + gcsTransInv.setMathTransform(transInv); + + Geometry gTrans = gcsTrans.transform(g); + Geometry g2 = gcsTransInv.transform(gTrans); + + // result better be a different geometry + assertTrue(g != g2); + assertTrue(hasSameValuesAndStructure(g, g2)); + } + + boolean hasSameValuesAndStructure(Geometry g1, Geometry g2) { + if (!g1.equalsExact(g2, ORD_TOLERANCE)) + return false; + if (g1.getFactory() != g2.getFactory()) + return false; + + CoordinateSequence seq = CoordinateSequenceFinder.find(g1); + if (!CoordinateSequenceSchemaChecker.check(g2, seq.getClass(), + seq.getDimension())) + return false; + return true; + } + + static class CoordinateSequenceFinder implements CoordinateSequenceFilter { + + public static CoordinateSequence find(Geometry g) { + CoordinateSequenceFinder finder = new CoordinateSequenceFinder(); + g.apply(finder); + return finder.getSeq(); + } + + private CoordinateSequence firstSeqFound = null; + + public CoordinateSequence getSeq() { + return firstSeqFound; + } + + public void filter(CoordinateSequence seq, int i) { + if (firstSeqFound == null) + firstSeqFound = seq; + + } + + public boolean isDone() { + return firstSeqFound != null; + } + + public boolean isGeometryChanged() { + return false; + } + } + + static class CoordinateSequenceSchemaChecker implements + CoordinateSequenceFilter { + + public static boolean check(Geometry g, Class coordSeqClass, int dimension) { + CoordinateSequenceSchemaChecker checkCS = new CoordinateSequenceSchemaChecker( + coordSeqClass, dimension); + g.apply(checkCS); + return checkCS.isSame(); + } + + private Class coordSeqClass; + + private int dimension; + + private boolean isSame = true; + + public CoordinateSequenceSchemaChecker(Class coordSeqClass, int dimension) { + this.coordSeqClass = coordSeqClass; + this.dimension = dimension; + } + + public boolean isSame() { + return isSame; + } + + public void filter(CoordinateSequence seq, int i) { + if (seq.getClass() != coordSeqClass) + isSame = false; + if (seq.getDimension() != dimension) + isSame = false; + } + + public boolean isDone() { + return !isSame; + } + + + public boolean isGeometryChanged() { + return false; + } + + } + +} |
From: <svn...@os...> - 2012-05-15 17:57:55
|
Author: mdavis Date: 2012-05-15 10:57:46 -0700 (Tue, 15 May 2012) New Revision: 38726 Added: branches/2.7.x/modules/library/main/src/main/java/org/geotools/geometry/jts/GeometryBuilder.java Log: GEOT-4145, Added GeometryBuilder for easier creation of JTS geometries Added: branches/2.7.x/modules/library/main/src/main/java/org/geotools/geometry/jts/GeometryBuilder.java =================================================================== --- branches/2.7.x/modules/library/main/src/main/java/org/geotools/geometry/jts/GeometryBuilder.java (rev 0) +++ branches/2.7.x/modules/library/main/src/main/java/org/geotools/geometry/jts/GeometryBuilder.java 2012-05-15 17:57:46 UTC (rev 38726) @@ -0,0 +1,466 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2004-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.geometry.jts; + +import com.vividsolutions.jts.geom.CoordinateSequence; +import com.vividsolutions.jts.geom.CoordinateSequenceFactory; +import com.vividsolutions.jts.geom.Geometry; +import com.vividsolutions.jts.geom.GeometryCollection; +import com.vividsolutions.jts.geom.GeometryFactory; +import com.vividsolutions.jts.geom.LineString; +import com.vividsolutions.jts.geom.LinearRing; +import com.vividsolutions.jts.geom.MultiLineString; +import com.vividsolutions.jts.geom.MultiPoint; +import com.vividsolutions.jts.geom.MultiPolygon; +import com.vividsolutions.jts.geom.Point; +import com.vividsolutions.jts.geom.Polygon; + +/** + * A builder for {@link Geometry} objects. Primarily intended to + * support fluent programming in test code. + * <p> + * Features include: + * <ul> + * <li>Both 2D and 3D coordinate dimensions are supported + * (assuming the provided {@link CoordinateSequenceFactory} supports them) + * <li>Sequences of ordinate values can be supplied in a number of ways + * <li>Rings do not need to be explicitly closed; a closing point will be + * supplied if needed + * <li>Empty geometries of all types can be created + * <li>Composite geometries are validated to ensure they have a consistent + * GeometryFactory and coordinate sequence dimension + * <p> + * Examples of intended usage are: + * + * <pre> + * GeometryBuilder gb = new GeometryBuilder(geomFact); + * LineString line = gb.linestring(1,2, 3,4); + * Polygon poly = gb.polygon(0,0, 0,1, 1,1, 1,0); + * Polygon box = gb.box(0,0, 1,1); + * Polygon hexagon = gb.circle(0,0, 1,1, 6); + * Polygon polyhole = gb.polygon(gb.linearring(0,0, 0,10, 10,10, 10,0), gb.linearring(1,1, 1,9, 9,9, 9,1)) + * </pre> + * + * @author Martin Davis - OpenGeo + * + */ +public class GeometryBuilder { + + private GeometryFactory geomFact; + + private CoordinateSequenceFactory csFact; + + /** + * Create a new instance using the default {@link GeometryFactory}. + */ + public GeometryBuilder() { + this(new GeometryFactory()); + } + + /** + * Creates a new instance using a provided GeometryFactory. + * + * @param geomFact the factory to use + */ + public GeometryBuilder(GeometryFactory geomFact) { + this.geomFact = geomFact; + csFact = geomFact.getCoordinateSequenceFactory(); + } + + /** + * Creates an empty Point + * + * @return an empty Point + */ + public Point point() { + return geomFact.createPoint(createCS(new double[0], 2)); + } + + /** + * Creates an empty Point with coordinate dimension = 3. + * + * @return an empty Point + */ + public Point pointZ() { + return geomFact.createPoint(createCS(new double[0], 3)); + } + + /** + * Creates a 2D Point. + * + * @param x the X ordinate + * @param y the Y ordinate + * @return a Point + */ + public Point point(double x, double y) { + return geomFact.createPoint(createCS(new double[] { x, y }, 2)); + } + + /** + * Creates a 3D Point. + * + * @param x the X ordinate + * @param y the Y ordinate + * @param z the Z ordinate + * @return a Point + */ + public Point pointZ(double x, double y, double z) { + return geomFact.createPoint(createCS(new double[] { x, y, z }, 3)); + } + + /** + * Creates an empty 2D LineString + * + * @return an empty LineString + */ + public LineString lineString() { + return geomFact.createLineString(createCS(new double[0], 2)); + } + + /** + * Creates an empty 3D LineString + * + * @return an empty LineString + */ + public LineString lineStringZ() { + return geomFact.createLineString(createCS(new double[0], 3)); + } + + /** + * Creates a 2D LineString. + * + * @param ord the XY ordinates + * @return a LineString + */ + public LineString lineString(double... ord) { + return geomFact.createLineString(createCS(ord, 2)); + } + + /** + * Creates a 3D LineString. + * + * @param ord the XYZ ordinates + * @return a LineString + */ + public LineString lineStringZ(double... ord) { + return geomFact.createLineString(createCS(ord, 3)); + } + + /** + * Creates an empty 2D LinearRing + * + * @return an empty LinearRing + */ + public LinearRing linearRing() { + return geomFact.createLinearRing(createRingCS(new double[0], 2)); + } + + /** + * Creates an empty 3D LinearRing + * + * @return an empty LinearRing + */ + public LinearRing linearRingZ() { + return geomFact.createLinearRing(createRingCS(new double[0], 3)); + } + + /** + * Creates a 2D LinearRing. If the supplied coordinate list is not closed, a + * closing coordinate is added. + * + * @param ord + * @return a LinearRing + */ + public LinearRing linearRing(double... ord) { + return geomFact.createLinearRing(createRingCS(ord, 2)); + } + + /** + * Creates a 3D LinearRing. If the supplied coordinate list is not closed, a + * closing coordinate is added. + * + * @param ord the XYZ ordinates + * @return a LinearRing + */ + public LinearRing linearRingZ(double... ord) { + return geomFact.createLinearRing(createRingCS(ord, 3)); + } + + /** + * Creates an empty 2D Polygon. + * + * @return an empty Polygon + */ + public Polygon polygon() { + return geomFact.createPolygon(linearRing(), null); + } + + /** + * Creates an empty 3D Polygon. + * + * @return an empty Polygon + */ + public Polygon polygonZ() { + return geomFact.createPolygon(linearRingZ(), null); + } + + /** + * Creates a Polygon from a list of XY coordinates. + * + * @param ord a list of XY ordinates + * @return a Polygon + */ + public Polygon polygon(double... ord) { + return geomFact.createPolygon(linearRing(ord), null); + } + + /** + * Creates a Polygon from a list of XYZ coordinates. + * + * @param ord a list of XYZ ordinates + * @return a Polygon + */ + public Polygon polygonZ(double... ord) { + return geomFact.createPolygon(linearRingZ(ord), null); + } + + /** + * Creates a Polygon from an exterior ring. The coordinate dimension of the + * Polygon is the dimension of the LinearRing. + * + * @param shell the exterior ring + * @return a Polygon + */ + public Polygon polygon(LinearRing shell) { + return geomFact.createPolygon(shell, null); + } + + /** + * Creates a Polygon with a hole from an exterior ring and an interior ring. + * + * @param shell the exterior ring + * @param hole the interior ring + * @return a Polygon with a hole + */ + public Polygon polygon(LinearRing shell, LinearRing hole) { + return geomFact.createPolygon(shell, new LinearRing[] { hole }); + } + + /** + * Creates a Polygon with a hole from an exterior ring and an interior ring + * supplied by the rings of Polygons. + * + * @param shell the exterior ring + * @param hole the interior ring + * @return a Polygon with a hole + */ + public Polygon polygon(Polygon shell, Polygon hole) { + return geomFact.createPolygon((LinearRing) shell.getExteriorRing(), + new LinearRing[] { (LinearRing) hole.getExteriorRing() }); + } + + /** + * Creates a rectangular 2D Polygon from X and Y bounds. + * + * @param x1 the lower X bound + * @param y1 the lower Y bound + * @param x2 the upper X bound + * @param y2 the upper Y bound + * @return a 2D Polygon + */ + public Polygon box(double x1, double y1, double x2, double y2) { + double[] ord = new double[] { x1, y1, x1, y2, x2, y2, x2, y1, x1, y1 }; + return polygon(ord); + } + + /** + * Creates a rectangular 3D Polygon from X and Y bounds. + * + * @param x1 the lower X bound + * @param y1 the lower Y bound + * @param x2 the upper X bound + * @param y2 the upper Y bound + * @param z the Z value for all coordinates + * @return a 3D Polygon + */ + public Polygon boxZ(double x1, double y1, double x2, double y2, double z) { + double[] ord = new double[] { x1, y1, z, x1, y2, z, x2, y2, z, x2, y1, z, + x1, y1, z }; + return polygonZ(ord); + } + + /** + * Creates an elliptical Polygon from a bounding box with a given number of + * sides. + * + * @param x1 + * @param y1 + * @param x2 + * @param y2 + * @param nsides + * @return a 2D Polygon + */ + public Polygon ellipse(double x1, double y1, double x2, double y2, int nsides) { + double rx = Math.abs(x2 - x1) / 2; + double ry = Math.abs(y2 - y1) / 2; + double cx = Math.min(x1, x2) + rx; + double cy = Math.min(x1, x2) + ry; + + double[] ord = new double[2 * nsides + 2]; + double angInc = 2 * Math.PI / nsides; + // create ring in CW order + for (int i = 0; i < nsides; i++) { + double ang = -(i * angInc); + ord[2 * i] = cx + rx * Math.cos(ang); + ord[2 * i + 1] = cy + ry * Math.sin(ang); + } + ord[2 * nsides] = ord[0]; + ord[2 * nsides + 1] = ord[1]; + return polygon(ord); + } + + /** + * Creates a circular Polygon with a given center, radius and number of sides. + * + * @param x the center X ordinate + * @param y the center Y ordinate + * @param radius the radius + * @param nsides the number of sides + * @return a 2D Polygon + */ + public Polygon circle(double x, double y, double radius, int nsides) { + return ellipse(x - radius, y - radius, x + radius, y + radius, nsides); + } + + /** + * Creates a MultiPoint with 2 2D Points. + * + * @param x1 the X ordinate of the first point + * @param y1 the Y ordinate of the first point + * @param x2 the X ordinate of the second point + * @param y2 the Y ordinate of the second point + * @return A MultiPoint + */ + public MultiPoint multiPoint(double x1, double y1, double x2, double y2) { + return geomFact + .createMultiPoint(new Point[] { point(x1, y1), point(x2, y2) }); + } + + /** + * Creates a MultiPoint with 2 3D Points. + * + * @param x1 the X ordinate of the first point + * @param y1 the Y ordinate of the first point + * @param z1 the Z ordinate of the first point + * @param x2 the X ordinate of the second point + * @param y2 the Y ordinate of the second point + * @param z2 the Z ordinate of the second point + * @return A 3D MultiPoint + */ + public MultiPoint multiPointZ(double x1, double y1, double z1, double x2, + double y2, double z2) { + return geomFact.createMultiPoint(new Point[] { pointZ(x1, y1, z1), + pointZ(x2, y2, z2) }); + } + + /** + * Creates a MultiLineString from a set of LineStrings + * + * @param lines the component LineStrings + * @return a MultiLineString + */ + public MultiLineString multiLineString(LineString... lines) { + return geomFact.createMultiLineString(lines); + } + + /** + * Creates a MultiPolygon from a set of Polygons. + * + * @param polys the component polygons + * @return A MultiPolygon + */ + public MultiPolygon multiPolygon(Polygon... polys) { + return geomFact.createMultiPolygon(polys); + } + + /** + * Creates a GeometryCollection from a set of Geometrys + * + * @param geoms the component Geometrys + * @return a GeometryCollection + */ + public GeometryCollection geometryCollection(Geometry... geoms) { + return geomFact.createGeometryCollection(geoms); + } + + /** + * Tests whether a sequence of ordinates of a given dimension is closed (i.e. + * has the first and last coordinate identical). + * + * @param ord the list of ordinate values + * @param dim the dimension of each coordinate + * @return true if the sequence is closed + */ + private boolean isClosed(double[] ord, int dim) { + int n = ord.length / dim; + if (n == 0) + return true; + + int lastPos = dim * (n - 1); + double lastx = ord[lastPos]; + double lasty = ord[lastPos + 1]; + boolean isClosed = lastx == ord[0] && lasty == ord[1]; + return isClosed; + } + + /** + * @param ord + * @param dim + * @return + */ + private CoordinateSequence createRingCS(double[] ord, int dim) { + if (isClosed(ord, dim)) + return createCS(ord, dim); + double[] ord2 = new double[ord.length + dim]; + System.arraycopy(ord, 0, ord2, 0, ord.length); + // copy first coord to last + int n = ord2.length / dim; + int lastPos = dim * n; + for (int i = 0; i < dim; i++) { + ord2[lastPos + i] = ord2[i]; + } + return createCS(ord2, dim); + } + + /** + * @param ord + * @param dim + * @return + */ + private CoordinateSequence createCS(double[] ord, int dim) { + if (ord.length % dim != 0) + throw new IllegalArgumentException("Ordinate array length " + + ord.length + " is not a multiple of dimension " + dim); + int n = ord.length / dim; + CoordinateSequence cs = csFact.create(n, dim); + for (int i = 0; i < n; i++) { + for (int d = 0; d < dim; d++) + cs.setOrdinate(i, d, ord[dim * i + d]); + } + return cs; + } +} |
From: <svn...@os...> - 2012-05-15 06:25:43
|
Author: aaime Date: 2012-05-14 23:25:34 -0700 (Mon, 14 May 2012) New Revision: 38725 Modified: trunk/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2EmptyGeometryTestSetup.java trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGISEmptyGeometryTestSetup.java Log: Removing order dependency from jdbc build Modified: trunk/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2EmptyGeometryTestSetup.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2EmptyGeometryTestSetup.java 2012-05-15 06:24:30 UTC (rev 38724) +++ trunk/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2EmptyGeometryTestSetup.java 2012-05-15 06:25:34 UTC (rev 38725) @@ -55,6 +55,12 @@ @Override protected void dropEmptyGeometryTable() throws Exception { + run("CALL DropGeometryColumn('geotools', 'empty', 'geom_point')"); + run("CALL DropGeometryColumn('geotools', 'empty', 'geom_linestring')"); + run("CALL DropGeometryColumn('geotools', 'empty', 'geom_polygon')"); + run("CALL DropGeometryColumn('geotools', 'empty', 'geom_multipoint')"); + run("CALL DropGeometryColumn('geotools', 'empty', 'geom_multilinestring')"); + run("CALL DropGeometryColumn('geotools', 'empty', 'geom_multipolygon')"); run( "DROP TABLE \"geotools\".\"empty\""); } Modified: trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGISEmptyGeometryTestSetup.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGISEmptyGeometryTestSetup.java 2012-05-15 06:24:30 UTC (rev 38724) +++ trunk/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGISEmptyGeometryTestSetup.java 2012-05-15 06:25:34 UTC (rev 38725) @@ -55,6 +55,7 @@ @Override protected void dropEmptyGeometryTable() throws Exception { + runSafe("DELETE GEOMETRY_COLUMNS WHERE F_TABLE_NAME = 'empty'"); run( "DROP TABLE \"empty\""); } |
From: <svn...@os...> - 2012-05-15 06:24:39
|
Author: aaime Date: 2012-05-14 23:24:30 -0700 (Mon, 14 May 2012) New Revision: 38724 Modified: branches/2.7.x/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2EmptyGeometryTestSetup.java branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGISEmptyGeometryTestSetup.java Log: Removing order dependency from jdbc build Modified: branches/2.7.x/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2EmptyGeometryTestSetup.java =================================================================== --- branches/2.7.x/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2EmptyGeometryTestSetup.java 2012-05-14 10:20:56 UTC (rev 38723) +++ branches/2.7.x/modules/plugin/jdbc/jdbc-h2/src/test/java/org/geotools/data/h2/H2EmptyGeometryTestSetup.java 2012-05-15 06:24:30 UTC (rev 38724) @@ -55,6 +55,12 @@ @Override protected void dropEmptyGeometryTable() throws Exception { + run("CALL DropGeometryColumn('geotools', 'empty', 'geom_point')"); + run("CALL DropGeometryColumn('geotools', 'empty', 'geom_linestring')"); + run("CALL DropGeometryColumn('geotools', 'empty', 'geom_polygon')"); + run("CALL DropGeometryColumn('geotools', 'empty', 'geom_multipoint')"); + run("CALL DropGeometryColumn('geotools', 'empty', 'geom_multilinestring')"); + run("CALL DropGeometryColumn('geotools', 'empty', 'geom_multipolygon')"); run( "DROP TABLE \"geotools\".\"empty\""); } Modified: branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGISEmptyGeometryTestSetup.java =================================================================== --- branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGISEmptyGeometryTestSetup.java 2012-05-14 10:20:56 UTC (rev 38723) +++ branches/2.7.x/modules/plugin/jdbc/jdbc-postgis/src/test/java/org/geotools/data/postgis/PostGISEmptyGeometryTestSetup.java 2012-05-15 06:24:30 UTC (rev 38724) @@ -55,6 +55,7 @@ @Override protected void dropEmptyGeometryTable() throws Exception { + runSafe("DELETE GEOMETRY_COLUMNS WHERE F_TABLE_NAME = 'empty'"); run( "DROP TABLE \"empty\""); } |
Author: nielscharlier Date: 2012-05-14 03:20:56 -0700 (Mon, 14 May 2012) New Revision: 38723 Modified: trunk/modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/AbstractMappingFeatureIterator.java trunk/modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/DataAccessMappingFeatureIterator.java trunk/modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/FilteringMappingFeatureIterator.java trunk/modules/library/render/src/main/java/org/geotools/renderer/lite/StreamingRenderer.java Log: GEOS-5080 - app-schema reprojection Modified: trunk/modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/AbstractMappingFeatureIterator.java =================================================================== --- trunk/modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/AbstractMappingFeatureIterator.java 2012-05-14 04:52:03 UTC (rev 38722) +++ trunk/modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/AbstractMappingFeatureIterator.java 2012-05-14 10:20:56 UTC (rev 38723) @@ -31,12 +31,14 @@ import org.geotools.feature.AppSchemaFeatureFactoryImpl; import org.geotools.feature.FeatureIterator; import org.geotools.feature.Types; +import org.geotools.feature.type.ComplexFeatureTypeFactoryImpl; import org.geotools.filter.FilterFactoryImplNamespaceAware; import org.geotools.xlink.XLINK; import org.opengis.feature.Attribute; import org.opengis.feature.Feature; import org.opengis.feature.FeatureFactory; import org.opengis.feature.type.AttributeDescriptor; +import org.opengis.feature.type.FeatureTypeFactory; import org.opengis.feature.type.PropertyDescriptor; import org.opengis.feature.GeometryAttribute; import org.opengis.feature.Property; @@ -67,6 +69,8 @@ .getLogger("org.geotools.data.complex"); private FilterFactory2 filterFac = CommonFactoryFinder.getFilterFactory2(null); + + protected FeatureTypeFactory ftf = new ComplexFeatureTypeFactoryImpl(); /** * Name representation of xlink:href Modified: trunk/modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/DataAccessMappingFeatureIterator.java =================================================================== --- trunk/modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/DataAccessMappingFeatureIterator.java 2012-05-14 04:52:03 UTC (rev 38722) +++ trunk/modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/DataAccessMappingFeatureIterator.java 2012-05-14 10:20:56 UTC (rev 38723) @@ -40,12 +40,14 @@ import org.geotools.data.complex.filter.XPath.StepList; import org.geotools.data.joining.JoiningNestedAttributeMapping; import org.geotools.data.joining.JoiningQuery; +import org.geotools.factory.CommonFactoryFinder; import org.geotools.feature.AttributeBuilder; import org.geotools.feature.ComplexAttributeImpl; import org.geotools.feature.FeatureCollection; import org.geotools.feature.FeatureImpl; import org.geotools.feature.FeatureIterator; import org.geotools.feature.Types; +import org.geotools.feature.type.ComplexFeatureTypeFactoryImpl; import org.geotools.filter.AttributeExpressionImpl; import org.geotools.filter.FilterAttributeExtractor; import org.geotools.gml2.bindings.GML2EncodingUtils; @@ -60,8 +62,12 @@ import org.opengis.feature.type.AttributeDescriptor; import org.opengis.feature.type.AttributeType; import org.opengis.feature.type.FeatureType; +import org.opengis.feature.type.FeatureTypeFactory; +import org.opengis.feature.type.GeometryDescriptor; +import org.opengis.feature.type.GeometryType; import org.opengis.feature.type.Name; import org.opengis.filter.Filter; +import org.opengis.feature.type.PropertyDescriptor; import org.opengis.filter.expression.Expression; import org.opengis.filter.expression.PropertyName; import org.opengis.filter.identity.FeatureId; @@ -110,6 +116,8 @@ protected FeatureCollection<? extends FeatureType, ? extends Feature> sourceFeatures; protected List<Expression> foreignIds = null; + + protected AttributeDescriptor targetFeature; /** * True if joining is turned off and pre filter exists. There's a need to run extra query to get @@ -325,22 +333,37 @@ // gather declared CRS CoordinateReferenceSystem declaredCRS = this.getDeclaredCrs(crs, version); CoordinateReferenceSystem target; - URI uri=(URI)this.mapping.getTargetFeature().getType().getUserData().get("targetCrs"); - if (uri != null) { - try { - target = CRS.decode(uri.toString()); - } catch (Exception e) { - String msg = "Unable to support srsName: " + uri; - throw new UnsupportedOperationException(msg, e); - } + Object crsobject = this.mapping.getTargetFeature().getType().getUserData().get("targetCrs"); + if (crsobject instanceof CoordinateReferenceSystem) { + target = (CoordinateReferenceSystem) crsobject; + } else if (crsobject instanceof URI) { + + URI uri=(URI) crsobject; + if (uri != null) { + try { + target = CRS.decode(uri.toString()); + } catch (Exception e) { + String msg = "Unable to support srsName: " + uri; + throw new UnsupportedOperationException(msg, e); + } + } else { + target = declaredCRS; + } } else { - target = declaredCRS; + target = declaredCRS; } this.reprojection = target; - + } else { this.reprojection = targetCRS; } + + //clean up user data related to request + mapping.getTargetFeature().getType().getUserData().put("targetVersion", null); + mapping.getTargetFeature().getType().getUserData().put("targetCrs", null); + + //reproject target feature + targetFeature = reprojectAttribute(mapping.getTargetFeature()); // we need to disable the max number of features retrieved so we can // sort them manually just in case the data is denormalised @@ -854,22 +877,61 @@ } return sources; } + + private GeometryDescriptor reprojectGeometry(GeometryDescriptor descr) { + if (descr == null) { + return null; + } + GeometryType type = ftf.createGeometryType(descr.getType().getName(), descr.getType().getBinding(), reprojection, descr.getType().isIdentified(), descr.getType().isAbstract(), descr.getType().getRestrictions(), descr.getType().getSuper(), descr.getType().getDescription()); + type.getUserData().putAll(descr.getType().getUserData()); + GeometryDescriptor gd = ftf.createGeometryDescriptor(type, descr.getName(), descr.getMinOccurs(), descr.getMaxOccurs(), descr.isNillable(), descr.getDefaultValue()); + gd.getUserData().putAll(descr.getUserData()); + return gd; + } + private FeatureType reprojectType(FeatureType type) { + Collection<PropertyDescriptor> schema = new ArrayList<PropertyDescriptor>(); + + for (PropertyDescriptor descr : type.getDescriptors()) { + if (descr instanceof GeometryDescriptor) { + schema.add(reprojectGeometry((GeometryDescriptor)descr)); + } + else { + schema.add(descr); + } + } + + FeatureType ft = ftf.createFeatureType(type.getName(), schema, reprojectGeometry(type.getGeometryDescriptor()), type.isAbstract(), type.getRestrictions(), type.getSuper(), type.getDescription()); + ft.getUserData().putAll(type.getUserData()); + return ft; + } + + + private AttributeDescriptor reprojectAttribute(AttributeDescriptor descr) { + + if ( reprojection != null && descr.getType() instanceof FeatureType ) { + AttributeDescriptor ad = ftf.createAttributeDescriptor(reprojectType((FeatureType) descr.getType()), descr.getName(), descr.getMinOccurs(), descr.getMaxOccurs(), descr.isNillable(), descr.getDefaultValue()); + ad.getUserData().putAll(descr.getUserData()); + return ad; + } else { + return descr; + } + } + protected Feature computeNext() throws IOException { String id = getNextFeatureId(); List<Feature> sources = getSources(id); - final AttributeDescriptor targetNode = mapping.getTargetFeature(); - final Name targetNodeName = targetNode.getName(); + final Name targetNodeName = targetFeature.getName(); AttributeBuilder builder = new AttributeBuilder(attf); - builder.setDescriptor(targetNode); + builder.setDescriptor(targetFeature); Feature target = (Feature) builder.build(id); for (AttributeMapping attMapping : selectedMapping) { try { - if (skipTopElement(targetNodeName, attMapping.getTargetXPath(), targetNode.getType())) { + if (skipTopElement(targetNodeName, attMapping.getTargetXPath(), targetFeature.getType())) { // ignore the top level mapping for the Feature itself // as it was already set continue; Modified: trunk/modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/FilteringMappingFeatureIterator.java =================================================================== --- trunk/modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/FilteringMappingFeatureIterator.java 2012-05-14 04:52:03 UTC (rev 38722) +++ trunk/modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/FilteringMappingFeatureIterator.java 2012-05-14 10:20:56 UTC (rev 38723) @@ -137,7 +137,7 @@ try { reprojectedFeatures = new ReprojectingIterator(srcFeatures.iterator(), mappedSource .getSchema().getCoordinateReferenceSystem(), targetCrs, - (SimpleFeatureType) this.mappedSource.getSchema(), transformer); + (SimpleFeatureType) this.sourceFeatures.getSchema(), transformer); while (reprojectedFeatures.hasNext()) { features.add(reprojectedFeatures.next()); } Modified: trunk/modules/library/render/src/main/java/org/geotools/renderer/lite/StreamingRenderer.java =================================================================== --- trunk/modules/library/render/src/main/java/org/geotools/renderer/lite/StreamingRenderer.java 2012-05-14 04:52:03 UTC (rev 38722) +++ trunk/modules/library/render/src/main/java/org/geotools/renderer/lite/StreamingRenderer.java 2012-05-14 10:20:56 UTC (rev 38723) @@ -1958,8 +1958,21 @@ checkAttributeExistence(featureSource.getSchema(), query); rawFeatures = featureSource.getFeatures(query); } - features = prepFeatureCollection(rawFeatures, sourceCrs); + features = prepFeatureCollection(rawFeatures, sourceCrs); + // HACK HACK HACK + // For complex features, we need the targetCrs and version in scenario where we have + // a top level feature that does not contain a geometry(therefore no crs) and has a + // nested feature that contains geometry as its property.Furthermore it is possible + // for each nested feature to have different crs hence we need to reproject on each + // feature accordingly. + // This is a Hack, this information should not be passed through feature type + // appschema will need to remove this information from the feature type again + if (!(features instanceof SimpleFeatureCollection)) { + features.getSchema().getUserData().put("targetCrs", destinationCrs); + features.getSchema().getUserData().put("targetVersion", "wms:getmap"); + } + // finally, perform rendering if(isOptimizedFTSRenderingEnabled() && lfts.size() > 1) { drawOptimized(graphics, currLayer, at, destinationCrs, layerId, null, features, |
From: <svn...@os...> - 2012-05-14 04:52:10
|
Author: bencaradocdavies Date: 2012-05-13 21:52:03 -0700 (Sun, 13 May 2012) New Revision: 38722 Modified: trunk/modules/extension/app-schema/app-schema-resolver/src/main/java/org/geotools/xml/AppSchemaValidator.java Log: Removed unused imports Modified: trunk/modules/extension/app-schema/app-schema-resolver/src/main/java/org/geotools/xml/AppSchemaValidator.java =================================================================== --- trunk/modules/extension/app-schema/app-schema-resolver/src/main/java/org/geotools/xml/AppSchemaValidator.java 2012-05-13 20:15:40 UTC (rev 38721) +++ trunk/modules/extension/app-schema/app-schema-resolver/src/main/java/org/geotools/xml/AppSchemaValidator.java 2012-05-14 04:52:03 UTC (rev 38722) @@ -21,8 +21,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; -import java.net.MalformedURLException; -import java.net.URL; import java.util.ArrayList; import java.util.Collections; import java.util.List; |