Revision 41417
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.impl/src/main/java/org/gvsig/fmap/geom/primitive/impl/Envelope2D.java | ||
---|---|---|
188 | 188 |
public Object clone() throws CloneNotSupportedException { |
189 | 189 |
return super.clone(); |
190 | 190 |
} |
191 |
|
|
192 |
private void createPoints() { |
|
193 |
this.min = new Point2D(0, 0); |
|
194 |
this.max = new Point2D(0, 0); |
|
195 |
} |
|
196 |
|
|
197 |
public void add(Envelope envelope) { |
|
198 |
int i; |
|
199 |
if( envelope==null && envelope.isEmpty() ) { |
|
200 |
return; |
|
201 |
} |
|
202 |
if (isEmpty){ |
|
203 |
createPoints(); |
|
204 |
for (i=0;i<getDimension();i++){ |
|
205 |
this.min.setCoordinateAt(i, envelope.getMinimum(i)); |
|
206 |
this.max.setCoordinateAt(i, envelope.getMaximum(i)); |
|
207 |
} |
|
208 |
isEmpty = false; |
|
209 |
} else { |
|
210 |
for (i=0;i<getDimension();i++){ |
|
211 |
this.min.setCoordinateAt(i, |
|
212 |
Math.min(this.min.getCoordinateAt(i), envelope.getMinimum(i))); |
|
213 |
this.max.setCoordinateAt(i, |
|
214 |
Math.max(this.max.getCoordinateAt(i), envelope.getMaximum(i))); |
|
215 |
} |
|
216 |
} |
|
217 |
} |
|
191 | 218 |
} |
192 | 219 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.impl/src/main/java/org/gvsig/fmap/geom/primitive/impl/Envelope3D.java | ||
---|---|---|
37 | 37 |
*/ |
38 | 38 |
public class Envelope3D extends DefaultEnvelope implements Cloneable{ |
39 | 39 |
public static final String PERSISTENCE_DEFINITION_NAME = "Envelope3Dimensions"; |
40 |
|
|
40 |
private static final int DIMENSION = 3; |
|
41 |
private boolean isZInitilized =false; |
|
42 |
|
|
41 | 43 |
public Envelope3D() { |
42 | 44 |
super(); |
43 | 45 |
} |
... | ... | |
50 | 52 |
* @see org.gvsig.fmap.geom.primitive.Envelope#getDimension() |
51 | 53 |
*/ |
52 | 54 |
public int getDimension() { |
53 |
return 3;
|
|
55 |
return DIMENSION;
|
|
54 | 56 |
} |
55 | 57 |
|
56 | 58 |
/* |
... | ... | |
79 | 81 |
public Object clone() throws CloneNotSupportedException { |
80 | 82 |
return super.clone(); |
81 | 83 |
} |
84 |
|
|
85 |
|
|
86 |
private void createPoints() { |
|
87 |
this.min = new Point2DZ(0, 0, 0); |
|
88 |
this.max = new Point2DZ(0, 0, 0); |
|
89 |
} |
|
90 |
|
|
91 |
public void add(Envelope envelope) { |
|
92 |
int i; |
|
93 |
|
|
94 |
if( envelope==null && envelope.isEmpty() ) { |
|
95 |
return; |
|
96 |
} |
|
97 |
|
|
98 |
int maxDimension = DIMENSION; |
|
99 |
|
|
100 |
if( envelope.getDimension()==2 ) { |
|
101 |
maxDimension = 2; |
|
102 |
} |
|
103 |
|
|
104 |
if( this.isZInitilized ) { |
|
105 |
for (i=0;i<maxDimension;i++){ |
|
106 |
this.min.setCoordinateAt(i, |
|
107 |
Math.min(this.min.getCoordinateAt(i), envelope.getMinimum(i))); |
|
108 |
this.max.setCoordinateAt(i, |
|
109 |
Math.max(this.max.getCoordinateAt(i), envelope.getMaximum(i))); |
|
110 |
} |
|
111 |
return; |
|
112 |
} |
|
113 |
|
|
114 |
|
|
115 |
if (isEmpty){ |
|
116 |
createPoints(); |
|
117 |
if( maxDimension == 3 ) { |
|
118 |
this.isZInitilized = true; |
|
119 |
} |
|
120 |
for (i=0;i<maxDimension;i++){ |
|
121 |
this.min.setCoordinateAt(i, envelope.getMinimum(i)); |
|
122 |
this.max.setCoordinateAt(i, envelope.getMaximum(i)); |
|
123 |
} |
|
124 |
isEmpty = false; |
|
125 |
} else { |
|
126 |
if( maxDimension==DIMENSION ) { |
|
127 |
this.min.setCoordinateAt(2, envelope.getMinimum(2)); |
|
128 |
this.max.setCoordinateAt(2, envelope.getMaximum(2)); |
|
129 |
this.isZInitilized = true; |
|
130 |
} |
|
131 |
for (i=0;i<maxDimension;i++){ |
|
132 |
this.min.setCoordinateAt(i, |
|
133 |
Math.min(this.min.getCoordinateAt(i), envelope.getMinimum(i))); |
|
134 |
this.max.setCoordinateAt(i, |
|
135 |
Math.max(this.max.getCoordinateAt(i), envelope.getMaximum(i))); |
|
136 |
} |
|
137 |
} |
|
138 |
} |
|
82 | 139 |
} |
83 | 140 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.impl/src/main/java/org/gvsig/fmap/geom/primitive/impl/DefaultEnvelope.java | ||
---|---|---|
174 | 174 |
return max; |
175 | 175 |
} |
176 | 176 |
|
177 |
public void add(Envelope envelope) { |
|
178 |
if (isEmpty){ |
|
179 |
setLowerCorner((Point)envelope.getLowerCorner().cloneGeometry()); |
|
180 |
setUpperCorner((Point)envelope.getUpperCorner().cloneGeometry()); |
|
181 |
}else{ |
|
182 |
int maxDimension = Math.min(getDimension(), envelope.getDimension()); |
|
183 |
int i; |
|
184 |
for (i=0;i<maxDimension;i++){ |
|
185 |
this.min.setCoordinateAt(i, |
|
186 |
Math.min(this.min.getCoordinateAt(i), envelope.getMinimum(i))); |
|
187 |
this.max.setCoordinateAt(i, |
|
188 |
Math.max(this.max.getCoordinateAt(i), envelope.getMaximum(i))); |
|
189 |
} |
|
190 |
} |
|
191 |
} |
|
192 | 177 |
|
178 |
|
|
193 | 179 |
public Geometry getGeometry() { |
194 | 180 |
if (isEmpty){ |
195 | 181 |
throw new EnvelopeNotInitializedException(); |
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 | ||
---|---|---|
130 | 130 |
|
131 | 131 |
/** |
132 | 132 |
* Adds a envelope to the current envelope. |
133 |
* |
|
134 |
* If the envelope to add is null or empty do not modify the current |
|
135 |
* enevelop and don't throw a exception. |
|
136 |
* |
|
133 | 137 |
* @param envelope |
134 |
* The envelope to add. |
|
138 |
* The envelope to add.
|
|
135 | 139 |
*/ |
136 | 140 |
void add(Envelope envelope); |
137 | 141 |
|
138 | 142 |
/** |
139 | 143 |
* It returns the equivalent of an envelope like a geometry. |
144 |
* |
|
140 | 145 |
* @return |
141 |
* A geometry that contains the same area that the envelope. |
|
146 |
* A geometry that contains the same area that the envelope. |
|
147 |
* |
|
142 | 148 |
* @throws EnvelopeNotInitializedException |
143 |
* if the envelope is empty.
|
|
149 |
* if the envelope is empty.
|
|
144 | 150 |
*/ |
145 | 151 |
Geometry getGeometry(); |
146 | 152 |
|
Also available in: Unified diff