Revision 3601

View differences:

trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/VectorialFileAdapter.java
57 57
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
58 58
import com.iver.cit.gvsig.fmap.drivers.ExternalData;
59 59
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver;
60
import com.iver.cit.gvsig.fmap.rendering.indexes.Index;
61
import com.iver.cit.gvsig.fmap.rendering.indexes.IndexNotExistsException;
62 60
import com.iver.cit.gvsig.fmap.write.FileWriterDriver;
63 61

  
64 62

  
......
67 65
 * adem?s el estado necesario por una capa vectorial de fichero (el nombre del
68 66
 * fichero)
69 67
 */
70
public class VectorialFileAdapter extends VectorialAdapter implements Index {
68
public class VectorialFileAdapter extends VectorialAdapter {
71 69
	private boolean driverInitialized = false;
72 70
	private File file;
73 71
	private FileWriterDriver writeDriver;
......
179 177
		}
180 178
	}
181 179

  
182
	/**
183
	 * @see com.iver.cit.gvsig.fmap.rendering.indexes.Index#getRecordIndexes(java.awt.geom.Rectangle2D)
184
	 */
185
	public int[] getRecordIndexes(Rectangle2D rect)
186
		throws DriverIOException, IndexNotExistsException {
187
		//TODO implementar bien
188
		return null;
189
	}
190 180

  
191 181
	/**
192 182
	 * @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShapeType()
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/VectorialAdapter.java
40 40
 */
41 41
package com.iver.cit.gvsig.fmap.layers;
42 42

  
43
import com.hardcode.driverManager.DriverLoadException;
43
import java.awt.Image;
44 44

  
45
import com.hardcode.driverManager.DriverLoadException;
45 46
import com.hardcode.gdbms.engine.data.DataSource;
46 47
import com.hardcode.gdbms.engine.values.Value;
47
import com.hardcode.gdbms.engine.values.ValueFactory;
48

  
49 48
import com.iver.cit.gvsig.fmap.DriverException;
50 49
import com.iver.cit.gvsig.fmap.core.DefaultFeature;
51 50
import com.iver.cit.gvsig.fmap.core.IFeature;
......
53 52
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes;
54 53
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
55 54
import com.iver.cit.gvsig.fmap.drivers.VectorialDriver;
56
import com.iver.cit.gvsig.fmap.operations.strategies.ShapeInfo;
57
import com.iver.cit.gvsig.fmap.rendering.indexes.Indexable;
58 55

  
59
import java.awt.Image;
60
import java.awt.geom.Rectangle2D;
61
import java.nio.ByteBuffer;
62
import java.sql.Types;
63 56

  
64

  
65 57
/**
66 58
 * Clase padre de los adaptadores de los drivers. De momento mantiene solo el
67 59
 * ?ndice creado sobre la capa
68 60
 */
