Statistics
| Revision:

root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / operations / strategies / FilterRectVisitor.java @ 10627

History | View | Annotate | Download (3.09 KB)

1
/*
2
 * Created on 26-feb-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: FilterRectVisitor.java 10627 2007-03-06 17:10:21Z caballero $
47
* $Log$
48
* Revision 1.4  2007-03-06 17:08:55  caballero
49
* Exceptions
50
*
51
* Revision 1.3  2006/06/20 18:15:19  azabala
52
* a?adida comprobaci?n de geometria nula en la construcci?n del indice espacial
53
*
54
* Revision 1.2  2006/03/07 20:59:28  azabala
55
* *** empty log message ***
56
*
57
* Revision 1.1  2006/02/26 20:50:00  azabala
58
* *** empty log message ***
59
*
60
*
61
*/
62
package com.iver.cit.gvsig.fmap.operations.strategies;
63

    
64
import java.awt.geom.Rectangle2D;
65

    
66
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
67
import com.iver.cit.gvsig.exceptions.visitors.ProcessVisitorException;
68
import com.iver.cit.gvsig.exceptions.visitors.StartVisitorException;
69
import com.iver.cit.gvsig.exceptions.visitors.VisitorException;
70
import com.iver.cit.gvsig.fmap.core.IGeometry;
71
import com.iver.cit.gvsig.fmap.layers.FLayer;
72
/**
73
 * This FeatureVisitor is a spatial filter.
74
 * It wraps a FeatureVisitor, and only calls its visit
75
 * method if visited geometries are within specified rectangle.
76
 * @author azabala
77
 *
78
 */
79
public class FilterRectVisitor implements FeatureVisitor {
80
        private Rectangle2D rect;
81
        private FeatureVisitor wrappedVisitor;
82

    
83
        public void setRectangle(Rectangle2D rect){
84
                this.rect = rect;
85
        }
86
        public void visit(IGeometry g, int index) throws ReadDriverException, VisitorException, ProcessVisitorException {
87
                if ((g != null) && (g.intersects(rect))) {
88
                        wrappedVisitor.visit(g, index);
89
                }
90
        }
91
        public void stop(FLayer layer) throws VisitorException {
92
                wrappedVisitor.stop(layer);
93
        }
94

    
95
        public boolean start(FLayer layer) throws StartVisitorException {
96
                return wrappedVisitor.start(layer);
97
        }
98
        public FeatureVisitor getWrappedVisitor() {
99
                return wrappedVisitor;
100
        }
101
        public void setWrappedVisitor(FeatureVisitor wrappedVisitor) {
102
                this.wrappedVisitor = wrappedVisitor;
103
        }
104
        public String getProcessDescription() {
105
                return "Filters visit calls to a visitor by spatial criteria";
106
        }
107

    
108

    
109
}
110