Revision 35304

View differences:

tags/v2_0_0_Build_2026/libraries/libFMap_dalindex/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
5
                      http://maven.apache.org/maven-v4_0_0.xsd">
6
	<modelVersion>4.0.0</modelVersion>
7
	<groupId>org.gvsig</groupId>
8
	<artifactId>org.gvsig.fmap.dal.index.spatial
9
	</artifactId>
10
	<packaging>jar</packaging>
11
	<version>2.0-SNAPSHOT</version>
12
	<name>libFMap_dalindex</name>
13
	<url>http://gvsig.org</url>
14
	<parent>
15
		<groupId>org.gvsig</groupId>
16
		<artifactId>gvsig-base-library-pom</artifactId>
17
		<version>2.0-SNAPSHOT</version>
18
	</parent>	
19
	<distributionManagement>
20
		<site>
21
			<id>gvsig-repository</id>
22
			<url>${site-repository}/</url>
23
		</site>
24
	</distributionManagement>
25

  
26

  
27
	<properties>
28
		<!-- gt2 -->
29
		<gt2-jarIncludes>org/gvsig/fmap/dal/index/spatial/gt2/**
30
		</gt2-jarIncludes>
31
		<gt2-jarExcludes>NONE</gt2-jarExcludes>
32

  
33
		<!-- jts -->
34
		<jts-jarIncludes>org/gvsig/fmap/dal/index/spatial/jts/**
35
		</jts-jarIncludes>
36
		<jts-jarExcludes>NONE</jts-jarExcludes>
37

  
38
		<!-- jsi -->
39
		<jsi-jarIncludes>org/gvsig/fmap/dal/index/spatial/jsi/**
40
		</jsi-jarIncludes>
41
		<jsi-jarExcludes>NONE</jsi-jarExcludes>
42

  
43
		<!-- spatialindex -->
44
		<sptidx-jarIncludes>org/gvsig/fmap/dal/index/spatial/spatialindex/**
45
		</sptidx-jarIncludes>
46
		<sptidx-jarExcludes>NONE</sptidx-jarExcludes>
47

  
48
		<build-dir>${basedir}/../build</build-dir>
49
        <eclipse.project.name>libFMap_dalindex</eclipse.project.name>
50
	</properties>
51

  
52
	<dependencies>
53
        <dependency>
54
            <groupId>org.gvsig</groupId>
55
            <artifactId>org.gvsig.tools.lib</artifactId>
56
            <scope>compile</scope>
57
        </dependency>
58
		<dependency>
59
			<groupId>org.gvsig</groupId>
60
			<artifactId>org.gvsig.fmap.dal</artifactId>
61
            <scope>compile</scope>
62
		</dependency>
63
		<dependency>
64
			<groupId>org.gvsig</groupId>
65
			<artifactId>org.gvsig.fmap.dal</artifactId>
66
			<classifier>spi</classifier>
67
            <scope>compile</scope>
68
		</dependency>
69
        <dependency>
70
            <groupId>org.gvsig</groupId>
71
            <artifactId>org.gvsig.fmap.geometry</artifactId>
72
            <scope>compile</scope>
73
        </dependency>
74
        <dependency>
75
            <groupId>org.gvsig</groupId>
76
            <artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
77
            <scope>compile</scope>
78
        </dependency>        
79
        <dependency>
80
            <groupId>org.gvsig</groupId>
81
            <artifactId>org.gvsig.projection</artifactId>
82
            <scope>compile</scope>
83
        </dependency>
84
		<dependency>
85
			<groupId>com.vividsolutions</groupId>
86
			<artifactId>jts</artifactId>
87
            <scope>compile</scope>
88
		</dependency>
89
		<dependency>
90
			<groupId>net.sf</groupId>
91
			<artifactId>jsi</artifactId>
92
            <scope>compile</scope>
93
		</dependency>
94
		<dependency>
95
			<groupId>sil</groupId>
96
			<artifactId>sil</artifactId>
97
            <scope>compile</scope>
98
		</dependency>
99
		<dependency>
100
			<groupId>gnu.trove</groupId>
101
			<artifactId>trove</artifactId>
102
            <scope>compile</scope>
103
		</dependency>
104
		<dependency>
105
			<groupId>org.geotools</groupId>
106
			<artifactId>gt2-main</artifactId>
107
            <scope>compile</scope>
108
		</dependency>		
109
 		<dependency>
110
		    <groupId>spatialindex</groupId>
111
   			<artifactId>spatialindex</artifactId>
112
            <scope>compile</scope>
113
   		</dependency>
114
	</dependencies>
115
	<build>
116
		<sourceDirectory>src</sourceDirectory>
117
		<testSourceDirectory>src-test</testSourceDirectory>
118
		<testResources>
119
			<testResource>
120
				<directory>src-test</directory>
121
			</testResource>
122
		</testResources>
123
	</build>
124

  
125
	<profiles>
126
		<profile>
127
			<id>se</id>
128
			<activation>
129
				<activeByDefault>true</activeByDefault>
130
			</activation>
131
			<build>
132
				<plugins>
133
					<plugin>
134
						<groupId>org.apache.maven.plugins
135
						</groupId>
136
						<artifactId>maven-jar-plugin</artifactId>
137
						<configuration>
138
							<excludes>
139
								<exclude>${gt2-jarIncludes}</exclude>
140
								<exclude>${jts-jarIncludes}</exclude>
141
								<exclude>${jsi-jarIncludes}</exclude>
142
								<exclude>${sptidx-jarIncludes}</exclude>
143
							</excludes>
144
						</configuration>
145
						<executions>
146
							<!--
147
								Generates a jar file only with the GT2 based spatial index
148
								classes
149
							-->
150
							<execution>
151
								<id>gt2</id>
152
								<phase>package</phase>
153
								<goals>
154
									<goal>jar</goal>
155
								</goals>
156
								<configuration>
157
									<classifier>gt2</classifier>
158
									<includes>
159
										<include>${gt2-jarIncludes}</include>
160
									</includes>
161
									<excludes>
162
										<exclude>${gt2-jarExcludes}</exclude>
163
									</excludes>
164
								</configuration>
165
							</execution>
166
							<!--
167
								Generates a jar file only with the JTS based spatial index
168
								classes
169
							-->
170
							<execution>
171
								<id>jts</id>
172
								<phase>package</phase>
173
								<goals>
174
									<goal>jar</goal>
175
								</goals>
176
								<configuration>
177
									<classifier>jts</classifier>
178
									<includes>
179
										<include>${jts-jarIncludes}</include>
180
									</includes>
181
									<excludes>
182
										<exclude>${jts-jarExcludes}</exclude>
183
									</excludes>
184
								</configuration>
185
							</execution>
186
							<!--
187
								Generates a jar file only with the JSI based spatial index
188
								classes
189
							-->
190
							<execution>
191
								<id>jsi</id>
192
								<phase>package</phase>
193
								<goals>
194
									<goal>jar</goal>
195
								</goals>
196
								<configuration>
197
									<classifier>jsi</classifier>
198
									<includes>
199
										<include>${jsi-jarIncludes}</include>
200
									</includes>
201
									<excludes>
202
										<exclude>${jsi-jarExcludes}</exclude>
203
									</excludes>
204
								</configuration>
205
							</execution>
206
							<!--
207
								Generates a jar file only with the spatialindex based spatial
208
								index classes
209
							-->
210
							<execution>
211
								<id>spatialindex</id>
212
								<phase>package</phase>
213
								<goals>
214
									<goal>jar</goal>
215
								</goals>
216
								<configuration>
217
									<classifier>spatialindex</classifier>
218
									<includes>
219
										<include>${sptidx-jarIncludes}</include>
220
									</includes>
221
									<excludes>
222
										<exclude>${sptidx-jarExcludes}</exclude>
223
									</excludes>
224
								</configuration>
225
							</execution>
226
						</executions>
227
					</plugin>
228
					<plugin>
229
						<artifactId>maven-antrun-plugin</artifactId>
230
						<executions>
231
							<execution>
232
								<id>services</id>
233
								<phase>package</phase>
234
								<goals>
235
									<goal>run</goal>
236
								</goals>
237
								<configuration>
238
									<tasks>
239
										<jar
240
											destfile="${project.build.directory}/${project.build.finalName}-gt2.jar"
241
											update="true">
242
											<fileset dir="${basedir}/resources/gt2" />
243
										</jar>
244
										<jar
245
											destfile="${project.build.directory}/${project.build.finalName}-jsi.jar"
246
											update="true">
247
											<fileset dir="${basedir}/resources/jsi" />
248
										</jar>
249
										<jar
250
											destfile="${project.build.directory}/${project.build.finalName}-jts.jar"
251
											update="true">
252
											<fileset dir="${basedir}/resources/jts" />
253
										</jar>
254
										<jar
255
											destfile="${project.build.directory}/${project.build.finalName}-spatialindex.jar"
256
											update="true">
257
											<fileset dir="${basedir}/resources/spatialindex" />
258
										</jar>
259
									</tasks>
260
								</configuration>
261
							</execution>
262
						</executions>
263
					</plugin>
264
					<plugin>
265
						<groupId>org.apache.maven.plugins
266
						</groupId>
267
						<artifactId>maven-surefire-plugin
268
						</artifactId>
269
						<configuration>
270
							<additionalClasspathElements>
271
								<additionalClasspathElement>${basedir}/resources/gt2
272
								</additionalClasspathElement>
273
								<additionalClasspathElement>${basedir}/resources/jsi
274
								</additionalClasspathElement>
275
								<additionalClasspathElement>${basedir}/resources/jts
276
								</additionalClasspathElement>
277
								<additionalClasspathElement>${basedir}/resources/spatialindex
278
								</additionalClasspathElement>
279
							</additionalClasspathElements>
280
						</configuration>
281
					</plugin>
282

  
283
				</plugins>
284
			</build>
285
		</profile>
286
		<profile>
287
			<id>cdc</id>
288
			<activation>
289
				<activeByDefault>false</activeByDefault>
290
			</activation>
291
			<build>
292

  
293
				<plugins>
294
					<plugin>
295
						<groupId>org.apache.maven.plugins
296
						</groupId>
297
						<artifactId>maven-compiler-plugin
298
						</artifactId>
299
						<configuration>
300
							<source>1.4</source>
301
							<target>1.4</target>
302
							<!-- put your configurations here -->
303
							<encoding>ISO-8859-1</encoding>
304
							<excludes>
305
								<exclude>${jts-jarExcludes}</exclude>
306
								<exclude>**/gt2/**</exclude>
307
								<exclude>**/jsi/**</exclude>
308
								<exclude>**/spatialindex/**</exclude>
309
							</excludes>
310
						</configuration>
311
					</plugin>
312
					<plugin>
313
						<groupId>org.apache.maven.plugins
314
						</groupId>
315
						<artifactId>maven-jar-plugin</artifactId>
316
						<configuration>
317
							<excludes>
318
								<exclude>${jts-jarIncludes}</exclude>
319
							</excludes>
320
						</configuration>
321
						<executions>
322

  
323
							<!--
324
								Generates a jar file only with the JTS based spatial index
325
								classes
326
							-->
327
							<execution>
328
								<id>jts</id>
329
								<phase>package</phase>
330
								<goals>
331
									<goal>jar</goal>
332
								</goals>
333
								<configuration>
334
									<classifier>jts</classifier>
335
									<includes>
336
										<include>${jts-jarIncludes}</include>
337
									</includes>
338
									<excludes>
339
										<exclude>${jts-jarExcludes}</exclude>
340
										<exclude>**/gt2/**</exclude>
341
										<exclude>**/jsi/**</exclude>
342
										<exclude>**/spatialindex/**</exclude>
343
									</excludes>
344
								</configuration>
345
							</execution>
346
						</executions>
347
					</plugin>
348
				</plugins>
349
			</build>
350
		</profile>
351
		<profile>
352
			<id>eclipse-project</id>
353
			<build>
354
				<defaultGoal>antrun:run</defaultGoal>
355
				<plugins>
356
					<plugin>
357
						<artifactId>maven-antrun-plugin</artifactId>
358
						<configuration>
359
							<tasks>
360
								<ant antfile="${build-dir}/ant-tasks/eclipse-tasks.xml"
361
									target="eclipse.all"/>
362
							</tasks>
363
						</configuration>
364
					</plugin>
365
				</plugins>
366
			</build>				
367
		</profile>		
368
	</profiles>
369

  
370

  
371
</project>
tags/v2_0_0_Build_2026/libraries/libFMap_dalindex/resources/jsi/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.fmap.dal.index.spatial.jsi.JSIIndexLibrary
tags/v2_0_0_Build_2026/libraries/libFMap_dalindex/resources/spatialindex/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.fmap.dal.index.spatial.spatialindex.SPTLIBIndexLibrary
tags/v2_0_0_Build_2026/libraries/libFMap_dalindex/resources/gt2/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.fmap.dal.index.spatial.gt2.Gt2IndexLibrary
tags/v2_0_0_Build_2026/libraries/libFMap_dalindex/resources/jts/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.fmap.dal.index.spatial.jts.JTSIndexLibrary
tags/v2_0_0_Build_2026/libraries/libFMap_dalindex/src/org/gvsig/fmap/dal/index/spatial/gt2/GT2Quadtree.java
1
/*
2
 * Created on 16-may-2006
3
 *
4
 * gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib��ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
/* CVS MESSAGES:
45
 *
46
 * $Id: QuadtreeGt2.java 10627 2007-03-06 17:10:21Z caballero $
47
 * $Log$
48
 * Revision 1.3  2007-03-06 17:08:59  caballero
49
 * Exceptions
50
 *
51
 * Revision 1.2  2006/11/29 19:27:59  azabala
52
 * bug fixed (caused when we query for a bbox which is greater or equal to a layer bbox)
53
 *
54
 * Revision 1.1  2006/05/24 21:58:04  azabala
55
 * *** empty log message ***
56
 *
57
 *
58
 */
