Revision 47604
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.shp/src/main/java/org/gvsig/fmap/dal/store/shp/utils/SHPMultiLine3DWriter.java | ||
---|---|---|
25 | 25 |
|
26 | 26 |
import java.nio.ByteBuffer; |
27 | 27 |
import java.util.ArrayList; |
28 |
|
|
29 |
import org.slf4j.Logger; |
|
30 |
import org.slf4j.LoggerFactory; |
|
31 |
|
|
32 | 28 |
import org.gvsig.fmap.dal.exception.WriteException; |
33 | 29 |
import org.gvsig.fmap.geom.Geometry; |
34 | 30 |
import org.gvsig.fmap.geom.GeometryException; |
... | ... | |
40 | 36 |
import org.gvsig.fmap.geom.primitive.Envelope; |
41 | 37 |
import org.gvsig.fmap.geom.primitive.Line; |
42 | 38 |
import org.gvsig.fmap.geom.primitive.Point; |
39 |
import org.slf4j.Logger; |
|
40 |
import org.slf4j.LoggerFactory; |
|
43 | 41 |
|
44 | 42 |
|
45 | 43 |
/** |
... | ... | |
72 | 70 |
* @throws WriteException |
73 | 71 |
* @see com.iver.cit.gvsig.fmap.shp.SHPShape#write(ByteBuffer, IGeometry) |
74 | 72 |
*/ |
75 |
public void write(ByteBuffer buffer) throws WriteException { |
|
76 |
Envelope env = geometry.getEnvelope(); |
|
73 |
public void write(ByteBuffer buffer) throws WriteException { |
|
74 |
try { |
|
75 |
Envelope env = geometry.getEnvelope(); |
|
77 | 76 |
|
78 |
buffer.putDouble(env.getMinimum(0));
|
|
79 |
buffer.putDouble(env.getMinimum(1));
|
|
80 |
buffer.putDouble(env.getMaximum(0));
|
|
81 |
buffer.putDouble(env.getMaximum(1));
|
|
77 |
buffer.putDouble(env.getMinimum(0));
|
|
78 |
buffer.putDouble(env.getMinimum(1));
|
|
79 |
buffer.putDouble(env.getMaximum(0));
|
|
80 |
buffer.putDouble(env.getMaximum(1));
|
|
82 | 81 |
|
83 |
try { |
|
84 | 82 |
initialize(geometry); |
85 |
} catch (GeometryException e) {
|
|
83 |
} catch (Exception e) { |
|
86 | 84 |
throw new WriteException("SHPMultiLine3D write", e); |
87 | 85 |
} |
88 | 86 |
|
89 |
double minM=Double.POSITIVE_INFINITY;
|
|
90 |
double maxM=Double.NEGATIVE_INFINITY;
|
|
91 |
double minZ=Double.POSITIVE_INFINITY;
|
|
92 |
double maxZ=Double.NEGATIVE_INFINITY;
|
|
93 |
int numParts = parts.length;
|
|
94 |
int npoints = points.length;
|
|
95 |
buffer.putInt(numParts);
|
|
96 |
buffer.putInt(npoints);
|
|
87 |
double minM = Double.POSITIVE_INFINITY;
|
|
88 |
double maxM = Double.NEGATIVE_INFINITY;
|
|
89 |
double minZ = Double.POSITIVE_INFINITY;
|
|
90 |
double maxZ = Double.NEGATIVE_INFINITY;
|
|
91 |
int numParts = parts.length;
|
|
92 |
int npoints = points.length;
|
|
93 |
buffer.putInt(numParts);
|
|
94 |
buffer.putInt(npoints);
|
|
97 | 95 |
|
98 |
for (int i = 0; i < numParts; i++) {
|
|
99 |
buffer.putInt(parts[i]);
|
|
100 |
}
|
|
96 |
for (int i = 0; i < numParts; i++) {
|
|
97 |
buffer.putInt(parts[i]);
|
|
98 |
}
|
|
101 | 99 |
|
102 |
for (int t = 0; t < npoints; t++) {
|
|
103 |
Point point = points[t];
|
|
100 |
for (int t = 0; t < npoints; t++) {
|
|
101 |
Point point = points[t];
|
|
104 | 102 |
buffer.putDouble(point.getX()); |
105 |
buffer.putDouble(point.getY());
|
|
103 |
buffer.putDouble(point.getY());
|
|
106 | 104 |
double z = point.getCoordinateAt(Geometry.DIMENSIONS.Z); |
107 |
if(z<minZ){
|
|
105 |
if (z < minZ) {
|
|
108 | 106 |
minZ = z; |
109 | 107 |
} |
110 |
if(z>maxZ){
|
|
108 |
if (z > maxZ) {
|
|
111 | 109 |
maxZ = z; |
112 | 110 |
} |
113 | 111 |
if (geometry.getGeometryType().getSubType() == Geometry.SUBTYPES.GEOM3DM) { |
114 |
double m = point.getCoordinateAt(point.getDimension()-1);
|
|
112 |
double m = point.getCoordinateAt(point.getDimension() - 1);
|
|
115 | 113 |
if (m < minM) { |
116 | 114 |
minM = m; |
117 | 115 |
} |
... | ... | |
119 | 117 |
maxM = m; |
120 | 118 |
} |
121 | 119 |
} |
122 |
}
|
|
120 |
}
|
|
123 | 121 |
buffer.putDouble(minZ); |
124 | 122 |
buffer.putDouble(maxZ); |
125 | 123 |
for (int t = 0; t < npoints; t++) { |
... | ... | |
131 | 129 |
buffer.putDouble(maxM); |
132 | 130 |
for (int t = 0; t < npoints; t++) { |
133 | 131 |
Point point = points[t]; |
134 |
buffer.putDouble(point.getCoordinateAt(point.getDimension()-1));
|
|
132 |
buffer.putDouble(point.getCoordinateAt(point.getDimension() - 1));
|
|
135 | 133 |
} |
136 | 134 |
} |
137 |
}
|
|
135 |
}
|
|
138 | 136 |
|
139 | 137 |
/** |
140 | 138 |
* @throws GeometryException |
Also available in: Unified diff