Revision 42267

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/DefaultGeometryManager.java
52 52
import org.gvsig.fmap.geom.jts.gputils.DefaultGeneralPathX;
53 53
import org.gvsig.fmap.geom.jts.primitive.Envelope2D;
54 54
import org.gvsig.fmap.geom.jts.primitive.Envelope3D;
55
import org.gvsig.fmap.geom.jts.utils.JTSUtils;
55
import org.gvsig.fmap.geom.jts.util.JTSUtils;
56 56
import org.gvsig.fmap.geom.operation.GeometryOperation;
57 57
import org.gvsig.fmap.geom.operation.GeometryOperationContext;
58 58
import org.gvsig.fmap.geom.operation.GeometryOperationException;
......
683 683
        if (pathIterator == null) {
684 684
            return new DefaultGeneralPathX(rule);
685 685
        }
686
        return new DefaultGeneralPathX(pathIterator);
686
        return new DefaultGeneralPathX(pathIterator, false, 0);
687 687
    }
688 688

  
689 689
    public MultiPoint createMultiPoint(int subType) throws CreateGeometryException {
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/util/JTSUtils.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2015 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.fmap.geom.jts.util;
24

  
25
import java.util.ArrayList;
26

  
27
import com.vividsolutions.jts.geom.Coordinate;
28
import com.vividsolutions.jts.geom.CoordinateSequence;
29
import com.vividsolutions.jts.geom.LineSegment;
30
import com.vividsolutions.jts.geom.LineString;
31
import com.vividsolutions.jts.geom.LinearRing;
32
import com.vividsolutions.jts.geom.MultiLineString;
33
import com.vividsolutions.jts.geom.MultiPoint;
34
import com.vividsolutions.jts.geom.Polygon;
35
import com.vividsolutions.jts.geom.Triangle;
36
import com.vividsolutions.jts.util.GeometricShapeFactory;
37

  
38
import org.gvsig.fmap.geom.Geometry;
39
import org.gvsig.fmap.geom.exception.CreateGeometryException;
40
import org.gvsig.fmap.geom.jts.MCoordinate;
41
import org.gvsig.fmap.geom.jts.primitive.curve.line.Line2D;
42
import org.gvsig.fmap.geom.jts.primitive.curve.line.Line2DM;
43
import org.gvsig.fmap.geom.jts.primitive.curve.line.Line3D;
44
import org.gvsig.fmap.geom.jts.primitive.curve.line.Line3DM;
45
import org.gvsig.fmap.geom.jts.primitive.point.Point2D;
46
import org.gvsig.fmap.geom.jts.primitive.point.Point2DM;
47
import org.gvsig.fmap.geom.jts.primitive.point.Point3D;
48
import org.gvsig.fmap.geom.jts.primitive.point.Point3DM;
49
import org.gvsig.fmap.geom.jts.primitive.point.PointJTS;
50
import org.gvsig.fmap.geom.primitive.Point;
51
import org.gvsig.fmap.geom.type.GeometryType;
52

  
53
/**
54
 * @author fdiaz
55
 *
56
 */
57
public class JTSUtils {
58

  
59
    public static final com.vividsolutions.jts.geom.GeometryFactory factory =
60
        new com.vividsolutions.jts.geom.GeometryFactory();
61

  
62
    public static Point createPoint(GeometryType type, Coordinate coordinate) throws CreateGeometryException {
63

  
64
        switch (type.getSubType()) {
65
        case Geometry.SUBTYPES.GEOM2D:
66
            return new Point2D(coordinate);
67
        case Geometry.SUBTYPES.GEOM2DM:
68
            return new Point2DM(coordinate);
69
        case Geometry.SUBTYPES.GEOM3D:
70
            return new Point3D(coordinate);
71
        case Geometry.SUBTYPES.GEOM3DM:
72
            return new Point3DM(coordinate);
73
        default:
74
            Point p = null;
75
            p = (Point) type.create();
76
            for (int i = 0; i < p.getDimension(); i++) {
77
                p.setCoordinateAt(i, coordinate.getOrdinate(i));
78
            }
79
            break;
80
        }
81

  
82
        return null;
83
    }
84

  
85
    public static LineString createJTSLineString(CoordinateSequence coordinates) {
86
        return factory.createLineString(coordinates);
87
    }
88

  
89
    public static Polygon createJTSPolygon(CoordinateSequence coordinates) {
90
        return factory.createPolygon(coordinates);
91

  
92
    }
93

  
94
    public static LinearRing createJTSLinearRing(CoordinateSequence coordinates) {
95
        return factory.createLinearRing(coordinates);
96
    }
97

  
98
    public static MultiPoint createJTSMultiPoint(CoordinateSequence coordinates) {
99
        return factory.createMultiPoint(coordinates);
100
    }
101

  
102
    public static Geometry createGeometry(com.vividsolutions.jts.geom.Geometry jtsGeom) {
103
        if (jtsGeom instanceof com.vividsolutions.jts.geom.Point) {
104
            Coordinate coordinate = jtsGeom.getCoordinate();
105
            if (coordinate instanceof MCoordinate) {
106
                if (Double.isNaN(coordinate.z)) {
107
                    return new Point2DM(coordinate);
108
                } else {
109
                    return new Point3DM(coordinate);
110
                }
111
            } else {
112
                if (Double.isNaN(coordinate.z)) {
113
                    return new Point2D(coordinate);
114
                } else {
115
                    return new Point3D(coordinate);
116
                }
117
            }
118
        }
119

  
120
        if (jtsGeom instanceof com.vividsolutions.jts.geom.LineString) {
121
            Coordinate[] coordinates = jtsGeom.getCoordinates();
122
            Coordinate coordinate = jtsGeom.getCoordinate();
123
            if (coordinate instanceof MCoordinate) {
124
                if (Double.isNaN(coordinate.z)) {
125
                    return new Line2DM(coordinates);
126
                } else {
127
                    return new Line3DM(coordinates);
128
                }
129
            } else {
130
                if (Double.isNaN(coordinate.z)) {
131
                    return new Line2D(coordinates);
132
                } else {
133
                    return new Line3D(coordinates);
134
                }
135
            }
136
        }
137

  
138
        if (jtsGeom instanceof com.vividsolutions.jts.geom.Polygon) {
139

  
140
        }
141

  
142
        if (jtsGeom instanceof com.vividsolutions.jts.geom.GeometryCollection) {
143

  
144
        }
145

  
146
        return null;
147
    }
148

  
149
    /**
150
     * This function is called when the we need force types, that is the
151
     * destination
152
     * type does not match with the input geometry type
153
     *
154
     * @param g
155
     * @param sourceType
156
     * @param destinationType
157
     * @return
158
     */
159
    public static com.vividsolutions.jts.geom.Geometry convertTypes(com.vividsolutions.jts.geom.Geometry g,
160
        int sourceType, int destinationType) {
161
        if ((sourceType == Geometry.TYPES.CURVE || sourceType == Geometry.TYPES.SPLINE
162
            || sourceType == Geometry.TYPES.ARC || sourceType == Geometry.TYPES.ELLIPTICARC)
163
            && destinationType == Geometry.TYPES.MULTISURFACE) {
164
            if (g instanceof MultiLineString) {
165
                Polygon[] poly = new Polygon[((MultiLineString) g).getNumGeometries()];
166
                for (int i = 0; i < ((MultiLineString) g).getNumGeometries(); i++) {
167
                    com.vividsolutions.jts.geom.Geometry lineString = ((MultiLineString) g).getGeometryN(i);
168
                    poly[i] = convertLineStringToPolygon((LineString) lineString);
169
                }
170
                return factory.createMultiPolygon(poly);
171
            } else {
172
                return convertLineStringToPolygon((LineString) g);
173
            }
174
        }
175

  
176
        if ((sourceType == Geometry.TYPES.CIRCLE || sourceType == Geometry.TYPES.ELLIPSE)
177
            && destinationType == Geometry.TYPES.MULTICURVE) {
178
            if (g instanceof Polygon) {
179
                Polygon poly = (Polygon) g;
180
                LineString lineString = factory.createLinearRing(poly.getCoordinates());
181
                return factory.createMultiLineString(new LineString[] { lineString });
182
            }
183
        }
184
        return g;
185
    }
186

  
187
    private static com.vividsolutions.jts.geom.Polygon convertLineStringToPolygon(LineString line) {
188
        Coordinate[] coordinates = line.getCoordinates();
189
        LinearRing shell = factory.createLinearRing(coordinates);
190
        Polygon pol = factory.createPolygon(shell, null);
191
        return pol;
192
    }
193

  
194
    public static MCoordinate createMCoordinate(double x, double y, double m) {
195
        return (MCoordinate) MCoordinate.create2dWithMeasure(x, y, m);
196
    }
197

  
198
    public static MCoordinate createMCoordinate(double x, double y, double z, double m) {
199
        return (MCoordinate) MCoordinate.create3dWithMeasure(x, y, z, m);
200
    }
201

  
202
    /**
203
     * @param init
204
     * @param middle
205
     * @param end
206
     * @return
207
     */
208
    public static Coordinate getCircumcentre(Point init, Point middle, Point end) {
209
        Triangle triangle =
210
            new Triangle(((PointJTS) init).getJTSCoordinate(),
211
                ((PointJTS) middle).getJTSCoordinate(),
212
                ((PointJTS) end).getJTSCoordinate());
213
        return triangle.circumcentre();
214
    }
215

  
216
    public static LineString createJTSLineStringFromArcPoints(Point centre, double radius, double startAngle, double endAngle){
217
        GeometricShapeFactory shapeFactory = new GeometricShapeFactory();
218
        shapeFactory.setCentre(((PointJTS)centre).getJTSCoordinate());
219
        shapeFactory.setSize(radius*2);
220
        return shapeFactory.createArc(startAngle, endAngle);
221
    }
222
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/util/UtilFunctions.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom.jts.util;
25

  
26
import java.awt.geom.Arc2D;
27
import java.awt.geom.Line2D;
28
import java.awt.geom.Point2D;
29
import java.awt.geom.Rectangle2D;
30

  
31
import org.slf4j.Logger;
32
import org.slf4j.LoggerFactory;
33

  
34
import org.gvsig.fmap.geom.Geometry;
35
import org.gvsig.fmap.geom.GeometryLocator;
36
import org.gvsig.fmap.geom.GeometryManager;
37
import org.gvsig.fmap.geom.primitive.Curve;
38

  
39
//import com.vividsolutions.jts.algorithm.RobustCGAlgorithms;
40
//import com.vividsolutions.jts.geom.Coordinate;
41

  
42
/**
43
 * @author FJP
44
 *
45
 *         TODO To change the template for this generated type comment go to
46
 *         Window - Preferences - Java - Code Generation - Code and Comments
47
 * @deprecated to be removed or moved from API to implementation in gvSIG 2.1.0
48
 */
49
public class UtilFunctions {
50
	private static final Logger logger = LoggerFactory.getLogger(GeometryManager.class);
51

  
52
	static public Arc2D createCircle(Point2D p1, Point2D p2, Point2D p3) //, Graphics g)
53
    {
54
        double xC, yC, w, h;
55

  
56
        // Calculamos 2 secantes, tiramos perpendiculares por sus puntos
57
        // medios y obtenemos el centro. Luego calculamos el radio.
58
        // Puntos medios de los segmentos.
59
        double xm1, ym1, xm2, ym2;
60
        xm1 = (p1.getX() + p2.getX())/ 2.0;
61
        ym1 = (p1.getY() + p2.getY())/ 2.0;
62
        xm2 = (p2.getX() + p3.getX())/ 2.0;
63
        ym2 = (p2.getY() + p3.getY())/ 2.0;
64

  
65
        /* g.setColor(Color.GRAY);
66
        g.draw3DRect((int)xm1, (int) ym1, 1, 1, true);
67
        g.draw3DRect((int)xm2, (int) ym2, 1, 1, true); */
68
        // Pendientes de las perpendiculares y constantes
69
        double mP1=0, mP2=0, A1, A2;
70
        boolean bPerp1 = false;
71
        //boolean bPerp2 = false;
72
        if (p2.getY() - p1.getY() == 0)
73
        {
74
            A1 = ym1;
75
            bPerp1 = true;
76
        }
77
        else
78
        {
79
            mP1 = (p2.getX() - p1.getX()) /(p1.getY() - p2.getY());
80
            A1 = ym1 - xm1 * mP1;
81
        }
82
        if (p2.getY() - p3.getY() == 0)
83
        {
84
            A2 = ym2;
85
            //bPerp2 = true;
86
        }
87
        else
88
        {
89
            mP2 = (p3.getX() - p2.getX()) /(p2.getY() - p3.getY());
90
            A2 = ym2 - xm2 * mP2;
91
        }
92
        if (mP2 == mP1)
93
        {
94
            return null; // Error, 3 puntos alineados. No puede pasar un arco
95
        }
96
        else
97
        {
98
            xC = (A2 - A1)/(mP1-mP2);
99
            if (!bPerp1) {
100
				yC = xC * mP1 + A1;
101
			} else {
102
				yC = xC * mP2 + A2;
103
			}
104
        }
105
        double Radio = p1.distance(xC, yC);
106
        double xR = xC - Radio ;
107
        double yR = yC - Radio ;
108
        w = 2.0* Radio;
109
        h = w;
110
        Rectangle2D.Double rBounds = new Rectangle2D.Double(xR,yR, w,h);
111
        Arc2D.Double resul = new Arc2D.Double(rBounds, 0.0, 360.0, Arc2D.OPEN);
112
		/* g.setColor(Color.RED);
113
		((Graphics2D) g).draw(resul);
114
		g.setColor(Color.BLUE);
115
		((Graphics2D) g).draw(rBounds);
116
		g.draw3DRect((int)p1.getX(), (int) p1.getY(), 1, 1, true);
117
		g.draw3DRect((int)p2.getX(), (int) p2.getY(), 2, 2, true);
118
		g.draw3DRect((int)p3.getX(), (int) p3.getY(), 1, 1, true);
119
		g.drawString("1", (int) p1.getX(), (int) p1.getY());
120
		g.drawString("2", (int) p2.getX(), (int) p2.getY());
121
		g.drawString("3", (int) p3.getX(), (int) p3.getY());
122
		g.drawString("C", (int) xC, (int) yC);
123
		g.draw3DRect((int)xC, (int) yC, 2, 2, true); */
124

  
125
        return resul;
126
    }
127
    /**
128
	 * Obtiene un par de puntos que definen la recta perpendicular a p1-p2 que
129
	 * pasa por el punto perp
130
	 *
131
	 * @param p1 punto de la recta p1-p2
132
	 * @param p2 punto de la recta p1-p2
133
	 * @param perp Punto por el que pasa la recta perpendicular, debe ser
134
	 * 		  distinto a p2
135
	 *
136
	 * @return Array con dos puntos que definen la recta resultante
137
	 * @deprecated
138
	 *         use the perpendicular operation
139
	 */
140
	public static Point2D[] getPerpendicular(Point2D p1, Point2D p2,
141
		Point2D perp) {
142
		if ((p2.getY() - p1.getY()) == 0) {
143
			return new Point2D[] {
144
				new Point2D.Double(perp.getX(), 0),
145
				new Point2D.Double(perp.getX(), 1)
146
			};
147
		}
148

  
149
		//Pendiente de la recta perpendicular
150
		double m = (p1.getX() - p2.getX()) / (p2.getY() - p1.getY());
151

  
152
		//b de la funcion de la recta perpendicular
153
		double b = perp.getY() - (m * perp.getX());
154

  
155
		//Obtenemos un par de puntos
156
		Point2D[] res = new Point2D[2];
157

  
158
		res[0] = new Point2D.Double(0, (m * 0) + b);
159
		res[1] = new Point2D.Double(1000, (m * 1000) + b);
160

  
161
		return res;
162
	}
163
	public static Point2D[] getParallel(Point2D p1,Point2D p2,double distance) {
164
		Point2D[] pParallel=new Point2D[2];
165
		pParallel[0]=getPerpendicularPoint(p1,p2,p1,distance);
166
		pParallel[1]=getPerpendicularPoint(p1,p2,p2,distance);
167
		return pParallel;
168
	}
169

  
170
	/**
171
	 * Obtiene el punto que se encuentra a una distancia 'dist' de la recta
172
	 * p1-p2 y se encuentra en la recta perpendicular que pasa por perpPoint
173
	 *
174
	 * @param p1 Punto de la recta p1-p2
175
	 * @param p2 Punto de la recta p1-p2
176
	 * @param perpPoint Punto de la recta perpendicular
177
	 * @param dist Distancia del punto que se quiere obtener a la recta p1-p2
178
	 *
179
	 * @return DOCUMENT ME!
180
	 * @deprecated
181
	 *         Use the perpendicularPoint operation
182
	 */
183
	public static Point2D getPerpendicularPoint(Point2D p1, Point2D p2,
184
		Point2D perpPoint, double dist) {
185
		Point2D[] p = getPerpendicular(p1, p2, perpPoint);
186
		Point2D unit = getUnitVector(p[0], p[1]);
187

  
188
		return new Point2D.Double(perpPoint.getX() + (unit.getX() * dist),
189
			perpPoint.getY() + (unit.getY() * dist));
190
	}
191

  
192
	/**
193
	 * Devuelve un vector unitario en forma de punto a partir de dos puntos.
194
	 *
195
	 * @param p1 punto origen.
196
	 * @param p2 punto destino.
197
	 *
198
	 * @return vector unitario.
199
	 * @deprecated
200
	 *         use the UnitVector operation
201
	 */
202
	public static Point2D getUnitVector(Point2D p1, Point2D p2) {
203
		Point2D paux = new Point2D.Double(p2.getX() - p1.getX(),
204
				p2.getY() - p1.getY());
205
		double v = Math.sqrt(Math.pow(paux.getX(), 2d) +
206
				Math.pow(paux.getY(), 2d));
207
		paux = new Point2D.Double(paux.getX() / v, paux.getY() / v);
208

  
209
		return paux;
210
	}
211
	/**
212
	 * Obtiene el centro del c�rculo que pasa por los tres puntos que se pasan
213
	 * como  par�metro
214
	 *
215
	 * @param p1 primer punto del c�rculo cuyo centro se quiere obtener
216
	 * @param p2 segundo punto del c�rculo cuyo centro se quiere obtener
217
	 * @param p3 tercer punto del c�rculo cuyo centro se quiere obtener
218
	 *
219
	 * @return Devuelve null si los puntos est�n alineados o no son 3 puntos
220
	 * 		   distintos
221
	 */
222
	public static Point2D getCenter(Point2D p1, Point2D p2, Point2D p3) {
223
		if (p1.equals(p2) || p2.equals(p3) || p1.equals(p3)) {
224
			return null;
225
		}
226

  
227
		Point2D[] perp1 = getPerpendicular(p1, p2,
228
				new Point2D.Double((p1.getX() + p2.getX()) / 2,
229
					(p1.getY() + p2.getY()) / 2));
230
		Point2D[] perp2 = getPerpendicular(p2, p3,
231
				new Point2D.Double((p2.getX() + p3.getX()) / 2,
232
					(p2.getY() + p3.getY()) / 2));
233

  
234
		return getIntersection(perp1[0], perp1[1], perp2[0], perp2[1]);
235
	}
236

  
237

  
238
	/**
239
	 * Devuelve el punto de la intersecci�n entre las lineas p1-p2 y p3-p4.
240
	 *
241
	 * @param p1 punto de la recta p1-p2
242
	 * @param p2 punto de la recta p1-p2
243
	 * @param p3 punto de la recta p3-p4
244
	 * @param p4 punto de la recta p3-p4
245
	 *
246
	 * @return DOCUMENT ME!
247
	 *
248
	 * @throws RuntimeException DOCUMENT ME!
249
	 */
250
	public static Point2D getIntersection(Point2D p1, Point2D p2, Point2D p3,
251
		Point2D p4) {
252
		double m1 = Double.POSITIVE_INFINITY;
253

  
254
		if ((p2.getX() - p1.getX()) != 0) {
255
			m1 = (p2.getY() - p1.getY()) / (p2.getX() - p1.getX());
256
		}
257

  
258
		double m2 = Double.POSITIVE_INFINITY;
259

  
260
		if ((p4.getX() - p3.getX()) != 0) {
261
			m2 = (p4.getY() - p3.getY()) / (p4.getX() - p3.getX());
262
		}
263

  
264
		if ((m1 == Double.POSITIVE_INFINITY) &&
265
				(m2 == Double.POSITIVE_INFINITY)) {
266
			return null;
267
		}
268

  
269
		double b1 = p2.getY() - (m1 * p2.getX());
270

  
271
		double b2 = p4.getY() - (m2 * p4.getX());
272

  
273
		if ((m1 != Double.POSITIVE_INFINITY) &&
274
				(m2 != Double.POSITIVE_INFINITY)) {
275
			if (m1 == m2) {
276
				return null;
277
			}
278

  
279
			double x = (b2 - b1) / (m1 - m2);
280

  
281
			return new Point2D.Double(x, (m1 * x) + b1);
282
		} else if (m1 == Double.POSITIVE_INFINITY) {
283
			double x = p1.getX();
284

  
285
			return new Point2D.Double(x, (m2 * x) + b2);
286
		} else if (m2 == Double.POSITIVE_INFINITY) {
287
			double x = p3.getX();
288

  
289
			return new Point2D.Double(x, (m1 * x) + b1);
290
		}
291

  
292
		//no llega nunca
293
		throw new RuntimeException("BUG!");
294
	}
295
	/**
296
	 * Obtiene el �ngulo del vector que se pasa como par�metro con el vector
297
	 * horizontal de izquierda a derecha
298
	 *
299
	 * @param start punto origen del vector
300
	 * @param end punto destino del vector
301
	 *
302
	 * @return angulo en radianes
303
	 */
304
	public static double getAngle(Point2D start, Point2D end) {
305
		double angle = Math.acos((end.getX() - start.getX()) / start.distance(
306
					end));
307

  
308
		if (start.getY() > end.getY()) {
309
			angle = -angle;
310
		}
311

  
312
		if (angle < 0) {
313
			angle += (2 * Math.PI);
314
		}
315

  
316
		return angle;
317
	}
318
	/**
319
	 * Devuelve la distancia desde angle1 a angle2. Angulo en radianes de
320
	 * diferencia entre angle1 y angle2 en sentido antihorario
321
	 *
322
	 * @param angle1 angulo en radianes. Debe ser positivo y no dar ninguna
323
	 * 		  vuelta a la circunferencia
324
	 * @param angle2 angulo en radianes. Debe ser positivo y no dar ninguna
325
	 * 		  vuelta a la circunferencia
326
	 *
327
	 * @return distancia entre los �ngulos
328
	 */
329
	public static double angleDistance(double angle1, double angle2) {
330
		if (angle1 < angle2) {
331
			return angle2 - angle1;
332
		} else {
333
			return ((Math.PI * 2) - angle1) + angle2;
334
		}
335
	}
336
	/**
337
	 * Devuelve el punto de la recta que viene dada por los puntos p1 y p2 a
338
	 * una distancia radio de p1.
339
	 *
340
	 * @param p1 DOCUMENT ME!
341
	 * @param p2 DOCUMENT ME!
342
	 * @param radio DOCUMENT ME!
343
	 *
344
	 * @return DOCUMENT ME!
345
	 */
346
	public static Point2D getPoint(Point2D p1, Point2D p2, double radio) {
347
		Point2D paux = new Point2D.Double(p2.getX() - p1.getX(),
348
				p2.getY() - p1.getY());
349
		double v = Math.sqrt(Math.pow(paux.getX(), 2d) +
350
				Math.pow(paux.getY(), 2d));
351
		paux = new Point2D.Double(paux.getX() / v, paux.getY() / v);
352

  
353
		Point2D aux1 = new Point2D.Double(p1.getX() + (radio * paux.getX()),
354
				p1.getY() + (radio * paux.getY()));
355

  
356
		return aux1;
357
	}
358
	/**
359
	 * Devuelve la menor distancia desde angle1 a angle2.
360
	 *
361
	 * @param angle1 angulo en radianes. Debe ser positivo y no dar ninguna
362
	 * 		  vuelta a la circunferencia
363
	 * @param angle2 angulo en radianes. Debe ser positivo y no dar ninguna
364
	 * 		  vuelta a la circunferencia
365
	 *
366
	 * @return distancia entre los �ngulos
367
	 */
368
	public static double absoluteAngleDistance(double angle1, double angle2) {
369
		double d = Math.abs(angle1 - angle2);
370

  
371
		if (d < Math.PI) {
372
			return d;
373
		} else {
374
			if (angle1 < angle2) {
375
				angle2 -= (Math.PI * 2);
376
			} else {
377
				angle1 -= (Math.PI * 2);
378
			}
379

  
380
			return Math.abs(angle1 - angle2);
381
		}
382
	}
383
	/**
384
	 * Obtiene un arco a partir de 3 puntos. Devuelve null si no se puede crear
385
	 * el arco porque los puntos est�n alineados o los 3 puntos no son
386
	 * distintos
387
	 *
388
	 * @param p1
389
	 * @param p2
390
	 * @param p3
391
	 *
392
	 * @return Arco
393
	 */
394
	public static Arc2D createArc(Point2D p1, Point2D p2, Point2D p3) {
395
		Point2D center = getCenter(p1, p2, p3);
396

  
397
		double angle1;
398
		double angle2;
399
		double extent;
400

  
401
		if (center == null) {
402
			if (p1.equals(p3) && !p2.equals(p1)) {
403
				//Si los puntos p1 y p3 son los mismos (pero el p2 no),
404
				//consideramos que el arco es una circunferencia completa
405
				center = new Point2D.Double((p1.getX() + p2.getX()) / 2,
406
							(p1.getY() + p2.getY()) / 2);
407
				angle1 = getAngle(center, p1);
408
				extent = Math.PI*2;
409
			} else {
410
				//en cualquier otro caso, no podemos crear el arco.
411
				return null;
412
			}
413
		} else {
414
                    angle1 = getAngle(center, p1);
415
                    angle2 = getAngle(center, p3);
416
                    extent = angleDistance(angle1, angle2);
417

  
418
                    try {
419
                        GeometryManager manager = GeometryLocator.getGeometryManager();
420
                        Curve line = manager.createCurve(Geometry.SUBTYPES.GEOM2D);
421
                        line.addVertex(p1.getX(), p1.getY());
422
                        line.addVertex(p2.getX(), p2.getY());
423
                        line.addVertex(p3.getX(), p3.getY());
424
                        line.addVertex(p1.getX(), p1.getY());
425
                        if( line.isCCW() ) {
426
                            extent = (Math.PI * 2) - extent;
427
                        } else {
428
                            extent = -extent;
429
                        }
430
                    } catch (Exception ex) {
431
                        logger.warn("Can't determine CCW of the Arc",ex);
432
                        extent = -extent;
433
                    }
434
		}
435
		//System.err.println("angle1:" + angle1);
436
		//System.err.println("angle2:" + getAngle(center, p2));
437
		//System.err.println("angle3:" + angle2);
438
		//System.err.println("extent:" + extent);
439
		double Radio = p1.distance(center);
440
		double xR = center.getX() - Radio;
441
		double yR = center.getY() - Radio;
442
		double w = 2.0 * Radio;
443
		double h = w;
444

  
445
		Rectangle2D.Double rBounds = new Rectangle2D.Double(xR, yR, w, h);
446
		Arc2D.Double resul = new Arc2D.Double(rBounds,
447
				Math.toDegrees((Math.PI * 2) - angle1), Math.toDegrees(extent),
448
				Arc2D.OPEN);
449

  
450
		return resul;
451
	}
452

  
453
	/**
454
	 * Obtiene un arco a partir del centro, radio, angulo inicial y extension del angulo.
455
	 * Devuelve null si no lo puede crear.
456
	 *
457
	 * @param center
458
	 * @param radius
459
	 * @param angSt en radianes
460
	 * @param angExt en radianes
461
	 *
462
	 * @return Arco
463
	 */
464
	public static Arc2D createArc(Point2D center, double radius, double angSt, double angExt) {
465
		double xR = center.getX() - radius;
466
		double yR = center.getY() - radius;
467
		double w = 2.0 * radius;
468
		double h = w;
469

  
470
		Rectangle2D.Double rBounds = new Rectangle2D.Double(xR, yR, w, h);
471
		Arc2D.Double resul = new Arc2D.Double(rBounds,
472
				Math.toDegrees((Math.PI * 2) - angSt), Math.toDegrees(angExt),
473
				Arc2D.OPEN);
474

  
475
		return resul;
476
	}
477

  
478
	/**
479
	 * Obtiene un arco a partir del
480
	 *  centro del arco y punto inicio y punto final
481
	 *  Suponemos un Arco definicio CCW (CounterClockWise)
482
	 * @param center
483
	 * @param init
484
	 * @param end
485
	 *
486
	 * @return Arco
487
	 */
488
	public static Arc2D createArc2points(Point2D center, Point2D init, Point2D end) {
489

  
490
		double angle1 = getAngle(center, init);
491
		double angle2 = getAngle(center, end);
492
		double extent = angleDistance(angle1, angle2);
493

  
494
		extent = -extent; // CCW
495

  
496
		//System.err.println("angle1:" + angle1);
497
		//System.err.println("angle2:" + getAngle(center, p2));
498
		//System.err.println("angle3:" + angle2);
499
		//System.err.println("extent:" + extent);
500
		double Radio = init.distance(center);
501
		double xR = center.getX() - Radio;
502
		double yR = center.getY() - Radio;
503
		double w = 2.0 * Radio;
504
		double h = w;
505

  
506
		Rectangle2D.Double rBounds = new Rectangle2D.Double(xR, yR, w, h);
507
		Arc2D.Double resul = new Arc2D.Double(rBounds,
508
				Math.toDegrees((Math.PI * 2) - angle1), Math.toDegrees(extent),
509
				Arc2D.OPEN);
510

  
511
		return resul;
512
	}
513

  
514
	/**
515
	 * Devuelve el punto a una distancia radio del punto p1 y aplicandole un �ngulo an.
516
	 * una distancia radio de p1.
517
	 *
518
	 * @param p1 DOCUMENT ME!
519
	 * @param p2 DOCUMENT ME!
520
	 * @param radio DOCUMENT ME!
521
	 *
522
	 * @return DOCUMENT ME!
523
	 */
524
	public static Point2D getPoint(Point2D p1, double an, double radio) {
525
		double x=(radio*Math.cos(an))+p1.getX();
526
		double y=(radio*Math.sin(an))+p1.getY();
527

  
528
		Point2D p=new Point2D.Double(x,y);
529

  
530
		return p;
531
	}
532

  
533
	/**
534
	 * Obtiene una linea a partir de dos puntos.
535
	 * Devuelve null si no lo puede crear.
536
	 *
537
	 * @param start
538
	 * @param end
539
	 *
540
	 * @return Linea
541
	 */
542
	public static Line2D createLine(Point2D start, Point2D end) {
543
		return new Line2D.Double(start, end);
544

  
545
	}
546

  
547

  
548
	/**
549
	 * DOCUMENT ME!
550
	 *
551
	 * @param antp DOCUMENT ME!
552
	 * @param lastp DOCUMENT ME!
553
	 * @param interp DOCUMENT ME!
554
	 * @param point DOCUMENT ME!
555
	 *
556
	 * @return DOCUMENT ME!
557
	 */
558
	public static boolean isLowAngle(Point2D antp, Point2D lastp,
559
		Point2D interp, Point2D point) {
560
		///double ob=lastp.distance(point);
561
		///Point2D[] aux=getPerpendicular(lastp,interp,point);
562
		///Point2D intersect=getIntersection(aux[0],aux[1],lastp,interp);
563
		///double pb=intersect.distance(point);
564
		///double a=Math.asin(pb/ob);
565

  
566
                boolean isCCW = true;
567
                try {
568
                    GeometryManager manager = GeometryLocator.getGeometryManager();
569
                    Curve line;
570
                    line = manager.createCurve(Geometry.SUBTYPES.GEOM2D);
571
                    line.addVertex(lastp.getX(), lastp.getY());
572
                    line.addVertex(interp.getX(), interp.getY());
573
                    line.addVertex(point.getX(), point.getY());
574
                    line.addVertex(lastp.getX(), lastp.getY());
575
                    isCCW = line.isCCW();
576
                } catch (Exception ex) {
577
                    logger.warn("Can't determine CCW of angle.",ex);
578
                }
579

  
580
		try {
581
			double angle1 = getAngle(antp, lastp);
582
			// System.out.println("angle1= " + angle1);
583

  
584
			double angle2 = getAngle(lastp, point);
585
			// System.out.println("angle2= " + angle2);
586

  
587
			/*if (lastp.getX()<antp.getX()){
588
			   System.out.println("angleDiff 2 1= "+angleDistance(angle2,angle1));
589
			   System.out.println("angleDiff 1 2= "+angleDistance(angle1,angle2));
590
			   if (angleDistance(angle2,angle1)>Math.PI){
591

  
592
			   if (RobustCGAlgorithms.isCCW(coords)) {
593
			           System.out.println("izquierda,arriba,true");
594
			           return true;
595
			   } else{
596
			           System.out.println("izquierda,arriba,false");
597
			   }
598
			   }else {
599
			           if (!RobustCGAlgorithms.isCCW(coords)) {
600
			                   System.out.println("izquierda,abajo,true");
601
			                   return true;
602
			           } else{
603
			                   System.out.println("izquierda,abajo,false");
604
			           }
605
			   }
606
			   }else if (lastp.getX()>antp.getX()){
607
			 */
608

  
609
			/*
610
			System.out.println("angleDifl 2 1= " +
611
				angleDistance(angle2, angle1));
612
			System.out.println("angleDifl 1 2= " +
613
				angleDistance(angle1, angle2));
614
			*/
615

  
616
			if (angleDistance(angle2, angle1) > Math.PI) {
617
				if (isCCW) {
618
					// System.out.println("derecha,arriba,true");
619

  
620
					return true;
621
				} else {
622
					// System.out.println("derecha,arriba,false");
623
				}
624
			} else {
625
				if (!isCCW) {
626
					// System.out.println("derecha,abajo,true");
627

  
628
					return true;
629
				} else {
630
				    // System.out.println("derecha,abajo,false");
631
				}
632
			}
633

  
634
			//}
635
		} catch (Exception e) {
636
			// System.out.println("false");
637

  
638
			return true;
639
		}
640

  
641
		return false;
642
	}
643

  
644

  
645

  
646

  
647
}
0 648

  
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/util/ReadOnlyCoordinates.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2015 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.fmap.geom.jts.util;
24

  
25
import java.util.Collection;
26
import java.util.Iterator;
27

  
28
import com.vividsolutions.jts.geom.Coordinate;
29

  
30

  
31
/**
32
 * @author fdiaz
33
 *
34
 */
35
public class ReadOnlyCoordinates implements Collection<Coordinate> {
36

  
37
    Coordinate coordinates[];
38

  
39
    /**
40
     *
41
     */
42
    public ReadOnlyCoordinates(Coordinate coordinates[]) {
43
        this.coordinates = coordinates;
44
    }
45

  
46
    /* (non-Javadoc)
47
     * @see java.util.Collection#size()
48
     */
49
    public int size() {
50
        return this.coordinates.length;
51
    }
52

  
53
    /* (non-Javadoc)
54
     * @see java.util.Collection#isEmpty()
55
     */
56
    public boolean isEmpty() {
57
        return this.coordinates.length==0;
58
    }
59

  
60
    /* (non-Javadoc)
61
     * @see java.util.Collection#contains(java.lang.Object)
62
     */
63
    public boolean contains(Object o) {
64
        for (int i = 0; i < coordinates.length; i++) {
65
            if(coordinates[i].equals(o)){
66
                return true;
67
            }
68
        }
69
        return false;
70
    }
71

  
72
    /* (non-Javadoc)
73
     * @see java.util.Collection#iterator()
74
     */
75
    public Iterator<Coordinate> iterator() {
76
        return new Iterator<Coordinate>() {
77

  
78
            int i=0;
79

  
80
            public boolean hasNext() {
81
                return i<coordinates.length;
82
            }
83

  
84
            public Coordinate next() {
85
                return coordinates[i++];
86
            }
87

  
88
            public void remove() {
89
                throw new UnsupportedOperationException();
90
            }
91
        };
92
    }
93

  
94
    /* (non-Javadoc)
95
     * @see java.util.Collection#toArray()
96
     */
97
    public Object[] toArray() {
98
        return this.coordinates;
99
    }
100

  
101
    /* (non-Javadoc)
102
     * @see java.util.Collection#toArray(java.lang.Object[])
103
     */
104
    public <T> T[] toArray(T[] a) {
105
        return (T[]) this.coordinates;
106
    }
107

  
108
    /* (non-Javadoc)
109
     * @see java.util.Collection#add(java.lang.Object)
110
     */
111
    public boolean add(Coordinate e) {
112
        throw new UnsupportedOperationException();
113
    }
114

  
115
    /* (non-Javadoc)
116
     * @see java.util.Collection#remove(java.lang.Object)
117
     */
118
    public boolean remove(Object o) {
119
        throw new UnsupportedOperationException();
120
    }
121

  
122
    /* (non-Javadoc)
123
     * @see java.util.Collection#containsAll(java.util.Collection)
124
     */
125
    public boolean containsAll(Collection<?> c) {
126
        for (Iterator iterator = c.iterator(); iterator.hasNext();) {
127
            Object object = (Object) iterator.next();
128
            if(contains(object)){
129
                return true;
130
            }
131
        }
132
        return false;
133
    }
134

  
135
    /* (non-Javadoc)
136
     * @see java.util.Collection#addAll(java.util.Collection)
137
     */
138
    public boolean addAll(Collection<? extends Coordinate> c) {
139
        throw new UnsupportedOperationException();
140
    }
141

  
142
    /* (non-Javadoc)
143
     * @see java.util.Collection#removeAll(java.util.Collection)
144
     */
145
    public boolean removeAll(Collection<?> c) {
146
        throw new UnsupportedOperationException();
147
    }
148

  
149
    /* (non-Javadoc)
150
     * @see java.util.Collection#retainAll(java.util.Collection)
151
     */
152
    public boolean retainAll(Collection<?> c) {
153
        throw new UnsupportedOperationException();
154
    }
155

  
156
    /* (non-Javadoc)
157
     * @see java.util.Collection#clear()
158
     */
159
    public void clear() {
160
        throw new UnsupportedOperationException();
161
    }
162

  
163
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/util/ArrayListCoordinateSequence.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2015 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.fmap.geom.jts.util;
24

  
25
import java.util.ArrayList;
26
import java.util.Collection;
27

  
28
import com.vividsolutions.jts.geom.Coordinate;
29
import com.vividsolutions.jts.geom.CoordinateSequence;
30
import com.vividsolutions.jts.geom.Envelope;
31

  
32
import org.gvsig.fmap.geom.jts.MCoordinate;
33

  
34
/**
35
 * @author fdiaz
36
 *
37
 */
38
public class ArrayListCoordinateSequence extends ArrayList<Coordinate> implements CoordinateSequence {
39

  
40

  
41
    /**
42
     *
43
     */
44
    private static final long serialVersionUID = -6406449425908120065L;
45

  
46
    /**
47
     *
48
     */
49
    public ArrayListCoordinateSequence(Collection<Coordinate> coordinates) {
50
        super(coordinates);
51
    }
52

  
53
    /**
54
    *
55
    */
56
   public ArrayListCoordinateSequence() {
57
       super();
58
   }
59

  
60
    /* (non-Javadoc)
61
     * @see com.vividsolutions.jts.geom.CoordinateSequence#getDimension()
62
     */
63
    public int getDimension() {
64

  
65
        // FIXME: ?Esto es correcto?????
66

  
67
        Coordinate c = get(0);
68
        if(c instanceof MCoordinate){
69
            if(Double.isNaN(c.z)){
70
                return 3;
71
            } else {
72
                return 4;
73
            }
74
        } else {
75
            if(Double.isNaN(c.z)){
76
                return 2;
77
            } else {
78
                return 3;
79
            }
80
        }
81
    }
82

  
83
    /* (non-Javadoc)
84
     * @see com.vividsolutions.jts.geom.CoordinateSequence#getCoordinate(int)
85
     */
86
    public com.vividsolutions.jts.geom.Coordinate getCoordinate(int i) {
87
        return (com.vividsolutions.jts.geom.Coordinate) get(i);
88
    }
89

  
90
    /* (non-Javadoc)
91
     * @see com.vividsolutions.jts.geom.CoordinateSequence#getCoordinateCopy(int)
92
     */
93
    public com.vividsolutions.jts.geom.Coordinate getCoordinateCopy(int i) {
94
        return (com.vividsolutions.jts.geom.Coordinate) ((com.vividsolutions.jts.geom.Coordinate)get(i)).clone();
95
    }
96

  
97
    /* (non-Javadoc)
98
     * @see com.vividsolutions.jts.geom.CoordinateSequence#getCoordinate(int, com.vividsolutions.jts.geom.Coordinate)
99
     */
100
    public void getCoordinate(int index, com.vividsolutions.jts.geom.Coordinate coord) {
101
        Coordinate c = ((com.vividsolutions.jts.geom.Coordinate) get(index));
102
        coord = new Coordinate(c.x, c.y);
103
    }
104

  
105
    /* (non-Javadoc)
106
     * @see com.vividsolutions.jts.geom.CoordinateSequence#getX(int)
107
     */
108
    public double getX(int index) {
109
        return ((com.vividsolutions.jts.geom.Coordinate) get(index)).x;
110
    }
111

  
112
    /* (non-Javadoc)
113
     * @see com.vividsolutions.jts.geom.CoordinateSequence#getY(int)
114
     */
115
    public double getY(int index) {
116
        return ((com.vividsolutions.jts.geom.Coordinate) get(index)).y;
117
    }
118

  
119
    /* (non-Javadoc)
120
     * @see com.vividsolutions.jts.geom.CoordinateSequence#getOrdinate(int, int)
121
     */
122
    public double getOrdinate(int index, int ordinateIndex) {
123
        return ((com.vividsolutions.jts.geom.Coordinate) get(index)).getOrdinate(ordinateIndex);
124
    }
125

  
126
    /* (non-Javadoc)
127
     * @see com.vividsolutions.jts.geom.CoordinateSequence#setOrdinate(int, int, double)
128
     */
129
    public void setOrdinate(int index, int ordinateIndex, double value) {
130
        ((com.vividsolutions.jts.geom.Coordinate) get(index)).setOrdinate(ordinateIndex, value);
131
    }
132

  
133
    /* (non-Javadoc)
134
     * @see com.vividsolutions.jts.geom.CoordinateSequence#toCoordinateArray()
135
     */
136
    public com.vividsolutions.jts.geom.Coordinate[] toCoordinateArray() {
137
        return (Coordinate[]) this.toArray();
138
    }
139

  
140
    /* (non-Javadoc)
141
     * @see com.vividsolutions.jts.geom.CoordinateSequence#expandEnvelope(com.vividsolutions.jts.geom.Envelope)
142
     */
143
    public Envelope expandEnvelope(Envelope env) {
144
        for (int i = 0; i < this.size(); i++) {
145
            env.expandToInclude((com.vividsolutions.jts.geom.Coordinate) get(i));
146
        }
147
        return env;
148
    }
149
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/AbstractGeometry.java
46 46
import org.gvsig.fmap.geom.jts.primitive.Envelope2D;
47 47
import org.gvsig.fmap.geom.jts.primitive.Envelope3D;
48 48
import org.gvsig.fmap.geom.jts.primitive.point.Point3D;
49
import org.gvsig.fmap.geom.jts.utils.JTSUtils;
49
import org.gvsig.fmap.geom.jts.util.JTSUtils;
50 50
import org.gvsig.fmap.geom.operation.GeometryOperationContext;
51 51
import org.gvsig.fmap.geom.operation.GeometryOperationException;
52 52
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
......
65 65
 */
66 66
public abstract class AbstractGeometry implements GeometryJTS {
67 67

  
68
    private static final Logger logger = LoggerFactory.getLogger(AbstractGeometry.class);
68
    protected static final Logger logger = LoggerFactory.getLogger(AbstractGeometry.class);
69 69

  
70 70
    /**
71 71
     *
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/MCoordinate.java
30 30
 */
31 31
public class MCoordinate extends org.hibernate.spatial.jts.mgeom.MCoordinate {
32 32

  
33
    /**
34
     *
35
     */
36
    private static final long serialVersionUID = -734914554153589737L;
37

  
33 38
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/DefaultGeometryLibrary.java
30 30
import org.gvsig.fmap.geom.GeometryLibrary;
31 31
import org.gvsig.fmap.geom.GeometryLocator;
32 32
import org.gvsig.fmap.geom.GeometryManager;
33
import org.gvsig.fmap.geom.jts.aggregate.MultiPoint2D;
34
import org.gvsig.fmap.geom.jts.aggregate.MultiPoint2DM;
35
import org.gvsig.fmap.geom.jts.aggregate.MultiPoint3DM;
33 36
import org.gvsig.fmap.geom.jts.coerce.CoerceToByteArray;
34 37
import org.gvsig.fmap.geom.jts.coerce.CoerceToEnvelope;
35 38
import org.gvsig.fmap.geom.jts.coerce.CoerceToGeometry;
......
37 40
import org.gvsig.fmap.geom.jts.primitive.DefaultEnvelope;
38 41
import org.gvsig.fmap.geom.jts.primitive.Envelope2D;
39 42
import org.gvsig.fmap.geom.jts.primitive.Envelope3D;
43
import org.gvsig.fmap.geom.jts.primitive.curve.arc.Arc2D;
44
import org.gvsig.fmap.geom.jts.primitive.curve.arc.Arc2DZ;
40 45
import org.gvsig.fmap.geom.jts.primitive.curve.line.Line2D;
41 46
import org.gvsig.fmap.geom.jts.primitive.curve.line.Line2DM;
42 47
import org.gvsig.fmap.geom.jts.primitive.curve.line.Line3D;
43 48
import org.gvsig.fmap.geom.jts.primitive.curve.line.Line3DM;
49
import org.gvsig.fmap.geom.jts.primitive.curve.spline.Spline2D;
50
import org.gvsig.fmap.geom.jts.primitive.curve.spline.Spline2DM;
51
import org.gvsig.fmap.geom.jts.primitive.curve.spline.Spline3D;
52
import org.gvsig.fmap.geom.jts.primitive.curve.spline.Spline3DM;
44 53
import org.gvsig.fmap.geom.jts.primitive.point.Point2D;
45 54
import org.gvsig.fmap.geom.jts.primitive.point.Point2DM;
46 55
import org.gvsig.fmap.geom.jts.primitive.point.Point3D;
......
98 107
//        geometryManager.registerGeometryType(new Point2DGeometryType());
99 108
        geometryManager.registerGeometryType(Point2D.class, "Point2D", TYPES.POINT, SUBTYPES.GEOM2D);
100 109
        geometryManager.registerGeometryType(Point2DM.class, "Point2DM", TYPES.POINT, SUBTYPES.GEOM2DM);
101
        geometryManager.registerGeometryType(Point3D.class, "Point3D", TYPES.POINT, SUBTYPES.GEOM3D);
102
        geometryManager.registerGeometryType(Point3DM.class, "Point3DM", TYPES.POINT, SUBTYPES.GEOM3DM);
103 110

  
104 111
        // Register curves in 2D
105 112
        geometryManager.registerGeometryType(Line2D.class, "Line2D", TYPES.LINE, SUBTYPES.GEOM2D);
113
        geometryManager.registerGeometryType(Arc2D.class, "Arc2D", TYPES.ARC, SUBTYPES.GEOM2D, TYPES.CURVE);
114
        geometryManager.registerGeometryType(Spline2D.class, "Spline2D", TYPES.SPLINE, SUBTYPES.GEOM2D, TYPES.CURVE);
115

  
116
        // Register curves in 2DM
106 117
        geometryManager.registerGeometryType(Line2DM.class, "Line2DM", TYPES.LINE, SUBTYPES.GEOM2DM);
107
        geometryManager.registerGeometryType(Line3D.class, "Line3D", TYPES.LINE, SUBTYPES.GEOM3D);
108
        geometryManager.registerGeometryType(Line3DM.class, "Line3DM", TYPES.LINE, SUBTYPES.GEOM3DM);
109
//        geometryManager.registerGeometryType(Arc2D.class, "Arc2D", TYPES.ARC, SUBTYPES.GEOM2D, TYPES.CURVE);
110
//        geometryManager.registerGeometryType(Spline2D.class, "Spline2D", TYPES.SPLINE, SUBTYPES.GEOM2D, TYPES.CURVE);
118
        geometryManager.registerGeometryType(Spline2DM.class, "Spline2DM", TYPES.SPLINE, SUBTYPES.GEOM2DM, TYPES.CURVE);
111 119

  
112 120
        // Register surfaces in 2D
113 121
        geometryManager.registerGeometryType(Polygon2D.class, "Polygon2D", TYPES.POLYGON, SUBTYPES.GEOM2D,
......
121 129
        // Register multigeometries in 2D
122 130
//        geometryManager.registerGeometryType(BaseMultiPrimitive2D.class, "MultiPrimitive2D", TYPES.AGGREGATE,
123 131
//            SUBTYPES.GEOM2D);
124
//        geometryManager.registerGeometryType(MultiPoint2D.class, "MultiPoint2D", TYPES.MULTIPOINT, SUBTYPES.GEOM2D,
125
//            TYPES.AGGREGATE);
132
        geometryManager.registerGeometryType(MultiPoint2D.class, "MultiPoint2D", TYPES.MULTIPOINT, SUBTYPES.GEOM2D,
133
            TYPES.AGGREGATE);
126 134
//        geometryManager.registerGeometryType(MultiCurve2D.class, "MultiCurve2D", TYPES.MULTICURVE, SUBTYPES.GEOM2D,
127 135
//            TYPES.AGGREGATE);
128 136
//        geometryManager.registerGeometryType(MultiSurface2D.class, "MultiSurface2D", TYPES.MULTISURFACE,
129 137
//            SUBTYPES.GEOM2D, TYPES.AGGREGATE);
130 138

  
139
        // Register multigeometries in 2DM
140
        geometryManager.registerGeometryType(MultiPoint2DM.class, "MultiPoint2DM", TYPES.MULTIPOINT, SUBTYPES.GEOM2DM,
141
            TYPES.AGGREGATE);
142

  
131 143
        // Register the geometries in 3D
132 144
//        geometryManager.registerGeometryType(DefaultNullGeometry.class, TYPES.NULL, SUBTYPES.GEOM3D);
133 145

  
134 146
        // Register points in 3D
135 147
//        geometryManager.registerGeometryType(new Point3DGeometryType());
148
        geometryManager.registerGeometryType(Point3D.class, "Point3D", TYPES.POINT, SUBTYPES.GEOM3D);
149
        geometryManager.registerGeometryType(Point3DM.class, "Point3DM", TYPES.POINT, SUBTYPES.GEOM3DM);
136 150

  
137 151
        // Register curves in 3D
138 152
//        geometryManager.registerGeometryType(Line2DZ.class, "Curve3D", TYPES.CURVE, SUBTYPES.GEOM3D, new int[0],
139 153
//            new int[] { SUBTYPES.GEOM2D });
140
//        geometryManager.registerGeometryType(Arc2DZ.class, "Arc3D", TYPES.ARC, SUBTYPES.GEOM3D, TYPES.CURVE,
141
//            SUBTYPES.GEOM2D);
142
//        geometryManager.registerGeometryType(Spline2DZ.class, "Spline3D", TYPES.SPLINE, SUBTYPES.GEOM3D, TYPES.CURVE,
143
//            SUBTYPES.GEOM2D);
154
        geometryManager.registerGeometryType(Line3D.class, "Line3D", TYPES.LINE, SUBTYPES.GEOM3D);
155
        geometryManager.registerGeometryType(Arc2DZ.class, "Arc3D", TYPES.ARC, SUBTYPES.GEOM3D, TYPES.CURVE,
156
            SUBTYPES.GEOM2D);
157
        geometryManager.registerGeometryType(Spline3D.class, "Spline3D", TYPES.SPLINE, SUBTYPES.GEOM3D, TYPES.CURVE,
158
            SUBTYPES.GEOM2D);
144 159

  
160
        // Register curves in 3DM
161
        geometryManager.registerGeometryType(Line3DM.class, "Line3DM", TYPES.LINE, SUBTYPES.GEOM3DM);
162
        geometryManager.registerGeometryType(Spline3DM.class, "Spline3DM", TYPES.SPLINE, SUBTYPES.GEOM3DM, TYPES.CURVE,
163
            SUBTYPES.GEOM2DM);
164

  
145 165
        // Register surfaces in 3D
146 166
        geometryManager.registerGeometryType(Polygon3D.class, "Polygon3D", TYPES.POLYGON, SUBTYPES.GEOM3D, new int[0],
147 167
            new int[] { SUBTYPES.GEOM3D });
......
160 180
//        geometryManager.registerGeometryType(MultiSurface3D.class, "MultiSurface3D", TYPES.MULTISURFACE,
161 181
//            SUBTYPES.GEOM3D, TYPES.AGGREGATE, SUBTYPES.GEOM2D);
162 182

  
183
        // Register multigeometries in 3DM
184
        geometryManager.registerGeometryType(MultiPoint3DM.class, "MultiPoint3DM", TYPES.MULTIPOINT, SUBTYPES.GEOM2DM,
185
            TYPES.AGGREGATE);
186

  
163 187
        // Register solids
164 188
//        geometryManager.registerGeometryType(Solid2DZ.class, "Solid3D", TYPES.SOLID, SUBTYPES.GEOM3D);
165 189
//        geometryManager.registerGeometryType(MultiSolid2DZ.class, "MultiSolid3D", TYPES.MULTISOLID, SUBTYPES.GEOM3D,
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/aggregate/AbstractMultiLine.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2015 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.fmap.geom.jts.aggregate;
24

  
25
import java.awt.Shape;
26
import java.awt.geom.AffineTransform;
27
import java.awt.geom.PathIterator;
28

  
29
import org.cresques.cts.ICoordTrans;
30

  
31
import org.gvsig.fmap.geom.Geometry;
32
import org.gvsig.fmap.geom.GeometryException;
33
import org.gvsig.fmap.geom.aggregate.MultiLine;
34
import org.gvsig.fmap.geom.aggregate.MultiPoint;
35
import org.gvsig.fmap.geom.aggregate.MultiPolygon;
36
import org.gvsig.fmap.geom.handler.Handler;
37
import org.gvsig.fmap.geom.operation.GeometryOperationException;
38
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
39
import org.gvsig.fmap.geom.primitive.GeneralPathX;
40

  
41

  
42
/**
43
 * @author fdiaz
44
 *
45
 */
46
public abstract class AbstractMultiLine extends AbstractMultiCurve implements MultiLine {
47

  
48
    /**
49
     *
50
     */
51
    private static final long serialVersionUID = 3585059833766514177L;
52

  
53
    /**
54
     * @param type
55
     */
56
    public AbstractMultiLine(int subtype) {
57
        super(subtype);
58
    }
59

  
60

  
61
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/aggregate/AbstractMultiPrimitive.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2015 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.fmap.geom.jts.aggregate;
24

  
25
import java.awt.Shape;
26
import java.awt.geom.AffineTransform;
27
import java.awt.geom.PathIterator;
28

  
29
import org.cresques.cts.ICoordTrans;
30

  
31
import org.gvsig.fmap.geom.Geometry;
32
import org.gvsig.fmap.geom.aggregate.MultiPrimitive;
33
import org.gvsig.fmap.geom.handler.Handler;
34
import org.gvsig.fmap.geom.operation.GeometryOperationException;
35
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
36
import org.gvsig.fmap.geom.primitive.GeneralPathX;
37
import org.gvsig.fmap.geom.primitive.Primitive;
38

  
39

  
40
/**
41
 * @author fdiaz
42
 *
43
 */
44
public abstract class AbstractMultiPrimitive extends AbstractAggregate implements MultiPrimitive {
45

  
46
    /**
47
     *
48
     */
49
    private static final long serialVersionUID = -5993428771359742467L;
50

  
51
    /**
52
     * @param type
53
     * @param subtype
54
     */
55
    public AbstractMultiPrimitive(int type, int subtype) {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff