svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.oracle / src / org / gvsig / oracle / utils / LineString3D.java @ 29865
History | View | Annotate | Download (2.5 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2009 Prodevelop S.L. main development
|
26 |
*/
|
27 |
package org.gvsig.oracle.utils; |
28 |
|
29 |
|
30 |
import org.gvsig.fmap.dal.store.oracle.OracleUtils; |
31 |
|
32 |
import com.vividsolutions.jts.geom.Coordinate; |
33 |
import com.vividsolutions.jts.geom.GeometryFactory; |
34 |
import com.vividsolutions.jts.geom.LineString; |
35 |
import com.vividsolutions.jts.geom.LinearRing; |
36 |
import com.vividsolutions.jts.geom.impl.CoordinateArraySequence; |
37 |
|
38 |
|
39 |
/**
|
40 |
* Utility class to manage 3D geometries. Keeps a LineString field and an array
|
41 |
* of Z.
|
42 |
*
|
43 |
* @author jldominguez
|
44 |
*/
|
45 |
public class LineString3D { |
46 |
private LineString ls;
|
47 |
private double[] zc; |
48 |
|
49 |
public LineString3D(LineString l, double[] z) { |
50 |
ls = l; |
51 |
zc = z; |
52 |
} |
53 |
|
54 |
public LineString getLs() {
|
55 |
return ls;
|
56 |
} |
57 |
|
58 |
public void setLs(LineString l) { |
59 |
ls = l; |
60 |
} |
61 |
|
62 |
public double[] getZc() { |
63 |
return zc;
|
64 |
} |
65 |
|
66 |
public void setZc(double[] z) { |
67 |
zc = z; |
68 |
} |
69 |
|
70 |
public LineString3D createReverse() {
|
71 |
double[] nz = null; |
72 |
|
73 |
if (zc != null) { |
74 |
nz = OracleUtils.reverseArray(zc); |
75 |
} |
76 |
|
77 |
Coordinate[] nc = OracleUtils.reverseCoordinateArray(ls.getCoordinates());
|
78 |
GeometryFactory gf = new GeometryFactory();
|
79 |
CoordinateArraySequence ncs = new CoordinateArraySequence(nc);
|
80 |
LineString nls = null;
|
81 |
|
82 |
if (ls instanceof LinearRing) { |
83 |
nls = new LinearRing(ncs, gf);
|
84 |
} |
85 |
else {
|
86 |
nls = new LineString(ncs, gf);
|
87 |
} |
88 |
|
89 |
return new LineString3D(nls, nz); |
90 |
} |
91 |
} |