Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_geometries / src / org / gvsig / fmap / geom / GeometryManager.java @ 40388

History | View | Annotate | Download (42.8 KB)

1
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib��ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.fmap.geom;
42

    
43
import java.awt.geom.PathIterator;
44
import java.util.List;
45

    
46
import org.gvsig.fmap.geom.aggregate.MultiCurve;
47
import org.gvsig.fmap.geom.aggregate.MultiSurface;
48
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
49
import org.gvsig.fmap.geom.exception.CreateGeometryException;
50
import org.gvsig.fmap.geom.operation.GeometryOperation;
51
import org.gvsig.fmap.geom.operation.GeometryOperationContext;
52
import org.gvsig.fmap.geom.operation.GeometryOperationException;
53
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
54
import org.gvsig.fmap.geom.primitive.Curve;
55
import org.gvsig.fmap.geom.primitive.Envelope;
56
import org.gvsig.fmap.geom.primitive.GeneralPathX;
57
import org.gvsig.fmap.geom.primitive.NullGeometry;
58
import org.gvsig.fmap.geom.primitive.Point;
59
import org.gvsig.fmap.geom.primitive.Surface;
60
import org.gvsig.fmap.geom.type.GeometryType;
61
import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException;
62
import org.gvsig.fmap.geom.type.GeometryTypeNotValidException;
63

    
64
/**
65
 * This singleton provides a centralized access to gvSIG's Geometry Model.
66
 * Its responsibilities are:<br>
67
 * 
68
 * <ul>
69
 * <li>Offering a set of convenient methods for registering and retrieving
70
 * geometry types.
71
 * <li>Offering a set of convenient methods for registering and retrieving
72
 * geometry operations associated to one or more geometry types.
73
 * <li>Offering a set of convenient methods for registering and retrieving new
74
 * geometries.
75
 * </ul>
76
 * 
77
 * @author jiyarza
78
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
79
 */
