Revision 2196 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/shp/write/SHPMultiLine.java

View differences:

SHPMultiLine.java
40 40
 */
41 41
package com.iver.cit.gvsig.fmap.drivers.shp.write;
42 42

  
43
import java.awt.geom.PathIterator;
44
import java.awt.geom.Rectangle2D;
45
import java.nio.ByteBuffer;
46
import java.nio.MappedByteBuffer;
47
import java.util.ArrayList;
48

  
43 49
import com.iver.cit.gvsig.fmap.core.FPoint2D;
44 50
import com.iver.cit.gvsig.fmap.core.FPolyline2D;
45 51
import com.iver.cit.gvsig.fmap.core.GeneralPathX;
46 52
import com.iver.cit.gvsig.fmap.core.GeneralPathXIterator;
47 53
import com.iver.cit.gvsig.fmap.core.IGeometry;
54
import com.iver.cit.gvsig.fmap.core.IGeometry3D;
48 55
import com.iver.cit.gvsig.fmap.core.v02.FConstant;
56
import com.iver.cit.gvsig.fmap.drivers.shp.SHP;
49 57

  
50
import java.awt.geom.PathIterator;
51
import java.awt.geom.Rectangle2D;
52 58

  
53
import java.nio.ByteBuffer;
54
import java.nio.MappedByteBuffer;
55

  
56
import java.util.ArrayList;
57

  
58

  
59 59
/**
60 60
 * Elemento shape de tipo multil?nea.
61 61
 *
......
65 65
	private int m_type;
66 66
	protected int[] parts;
67 67
	protected FPoint2D[] points;
68
	protected double[] zs;
68 69

  
69 70
	/**
70 71
	 * Crea un nuevo SHPMultiLine.
......
138 139
	 * @see com.iver.cit.gvsig.fmap.shp.SHPShape#write(ByteBuffer, IGeometry)
139 140
	 */
140 141
	public void write(ByteBuffer buffer, IGeometry geometry) {
141
		//FPolyline2D polyLine = (FPolyline2D) geometry.getShape();
142 142
		Rectangle2D rec = geometry.getBounds2D();
143 143
		buffer.putDouble(rec.getMinX());
144 144
		buffer.putDouble(rec.getMinY());
145 145
		buffer.putDouble(rec.getMaxX());
146 146
		buffer.putDouble(rec.getMaxY());
147
		///obtainsPoints(geometry.getGeneralPathXIterator());
148

  
149
		//int[] parts=polyLine.getParts();
150
		//FPoint2D[] points=polyLine.getPoints();
151 147
		int numParts = parts.length;
152 148
		int npoints = points.length;
153

  
154
		//int numParts = polyLine.getNumParts();
155 149
		buffer.putInt(numParts);
156

  
157
		///int npoints = polyLine.getNumPoints();
158 150
		buffer.putInt(npoints);
159 151

  
160
		//Aqu? es posible que falle algo referente a Parts
161 152
		for (int i = 0; i < numParts; i++) {
162
			///buffer.putInt(polyLine.getPart(i));
163 153
			buffer.putInt(parts[i]);
164 154
		}
165 155

  
166
		/// FPoint2D[] points = polyLine.getPoints();
167 156
		for (int t = 0; t < npoints; t++) {
168 157
			buffer.putDouble(points[t].getX());
169 158
			buffer.putDouble(points[t].getY());
170 159
		}
171 160

  
172
		/*  if (m_type == FConstant.SHAPE_TYPE_POLYLINEZ) {
173
		   double[] zExtreame = JTSUtilities.zMinMax(points);
161
		  if (m_type == FConstant.SHAPE_TYPE_POLYLINEZ) {
162
		   double[] zExtreame = SHP.getZMinMax(zs);
174 163
		   if (Double.isNaN(zExtreame[0])) {
175 164
		       buffer.putDouble(0.0);
176 165
		       buffer.putDouble(0.0);
......
179 168
		       buffer.putDouble(zExtreame[1]);
180 169
		   }
181 170
		   for (int t = 0; t < npoints; t++) {
182
		       double z = points[t].z;
171
		       double z = zs[t];
183 172
		       if (Double.isNaN(z)) {
184 173
		           buffer.putDouble(0.0);
185 174
		       } else {
186 175
		           buffer.putDouble(z);
187 176
		       }
188 177
		   }
178
		  
189 179
		   }
190 180
		   if (m_type == FConstant.SHAPE_TYPE_POLYLINEM) {
191 181
		       buffer.putDouble(-10E40);
......
194 184
		           buffer.putDouble(-10E40);
195 185
		       }
196 186
		   }
197
		 */
187
		 
198 188
	}
199 189

  
200 190
	/**
201 191
	 * @see com.iver.cit.gvsig.fmap.shp.SHPShape#getLength(int)
202 192
	 */
203 193
	public int getLength(IGeometry fgeometry) {
204
		///FPolyline2D multi = (FPolyline2D) fgeometry.getShape();
205 194
		int numlines;
206 195
		int numpoints;
207 196
		int length;
208 197

  
209
		///obtainsPoints(fgeometry.getGeneralPathXIterator());
210

  
211
		//int[] parts=multi.getParts();
212
		//FPoint2D[] points=multi.getPoints();
213 198
		numlines = parts.length;
214 199
		numpoints = points.length;
215

  
216
		//numlines = multi.getNumParts();
217
		//numpoints = multi.getNumPoints();
218 200
		if (m_type == FConstant.SHAPE_TYPE_POLYLINE) {
219 201
			length = 44 + (4 * numlines) + (numpoints * 16);
220 202
		} else if (m_type == FConstant.SHAPE_TYPE_POLYLINEM) {
221 203
			length = 44 + (4 * numlines) + (numpoints * 16) + 8 + 8 +
222 204
				(8 * numpoints);
223 205
		} else if (m_type == FConstant.SHAPE_TYPE_POLYLINEZ) {
224
			length = 44 + (4 * numlines) + (numpoints * 16) + 8 + 8 +
225
				(8 * numpoints) + 8 + 8 + (8 * numpoints);
206
			length = 44 + (4 * numlines) + (numpoints * 16) +
207
				(8 * numpoints) + 8 + 8;
226 208
		} else {
227 209
			throw new IllegalStateException("Expected ShapeType of Arc, got " +
228 210
				m_type);
......
262 244
	/**
263 245
	 * @see com.iver.cit.gvsig.fmap.shp.SHPShape#obtainsPoints(com.iver.cit.gvsig.fmap.core.GeneralPathXIterator)
264 246
	 */
265
	public void obtainsPoints(GeneralPathXIterator iter) {
247
	public void obtainsPoints(IGeometry g) {
248
		if (FConstant.SHAPE_TYPE_POLYLINEZ == m_type || FConstant.SHAPE_TYPE_POLYGONZ == m_type){
249
			zs=((IGeometry3D)g).getZs();
250
		}
266 251
		ArrayList arrayPoints = null;
267 252
		ArrayList arrayParts = new ArrayList();
268
		GeneralPathXIterator theIterator = iter; //polyLine.getPathIterator(null, flatness);
253
		GeneralPathXIterator theIterator = g.getGeneralPathXIterator(); //polyLine.getPathIterator(null, flatness);
269 254
		double[] theData = new double[6];
270 255
		int numParts = 0;
271 256
		while (!theIterator.isDone()) {

Also available in: Unified diff