svn-gvsig-desktop / 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 / MultiPoint3DM.java @ 42271
History | View | Annotate | Download (5.41 KB)
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.util.Iterator; |
26 |
|
27 |
import org.gvsig.fmap.geom.Geometry; |
28 |
import org.gvsig.fmap.geom.GeometryException; |
29 |
import org.gvsig.fmap.geom.aggregate.MultiLine; |
30 |
import org.gvsig.fmap.geom.aggregate.MultiPoint; |
31 |
import org.gvsig.fmap.geom.aggregate.MultiPolygon; |
32 |
import org.gvsig.fmap.geom.jts.gputils.DefaultGeneralPathX; |
33 |
import org.gvsig.fmap.geom.jts.primitive.curve.line.Line2D; |
34 |
import org.gvsig.fmap.geom.jts.primitive.curve.line.Line3DM; |
35 |
import org.gvsig.fmap.geom.jts.primitive.point.Point2D; |
36 |
import org.gvsig.fmap.geom.jts.primitive.point.Point3DM; |
37 |
import org.gvsig.fmap.geom.jts.primitive.surface.polygon.Polygon2D; |
38 |
import org.gvsig.fmap.geom.jts.primitive.surface.polygon.Polygon3DM; |
39 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
40 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
41 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
42 |
import org.gvsig.fmap.geom.primitive.Line; |
43 |
import org.gvsig.fmap.geom.primitive.Point; |
44 |
import org.gvsig.fmap.geom.primitive.Polygon; |
45 |
import org.gvsig.fmap.geom.primitive.Primitive; |
46 |
|
47 |
|
48 |
/**
|
49 |
* @author fdiaz
|
50 |
*
|
51 |
*/
|
52 |
public class MultiPoint3DM extends AbstractMultiPoint { |
53 |
|
54 |
/**
|
55 |
*
|
56 |
*/
|
57 |
private static final long serialVersionUID = -2230359991187613190L; |
58 |
|
59 |
/**
|
60 |
* @param subtype
|
61 |
*/
|
62 |
public MultiPoint3DM() {
|
63 |
super(Geometry.SUBTYPES.GEOM3DM);
|
64 |
} |
65 |
|
66 |
/* (non-Javadoc)
|
67 |
* @see org.gvsig.fmap.geom.aggregate.Aggregate#union()
|
68 |
*/
|
69 |
public Geometry union() throws GeometryOperationException, GeometryOperationNotSupportedException { |
70 |
// TODO Auto-generated method stub
|
71 |
return null; |
72 |
} |
73 |
|
74 |
/* (non-Javadoc)
|
75 |
* @see org.gvsig.fmap.geom.aggregate.Aggregate#intersection()
|
76 |
*/
|
77 |
public Geometry intersection() throws GeometryOperationException, GeometryOperationNotSupportedException { |
78 |
// TODO Auto-generated method stub
|
79 |
return null; |
80 |
} |
81 |
|
82 |
/* (non-Javadoc)
|
83 |
* @see org.gvsig.fmap.geom.Geometry#cloneGeometry()
|
84 |
*/
|
85 |
public Geometry cloneGeometry() {
|
86 |
MultiPoint3DM clone = new MultiPoint3DM();
|
87 |
for (Iterator<Primitive> iterator = primitives.iterator(); iterator.hasNext();) { |
88 |
Point point = (Point)iterator.next(); |
89 |
Point clonePoint = (Point)(point.cloneGeometry()); |
90 |
clone.addPoint(clonePoint); |
91 |
} |
92 |
return clone;
|
93 |
} |
94 |
|
95 |
/* (non-Javadoc)
|
96 |
* @see org.gvsig.fmap.geom.Geometry#getDimension()
|
97 |
*/
|
98 |
public int getDimension() { |
99 |
return 4; |
100 |
} |
101 |
|
102 |
/*
|
103 |
* (non-Javadoc)
|
104 |
*
|
105 |
* @see org.gvsig.fmap.geom.Geometry#getGeneralPath()
|
106 |
*/
|
107 |
public GeneralPathX getGeneralPath() {
|
108 |
return new DefaultGeneralPathX(new PointIterator(null), false, 0); |
109 |
} |
110 |
|
111 |
/* (non-Javadoc)
|
112 |
* @see org.gvsig.fmap.geom.aggregate.MultiLine#toPoints()
|
113 |
*/
|
114 |
public MultiPoint toPoints() throws GeometryException { |
115 |
return this; |
116 |
} |
117 |
|
118 |
/* (non-Javadoc)
|
119 |
* @see org.gvsig.fmap.geom.aggregate.MultiLine#toLines()
|
120 |
*/
|
121 |
public MultiLine toLines() throws GeometryException { |
122 |
MultiLine multiLine = new MultiLine2D();
|
123 |
Line line = new Line3DM(); |
124 |
line.ensureCapacity(primitives.size()); |
125 |
for (Iterator<Primitive> iterator = primitives.iterator(); iterator.hasNext();) { |
126 |
Point3DM point = (Point3DM) iterator.next(); |
127 |
line.addVertex(point); |
128 |
} |
129 |
multiLine.addPrimitive(line); |
130 |
return multiLine;
|
131 |
} |
132 |
|
133 |
/* (non-Javadoc)
|
134 |
* @see org.gvsig.fmap.geom.aggregate.MultiLine#toPolygons()
|
135 |
*/
|
136 |
public MultiPolygon toPolygons() throws GeometryException { |
137 |
MultiPolygon multiPolygon = new MultiPolygon2D();
|
138 |
Polygon polygon = new Polygon3DM(); |
139 |
polygon.ensureCapacity(primitives.size()); |
140 |
for (Iterator<Primitive> iterator = primitives.iterator(); iterator.hasNext();) { |
141 |
Point3DM point = (Point3DM) iterator.next(); |
142 |
polygon.addVertex(point); |
143 |
} |
144 |
multiPolygon.addPrimitive(polygon); |
145 |
return multiPolygon;
|
146 |
} |
147 |
|
148 |
/* (non-Javadoc)
|
149 |
* @see org.gvsig.fmap.geom.jts.aggregate.AbstractMultiPrimitive#fixPrimitive(org.gvsig.fmap.geom.primitive.Primitive)
|
150 |
*/
|
151 |
@Override
|
152 |
protected Primitive fixPrimitive(Primitive primitive) {
|
153 |
if(!(primitive instanceof Point3DM)){ |
154 |
String message = "Only Point3DM primitives can be added to a MultiPoint3DM"; |
155 |
notifyDeprecated(message); |
156 |
throw new UnsupportedOperationException(message); |
157 |
} |
158 |
return primitive;
|
159 |
} |
160 |
} |