59
package org.gvsig.fmap.dal.index.spatial.gt2;
60

  
61
import java.io.File;
62
import java.io.IOException;
63
import java.util.List;
64
import java.util.Stack;
65

  
66
import org.geotools.index.quadtree.Node;
67
import org.geotools.index.quadtree.QuadTree;
68
import org.geotools.index.quadtree.StoreException;
69
import org.geotools.index.quadtree.fs.FileSystemIndexStore;
70
import org.geotools.index.quadtree.fs.IndexHeader;
71
import org.gvsig.fmap.dal.exception.InitializeException;
72
import org.gvsig.fmap.dal.feature.FeatureStore;
73
import org.gvsig.fmap.dal.feature.exception.FeatureIndexException;
74
import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices;
75
import org.gvsig.fmap.dal.feature.spi.index.AbstractFeatureIndexProvider;
76
import org.gvsig.fmap.dal.feature.spi.index.FeatureIndexProvider;
77
import org.gvsig.fmap.geom.Geometry;
78
import org.gvsig.fmap.geom.primitive.Point;
79
import org.gvsig.tools.exception.BaseException;
80

  
81
import com.vividsolutions.jts.geom.Envelope;
82

  
83
/**
84
 * This Quadtree spatial index implementation is based in a fork of
85
 * org.geotools.index.quadtree.Quadtree implementation. <br>
86
 * This implementation offers us:
87
 * <ol>
88
 * <li>Persistence of spatial index</li>
89
 * </ol>
90
 * We had to fork geotools quadtree for many reasons:
91
 * <ol>
92
 * <li>It was strongly dependent of SHP format, so it returned not only a num
93
 * of rectangle, it also returned byte offset of this rectangle in shp file</li>
94
 * <li> Query artifact wasnt run well at all </li>
95
 * </ol>
96
 *
97
 * @author azabala
98
 *
99
 */
