svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.geometry / org.gvsig.fmap.geometry.api / src / main / java / org / gvsig / fmap / geom / primitive / Envelope.java @ 43329
History | View | Annotate | Download (6.41 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it under
|
7 |
* the terms of the GNU General Public License as published by the Free Software
|
8 |
* Foundation; either version 3 of the License, or (at your option) any later
|
9 |
* version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
14 |
* details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License along with
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
19 |
*
|
20 |
* For any additional information, do not hesitate to contact us at info AT
|
21 |
* gvsig.com, or visit our website www.gvsig.com.
|
22 |
*/
|
23 |
package org.gvsig.fmap.geom.primitive; |
24 |
|
25 |
import java.awt.geom.AffineTransform; |
26 |
import org.cresques.cts.ICoordTrans; |
27 |
import org.gvsig.fmap.geom.Geometry; |
28 |
import org.gvsig.tools.lang.Cloneable; |
29 |
import org.gvsig.tools.persistence.Persistent; |
30 |
|
31 |
/**
|
32 |
* <p>
|
33 |
* This interface is equivalent to the GM_Envelope specified in
|
34 |
* <a
|
35 |
* href="http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=26012">ISO
|
36 |
* 19107</a>. A minimum bounding box or rectangle. Regardless of dimension, an
|
37 |
* Envelope can be represented without ambiguity as two direct positions
|
38 |
* (coordinate points). To encode an Envelope, it is sufficient to encode these
|
39 |
* two points. This is consistent with all of the data types in this
|
40 |
* specification, their state is represented by their publicly accessible
|
41 |
* attributes.
|
42 |
* </p>
|
43 |
*
|
44 |
* @see <a
|
45 |
* href="http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=26012">ISO
|
46 |
* 19107</a>
|
47 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
|
48 |
*/
|
49 |
public interface Envelope extends Persistent, Cloneable { |
50 |
|
51 |
/**
|
52 |
* Returns the center ordinate along the specified dimension.
|
53 |
*
|
54 |
* @param dimension. The dimension
|
55 |
* @return The value of the ordinate.
|
56 |
* @throws EnvelopeNotInitializedException if the envelope is empty.
|
57 |
*/
|
58 |
double getCenter(int dimension); |
59 |
|
60 |
/**
|
61 |
* The length of coordinate sequence (the number of entries) in this
|
62 |
* envelope.
|
63 |
*
|
64 |
* @return The dimension of the envelope.
|
65 |
*/
|
66 |
int getDimension();
|
67 |
|
68 |
/**
|
69 |
* Returns the envelope length along the specified dimension.
|
70 |
*
|
71 |
* @param dimension The dimension.
|
72 |
* @return The envelope length along a dimension.
|
73 |
* @throws EnvelopeNotInitializedException if the envelope is empty.
|
74 |
*/
|
75 |
double getLength(int dimension); |
76 |
|
77 |
/**
|
78 |
* A coordinate position consisting of all the minimal ordinates for each
|
79 |
* dimension for all points within the Envelope.
|
80 |
*
|
81 |
* @return The lower corner.
|
82 |
*/
|
83 |
Point getLowerCorner();
|
84 |
|
85 |
/**
|
86 |
* Sets the coordinate position consisting of all the minimal ordinates for
|
87 |
* each dimension for all points within the Envelope.
|
88 |
*
|
89 |
* @param point The lower corner.
|
90 |
*/
|
91 |
void setLowerCorner(Point point); |
92 |
|
93 |
/**
|
94 |
* Returns the maximal ordinate along the specified dimension.
|
95 |
*
|
96 |
* @param dimension The dimension.
|
97 |
* @return The maximum value
|
98 |
* @throws EnvelopeNotInitializedException if the envelope is empty.
|
99 |
*/
|
100 |
double getMaximum(int dimension); |
101 |
|
102 |
/**
|
103 |
* Returns the minimal ordinate along the specified dimension.
|
104 |
*
|
105 |
* @param dimension The dimension.
|
106 |
* @return The minimum value.
|
107 |
* @throws EnvelopeNotInitializedException if the envelope is empty.
|
108 |
*/
|
109 |
double getMinimum(int dimension); |
110 |
|
111 |
/**
|
112 |
* A coordinate position consisting of all the maximal ordinates for each
|
113 |
* dimension for all points within the Envelope.
|
114 |
*
|
115 |
* @return The upper corner
|
116 |
*/
|
117 |
Point getUpperCorner();
|
118 |
|
119 |
/**
|
120 |
* Sets the coordinate position consisting of all the maximal ordinates for
|
121 |
* each dimension for all points within the Envelope.
|
122 |
*
|
123 |
* @param upperCorner The upper corner.
|
124 |
*/
|
125 |
void setUpperCorner(Point upperCorner); |
126 |
|
127 |
/**
|
128 |
* Adds a envelope to the current envelope.
|
129 |
*
|
130 |
* If the envelope to add is null or empty do not modify the current
|
131 |
* enevelop and don't throw a exception.
|
132 |
*
|
133 |
* @param envelope The envelope to add.
|
134 |
*/
|
135 |
void add(Envelope envelope);
|
136 |
|
137 |
/**
|
138 |
* Utility method to add the envelop of geometry to the current envelope.
|
139 |
*
|
140 |
* Is equivalent to:
|
141 |
* <code>add(geometry.getEnvelope())</code>
|
142 |
*
|
143 |
* @param geometry The geometry to add.
|
144 |
*/
|
145 |
void add(Geometry geometry);
|
146 |
|
147 |
/**
|
148 |
* It returns the equivalent of an envelope like a geometry.
|
149 |
*
|
150 |
* @return A geometry that contains the same area that the envelope.
|
151 |
*
|
152 |
* @throws EnvelopeNotInitializedException if the envelope is empty.
|
153 |
*/
|
154 |
Geometry getGeometry(); |
155 |
|
156 |
/**
|
157 |
* Returns <code>true</code> if the new envelope is contained in the current
|
158 |
* envelope.
|
159 |
*
|
160 |
* @param envelope The envelope to compare.
|
161 |
* @return If the current envelope contains the new envelope
|
162 |
*/
|
163 |
boolean contains(Envelope envelope);
|
164 |
|
165 |
/**
|
166 |
* Returns <code>true</code> if the new envelope intersects with the current
|
167 |
* envelope.
|
168 |
*
|
169 |
* @param envelope The envelope to compare.
|
170 |
* @return If the current envelope intersects with the new envelope
|
171 |
*/
|
172 |
boolean intersects(Envelope envelope);
|
173 |
|
174 |
/**
|
175 |
* Returns <code>true</code> if the geometry intersects with the current
|
176 |
* envelope.
|
177 |
*
|
178 |
* @param geometry The geometry to compare.
|
179 |
* @return If the current envelope intersects with the geometry
|
180 |
*/
|
181 |
boolean intersects(Geometry geometry);
|
182 |
|
183 |
/**
|
184 |
* Converts the envelope to other coordinate reference system
|
185 |
*
|
186 |
* @param trans The CRS conversor
|
187 |
* @return A new envelope in other CRS
|
188 |
* @throws EnvelopeNotInitializedException if the envelope is empty.
|
189 |
*/
|
190 |
Envelope convert(ICoordTrans trans); |
191 |
|
192 |
/**
|
193 |
* Gets if the envelope is <code>null</code> or not. Is Empty means that the
|
194 |
* lower and upper corner are <code>null</code>.
|
195 |
*
|
196 |
* @return <code>null</code> or not if is empty.
|
197 |
*/
|
198 |
boolean isEmpty();
|
199 |
|
200 |
void clear();
|
201 |
|
202 |
/**
|
203 |
* Centers the envelope to a given point
|
204 |
* @param p Point to be centered
|
205 |
*/
|
206 |
public void centerTo(Point p); |
207 |
} |