80
public interface GeometryManager {
81

    
82
    public interface OPERATIONS {
83

    
84
        public final static String FROMWKT = "FromWKT";
85
        public final static String FROMWKB = "FromWKB";
86
    }
87

    
88
    /**
89
     * <p>
90
     * Registers a GeometryOperation associated to a GeometryType. Returns an
91
     * unique index that is used later to identify and invoke the operation.
92
     * </p>
93
     * <p>
94
     * By convention this index should be in a final and static variable in the
95
     * class that implements the operation. The value of this variable must be
96
     * set using the method
97
     * {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
98
     * 
99
     * <pre>
100
     * 
101
     * public class MyOperation extends GeometryOperation {
102
     * 
103
     *     public static final int CODE = GeometryLocator.getGeometryManager()
104
     *         .getGeometryOperationCode(&quot;MyOperation&quot;);
105
     * }
106
     * </pre>
107
     * 
108
     * </p>
109
     * 
110
     * @param geomOpName
111
     *            Operation's unique name
112
     * @param geomOp
113
     *            Specific GeometryOperation's instance implementing this
114
     *            operation
115
     * @param geomType
116
     *            GeometryType instance to which this operation should be
117
     *            associated
118
     * @return Index assigned to this operation. This index is used later to
119
     *         access the operation.
120
     * 
121
     */
122
    public int registerGeometryOperation(String geomOpName,
123
        GeometryOperation geomOp, GeometryType geomType);
124

    
125
    /**
126
     * <p>
127
     * Registers a GeometryOperation that is common for all GeometryType
128
     * (registered yet or not). Returns an unique index that is used later to
129
     * identify and invoke the operation.
130
     * </p>
131
     * <p>
132
     * By convention this index should be in a final and static variable in the
133
     * class that implements the operation. The value of this variable must be
134
     * set using the method
135
     * {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
136
     * 
137
     * <pre>
138
     * 
139
     * public class MyOperation extends GeometryOperation {
140
     * 
141
     *     public static final int CODE = GeometryLocator.getGeometryManager()
142
     *         .getGeometryOperationCode(&quot;MyOperation&quot;);
143
     * }
144
     * </pre>
145
     * 
146
     * </p>
147
     * 
148
     * @param geomOpName
149
     *            Operation's unique name
150
     * @param geomOp
151
     *            Specific GeometryOperation's instance implementing this
152
     *            operation
153
     * @return Index assigned to this operation. This index is used later to
154
     *         access the operation.
155
     */
156
    public int registerGeometryOperation(String geomOpName,
157
        GeometryOperation geomOp);
158

    
159
    /**
160
     * <p>
161
     * Registers a GeometryOperation associated to a GeometryType, that has been
162
     * specified using the type code and the subtype code. Returns an unique
163
     * index that is used later to identify and invoke the operation.
164
     * </p>
165
     * <p>
166
     * By convention this index should be in a final and static variable in the
167
     * class that implements the operation. The value of this variable must be
168
     * set using the method
169
     * {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
170
     * 
171
     * <pre>
172
     * 
173
     * public class MyOperation extends GeometryOperation {
174
     * 
175
     *     public static final int CODE = GeometryLocator.getGeometryManager()
176
     *         .getGeometryOperationCode(&quot;MyOperation&quot;);
177
     * }
178
     * </pre>
179
     * 
180
     * </p>
181
     * <p>
182
     * This method is only used if you have not a reference to the GeometryType
183
     * associated to the geometry class. If you have such reference then it is
184
     * slightly faster to use the method that receives the GeometryType.<br>
185
     * </p>
186
     * 
187
     * @param geomOpName
188
     *            Operation's unique name
189
     * @param geomOp
190
     *            Specific GeometryOperation's instance implementing this
191
     *            operation
192
     * @param type
193
     *            Type of geometry. Must be a value defined in
194
     *            {@link Geometry.TYPES}
195
     * @param subType
196
     *            SubType of geometry. Must be a value defined in
197
     *            {@link Geometry.SUBTYPES}
198
     * @return Index assigned to this operation. This index is used later to
199
     *         access the operation.
200
     * @throws GeometryTypeNotSupportedException
201
     *             Returns this exception if there is not a registered geometry
202
     *             with
203
     *             these type and subtype
204
     * @throws GeometryTypeNotValidException
205
     *             Returns if the type and subtype are not valid
206
     */
207
    public int registerGeometryOperation(String geomOpName,
208
        GeometryOperation geomOp, int type, int subType)
209
        throws GeometryTypeNotSupportedException, GeometryTypeNotValidException;
210

    
211
    /**
212
     * <p>
213
     * Registers a GeometryOperation associated to all the geometries with a
214
     * concrete type. Returns an unique index that is used later to identify and
215
     * invoke the operation.<br>
216
     * </p>
217
     * <p>
218
     * By convention this index should be in a final and static variable in the
219
     * class that implements the operation. The value of this variable must be
220
     * set using the method
221
     * {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
222
     * 
223
     * <pre>
224
     * 
225
     * public class MyOperation extends GeometryOperation {
226
     * 
227
     *     public static final int CODE = GeometryLocator.getGeometryManager()
228
     *         .getGeometryOperationCode(&quot;MyOperation&quot;);
229
     * }
230
     * </pre>
231
     * 
232
     * </p>
233
     * 
234
     * @param geomOpName
235
     *            Operation's unique name
236
     * @param geomOp
237
     *            Specific GeometryOperation's instance implementing this
238
     *            operation
239
     * @param type
240
     *            Type of geometry. Must be a value defined in
241
     *            {@link Geometry.TYPES}
242
     * @return Index assigned to this operation. This index is used later to
243
     *         access the operation.
244
     */
245
    public int registerGeometryOperation(String geomOpName,
246
        GeometryOperation geomOp, int type);
247
    
248
    /**
249
     * <p>
250
     * Registers a GeometryOperation associated to all the geometries which
251
     * super type matches with a concrete type. Returns an unique index that 
252
     * is used later to identify and invoke the operation.<br>
253
     * </p>
254
     * <p>
255
     * By convention this index should be in a final and static variable in the
256
     * class that implements the operation. The value of this variable must be
257
     * set using the method
258
     * {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
259
     * 
260
     * <pre>
261
     * 
262
     * public class MyOperation extends GeometryOperation {
263
     * 
264
     *     public static final int CODE = GeometryLocator.getGeometryManager()
265
     *         .getGeometryOperationCode(&quot;MyOperation&quot;);
266
     * }
267
     * </pre>
268
     * 
269
     * </p>
270
     * 
271
     * @param geomOpName
272
     *            Operation's unique name
273
     * @param geomOp
274
     *            Specific GeometryOperation's instance implementing this
275
     *            operation
276
     * @param superType
277
     *            super type of geometries that is used to register
278
     *            the operation. Must be a value defined in
279
     *            {@link Geometry.TYPES}
280
     * @return Index assigned to this operation. This index is used later to
281
     *         access the operation.
282
     */
283
    public int registerGeometryOperationBySuperType(String geomOpName,
284
        GeometryOperation geomOp, int superType);
285
    
286
    /**
287
     * <p>
288
     * Registers a GeometryOperation associated to all the geometries which
289
     * super subType matches with a concrete subType. Returns an unique index that 
290
     * is used later to identify and invoke the operation.<br>
291
     * </p>
292
     * <p>
293
     * By convention this index should be in a final and static variable in the
294
     * class that implements the operation. The value of this variable must be
295
     * set using the method
296
     * {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
297
     * 
298
     * <pre>
299
     * 
300
     * public class MyOperation extends GeometryOperation {
301
     * 
302
     *     public static final int CODE = GeometryLocator.getGeometryManager()
303
     *         .getGeometryOperationCode(&quot;MyOperation&quot;);
304
     * }
305
     * </pre>
306
     * 
307
     * </p>
308
     * 
309
     * @param geomOpName
310
     *            Operation's unique name
311
     * @param geomOp
312
     *            Specific GeometryOperation's instance implementing this
313
     *            operation
314
     * @param superSubType
315
     *            super subType of geometries that is used to register
316
     *            the operation. Must be a value defined in
317
     *            {@link Geometry.SUBTYPES}
318
     * @return Index assigned to this operation. This index is used later to
319
     *         access the operation.
320
     */
321
    public int registerGeometryOperationBySuperSubType(String geomOpName,
322
        GeometryOperation geomOp, int superSubType);
323

    
324
    /**
325
     * <p>
326
     * Registers a GeometryOperation associated to all the geometries with a
327
     * concrete subtype. Returns an unique index that is used later to identify
328
     * and invoke the operation.<br>
329
     * </p>
330
     * <p>
331
     * By convention this index should be in a final and static variable in the
332
     * class that implements the operation. The value of this variable must be
333
     * set using the method
334
     * {@link GeometryManager#getGeometryOperationCode(String)}:<BR>
335
     * 
336
     * <pre>
337
     * 
338
     * public class MyOperation extends GeometryOperation {
339
     * 
340
     *     public static final int CODE = GeometryLocator.getGeometryManager()
341
     *         .getGeometryOperationCode(&quot;MyOperation&quot;);
342
     * }
343
     * </pre>
344
     * 
345
     * </p>
346
     * 
347
     * @param geomOpName
348
     *            Operation's unique name
349
     * @param geomOp
350
     *            Specific GeometryOperation's instance implementing this
351
     *            operation
352
     * @param subType
353
     *            SubType of geometry. Must be a value defined in
354
     *            {@link Geometry.SUBTYPES}
355
     * @return Index assigned to this operation. This index is used later to
356
     *         access the operation.
357
     */
358
    public int registerGeometryOperationBySubtype(String geomOpName,
359
        GeometryOperation geomOp, int subType);
360

    
361
    /**
362
     * <p>
363
     * Registers a GeometryType instance. 
364
     * </p>
365
     * 
366
     * @param geometryType
367
     *            A {@link GeometryType} instance to create {@link Geometry} objects
368
     */
369
    public void registerGeometryType(GeometryType geometryType);
370
    
371
    /**
372
     * <p>
373
     * Registers a Geometry implementation class with a predefined geometry type
374
     * and returns the associated GeometryType instance. Available predefined
375
     * types are defined in {@link Geometry.TYPES} and the subtypes are defined
376
     * in {@link Geometry.SUBTYPES}.
377
     * </p>
378
     * <p>
379
     * How to register a geometry class with a predefined type:
380
     * 
381
     * <pre>
382
     * 
383
     * GeometryType geomType = GeometryLocator.getGeometryManager()
384
     *     .registerBasicGeometryType(Point2D.class, &quot;Point2D&quot;, Geometry.TYPES.POINT,
385
     *         Geometry.SYBTYPES.GEOM2D);
386
     * </pre>
387
     * 
388
     * </p>
389
     * 
390
     * @param geomClass
391
     *            Geometry subclass. It must not be null and must implement
392
     *            Geometry, otherwise an exception
393
     *            is raised.
394
     * @param name
395
     *            Symbolic name for the geometry type, it can be null. If it is
396
     *            null then the symbolic name
397
     *            will be the simple class name.
398
     * @param type
399
     *            Type of geometry. Must be a value defined in
400
     *            {@link Geometry.TYPES}
401
     * @param subType
402
     *            SubType of geometry. Must be a value defined in
403
     *            {@link Geometry.SUBTYPES}
404
     * @return Instance of GeometryType associated to the Geometry
405
     *         implementation class
406
     *         geomClass
407
     * @throws IllegalArgumentException
408
     *             If geomClass is null or does not implement Geometry
409
     */
410
    public GeometryType registerGeometryType(Class geomClass, String name,
411
        int type, int subType);
412
    
413
    /**
414
     * <p>
415
     * Registers a Geometry implementation class with a predefined geometry type
416
     * and returns the associated GeometryType instance. Available predefined
417
     * types are defined in {@link Geometry.TYPES} and the subtypes are defined
418
     * in {@link Geometry.SUBTYPES}.    
419
     * </p>
420
     * <p>
421
     * It adds also the super type and the super subType of the geometry, that
422
     * can be used to check if the type (or the subtype) inherits of other 
423
     * type (or subType)
424
     * </p>
425
     * <p>
426
     * How to register a geometry class with a predefined type:
427
     * 
428
     * <pre>
429
     * 
430
     * GeometryType geomType = GeometryLocator.getGeometryManager()
431
     *     .registerBasicGeometryType(Arc3D.class, &quot;Arc3D&quot;, Geometry.TYPES.ARC,
432
     *         Geometry.SYBTYPES.GEOM3D, Geometry.TYPES.CURVE, Geometry.SYBTYPES.GEOM2D);
433
     * </pre>
434
     * 
435
     * </p>
436
     * 
437
     * @param geomClass
438
     *            Geometry subclass. It must not be null and must implement
439
     *            Geometry, otherwise an exception
440
     *            is raised.
441
     * @param name
442
     *            Symbolic name for the geometry type, it can be null. If it is
443
     *            null then the symbolic name
444
     *            will be the simple class name.
445
     * @param type
446
     *            Type of geometry. Must be a value defined in
447
     *            {@link Geometry.TYPES}
448
     * @param subType
449
     *            SubType of geometry. Must be a value defined in
450
     *            {@link Geometry.SUBTYPES}
451
     * @param superType
452
     *              Super type of a geometry. Must be a value defined in
453
     *            {@link Geometry.TYPES}
454
     * @param superSubType
455
     *             Super subType of a geometry. Must be a value defined in
456
     *            {@link Geometry.SUBTYPES}
457
     * @return Instance of GeometryType associated to the Geometry
458
     *         implementation class
459
     *         geomClass
460
     * @throws IllegalArgumentException
461
     *             If geomClass is null or does not implement Geometry
462
     */
463
    public GeometryType registerGeometryType(Class geomClass, String name,
464
        int type, int subType, int superType, int superSubType);
465
    
466
    /**
467
     * <p>
468
     * Registers a Geometry implementation class with a predefined geometry type
469
     * and returns the associated GeometryType instance. Available predefined
470
     * types are defined in {@link Geometry.TYPES} and the subtypes are defined
471
     * in {@link Geometry.SUBTYPES}.    
472
     * </p>
473
     * <p>
474
     * It adds also the super type of the geometry, that can be used to 
475
     * check if the type inherits of other type.
476
     * </p>
477
     * <p>
478
     * How to register a geometry class with a predefined type:
479
     * 
480
     * <pre>
481
     * 
482
     * GeometryType geomType = GeometryLocator.getGeometryManager()
483
     *     .registerBasicGeometryType(Arc3D.class, &quot;Arc3D&quot;, Geometry.TYPES.ARC,
484
     *         Geometry.SYBTYPES.GEOM3D, Geometry.TYPES.CURVE);
485
     * </pre>
486
     * 
487
     * </p>
488
     * 
489
     * @param geomClass
490
     *            Geometry subclass. It must not be null and must implement
491
     *            Geometry, otherwise an exception
492
     *            is raised.
493
     * @param name
494
     *            Symbolic name for the geometry type, it can be null. If it is
495
     *            null then the symbolic name
496
     *            will be the simple class name.
497
     * @param type
498
     *            Type of geometry. Must be a value defined in
499
     *            {@link Geometry.TYPES}
500
     * @param subType
501
     *            SubType of geometry. Must be a value defined in
502
     *            {@link Geometry.SUBTYPES}
503
     * @param superType
504
     *              Super type of a geometry. Must be a value defined in
505
     *            {@link Geometry.TYPES}   
506
     * @return Instance of GeometryType associated to the Geometry
507
     *         implementation class
508
     *         geomClass
509
     * @throws IllegalArgumentException
510
     *             If geomClass is null or does not implement Geometry
511
     */
512
    public GeometryType registerGeometryType(Class geomClass, String name,
513
        int type, int subType, int superType);
514
    
515
    /**
516
     * <p>
517
     * Registers a Geometry implementation class with a predefined geometry type
518
     * and returns the associated GeometryType instance. Available predefined
519
     * types are defined in {@link Geometry.TYPES} and the subtypes are defined
520
     * in {@link Geometry.SUBTYPES}.    
521
     * </p>
522
     * <p>
523
     * It adds also the super types and the super subTypes of the geometry, that
524
     * can be used to check if the type (or the subtype) inherits of other 
525
     * types (or subTypes)
526
     * </p>
527
     * <p>
528
     * How to register a geometry class with a predefined type:
529
     * 
530
     * <pre>
531
     * 
532
     * GeometryType geomType = GeometryLocator.getGeometryManager()
533
     *     .registerBasicGeometryType(Circle3DM.class, &quot;Circle3DM&quot;, Geometry.TYPES.CIRCLE,
534
     *         Geometry.SYBTYPES.GEOM3DM,
535
     *         new int[]{Geometry.TYPES.CURVE, Geometry.TYPES.GEOMETRY},
536
     *         new int[]{Geometry.SYBTYPES.GEOM2D, Geometry.SYBTYPES.GEOM3D});
537
     * </pre>
538
     * 
539
     * </p>
540
     * 
541
     * @param geomClass
542
     *            Geometry subclass. It must not be null and must implement
543
     *            Geometry, otherwise an exception
544
     *            is raised.
545
     * @param name
546
     *            Symbolic name for the geometry type, it can be null. If it is
547
     *            null then the symbolic name
548
     *            will be the simple class name.
549
     * @param type
550
     *            Type of geometry. Must be a value defined in
551
     *            {@link Geometry.TYPES}
552
     * @param subType
553
     *            SubType of geometry. Must be a value defined in
554
     *            {@link Geometry.SUBTYPES}
555
     * @param superTypes
556
     *              List of the super types of a geometry. Must be a value defined in
557
     *            {@link Geometry.TYPES}
558
     * @param superSubTypes
559
     *             List of the super subType of a geometry. Must be a value defined in
560
     *            {@link Geometry.SUBTYPES}
561
     * @return Instance of GeometryType associated to the Geometry
562
     *         implementation class
563
     *         geomClass
564
     * @throws IllegalArgumentException
565
     *             If geomClass is null or does not implement Geometry
566
     */
567
    public GeometryType registerGeometryType(Class geomClass, String name,
568
        int type, int subType, int[] superTypes, int superSubTypes[]);
569
    
570
    /**
571
     * <p>
572
     * Registers a Geometry implementation class with a predefined geometry type
573
     * and returns the associated GeometryType instance. Available predefined
574
     * types are defined in {@link Geometry.TYPES} and the subtypes are defined
575
     * in {@link Geometry.SUBTYPES}.    
576
     * </p>
577
     * <p>
578
     * It adds also the super types and the super subTypes of the geometry, that
579
     * can be used to check if the type inherits of other types.
580
     * </p>
581
     * <p>
582
     * How to register a geometry class with a predefined type:
583
     * 
584
     * <pre>
585
     * 
586
     * GeometryType geomType = GeometryLocator.getGeometryManager()
587
     *     .registerBasicGeometryType(Circle2D.class, &quot;Circle2DM&quot;, Geometry.TYPES.CIRCLE,
588
     *         Geometry.SYBTYPES.GEOM2D,
589
     *         new int[]{Geometry.TYPES.CURVE, Geometry.TYPES.SURFACE});        
590
     * </pre>
591
     * 
592
     * </p>
593
     * 
594
     * @param geomClass
595
     *            Geometry subclass. It must not be null and must implement
596
     *            Geometry, otherwise an exception
597
     *            is raised.
598
     * @param name
599
     *            Symbolic name for the geometry type, it can be null. If it is
600
     *            null then the symbolic name
601
     *            will be the simple class name.
602
     * @param type
603
     *            Type of geometry. Must be a value defined in
604
     *            {@link Geometry.TYPES}
605
     * @param subType
606
     *            SubType of geometry. Must be a value defined in
607
     *            {@link Geometry.SUBTYPES}
608
     * @param superTypes
609
     *              List of the super types of a geometry. Must be a value defined in
610
     *            {@link Geometry.TYPES}
611
     * @return Instance of GeometryType associated to the Geometry
612
     *         implementation class
613
     *         geomClass
614
     * @throws IllegalArgumentException
615
     *             If geomClass is null or does not implement Geometry
616
     */
617
    public GeometryType registerGeometryType(Class geomClass, String name,
618
        int type, int subType, int[] superTypes);
619

    
620
    /**
621
     * <p>
622
     * Registers a Geometry implementation class with a predefined geometry type
623
     * and returns the associated GeometryType instance. Available predefined
624
     * types are defined in {@link Geometry.TYPES} and the subtypes are defined
625
     * in {@link Geometry.SUBTYPES}.
626
     * </p>
627
     * <p>
628
     * In this case the symbolic name will be the geometry's simple class name
629
     * </p>
630
     * How to register a new geometry type:
631
     * 
632
     * <pre>
633
     * 
634
     * GeometryType geomType = GeometryLocator.getGeometryManager()
635
     *     .registerBasicGeometryType(Point2D.class, Geometry.TYPES.POINT,
636
     *         Geometry.SYBTYPES.GEOM2D);
637
     * </pre>
638
     * 
639
     * @param geomClass
640
     *            Geometry implementation class. It must not be null and must
641
     *            implement Geometry,
642
     *            otherwise an exception is thrown.
643
     * @param type
644
     *            Type of geometry. Must be a value defined in
645
     *            {@link Geometry.TYPES}
646
     * @param subType
647
     *            SubType of geometry. Must be a value defined in
648
     *            {@link Geometry.SUBTYPES}
649
     * @return Instance of GeometryType associated to the Geometry
650
     *         implementation class
651
     * @throws IllegalArgumentException
652
     *             If geomClass is null or does not implement Geometry
653
     */
654
    public GeometryType registerGeometryType(Class geomClass, int type,
655
        int subType);
656

    
657
    /**
658
     * <p>
659
     * Returns an instance of GeometryType given the Geometry type and the
660
     * subtype.
661
     * </p>
662
     * 
663
     * @param type
664
     *            Type of geometry. Must be a value defined in
665
     *            {@link Geometry.TYPES}
666
     * @param subType
667
     *            SubType of geometry. Must be a value defined in
668
     *            {@link Geometry.SUBTYPES}
669
     * @return Instance of GeometryType associated to the type and the subtype
670
     * @throws GeometryTypeNotSupportedException
671
     *             Returns this exception if there is not a registered geometry
672
     *             with
673
     *             these type and subtype
674
     * @throws GeometryTypeNotValidException
675
     *             Returns if the type and subtype are not valid
676
     */
677
    public GeometryType getGeometryType(int type, int subType)
678
        throws GeometryTypeNotSupportedException, GeometryTypeNotValidException;
679

    
680
    /**
681
     * <p>
682
     * This method creates a {@link Geometry} with the type specified by this
683
     * GeometryType. The geometry is empty, and all the internal attributes must
684
     * be assigned to a value when the geometry has been created.
685
     * </p>
686
     * <p>
687
     * This example creates a point2D and sets the coordinates to 1,1:
688
     * 
689
     * <pre>
690
     * Point point =
691
     *     (Point) GeometryLocator.getGeometryManager().create(GEOMETRY.TYPES.POINT,
692
     *         GEOMETRY.SUBTYPES.GEOM2D);
693
     * point.setX(1);
694
     * point.setY(1);
695
     * </pre>
696
     * 
697
     * </p>
698
     * 
699
     * @param geomType
700
     *            The geometry type
701
     * @return
702
     *         A instance of a geometry.
703
     * @throws CreateGeometryException
704
     *             This exception is thrown when the manager can not create
705
     *             the geometry.
706
     */
707
    public Geometry create(GeometryType geomType)
708
        throws CreateGeometryException;
709

    
710
    /**
711
     * <p>
712
     * Creates a Envelope with a concrete subtype. The envelope is empty and it
713
     * have to be filled with the corners once has been created.
714
     * </p>
715
     * 
716
     * @param subType
717
     *            SubType of envelope. Must be a value defined in
718
     *            {@link Geometry.SUBTYPES}
719
     * @return
720
     *         A Envelope
721
     * @throws CreateEnvelopeException
722
     *             If it is not possible to create the envelope.
723
     */
724
    public Envelope createEnvelope(int subType) throws CreateEnvelopeException;
725

    
726
    /**
727
     * <p>
728
     * Creates a Envelope with a concrete subtype. It sets the values for the
729
     * lower corner and the upper corner (in 2D) using the method parameters.
730
     * </p>
731
     * 
732
     * @param minX
733
     *            The minimum value for the X coordinate.
734
     * @param minY
735
     *            The minimum value for the Y coordinate.
736
     * @param maxX
737
     *            The maximum value for the X coordinate.
738
     * @param maxY
739
     *            The maximum value for the Y coordinate.
740
     * @param subType
741
     *            SubType of envelope. Must be a value defined in
742
     *            {@link Geometry.SUBTYPES}
743
     * @return
744
     * @throws CreateEnvelopeException
745
     */
746
    public Envelope createEnvelope(double minX, double minY, double maxX,
747
        double maxY, int subType) throws CreateEnvelopeException;
748

    
749
    /**
750
     * <p>
751
     * This method creates a {@link Geometry} with the type specified by this
752
     * name. If a geometry with this name doesn't exist, a
753
     * {@link IllegalArgumentException} is thrown. The geometry is empty, and
754
     * all the internal attributes must be assigned to a value when the geometry
755
     * has been created.
756
     * </p>
757
     * <p>
758
     * This example creates a point2D and sets the coordinates to 1,1: It
759
     * supposes that there is a Point2D class with name "Point2D".
760
     * </p>
761
     * 
762
     * <pre>
763
     * Point point = (Point) GeometryLocator.getGeometryManager().create(&quot;Point2D&quot;);
764
     * point.setX(1);
765
     * point.setY(1);
766
     * </pre>
767
     * 
768
     * @param name
769
     *            The name of the geometry type
770
     * @return
771
     *         A instance of a geometry.
772
     * @throws CreateGeometryException
773
     *             This exception is thrown when the manager can not create
774
     *             the geometry.
775
     */
776
    public Geometry create(String name) throws CreateGeometryException;
777

    
778
    /**
779
     * Create a geometry from a WKT definition.
780
     * 
781
     * This is a utility method to wrap the invocation to the operation
782
     * {@link OPERATIONS#FROMWKT}.
783
     * 
784
     * @param wkt
785
     *            geometry in Well-known text format
786
     * 
787
     * @return the geometry as a Geometry
788
     * 
789
     * @throws CreateGeometryException
790
     * @throws GeometryException
791
     */
792
    public Geometry createFrom(String wkt, String srs)
793
        throws CreateGeometryException, GeometryException;
794

    
795
    public Geometry createFrom(String wkt) throws CreateGeometryException,
796
        GeometryException;
797

    
798
    /**
799
     * Create a geometry from a WKB definition.
800
     * 
801
     * This is a utility method to wrap the invocation to the operation
802
     * {@link OPERATIONS#FROMWKB}.
803
     * 
804
     * @param wkb
805
     *            geometry in well-known binary format
806
     * 
807
     * @return the geometry as a Geometry
808
     * 
809
     * @throws CreateGeometryException
810
     * @throws GeometryException
811
     */
812
    public Geometry createFrom(byte[] wkb) throws CreateGeometryException,
813
        GeometryException;
814

    
815
    /**
816
     * <p>
817
     * This method creates a {@link Geometry} with a concrete type and subtype.
818
     * The geometry is empty, and all the internal attributes must be assigned
819
     * to a value when the geometry has been created.
820
     * </p>
821
     * <p>
822
     * This example creates a point2D and sets the coordinates to 1,1. It
823
     * supposes that there is a Point2D class with the id 1.
824
     * </p>
825
     * 
826
     * <pre>
827
     * Point point =
828
     *     (Point) GeometryLocator.getGeometryManager().create(Geometry.TYPES.POINT,
829
     *         Geometry.SYBTYPES.GEOM2D);
830
     * point.setX(1);
831
     * point.setY(1);
832
     * </pre>
833
     * 
834
     * @param type
835
     *            Type of geometry. Must be a value defined in
836
     *            {@link Geometry.TYPES}
837
     * @param subType
838
     *            SubType of geometry. Must be a value defined in
839
     *            {@link Geometry.SUBTYPES}
840
     * @return
841
     *         A instance of a geometry.
842
     * @throws CreateGeometryException
843
     *             This exception is thrown when the manager can not create
844
     *             the geometry.
845
     */
846
    public Geometry create(int type, int subType)
847
        throws CreateGeometryException;
848

    
849
    /**
850
     * <p>
851
     * It creates a null geometry with a concrete subtype.
852
     * <p>
853
     * 
854
     * @param subType
855
     *            SubType of geometry. Must be a value defined in
856
     *            {@link Geometry.SUBTYPES}
857
     * @return
858
     *         A NullGeometry
859
     * @throws CreateGeometryException
860
     *             This exception is thrown when the manager can not create
861
     *             the geometry.
862
     */
863
    public NullGeometry createNullGeometry(int subType)
864
        throws CreateGeometryException;
865

    
866
    /**
867
     * <p>
868
     * Create a new point with a concrete type and sets the value for the X and
869
     * the Y.
870
     * </p>
871
     * 
872
     * @param x
873
     *            The X coordinate
874
     * @param y
875
     *            The y coordinate
876
     * @param subType
877
     *            SubType of geometry. Must be a value defined in
878
     *            {@link Geometry.SUBTYPES}
879
     * @throws CreateGeometryException
880
     *             This exception is thrown when the manager can not create
881
     *             the geometry.
882
     * @return
883
     *         The Point
884
     */
885
    public Point createPoint(double x, double y, int subType)
886
        throws CreateGeometryException;
887

    
888
    /**
889
     * <p>
890
     * Create a new curve with a concrete type and sets the value for the
891
     * coordinates using a GeneralPathX.
892
     * </p>
893
     * 
894
     * @param generalPathX
895
     *            It is used to set the values for the X and Y coordinates.
896
     * @param subType
897
     *            SubType of geometry. Must be a value defined in
898
     *            {@link Geometry.SUBTYPES}
899
     * @return
900
     *         A curve
901
     * @throws CreateGeometryException
902
     *             This exception is thrown when the manager can not create
903
     *             the geometry.
904
     */
905
    public Curve createCurve(GeneralPathX generalPathX, int subType)
906
        throws CreateGeometryException;
907

    
908
    /**
909
     * <p>
910
     * Create a new multicurve with a concrete type and sets the value for the
911
     * coordinates using a GeneralPathX.
912
     * </p>
913
     * 
914
     * @param generalPathX
915
     *            It is used to set the values for the X and Y coordinates.
916
     * @param subType
917
     *            SubType of geometry. Must be a value defined in
918
     *            {@link Geometry.SUBTYPES}
919
     * @return A multicurve
920
     * @throws CreateGeometryException
921
     *             This exception is thrown when the manager can not create the
922
     *             geometry.
923
     */
924
    public MultiCurve createMultiCurve(GeneralPathX generalPathX, int subType)
925
        throws CreateGeometryException;
926

    
927
    /**
928
     * <p>
929
     * Create a new surface with a concrete type and sets the value for the
930
     * coordinates using a GeneralPathX.
931
     * </p>
932
     * 
933
     * @param generalPathX
934
     *            It is used to set the values for the X and Y coordinates.
935
     * @param subType
936
     *            SubType of geometry. Must be a value defined in
937
     *            {@link Geometry.SUBTYPES}
938
     * @return
939
     *         A surface
940
     * @throws CreateGeometryException
941
     *             This exception is thrown when the manager can not create
942
     *             the geometry.
943
     */
944
    public Surface createSurface(GeneralPathX generalPathX, int subType)
945
        throws CreateGeometryException;
946

    
947
    /**
948
     * <p>
949
     * Create a new multisurface with a concrete type and sets the value for the
950
     * coordinates using a GeneralPathX.
951
     * </p>
952
     * 
953
     * @param generalPathX
954
     *            It is used to set the values for the X and Y coordinates.
955
     * @param subType
956
     *            SubType of geometry. Must be a value defined in
957
     *            {@link Geometry.SUBTYPES}
958
     * @return A multisurface
959
     * @throws CreateGeometryException
960
     *             This exception is thrown when the manager can not create the
961
     *             geometry.
962
     */
963
    public MultiSurface createMultiSurface(GeneralPathX generalPathX,
964
        int subType) throws CreateGeometryException;
965

    
966
    /**
967
     * <p>
968
     * Returns an operation given the Geometry type, the Geometry subtype and
969
     * and the operation code. If opCode corresponds to a common operation (a
970
     * common operation is an operation registered for all geometries), then
971
     * this method returns the common operation.
972
     * </p>
973
     * <p>
974
     * For better performance, if you need to call an operation multiple times,
975
     * use this method only once and keep the returned object in a local
976
     * variable over which you can iterate. For instance:
977
     * 
978
     * <pre>
979
     * // Get the operation you need
980
     * GeometryManager gm = GeometryLocator.getGeometryManager()
981
     * GeometryOperation geomOp = null;
982
     * try {
983
     *    geomOp = gm.getGeometryOperation(Draw2D.CODE, Geometry.TYPES.POINT, 
984
     *    Geometry.SUBTYPES.GEOM2D);
985
     * } catch (GeometryTypeNotSupportedException gtnse) {
986
     *    // treat exception
987
     * } catch (GeometryOperationNotSupportedException gonse) {
988
     *    // treat exception
989
     * }
990
     * 
991
     *  // Fill the operation context with required params
992
     * GeometryOperationContext ctx = new GeometryOperationContext();
993
     * 
994
     *  // Here is the main loop where you call the operation
995
     * for (int i=0; i<myGeometries.length; i++) {
996
     *    Object result = geomOp.invoke(myGeometries[i], ctx);
997
     * }
998
     * </pre>
999
     * 
1000
     * </p>
1001
     * 
1002
     * @param opCode
1003
     *            The operation code
1004
     * @param type
1005
     *            Type of geometry. Must be a value defined in
1006
     *            {@link Geometry.TYPES}
1007
     * @param subType
1008
     *            SubType of geometry. Must be a value defined in
1009
     *            {@link Geometry.SUBTYPES}
1010
     * @return Geometry operation
1011
     * @throws GeometryTypeNotSupportedException
1012
     *             Returns this exception if there is not a registered geometry
1013
     *             with
1014
     *             these type and subtype
1015
     * @throws GeometryTypeNotValidException
1016
     *             Returns this exception if the type and subtype are not valid
1017
     * @throws GeometryOperationNotSupportedException
1018
     *             Returns this exception if there is not a registered operation
1019
     *             with
1020
     *             this operation code
1021
     */
1022
    public GeometryOperation getGeometryOperation(int opCode, int type,
1023
        int subType) throws GeometryTypeNotSupportedException,
1024
        GeometryOperationNotSupportedException, GeometryTypeNotValidException;
1025

    
1026
    /**
1027
     * <p>
1028
     * Returns an common operation with given operation code. A common operation
1029
     * is an operation registered for all geometries.
1030
     * </p>
1031
     * <p>
1032
     * For better performance, if you need to call an operation multiple times,
1033
     * use this method only once and keep the returned object in a local
1034
     * variable over which you can iterate. For instance:
1035
     * 
1036
     * <pre>
1037
     * // Get the operation you need
1038
     * GeometryManager gm = GeometryLocator.getGeometryManager()
1039
     * GeometryOperation geomOp = null;
1040
     * try {
1041
     *    geomOp = gm.getGeometryOperation(FromWKB.CODE);
1042
     * } catch (GeometryOperationNotSupportedException gonse) {
1043
     *    // treat exception
1044
     * }
1045
     * 
1046
     *  // Fill the operation context with required params
1047
     * FromWKBGeometryOperationContext ctx = new FromWKBGeometryOperationContext();
1048
     * 
1049
     *  // Here is the main loop where you call the operation
1050
     * for (int i=0; i<myGeometriesWKB.length; i++) {
1051
     *    ctx.setData(myGeometriesWKB[i]);
1052
     *    Object result = geomOp.invoke(null, ctx);
1053
     * }
1054
     * </pre>
1055
     * 
1056
     * </p>
1057
     * 
1058
     * @param opCode
1059
     *            The operation code
1060
     * @return Geometry operation
1061
     * @throws GeometryOperationNotSupportedException
1062
     *             Returns this exception if there is not a registered operation
1063
     *             with
1064
     *             this operation code
1065
     */
1066
    public GeometryOperation getGeometryOperation(int opCode)
1067
        throws GeometryOperationNotSupportedException;
1068

    
1069
    /**
1070
     * <p>
1071
     * Invokes an operation given its code, the geometry and the operation
1072
     * context holding the parameters required for the operation.
1073
     * </p>
1074
     * 
1075
     * @param opCode
1076
     *            Operation code.
1077
     * @param geom
1078
     *            Geometry to which apply the operation
1079
     * @param ctx
1080
     *            Context holding the operation parameters
1081
     * @return
1082
     *         The object returned by an operation, depends on each operation.
1083
     */
1084
    public Object invokeOperation(int opCode, Geometry geom,
1085
        GeometryOperationContext ctx)
1086
        throws GeometryOperationNotSupportedException,
1087
        GeometryOperationException;
1088

    
1089
    /**
1090
     * <p>
1091
     * Invokes an operation given its code, the geometry and the operation
1092
     * context holding the parameters required for the operation.
1093
     * </p>
1094
     * 
1095
     * @param geomOpName
1096
     *            Operation name.
1097
     * @param geom
1098
     *            Geometry to which apply the operation
1099
     * @param ctx
1100
     *            Context holding the operation parameters
1101
     * @return
1102
     *         The object returned by an operation, depends on each operation.
1103
     */
1104
    public Object invokeOperation(String geomOpName, Geometry geom,
1105
        GeometryOperationContext ctx)
1106
        throws GeometryOperationNotSupportedException,
1107
        GeometryOperationException;
1108

    
1109
    /**
1110
     * <p>
1111
     * Invokes an operation given its code, and the operation context holding
1112
     * the parameters required for the operation.
1113
     * </p>
1114
     * 
1115
     * @param geomOpName
1116
     *            Operation name.
1117
     * @param ctx
1118
     *            Context holding the operation parameters
1119
     * @return
1120
     *         The object returned by an operation, depends on each operation.
1121
     */
1122
    public Object invokeOperation(String geomOpName,
1123
        GeometryOperationContext ctx)
1124
        throws GeometryOperationNotSupportedException,
1125
        GeometryOperationException;
1126

    
1127
    /**
1128
     * <p>
1129
     * Registers the unique name of one operation. If it already exists then
1130
     * this method does nothing but returning the name's corresponding index.
1131
     * </p>
1132
     * <p>
1133
     * By convention this method is used to set the value of the final and
1134
     * static variable that is located in the classes that implements the
1135
     * operation:<BR>
1136
     * 
1137
     * <pre>
1138
     * 
1139
     * public class MyOperation extends GeometryOperation {
1140
     * 
1141
     *     public static final int CODE = GeometryLocator.getGeometryManager()
1142
     *         .getGeometryOperationCode(&quot;MyOperation&quot;);
1143
     * }
1144
     * </pre>
1145
     * 
1146
     * </p>
1147
     * 
1148
     * @param geomOpName
1149
     *            Name used to register the geometry operation
1150
     * @return
1151
     *         Index assigned to the operation name passed as parameter
1152
     */
1153
    public int getGeometryOperationCode(String geomOpName);
1154

    
1155
    /**
1156
     * Returns a list with the name of the operations that have been
1157
     * registered.
1158
     * 
1159
     * @return
1160
     *         A list of the registered operations.
1161
     */
1162
    public List getGeometryOperationNames();
1163

    
1164
    /**
1165
     * Returns the flatness used to convert a curve is a set
1166
     * of points.
1167
     * 
1168
     * @return
1169
     *         The flatness.
1170
     */
1171
    public double getFlatness();
1172

    
1173
    /**
1174
     * Sets the application flatness.
1175
     * 
1176
     * @param flatness
1177
     *            The flatness to set
1178
     */
1179
    public void setFlatness(double flatness);
1180
    
1181
    /**
1182
     * Create a memory spatial index with the default implementation.
1183
     * 
1184
     * @return a new SpatialIndex
1185
     */
1186
    public SpatialIndex createDefaultMemorySpatialIndex() throws GeometryException;
1187
    
1188

    
1189
    /**
1190
     * 
1191
     * @param rule
1192
     * @param initialCapacity
1193
     * @param pathIterator , can be null
1194
     * @return a GeneralPathX
1195
     * @deprecated use method of Geometry to handle this
1196
     */
1197
    public GeneralPathX createGeneralPath(int rule, PathIterator pathIterator);}