100
public class GT2Quadtree extends AbstractFeatureIndexProvider implements FeatureIndexProvider {
101

  
102
	public static final String NAME = GT2Quadtree.class.getSimpleName();
103
	/**
104
	 * Geotools quadtree implementation
105
	 */
106
	QuadTree quadtree;
107
	/**
108
	 * Persistent storage
109
	 */
110
	String fileName;
111
	/**
112
	 * Spatial index file extension
113
	 */
114
	final String qExt = ".qix";
115
	/**
116
	 * qix format has many versions, and allows different byte orders.
117
	 */
118
	String byteOrder;
119
	/**
120
	 * Bounds of the layer to index
121
	 */
122
	//Envelope bounds;
123
	/**
124
	 * Number of records of the layer to index
125
	 */
126
	//int numRecs = 0;
127

  
128
	boolean inMemory = false;
129

  
130
	public GT2Quadtree() {
131

  
132
	}
133

  
134
	public void initialize() throws InitializeException {
135
		try {
136
			File file = File.createTempFile(getFeatureStore().getName(), ".qix");
137
			this.fileName = file.getAbsolutePath();
138
			org.gvsig.fmap.geom.primitive.Envelope env = getFeatureStore()
139
					.getEnvelope();
140
			int featureCount = (int) getFeatureStore().getFeatureCount();
141
			this.byteOrder = "NM";
142
			quadtree = new QuadTree(featureCount, toJtsEnvelope(env));
143
			if (exists()) {
144
				load();
145
			}
146
		} catch (IOException e) {
147
			throw new InitializeException(e);
148
		} catch (BaseException e) {
149
			throw new InitializeException(e);
150
		}
151
	}
152

  
153
	/**
154
	 * If the spatial index file exists and has content
155
	 */
156
	public boolean exists() {
157
		return (new File(fileName).length() != 0);
158
	}
159

  
160
	public void load() throws FeatureIndexException {
161
		if (quadtree == null) {
162
			load(new File(fileName));
163
		}
164
	}
165

  
166
	public void load(File f) throws FeatureIndexException {
167
		try {
168
			FileSystemIndexStore store = new FileSystemIndexStore(f);
169
			quadtree = store.load();
170
			this.fileName = f.getAbsolutePath();
171
		} catch (StoreException e) {
172
			throw new FeatureIndexException(e);
173
		}
174
	}
175

  
176
	/**
177
	 * Inserts an object in the index
178
	 */
179
	public void insert(org.gvsig.fmap.geom.primitive.Envelope env, int index) {
180
		if (env == null) {
181
			throw new IllegalArgumentException("Envelope cannot be null");
182
		}
183
		Envelope e = toJtsEnvelope(env);
184
		if (e == null) {
185
			throw new IllegalStateException(
186
					"JTS Envelope conversion returns null");
187
		}
188
		System.out.println("recno=" + index);
189
		if (quadtree == null) {
190
			throw new IllegalStateException("quadtree is null");
191
		}
192
		try {
193
			quadtree.insert(index, toJtsEnvelope(env));
194
		} catch (StoreException se) {
195
			// TODO Auto-generated catch block
196
			se.printStackTrace();
197
		}
198
	}
199

  
200
	public void delete(org.gvsig.fmap.geom.primitive.Envelope env, int index) {
201
		if (inMemory) {
202
			quadtree.delete(toJtsEnvelope(env), index);
203
		}
204
	}
205

  
206
	public Envelope toJtsEnvelope(org.gvsig.fmap.geom.primitive.Envelope env) {
207
		if (env == null) {
208
			return null;
209
		}
210
		Point min = env.getLowerCorner();
211
		Point max = env.getUpperCorner();
212

  
213
		return new Envelope(min.getX(), max.getX(), min.getY(), max.getY());
214
	}
215

  
216
	/**
217
	 *
218
	 * @throws StoreException
219
	 * @deprecated
220
	 */
221
	void openQuadTree() throws StoreException {
222
		if (quadtree == null) {
223
			File file = new File(this.fileName);
224
			// Intento de cargar todo el quadtree en memoria
225
			FileSystemIndexStore store = new FileSystemIndexStore(file);
226
			quadtree = store.load();
227
		}
228
	}
229

  
230
	void openQuadTreeInMemory() throws StoreException {
231
		if (quadtree == null) {
232
			File file = new File(fileName);
233
			// Intento de cargar todo el quadtree en memoria
234
			FileSystemIndexStore store = new FileSystemIndexStore(file);
235
			QuadTree filequadtree = store.load();
236
			quadtree = new QuadTree(filequadtree.getNumShapes(), filequadtree
237
					.getMaxDepth(), filequadtree.getRoot().getBounds());
238
			Stack nodes = new Stack();
239
			nodes.push(filequadtree.getRoot());
240
			while (nodes.size() != 0) {
241
				Node node = (Node) nodes.pop();
242
				Envelope nodeEnv = node.getBounds();
243
				int[] shapeIds = node.getShapesId();
244
				for (int i = 0; i < shapeIds.length; i++) {
245
					quadtree.insert(shapeIds[i], nodeEnv);
246
				}
247
				int numSubnodes = node.getNumSubNodes();
248
				for (int i = 0; i < numSubnodes; i++) {
249
					nodes.push(node.getSubNode(i));
250
				}
251
			}// while
252
			filequadtree.close();
253
		}
254
	}
255

  
256
	public void flush() throws FeatureIndexException {
257
		flush(new File(fileName));
258
	}
259

  
260
	public void flush(File f) throws FeatureIndexException {
261
		byte order = 0;
262
		if ((byteOrder == null) || byteOrder.equalsIgnoreCase("NM")) {
263
			order = IndexHeader.NEW_MSB_ORDER;
264
		} else if (byteOrder.equalsIgnoreCase("NL")) {
265
			order = IndexHeader.NEW_LSB_ORDER;
266
		}
267
		FileSystemIndexStore store = new FileSystemIndexStore(f, order);
268
		try {
269
			store.store(quadtree);
270
			this.fileName = f.getAbsolutePath();
271
		} catch (StoreException e) {
272
			throw new FeatureIndexException(e);
273
		}
274
	}
275

  
276
	public File getFile() {
277
		return new File(this.fileName);
278
	}
279

  
280
	private FeatureStore getFeatureStore() {
281
		return getFeatureIndexProviderServices()
282
				.getFeatureStoreProviderServices().getFeatureStore();
283
	}
284

  
285
	public void delete(Object value, FeatureReferenceProviderServices fref) {
286

  
287
		if (!isCompatibleOID(fref.getOID())) {
288
			throw new IllegalArgumentException("OID not compatible. Must be an instance of Number within the Integer range.");
289
		}
290

  
291
		delete(((org.gvsig.fmap.geom.Geometry) value).getEnvelope(), ((Number) fref.getOID()).intValue());
292
	}
293

  
294
	public void insert(Object value, FeatureReferenceProviderServices fref) {
295

  
296
		if (!isCompatibleOID(fref.getOID())) {
297
			throw new IllegalArgumentException("OID not compatible. Must be an instance of Number within the Integer range.");
298
		}
299

  
300
		insert(((org.gvsig.fmap.geom.Geometry) value).getEnvelope(), ((Number) fref.getOID()).intValue());
301
	}
302

  
303
	public List match(Object value) throws FeatureIndexException {
304
		if (quadtree == null) {
305
			throw new IllegalStateException("This quadtree is null.");
306
		}
307
		if (value == null) {
308
			throw new IllegalArgumentException("Envelope cannot be null.");
309
		}
310
		if (!(value instanceof org.gvsig.fmap.geom.primitive.Envelope)) {
311
			throw new IllegalArgumentException("Not an envelope.");
312
		}
313
		org.gvsig.fmap.geom.primitive.Envelope env = null;
314
		if (value instanceof org.gvsig.fmap.geom.primitive.Envelope) {
315
			env = (org.gvsig.fmap.geom.primitive.Envelope) value;
316
		} else if (value instanceof Geometry) {
317
			env = ((Geometry) value).getEnvelope();
318
		}
319
		return new LongList(quadtree.query(toJtsEnvelope(env)));
320
	}
321

  
322
	public List nearest(int count, Object value) throws FeatureIndexException {
323
		throw new UnsupportedOperationException();
324
	}
325

  
326
	public boolean isMatchSupported() {
327
		return true;
328
	}
329

  
330
	public boolean isNearestSupported() {
331
		return false;
332
	}
333

  
334
	public boolean isNearestToleranceSupported() {
335
		return false;
336
	}
337

  
338
	public boolean isRangeSupported() {
339
		return false;
340
	}
341

  
342
	public List nearest(int count, Object value, Object tolerance)
343
			throws FeatureIndexException {
344
		throw new UnsupportedOperationException();
345
	}
346

  
347
	public List range(Object value1, Object value2) throws FeatureIndexException {
348
		throw new UnsupportedOperationException();
349
	}
350

  
351
	/**
352
	 * Indicates whether the given OID's type is compatible
353
	 * with this provider
354
	 *
355
	 * @param oid
356
	 *
357
	 * @return
358
	 * 		true if this index provider supports the given oid type
359
	 */
360
	private boolean isCompatibleOID(Object oid) {
361
		if (!(oid instanceof Number)) {
362
			return false;
363
		}
364

  
365
		long num = ((Number) oid).longValue();
366

  
367
		if (num > Integer.MAX_VALUE || num < Integer.MIN_VALUE) {
368
			return false;
369
		}
370

  
371
		return true;
372
	}
373

  
374
}
tags/v2_0_0_Build_2026/libraries/libFMap_dalindex/src/org/gvsig/fmap/dal/index/spatial/gt2/Gt2IndexLibrary.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
* MA  02110-1301, USA.
20
*
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 {{Company}}   {{Task}}
26
*/
27

  
28

  
29
package org.gvsig.fmap.dal.index.spatial.gt2;
30

  
31
import org.gvsig.fmap.dal.DALLibrary;
32
import org.gvsig.fmap.dal.DALLocator;
33
import org.gvsig.fmap.dal.DataTypes;
34
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
35
import org.gvsig.tools.library.AbstractLibrary;
36
import org.gvsig.tools.library.LibraryException;
37

  
38
public class Gt2IndexLibrary extends AbstractLibrary {
39

  
40
    @Override
41
    public void doRegistration() {
42
        registerAsServiceOf(DALLibrary.class);
43
    }
44

  
45
	@Override
46
	protected void doInitialize() throws LibraryException {
47
	}
48

  
49
	@Override
50
	protected void doPostInitialize() throws LibraryException {
51
    	DataManagerProviderServices man = (DataManagerProviderServices) DALLocator.getDataManager();
52

  
53
    	if (!man.getFeatureIndexProviders().contains(GT2Quadtree.NAME)) {
54
			man.registerFeatureIndexProvider(GT2Quadtree.NAME, "Quadtree index based on Geotools 2",
55
					GT2Quadtree.class, DataTypes.GEOMETRY);
56
    	}
57
	}
58
}
tags/v2_0_0_Build_2026/libraries/libFMap_dalindex/src/org/gvsig/fmap/dal/index/spatial/jts/JTSIndexLibrary.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
* MA  02110-1301, USA.
20
*
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 {{Company}}   {{Task}}
26
*/
27

  
28
package org.gvsig.fmap.dal.index.spatial.jts;
29

  
30
import org.gvsig.fmap.dal.DALLibrary;
31
import org.gvsig.fmap.dal.DALLocator;
32
import org.gvsig.fmap.dal.DataTypes;
33
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
34
import org.gvsig.tools.library.AbstractLibrary;
35
import org.gvsig.tools.library.LibraryException;
36

  
37
public class JTSIndexLibrary extends AbstractLibrary {
38

  
39
    @Override
40
    public void doRegistration() {
41
        registerAsServiceOf(DALLibrary.class);
42
    }
43

  
44
	protected void doInitialize() throws LibraryException {
45
	}
46

  
47
	protected void doPostInitialize() throws LibraryException {
48
    	DataManagerProviderServices man = (DataManagerProviderServices) DALLocator.getDataManager();
49

  
50

  
51
    	if (!man.getFeatureIndexProviders().contains(JTSQuadtree.NAME)) {
52
			man.registerFeatureIndexProvider(JTSQuadtree.NAME, "Quadtree index based on JTS",
53
					JTSQuadtree.class, DataTypes.GEOMETRY);
54
			man.setDefaultFeatureIndexProviderName(DataTypes.GEOMETRY, JTSQuadtree.NAME);
55
    	}
56
	}
57
}
58

  
tags/v2_0_0_Build_2026/libraries/libFMap_dalindex/src/org/gvsig/fmap/dal/index/spatial/jts/JTSQuadtree.java
1
/*
2
 * Created on 28-abr-2006
3
 *
4
 * gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib��ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
/* CVS MESSAGES:
45
*
46
* $Id: QuadtreeJts.java 11288 2007-04-19 17:32:50Z azabala $
47
* $Log$
48
* Revision 1.2  2007-04-19 17:32:50  azabala
49
* new constructor (fmap spatial index from an existing jts spatial index)
50
*
51
* Revision 1.1  2006/05/01 18:38:41  azabala
52
* primera version en cvs del api de indices espaciales
53
*
54
*
55
*/
56
package org.gvsig.fmap.dal.index.spatial.jts;
57

  
58
import java.util.List;
59

  
60
import org.gvsig.fmap.dal.feature.exception.FeatureIndexException;
61
import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices;
62
import org.gvsig.fmap.dal.feature.spi.index.AbstractFeatureIndexProvider;
63
import org.gvsig.fmap.dal.feature.spi.index.FeatureIndexProvider;
64
import org.gvsig.fmap.geom.Geometry;
65
import org.gvsig.fmap.geom.primitive.NullGeometry;
66
import org.gvsig.fmap.geom.primitive.Point;
67

  
68
import com.vividsolutions.jts.geom.Envelope;
69
import com.vividsolutions.jts.index.quadtree.Quadtree;
70
/**
71
 * Adapter for ISPatialIndex gvSIG's interface to
72
 * JTS Quadtree.
73
 *
74
 *
75
 * @author azabala
76
 *
77
 */
