Statistics
| Revision:

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 / MultiPolygon2D.java @ 42271

History | View | Annotate | Download (6.9 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.Line2D;
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.Polygon;
44
import org.gvsig.fmap.geom.primitive.Primitive;
45
import org.gvsig.fmap.geom.primitive.Surface;
46

    
47

    
48
/**
49
 * @author fdiaz
50
 *
51
 */
52
public class MultiPolygon2D extends AbstractMultiPolygon {
53

    
54
    /**
55
     *
56
     */
57
    private static final long serialVersionUID = -7018238332611444136L;
58

    
59
    /**
60
     * @param subtype
61
     */
62
    public MultiPolygon2D() {
63
        super(Geometry.SUBTYPES.GEOM2D);
64
    }
65

    
66
    /* (non-Javadoc)
67
     * @see org.gvsig.fmap.geom.aggregate.MultiPolygon#toPoints()
68
     */
69
    public MultiPoint toPoints() throws GeometryException {
70
        MultiPoint multiPoint = new MultiPoint2D();
71
        for (Iterator<Primitive> iterator = primitives.iterator(); iterator.hasNext();) {
72
            Polygon2D polygon = (Polygon2D) iterator.next();
73
            MultiPoint points = polygon.toPoints();
74
            multiPoint.ensureCapacity(multiPoint.getPrimitivesNumber()+points.getPrimitivesNumber());
75
            for(int i=0; i<points.getPrimitivesNumber(); i++){
76
                multiPoint.addPoint(points.getPointAt(i));
77
            }
78
        }
79
        return multiPoint;
80
    }
81

    
82
    /* (non-Javadoc)
83
     * @see org.gvsig.fmap.geom.aggregate.MultiPolygon#toLines()
84
     */
85
    public MultiLine toLines() throws GeometryException {
86
        MultiLine multiLine = new MultiLine2D();
87
        for (Iterator<Primitive> iterator = primitives.iterator(); iterator.hasNext();) {
88
            Polygon2D polygon = (Polygon2D) iterator.next();
89
            MultiLine lines = polygon.toLines();
90
            multiLine.ensureCapacity(multiLine.getPrimitivesNumber()+lines.getPrimitivesNumber());
91
            for(int i=0; i<lines.getPrimitivesNumber(); i++){
92
                multiLine.addPrimitive((Line2D)lines.getPrimitiveAt(i));
93
            }
94
        }
95
        return multiLine;
96
    }
97

    
98
    /* (non-Javadoc)
99
     * @see org.gvsig.fmap.geom.aggregate.MultiPolygon#toPolygons()
100
     */
101
    public MultiPolygon toPolygons() throws GeometryException {
102
        return this;
103
    }
104

    
105

    
106
    /* (non-Javadoc)
107
     * @see org.gvsig.fmap.geom.aggregate.MultiSurface#getSurfaceAt(int)
108
     */
109
    public Surface getSurfaceAt(int index) {
110
        // TODO Auto-generated method stub
111
        return null;
112
    }
113

    
114
    /* (non-Javadoc)
115
     * @see org.gvsig.fmap.geom.aggregate.Aggregate#union()
116
     */
117
    public Geometry union() throws GeometryOperationException, GeometryOperationNotSupportedException {
118
        // TODO Auto-generated method stub
119
        return null;
120
    }
121

    
122
    /* (non-Javadoc)
123
     * @see org.gvsig.fmap.geom.aggregate.Aggregate#intersection()
124
     */
125
    public Geometry intersection() throws GeometryOperationException, GeometryOperationNotSupportedException {
126
        // TODO Auto-generated method stub
127
        return null;
128
    }
129

    
130
    /* (non-Javadoc)
131
     * @see org.gvsig.fmap.geom.Geometry#cloneGeometry()
132
     */
133
    public Geometry cloneGeometry() {
134
        // TODO Auto-generated method stub
135
        return null;
136
    }
137

    
138
    /* (non-Javadoc)
139
     * @see org.gvsig.fmap.geom.Geometry#getDimension()
140
     */
141
    public int getDimension() {
142
        // TODO Auto-generated method stub
143
        return 0;
144
    }
145

    
146
    /* (non-Javadoc)
147
     * @see org.gvsig.fmap.geom.Geometry#getShape(java.awt.geom.AffineTransform)
148
     */
149
    public Shape getShape(AffineTransform affineTransform) {
150
        // TODO Auto-generated method stub
151
        return null;
152
    }
153

    
154
    /* (non-Javadoc)
155
     * @see org.gvsig.fmap.geom.Geometry#getShape()
156
     */
157
    public Shape getShape() {
158
        // TODO Auto-generated method stub
159
        return null;
160
    }
161

    
162
    /* (non-Javadoc)
163
     * @see org.gvsig.fmap.geom.Geometry#getPathIterator(java.awt.geom.AffineTransform)
164
     */
165
    public PathIterator getPathIterator(AffineTransform at) {
166
        // TODO Auto-generated method stub
167
        return null;
168
    }
169

    
170
    /* (non-Javadoc)
171
     * @see org.gvsig.fmap.geom.Geometry#getHandlers(int)
172
     */
173
    public Handler[] getHandlers(int type) {
174
        // TODO Auto-generated method stub
175
        return null;
176
    }
177

    
178
    /* (non-Javadoc)
179
     * @see org.gvsig.fmap.geom.Geometry#getPathIterator(java.awt.geom.AffineTransform, double)
180
     */
181
    public PathIterator getPathIterator(AffineTransform at, double flatness) {
182
        // TODO Auto-generated method stub
183
        return null;
184
    }
185

    
186
    /* (non-Javadoc)
187
     * @see org.gvsig.fmap.geom.Geometry#getGeneralPath()
188
     */
189
    public GeneralPathX getGeneralPath() {
190
        // TODO Auto-generated method stub
191
        return null;
192
    }
193

    
194
    /* (non-Javadoc)
195
     * @see org.gvsig.fmap.geom.jts.GeometryJTS#getJTS()
196
     */
197
    public com.vividsolutions.jts.geom.Geometry getJTS() {
198
        // TODO Auto-generated method stub
199
        return null;
200
    }
201

    
202

    
203
    /* (non-Javadoc)
204
     * @see org.gvsig.fmap.geom.jts.aggregate.AbstractMultiPrimitive#fixPrimitive(org.gvsig.fmap.geom.primitive.Primitive)
205
     */
206
    @Override
207
    protected Primitive fixPrimitive(Primitive primitive) {
208
        if(!(primitive instanceof Polygon2D)){
209
            String message = "Only Polygon2D primitives can be added to a MultiPolygon2D";
210
            notifyDeprecated(message);
211
            throw new UnsupportedOperationException(message);
212
        }
213
        return primitive;
214
    }
215
}