Revision 29097 branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/aggregate/impl/MultiPoint2D.java
MultiPoint2D.java | ||
---|---|---|
47 | 47 |
|
48 | 48 |
import org.cresques.cts.IProjection; |
49 | 49 |
import org.gvsig.fmap.geom.Geometry; |
50 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
51 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
52 | 50 |
import org.gvsig.fmap.geom.aggregate.MultiPoint; |
53 | 51 |
import org.gvsig.fmap.geom.handler.AbstractHandler; |
54 | 52 |
import org.gvsig.fmap.geom.primitive.Envelope; |
55 | 53 |
import org.gvsig.fmap.geom.primitive.FShape; |
56 | 54 |
import org.gvsig.fmap.geom.primitive.Point; |
57 |
import org.gvsig.fmap.geom.primitive.impl.DefaultEnvelope; |
|
58 | 55 |
import org.gvsig.fmap.geom.primitive.impl.Envelope2D; |
59 | 56 |
import org.gvsig.fmap.geom.primitive.impl.Point2D; |
60 | 57 |
import org.gvsig.fmap.geom.type.GeometryType; |
... | ... | |
66 | 63 |
*/ |
67 | 64 |
public class MultiPoint2D extends BaseMultiPrimitive implements MultiPoint { |
68 | 65 |
|
69 |
private static final long serialVersionUID = 1L; |
|
66 |
/** |
|
67 |
* The constructor with the GeometryType like and argument |
|
68 |
* is used by the {@link GeometryType}{@link #create()} |
|
69 |
* to create the geometry |
|
70 |
* @param type |
|
71 |
* The geometry type |
|
72 |
*/ |
|
73 |
public MultiPoint2D(GeometryType geometryType) { |
|
74 |
super(geometryType); |
|
75 |
} |
|
70 | 76 |
|
71 |
private static GeometryType geomType = GeometryLocator.getGeometryManager() |
|
72 |
.registerGeometryType(MultiPoint2D.class, null, TYPES.MULTIPOINT, SUBTYPES.GEOM2D); |
|
73 |
public static int CODE = geomType.getId(); |
|
74 |
|
|
75 | 77 |
/** |
76 |
* Constructor without arguments. It is necessary to create |
|
77 |
* geometries using the {@link GeometryType}{@link #create()} |
|
78 |
* method |
|
78 |
* |
|
79 |
* @param geometryType |
|
80 |
* @param id |
|
81 |
* @param projection |
|
79 | 82 |
*/ |
80 |
public MultiPoint2D() {
|
|
81 |
super();
|
|
83 |
MultiPoint2D(GeometryType geometryType, String id, IProjection projection) {
|
|
84 |
super(geometryType, id, projection);
|
|
82 | 85 |
} |
83 | 86 |
|
84 |
public MultiPoint2D(IProjection projection, Point2D[] points) { |
|
85 |
this(null, projection, points); |
|
87 |
/** |
|
88 |
* |
|
89 |
* @param geometryType |
|
90 |
* @param id |
|
91 |
* @param projection |
|
92 |
* @param points |
|
93 |
*/ |
|
94 |
public MultiPoint2D(GeometryType geometryType, String id, IProjection projection, Point2D[] points) { |
|
95 |
super(geometryType, id, projection, points); |
|
86 | 96 |
} |
87 |
|
|
88 |
public MultiPoint2D(Point2D[] points) { |
|
89 |
this(null, null, points); |
|
90 |
} |
|
91 |
|
|
92 |
public MultiPoint2D(IProjection projection) { |
|
93 |
this(null, projection, null); |
|
94 |
} |
|
95 |
|
|
96 |
public MultiPoint2D(String id, IProjection projection, Point2D[] points) { |
|
97 |
super(id, projection, points); |
|
98 |
} |
|
99 |
|
|
100 |
public MultiPoint2D(String id, IProjection projection) { |
|
101 |
this(id, projection, null); |
|
102 |
} |
|
103 |
|
|
104 |
public MultiPoint2D(double[] x, double[] y) { |
|
105 |
this(null, null, x, y); |
|
106 |
} |
|
107 |
|
|
97 |
|
|
98 |
|
|
99 |
|
|
108 | 100 |
/** |
109 |
* Crea un nuevo MultiPoint2D. |
|
110 |
* |
|
101 |
* |
|
102 |
* @param id |
|
103 |
* @param projection |
|
111 | 104 |
* @param x |
112 |
* DOCUMENT ME! |
|
113 | 105 |
* @param y |
114 |
* DOCUMENT ME! |
|
115 | 106 |
*/ |
116 |
public MultiPoint2D(String id, IProjection projection, double[] x,
|
|
107 |
MultiPoint2D(GeometryType geometryType, String id, IProjection projection, double[] x,
|
|
117 | 108 |
double[] y) { |
118 |
super(id, projection); |
|
109 |
super(geometryType, id, projection);
|
|
119 | 110 |
geometries = new ArrayList(); |
120 | 111 |
for (int i = 0; i < x.length; i++) { |
121 |
geometries.add(new Point2D(id, projection, x[i], y[i]));
|
|
112 |
geometries.add(new Point2D(x[i], y[i])); |
|
122 | 113 |
} |
123 | 114 |
} |
124 | 115 |
|
... | ... | |
128 | 119 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#cloneGeometry() |
129 | 120 |
*/ |
130 | 121 |
public Geometry cloneGeometry() { |
131 |
MultiPoint auxPoint = new MultiPoint2D(id, projection); |
|
122 |
MultiPoint auxPoint = new MultiPoint2D(geometryType, id, projection);
|
|
132 | 123 |
for (int i = 0; i < getPrimitivesNumber(); i++) { |
133 | 124 |
auxPoint.addPoint((Point)((Point) geometries.get(i)).cloneGeometry()); |
134 | 125 |
} |
... | ... | |
184 | 175 |
for (int i = 0; i < getNumgeometries(); i++) { |
185 | 176 |
aux[i] = (Point2D) ((Point)geometries.get(i)).cloneGeometry().getInternalShape(); |
186 | 177 |
} |
187 |
return (FShape) new MultiPoint2D(id, projection, aux); |
|
178 |
return (FShape) new MultiPoint2D(getGeometryType(), id, projection, aux);
|
|
188 | 179 |
} |
189 | 180 |
|
190 | 181 |
/** |
... | ... | |
276 | 267 |
} |
277 | 268 |
|
278 | 269 |
/* (non-Javadoc) |
279 |
* @see org.gvsig.fmap.geom.primitive.AbstractPrimitive#getGeometryType() |
|
280 |
*/ |
|
281 |
public GeometryType getGeometryType() { |
|
282 |
return geomType; |
|
283 |
} |
|
284 |
|
|
285 |
/* (non-Javadoc) |
|
286 |
* @see org.gvsig.fmap.geom.Geometry#getType() |
|
287 |
*/ |
|
288 |
public int getType() { |
|
289 |
return geomType.getType(); |
|
290 |
} |
|
291 |
|
|
292 |
/* (non-Javadoc) |
|
293 | 270 |
* @see org.gvsig.fmap.geom.aggregate.MultiPoint#addPoint(org.gvsig.fmap.geom.primitive.Point) |
294 | 271 |
*/ |
295 | 272 |
public void addPoint(Point point) { |
... | ... | |
302 | 279 |
public void setPoints(double[] x, double[] y) { |
303 | 280 |
geometries = new ArrayList(); |
304 | 281 |
for (int i = 0; i < x.length; i++) { |
305 |
geometries.add(new Point2D(id, projection, x[i], y[i]));
|
|
282 |
geometries.add(new Point2D(x[i], y[i])); |
|
306 | 283 |
} |
307 | 284 |
} |
308 | 285 |
|
Also available in: Unified diff