78
public class JTSQuadtree extends AbstractFeatureIndexProvider implements FeatureIndexProvider {
79

  
80
	public static final String NAME = JTSQuadtree.class.getName();
81

  
82
	private Quadtree quadtree;
83

  
84
	public JTSQuadtree() {
85
	}
86

  
87
	public void initialize() {
88
		quadtree = new Quadtree();
89
	}
90

  
91
	private Envelope fromEnvelope(org.gvsig.fmap.geom.primitive.Envelope env){
92
		Point min = env.getLowerCorner();
93
		Point max = env.getUpperCorner();
94
		Envelope env2 = new Envelope(min.getX(), max.getX(), min.getY(), max.getY());
95
		return env2;
96
	}
97

  
98
	public void delete(Object o, FeatureReferenceProviderServices fref) {
99
		Integer integer=new Integer(((Long)(fref).getOID()).intValue());
100
		quadtree.remove(
101
				fromEnvelope(((Geometry) o).getEnvelope()), integer);
102
	}
103

  
104
	public void insert(Object o, FeatureReferenceProviderServices fref) {
105
		if (o == null || o instanceof NullGeometry) {
106
			return;
107
		}
108
		Integer integer=new Integer(((Long)(fref).getOID()).intValue());
109
		quadtree.insert(
110
				fromEnvelope(((Geometry) o).getEnvelope()), integer);
111

  
112
	}
113

  
114
	public List match(Object value) throws FeatureIndexException {
115
		org.gvsig.fmap.geom.primitive.Envelope env = null;
116
		if (value instanceof org.gvsig.fmap.geom.primitive.Envelope) {
117
			env = (org.gvsig.fmap.geom.primitive.Envelope) value;
118
		} else if (value instanceof Geometry) {
119
			env = ((Geometry) value).getEnvelope();
120
		}
121
		return new LongList(quadtree.query(fromEnvelope(env)));
122
	}
123

  
124
	public List match(Object min, Object max) {
125
		throw new UnsupportedOperationException("Can't perform this kind of search.");
126
	}
127

  
128
	public List nearest(int count, Object value) throws FeatureIndexException {
129
		throw new UnsupportedOperationException("Can't perform this kind of search.");
130
	}
131

  
132
	public boolean isMatchSupported() {
133
		return true;
134
	}
135

  
136
	public boolean isNearestSupported() {
137
		return false;
138
	}
139

  
140
	public boolean isNearestToleranceSupported() {
141
		return false;
142
	}
143

  
144
	public boolean isRangeSupported() {
145
		return false;
146
	}
147

  
148
	public List nearest(int count, Object value, Object tolerance)
149
			throws FeatureIndexException {
150
		throw new UnsupportedOperationException();
151
	}
152

  
153
	public List range(Object value1, Object value2)
154
			throws FeatureIndexException {
155
		throw new UnsupportedOperationException();
156
	}
157
}
158

  
tags/v2_0_0_Build_2026/libraries/libFMap_dalindex/src/org/gvsig/fmap/dal/index/spatial/jsi/JSIIndexLibrary.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
* MA  02110-1301, USA.
20
*
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 {{Company}}   {{Task}}
26
*/
27

  
28
package org.gvsig.fmap.dal.index.spatial.jsi;
29

  
30
import org.gvsig.fmap.dal.DALLibrary;
31
import org.gvsig.fmap.dal.DALLocator;
32
import org.gvsig.fmap.dal.DataTypes;
33
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
34
import org.gvsig.tools.library.AbstractLibrary;
35
import org.gvsig.tools.library.LibraryException;
36

  
37
public class JSIIndexLibrary extends AbstractLibrary {
38

  
39
    @Override
40
    public void doRegistration() {
41
        registerAsServiceOf(DALLibrary.class);
42
    }
43

  
44
	@Override
45
	protected void doInitialize() throws LibraryException {
46
	}
47

  
48
	@Override
49
	protected void doPostInitialize() throws LibraryException {
50
    	DataManagerProviderServices man = (DataManagerProviderServices) DALLocator.getDataManager();
51

  
52
    	if (!man.getFeatureIndexProviders().contains(JSIPersistentRTree.NAME)) {
53
			man.registerFeatureIndexProvider(JSIPersistentRTree.NAME, "Persistent RTree index based on JSI",
54
					JSIPersistentRTree.class, DataTypes.GEOMETRY);
55
    	}
56

  
57
    	if (!man.getFeatureIndexProviders().contains(JSIRTree.NAME)) {
58
			man.registerFeatureIndexProvider(JSIRTree.NAME, "RTree index based on JSI",
59
					JSIRTree.class, DataTypes.GEOMETRY);
60
    	}
61
	}
62
}
tags/v2_0_0_Build_2026/libraries/libFMap_dalindex/src/org/gvsig/fmap/dal/index/spatial/jsi/JSIRTree.java
1
/*
2
 * Created on 15-may-2006
3
 *
4
 * gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib��ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
/* CVS MESSAGES:
45
*
46
* $Id: RTreeJsi.java 13884 2007-09-19 16:26:04Z jaume $
47
* $Log$
48
* Revision 1.5  2007-09-19 16:25:39  jaume
49
* ReadExpansionFileException removed from this context and removed unnecessary imports
50
*
51
* Revision 1.4  2007/06/27 20:17:30  azabala
52
* new spatial index (rix)
53
*
54
* Revision 1.3  2007/03/06 17:08:59  caballero
55
* Exceptions
56
*
57
* Revision 1.2  2006/06/05 16:59:08  azabala
58
* implementada busqueda de vecino mas proximo a partir de rectangulos
59
*
60
* Revision 1.1  2006/05/24 21:58:04  azabala
61
* *** empty log message ***
62
*
63
*
64
*/
65
package org.gvsig.fmap.dal.index.spatial.jsi;
66

  
67
import java.util.ArrayList;
68
import java.util.Iterator;
69
import java.util.List;
70
import java.util.Properties;
71

  
72
import org.gvsig.fmap.dal.exception.InitializeException;
73
import org.gvsig.fmap.dal.feature.exception.FeatureIndexException;
74
import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices;
75
import org.gvsig.fmap.dal.feature.spi.index.AbstractFeatureIndexProvider;
76
import org.gvsig.fmap.dal.feature.spi.index.FeatureIndexProvider;
77
import org.gvsig.fmap.geom.Geometry;
78
import org.gvsig.fmap.geom.primitive.Envelope;
79
import org.gvsig.fmap.geom.primitive.Point;
80

  
81
import com.infomatiq.jsi.IntProcedure;
82
import com.infomatiq.jsi.Rectangle;
83
import com.infomatiq.jsi.rtree.RTree;
84

  
85
/**
86
 * RTree spatial index implementation based in library
87
 * JSI (java spatial index).
88
 *
89
 * http://jsi.sourceforge.net/
90
 *
91
 * This RTree has better performance that Spatial Index Library
92
 * RTree, and that JTS'RTree, because
93
 * it uses the GNU's Trove Collections API.
94
 *
95
 * We are doing some probes with it, because it offers
96
 * a Nearest Neighbour algorithm implementation
97
 * (useful for Spatial Join geoprocess, for example).
98
 *
99
 * It isnt persistent, and We've found some problems
100
 * with delete operations.
101
 *
102
 *
103
 *
104
 *
105
 * @author azabala
106
 * @author jyarza
107
 *
108
 */
