Source Code Cross Referenced for ReprojectingFilterVisitorTest.java in  » GIS » GeoServer » org » geoserver » feature » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeoServer » org.geoserver.feature 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.geoserver.feature;
002:
003:        import java.util.Collections;
004:
005:        import junit.framework.TestCase;
006:
007:        import org.geoserver.feature.ReprojectingFilterVisitor;
008:        import org.geotools.data.DataUtilities;
009:        import org.geotools.factory.CommonFactoryFinder;
010:        import org.geotools.factory.GeoTools;
011:        import org.geotools.feature.FeatureType;
012:        import org.geotools.referencing.CRS;
013:        import org.opengis.filter.Filter;
014:        import org.opengis.filter.FilterFactory2;
015:        import org.opengis.filter.expression.Literal;
016:        import org.opengis.filter.spatial.BBOX;
017:        import org.opengis.filter.spatial.Intersects;
018:
019:        import com.vividsolutions.jts.geom.Coordinate;
020:        import com.vividsolutions.jts.geom.GeometryFactory;
021:        import com.vividsolutions.jts.geom.LineString;
022:
023:        public class ReprojectingFilterVisitorTest extends TestCase {
024:
025:            FeatureType ft;
026:            FilterFactory2 ff;
027:            ReprojectingFilterVisitor reprojector;
028:
029:            protected void setUp() throws Exception {
030:                System.setProperty("org.geotools.referencing.forceXY", "true");
031:                ft = DataUtilities
032:                        .createType("testType",
033:                                "geom:Point:srid=4326,line:LineString,name:String,id:int");
034:                ff = CommonFactoryFinder.getFilterFactory2(GeoTools
035:                        .getDefaultHints());
036:                reprojector = new ReprojectingFilterVisitor(ff, ft);
037:            }
038:
039:            /**
040:             * Make sure it does not break with non spatial filters
041:             */
042:            public void testNoProjection() {
043:                Filter idFilter = ff.id(Collections.singleton(ff
044:                        .featureId("testType:1")));
045:                Filter clone = (Filter) idFilter.accept(reprojector, null);
046:                assertNotSame(idFilter, clone);
047:                assertEquals(idFilter, clone);
048:            }
049:
050:            public void testBboxNoReprojection() {
051:                // no reprojection needed in fact
052:                Filter bbox = ff.bbox(ff.property("geom"), 10, 10, 20, 20,
053:                        "EPSG:4326");
054:                Filter clone = (Filter) bbox.accept(reprojector, null);
055:                assertNotSame(bbox, clone);
056:                assertEquals(bbox, clone);
057:            }
058:
059:            public void testBboxReproject() {
060:                // see if coordinates gets flipped, urn forces lat/lon interpretation
061:                BBOX bbox = ff.bbox(ff.property("geom"), 10, 15, 20, 25,
062:                        "urn:x-ogc:def:crs:EPSG:6.11.2:4326");
063:                Filter clone = (Filter) bbox.accept(reprojector, null);
064:                assertNotSame(bbox, clone);
065:                BBOX clonedBbox = (BBOX) clone;
066:                assertEquals(bbox.getPropertyName(), clonedBbox
067:                        .getPropertyName());
068:                assertTrue(15 == clonedBbox.getMinX());
069:                assertTrue(10 == clonedBbox.getMinY());
070:                assertTrue(25 == clonedBbox.getMaxX());
071:                assertTrue(20 == clonedBbox.getMaxY());
072:                assertEquals("EPSG:4326", clonedBbox.getSRS());
073:            }
074:
075:            public void testBboxReprojectUnreferencedProperty() {
076:                // see if coordinates gets flipped, urn forces lat/lon interpretation
077:                BBOX bbox = ff.bbox(ff.property("line"), 10, 15, 20, 25,
078:                        "urn:x-ogc:def:crs:EPSG:6.11.2:4326");
079:                Filter clone = (Filter) bbox.accept(reprojector, null);
080:                assertNotSame(bbox, clone);
081:                assertEquals(bbox, clone);
082:            }
083:
084:            public void testBboxReprojectUnreferencedBBox() {
085:                // see if coordinates gets flipped, urn forces lat/lon interpretation
086:                BBOX bbox = ff.bbox(ff.property("geom"), 10, 15, 20, 25, null);
087:                Filter clone = (Filter) bbox.accept(reprojector, null);
088:                assertNotSame(bbox, clone);
089:                assertEquals(bbox, clone);
090:            }
091:
092:            public void testIntersectsReproject() throws Exception {
093:                GeometryFactory gf = new GeometryFactory();
094:                LineString ls = gf.createLineString(new Coordinate[] {
095:                        new Coordinate(10, 15), new Coordinate(20, 25) });
096:                ls
097:                        .setUserData(CRS
098:                                .decode("urn:x-ogc:def:crs:EPSG:6.11.2:4326"));
099:
100:                // see if coordinates gets flipped, urn forces lat/lon interpretation
101:                Intersects original = ff.intersects(ff.property("geom"), ff
102:                        .literal(ls));
103:                Filter clone = (Filter) original.accept(reprojector, null);
104:                assertNotSame(original, clone);
105:                Intersects isClone = (Intersects) clone;
106:                assertEquals(isClone.getExpression1(), original
107:                        .getExpression1());
108:                LineString clonedLs = (LineString) ((Literal) isClone
109:                        .getExpression2()).getValue();
110:                assertTrue(15 == clonedLs.getCoordinateN(0).x);
111:                assertTrue(10 == clonedLs.getCoordinateN(0).y);
112:                assertTrue(25 == clonedLs.getCoordinateN(1).x);
113:                assertTrue(20 == clonedLs.getCoordinateN(1).y);
114:                assertEquals(CRS.decode("EPSG:4326"), clonedLs.getUserData());
115:            }
116:
117:            public void testIntersectsUnreferencedGeometry() throws Exception {
118:                GeometryFactory gf = new GeometryFactory();
119:                LineString ls = gf.createLineString(new Coordinate[] {
120:                        new Coordinate(10, 15), new Coordinate(20, 25) });
121:
122:                // see if coordinates gets flipped, urn forces lat/lon interpretation
123:                Intersects original = ff.intersects(ff.property("geom"), ff
124:                        .literal(ls));
125:                Filter clone = (Filter) original.accept(reprojector, null);
126:                assertNotSame(original, clone);
127:                assertEquals(original, clone);
128:            }
129:
130:            public void testIntersectsUnreferencedProperty() throws Exception {
131:                GeometryFactory gf = new GeometryFactory();
132:                LineString ls = gf.createLineString(new Coordinate[] {
133:                        new Coordinate(10, 15), new Coordinate(20, 25) });
134:                ls
135:                        .setUserData(CRS
136:                                .decode("urn:x-ogc:def:crs:EPSG:6.11.2:4326"));
137:
138:                // see if coordinates gets flipped, urn forces lat/lon interpretation
139:                Intersects original = ff.intersects(ff.property("line"), ff
140:                        .literal(ls));
141:                Filter clone = (Filter) original.accept(reprojector, null);
142:                assertNotSame(original, clone);
143:                assertEquals(original, clone);
144:            }
145:
146:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.