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

History | View | Annotate | Download (6.67 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.Polygon2DM;
39
import org.gvsig.fmap.geom.jts.primitive.surface.polygon.Polygon3DM;
40
import org.gvsig.fmap.geom.operation.GeometryOperationException;
41
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
42
import org.gvsig.fmap.geom.primitive.GeneralPathX;
43
import org.gvsig.fmap.geom.primitive.Primitive;
44
import org.gvsig.fmap.geom.primitive.Surface;
45

    
46

    
47
/**
48
 * @author fdiaz
49
 *
50
 */
51
public class MultiPolygon2DM extends AbstractMultiPolygon {
52

    
53

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

    
59
    /**
60
     * @param subtype
61
     */
62
    public MultiPolygon2DM() {
63
        super(Geometry.SUBTYPES.GEOM2DM);
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 MultiPoint2DM();
71
        for (Iterator<Primitive> iterator = primitives.iterator(); iterator.hasNext();) {
72
            Polygon2DM polygon = (Polygon2DM) 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
    /* (non-Javadoc)
106
     * @see org.gvsig.fmap.geom.aggregate.Aggregate#union()
107
     */
108
    public Geometry union() throws GeometryOperationException, GeometryOperationNotSupportedException {
109
        // TODO Auto-generated method stub
110
        return null;
111
    }
112

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

    
121
    /* (non-Javadoc)
122
     * @see org.gvsig.fmap.geom.Geometry#cloneGeometry()
123
     */
124
    public Geometry cloneGeometry() {
125
        // TODO Auto-generated method stub
126
        return null;
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

    
194
    /* (non-Javadoc)
195
     * @see org.gvsig.fmap.geom.jts.aggregate.AbstractMultiPrimitive#fixPrimitive(org.gvsig.fmap.geom.primitive.Primitive)
196
     */
197
    @Override
198
    protected Primitive fixPrimitive(Primitive primitive) {
199
        if(!(primitive instanceof Polygon2DM)){
200
            String message = "Only Polygon2DM primitives can be added to a MultiPolygon2DM";
201
            notifyDeprecated(message);
202
            throw new UnsupportedOperationException(message);
203
        }
204
        return primitive;
205
    }
206
}