Revision 11012 branches/v10/extensions/extSDE/src/com/iver/cit/gvsig/fmap/drivers/sde/ArcSdeFeatureIterator.java
ArcSdeFeatureIterator.java | ||
---|---|---|
43 | 43 |
*/ |
44 | 44 |
package com.iver.cit.gvsig.fmap.drivers.sde; |
45 | 45 |
|
46 |
import java.awt.geom.PathIterator; |
|
46 | 47 |
import java.sql.SQLException; |
48 |
import java.util.ArrayList; |
|
49 |
import java.util.List; |
|
47 | 50 |
|
51 |
import com.esri.sde.sdk.client.SDEPoint; |
|
48 | 52 |
import com.esri.sde.sdk.client.SeColumnDefinition; |
53 |
import com.esri.sde.sdk.client.SeCoordinateReference; |
|
49 | 54 |
import com.esri.sde.sdk.client.SeException; |
50 | 55 |
import com.esri.sde.sdk.client.SeQuery; |
51 | 56 |
import com.esri.sde.sdk.client.SeRow; |
... | ... | |
54 | 59 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
55 | 60 |
import com.iver.cit.gvsig.fmap.DriverException; |
56 | 61 |
import com.iver.cit.gvsig.fmap.core.DefaultFeature; |
62 |
import com.iver.cit.gvsig.fmap.core.FMultiPoint2D; |
|
57 | 63 |
import com.iver.cit.gvsig.fmap.core.FNullGeometry; |
58 | 64 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
65 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
59 | 66 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
60 | 67 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
61 | 68 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
... | ... | |
72 | 79 |
private boolean bFirst; |
73 | 80 |
Value[] regAtt; |
74 | 81 |
SeRow row; |
82 |
private int index=0; |
|
75 | 83 |
|
76 | 84 |
static GeneralPathX convertSeShapeToGeneralPathX(SeShape spVal) throws SeException |
77 | 85 |
{ |
... | ... | |
158 | 166 |
return new FNullGeometry(); |
159 | 167 |
} |
160 | 168 |
|
169 |
|
|
170 |
public static SeShape constructShape(IGeometry geometry, SeCoordinateReference seSrs) { |
|
171 |
SeShape shape = null; |
|
172 |
|
|
173 |
try { |
|
174 |
shape = new SeShape(seSrs); |
|
175 |
} catch (SeException ex) { |
|
176 |
|
|
177 |
} |
|
178 |
|
|
179 |
// if (geometry.isEmpty()) { |
|
180 |
// return shape; |
|
181 |
// } |
|
182 |
|
|
183 |
int numParts=1; |
|
184 |
// GeometryCollection gcol = null; |
|
185 |
// |
|
186 |
// if (geometry instanceof GeometryCollection) { |
|
187 |
// gcol = (GeometryCollection) geometry; |
|
188 |
// } else { |
|
189 |
// Geometry[] geoms = { geometry }; |
|
190 |
// gcol = new GeometryFactory().createGeometryCollection(geoms); |
|
191 |
// } |
|
192 |
|
|
193 |
// List allPoints = new ArrayList(); |
|
194 |
// numParts = gcol.getNumGeometries(); |
|
195 |
|
|
196 |
int[] partOffsets = new int[numParts]; |
|
197 |
// Geometry geom; |
|
198 |
// Coordinate[] coords; |
|
199 |
// Coordinate c; |
|
200 |
SDEPoint[] points = getPoints(geometry); |
|
201 |
partOffsets[0]=points.length; |
|
202 |
// for (int currGeom = 0; currGeom < numParts; currGeom++) { |
|
203 |
// partOffsets[currGeom] = allPoints.size(); |
|
204 |
// geom = gcol.getGeometryN(currGeom); |
|
205 |
// |
|
206 |
// coords = geom.getCoordinates(); |
|
207 |
// |
|
208 |
// for (int i = 0; i < coords.length; i++) { |
|
209 |
// c = coords[i]; |
|
210 |
// allPoints.add(new SDEPoint(c.x, c.y)); |
|
211 |
// } |
|
212 |
// } |
|
213 |
|
|
214 |
// SDEPoint[] points = new SDEPoint[allPoints.size()]; |
|
215 |
// allPoints.toArray(points); |
|
216 |
|
|
217 |
try { |
|
218 |
if (geometry.getGeometryType()==FShape.POINT || geometry instanceof FMultiPoint2D) { |
|
219 |
shape.generatePoint(points.length, points); |
|
220 |
} else if (geometry.getGeometryType()==FShape.LINE) { |
|
221 |
shape |
|
222 |
.generateLine(points.length, numParts, partOffsets, |
|
223 |
points); |
|
224 |
} else { |
|
225 |
shape.generatePolygon(points.length, numParts, partOffsets, |
|
226 |
points); |
|
227 |
} |
|
228 |
} catch (SeException e) { |
|
229 |
e.printStackTrace(); |
|
230 |
} |
|
231 |
|
|
232 |
return shape; |
|
233 |
} |
|
234 |
|
|
235 |
private static SDEPoint[] getPoints(IGeometry g) { |
|
236 |
// if (FConstant.SHAPE_TYPE_MULTIPOINTZ == m_type){ |
|
237 |
// zs=((IGeometry3D)g).getZs(); |
|
238 |
// } |
|
239 |
PathIterator theIterator = g.getPathIterator(null); //polyLine.getPathIterator(null, flatness); |
|
240 |
double[] theData = new double[6]; |
|
241 |
ArrayList ps=new ArrayList(); |
|
242 |
while (!theIterator.isDone()) { |
|
243 |
//while not done |
|
244 |
int theType = theIterator.currentSegment(theData); |
|
245 |
|
|
246 |
ps.add(new SDEPoint(theData[0], theData[1])); |
|
247 |
theIterator.next(); |
|
248 |
} //end while loop |
|
249 |
SDEPoint[] points = (SDEPoint[])ps.toArray(new SDEPoint[0]); |
|
250 |
return points; |
|
251 |
} |
|
252 |
|
|
253 |
|
|
254 |
|
|
255 |
|
|
161 | 256 |
/** |
162 | 257 |
* @throws SQLException |
163 | 258 |
* |
... | ... | |
175 | 270 |
numColumns = row.getNumColumns(); |
176 | 271 |
regAtt = new Value[numColumns-1]; |
177 | 272 |
bFirst = true; |
273 |
SeColumnDefinition[] colDefs = row.getColumns(); |
|
274 |
for (int i=0; i<colDefs.length;i++){ |
|
275 |
if (colDefs[i].getName().equals("OBJECTID")){ |
|
276 |
index=i; |
|
277 |
} |
|
278 |
} |
|
178 | 279 |
} catch (SeException e) { |
179 | 280 |
// TODO Auto-generated catch block |
180 | 281 |
e.printStackTrace(); |
... | ... | |
214 | 315 |
IFeature feat = null; |
215 | 316 |
try |
216 | 317 |
{ |
318 |
|
|
217 | 319 |
if ( row != null ) |
218 | 320 |
{ |
219 | 321 |
for (int colNum = 0; colNum < colDefs.length; colNum++) |
... | ... | |
255 | 357 |
} // End switch |
256 | 358 |
} // End if |
257 | 359 |
} // for |
258 |
// System.out.println("Dentro de next(): " + spVal.getFeatureId().toString() + " " + regAtt[0]);
|
|
360 |
//System.out.println("Dentro de next(): " + spVal.getFeatureId().longValue() + " " + regAtt[0]);
|
|
259 | 361 |
|
260 |
feat = new DefaultFeature(geom, regAtt, "" + spVal.getFeatureId().longValue());
|
|
362 |
feat = new DefaultFeature(geom, regAtt,String.valueOf(regAtt[index-1]));//""+ spVal.getFeatureId().longValue());
|
|
261 | 363 |
} // if |
262 | 364 |
|
263 | 365 |
|
Also available in: Unified diff