Revision 12037 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/featureiterators/SpatialQueryFeatureIterator.java
SpatialQueryFeatureIterator.java | ||
---|---|---|
45 | 45 |
* |
46 | 46 |
* $Id$ |
47 | 47 |
* $Log$ |
48 |
* Revision 1.1 2007-05-29 19:08:11 azabala |
|
48 |
* Revision 1.2 2007-06-06 18:03:03 azabala |
|
49 |
* bug fixed |
|
50 |
* |
|
51 |
* Revision 1.1 2007/05/29 19:08:11 azabala |
|
49 | 52 |
* first version in cvs |
50 | 53 |
* |
51 | 54 |
* Revision 1.1 2007/04/19 17:27:58 azabala |
... | ... | |
136 | 139 |
if(currentFeature >= source.getShapeCount()) |
137 | 140 |
return false; |
138 | 141 |
if(spatialChecker.intersects(rect, currentFeature)){ |
139 |
currentFeature++; |
|
142 |
//we only update the counter if spatialChecker could read the geometry |
|
143 |
//if it is boundedshape it doesnt read the geometry, so we need to read |
|
144 |
//currentFeature again |
|
145 |
if(spatialChecker.returnShapes()) |
|
146 |
currentFeature++; |
|
140 | 147 |
break; |
141 | 148 |
}else |
142 | 149 |
currentFeature++; |
... | ... | |
148 | 155 |
geom = spatialChecker.getLastGeometry(); |
149 | 156 |
}else{ |
150 | 157 |
geom = source.getShape(currentFeature); |
158 |
currentFeature++; |
|
151 | 159 |
reprojectIfNecessary(geom); |
152 | 160 |
} |
153 | 161 |
|
... | ... | |
322 | 330 |
class FastSpatialCheck implements ISpatialCheck { |
323 | 331 |
BoundsProvider boundProvider; |
324 | 332 |
int lastIndex; |
333 |
final static double BOUNDED_SHAPES_FACTOR = 4.0d; |
|
325 | 334 |
|
326 | 335 |
FastSpatialCheck() { |
327 |
if (source instanceof BoundedShapes) |
|
328 |
boundProvider = new BoundedShapesProvider( |
|
329 |
(BoundedShapes) source); |
|
330 |
else if (source.getDriver() instanceof BoundedShapes) |
|
331 |
boundProvider = new BoundedShapesProvider( |
|
332 |
(BoundedShapes) source.getDriver()); |
|
333 |
else |
|
336 |
try { |
|
337 |
if(isBoundedShapesNecessary()){ |
|
338 |
if (source instanceof BoundedShapes){ |
|
339 |
boundProvider = new BoundedShapesProvider( |
|
340 |
(BoundedShapes) source); |
|
341 |
}else if (source.getDriver() instanceof BoundedShapes){ |
|
342 |
boundProvider = new BoundedShapesProvider( |
|
343 |
(BoundedShapes) source.getDriver()); |
|
344 |
} |
|
345 |
}else{ |
|
346 |
boundProvider = new IGeometryBoundProvider(source); |
|
347 |
} |
|
348 |
} catch (ExpansionFileReadException e) { |
|
349 |
// TODO Auto-generated catch block |
|
350 |
e.printStackTrace(); |
|
334 | 351 |
boundProvider = new IGeometryBoundProvider(source); |
352 |
} catch (ReadDriverException e) { |
|
353 |
// TODO Auto-generated catch block |
|
354 |
e.printStackTrace(); |
|
355 |
boundProvider = new IGeometryBoundProvider(source); |
|
356 |
} |
|
335 | 357 |
} |
358 |
|
|
359 |
|
|
360 |
protected boolean isBoundedShapesNecessary() throws ReadDriverException, ExpansionFileReadException { |
|
361 |
Rectangle2D driverExtent = source.getFullExtent(); |
|
362 |
double areaExtent = rect.getWidth() * rect.getHeight(); |
|
363 |
double areaFullExtent = driverExtent.getWidth() * |
|
364 |
driverExtent.getHeight(); |
|
365 |
return areaExtent < (areaFullExtent / BOUNDED_SHAPES_FACTOR); |
|
336 | 366 |
|
367 |
} |
|
368 |
|
|
337 | 369 |
public boolean intersects(Rectangle2D extent, int featureIndex) |
338 | 370 |
throws ExpansionFileReadException, ReadDriverException { |
339 | 371 |
this.lastIndex = featureIndex; |
Also available in: Unified diff