Revision 42309 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/Geometry.java
Geometry.java | ||
---|---|---|
32 | 32 |
|
33 | 33 |
import org.cresques.cts.ICoordTrans; |
34 | 34 |
|
35 |
import org.gvsig.fmap.geom.aggregate.MultiLine; |
|
36 |
import org.gvsig.fmap.geom.aggregate.MultiPoint; |
|
37 |
import org.gvsig.fmap.geom.aggregate.MultiPolygon; |
|
35 | 38 |
import org.gvsig.fmap.geom.handler.Handler; |
36 | 39 |
import org.gvsig.fmap.geom.operation.GeometryOperationContext; |
37 | 40 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
... | ... | |
154 | 157 |
* NO DATA geometry. |
155 | 158 |
*/ |
156 | 159 |
public final static int NULL = 16; |
157 |
|
|
158 |
public final static int COMPLEX = 17; |
|
159 |
|
|
160 |
|
|
160 |
|
|
161 |
public final static int COMPLEX = 17; |
|
162 |
|
|
161 | 163 |
public final static int LINE = 18; |
162 |
|
|
164 |
|
|
163 | 165 |
public final static int POLYGON = 19; |
164 |
} |
|
165 | 166 |
|
167 |
public final static int RING = 20; |
|
168 |
|
|
169 |
public final static int MULTILINE = 21; |
|
170 |
|
|
171 |
public final static int MULTIPOLYGON = 22; |
|
172 |
|
|
173 |
public final static int CIRCUMFERENCE = 23; |
|
174 |
|
|
175 |
public final static int PERIELLIPSE = 24; |
|
176 |
|
|
177 |
public final static int FILLEDSPLINE = 25; |
|
178 |
|
|
179 |
} |
|
180 |
|
|
166 | 181 |
public interface DIMENSIONS { |
167 | 182 |
public final static int X = 0; |
168 | 183 |
public final static int Y = 1; |
... | ... | |
173 | 188 |
* The subtype of a geometry is related with the dimension of the geometry, |
174 | 189 |
* that is a combination between the spatial dimension (2D, 2ZD, 3D) and the |
175 | 190 |
* M coordinate or "measure". |
176 |
*
|
|
191 |
* |
|
177 | 192 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
178 | 193 |
*/ |
179 | 194 |
public interface SUBTYPES { |
... | ... | |
254 | 269 |
|
255 | 270 |
/** |
256 | 271 |
* True if the geoemtry are valid. |
257 |
*
|
|
272 |
* |
|
258 | 273 |
* @return true form valid geometries |
259 | 274 |
*/ |
260 | 275 |
public boolean isValid(); |
261 |
|
|
276 |
|
|
262 | 277 |
/** |
263 | 278 |
* Return the status code results of validate the geometry. |
264 |
*
|
|
279 |
* |
|
265 | 280 |
* @return validation code |
266 | 281 |
*/ |
267 | 282 |
public int getStatusCode(); |
268 | 283 |
|
269 | 284 |
/** |
270 | 285 |
* Return the nearest point to the problem when validate the geometry. |
271 |
*
|
|
286 |
* |
|
272 | 287 |
* If the geometry is valid, this return null. |
273 |
*
|
|
288 |
* |
|
274 | 289 |
* @return the nearest point to the problem or null. |
275 | 290 |
*/ |
276 | 291 |
public Point getProblemLocation(); |
277 | 292 |
|
278 | 293 |
/** |
279 | 294 |
* Return a human readable message explaining the cause of the problem. |
280 |
*
|
|
295 |
* |
|
281 | 296 |
* If the geometry is valid this is null. |
282 |
*
|
|
297 |
* |
|
283 | 298 |
* @return the message cause of the problem. |
284 | 299 |
*/ |
285 | 300 |
public String getMessage(); |
286 | 301 |
} |
287 |
|
|
302 |
|
|
288 | 303 |
public static int BEST = 0; |
289 | 304 |
/** |
290 | 305 |
* North. |
... | ... | |
336 | 351 |
* constant that identifies its type. By convention this value is stored in |
337 | 352 |
* a constant called .CODE within the geometry class, for instance: |
338 | 353 |
* Point2D.CODE. |
339 |
*
|
|
354 |
* |
|
340 | 355 |
* @return If this geometry is a predefined interface then one of |
341 | 356 |
* {@link Geometry.TYPES} or a runtime constant if it is an extended |
342 | 357 |
* type. |
... | ... | |
345 | 360 |
|
346 | 361 |
/** |
347 | 362 |
* Creates a clone of this geometry. |
348 |
*
|
|
363 |
* |
|
349 | 364 |
* @return A clone of this geometry. |
350 | 365 |
*/ |
351 | 366 |
public Geometry cloneGeometry(); |
... | ... | |
353 | 368 |
/** |
354 | 369 |
* Returns true if this geometry intersects the rectangle passed as |
355 | 370 |
* parameter. |
356 |
*
|
|
371 |
* |
|
357 | 372 |
* @param r |
358 | 373 |
* Rectangle. |
359 |
*
|
|
374 |
* |
|
360 | 375 |
* @return True, if <code>this</code> intersects <code>r</code>. |
361 | 376 |
*/ |
362 | 377 |
public boolean intersects(Rectangle2D r); |
... | ... | |
364 | 379 |
/** |
365 | 380 |
* Used by the drawing strategies to quickly test whether this geometry |
366 | 381 |
* intersects with the visible rectangle. |
367 |
*
|
|
382 |
* |
|
368 | 383 |
* @param x |
369 | 384 |
* The minimum X coordinate. |
370 | 385 |
* @param y |
... | ... | |
387 | 402 |
* one containing all the minimums for each ordinate, and second one |
388 | 403 |
* containing all the maximums. |
389 | 404 |
* </p> |
390 |
*
|
|
405 |
* |
|
391 | 406 |
* @return The minimum bounding box for this Geometry. |
392 | 407 |
*/ |
393 | 408 |
public Envelope getEnvelope(); |
... | ... | |
395 | 410 |
/** |
396 | 411 |
* Reprojects this geometry by the coordinate transformer passed as |
397 | 412 |
* parameter. |
398 |
*
|
|
413 |
* |
|
399 | 414 |
* @param ct |
400 | 415 |
* Coordinate Transformer. |
401 | 416 |
*/ |
... | ... | |
406 | 421 |
* If parameter value is null, it will be considered an |
407 | 422 |
* empty transformation, therefore equivalent to the identity |
408 | 423 |
* transformation. |
409 |
*
|
|
424 |
* |
|
410 | 425 |
* @param at |
411 | 426 |
* The transformation to apply. |
412 | 427 |
*/ |
... | ... | |
416 | 431 |
* geometric set can be associated with a subset that has the direct |
417 | 432 |
* position in its interior and is similar (isomorphic) to Rn, Euclidean |
418 | 433 |
* n-space. |
419 |
*
|
|
434 |
* |
|
420 | 435 |
* @return The dimension. |
421 | 436 |
*/ |
422 | 437 |
public int getDimension(); |
... | ... | |
427 | 442 |
* means that every point in the interior of the object must have a metric |
428 | 443 |
* neighborhood whose intersection with the object is isomorphic to an |
429 | 444 |
* n-sphere, where n is the dimension of this Geometry. |
430 |
*
|
|
445 |
* |
|
431 | 446 |
* @return If the geometry is simple. |
432 | 447 |
*/ |
433 | 448 |
public boolean isSimple(); |
... | ... | |
438 | 453 |
|
439 | 454 |
/** |
440 | 455 |
* Invokes a geometry operation given its index and context. |
441 |
*
|
|
456 |
* |
|
442 | 457 |
* @param index |
443 | 458 |
* Unique index of the operation. Operation code. |
444 | 459 |
* @param ctx |
... | ... | |
456 | 471 |
|
457 | 472 |
/** |
458 | 473 |
* Invokes a geometry operation given its name and context. |
459 |
*
|
|
474 |
* |
|
460 | 475 |
* @param opName |
461 | 476 |
* Operation name. |
462 | 477 |
* @param ctx |
... | ... | |
474 | 489 |
|
475 | 490 |
/** |
476 | 491 |
* Instance of the GeometryType associated to this geometry. |
477 |
*
|
|
492 |
* |
|
478 | 493 |
* @return The geometry type. |
479 | 494 |
*/ |
480 | 495 |
public GeometryType getGeometryType(); |
481 | 496 |
|
482 | 497 |
/** |
483 | 498 |
* Return a byte array with the equivalent in WKB format of the Geometry. |
484 |
*
|
|
499 |
* |
|
485 | 500 |
* Utility method to wrap the invocation to the operation |
486 | 501 |
* {@link OPERATIONS#CONVERTTOWKB}. |
487 |
*
|
|
502 |
* |
|
488 | 503 |
* @return the WKB version of the geometry |
489 | 504 |
*/ |
490 | 505 |
public byte[] convertToWKB() throws GeometryOperationNotSupportedException, |
491 | 506 |
GeometryOperationException; |
492 | 507 |
|
493 |
public byte[] convertToWKB(int srs)
|
|
508 |
public byte[] convertToWKB(int srs) |
|
494 | 509 |
throws GeometryOperationNotSupportedException, GeometryOperationException; |
495 |
|
|
496 |
public byte[] convertToWKBForcingType(int srs, int type)
|
|
510 |
|
|
511 |
public byte[] convertToWKBForcingType(int srs, int type) |
|
497 | 512 |
throws GeometryOperationNotSupportedException, GeometryOperationException; |
498 | 513 |
|
499 | 514 |
/** |
500 | 515 |
* Return a string with the equivalent in WKT format of the Geometry. |
501 |
*
|
|
516 |
* |
|
502 | 517 |
* This is a utility method to wrap the invocation to the operation |
503 | 518 |
* {@link OPERATIONS#CONVERTTOWKT}. |
504 |
*
|
|
519 |
* |
|
505 | 520 |
* @return the WKT version of the geometry. |
506 |
*
|
|
521 |
* |
|
507 | 522 |
* @throws GeometryOperationNotSupportedException |
508 | 523 |
* @throws GeometryOperationException |
509 | 524 |
*/ |
... | ... | |
512 | 527 |
|
513 | 528 |
/** |
514 | 529 |
* Computes a buffer area around this geometry having the given width |
515 |
*
|
|
530 |
* |
|
516 | 531 |
* This is a utility method to wrap the invocation to the operation |
517 | 532 |
* {@link OPERATIONS#BUFFER}. |
518 |
*
|
|
533 |
* |
|
519 | 534 |
* @param distance |
520 | 535 |
* the width of the buffer |
521 |
*
|
|
536 |
* |
|
522 | 537 |
* @return a new Geometry with the computed buffer. |
523 |
*
|
|
538 |
* |
|
524 | 539 |
* @throws GeometryOperationNotSupportedException |
525 | 540 |
* @throws GeometryOperationException |
526 | 541 |
*/ |
... | ... | |
530 | 545 |
|
531 | 546 |
/** |
532 | 547 |
* Tests whether this geometry contains the specified geometry. |
533 |
*
|
|
548 |
* |
|
534 | 549 |
* This is a utility method to wrap the invocation to the operation |
535 | 550 |
* {@link OPERATIONS#CONTAINS}. |
536 |
*
|
|
551 |
* |
|
537 | 552 |
* @param geometry |
538 | 553 |
* the Geometry with which to compare this Geometry |
539 |
*
|
|
554 |
* |
|
540 | 555 |
* @return if this Geometry contains the specified geometry |
541 |
*
|
|
556 |
* |
|
542 | 557 |
* @throws GeometryOperationNotSupportedException |
543 | 558 |
* @throws GeometryOperationException |
544 | 559 |
*/ |
... | ... | |
549 | 564 |
/** |
550 | 565 |
* Returns the minimum distance between this Geometry and the specified |
551 | 566 |
* geometry. |
552 |
*
|
|
567 |
* |
|
553 | 568 |
* This is a utility method to wrap the invocation to the operation |
554 | 569 |
* {@link OPERATIONS#DISTANCE}. |
555 |
*
|
|
570 |
* |
|
556 | 571 |
* @param geometry |
557 | 572 |
* the Geometry from which to compute the distance |
558 |
*
|
|
573 |
* |
|
559 | 574 |
* @return the distance between the geometries |
560 |
*
|
|
575 |
* |
|
561 | 576 |
* @throws GeometryOperationNotSupportedException |
562 | 577 |
* @throws GeometryOperationException |
563 | 578 |
*/ |
... | ... | |
568 | 583 |
public Geometry[] closestPoints(Geometry other) |
569 | 584 |
throws GeometryOperationNotSupportedException, |
570 | 585 |
GeometryOperationException; |
571 |
|
|
572 |
boolean isWithinDistance(Geometry other, double distance)
|
|
586 |
|
|
587 |
boolean isWithinDistance(Geometry other, double distance) |
|
573 | 588 |
throws GeometryOperationNotSupportedException, |
574 | 589 |
GeometryOperationException; |
575 | 590 |
|
576 | 591 |
/** |
577 | 592 |
* Tests whether this geometry overlaps the specified geometry. |
578 |
*
|
|
593 |
* |
|
579 | 594 |
* This is a utility method to wrap the invocation to the operation |
580 | 595 |
* {@link OPERATIONS#OVERLAPS}. |
581 |
*
|
|
596 |
* |
|
582 | 597 |
* @param geometry |
583 | 598 |
* the Geometry with which to compare this Geometry |
584 |
*
|
|
599 |
* |
|
585 | 600 |
* @return true if the two geometries overlap. |
586 |
*
|
|
601 |
* |
|
587 | 602 |
* @throws GeometryOperationNotSupportedException |
588 | 603 |
* @throws GeometryOperationException |
589 | 604 |
*/ |
... | ... | |
597 | 612 |
public boolean coveredBy(Geometry geometry) |
598 | 613 |
throws GeometryOperationNotSupportedException, |
599 | 614 |
GeometryOperationException; |
600 |
|
|
615 |
|
|
601 | 616 |
public boolean covers(Geometry geometry) |
602 | 617 |
throws GeometryOperationNotSupportedException, |
603 | 618 |
GeometryOperationException; |
604 |
|
|
619 |
|
|
605 | 620 |
public boolean crosses(Geometry geometry) |
606 | 621 |
throws GeometryOperationNotSupportedException, |
607 | 622 |
GeometryOperationException; |
... | ... | |
625 | 640 |
public Geometry snapTo(Geometry other, double snapTolerance) |
626 | 641 |
throws GeometryOperationNotSupportedException, |
627 | 642 |
GeometryOperationException; |
628 |
|
|
643 |
|
|
629 | 644 |
public boolean touches(Geometry geometry) |
630 | 645 |
throws GeometryOperationNotSupportedException, |
631 | 646 |
GeometryOperationException; |
... | ... | |
639 | 654 |
GeometryOperationException; |
640 | 655 |
|
641 | 656 |
public Point centroid() throws GeometryOperationNotSupportedException, GeometryOperationException; |
642 |
|
|
657 |
|
|
643 | 658 |
/** |
644 | 659 |
* This method returns a point which is inside the geometry. |
645 | 660 |
* This is useful for mathematical purposes but it is very unlikely |
646 | 661 |
* to be a suitable place for a label, for example. |
647 |
*
|
|
648 |
*
|
|
662 |
* |
|
663 |
* |
|
649 | 664 |
* @return an interior point |
650 | 665 |
* @throws GeometryOperationNotSupportedException |
651 | 666 |
* @throws GeometryOperationException |
... | ... | |
653 | 668 |
public Point getInteriorPoint() throws GeometryOperationNotSupportedException, GeometryOperationException; |
654 | 669 |
|
655 | 670 |
public double area() throws GeometryOperationNotSupportedException, GeometryOperationException; |
656 |
|
|
671 |
|
|
657 | 672 |
public double perimeter() throws GeometryOperationNotSupportedException, GeometryOperationException; |
658 | 673 |
|
659 |
|
|
660 |
|
|
661 |
|
|
674 |
|
|
675 |
|
|
676 |
|
|
662 | 677 |
/** |
663 | 678 |
* Rotates the geometry by radAngle radians using the given |
664 | 679 |
* coordinates as center of rotation. Rotating with a positive |
... | ... | |
666 | 681 |
* positive y axis. In most cases, we assume x increases |
667 | 682 |
* rightwards and y increases upwards, so in most cases, |
668 | 683 |
* a positive angle will mean counter-clockwise rotation. |
669 |
*
|
|
684 |
* |
|
670 | 685 |
* @param radAngle the amount of rotation, in radians |
671 | 686 |
* @param basex x coordinate of center of rotation |
672 | 687 |
* @param basey y coordinate of center of rotation |
673 | 688 |
*/ |
674 | 689 |
public void rotate(double radAngle, double basex, double basey); |
675 |
|
|
690 |
|
|
676 | 691 |
/** |
677 | 692 |
* Shifts geometry by given amount in x and y axes |
678 |
*
|
|
679 |
* @param dx
|
|
693 |
* |
|
694 |
* @param dx |
|
680 | 695 |
* @param dy |
681 | 696 |
*/ |
682 | 697 |
public void move(double dx, double dy); |
683 |
|
|
684 |
|
|
698 |
|
|
699 |
|
|
685 | 700 |
/** |
686 | 701 |
* Scales geometry in x and y axes by given scale factors |
687 | 702 |
* using the given point as center of projection. |
688 |
*
|
|
703 |
* |
|
689 | 704 |
* @param basePoint |
690 | 705 |
* @param sx scale factor in x axis |
691 | 706 |
* @param sy scale factor in y axis |
692 | 707 |
*/ |
693 | 708 |
public void scale(Point basePoint, double sx, double sy); |
694 |
|
|
709 |
|
|
695 | 710 |
/** |
696 | 711 |
* Check if the geometry is valid. |
697 |
*
|
|
712 |
* |
|
698 | 713 |
* @return true if the geometry is valid. |
699 | 714 |
*/ |
700 | 715 |
public boolean isValid(); |
701 |
|
|
716 |
|
|
702 | 717 |
/** |
703 | 718 |
* Check if the geometry is valid and returns the validation status. |
704 |
*
|
|
705 |
* @return the ValidationStatus
|
|
719 |
* |
|
720 |
* @return the ValidationStatus |
|
706 | 721 |
*/ |
707 | 722 |
public ValidationStatus getValidationStatus(); |
708 | 723 |
|
... | ... | |
710 | 725 |
* Try to fix the geometry and return the new geometry. |
711 | 726 |
* If the geometry is valid return the same geometry. |
712 | 727 |
* If the geometry is corrupt or can't fix it, return null. |
713 |
*
|
|
728 |
* |
|
714 | 729 |
* @return the new fixed geometry |
715 | 730 |
*/ |
716 | 731 |
public Geometry makeValid(); |
717 |
|
|
732 |
|
|
718 | 733 |
// |
719 | 734 |
// =============================================== |
720 | 735 |
// |
721 |
|
|
722 |
|
|
736 |
|
|
737 |
|
|
723 | 738 |
/** |
724 |
* @return the awt shape used to display the geometry. It
|
|
739 |
* @return the awt shape used to display the geometry. It |
|
725 | 740 |
* applies a tranformation before to return the coordinates |
726 | 741 |
* of the shape |
727 | 742 |
* @deprecated this class inherits of {@link Shape} by historical |
... | ... | |
729 | 744 |
* the {@link Shape} class but it will removed in a future. |
730 | 745 |
*/ |
731 | 746 |
public Shape getShape(AffineTransform affineTransform); |
732 |
|
|
747 |
|
|
733 | 748 |
/** |
734 |
* @return the awt shape used to display the geometry.
|
|
749 |
* @return the awt shape used to display the geometry. |
|
735 | 750 |
* @deprecated this class inherits of {@link Shape} by historical |
736 | 751 |
* reasons. This method has been added just to control the usage of |
737 | 752 |
* the {@link Shape} class but it will removed in a future. |
... | ... | |
740 | 755 |
|
741 | 756 |
/** |
742 | 757 |
* Returns this geometry's boundary rectangle. |
743 |
*
|
|
758 |
* |
|
744 | 759 |
* @deprecated use getEnvelope. |
745 | 760 |
* @return Boundary rectangle. |
746 | 761 |
*/ |
... | ... | |
749 | 764 |
/** |
750 | 765 |
* If applies an affine transformation and returns the GeneralPathXIterator |
751 | 766 |
* with this geometry's information. |
752 |
*
|
|
767 |
* |
|
753 | 768 |
* @param at |
754 | 769 |
* The transformation to apply. |
755 | 770 |
* @return The GeneralPathXIterator with this geometry's information. |
756 | 771 |
* @deprecated don't use PathIterator over geometries, use instead specific API for each operation. If not has API for that operation let the project team. |
757 |
*
|
|
772 |
* |
|
758 | 773 |
*/ |
759 | 774 |
public PathIterator getPathIterator(AffineTransform at); |
760 | 775 |
|
761 | 776 |
/** |
762 | 777 |
* It returns the handlers of the geometry, these they can be of two types |
763 | 778 |
* is straightening and of selection. |
764 |
*
|
|
779 |
* |
|
765 | 780 |
* @param type |
766 | 781 |
* Type of handlers. |
767 |
*
|
|
782 |
* |
|
768 | 783 |
* @deprecated don't use Handlers over geometries, use instead specific API for each operation. If not has API for that operation let the project team. |
769 | 784 |
* @return The handlers. |
770 | 785 |
*/ |
... | ... | |
774 | 789 |
/** |
775 | 790 |
* If applies an affine transformation and returns the GeneralPathXIterator |
776 | 791 |
* with this geometry's information. |
777 |
*
|
|
792 |
* |
|
778 | 793 |
* @param at |
779 | 794 |
* The affine transformation. |
780 | 795 |
* @param flatness |
781 |
*
|
|
796 |
* |
|
782 | 797 |
* @return The GeneralPathXIterator with this geometry's information. |
783 | 798 |
* @deprecated don't use PathIterator over geometries, use instead specific API for each operation. If not has API for that operation let the project team. |
784 | 799 |
*/ |
... | ... | |
787 | 802 |
/** |
788 | 803 |
* Useful to have the real shape behind the scenes. May be uses to edit it |
789 | 804 |
* knowing it it is a Circle, Ellipse, etc. |
790 |
*
|
|
805 |
* |
|
791 | 806 |
* @return The awt shape |
792 | 807 |
* @deprecated |
793 | 808 |
*/ |
... | ... | |
796 | 811 |
|
797 | 812 |
/** |
798 | 813 |
* Get GeneralPathIterator, to do registered operations to it. |
799 |
*
|
|
814 |
* |
|
800 | 815 |
* @return The GeneralPathX. |
801 | 816 |
* @deprecated don't use GeneralPathX over geometries, use instead specific API for each operation. If not has API for that operation let the project team. |
802 | 817 |
*/ |
803 | 818 |
public GeneralPathX getGeneralPath(); |
804 | 819 |
|
820 |
|
|
821 |
/** |
|
822 |
* Converts the geometry to be points and makes with them a multiPoint |
|
823 |
* |
|
824 |
* @return MultiPoint |
|
825 |
* @throws GeometryException |
|
826 |
*/ |
|
827 |
public MultiPoint toPoints() throws GeometryException; |
|
828 |
|
|
829 |
/** |
|
830 |
* Converts the geometry to be lines and makes with them a multiLine |
|
831 |
* @return |
|
832 |
* @throws GeometryException |
|
833 |
*/ |
|
834 |
public MultiLine toLines() throws GeometryException; |
|
835 |
|
|
836 |
/** |
|
837 |
* Converts the geometry to be polygons and makes with them a multiPolygon |
|
838 |
* @return |
|
839 |
* @throws GeometryException |
|
840 |
*/ |
|
841 |
public MultiPolygon toPolygons() throws GeometryException; |
|
842 |
|
|
843 |
public void flip() throws GeometryOperationNotSupportedException, GeometryOperationException; |
|
844 |
|
|
845 |
public boolean ensureOrientation(boolean ccw) throws GeometryOperationNotSupportedException, GeometryOperationException; |
|
846 |
|
|
847 |
public boolean out(Geometry geometry) throws GeometryOperationNotSupportedException, GeometryOperationException; |
|
805 | 848 |
} |
Also available in: Unified diff