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 / util / ArrayListCoordinateSequence.java @ 42283
History | View | Annotate | Download (4.84 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.util; |
24 |
|
25 |
import java.util.ArrayList; |
26 |
import java.util.Collection; |
27 |
|
28 |
import com.vividsolutions.jts.geom.Coordinate; |
29 |
import com.vividsolutions.jts.geom.CoordinateSequence; |
30 |
import com.vividsolutions.jts.geom.Envelope; |
31 |
|
32 |
import org.gvsig.fmap.geom.jts.MCoordinate; |
33 |
|
34 |
/**
|
35 |
* @author fdiaz
|
36 |
*
|
37 |
*/
|
38 |
public class ArrayListCoordinateSequence extends ArrayList<com.vividsolutions.jts.geom.Coordinate> implements com.vividsolutions.jts.geom.CoordinateSequence { |
39 |
|
40 |
|
41 |
/**
|
42 |
*
|
43 |
*/
|
44 |
private static final long serialVersionUID = -6406449425908120065L; |
45 |
|
46 |
/**
|
47 |
*
|
48 |
*/
|
49 |
public ArrayListCoordinateSequence(Collection<com.vividsolutions.jts.geom.Coordinate> coordinates) { |
50 |
super(coordinates);
|
51 |
} |
52 |
|
53 |
/**
|
54 |
*
|
55 |
*/
|
56 |
public ArrayListCoordinateSequence() {
|
57 |
super();
|
58 |
} |
59 |
|
60 |
/* (non-Javadoc)
|
61 |
* @see com.vividsolutions.jts.geom.CoordinateSequence#getDimension()
|
62 |
*/
|
63 |
public int getDimension() { |
64 |
|
65 |
// FIXME: ?Esto es correcto?????
|
66 |
|
67 |
com.vividsolutions.jts.geom.Coordinate c = get(0);
|
68 |
if(c instanceof MCoordinate){ |
69 |
if(Double.isNaN(c.z)){ |
70 |
return 3; |
71 |
} else {
|
72 |
return 4; |
73 |
} |
74 |
} else {
|
75 |
if(Double.isNaN(c.z)){ |
76 |
return 2; |
77 |
} else {
|
78 |
return 3; |
79 |
} |
80 |
} |
81 |
} |
82 |
|
83 |
/* (non-Javadoc)
|
84 |
* @see com.vividsolutions.jts.geom.CoordinateSequence#getCoordinate(int)
|
85 |
*/
|
86 |
public com.vividsolutions.jts.geom.Coordinate getCoordinate(int i) { |
87 |
return (com.vividsolutions.jts.geom.Coordinate) get(i);
|
88 |
} |
89 |
|
90 |
/* (non-Javadoc)
|
91 |
* @see com.vividsolutions.jts.geom.CoordinateSequence#getCoordinateCopy(int)
|
92 |
*/
|
93 |
public com.vividsolutions.jts.geom.Coordinate getCoordinateCopy(int i) { |
94 |
return (com.vividsolutions.jts.geom.Coordinate) ((com.vividsolutions.jts.geom.Coordinate)get(i)).clone();
|
95 |
} |
96 |
|
97 |
/* (non-Javadoc)
|
98 |
* @see com.vividsolutions.jts.geom.CoordinateSequence#getCoordinate(int, com.vividsolutions.jts.geom.Coordinate)
|
99 |
*/
|
100 |
public void getCoordinate(int index, com.vividsolutions.jts.geom.Coordinate coord) { |
101 |
com.vividsolutions.jts.geom.Coordinate c = ((com.vividsolutions.jts.geom.Coordinate) get(index)); |
102 |
coord = new com.vividsolutions.jts.geom.Coordinate(c.x, c.y);
|
103 |
} |
104 |
|
105 |
/* (non-Javadoc)
|
106 |
* @see com.vividsolutions.jts.geom.CoordinateSequence#getX(int)
|
107 |
*/
|
108 |
public double getX(int index) { |
109 |
return ((com.vividsolutions.jts.geom.Coordinate) get(index)).x;
|
110 |
} |
111 |
|
112 |
/* (non-Javadoc)
|
113 |
* @see com.vividsolutions.jts.geom.CoordinateSequence#getY(int)
|
114 |
*/
|
115 |
public double getY(int index) { |
116 |
return ((com.vividsolutions.jts.geom.Coordinate) get(index)).y;
|
117 |
} |
118 |
|
119 |
/* (non-Javadoc)
|
120 |
* @see com.vividsolutions.jts.geom.CoordinateSequence#getOrdinate(int, int)
|
121 |
*/
|
122 |
public double getOrdinate(int index, int ordinateIndex) { |
123 |
return ((com.vividsolutions.jts.geom.Coordinate) get(index)).getOrdinate(ordinateIndex);
|
124 |
} |
125 |
|
126 |
/* (non-Javadoc)
|
127 |
* @see com.vividsolutions.jts.geom.CoordinateSequence#setOrdinate(int, int, double)
|
128 |
*/
|
129 |
public void setOrdinate(int index, int ordinateIndex, double value) { |
130 |
((com.vividsolutions.jts.geom.Coordinate) get(index)).setOrdinate(ordinateIndex, value); |
131 |
} |
132 |
|
133 |
/* (non-Javadoc)
|
134 |
* @see com.vividsolutions.jts.geom.CoordinateSequence#toCoordinateArray()
|
135 |
*/
|
136 |
public com.vividsolutions.jts.geom.Coordinate[] toCoordinateArray() { |
137 |
return ((com.vividsolutions.jts.geom.Coordinate[])(this.toArray(new Coordinate[this.size()]))); |
138 |
} |
139 |
|
140 |
/* (non-Javadoc)
|
141 |
* @see com.vividsolutions.jts.geom.CoordinateSequence#expandEnvelope(com.vividsolutions.jts.geom.Envelope)
|
142 |
*/
|
143 |
public Envelope expandEnvelope(Envelope env) {
|
144 |
for (int i = 0; i < this.size(); i++) { |
145 |
env.expandToInclude((com.vividsolutions.jts.geom.Coordinate) get(i)); |
146 |
} |
147 |
return env;
|
148 |
} |
149 |
} |