Source Code Cross Referenced for StaticLineStringTest.java in  » GIS » jts » com » vividsolutions » jts » io » oracle » 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 » jts » com.vividsolutions.jts.io.oracle 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The JTS Topology Suite is a collection of Java classes that
003:         * implement the fundamental operations required to validate a given
004:         * geo-spatial data set to a known topological specification.
005:         *
006:         * Copyright (C) 2001 Vivid Solutions
007:         *
008:         * This library is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU Lesser General Public
010:         * License as published by the Free Software Foundation; either
011:         * version 2.1 of the License, or (at your option) any later version.
012:         *
013:         * This library is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
016:         * Lesser General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU Lesser General Public
019:         * License along with this library; if not, write to the Free Software
020:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
021:         *
022:         * For more information, contact:
023:         *
024:         *     Vivid Solutions
025:         *     Suite #1A
026:         *     2328 Government Street
027:         *     Victoria BC  V8T 5G5
028:         *     Canada
029:         *
030:         *     (250)385-6040
031:         *     www.vividsolutions.com
032:         */
033:        package com.vividsolutions.jts.io.oracle;
034:
035:        import java.sql.SQLException;
036:
037:        import oracle.sql.STRUCT;
038:
039:        import com.vividsolutions.jts.generator.*;
040:        import com.vividsolutions.jts.geom.*;
041:
042:        /**
043:         * 
044:         * Does round trip testing by creating the oracle object, then decoding it. 
045:         * 
046:         * These tests do not include insert / delete / select operations.
047:         * 
048:         * NOTE: This test does require a precision to be used during the comparison, 
049:         * as points are rounded somewhat when creating the oracle struct. 
050:         * (One less decimal than a java double).
051:         *
052:         * @author David Zwiers, Vivid Solutions. 
053:         */
054:        public class StaticLineStringTest extends ConnectedTestCase {
055:
056:            /**
057:             * @param arg
058:             */
059:            public StaticLineStringTest(String arg) {
060:                super (arg);
061:            }
062:
063:            /**
064:             * Round Trip test for a single line string
065:             * @throws SQLException 
066:             */
067:            public void testSingleLineStringRoundTrip() throws SQLException {
068:                LineStringGenerator pg = new LineStringGenerator();
069:                pg.setGeometryFactory(geometryFactory);
070:                pg.setBoundingBox(new Envelope(0, 10, 0, 10));
071:                pg.setNumberPoints(10);
072:
073:                LineString pt = (LineString) pg.create();
074:
075:                OraWriter ow = new OraWriter(getConnection());
076:                STRUCT st = ow.write(pt);
077:
078:                OraReader or = new OraReader();
079:                LineString pt2 = (LineString) or.read(st);
080:
081:                //		System.out.println((pt==null?"NULL":pt.toString()));
082:                //		System.out.println((pt2==null?"NULL":pt2.toString()));
083:                assertTrue(
084:                        "The input LineString is not the same as the output LineString",
085:                        pt.equals(pt2));
086:            }
087:
088:            /**
089:             * Round Trip test for a 100 non overlapping line strings
090:             * @throws SQLException 
091:             */
092:            public void testGridLineStringsRoundTrip() throws SQLException {
093:                GridGenerator grid = new GridGenerator();
094:                grid.setGeometryFactory(geometryFactory);
095:                grid.setBoundingBox(new Envelope(0, 10, 0, 10));
096:                grid.setNumberColumns(10);
097:                grid.setNumberRows(10);
098:
099:                LineString[] pt = new LineString[100];
100:                STRUCT[] st = new STRUCT[100];
101:
102:                LineStringGenerator pg = new LineStringGenerator();
103:                pg.setGeometryFactory(geometryFactory);
104:                pg.setNumberPoints(10);
105:                OraWriter ow = new OraWriter(getConnection());
106:
107:                int i = 0;
108:                while (grid.canCreate() && i < 100) {
109:                    pg.setBoundingBox(grid.createEnv());
110:                    pt[i] = (LineString) pg.create();
111:                    st[i] = ow.write(pt[i]);
112:                    i++;
113:                }
114:
115:                OraReader or = new OraReader();
116:                i = 0;
117:                while (i < 100 && pt[i] != null) {
118:                    LineString pt2 = (LineString) or.read(st[i]);
119:                    //			System.out.println((pt[i]==null?"NULL":pt[i].toString()));
120:                    //			System.out.println((pt2==null?"NULL":pt2.toString()));
121:                    assertTrue(
122:                            "The input LineString is not the same as the output LineString",
123:                            pt[i].equals(pt2));
124:                    i++;
125:                }
126:            }
127:
128:            /**
129:             * Round Trip test for a 8 overlapping line strings (4 distinct line strings)
130:             * @throws SQLException 
131:             */
132:            public void testOverlappingLineStringsRoundTrip()
133:                    throws SQLException {
134:                GridGenerator grid = new GridGenerator();
135:                grid.setGeometryFactory(geometryFactory);
136:                grid.setBoundingBox(new Envelope(0, 10, 0, 10));
137:                grid.setNumberColumns(2);
138:                grid.setNumberRows(2);
139:
140:                LineString[] pt = new LineString[4];
141:                STRUCT[] st = new STRUCT[8];
142:
143:                LineStringGenerator pg = new LineStringGenerator();
144:                pg.setGeometryFactory(geometryFactory);
145:                pg.setNumberPoints(10);
146:                OraWriter ow = new OraWriter(getConnection());
147:
148:                int i = 0;
149:                while (grid.canCreate() && i < 8) {
150:                    pg.setBoundingBox(grid.createEnv());
151:                    pt[i] = (LineString) pg.create();
152:                    st[i] = ow.write(pt[i]);
153:                    i++;
154:                }
155:                for (int j = 0; j < 4; j++) {
156:                    if (pt[j] != null)
157:                        st[i++] = ow.write(pt[j]);
158:                }
159:
160:                OraReader or = new OraReader();
161:                i = 0;
162:                while (i < 8 && pt[i % 4] != null) {
163:                    LineString pt2 = (LineString) or.read(st[i]);
164:                    //			System.out.println((pt==null?"NULL":pt[i%4].toString()));
165:                    //			System.out.println((pt2==null?"NULL":pt2.toString()));
166:                    assertTrue(
167:                            "The input LineString is not the same as the output LineString",
168:                            pt[i % 4].equals(pt2));
169:                    i++;
170:                }
171:            }
172:
173:            /**
174:             * Round Trip test for a single line string with lotsa points
175:             * @throws SQLException 
176:             */
177:            public void testSingleLineStringManyPointRoundTrip()
178:                    throws SQLException {
179:                LineStringGenerator pg = new LineStringGenerator();
180:                pg.setGeometryFactory(geometryFactory);
181:                pg.setBoundingBox(new Envelope(0, 10, 0, 10));
182:                pg.setGenerationAlgorithm(LineStringGenerator.HORZ);
183:                pg.setNumberPoints(1000);
184:
185:                LineString pt = (LineString) pg.create();
186:                //		System.out.println((pt==null?"NULL":pt.toString()));
187:
188:                OraWriter ow = new OraWriter(getConnection());
189:                STRUCT st = ow.write(pt);
190:
191:                OraReader or = new OraReader();
192:                LineString pt2 = (LineString) or.read(st);
193:
194:                //		System.out.println((pt==null?"NULL":pt.toString()));
195:                //		System.out.println((pt2==null?"NULL":pt2.toString()));
196:                assertTrue(
197:                        "The input LineString is not the same as the output LineString",
198:                        pt.equals(pt2));
199:            }
200:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.