Source Code Cross Referenced for GeometryFixture.java in  » GIS » GeoTools-2.4.1 » org » geotools » data » oracle » sdo » 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 » GeoTools 2.4.1 » org.geotools.data.oracle.sdo 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2003-2006, Geotools Project Managment Committee (PMC)
005:         *    (C) 2003  Refractions Research Inc.
006:         *    
007:         *    This library is free software; you can redistribute it and/or
008:         *    modify it under the terms of the GNU Lesser General Public
009:         *    License as published by the Free Software Foundation; either
010:         *    version 2.1 of the License, or (at your option) any later version.
011:         *
012:         *    This library is distributed in the hope that it will be useful,
013:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         *    Lesser General Public License for more details.
016:         *
017:         *    Refractions Research Inc. Can be found on the web at:
018:         *    http://www.refractions.net/
019:         */
020:        package org.geotools.data.oracle.sdo;
021:
022:        import com.vividsolutions.jts.geom.Coordinate;
023:        import com.vividsolutions.jts.geom.CoordinateSequence;
024:        import com.vividsolutions.jts.geom.Geometry;
025:        import com.vividsolutions.jts.geom.GeometryCollection;
026:        import com.vividsolutions.jts.geom.GeometryFactory;
027:        import com.vividsolutions.jts.geom.LineString;
028:        import com.vividsolutions.jts.geom.LinearRing;
029:        import com.vividsolutions.jts.geom.MultiLineString;
030:        import com.vividsolutions.jts.geom.MultiPoint;
031:        import com.vividsolutions.jts.geom.MultiPolygon;
032:        import com.vividsolutions.jts.geom.Point;
033:        import com.vividsolutions.jts.geom.Polygon;
034:        import com.vividsolutions.jts.geom.PrecisionModel;
035:
036:        /**
037:         * Construct geometry used by test cases.
038:         * <p>
039:         * Several examples are from the the Oracle Spatial Geometry Spec.</p>
040:         * 
041:         * @see net.refractions.jspatial.jts
042:         * @author jgarnett, Refractions Reasearch Inc.
043:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/oracle-spatial/src/test/java/org/geotools/data/oracle/sdo/GeometryFixture.java $
044:         * @version CVS Version
045:         */
046:        public class GeometryFixture {
047:            GeometryFactory gf;
048:
049:            /**
050:             * Geometry Example "2.3.1 Rectangle".
051:             * <p>
052:             * A simple rectangle as used with CAD applications</p>
053:             * <code><pre>
054:             * (1,7)         (5,7)
055:             *   +-------------+
056:             *   |             |
057:             *   |             |
058:             *   +-------------+
059:             * (1,1)          (5,1)
060:             * </pre><code>
061:             */
062:            public Polygon rectangle;
063:
064:            /** Polygon used for testing */
065:            public Polygon polygon;
066:
067:            /**
068:             * Geometry Example "2.3.2 Polygon with Hole".
069:             * <p>
070:             * A Polygon with a Hole as follows:</p>
071:             * <code><pre>
072:             *   5,13+-------------+   11,13
073:             *      /               \
074:             * 2,11+                 \
075:             *     | 7,10+----+10,10  \
076:             *     |     |    |       +13,9
077:             *     |     |    |       |
078:             *     |     |    |       |
079:             *     |  7,5+----+10,5   +13,5
080:             *  2,4+                  /
081:             *      \                /
082:             *   4,3+---------------+10,3
083:             * </pre></code>
084:             */
085:            public Polygon polygonWithHole;
086:            /**
087:             * Geometry Example "2.3.5 Point".
088:             * <p>
089:             * Simple Point used to test POINT_TYPE array use.</p>
090:             * <code><pre>
091:             *   +   12,14
092:             * </pre></code>
093:             */
094:            public Point point;
095:
096:            /** LineString used for testing */
097:            public LineString lineString;
098:
099:            /** MultiPoint used for testing */
100:            public MultiPoint multiPoint;
101:
102:            /** MultiLineString used for testing */
103:            public MultiLineString multiLineString;
104:
105:            /** MultiPolygon used for testing */
106:            public MultiPolygon multiPolygon;
107:
108:            /** MultiPolygon used for testing */
109:            public MultiPolygon multiPolygonWithHole;
110:
111:            /** GeometryCollection used for testing */
112:            public GeometryCollection geometryCollection;
113:
114:            /**
115:             * Construct Fixture for use with default GeometryFactory.
116:             */
117:            public GeometryFixture() {
118:                this (new GeometryFactory(new PrecisionModel(), -1));
119:            }
120:
121:            /**
122:             * Construct Fixture for use with provided <code>GeometryFactory</code>.
123:             */
124:            public GeometryFixture(GeometryFactory geometryFactory) {
125:                gf = geometryFactory;
126:                rectangle = createRectangle();
127:                polygon = createPolygon();
128:                polygonWithHole = createPolygonWithHole();
129:                point = createPoint();
130:                lineString = createLineString();
131:                multiPoint = createMultiPoint();
132:                multiLineString = createMultiLineString();
133:                multiPolygon = createMultiPolygon();
134:                multiPolygonWithHole = createMultiPolygonWithHole();
135:                geometryCollection = createGeometryCollection();
136:            }
137:
138:            /**
139:             * Construct a rectangle according to Geometry Examples "2.3.1 Rectangle".
140:             * <p>
141:             * A simple rectangle as used with CAD applications</p>
142:             * <code><pre>
143:             * (1,7)         (5,7)
144:             *   +-------------+
145:             *   |             |
146:             *   |             |
147:             *   +-------------+
148:             * (1,1)          (5,1)
149:             * </pre><code>
150:             * <p>The polygon is not consturcted with an SRID (ie srid == -1)</p>
151:             * A Rectangle with expected encoding:</p>
152:             * <ul>
153:             * <li><b>SDO_GTYPE:</b><code>2003</code><br/>
154:             *     2 dimensional polygon
155:             *     </li>
156:             * <li><b>SDO_SRID:</b><code>NULL</code></li>
157:             * <li><b>SDO_POINT:</b>NULL></li>
158:             * <li><b>SDO_ELEM_INFO:</b><code>(1,1003,3)</code><br/>
159:             *     03 indicates this is a rectangle
160:             *     </li>
161:             * <li><b>SDO_ORDINATES:</b><code>(1,1,5,7)</code><br/>
162:             *     bottom left and upper right
163:             *     </li> 
164:             * </ul>
165:             * <p>
166:             * SQL:</p>
167:             * <code><pre>
168:             * MDSYS.SDO_GEOMETRY(
169:             *   2003,
170:             *   NULL,
171:             *   NULL,
172:             *   MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,3),
173:             *   MDSYS.SDO_ORDINATE_ARRAY(1,1,5,7)
174:             * )
175:             * </pre></code>
176:             * 
177:             * @see GeometryFixture.rectangle
178:             */
179:            protected Polygon createRectangle() {
180:                Polygon rect = gf.createPolygon(ring(new double[] { 1, 1, 5, 1,
181:                        5, 7, 1, 7, 1, 1 }), null);
182:                return rect;
183:            }
184:
185:            /**
186:             * Construct a polygon of a triangle.
187:             * <p>
188:             * Used to illustrate polyugon encoding.</p>
189:             * <code><pre>
190:             *        +11,8
191:             *       / \
192:             *      /   \
193:             *     /     \
194:             * 9,5+-------+13,5
195:             * </pre></code>
196:             * <p>
197:             * A Rectangle with expected encoding:</p>
198:             * <ul>
199:             * <li><b>SDO_GTYPE:</b><code>2003</code><br/>
200:             *     2 dimensional polygon
201:             *     </li>
202:             * <li><b>SDO_SRID:</b><code>NULL</code></li>
203:             * <li><b>SDO_POINT:</b>NULL></li>
204:             * <li><b>SDO_ELEM_INFO:</b><code>(1,1003,1)</code><br/>
205:             *     1000 for external, 03 for polygon,
206:             *     1 indicates this polygon uses strait edges
207:             *     </li>
208:             * <li><b>SDO_ORDINATES:</b><code>(1,1,5,7)</code><br/>
209:             *     bottom left and upper right
210:             *     </li> 
211:             * </ul>
212:             * <p>
213:             * SQL:</p>
214:             * <code><pre>
215:             * MDSYS.SDO_GEOMETRY(
216:             *   2003,
217:             *   NULL,
218:             *   NULL,
219:             *   MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1),
220:             *   MDSYS.SDO_ORDINATE_ARRAY(9,5, 13,5, 11,8, 9,5)
221:             * )
222:             * </pre></code>
223:             */
224:            protected Polygon createPolygon() {
225:                Polygon poly = gf.createPolygon(ring(new double[] { 9, 5, 13,
226:                        5, 11, 8, 9, 5 }), null);
227:                poly.setSRID(-1); // don't have an SRID number
228:                return poly;
229:            }
230:
231:            /**
232:             * Construct a polygon with hole according to Geometry Examples 2.3.2.
233:             * <p>
234:             * Polygon examples used to illustrate compound encoding.</p>
235:             * <code><pre>
236:             *   5,13+-------------+   11,13
237:             *      /               \
238:             * 2,11+                 \
239:             *     | 7,10+----+10,10  \
240:             *     |     |    |       +13,9
241:             *     |     |    |       |
242:             *     |     |    |       |
243:             *     |  7,5+----+10,5   +13,5
244:             *  2,4+                  /
245:             *      \                /
246:             *   4,3+---------------+10,3
247:             * </pre></code>
248:             * <p>
249:             * A Polygon with expected encoding:</p>
250:             * <ul>
251:             * <li><b>SDO_GTYPE:</b><code>2003</code><br/>
252:             *     2 dimensional polygon, 3 for polygon
253:             *     </li>
254:             * <li><b>SDO_SRID:</b><code>NULL</code></li>
255:             * <li><b>SDO_POINT:</b>NULL></li>
256:             * <li><b>SDO_ELEM_INFO:</b><code>(1,1003,1,19,2003,1)</code><br/>
257:             *     Two triplets
258:             *     <ul>
259:             *     <li>(1,1003,1): exterior polygon ring starting at 1
260:             *         </li>
261:             *         
262:             *     <li>(19,2003,1): interior polygon ring starting at 19
263:             *         </li>
264:             *     </ul>
265:             *     </li>
266:             * <li><b>SDO_ORDINATES:</b>
267:             *     <code><pre>
268:             *        (2,4, 4,3, 10,3, 13,5, 13,9, 11,13, 5,13, 2,11, 2,4,
269:             *         7,5, 7,10, 10,10, 10,5, 7,5)
270:             *     </code><pre/>
271:             *     </li> 
272:             * </ul>
273:             * <p>
274:             * SQL:</p>
275:             * <code><pre>
276:             * MDSYS.SDO_GEOMETRY(
277:             *   2003,
278:             *   NULL,
279:             *   NULL,
280:             *   MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1, 19,2003,1),
281:             *   MDSYS.SDO_ORDINATE_ARRAY(2,4, 4,3, 10,3, 13,5, 13,9, 11,13, 5,13, 2,11, 2,4,
282:             *       7,5, 7,10, 10,10, 10,5, 7,5)
283:             * )
284:             * </pre></code> 
285:             */
286:            protected Polygon createPolygonWithHole() {
287:                Polygon poly = gf.createPolygon(ring(new double[] { 2, 4, 4, 3,
288:                        10, 3, 13, 5, 13, 9, 11, 13, 5, 13, 2, 11, 2, 4 }),
289:                        new LinearRing[] { ring(new double[] { 7, 5, 7, 10, 10,
290:                                10, 10, 5, 7, 5 }), });
291:                poly.setSRID(-1); // don't have an SRID number
292:                return poly;
293:            }
294:
295:            /**
296:             * Geometry Example "2.3.5 Point".
297:             * <p>
298:             * Simple Point used to test POINT_TYPE array use.</p>
299:             * <code><pre>
300:             *   +   12,14
301:             * </pre></code>
302:             * <p>
303:             * Expected Encoding:</p>
304:             * <ul>
305:             * <li><b>SDO_GTYPE:</b><code>2001</code><br/>
306:             *     2 dimensional, 0 measures, 01 for point
307:             *     </li>
308:             * <li><b>SDO_SRID:</b><code>NULL</code></li>
309:             * <li><b>SDO_POINT:</b><code>(12,14,NULL)</code></li>
310:             * <li><b>SDO_ELEM_INFO:</b><code>(1,1,1)</code></li>
311:             * <li><b>SDO_ORDINATES:</b><code>(12,14)</code></li>
312:             * </ul>
313:             * <p>
314:             * SQL:</p>
315:             * <code><pre>
316:             * MDSYS.SDO_GEOMETRY(
317:             *   2001,
318:             *   NULL,
319:             *   MDSYS.SDO_POINT_TYPE(12, 14, NULL),
320:             *   NULL,
321:             *   NULL
322:             * )
323:             * </pre></code> 
324:             */
325:            protected Point createPoint() {
326:                Point point = gf.createPoint(coords(new double[] { 12, 14 }));
327:                return point;
328:            }
329:
330:            /**
331:             * LineString geometry for testing fixture.
332:             * <code><pre>
333:             *        +4,7
334:             *        |
335:             *        |
336:             *        |
337:             * 1,2+   +4,2
338:             *    \   /
339:             *  2,1+-+3,1
340:             * </pre></code>
341:             * <p>
342:             * Expected Encoding:</p>
343:             * <ul>
344:             * <li><b>SDO_GTYPE:</b><code>2002</code><br/>
345:             *     2 dimensional, 0 measures, 02 for Line
346:             *     </li>
347:             * <li><b>SDO_SRID:</b><code>NULL</code></li>
348:             * <li><b>SDO_POINT:</b><code>NULL</code></li>
349:             * <li><b>SDO_ELEM_INFO:</b><code>(1,2,5)</code></li>
350:             * <li><b>SDO_ORDINATES:</b><code>(1,2, 2,1, 3,1, 4,2 4,7)</code></li>
351:             * </ul>
352:             * <p>
353:             * SQL:</p>
354:             * <code><pre>
355:             * MDSYS.SDO_GEOMETRY(
356:             *   2002,
357:             *   NULL,
358:             *   NULL,
359:             *   (1,2,5),
360:             *   (1,2, 2,1, 3,1, 4,2 4,7)
361:             * )
362:             * </pre></code> 
363:             */
364:            protected LineString createLineString() {
365:                LineString lineString = gf
366:                        .createLineString(coords(new double[] { 1, 2, 2, 1, 3,
367:                                1, 4, 2, 4, 7 }));
368:                return lineString;
369:            }
370:
371:            /**
372:             * MultiPoint geometry for testing fixture.
373:             * <code><pre>
374:             * 
375:             *      5,5+
376:             * 
377:             *    3,3+
378:             * 
379:             *  2,2+
380:             * 1,1+
381:             * </pre></code>
382:             * <p>
383:             * Expected Encoding:</p>
384:             * <ul>
385:             * <li><b>SDO_GTYPE:</b><code>2004</code><br/>
386:             *     2 dimensional, 0 measures, 05 for MultiPoint
387:             *     </li>
388:             * <li><b>SDO_SRID:</b><code>NULL</code></li>
389:             * <li><b>SDO_POINT:</b><code>NULL</code></li>
390:             * <li><b>SDO_ELEM_INFO:</b><code>(1,1,4)</code></li>
391:             * <li><b>SDO_ORDINATES:</b><code>(1,1, 2,2, 3,3, 5,5)</code></li>
392:             * </ul>
393:             * <p>
394:             * SQL:</p>
395:             * <code><pre>
396:             * MDSYS.SDO_GEOMETRY(
397:             *   2005,
398:             *   NULL,
399:             *   NULL,
400:             *   (1,1,4),
401:             *   (1,1, 2,2, 3,3, 5,5)
402:             * )
403:             * </pre></code> 
404:             */
405:            protected MultiPoint createMultiPoint() {
406:                MultiPoint multiPoint = gf
407:                        .createMultiPoint(coords(new double[] { 1, 1, 2, 2, 3,
408:                                3, 5, 5 }));
409:                return multiPoint;
410:            }
411:
412:            /**
413:             * MultiLineString geometry for testing fixture.
414:             * <code><pre>
415:             *  2,7+==+==+5,7
416:             *        |4,7
417:             *        |
418:             *        |
419:             * 1,2+   +4,2
420:             *    \   /
421:             *  2,1+-+3,1
422:             * </pre></code>
423:             * <p>
424:             * Expected Encoding:</p>
425:             * <ul>
426:             * <li><b>SDO_GTYPE:</b><code>2005</code><br/>
427:             *     2 dimensional, 0 measures, 05 for MultiLine
428:             *     </li>
429:             * <li><b>SDO_SRID:</b><code>NULL</code></li>
430:             * <li><b>SDO_POINT:</b><code>NULL</code></li>
431:             * <li><b>SDO_ELEM_INFO:</b><code>(1,2,1,11,2,1)</code><br/>
432:             *     Two triplets
433:             *     <ul>
434:             *     <li>(1,2,1): linestring(2) of straight lines(1) starting at 1
435:             *         </li>
436:             *         
437:             *     <li>(11,2,1): linestring(2) of straight lines(1) starting at 1
438:             *         </li>
439:             *     </ul>
440:             *     </li>
441:             * <li><b>SDO_ORDINATES:</b><code>(1,2, 2,1, 3,1, 4,2 4,7,
442:             *                                 2,7, 4,7, 5,7)</code></li>
443:             * </ul>
444:             * <p>
445:             * SQL:</p>
446:             * <code><pre>
447:             * MDSYS.SDO_GEOMETRY(
448:             *   2005,
449:             *   NULL,
450:             *   NULL,
451:             *   (1,2,1,11,2,1),
452:             *   (1,2, 2,1, 3,1, 4,2 4,7, 2,7, 4,7, 5,7)
453:             * )
454:             * </pre></code> 
455:             */
456:            protected MultiLineString createMultiLineString() {
457:                LineString line1 = gf.createLineString(coords(new double[] { 1,
458:                        2, 2, 1, 3, 1, 4, 2, 4, 7 }));
459:                LineString line2 = gf.createLineString(coords(new double[] { 2,
460:                        7, 4, 7, 5, 7 }));
461:                MultiLineString multiLineString = gf
462:                        .createMultiLineString(new LineString[] { line1, line2 });
463:
464:                return multiLineString;
465:            }
466:
467:            /**
468:             * Construct a multipolyugon with a square and a triangle.
469:             * <p>
470:             * Used to illustrate multi polyugon encoding.</p>
471:             * <code><pre>
472:             * 
473:             * 2,9+------+7,9   
474:             *    |      |      +11,8
475:             *    |      |     / \
476:             *    |      |    /   \
477:             *    |      |9,5-----+13,5
478:             *    |      |
479:             * 2,3+------+7,3
480:             * </pre></code>
481:             * <p>
482:             * A MultiPolygon with expected encoding:</p>
483:             * <ul>
484:             * <li><b>SDO_GTYPE:</b><code>2006</code><br/>
485:             *     2 dimensional polygon, 6 for multi polygon
486:             *     </li>
487:             * <li><b>SDO_SRID:</b><code>NULL</code></li>
488:             * <li><b>SDO_POINT:</b>NULL></li>
489:             * <li><b>SDO_ELEM_INFO:</b><code>(1,1003,1,11,1003,1)</code><br/>
490:             *     Three triplets
491:             *     <ul>
492:             *     <li>(1,1003,1): exterior(1000) polygon(3) starting at 1 with
493:             *         straight edges(1)
494:             *         </li>
495:             *         
496:             *     <li>(11,1003,1): exterior(1000) polygon(3) starting at 11 with
497:             *         straight edges(1)
498:             *         </li>
499:             *     </ul>
500:             *     </li>
501:             * <li><b>SDO_ORDINATES:</b>
502:             *     <code><pre>
503:             *        (2,3, 7,3, 7,9, 2,9, 2,3,
504:             *         9,5, 13,5, 11,5, 9,5)
505:             *     </code><pre/>
506:             *     </li> 
507:             * </ul>
508:             * <p>
509:             * SQL:</p>
510:             * <code><pre>
511:             * MDSYS.SDO_GEOMETRY(
512:             *   2006,
513:             *   NULL,
514:             *   NULL,
515:             *   MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1, 11,1003,1),
516:             *   MDSYS.SDO_ORDINATE_ARRAY(2,3, 7,3, 7,9, 2,9, 2,3,
517:             *         9,5, 13,5, 11,5, 9,5)
518:             * )
519:             * </pre></code> 
520:             */
521:            protected MultiPolygon createMultiPolygon() {
522:                Polygon poly1 = gf.createPolygon(ring(new double[] { 2, 3, 7,
523:                        3, 7, 9, 2, 9, 2, 3 }), null);
524:                Polygon poly2 = gf.createPolygon(ring(new double[] { 9, 5, 13,
525:                        5, 11, 8, 9, 5 }), null);
526:                MultiPolygon multiPolygon = gf
527:                        .createMultiPolygon(new Polygon[] { poly1, poly2 });
528:                return multiPolygon;
529:            }
530:
531:            /**
532:             * Construct a multipolyugon with a square with a hole and a triangle.
533:             * <p>
534:             * Used to illustrate multi polyugon encoding.</p>
535:             * <code><pre>
536:             * 
537:             * 2,9+-------+7,9   
538:             *    |3,8 6,8|        +11,8
539:             *    | +---+ |      / \
540:             *    | |  /  |     /   \
541:             *    | | /   |    /     \
542:             *    | +     |9,5+-------+13,5
543:             *    |3,4    |
544:             * 2,3+-------+7,3
545:             * </pre></code>
546:             * <p>
547:             * A MultiPolygon with expected encoding:</p>
548:             * <ul>
549:             * <li><b>SDO_GTYPE:</b><code>2007</code><br/>
550:             *     2 dimensional, 6 for multipolygon
551:             *     </li>
552:             * <li><b>SDO_SRID:</b><code>0</code></li>
553:             * <li><b>SDO_POINT:</b>NULL></li>
554:             * <li><b>SDO_ELEM_INFO:</b><code>(1,1003,1,11,2003,1,19,1003,1)</code><br/>
555:             *     Two triplets
556:             *     <ul>
557:             *     <li>(1,1003,1): exterior(1000) polygon(3) starting at 1 with
558:             *         straight edges(1)
559:             *         <ul>
560:             *         <li>(1,2003,1): interior(2000) polygon(3) starting at 11 with
561:             *         straight edges(1)
562:             *             </li>
563:             *         </ul>
564:             *         </li>
565:             *         
566:             *     <li>(11,1003,1): exterior(1000) polygon(3) starting at 19 with
567:             *         straight edges(1)
568:             *         </li>
569:             *     </ul>
570:             *     </li>
571:             * <li><b>SDO_ORDINATES:</b>
572:             *     <code><pre>
573:             *        (2,3, 7,3, 7,9, 2,9, 2,3,
574:             *         3,4, 3,8, 6,8, 3,4,
575:             *         9,5, 13,5, 11,8, 9,5)
576:             *     </code><pre/>
577:             *     </li> 
578:             * </ul>
579:             * <p>
580:             * SQL:</p>
581:             * <code><pre>
582:             * MDSYS.SDO_GEOMETRY(
583:             *   2006,
584:             *   NULL,
585:             *   NULL,
586:             *   MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1,11,2003,1,19,1003,1),
587:             *   MDSYS.SDO_ORDINATE_ARRAY(2,3, 7,3, 7,9, 2,9, 2,3,
588:             *         3,4, 3,8, 6,8, 3,4, 
589:             *         9,5, 13,5, 11,8, 9,5)
590:             * )
591:             * </pre></code> 
592:             */
593:            protected MultiPolygon createMultiPolygonWithHole() {
594:                Polygon poly1 = gf.createPolygon(ring(new double[] { 2, 3, 7,
595:                        3, 7, 9, 2, 9, 2, 3 }),
596:                        new LinearRing[] { ring(new double[] { 3, 4, 6, 8, 3,
597:                                8, 3, 4 }), });
598:                Polygon poly2 = gf.createPolygon(ring(new double[] { 9, 5, 11,
599:                        8, 13, 5, 9, 5 }), null);
600:                MultiPolygon multiPolygon = gf
601:                        .createMultiPolygon(new Polygon[] { poly1, poly2 });
602:                return multiPolygon;
603:            }
604:
605:            /**
606:             * General Geometry Collection - with point, line, polygon, and a polygonWithHole.
607:             * <code><pre>
608:             *                          
609:             *                5,5+-------+9,5
610:             *                   |  +6,4/
611:             *                   | /|  /
612:             *                   |/ | / 
613:             *  2,3 +---+3,3  5,3+--+/6,3
614:             *      |2,2|        |  /
615:             * 1,2+ +---+3,2     | / 
616:             *     \             |/
617:             * 1,1+ +2,1      5,1+
618:             * </pre></code>
619:             * A GeometryCollection with expected encoding:</p>
620:             * <ul>
621:             * <li><b>SDO_GTYPE:</b><code>2004</code><br/>
622:             *     2000 dimensional polygon, 000 for no LRS, 4 for geometry collection
623:             *     </li>
624:             * <li><b>SDO_SRID:</b><code>0</code></li>
625:             * <li><b>SDO_POINT:</b>NULL></li>
626:             * <li><b>SDO_ELEM_INFO:</b>
627:             *     <code>(1,1,1, 3,2,1, 7,1003,1, 15,1003,1, 23,2003,1)</code><br/>
628:             *     Two triplets
629:             *     <ul>
630:             *     <li>(1,1,1): starting at 1, a point(1) (single(1))
631:             *         </li>
632:             *     <li>(3,2,1): starting at 3, a line(2) with straight segments(1)
633:             *         </li>
634:             *     <li>(7,1003,1): starting at 5, an exterior(1000), polygon(3)
635:             *         </li>
636:             * 
637:             *     <li>(15,1003,1, 23,2003,1) polygon with:
638:             *         <ul>
639:             *         <li>starting at 15 and exterior(1003) and straight edges 1
640:             *             </li>
641:             *         <li>starting at 23 and interior(2003) and straight edges 1
642:             *             </li>
643:             *         </ul>
644:             *         </li>
645:             *     </ul>
646:             * <li><b>SDO_ORDINATES:</b>
647:             *     <code><pre>
648:             *        (1,1,
649:             *         1,2, 2,1,
650:             *         2,2, 3,2, 3,3, 2,3, 2,2
651:             *         5,1, 5,5, 9,5, 5,1,
652:             *         5,3, 6,4, 6,3, 5,3)
653:             *     </code><pre/>
654:             *     </li> 
655:             * </ul>
656:             * <p>
657:             * SQL:</p>
658:             * <code><pre>
659:             * MDSYS.SDO_GEOMETRY(
660:             *   2004,
661:             *   NULL,
662:             *   NULL,
663:             *   MDSYS.SDO_ELEM_INFO_ARRAY(1,1,1, 3,2,1, 7,1003,1, 17,1003,1, 25,2003,1),
664:             *   MDSYS.SDO_ORDINATE_ARRAY(
665:             *         1,1,
666:             *         1,2, 2,1,
667:             *         2,2, 3,2, 3,3, 2,3, 2,2,
668:             *         5,1, 5,5, 9,5, 5,1,
669:             *         5,3, 6,4, 6,3, 5,3
670:             *   )
671:             * )
672:             * </pre></code> 
673:             */
674:            protected GeometryCollection createGeometryCollection() {
675:                return gf.createGeometryCollection(new Geometry[] {
676:                        gf.createPoint(coords(new double[] { 1, 1 })),
677:                        gf
678:                                .createLineString(coords(new double[] { 1, 2,
679:                                        2, 1 })),
680:                        gf.createPolygon(ring(new double[] { 2, 2, 3, 2, 3, 3,
681:                                2, 3, 2, 2 }), null),
682:                        gf.createPolygon(ring(new double[] { 5, 1, 9, 5, 5, 5,
683:                                5, 1 }), new LinearRing[] { ring(new double[] {
684:                                5, 3, 6, 4, 6, 3, 5, 3, }) }) });
685:            }
686:
687:            //
688:            // Utility Methods
689:            //
690:            protected LinearRing ring(double coords[]) {
691:                CoordinateSequence seq = coords(coords);
692:                return gf.createLinearRing(seq);
693:            }
694:
695:            protected CoordinateSequence coords(double coords[]) {
696:                Coordinate array[] = new Coordinate[coords.length / 2];
697:                for (int i = 0; i < array.length; i++) {
698:                    array[i] = new Coordinate(coords[i * 2], coords[i * 2 + 1]);
699:                }
700:                return gf.getCoordinateSequenceFactory().create(array);
701:            }
702:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.