svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_geometries / src / org / gvsig / fmap / geom / primitive / DefaultEnvelope.java @ 21178
History | View | Annotate | Download (5.52 KB)
1 |
|
---|---|
2 |
/* gvSIG. Geographic Information System of the Valencian Government
|
3 |
*
|
4 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
5 |
* of the Valencian Government (CIT)
|
6 |
*
|
7 |
* This program is free software; you can redistribute it and/or
|
8 |
* modify it under the terms of the GNU General Public License
|
9 |
* as published by the Free Software Foundation; either version 2
|
10 |
* of the License, or (at your option) any later version.
|
11 |
*
|
12 |
* This program is distributed in the hope that it will be useful,
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
* GNU General Public License for more details.
|
16 |
*
|
17 |
* You should have received a copy of the GNU General Public License
|
18 |
* along with this program; if not, write to the Free Software
|
19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
20 |
* MA 02110-1301, USA.
|
21 |
*
|
22 |
*/
|
23 |
|
24 |
/*
|
25 |
* AUTHORS (In addition to CIT):
|
26 |
* ${year} IVER T.I. S.A. {{Task}}
|
27 |
*/
|
28 |
|
29 |
/* gvSIG. Geographic Information System of the Valencian Government
|
30 |
*
|
31 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
32 |
* of the Valencian Government (CIT)
|
33 |
*
|
34 |
* This program is free software; you can redistribute it and/or
|
35 |
* modify it under the terms of the GNU General Public License
|
36 |
* as published by the Free Software Foundation; either version 2
|
37 |
* of the License, or (at your option) any later version.
|
38 |
*
|
39 |
* This program is distributed in the hope that it will be useful,
|
40 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
41 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
42 |
* GNU General Public License for more details.
|
43 |
*
|
44 |
* You should have received a copy of the GNU General Public License
|
45 |
* along with this program; if not, write to the Free Software
|
46 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
47 |
* MA 02110-1301, USA.
|
48 |
*
|
49 |
*/
|
50 |
/*
|
51 |
* AUTHORS (In addition to CIT):
|
52 |
* ${year} IVER T.I. S.A. {{Task}}
|
53 |
*/
|
54 |
/* gvSIG. Geographic Information System of the Valencian Government
|
55 |
*
|
56 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
57 |
* of the Valencian Government (CIT)
|
58 |
*
|
59 |
* This program is free software; you can redistribute it and/or
|
60 |
* modify it under the terms of the GNU General Public License
|
61 |
* as published by the Free Software Foundation; either version 2
|
62 |
* of the License, or (at your option) any later version.
|
63 |
*
|
64 |
* This program is distributed in the hope that it will be useful,
|
65 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
66 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
67 |
* GNU General Public License for more details.
|
68 |
*
|
69 |
* You should have received a copy of the GNU General Public License
|
70 |
* along with this program; if not, write to the Free Software
|
71 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
72 |
* MA 02110-1301, USA.
|
73 |
*
|
74 |
*/
|
75 |
/*
|
76 |
* AUTHORS (In addition to CIT):
|
77 |
* ${year} IVER T.I. S.A. {{Task}}
|
78 |
*/
|
79 |
package org.gvsig.fmap.geom.primitive; |
80 |
|
81 |
|
82 |
/**
|
83 |
* A minimum bounding box or rectangle. Regardless of dimension, an Envelope
|
84 |
* can be represented without ambiguity as two direct positions (coordinate
|
85 |
* points). To encode an Envelope, it is sufficient to encode these two
|
86 |
* points. This is consistent with all of the data types in this
|
87 |
* specification, their state is represented by their publicly accessible
|
88 |
* attributes.
|
89 |
|
90 |
* @author Vicente Caballero Navarro
|
91 |
*/
|
92 |
public class DefaultEnvelope implements Envelope{ |
93 |
private int dimensions = 0; |
94 |
private double[] min; |
95 |
private double[] max; |
96 |
|
97 |
public DefaultEnvelope(int dimensions, double[] min, double[] max) { |
98 |
this.dimensions = dimensions;
|
99 |
this.min = min;
|
100 |
this.max = max;
|
101 |
} |
102 |
|
103 |
/**
|
104 |
* Returns the center ordinate along the specified dimension.
|
105 |
*
|
106 |
* @param dimension DOCUMENT ME!
|
107 |
*
|
108 |
* @return DOCUMENT ME!
|
109 |
*/
|
110 |
public double getCenter(int dimension) { |
111 |
return (min[dimension] + max[dimension]) * 0.5; |
112 |
} |
113 |
|
114 |
/**
|
115 |
* The length of coordinate sequence (the number of entries) in this
|
116 |
* envelope.
|
117 |
*
|
118 |
* @return DOCUMENT ME!
|
119 |
*/
|
120 |
public int getDimension() { |
121 |
return dimensions;
|
122 |
} |
123 |
|
124 |
/**
|
125 |
* Returns the envelope length along the specified dimension.
|
126 |
*
|
127 |
* @param dimension
|
128 |
*
|
129 |
* @return
|
130 |
*/
|
131 |
public double getLength(int dimension) { |
132 |
if (max[dimension] > min[dimension]) {
|
133 |
return max[dimension] - min[dimension];
|
134 |
} |
135 |
|
136 |
return min[dimension] - max[dimension];
|
137 |
} |
138 |
|
139 |
/**
|
140 |
* A coordinate position consisting of all the minimal ordinates for each
|
141 |
* dimension for all points within the Envelope.
|
142 |
*
|
143 |
* @return
|
144 |
*/
|
145 |
public double[] getLowerCorner() { |
146 |
return min;
|
147 |
} |
148 |
|
149 |
/**
|
150 |
* Returns the maximal ordinate along the specified dimension.
|
151 |
*
|
152 |
* @param dimension
|
153 |
*
|
154 |
* @return
|
155 |
*/
|
156 |
public double getMaximum(int dimension) { |
157 |
return max[dimension];
|
158 |
} |
159 |
|
160 |
/**
|
161 |
* Returns the minimal ordinate along the specified dimension.
|
162 |
*
|
163 |
* @param dimension
|
164 |
*
|
165 |
* @return
|
166 |
*/
|
167 |
public double getMinimum(int dimension) { |
168 |
return min[dimension];
|
169 |
} |
170 |
|
171 |
/**
|
172 |
* A coordinate position consisting of all the maximal ordinates for each
|
173 |
* dimension for all points within the Envelope.
|
174 |
*
|
175 |
* @return
|
176 |
*/
|
177 |
public double[] getUpperCorner() { |
178 |
return max;
|
179 |
} |
180 |
|
181 |
public void add(Envelope boundsShp) { |
182 |
// TODO Auto-generated method stub
|
183 |
|
184 |
} |
185 |
} |