Revision 24187

View differences:

branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/impl/DefaultFeatureIndex.java
46 46
import org.gvsig.fmap.data.feature.spi.FeatureStoreProviderServices;
47 47
import org.gvsig.fmap.data.feature.spi.index.FeatureIndexProvider;
48 48
import org.gvsig.fmap.data.feature.spi.index.FeatureIndexProviderServices;
49
import org.gvsig.tools.exception.NotYetImplemented;
49 50

  
50 51
/**
51 52
 * Default feature index provider services.
......
167 168

  
168 169
	public FeatureSetProvider getNearestFeatureSet(int count, int tolerance,
169 170
			Object value) throws DataIndexException {
170
		throw new UnsupportedOperationException();
171
		// TODO Ver si indice soporta tolerancia / Implementar con tolerancia
172
		return new IndexFeatureSet(this, new DefaultLongList(indexProvider
173
				.nearest(count, value)));
171 174
	}
172 175

  
173
	/**
174
	 * Performs a search in the index. The type of search depends on the passed
175
	 * data
176
	 *
177
	 * @deprecated
178
	 * */
179
	public FeatureSetProvider getFeatureSet(String attrName, Object[] data) throws DataIndexException {
180
		return new IndexFeatureSet(this, new DefaultLongList(this.match(data)));
181
	}
182

  
183
	/**
184
	 * Performs a search in the index and returns a list with the elements that
185
	 * match the parameters
186
	 *
187
	 * @deprecated
188
	 */
189
	private List match(Object[] values) throws DataIndexException {
190

  
191
		if (values == null) {
192
			throw new IllegalArgumentException("values can't be null.");
193
		}
194
		if (values.length == 0) {
195
			throw new IllegalArgumentException("values must contain at least 1 value.");
196
		}
197

  
198
		List result = null;
199
		if (values.length == 1) {
200
			result = indexProvider.match(values[0]);
201
		}
202
		if (values.length == 2) {
203
			if (values[0] instanceof Integer && !(values[1] instanceof Integer)) {
204
				result = indexProvider.nearest(((Integer)values[0]).intValue(), values[1]);
205
			} else {
206
				result = indexProvider.match(values[0], values[1]);
207
			}
208
		}
209
		return result;
210
	}
211

  
212

  
213 176
	public void initialize() throws InitializeException {
214 177
		indexProvider.setFeatureIndexProviderServices(this);
215 178
		indexProvider.initialize();
......
240 203
		return null;
241 204
	}
242 205

  
243
	/**
244
	 * FIXME ver que hacemos con estas constantes
245
	 * Convenience constants to identify sets of providers classified by supported data types.
246
	 */
247
	public interface PROVIDERS {
248

  
249
		public interface GEOMETRY {
250
			public static final String GT2_QUADTREE = "QuadTreeGt2Provider";
251
			public static final String JSI_RTREE = "RTreeJsiProvider";
252
			public static final String JTS_QUADTREE = "QuadTreeJtsProvider";
253
			public static final String SPATIALINDEX_RTREE = "RTreeSptLibProvider";
254
			public static final String DEFAULT = GT2_QUADTREE;
255
		}
256

  
257
		public interface DATE {
258
			// added as example
259
		}
260

  
261
		public interface INTEGER {
262
			// added as example
263
		}
264
	}
265

  
266 206
	public String getNewFileName(String prefix, String sufix) {
267 207
		int n=0;
268 208
		File file = new File(prefix + getName(), sufix);

Also available in: Unified diff