Revision 21927 branches/Mobile_Compatible_Hito_1/libFMap_mobile_shp_driver/src-file/org/gvsig/data/datastores/vectorial/file/shp/utils/SHPMultiPoint.java

View differences:

SHPMultiPoint.java
54 54

  
55 55
/**
56 56
 * Elemento shape de tipo multipunto.
57
 *
57
 * 
58 58
 * @author Vicente Caballero Navarro
59 59
 */
60 60
public class SHPMultiPoint implements SHPShape {
61 61
	private int m_type;
62

  
62 63
	private int numpoints;
64

  
63 65
	private Point2D[] points;
66

  
64 67
	private double[] zs;
65 68

  
66 69
	/**
......
72 75

  
73 76
	/**
74 77
	 * Crea un nuevo SHPMultiPoint.
75
	 *
76
	 * @param type Tipo de multipunto.
77
	 *
78
	 * 
79
	 * @param type
80
	 *            Tipo de multipunto.
81
	 * 
78 82
	 * @throws ShapefileException
79 83
	 */
80 84
	public SHPMultiPoint(int type) {
81
		if ((type != SHP.MULTIPOINT2D) &&
82
				(type != SHP.MULTIPOINTM) &&
83
				(type != SHP.MULTIPOINT3D)) {
84
//			throw new ShapefileException("No es de tipo 8, 18, o 28");
85
		if ((type != SHP.MULTIPOINT2D) && (type != SHP.MULTIPOINTM)
86
				&& (type != SHP.MULTIPOINT3D)) {
87
			// throw new ShapefileException("No es de tipo 8, 18, o 28");
85 88
		}
86 89

  
87 90
		m_type = type;
......
89 92

  
90 93
	/**
91 94
	 * Devuelve el tipo de multipoint en concreto.
92
	 *
95
	 * 
93 96
	 * @return Tipo de multipoint.
94 97
	 */
95 98
	public int getShapeType() {
......
104 107
		double minY = buffer.getDouble();
105 108
		double maxX = buffer.getDouble();
106 109
		double maxY = buffer.getDouble();
107
		Rectangle2D rec = new Rectangle2D.Double(minX, minY, maxX - minX,
108
				maxY - maxY);
110
		Rectangle2D rec = new Rectangle2D.Double(minX, minY, maxX - minX, maxY
111
				- maxY);
109 112
		int numpoints = buffer.getInt();
110 113
		org.gvsig.fmap.geom.primitive.Point2D[] p = new org.gvsig.fmap.geom.primitive.Point2D[numpoints];
111 114

  
......
115 118
			p[t] = new org.gvsig.fmap.geom.primitive.Point2D(x, y);
116 119
		}
117 120

  
118
		/*   if (m_type == FConstant.SHAPE_TYPE_MULTIPOINTZ) {
119
		   buffer.position(buffer.position() + (2 * 8));
120
		   for (int t = 0; t < numpoints; t++) {
121
		       p[t].z = buffer.getDouble(); //z
122
		   }
123
		   }
121
		/*
122
		 * if (m_type == FConstant.SHAPE_TYPE_MULTIPOINTZ) {
123
		 * buffer.position(buffer.position() + (2 * 8)); for (int t = 0; t <
124
		 * numpoints; t++) { p[t].z = buffer.getDouble(); //z } }
124 125
		 */
125 126
		return (Geometry) new MultiPoint2D(p);
126 127
	}
......
137 138
		buffer.putDouble(box.getMinY());
138 139
		buffer.putDouble(box.getMaxX());
139 140
		buffer.putDouble(box.getMaxY());
140
		///obtainsPoints(geometry.getGeneralPathXIterator());
141
		// /obtainsPoints(geometry.getGeneralPathXIterator());
141 142
		buffer.putInt(numpoints);
142 143

  
143 144
		for (int t = 0, tt = numpoints; t < tt; t++) {
......
146 147
			buffer.putDouble(point.getY());
147 148
		}
148 149

  
149
		  if (m_type == SHP.MULTIPOINT3D) {
150
		   double[] zExtreame = SHP.getZMinMax(zs);
151
		   if (Double.isNaN(zExtreame[0])) {
152
		       buffer.putDouble(0.0);
153
		       buffer.putDouble(0.0);
154
		   } else {
155
		       buffer.putDouble(zExtreame[0]);
156
		       buffer.putDouble(zExtreame[1]);
157
		   }
158
		   for (int t = 0; t < numpoints; t++) {
159
		       double z = zs[t];
160
		       if (Double.isNaN(z)) {
161
		           buffer.putDouble(0.0);
162
		       } else {
163
		           buffer.putDouble(z);
164
		       }
165
		   }
166
		   }
167
		   if ((m_type == SHP.MULTIPOINTM) ||
168
		           (m_type == SHP.MULTIPOINT3D)) {
169
		       buffer.putDouble(-10E40);
170
		       buffer.putDouble(-10E40);
171
		       for (int t = 0; t < numpoints; t++) {
172
		           buffer.putDouble(-10E40);
173
		       }
174
		   }
150
		if (m_type == SHP.MULTIPOINT3D) {
151
			double[] zExtreame = SHP.getZMinMax(zs);
152
			if (Double.isNaN(zExtreame[0])) {
153
				buffer.putDouble(0.0);
154
				buffer.putDouble(0.0);
155
			} else {
156
				buffer.putDouble(zExtreame[0]);
157
				buffer.putDouble(zExtreame[1]);
158
			}
159
			for (int t = 0; t < numpoints; t++) {
160
				double z = zs[t];
161
				if (Double.isNaN(z)) {
162
					buffer.putDouble(0.0);
163
				} else {
164
					buffer.putDouble(z);
165
				}
166
			}
167
		}
168
		if ((m_type == SHP.MULTIPOINTM) || (m_type == SHP.MULTIPOINT3D)) {
169
			buffer.putDouble(-10E40);
170
			buffer.putDouble(-10E40);
171
			for (int t = 0; t < numpoints; t++) {
172
				buffer.putDouble(-10E40);
173
			}
174
		}
175 175

  
176 176
	}
177 177

  
......
179 179
	 * @see com.iver.cit.gvsig.fmap.shp.SHPShape#getLength(com.iver.cit.gvsig.core.BasicShape.FGeometry)
180 180
	 */
181 181
	public int getLength(Geometry fgeometry) {
182
		//FMultiPoint2D mp = (FMultiPoint2D) fgeometry.getShape();
183
		///obtainsPoints(fgeometry.getGeneralPathXIterator());
182
		// FMultiPoint2D mp = (FMultiPoint2D) fgeometry.getShape();
183
		// /obtainsPoints(fgeometry.getGeneralPathXIterator());
184 184

  
185 185
		int length;
186 186

  
......
194 194
			// add the additional ZMin,ZMax, plus 8 per Z
195 195
			length = (numpoints * 16) + 40 + 16 + (8 * numpoints);
196 196
		} else {
197
			throw new IllegalStateException("Expected ShapeType of Arc, got " +
198
				m_type);
197
			throw new IllegalStateException("Expected ShapeType of Arc, got "
198
					+ m_type);
199 199
		}
200 200

  
201 201
		return length;
......
205 205
	 * @see com.iver.cit.gvsig.fmap.drivers.shp.write.SHPShape#obtainsPoints(com.iver.cit.gvsig.fmap.core.GeneralPathXIterator)
206 206
	 */
207 207
	public void obtainsPoints(Geometry g) {
208
		if (SHP.MULTIPOINT3D == m_type){
209
			zs=((AbstractPrimitive)g).getZs();
208
		if (SHP.MULTIPOINT3D == m_type) {
209
			zs = ((AbstractPrimitive) g).getZs();
210 210
		}
211
		PathIterator theIterator = g.getPathIterator(null); //polyLine.getPathIterator(null, flatness);
211
		PathIterator theIterator = g.getPathIterator(null); // polyLine.getPathIterator(null,
212
															// flatness);
212 213
		double[] theData = new double[6];
213
		ArrayList ps=new ArrayList();
214
		ArrayList ps = new ArrayList();
214 215
		while (!theIterator.isDone()) {
215
			//while not done
216
			// while not done
216 217
			int theType = theIterator.currentSegment(theData);
217 218

  
218 219
			ps.add(new Point2D.Double(theData[0], theData[1]));
219 220
			theIterator.next();
220
		} //end while loop
221
		points=(Point2D[])ps.toArray(new Point2D.Double[0]);
222
		numpoints=points.length;
221
		} // end while loop
222
		points = (Point2D[]) ps.toArray(new Point2D.Double[0]);
223
		numpoints = points.length;
223 224
	}
224
//	public void setFlatness(double flatness) {
225
//		//this.flatness=flatness;
226
//	}
225
	// public void setFlatness(double flatness) {
226
	// //this.flatness=flatness;
227
	// }
227 228

  
228 229
}

Also available in: Unified diff