46 |
46 |
*/
|
47 |
47 |
package com.iver.cit.gvsig.fmap.core.v02;
|
48 |
48 |
|
|
49 |
import java.awt.Shape;
|
49 |
50 |
import java.awt.geom.AffineTransform;
|
|
51 |
import java.awt.geom.Area;
|
50 |
52 |
import java.awt.geom.NoninvertibleTransformException;
|
51 |
53 |
import java.awt.geom.PathIterator;
|
52 |
54 |
import java.awt.geom.Point2D;
|
... | ... | |
564 |
566 |
* @return DOCUMENT ME!
|
565 |
567 |
*
|
566 |
568 |
* @throws NoninvertibleTransformException DOCUMENT ME!
|
567 |
|
*/
|
|
569 |
*
|
568 |
570 |
private Coordinate[] toViewCoordinates(Coordinate[] modelCoordinates)
|
569 |
571 |
throws NoninvertibleTransformException {
|
570 |
572 |
Coordinate[] viewCoordinates = new Coordinate[modelCoordinates.length];
|
571 |
573 |
|
572 |
574 |
for (int i = 0; i < modelCoordinates.length; i++) {
|
573 |
|
FPoint2D point2D = toViewPoint(modelCoordinates[i]);
|
|
575 |
FPoint2D point2D = coordinate2FPoint2D(modelCoordinates[i]);
|
574 |
576 |
viewCoordinates[i] = new Coordinate(point2D.getX(), point2D.getY());
|
575 |
577 |
}
|
576 |
578 |
|
577 |
579 |
return viewCoordinates;
|
578 |
|
}
|
|
580 |
} */
|
579 |
581 |
|
580 |
582 |
/* private Shape toShape(GeometryCollection gc)
|
581 |
583 |
throws NoninvertibleTransformException {
|
... | ... | |
612 |
614 |
private static GeneralPathX toShape(LineString lineString)
|
613 |
615 |
throws NoninvertibleTransformException {
|
614 |
616 |
GeneralPathX shape = new GeneralPathX();
|
615 |
|
FPoint2D viewPoint = toViewPoint(lineString.getCoordinateN(0));
|
|
617 |
FPoint2D viewPoint = coordinate2FPoint2D(lineString.getCoordinateN(0));
|
616 |
618 |
shape.moveTo(viewPoint.getX(), viewPoint.getY());
|
617 |
619 |
|
618 |
620 |
for (int i = 1; i < lineString.getNumPoints(); i++) {
|
619 |
|
viewPoint = toViewPoint(lineString.getCoordinateN(i));
|
|
621 |
viewPoint = coordinate2FPoint2D(lineString.getCoordinateN(i));
|
620 |
622 |
shape.lineTo(viewPoint.getX(), viewPoint.getY());
|
621 |
623 |
}
|
622 |
624 |
|
... | ... | |
636 |
638 |
*/
|
637 |
639 |
private static FPoint2D toShape(Point point)
|
638 |
640 |
throws NoninvertibleTransformException {
|
639 |
|
FPoint2D viewPoint = toViewPoint(point.getCoordinate());
|
|
641 |
FPoint2D viewPoint = coordinate2FPoint2D(point.getCoordinate());
|
640 |
642 |
|
641 |
643 |
return viewPoint;
|
642 |
644 |
}
|
... | ... | |
661 |
663 |
*
|
662 |
664 |
* @return DOCUMENT ME!
|
663 |
665 |
*/
|
664 |
|
private static FPoint2D toViewPoint(Coordinate coord) {
|
|
666 |
private static FPoint2D coordinate2FPoint2D(Coordinate coord) {
|
665 |
667 |
return new FPoint2D(coord.x, coord.y); //,coord.z);
|
666 |
668 |
}
|
667 |
669 |
|
... | ... | |
895 |
897 |
* @param coordinates
|
896 |
898 |
* @return
|
897 |
899 |
*/
|
898 |
|
public static IGeometry gePolygon(Coordinate[] coordinates)
|
|
900 |
public static IGeometry getExteriorPolygon(Coordinate[] coordinates)
|
899 |
901 |
{
|
900 |
902 |
// isCCW = true => it's a hole
|
901 |
903 |
Coordinate[] vs=new Coordinate[coordinates.length];
|
... | ... | |
915 |
917 |
}
|
916 |
918 |
return null;
|
917 |
919 |
}
|
|
920 |
|
|
921 |
/**
|
|
922 |
* Return a hole (CCW ordered points)
|
|
923 |
* @param coordinates
|
|
924 |
* @return
|
|
925 |
*/
|
|
926 |
public static IGeometry getHole(Coordinate[] coordinates)
|
|
927 |
{
|
|
928 |
// isCCW = true => it's a hole
|
|
929 |
Coordinate[] vs=new Coordinate[coordinates.length];
|
|
930 |
if (CGAlgorithms.isCCW(coordinates)){
|
|
931 |
vs=coordinates;
|
|
932 |
|
|
933 |
}else{
|
|
934 |
for (int i=vs.length-1;i>=0;i--){
|
|
935 |
vs[i]=coordinates[i];
|
|
936 |
}
|
|
937 |
}
|
|
938 |
LinearRing ring = geomFactory.createLinearRing(vs);
|
|
939 |
|
|
940 |
try {
|
|
941 |
return ShapeFactory.createPolygon2D(toShape(ring));
|
|
942 |
} catch (NoninvertibleTransformException e) {
|
|
943 |
e.printStackTrace();
|
|
944 |
}
|
|
945 |
return null;
|
|
946 |
}
|
|
947 |
|
|
948 |
public static Shape getExteriorPolygon(GeneralPathX gp) {
|
|
949 |
Area area = new Area(gp);
|
|
950 |
|
|
951 |
return area;
|
|
952 |
|
|
953 |
|
|
954 |
}
|
|
955 |
|
918 |
956 |
/* public static GeometryCollection convertFGeometryCollection(FGeometryCollection fGeomC)
|
919 |
957 |
{
|
920 |
958 |
|