Revision 2978 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLyrVect.java

View differences:

FLyrVect.java
44 44
import java.awt.geom.Point2D;
45 45
import java.awt.geom.Rectangle2D;
46 46
import java.awt.image.BufferedImage;
47
import java.io.IOException;
47 48
import java.util.ArrayList;
48 49
import java.util.BitSet;
49 50

  
......
64 65
import com.iver.cit.gvsig.fmap.core.IGeometry;
65 66
import com.iver.cit.gvsig.fmap.core.v02.FLabel;
66 67
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
68
import com.iver.cit.gvsig.fmap.drivers.BoundedShapes;
67 69
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes;
68 70
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
69 71
import com.iver.cit.gvsig.fmap.drivers.VectorialDatabaseDriver;
......
85 87
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend;
86 88
import com.iver.utiles.PostProcessSupport;
87 89
import com.iver.utiles.XMLEntity;
90
import com.vividsolutions.jts.geom.Coordinate;
91
import com.vividsolutions.jts.geom.Envelope;
92
import com.vividsolutions.jts.index.quadtree.Quadtree;
88 93

  
89 94

  
90 95
/**
......
107 112
	private VectorialAdapter source;
108 113
	private SelectableDataSource sds;
109 114
    
115
    private Quadtree spatialIndex = null;
116
    
110 117
    private boolean bHasJoin = false;
111 118

  
112 119
	/**
......
365 372
		setLayerText(null);
366 373
	}
367 374

  
368
	/**
369
	 * @see com.iver.cit.gvsig.fmap.layers.VectorialOperations#createIndex()
375
	/* (non-Javadoc)
376
	 * @see com.iver.cit.gvsig.fmap.layers.layerOperations.RandomVectorialData#createIndex()
370 377
	 */
371
	public void createIndex() {
378
	public void createSpatialIndex() {
379
        // FJP: ESTO HABR? QUE CAMBIARLO. PARA LAS CAPAS SECUENCIALES, TENDREMOS
380
        // QUE ACCEDER CON UN WHILE NEXT. (O mejorar lo de los FeatureVisitor
381
        // para que acepten recorrer sin geometria, solo con rectangulos.
382
        spatialIndex = new Quadtree();
383
        VectorialAdapter va = getSource();
384
        ICoordTrans ct = getCoordTrans();
385
        BoundedShapes shapeBounds = (BoundedShapes) va.getDriver();
386
        try {
387
            va.start();
388

  
389
            for (int i=0; i < va.getShapeCount(); i++)
390
            {               
391
                Rectangle2D r = shapeBounds.getShapeBounds(i);
392
                // TODO: MIRAR COMO SE TRAGAR?A ESTO LO DE LAS REPROYECCIONES
393
                if (ct != null) {
394
                    r = ct.convert(r);
395
                }
396
                Coordinate c1 = new Coordinate(r.getMinX(), r.getMinY());
397
                Coordinate c2 = new Coordinate(r.getMaxX(), r.getMaxY());
398
                Envelope env = new Envelope(c1, c2);
399
                spatialIndex.insert(env, new Integer(i));
400
            } // for
401
            va.stop();
402
        } catch (DriverIOException e) {
403
            // TODO Auto-generated catch block
404
            e.printStackTrace();
405
        } catch (IOException e) {
406
            // TODO Auto-generated catch block
407
            e.printStackTrace();
408
        }
409
        
372 410
	}
373 411

  
374 412
	/**
......
419 457
		selectionSupport.clearSelection();
420 458
	}
421 459

  
422
	/**
423
	 * @see com.iver.cit.gvsig.fmap.layers.CommonOperations#queryByRect(java.awt.geom.Rectangle2D)
460
	/* (non-Javadoc)
461
	 * @see com.iver.cit.gvsig.fmap.layers.layerOperations.RandomVectorialData#queryByRect(java.awt.geom.Rectangle2D)
424 462
	 */
425
	public BitSet queryByRect(Rectangle2D rect) throws DriverException {
463
	public FBitSet queryByRect(Rectangle2D rect) throws DriverException {
426 464
		Strategy s = StrategyManager.getStrategy(this);
427 465

  
428 466
		return s.queryByRect(rect);
429 467
	}
430 468

  
469
    public FBitSet queryByPoint(Point2D p, double tolerance) throws DriverException
470
    {
471
        Strategy s = StrategyManager.getStrategy(this);
472
        return s.queryByPoint(p, tolerance);       
473
    }
474
    
475
    public FBitSet queryByShape(IGeometry g, int relationship) throws DriverException, VisitException
476
    {
477
        Strategy s = StrategyManager.getStrategy(this);
478
        return s.queryByShape(g, relationship);        
479
    }
431 480
	/**
432 481
	 * @throws DriverException
433 482
	 * @see com.iver.cit.gvsig.fmap.layers.CommonOperations#getRecordset()
......
700 749
    public void setIsJoined(boolean hasJoin) {
701 750
        bHasJoin = hasJoin;
702 751
    }
752

  
753
    /**
754
     * @return Returns the spatialIndex.
755
     */
756
    public Quadtree getSpatialIndex() {
757
        return spatialIndex;
758
    }
703 759
}

Also available in: Unified diff