root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / FPolyline3D.java @ 38563
History | View | Annotate | Download (3.21 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package com.iver.cit.gvsig.fmap.core; |
42 |
|
43 |
import java.awt.geom.PathIterator; |
44 |
|
45 |
import com.iver.cit.gvsig.fmap.core.v02.FConverter; |
46 |
|
47 |
/**
|
48 |
* Polilinea 3D.
|
49 |
*
|
50 |
* @author Vicente Caballero Navarro
|
51 |
*/
|
52 |
public class FPolyline3D extends FPolyline2D implements FShape3D { |
53 |
double[] pZ = null; |
54 |
|
55 |
/**
|
56 |
* Crea un nuevo Polyline3D.
|
57 |
*
|
58 |
* @param gpx GeneralPathX
|
59 |
* @param pZ Vector con la Z.
|
60 |
*/
|
61 |
public FPolyline3D(GeneralPathX gpx, double[] pZ) { |
62 |
super(gpx);
|
63 |
this.pZ = pZ;
|
64 |
} |
65 |
|
66 |
/**
|
67 |
* @see com.iver.cit.gvsig.fmap.core.FShape#getShapeType()
|
68 |
*/
|
69 |
public int getShapeType() { |
70 |
return FShape.LINE | FShape.Z;
|
71 |
} |
72 |
|
73 |
/**
|
74 |
* Devuelve un Array con todos los valores de Z.
|
75 |
*
|
76 |
* @return Array de Zs.
|
77 |
*/
|
78 |
public double[] getZs() { |
79 |
return pZ;
|
80 |
} |
81 |
|
82 |
/* (non-Javadoc)
|
83 |
* @see com.iver.cit.gvsig.fmap.core.FShape#cloneFShape()
|
84 |
*/
|
85 |
public FShape cloneFShape() {
|
86 |
return new FPolyline3D((GeneralPathX) gp.clone(), (double[]) pZ); |
87 |
} |
88 |
|
89 |
|
90 |
//
|
91 |
public String toText(){ |
92 |
StringBuffer str = new StringBuffer(); |
93 |
//Ojo eldriver postgis no tiene en cuenta capas
|
94 |
//de tipo no multi.Cambiar a static.
|
95 |
str.append("MULTILINESTRING");
|
96 |
str.append(" ((");
|
97 |
int theType;
|
98 |
double[] theData = new double[6]; |
99 |
|
100 |
PathIterator theIterator = getPathIterator(null, FConverter.FLATNESS); |
101 |
int i = 0; |
102 |
|
103 |
while (!theIterator.isDone()) {
|
104 |
//while not done
|
105 |
theType = theIterator.currentSegment(theData); |
106 |
|
107 |
double m = 0.0; |
108 |
if (i < pZ.length){
|
109 |
m = pZ[i]; |
110 |
} |
111 |
|
112 |
switch (theType) {
|
113 |
case PathIterator.SEG_MOVETO: |
114 |
str.append(theData[0] + " " + theData[1] + " " + m + ","); |
115 |
break;
|
116 |
|
117 |
case PathIterator.SEG_LINETO: |
118 |
str.append(theData[0] + " " + theData[1] + " " + m + ","); |
119 |
|
120 |
break;
|
121 |
|
122 |
case PathIterator.SEG_QUADTO: |
123 |
System.out.println("Not supported here"); |
124 |
|
125 |
break;
|
126 |
|
127 |
case PathIterator.SEG_CUBICTO: |
128 |
System.out.println("Not supported here"); |
129 |
|
130 |
break;
|
131 |
|
132 |
case PathIterator.SEG_CLOSE: |
133 |
break;
|
134 |
} //end switch
|
135 |
|
136 |
theIterator.next(); |
137 |
i++; |
138 |
} //end while loop
|
139 |
return str.delete(str.length()-1, str.length()) + "))"; |
140 |
} |
141 |
|
142 |
} |