69 61
public abstract class VectorialAdapter implements ReadableVectorial {
70 62
	protected VectorialDriver driver;
71
	private ShapeInfo shapeInfo;
72 63

  
73 64
	/**
74 65
	 * Establece el driver sobre el que act?a el adaptador
......
89 80
		return driver;
90 81
	}
91 82

  
92
	/**
93
	 * Crea un ?ndice para la capa. Se comprueba si el driver implementa
94
	 * Indexable. Si lo es, se delega la creaci?n en el driver, si no se crea
95
	 * un ?ndice interno con IndexFactory
96
	 *
97
	 * @param boundingBox Rect?ngulo.
98
	 *
99
	 * @throws DriverIOException
100
	 */
101
	public void createIndex(Rectangle2D boundingBox) throws DriverIOException {
102
	}
103 83

  
104 84
	/**
105
	 * Mira si la capa tiene un ?ndice, bien propio del tipo de capa, bien
106
	 * interno de gvSIG
107
	 *
108
	 * @return True si la capa contiene ?ndice.
109
	 */
110
	public boolean hasIndex() {
111
		//TODO Implementar bien
112
		return false;
113
	}
114

  
115
	/**
116
	 * Si el driver es indexable devuelve el valor de la invocaci?n a
117
	 * getIndexFile del driver, si no, devuelve la ruta del fichero de ?ndices
118
	 * interno de gvSIG
119
	 *
120
	 * @return String.
121
	 */
122
	public String getIndexFile() {
123
		//TODO implementar bien
124
		return null;
125
	}
126

  
127
	/**
128
	 * @see com.iver.cit.gvsig.fmap.rendering.indexes.Index#openIndexFile(java.lang.String)
129
	 */
130
	public void openIndexFile(String file) {
131
	}
132

  
133
	/**
134
	 * @see com.iver.cit.gvsig.fmap.rendering.indexes.Index#closeIndexFile()
135
	 */
136
	public void closeIndexFile() {
137
	}
138

  
139
	/**
140 85
	 * Devuelve el DataSource a pasrtir del nombre.
141 86
	 *
142 87
	 * @return DataSource.
......
146 91
	public abstract DataSource getRecordset()
147 92
		throws DriverLoadException;
148 93

  
149
	/**
150
	 * Devuelve el ShapeInfo.
151
	 *
152
	 * @return Returns the shapeInfo.
153
	 */
154
	public ShapeInfo getShapeInfo() {
155
		return shapeInfo;
156
	}
157 94
    
158
    
159

  
95
    	
160 96
	/**
161
	 * Inserta el ShapeInfo.
162
	 *
163
	 * @param shapeInfo The shapeInfo to set.
164
	 */
165
	public void setShapeInfo(ShapeInfo shapeInfo) {
166
		this.shapeInfo = shapeInfo;
167
	}
168

  
169
	
170
	/**
171 97
	 * Por defecto devuelve null, y se le pone el icono por defecto.
172 98
	 * Si el driver reescribe este m?todo, se usar? este icono en el TOC.
173 99
	 * 
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/operations/strategies/ShpStrategy.java
113 113
			ICoordTrans ct = getCapa().getCoordTrans();
114 114
			BitSet bitSet = selection.getSelection();
115 115
			BoundedShapes shapeBounds = (BoundedShapes) adapter.getDriver();
116
			VectorialFileDriver driver = (VectorialFileDriver) adapter.getDriver();
116
			// VectorialFileDriver driver = (VectorialFileDriver) adapter.getDriver();
117 117
			// logger.debug("adapter.start() -> Layer:" + getCapa().getName());
118 118
			adapter.start();
119 119
			IGeometry geom;
......
168 168
			}
169 169
            
170 170
            List lstIndexes = null;
171
			
172
            if (lyr.getSpatialIndex() == null)
173
                sc = adapter.getShapeCount();
174
            else
171
            
172
            // If area of needed extent is less than fullExtent / 4,
173
            // it will be worthy to use SpatialIndex.
174
            // Otherwhise, we will not use it.
175
			boolean bUseSpatialIndex = false;
176
            sc = adapter.getShapeCount();
177
            if (lyr.getSpatialIndex() != null)
175 178
            {
176
                Coordinate c1 = new Coordinate(extent.getMinX(), extent.getMinY());
177
                Coordinate c2 = new Coordinate(extent.getMaxX(), extent.getMaxY());
178
                Envelope env = new Envelope(c1, c2);
179
                lstIndexes = lyr.getSpatialIndex().query(env);
180
                sc = lstIndexes.size();
179
                double areaExtent = extent.getWidth() * extent.getHeight();
180
                double areaFullExtent = lyr.getFullExtent().getWidth() * 
181
                                                lyr.getFullExtent().getHeight();
182
                if (areaExtent < (areaFullExtent / 4.0))
183
                {
184
                    Coordinate c1 = new Coordinate(extent.getMinX(), extent.getMinY());
185
                    Coordinate c2 = new Coordinate(extent.getMaxX(), extent.getMaxY());
186
                    Envelope env = new Envelope(c1, c2);
187
                    lstIndexes = lyr.getSpatialIndex().query(env);
188
                    sc = lstIndexes.size();
189
                    bUseSpatialIndex = true;
190
                }
181 191
            }
182 192
            int i;
193
            
183 194
			for (int aux = 0; aux < sc; aux++) {
184 195
				// Salimos si alguien cancela
185 196
				if (cancel.isCanceled()) {
186 197
					break;
187 198
				}
188
                if (lyr.getSpatialIndex() == null)
189
                    i = aux;
190
                else
199
                if (bUseSpatialIndex)
191 200
                {
192 201
                    Integer idRec = (Integer) lstIndexes.get(aux);
193 202
                    i = idRec.intValue();
194 203
                }
204
                else
205
                {
206
                    i = aux;
207
                }
195 208
                
196 209
				bounds = shapeBounds.getShapeBounds(i);
197 210

  
......
211 224
					if (bPoint ||
212 225
							((bounds.getHeight() > viewPort.getDist1pixel()) ||
213 226
							(bounds.getWidth() > viewPort.getDist1pixel()))) {
214
						geom = driver.getShape(i);
227
						geom = adapter.getShape(i);
215 228
                        
216 229
                        // PRUEBA DE VELOCIDAD
217 230
                        // geom = ShapeFactory.createPolygon2D(new GeneralPathX(bounds));

Also available in: Unified diff