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 / MultiLine2DM.java @ 42271
History | View | Annotate | Download (6.64 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.awt.Shape; |
26 |
import java.awt.geom.AffineTransform; |
27 |
import java.awt.geom.PathIterator; |
28 |
import java.util.Iterator; |
29 |
|
30 |
import org.gvsig.fmap.geom.Geometry; |
31 |
import org.gvsig.fmap.geom.GeometryException; |
32 |
import org.gvsig.fmap.geom.aggregate.MultiLine; |
33 |
import org.gvsig.fmap.geom.aggregate.MultiPoint; |
34 |
import org.gvsig.fmap.geom.aggregate.MultiPolygon; |
35 |
import org.gvsig.fmap.geom.handler.Handler; |
36 |
import org.gvsig.fmap.geom.jts.primitive.curve.line.Line2DM; |
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 |
import org.gvsig.fmap.geom.primitive.Polygon; |
41 |
import org.gvsig.fmap.geom.primitive.Primitive; |
42 |
|
43 |
|
44 |
/**
|
45 |
* @author fdiaz
|
46 |
*
|
47 |
*/
|
48 |
public class MultiLine2DM extends AbstractMultiLine { |
49 |
|
50 |
|
51 |
/**
|
52 |
*
|
53 |
*/
|
54 |
private static final long serialVersionUID = 7970383739561430594L; |
55 |
|
56 |
/**
|
57 |
* @param type
|
58 |
* @param subtype
|
59 |
*/
|
60 |
public MultiLine2DM() {
|
61 |
super(Geometry.SUBTYPES.GEOM2DM);
|
62 |
} |
63 |
|
64 |
/* (non-Javadoc)
|
65 |
* @see org.gvsig.fmap.geom.aggregate.MultiLine#toPoints()
|
66 |
*/
|
67 |
public MultiPoint toPoints() throws GeometryException { |
68 |
MultiPoint multiPoint = new MultiPoint2DM();
|
69 |
for (Iterator<Primitive> iterator = primitives.iterator(); iterator.hasNext();) { |
70 |
Line2DM line = (Line2DM) iterator.next(); |
71 |
MultiPoint points = line.toPoints(); |
72 |
multiPoint.ensureCapacity(multiPoint.getPrimitivesNumber()+points.getPrimitivesNumber()); |
73 |
for(int i=0; i<points.getPrimitivesNumber(); i++){ |
74 |
multiPoint.addPoint(points.getPointAt(i)); |
75 |
} |
76 |
} |
77 |
return multiPoint;
|
78 |
} |
79 |
|
80 |
/* (non-Javadoc)
|
81 |
* @see org.gvsig.fmap.geom.aggregate.MultiLine#toLines()
|
82 |
*/
|
83 |
public MultiLine toLines() throws GeometryException { |
84 |
return this; |
85 |
} |
86 |
|
87 |
/* (non-Javadoc)
|
88 |
* @see org.gvsig.fmap.geom.aggregate.MultiLine#toPolygons()
|
89 |
*/
|
90 |
public MultiPolygon toPolygons() throws GeometryException { |
91 |
MultiPolygon multiPolygon = new MultiPolygon2DM();
|
92 |
for (Iterator<Primitive> iterator = primitives.iterator(); iterator.hasNext();) { |
93 |
Line2DM line = (Line2DM) iterator.next(); |
94 |
MultiPolygon polygons = line.toPolygons(); |
95 |
multiPolygon.ensureCapacity(multiPolygon.getPrimitivesNumber()+polygons.getPrimitivesNumber()); |
96 |
for(int i=0; i<polygons.getPrimitivesNumber(); i++){ |
97 |
multiPolygon.addSurface((Polygon)polygons.getPrimitiveAt(i));
|
98 |
} |
99 |
} |
100 |
return multiPolygon;
|
101 |
} |
102 |
|
103 |
|
104 |
/* (non-Javadoc)
|
105 |
* @see org.gvsig.fmap.geom.aggregate.Aggregate#union()
|
106 |
*/
|
107 |
public Geometry union() throws GeometryOperationException, GeometryOperationNotSupportedException { |
108 |
// TODO Auto-generated method stub
|
109 |
return null; |
110 |
} |
111 |
|
112 |
/* (non-Javadoc)
|
113 |
* @see org.gvsig.fmap.geom.aggregate.Aggregate#intersection()
|
114 |
*/
|
115 |
public Geometry intersection() throws GeometryOperationException, GeometryOperationNotSupportedException { |
116 |
// TODO Auto-generated method stub
|
117 |
return null; |
118 |
} |
119 |
|
120 |
/* (non-Javadoc)
|
121 |
* @see org.gvsig.fmap.geom.Geometry#cloneGeometry()
|
122 |
*/
|
123 |
public Geometry cloneGeometry() {
|
124 |
// TODO Auto-generated method stub
|
125 |
return null; |
126 |
} |
127 |
|
128 |
|
129 |
/* (non-Javadoc)
|
130 |
* @see org.gvsig.fmap.geom.Geometry#getDimension()
|
131 |
*/
|
132 |
public int getDimension() { |
133 |
// TODO Auto-generated method stub
|
134 |
return 0; |
135 |
} |
136 |
|
137 |
/* (non-Javadoc)
|
138 |
* @see org.gvsig.fmap.geom.Geometry#getShape(java.awt.geom.AffineTransform)
|
139 |
*/
|
140 |
public Shape getShape(AffineTransform affineTransform) { |
141 |
// TODO Auto-generated method stub
|
142 |
return null; |
143 |
} |
144 |
|
145 |
/* (non-Javadoc)
|
146 |
* @see org.gvsig.fmap.geom.Geometry#getShape()
|
147 |
*/
|
148 |
public Shape getShape() { |
149 |
// TODO Auto-generated method stub
|
150 |
return null; |
151 |
} |
152 |
|
153 |
/* (non-Javadoc)
|
154 |
* @see org.gvsig.fmap.geom.Geometry#getPathIterator(java.awt.geom.AffineTransform)
|
155 |
*/
|
156 |
public PathIterator getPathIterator(AffineTransform at) { |
157 |
// TODO Auto-generated method stub
|
158 |
return null; |
159 |
} |
160 |
|
161 |
/* (non-Javadoc)
|
162 |
* @see org.gvsig.fmap.geom.Geometry#getHandlers(int)
|
163 |
*/
|
164 |
public Handler[] getHandlers(int type) { |
165 |
// TODO Auto-generated method stub
|
166 |
return null; |
167 |
} |
168 |
|
169 |
/* (non-Javadoc)
|
170 |
* @see org.gvsig.fmap.geom.Geometry#getPathIterator(java.awt.geom.AffineTransform, double)
|
171 |
*/
|
172 |
public PathIterator getPathIterator(AffineTransform at, double flatness) { |
173 |
// TODO Auto-generated method stub
|
174 |
return null; |
175 |
} |
176 |
|
177 |
/* (non-Javadoc)
|
178 |
* @see org.gvsig.fmap.geom.Geometry#getGeneralPath()
|
179 |
*/
|
180 |
public GeneralPathX getGeneralPath() {
|
181 |
// TODO Auto-generated method stub
|
182 |
return null; |
183 |
} |
184 |
|
185 |
/* (non-Javadoc)
|
186 |
* @see org.gvsig.fmap.geom.jts.GeometryJTS#getJTS()
|
187 |
*/
|
188 |
public com.vividsolutions.jts.geom.Geometry getJTS() {
|
189 |
// TODO Auto-generated method stub
|
190 |
return null; |
191 |
} |
192 |
|
193 |
/* (non-Javadoc)
|
194 |
* @see org.gvsig.fmap.geom.jts.GeometryJTS#is3D()
|
195 |
*/
|
196 |
public boolean is3D() { |
197 |
// TODO Auto-generated method stub
|
198 |
return false; |
199 |
} |
200 |
|
201 |
/* (non-Javadoc)
|
202 |
* @see org.gvsig.fmap.geom.jts.aggregate.AbstractMultiLine#fixLine(org.gvsig.fmap.geom.primitive.Line)
|
203 |
*/
|
204 |
@Override
|
205 |
protected Primitive fixPrimitive(Primitive curve) {
|
206 |
if(!(curve instanceof Line2DM)){ |
207 |
String message = "Only Line2DM primitives can be added to a MultiLine2DM"; |
208 |
notifyDeprecated(message); |
209 |
throw new UnsupportedOperationException(message); |
210 |
} |
211 |
return curve;
|
212 |
} |
213 |
} |