Revision 929
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/operations/strategies/QueryByGeometryVisitor.java | ||
---|---|---|
12 | 12 |
private Geometry geom; |
13 | 13 |
private int relation; |
14 | 14 |
private FBitSet bitset = null; |
15 |
public static final int EQUALS = 0; |
|
16 |
public static final int DISJOINT = 1; |
|
17 |
public static final int INTERSECTS = 2; |
|
18 |
public static final int TOUCHES = 3; |
|
19 |
public static final int CROSSES = 4; |
|
20 |
public static final int WITHIN = 5; |
|
21 |
public static final int CONTAINS = 6; |
|
22 |
public static final int OVERLAPS = 7; |
|
15 | 23 |
|
16 | 24 |
/** |
17 | 25 |
* |
... | ... | |
29 | 37 |
IntersectionMatrix m = geom.relate(g1); |
30 | 38 |
|
31 | 39 |
switch (relation) { |
32 |
case SelectionByThemeVisitor.CONTAINS:
|
|
40 |
case CONTAINS: |
|
33 | 41 |
if (m.isContains()) { |
34 | 42 |
bitset.set(index, true); |
35 | 43 |
} |
36 | 44 |
break; |
37 | 45 |
|
38 |
case SelectionByThemeVisitor.CROSSES:
|
|
46 |
case CROSSES: |
|
39 | 47 |
|
40 | 48 |
if (m.isCrosses(g1.getDimension(), geom.getDimension())) { |
41 | 49 |
bitset.set(index, true); |
... | ... | |
43 | 51 |
|
44 | 52 |
break; |
45 | 53 |
|
46 |
case SelectionByThemeVisitor.DISJOINT:
|
|
47 |
if (m.isDisjoint()) {
|
|
54 |
case DISJOINT: |
|
55 |
if (m.isDisjoint()) {
|
|
48 | 56 |
bitset.set(index, true); |
49 | 57 |
} |
50 | 58 |
break; |
51 | 59 |
|
52 |
case SelectionByThemeVisitor.EQUALS:
|
|
60 |
case EQUALS: |
|
53 | 61 |
if (m.isEquals(g1.getDimension(), geom.getDimension())) { |
54 | 62 |
bitset.set(index, true); |
55 | 63 |
} |
56 | 64 |
|
57 | 65 |
break; |
58 | 66 |
|
59 |
case SelectionByThemeVisitor.INTERSECTS:
|
|
67 |
case INTERSECTS: |
|
60 | 68 |
|
61 | 69 |
if (m.isIntersects()) { |
62 | 70 |
bitset.set(index, true); |
... | ... | |
64 | 72 |
|
65 | 73 |
break; |
66 | 74 |
|
67 |
case SelectionByThemeVisitor.OVERLAPS:
|
|
75 |
case OVERLAPS: |
|
68 | 76 |
|
69 | 77 |
if (m.isOverlaps(g1.getDimension(), |
70 | 78 |
geom.getDimension())) { |
... | ... | |
73 | 81 |
|
74 | 82 |
break; |
75 | 83 |
|
76 |
case SelectionByThemeVisitor.TOUCHES:
|
|
84 |
case TOUCHES: |
|
77 | 85 |
|
78 | 86 |
if (m.isTouches(g1.getDimension(), geom.getDimension())) { |
79 | 87 |
bitset.set(index, true); |
... | ... | |
81 | 89 |
|
82 | 90 |
break; |
83 | 91 |
|
84 |
case SelectionByThemeVisitor.WITHIN:
|
|
92 |
case WITHIN: |
|
85 | 93 |
if (m.isWithin()) { |
86 | 94 |
bitset.set(index, true); |
87 | 95 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/operations/strategies/Strategy.java | ||
---|---|---|
1 | 1 |
/* Generated by Together */ |
2 | 2 |
package com.iver.cit.gvsig.fmap.operations.strategies; |
3 | 3 |
|
4 |
import java.awt.Graphics2D; |
|
5 |
import java.awt.geom.Rectangle2D; |
|
6 |
import java.awt.image.BufferedImage; |
|
7 |
import java.util.BitSet; |
|
4 |
import com.hardcode.driverManager.DriverLoadException; |
|
8 | 5 |
|
9 |
import com.hardcode.driverManager.DriverLoadException; |
|
10 | 6 |
import com.iver.cit.gvsig.fmap.DriverException; |
11 | 7 |
import com.iver.cit.gvsig.fmap.ViewPort; |
12 | 8 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
... | ... | |
14 | 10 |
import com.iver.cit.gvsig.fmap.operations.Cancellable; |
15 | 11 |
import com.iver.cit.gvsig.fmap.operations.QueriedPoint; |
16 | 12 |
|
13 |
import java.awt.Graphics2D; |
|
14 |
import java.awt.geom.Rectangle2D; |
|
15 |
import java.awt.image.BufferedImage; |
|
17 | 16 |
|
17 |
import java.util.BitSet; |
|
18 |
|
|
19 |
|
|
18 | 20 |
/** |
19 | 21 |
* DOCUMENT ME! |
20 | 22 |
* |
21 | 23 |
* @author $author$ |
22 | 24 |
*/ |
23 | 25 |
public interface Strategy { |
24 |
/** |
|
25 |
* Dibuja la capa vectorial asociada al Strategy en la imagen que se pasa |
|
26 |
* como par?metro. |
|
27 |
* |
|
28 |
* @param image DOCUMENT ME! |
|
29 |
* @param g DOCUMENT ME! |
|
30 |
* @param viewPort DOCUMENT ME! |
|
31 |
* @param cancel |
|
32 |
* |
|
33 |
* @throws DriverIOException DOCUMENT ME! |
|
34 |
* @throws DriverException |
|
35 |
* @throws DriverLoadException |
|
36 |
* @throws DriverLoadException |
|
37 |
* @throws DriverException |
|
38 |
*/ |
|
39 |
void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, Cancellable cancel) |
|
40 |
throws DriverException; |
|
26 |
/** |
|
27 |
* Dibuja la capa vectorial asociada al Strategy en la imagen que se pasa |
|
28 |
* como par?metro. |
|
29 |
* |
|
30 |
* @param image DOCUMENT ME! |
|
31 |
* @param g DOCUMENT ME! |
|
32 |
* @param viewPort DOCUMENT ME! |
|
33 |
* @param cancel |
|
34 |
* |
|
35 |
* @throws DriverException |
|
36 |
*/ |
|
37 |
void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
|
38 |
Cancellable cancel) throws DriverException; |
|
41 | 39 |
|
42 |
/**
|
|
40 |
/**
|
|
43 | 41 |
* Dibujar? esta Shape en el Graphics con el s?mbolo que se pasa como |
44 | 42 |
* par?metro y despues de aplicarle la transformaci?n que se pasa tambi?n |
45 | 43 |
* como par?metro. Dibujar? la geometria en caso de que la IGeometry |
46 | 44 |
* intersecte o est? contenida en el rect?ngulo que se pasa como par?metro |
47 | 45 |
* |
48 | 46 |
* @param g DOCUMENT ME! |
49 |
* @param mt DOCUMENT ME! |
|
50 |
* @param symbol DOCUMENT ME! |
|
51 |
* @param extent DOCUMENT ME! |
|
52 |
* @throws DriverException |
|
53 |
* @throws DriverLoadException |
|
54 |
* @throws DriverException |
|
55 |
* @throws DriverLoadException |
|
47 |
* @param viewPort DOCUMENT ME! |
|
48 |
* @param cancel DOCUMENT ME! |
|
49 |
* |
|
50 |
* @throws DriverException |
|
56 | 51 |
*/ |
57 | 52 |
void print(Graphics2D g, ViewPort viewPort, Cancellable cancel) |
58 | 53 |
throws DriverException; |
59 |
|
|
60 |
/** |
|
61 |
* Recorre las features de la capa vectorial invocando el m?todo visit del |
|
62 |
* visitador que se pasa como par?metro, que es el que realizar? la |
|
63 |
* operaci?n relacionada con la geometry |
|
64 |
* |
|
65 |
* @param visitor DOCUMENT ME! |
|
66 |
* @param subset DOCUMENT ME! |
|
67 |
* |
|
68 |
* @throws DriverIOException |
|
69 |
*/ |
|
70 |
void process(FeatureVisitor visitor, BitSet subset) |
|
71 |
throws DriverException; |
|
72 | 54 |
|
73 |
/** |
|
74 |
* Recorre las features de la capa vectorial invocando el m?todo visit del |
|
75 |
* visitador que se pasa como par?metro, que es el que realizar? la |
|
76 |
* operaci?n relacionada con la geometry |
|
77 |
* |
|
78 |
* @param visitor DOCUMENT ME! |
|
79 |
* |
|
80 |
* @throws DriverIOException |
|
81 |
*/ |
|
82 |
void process(FeatureVisitor visitor) throws DriverException; |
|
55 |
/** |
|
56 |
* Recorre las features de la capa vectorial invocando el m?todo visit del |
|
57 |
* visitador que se pasa como par?metro, que es el que realizar? la |
|
58 |
* operaci?n relacionada con la geometry |
|
59 |
* |
|
60 |
* @param visitor DOCUMENT ME! |
|
61 |
* @param subset DOCUMENT ME! |
|
62 |
* |
|
63 |
* @throws DriverException |
|
64 |
* @throws VisitException Si el visitor lanza una excepci?n al procesar una |
|
65 |
* geometr?a de la capa |
|
66 |
*/ |
|
67 |
void process(FeatureVisitor visitor, BitSet subset) |
|
68 |
throws DriverException, VisitException; |
|
83 | 69 |
|
84 |
/** |
|
85 |
* Realiza una query por punto en coordenadas del mundo real de la capa |
|
86 |
* vectorial asociada a la estrategia |
|
87 |
* |
|
88 |
* @param p DOCUMENT ME! |
|
89 |
* @param tolerance DOCUMENT ME! |
|
90 |
* |
|
91 |
* @return DOCUMENT ME! |
|
92 |
*/ |
|
93 |
BitSet queryByPoint(QueriedPoint p, double tolerance) throws DriverException; |
|
70 |
/** |
|
71 |
* Recorre las features de la capa vectorial invocando el m?todo visit del |
|
72 |
* visitador que se pasa como par?metro, que es el que realizar? la |
|
73 |
* operaci?n relacionada con la geometry |
|
74 |
* |
|
75 |
* @param visitor DOCUMENT ME! |
|
76 |
* |
|
77 |
* @throws DriverException |
|
78 |
* @throws VisitException Si el visitor lanza una excepci?n al procesar una |
|
79 |
* geometr?a de la capa |
|
80 |
*/ |
|
81 |
void process(FeatureVisitor visitor) throws DriverException, VisitException; |
|
94 | 82 |
|
95 |
/** |
|
96 |
* Realiza una query por rect?ngulo en coordenadas del mundo real de la |
|
97 |
* capa vectorial asociada a la estrategia |
|
98 |
* @param rect DOCUMENT ME! |
|
99 |
* @return DOCUMENT ME! |
|
100 |
*/ |
|
101 |
BitSet queryByRect(Rectangle2D rect) throws DriverException; |
|
83 |
/** |
|
84 |
* Realiza una query por punto en coordenadas del mundo real de la capa |
|
85 |
* vectorial asociada a la estrategia |
|
86 |
* |
|
87 |
* @param p DOCUMENT ME! |
|
88 |
* @param tolerance DOCUMENT ME! |
|
89 |
* |
|
90 |
* @return DOCUMENT ME! |
|
91 |
* |
|
92 |
* @throws DriverException DOCUMENT ME! |
|
93 |
*/ |
|
94 |
BitSet queryByPoint(QueriedPoint p, double tolerance) |
|
95 |
throws DriverException; |
|
102 | 96 |
|
103 |
/** |
|
104 |
* Realiza una query por IGeometry en coordenadas del mundo real de la capa |
|
105 |
* vectorial asociada a la estrategia |
|
106 |
* |
|
107 |
* @param g DOCUMENT ME! |
|
108 |
* @param relationship DOCUMENT ME! |
|
109 |
* |
|
110 |
* @return DOCUMENT ME! |
|
111 |
*/ |
|
112 |
BitSet queryByShape(IGeometry g, int relationship)throws DriverException; |
|
97 |
/** |
|
98 |
* Realiza una query por rect?ngulo en coordenadas del mundo real de la |
|
99 |
* capa vectorial asociada a la estrategia |
|
100 |
* |
|
101 |
* @param rect DOCUMENT ME! |
|
102 |
* |
|
103 |
* @return DOCUMENT ME! |
|
104 |
* |
|
105 |
* @throws DriverException DOCUMENT ME! |
|
106 |
*/ |
|
107 |
BitSet queryByRect(Rectangle2D rect) throws DriverException; |
|
113 | 108 |
|
114 |
/** |
|
115 |
* Obtiene el rect?ngulo m?nimo que contiene todas las features |
|
116 |
* seleccionadas o null si no hay ninguna seleccionada |
|
117 |
* |
|
118 |
* @return DOCUMENT ME! |
|
119 |
*/ |
|
120 |
Rectangle2D getSelectionBounds(); |
|
109 |
/** |
|
110 |
* Realiza una query por IGeometry en coordenadas del mundo real de la capa |
|
111 |
* vectorial asociada a la estrategia |
|
112 |
* |
|
113 |
* @param g DOCUMENT ME! |
|
114 |
* @param relationship DOCUMENT ME! |
|
115 |
* |
|
116 |
* @return DOCUMENT ME! |
|
117 |
* |
|
118 |
* @throws DriverException DOCUMENT ME! |
|
119 |
* @throws VisitException |
|
120 |
*/ |
|
121 |
BitSet queryByShape(IGeometry g, int relationship) |
|
122 |
throws DriverException, VisitException; |
|
121 | 123 |
|
122 |
/** |
|
123 |
* Crea un ?ndice sobre la capa vectorial de la estrategia |
|
124 |
*/ |
|
125 |
void createIndex(); |
|
124 |
/** |
|
125 |
* Obtiene el rect?ngulo m?nimo que contiene todas las features |
|
126 |
* seleccionadas o null si no hay ninguna seleccionada |
|
127 |
* |
|
128 |
* @return DOCUMENT ME! |
|
129 |
*/ |
|
130 |
Rectangle2D getSelectionBounds(); |
|
131 |
|
|
132 |
/** |
|
133 |
* Crea un ?ndice sobre la capa vectorial de la estrategia |
|
134 |
*/ |
|
135 |
void createIndex(); |
|
126 | 136 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/operations/strategies/DefaultStrategy.java | ||
---|---|---|
52 | 52 |
public BitSet queryByRect(Rectangle2D rect) throws DriverException { |
53 | 53 |
QueryByRectVisitor visitor = new QueryByRectVisitor(); |
54 | 54 |
visitor.setRect(rect); |
55 |
process(visitor); |
|
55 |
try{ |
|
56 |
process(visitor); |
|
57 |
} catch (VisitException e) { |
|
58 |
throw new RuntimeException("QueryByRectVisitor lanza una VisitException?"); |
|
59 |
} |
|
56 | 60 |
|
57 | 61 |
return visitor.getBitSet(); |
58 | 62 |
} |
... | ... | |
71 | 75 |
* int) |
72 | 76 |
*/ |
73 | 77 |
public BitSet queryByShape(IGeometry g, int relationship) |
74 |
throws DriverException { |
|
78 |
throws DriverException, VisitException {
|
|
75 | 79 |
QueryByShapeVisitor visitor = new QueryByShapeVisitor(); |
76 | 80 |
visitor.setRelationShip(relationship); |
77 | 81 |
visitor.setShape(g); |
... | ... | |
187 | 191 |
* com.iver.cit.gvsig.fmap.operations.selection.VectorialSubSet) |
188 | 192 |
*/ |
189 | 193 |
public void process(FeatureVisitor visitor, BitSet subset) |
190 |
throws DriverException { |
|
194 |
throws DriverException, VisitException {
|
|
191 | 195 |
try{ |
192 | 196 |
logger.debug("visitor.start()"); |
193 | 197 |
|
... | ... | |
209 | 213 |
} |
210 | 214 |
|
211 | 215 |
/** |
216 |
* @throws VisitException |
|
212 | 217 |
* @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#process(com.iver.cit.gvsig.fmap.operations.strategies.FeatureVisitor) |
213 | 218 |
*/ |
214 |
public void process(FeatureVisitor visitor) throws DriverException { |
|
219 |
public void process(FeatureVisitor visitor) throws DriverException, VisitException {
|
|
215 | 220 |
try{ |
216 | 221 |
logger.debug("visitor.start()"); |
217 | 222 |
|
... | ... | |
227 | 232 |
} |
228 | 233 |
}catch(DriverIOException e){ |
229 | 234 |
throw new DriverException(e); |
230 |
} |
|
235 |
}
|
|
231 | 236 |
} |
232 | 237 |
|
233 | 238 |
/** |
... | ... | |
240 | 245 |
visitor.setLayer(capa); |
241 | 246 |
visitor.setTolerance(tolerance); |
242 | 247 |
visitor.setQueriedPoint(p); |
243 |
process(visitor); |
|
248 |
try { |
|
249 |
process(visitor); |
|
250 |
} catch (VisitException e) { |
|
251 |
throw new RuntimeException("QueryByPointVisitor lanza una VisitException?"); |
|
252 |
} |
|
244 | 253 |
|
245 | 254 |
return visitor.getBitSet(); |
246 | 255 |
} |
Also available in: Unified diff