Revision 42267 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/primitive/point/Point3DM.java
Point3DM.java | ||
---|---|---|
22 | 22 |
*/ |
23 | 23 |
package org.gvsig.fmap.geom.jts.primitive.point; |
24 | 24 |
|
25 |
import java.awt.geom.AffineTransform; |
|
26 |
import java.awt.geom.PathIterator; |
|
27 |
|
|
25 | 28 |
import com.vividsolutions.jts.geom.Coordinate; |
26 | 29 |
|
27 | 30 |
import org.gvsig.fmap.geom.Geometry; |
28 | 31 |
import org.gvsig.fmap.geom.GeometryLocator; |
29 | 32 |
import org.gvsig.fmap.geom.jts.MCoordinate; |
30 |
import org.gvsig.fmap.geom.jts.utils.JTSUtils; |
|
33 |
import org.gvsig.fmap.geom.jts.gputils.DefaultGeneralPathX; |
|
34 |
import org.gvsig.fmap.geom.jts.gputils.GeneralPathXIterator; |
|
35 |
import org.gvsig.fmap.geom.jts.primitive.point.Point3D.PointIterator; |
|
36 |
import org.gvsig.fmap.geom.jts.util.JTSUtils; |
|
37 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
|
31 | 38 |
import org.gvsig.fmap.geom.type.GeometryType; |
32 | 39 |
|
33 |
|
|
34 | 40 |
/** |
35 | 41 |
* @author fdiaz |
36 | 42 |
* |
... | ... | |
63 | 69 |
this(JTSUtils.createMCoordinate(x, y, z, m)); |
64 | 70 |
} |
65 | 71 |
|
72 |
public double getZ() { |
|
73 |
return this.coordinate.z; |
|
74 |
} |
|
75 |
|
|
66 | 76 |
public double getM() { |
67 |
return ((MCoordinate)this.coordinate).m; |
|
77 |
return ((MCoordinate) this.coordinate).m;
|
|
68 | 78 |
} |
69 | 79 |
|
70 |
|
|
71 |
/* (non-Javadoc) |
|
80 |
/* |
|
81 |
* (non-Javadoc) |
|
82 |
* |
|
72 | 83 |
* @see org.gvsig.fmap.geom.Geometry#getDimension() |
73 | 84 |
*/ |
74 | 85 |
public int getDimension() { |
75 | 86 |
return 4; |
76 | 87 |
} |
77 | 88 |
|
78 |
/* (non-Javadoc) |
|
89 |
/* |
|
90 |
* (non-Javadoc) |
|
91 |
* |
|
79 | 92 |
* @see org.gvsig.fmap.geom.Geometry#getGeometryType() |
80 | 93 |
*/ |
81 | 94 |
public GeometryType getGeometryType() { |
82 | 95 |
try { |
83 |
return GeometryLocator.getGeometryManager().getGeometryType(Geometry.TYPES.POINT, Geometry.SUBTYPES.GEOM3DM); |
|
96 |
return GeometryLocator.getGeometryManager() |
|
97 |
.getGeometryType(Geometry.TYPES.POINT, Geometry.SUBTYPES.GEOM3DM); |
|
84 | 98 |
} catch (Exception e) { |
85 | 99 |
return null; |
86 | 100 |
} |
87 | 101 |
} |
88 | 102 |
|
89 |
|
|
90 |
/* (non-Javadoc) |
|
103 |
/* |
|
104 |
* (non-Javadoc) |
|
105 |
* |
|
91 | 106 |
* @see org.gvsig.fmap.geom.Geometry#cloneGeometry() |
92 | 107 |
*/ |
93 | 108 |
public Geometry cloneGeometry() { |
94 |
return new Point2DM((MCoordinate)this.coordinate.clone()); |
|
109 |
return new Point2DM((MCoordinate) this.coordinate.clone());
|
|
95 | 110 |
} |
96 | 111 |
|
97 |
/* (non-Javadoc) |
|
112 |
/* |
|
113 |
* (non-Javadoc) |
|
114 |
* |
|
98 | 115 |
* @see org.gvsig.fmap.geom.jts.GeometryJTS#is3D() |
99 | 116 |
*/ |
100 | 117 |
public boolean is3D() { |
101 | 118 |
return true; |
102 | 119 |
} |
103 | 120 |
|
104 |
/* (non-Javadoc) |
|
105 |
* @see org.gvsig.fmap.geom.jts.primitive.point.PointJTS#setJTSCoordinate(com.vividsolutions.jts.geom.Coordinate) |
|
121 |
/* |
|
122 |
* (non-Javadoc) |
|
123 |
* |
|
124 |
* @see |
|
125 |
* org.gvsig.fmap.geom.jts.primitive.point.PointJTS#setJTSCoordinate(com |
|
126 |
* .vividsolutions.jts.geom.Coordinate) |
|
106 | 127 |
*/ |
107 | 128 |
public void setJTSCoordinate(Coordinate coordinate) { |
108 | 129 |
this.coordinate = coordinate; |
109 | 130 |
} |
110 | 131 |
|
132 |
/* |
|
133 |
* (non-Javadoc) |
|
134 |
* |
|
135 |
* @see org.gvsig.fmap.geom.Geometry#getGeneralPath() |
|
136 |
*/ |
|
137 |
public GeneralPathX getGeneralPath() { |
|
138 |
return new DefaultGeneralPathX(new PointIterator(null), true, getZ()); |
|
139 |
} |
|
140 |
|
|
141 |
/* |
|
142 |
* (non-Javadoc) |
|
143 |
* |
|
144 |
* @see |
|
145 |
* org.gvsig.fmap.geom.Geometry#getPathIterator(java.awt.geom.AffineTransform |
|
146 |
* ) |
|
147 |
*/ |
|
148 |
public PathIterator getPathIterator(AffineTransform at) { |
|
149 |
PointIterator pi = new PointIterator(at); |
|
150 |
return pi; |
|
151 |
} |
|
152 |
|
|
153 |
public class PointIterator extends GeneralPathXIterator { |
|
154 |
|
|
155 |
/** Transform applied on the coordinates during iteration */ |
|
156 |
private AffineTransform at; |
|
157 |
|
|
158 |
/** True when the point has been read once */ |
|
159 |
private boolean done; |
|
160 |
|
|
161 |
/** |
|
162 |
* Creates a new PointIterator object. |
|
163 |
* |
|
164 |
* @param p |
|
165 |
* The polygon |
|
166 |
* @param at |
|
167 |
* The affine transform applied to coordinates during |
|
168 |
* iteration |
|
169 |
*/ |
|
170 |
public PointIterator(AffineTransform at) { |
|
171 |
super(new GeneralPathX()); |
|
172 |
if (at == null) { |
|
173 |
at = new AffineTransform(); |
|
174 |
} |
|
175 |
|
|
176 |
this.at = at; |
|
177 |
done = false; |
|
178 |
} |
|
179 |
|
|
180 |
/** |
|
181 |
* Return the winding rule for determining the interior of the path. |
|
182 |
* |
|
183 |
* @return <code>WIND_EVEN_ODD</code> by default. |
|
184 |
*/ |
|
185 |
public int getWindingRule() { |
|
186 |
return PathIterator.WIND_EVEN_ODD; |
|
187 |
} |
|
188 |
|
|
189 |
/** |
|
190 |
* @see java.awt.geom.PathIterator#next() |
|
191 |
*/ |
|
192 |
public void next() { |
|
193 |
done = true; |
|
194 |
} |
|
195 |
|
|
196 |
/** |
|
197 |
* @see java.awt.geom.PathIterator#isDone() |
|
198 |
*/ |
|
199 |
public boolean isDone() { |
|
200 |
return done; |
|
201 |
} |
|
202 |
|
|
203 |
/** |
|
204 |
* @see java.awt.geom.PathIterator#currentSegment(double[]) |
|
205 |
*/ |
|
206 |
public int currentSegment(double[] coords) { |
|
207 |
coords[0] = getX(); |
|
208 |
coords[1] = getY(); |
|
209 |
coords[2] = getZ(); |
|
210 |
at.transform(coords, 0, coords, 0, 1); |
|
211 |
|
|
212 |
return PathIterator.SEG_MOVETO; |
|
213 |
} |
|
214 |
|
|
215 |
/* |
|
216 |
* (non-Javadoc) |
|
217 |
* |
|
218 |
* @see java.awt.geom.PathIterator#currentSegment(float[]) |
|
219 |
*/ |
|
220 |
public int currentSegment(float[] coords) { |
|
221 |
coords[0] = (float) getX(); |
|
222 |
coords[1] = (float) getY(); |
|
223 |
coords[2] = (float) getZ(); |
|
224 |
|
|
225 |
at.transform(coords, 0, coords, 0, 1); |
|
226 |
|
|
227 |
return PathIterator.SEG_MOVETO; |
|
228 |
} |
|
229 |
} |
|
111 | 230 |
} |
Also available in: Unified diff