Revision 11906

View differences:

trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/featureiterators/IndexedSptQueryFeatureIterator.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-05-30 20:12:20  azabala
49
 * fastIteration = true optimized.
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
......
59 62
import java.util.List;
60 63

  
61 64
import org.cresques.cts.IProjection;
65
import org.geotools.resources.geometry.XRectangle2D;
62 66

  
63 67
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
64 68
import com.hardcode.gdbms.engine.values.Value;
......
121 125
		this.resultIdx = this.spatialIndex.query(this.rect);
122 126
	}
123 127

  
124
	public boolean hasNext() {
125
		if (fastIteration) {
126
			if (resultIdx != null && currentFeature < resultIdx.size())
127
				return true;
128
			else
129
				return false;
130
		} else {
131
			try {
132
				while (true) {
133
					if (currentFeature >= resultIdx.size())
134
						return false;
128
//	public boolean hasNext() {
129
//		if (fastIteration) {
130
//			if (resultIdx != null && currentFeature < resultIdx.size())
131
//				return true;
132
//			else
133
//				return false;
134
//		} else {
135
//			try {
136
//				while (true) {
137
//					if (currentFeature >= resultIdx.size())
138
//						return false;
139
//					if (spatialChecker.intersects(rect, 
140
//							((Integer) resultIdx.get(currentFeature)).intValue()))
141
//						return true;
142
//					currentFeature++;
143
//				}// while
144
//			} catch (ExpansionFileReadException e) {
145
//				e.printStackTrace();
146
//				return false;
147
//			} catch (ReadDriverException e) {
148
//				e.printStackTrace();
149
//				return false;
150
//			}
151
//
152
//		}
153
//	}
154
	
155
	public boolean hasNext(){
156
		try {
157
			while (true) {
158
				if (currentFeature >= resultIdx.size())
159
					return false;
160
//				if(fastIteration){
161
					
162
//					IGeometry geom = source.getShape(((Integer) resultIdx.get(currentFeature)).intValue());
163
//					if(XRectangle2D.intersectInclusive(geom, rect))
164
//						return true;
165
					
166
//				}else{
135 167
					if (spatialChecker.intersects(rect, 
136
							((Integer) resultIdx.get(currentFeature)).intValue()))
168
									((Integer) resultIdx.get(currentFeature)).intValue()))
137 169
						return true;
138
					currentFeature++;
139
				}// while
140
			} catch (ExpansionFileReadException e) {
141
				e.printStackTrace();
142
				return false;
143
			} catch (ReadDriverException e) {
144
				e.printStackTrace();
145
				return false;
146
			}
147

  
170
//				}//if fastIteration
171
				
172
				currentFeature++;
173
			}// while
174
		} catch (ExpansionFileReadException e) {
175
			e.printStackTrace();
176
			return false;
177
		} catch (ReadDriverException e) {
178
			e.printStackTrace();
179
			return false;
148 180
		}
149

  
150
		// if(resultIdx != null && currentFeature < resultIdx.size())
151
		// return true;
152
		// else
153
		// return false;
154 181
	}
155 182

  
156 183
	public IFeature next() throws ReadDriverException {
trunk/libraries/libFMap/src-test/com/iver/cit/gvsig/fmap/featureiterators/PerformanceFeatureIteratorTest.java
45 45
*
46 46
* $Id$
47 47
* $Log$
48
* Revision 1.1  2007-05-29 19:11:03  azabala
48
* Revision 1.2  2007-05-30 20:12:41  azabala
49
* fastIteration = true optimized.
50
*
51
* Revision 1.1  2007/05/29 19:11:03  azabala
49 52
* *** empty log message ***
50 53
*
51 54
*
......
96 99
	public void test1() {
97 100
		try {
98 101
			//pruebas de iteracion espacial
102
			System.out.println("TEST 1: ESPACIAL CON FULL EXTENT Y REPROYECCI?N");
99 103
			Rectangle2D rect = lyr.getFullExtent();
100 104
			IFeature feature = null;
101 105
			//fast iteration
......
209 213
		double xmax = 725000;
210 214
		double ymin = 4373800;
211 215
		double ymax = 4374300;
216
		System.out.println("TEST 2: ESPACIAL CON RECTANGULO PEQUE?O Y REPROYECCI?N");
212 217
		Rectangle2D rect = new Rectangle2D.Double(xmin, ymin, (xmax-xmin), (ymax-ymin));
213 218
		ICoordTrans trans = FeatureIteratorTest.PROJECTION_DEFAULT.
214 219
							getCT(FeatureIteratorTest.newProjection);
......
303 308
			//pruebas de iteracion espacial
304 309
			Rectangle2D rect = lyr.getFullExtent();
305 310
			IFeature feature = null;
311
			System.out.println("TEST 3: ESPACIAL CON FULL EXTENT SIN REPROYECCI?N");
306 312
			//fast iteration
307 313
			long t0 = System.currentTimeMillis();
308 314
			ISpatialIndex spatialIndex = lyr.getSource().getSpatialIndex();
......
384 390
		double ymin = 4373800;
385 391
		double ymax = 4374300;
386 392
		Rectangle2D rect = new Rectangle2D.Double(xmin, ymin, (xmax-xmin), (ymax-ymin));
387
		
393
		System.out.println("TEST 4: ESPACIAL CON RECTANGULO PEQUE?O SIN REPROYECCI?N");
388 394
		IFeature feature = null;
389 395
		//fast iteration
390 396
		try {

Also available in: Unified diff