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 / primitive / surface / polygon / Polygon2D.java @ 42275
History | View | Annotate | Download (5.13 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.primitive.surface.polygon; |
24 |
|
25 |
import java.awt.geom.AffineTransform; |
26 |
import java.awt.geom.PathIterator; |
27 |
import java.util.ArrayList; |
28 |
import java.util.List; |
29 |
|
30 |
import com.vividsolutions.jts.geom.Coordinate; |
31 |
|
32 |
import org.gvsig.fmap.geom.Geometry; |
33 |
import org.gvsig.fmap.geom.GeometryException; |
34 |
import org.gvsig.fmap.geom.aggregate.MultiLine; |
35 |
import org.gvsig.fmap.geom.aggregate.MultiPolygon; |
36 |
import org.gvsig.fmap.geom.jts.aggregate.MultiLine2D; |
37 |
import org.gvsig.fmap.geom.jts.aggregate.MultiPolygon2D; |
38 |
import org.gvsig.fmap.geom.jts.primitive.curve.line.BaseLine2D; |
39 |
import org.gvsig.fmap.geom.jts.primitive.curve.line.Line2D; |
40 |
import org.gvsig.fmap.geom.jts.util.JTSUtils; |
41 |
import org.gvsig.fmap.geom.primitive.Line; |
42 |
import org.gvsig.fmap.geom.primitive.Polygon; |
43 |
import org.gvsig.fmap.geom.primitive.Ring; |
44 |
import org.gvsig.fmap.geom.primitive.SurfaceAppearance; |
45 |
|
46 |
/**
|
47 |
* @author fdiaz
|
48 |
*
|
49 |
*/
|
50 |
public class Polygon2D extends BaseLine2D implements Polygon { |
51 |
|
52 |
/**
|
53 |
*
|
54 |
*/
|
55 |
private static final long serialVersionUID = 4927309852756014929L; |
56 |
|
57 |
List<Ring> interiorRings = new ArrayList<Ring>(); |
58 |
|
59 |
/**
|
60 |
* @param subtype
|
61 |
*/
|
62 |
public Polygon2D() {
|
63 |
super();
|
64 |
} |
65 |
|
66 |
/**
|
67 |
*
|
68 |
*/
|
69 |
public Polygon2D(Coordinate[] coordinates) { |
70 |
super(coordinates);
|
71 |
} |
72 |
|
73 |
/*
|
74 |
* (non-Javadoc)
|
75 |
*
|
76 |
* @see org.gvsig.fmap.geom.Geometry#cloneGeometry()
|
77 |
*/
|
78 |
public Geometry cloneGeometry() {
|
79 |
return new Polygon2D((Coordinate[]) coordinates.clone()); |
80 |
} |
81 |
|
82 |
/*
|
83 |
* (non-Javadoc)
|
84 |
*
|
85 |
* @see
|
86 |
* org.gvsig.fmap.geom.primitive.Surface#setSurfaceAppearance(org.gvsig.
|
87 |
* fmap.geom.primitive.SurfaceAppearance)
|
88 |
*/
|
89 |
public void setSurfaceAppearance(SurfaceAppearance app) { |
90 |
// TODO Auto-generated method stub
|
91 |
|
92 |
} |
93 |
|
94 |
/*
|
95 |
* (non-Javadoc)
|
96 |
*
|
97 |
* @see org.gvsig.fmap.geom.primitive.Surface#getSurfaceAppearance()
|
98 |
*/
|
99 |
public SurfaceAppearance getSurfaceAppearance() {
|
100 |
// TODO Auto-generated method stub
|
101 |
return null; |
102 |
} |
103 |
|
104 |
/*
|
105 |
* (non-Javadoc)
|
106 |
*
|
107 |
* @see org.gvsig.fmap.geom.primitive.Surface#getNumInteriorRings()
|
108 |
*/
|
109 |
public int getNumInteriorRings() { |
110 |
return interiorRings.size();
|
111 |
} |
112 |
|
113 |
/*
|
114 |
* (non-Javadoc)
|
115 |
*
|
116 |
* @see org.gvsig.fmap.geom.primitive.Surface#getInteriorRing(int)
|
117 |
*/
|
118 |
public Ring getInteriorRing(int index) { |
119 |
return interiorRings.get(index);
|
120 |
} |
121 |
|
122 |
/*
|
123 |
* (non-Javadoc)
|
124 |
*
|
125 |
* @see
|
126 |
* org.gvsig.fmap.geom.primitive.Surface#addInteriorRing(org.gvsig.fmap.
|
127 |
* geom.primitive.Ring)
|
128 |
*/
|
129 |
public void addInteriorRing(Ring ring) { |
130 |
interiorRings.add(ring); |
131 |
} |
132 |
|
133 |
/*
|
134 |
* (non-Javadoc)
|
135 |
*
|
136 |
* @see org.gvsig.fmap.geom.primitive.Surface#removeInteriorRing(int)
|
137 |
*/
|
138 |
public void removeInteriorRing(int index) { |
139 |
interiorRings.remove(index); |
140 |
} |
141 |
|
142 |
/*
|
143 |
* (non-Javadoc)
|
144 |
*
|
145 |
* @see
|
146 |
* org.gvsig.fmap.geom.primitive.Surface#addInteriorRing(org.gvsig.fmap.
|
147 |
* geom.primitive.Line)
|
148 |
*/
|
149 |
public void addInteriorRing(Line ring) { |
150 |
interiorRings.add((Ring)ring); //FIXME: ?????
|
151 |
} |
152 |
|
153 |
/* (non-Javadoc)
|
154 |
* @see org.gvsig.fmap.geom.primitive.Line#toLines()
|
155 |
*/
|
156 |
public MultiLine toLines() throws GeometryException { |
157 |
MultiLine multiLine = new MultiLine2D();
|
158 |
multiLine.addPrimitive(new Line2D(coordinates.toCoordinateArray())); |
159 |
return multiLine;
|
160 |
} |
161 |
|
162 |
/* (non-Javadoc)
|
163 |
* @see org.gvsig.fmap.geom.primitive.Line#toPolygons()
|
164 |
*/
|
165 |
public MultiPolygon toPolygons() throws GeometryException { |
166 |
MultiPolygon multiPolygon = new MultiPolygon2D();
|
167 |
multiPolygon.addPrimitive(this);
|
168 |
return multiPolygon;
|
169 |
} |
170 |
|
171 |
/* (non-Javadoc)
|
172 |
* @see org.gvsig.fmap.geom.jts.GeometryJTS#getJTS()
|
173 |
*/
|
174 |
public com.vividsolutions.jts.geom.Geometry getJTS() {
|
175 |
return JTSUtils.createJTSPolygon(coordinates, interiorRings);
|
176 |
} |
177 |
|
178 |
/*
|
179 |
* (non-Javadoc)
|
180 |
*
|
181 |
* @see
|
182 |
* org.gvsig.fmap.geom.Geometry#getPathIterator(java.awt.geom.AffineTransform
|
183 |
* )
|
184 |
*/
|
185 |
public PathIterator getPathIterator(AffineTransform at) { |
186 |
PolygonIterator pi = new PolygonIterator(this, at); |
187 |
return pi;
|
188 |
} |
189 |
} |