109
public class JSIRTree extends AbstractFeatureIndexProvider implements FeatureIndexProvider {
110

  
111
	public static final String NAME = JSIRTree.class.getSimpleName();
112

  
113
	protected RTree rtree;
114

  
115
	public JSIRTree() {
116
		rtree = new RTree();
117
	}
118

  
119

  
120
	public void initialize() throws InitializeException {
121
		Properties props = new Properties();
122
//		props.setProperty("MaxNodeEntries", "500");
123
//		props.setProperty("MinNodeEntries", "200");
124
		rtree.init(props);
125
	}
126

  
127
	class ListIntProcedure implements IntProcedure{
128
		ArrayList solution = new ArrayList();
129

  
130
		public boolean execute(int arg0) {
131
			solution.add(new Integer(arg0));
132
			return true;
133
		}
134

  
135
		public List getSolution(){
136
			return solution;
137
		}
138
	}
139

  
140
	protected List findNNearest(int numberOfNearest, Point point){
141
		com.infomatiq.jsi.Point jsiPoint =
142
			new com.infomatiq.jsi.Point((float)point.getX(), (float)point.getY());
143
		return (List) rtree.nearest(jsiPoint, numberOfNearest);
144
	}
145

  
146
	public Iterator iterator(){
147
		return rtree.iterator();
148
	}
149

  
150
	public int size(){
151
		return rtree.size();
152
	}
153

  
154
	protected Rectangle toJsiRect(Envelope env){
155
		Point min = env.getLowerCorner();
156
		Point max = env.getUpperCorner();
157

  
158
		Rectangle jsiRect = new Rectangle((float)min.getX(),
159
				(float)min.getY(),
160
				(float)max.getX(),
161
				(float)max.getY());
162
		return jsiRect;
163
	}
164

  
165
	public void insert(Object value, FeatureReferenceProviderServices fref) {
166
		Envelope env = getEnvelope(value);
167

  
168
		if (env == null) {
169
			throw new IllegalArgumentException("value is neither Geometry or Envelope");
170
		}
171
		
172
		Object oid = fref.getOID();
173
		if (!isCompatibleOID(oid)) {
174
			throw new IllegalArgumentException("OID type not compatible: " + oid.getClass().getName());
175
		}		
176

  
177
		rtree.add(toJsiRect(env), ((Number) oid).intValue());
178
	}
179

  
180
	public void delete(Object value, FeatureReferenceProviderServices fref) {
181
		Envelope env = getEnvelope(value);
182

  
183
		if (env == null) {
184
			throw new IllegalArgumentException("value is neither Geometry or Envelope");
185
		}
186
		
187
		Object oid = fref.getOID();
188
		if (!isCompatibleOID(oid)) {
189
			throw new IllegalArgumentException("OID type not compatible: " + oid.getClass().getName());
190
		}
191
		
192
		rtree.delete(toJsiRect(env), ((Number) oid).intValue());
193
	}
194

  
195
	public List match(Object value) throws FeatureIndexException {
196
		Envelope env = getEnvelope(value);
197

  
198
		if (env == null) {
199
			throw new IllegalArgumentException("value is neither Geometry or Envelope");
200
		}
201
		ListIntProcedure solution = new ListIntProcedure();
202
		rtree.intersects(toJsiRect(env), solution);
203
		return new LongList(solution.getSolution());
204
	}
205

  
206
	public List nearest(int count, Object value) {
207
		if (value == null) {
208
			throw new IllegalArgumentException("value is null");
209
		}
210
		
211
		if (value instanceof Point) {
212
			Point p = (Point) value;
213
			com.infomatiq.jsi.Point jsiPoint =
214
				new com.infomatiq.jsi.Point((float) p.getDirectPosition().getOrdinate(0), (float) p.getDirectPosition().getOrdinate(1));
215
			return (List) rtree.nearest(jsiPoint, count);
216
		} else {
217
			Envelope env = getEnvelope(value);
218

  
219
			if (env == null) {
220
				throw new IllegalArgumentException("value is neither Geometry or Envelope");
221
			}
222
			return new LongList((List) rtree.nearest(toJsiRect(env), count));
223
		}
224
	}
225

  
226

  
227
	public boolean isMatchSupported() {
228
		return true;
229
	}
230

  
231
	public boolean isNearestSupported() {
232
		return true;
233
	}
234

  
235
	public boolean isNearestToleranceSupported() {
236
		return false;
237
	}
238

  
239
	public boolean isRangeSupported() {
240
		return false;
241
	}
242

  
243
	public List nearest(int count, Object value, Object tolerance)
244
			throws FeatureIndexException {
245
		throw new UnsupportedOperationException();
246
	}
247

  
248
	public List range(Object value1, Object value2) throws FeatureIndexException {
249
		throw new UnsupportedOperationException();
250
	}
251
	
252
	/**
253
	 * Indicates whether the given OID's type is compatible
254
	 * with this provider
255
	 * 
256
	 * @param oid
257
	 * 
258
	 * @return
259
	 * 		true if this index provider supports the given oid type
260
	 */
261
	private boolean isCompatibleOID(Object oid) {
262
		if (!(oid instanceof Number)) {
263
			return false;
264
		}
265
		
266
		long num = ((Number) oid).longValue();
267
				 
268
		if (num > Integer.MAX_VALUE || num < Integer.MIN_VALUE) {
269
			return false;
270
		}
271
		
272
		return true;
273
	}
274
	
275
	protected Envelope getEnvelope(Object value) {
276
		Envelope env = null;
277
		
278
		if (value instanceof Envelope) {
279
			env = (Envelope) value;
280
		} else if (value instanceof Geometry) {
281
			env = ((Geometry) value).getEnvelope();
282
		}
283
		return env;
284
	}	
285

  
286
}
287

  
tags/v2_0_0_Build_2026/libraries/libFMap_dalindex/src/org/gvsig/fmap/dal/index/spatial/jsi/JSIPersistentRTree.java
1
/*
2
 * Created on 13-jun-2007
3
 *
4
 * gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib��ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
/* CVS MESSAGES:
45
*
46
* $Id: PersistentRTreeJsi.java 12380 2007-06-27 20:17:30Z azabala $
47
* $Log$
48
* Revision 1.1  2007-06-27 20:17:30  azabala
49
* new spatial index (rix)
50
*
51
*
52
*/
53
package org.gvsig.fmap.dal.index.spatial.jsi;
54

  
55
import java.awt.geom.Point2D;
56
import java.io.File;
57
import java.io.FileNotFoundException;
58
import java.io.IOException;
59
import java.io.RandomAccessFile;
60
import java.nio.ByteOrder;
61
import java.nio.MappedByteBuffer;
62
import java.nio.channels.FileChannel;
63
import java.util.Iterator;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff