svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.oracle / src / org / gvsig / oracle / utils / LineString3D.java @ 30231
History | View | Annotate | Download (2.33 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 |
import org.gvsig.fmap.dal.store.oracle.OracleUtils; |
30 |
|
31 |
import com.vividsolutions.jts.geom.Coordinate; |
32 |
import com.vividsolutions.jts.geom.GeometryFactory; |
33 |
import com.vividsolutions.jts.geom.LineString; |
34 |
import com.vividsolutions.jts.geom.LinearRing; |
35 |
import com.vividsolutions.jts.geom.impl.CoordinateArraySequence; |
36 |
|
37 |
/**
|
38 |
* Utility class to manage 3D geometries. Keeps a LineString field and an array
|
39 |
* of Z.
|
40 |
*
|
41 |
* @author jldominguez
|
42 |
*/
|
43 |
public class LineString3D { |
44 |
private LineString ls;
|
45 |
private double[] zc; |
46 |
|
47 |
public LineString3D(LineString l, double[] z) { |
48 |
ls = l; |
49 |
zc = z; |
50 |
} |
51 |
|
52 |
public LineString getLs() {
|
53 |
return ls;
|
54 |
} |
55 |
|
56 |
public void setLs(LineString l) { |
57 |
ls = l; |
58 |
} |
59 |
|
60 |
public double[] getZc() { |
61 |
return zc;
|
62 |
} |
63 |
|
64 |
public void setZc(double[] z) { |
65 |
zc = z; |
66 |
} |
67 |
|
68 |
public LineString3D createReverse() {
|
69 |
double[] nz = null; |
70 |
|
71 |
if (zc != null) { |
72 |
nz = OracleUtils.reverseArray(zc); |
73 |
} |
74 |
|
75 |
Coordinate[] nc = OracleUtils.reverseCoordinateArray(ls
|
76 |
.getCoordinates()); |
77 |
GeometryFactory gf = new GeometryFactory();
|
78 |
CoordinateArraySequence ncs = new CoordinateArraySequence(nc);
|
79 |
LineString nls = null;
|
80 |
|
81 |
if (ls instanceof LinearRing) { |
82 |
nls = new LinearRing(ncs, gf);
|
83 |
} else {
|
84 |
nls = new LineString(ncs, gf);
|
85 |
} |
86 |
|
87 |
return new LineString3D(nls, nz); |
88 |
} |
89 |
} |