Revision 28332
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/operations/strategies/QueryByGeometryVisitor.java | ||
---|---|---|
69 | 69 |
public static final int WITHIN = 5; |
70 | 70 |
public static final int CONTAINS = 6; |
71 | 71 |
public static final int OVERLAPS = 7; |
72 |
|
|
72 |
|
|
73 | 73 |
private Geometry getJTSgeom() |
74 | 74 |
{ |
75 | 75 |
if (geom == null) |
76 | 76 |
geom = geom_gvSIG.toJTSGeometry(); |
77 | 77 |
return geom; |
78 | 78 |
} |
79 |
|
|
79 |
|
|
80 | 80 |
/** |
81 |
*
|
|
81 |
* |
|
82 | 82 |
*/ |
83 | 83 |
public QueryByGeometryVisitor(IGeometry geom, int relation) { |
84 | 84 |
this.geomBounds = geom.getBounds2D(); |
... | ... | |
95 | 95 |
IntersectionMatrix m; |
96 | 96 |
switch (relation) { |
97 | 97 |
case CONTAINS: |
98 |
// if (XRectangle2D.intersectInclusive(extent, bounds)) { |
|
99 |
if (geomBounds.contains(g.getBounds2D())) |
|
100 |
{ |
|
101 |
g1 = g.toJTSGeometry(); |
|
102 |
m = getJTSgeom().relate(g1); |
|
103 |
|
|
104 |
if (m.isContains()) { |
|
105 |
bitset.set(index, true); |
|
106 |
} |
|
107 |
} |
|
108 |
break; |
|
98 |
if (XRectangle2D.intersectInclusive(geomBounds, g.getBounds2D())) { |
|
99 |
g1 = g.toJTSGeometry(); |
|
100 |
m = getJTSgeom().relate(g1); |
|
109 | 101 |
|
102 |
if (m.isContains()) { |
|
103 |
bitset.set(index, true); |
|
104 |
} |
|
105 |
} |
|
106 |
break; |
|
107 |
|
|
110 | 108 |
case CROSSES: |
111 |
if (XRectangle2D.intersectInclusive(geomBounds, g.getBounds2D()))
|
|
112 |
{
|
|
113 |
g1 = g.toJTSGeometry();
|
|
114 |
m = getJTSgeom().relate(g1);
|
|
109 |
if (XRectangle2D.intersectInclusive(geomBounds, g.getBounds2D()))
|
|
110 |
{
|
|
111 |
g1 = g.toJTSGeometry();
|
|
112 |
m = getJTSgeom().relate(g1);
|
|
115 | 113 |
|
116 |
if (m.isCrosses(g1.getDimension(), geom.getDimension())) {
|
|
117 |
bitset.set(index, true);
|
|
118 |
}
|
|
119 |
}
|
|
120 |
break;
|
|
114 |
if (m.isCrosses(g1.getDimension(), geom.getDimension())) {
|
|
115 |
bitset.set(index, true);
|
|
116 |
}
|
|
117 |
}
|
|
118 |
break;
|
|
121 | 119 |
|
122 | 120 |
case DISJOINT: |
123 |
// TODO: POR OPTIMIZAR
|
|
124 |
g1 = g.toJTSGeometry();
|
|
125 |
m = getJTSgeom().relate(g1);
|
|
121 |
// TODO: POR OPTIMIZAR
|
|
122 |
g1 = g.toJTSGeometry();
|
|
123 |
m = getJTSgeom().relate(g1);
|
|
126 | 124 |
if (m.isDisjoint()) { |
127 |
bitset.set(index, true);
|
|
128 |
}
|
|
129 |
break;
|
|
125 |
bitset.set(index, true);
|
|
126 |
}
|
|
127 |
break;
|
|
130 | 128 |
|
131 | 129 |
case EQUALS: |
132 |
// TODO: REVISAR ESTO PARA QUE COMPRUEBE SI SON IGUALES LOS RECTANGULOS
|
|
133 |
// Y DE PASO, COMPROBAR SI HACE FALTA USAR ESTA FUNCI?N DONDE
|
|
134 |
// SE USE EL Rectangle2D.contains
|
|
135 |
if (XRectangle2D.containsInclusive(geomBounds, g.getBounds2D()))
|
|
136 |
{
|
|
137 |
g1 = g.toJTSGeometry();
|
|
138 |
m = getJTSgeom().relate(g1);
|
|
139 |
if (m.isEquals(g1.getDimension(), getJTSgeom().getDimension())) {
|
|
140 |
bitset.set(index, true);
|
|
141 |
}
|
|
142 |
}
|
|
143 |
break;
|
|
130 |
// TODO: REVISAR ESTO PARA QUE COMPRUEBE SI SON IGUALES LOS RECTANGULOS
|
|
131 |
// Y DE PASO, COMPROBAR SI HACE FALTA USAR ESTA FUNCI?N DONDE
|
|
132 |
// SE USE EL Rectangle2D.contains
|
|
133 |
if (XRectangle2D.containsInclusive(geomBounds, g.getBounds2D()))
|
|
134 |
{
|
|
135 |
g1 = g.toJTSGeometry();
|
|
136 |
m = getJTSgeom().relate(g1);
|
|
137 |
if (m.isEquals(g1.getDimension(), getJTSgeom().getDimension())) {
|
|
138 |
bitset.set(index, true);
|
|
139 |
}
|
|
140 |
}
|
|
141 |
break;
|
|
144 | 142 |
|
145 | 143 |
case INTERSECTS: |
146 |
if (XRectangle2D.intersectInclusive(geomBounds, g.getBounds2D()))
|
|
147 |
{
|
|
148 |
g1 = g.toJTSGeometry();
|
|
149 |
m = getJTSgeom().relate(g1);
|
|
144 |
if (XRectangle2D.intersectInclusive(geomBounds, g.getBounds2D()))
|
|
145 |
{
|
|
146 |
g1 = g.toJTSGeometry();
|
|
147 |
m = getJTSgeom().relate(g1);
|
|
150 | 148 |
|
151 |
if (m.isIntersects()) {
|
|
152 |
bitset.set(index, true);
|
|
153 |
}
|
|
154 |
}
|
|
155 |
break;
|
|
149 |
if (m.isIntersects()) {
|
|
150 |
bitset.set(index, true);
|
|
151 |
}
|
|
152 |
}
|
|
153 |
break;
|
|
156 | 154 |
|
157 | 155 |
case OVERLAPS: |
158 |
if (XRectangle2D.intersectInclusive(geomBounds, g.getBounds2D()))
|
|
159 |
{
|
|
160 |
g1 = g.toJTSGeometry();
|
|
161 |
m = getJTSgeom().relate(g1);
|
|
162 |
if (m.isOverlaps(g1.getDimension(),
|
|
163 |
geom.getDimension())) {
|
|
164 |
bitset.set(index, true);
|
|
165 |
}
|
|
166 |
}
|
|
156 |
if (XRectangle2D.intersectInclusive(geomBounds, g.getBounds2D()))
|
|
157 |
{
|
|
158 |
g1 = g.toJTSGeometry();
|
|
159 |
m = getJTSgeom().relate(g1);
|
|
160 |
if (m.isOverlaps(g1.getDimension(),
|
|
161 |
geom.getDimension())) {
|
|
162 |
bitset.set(index, true);
|
|
163 |
}
|
|
164 |
}
|
|
167 | 165 |
|
168 |
break;
|
|
166 |
break;
|
|
169 | 167 |
|
170 | 168 |
case TOUCHES: |
171 |
if (XRectangle2D.intersectInclusive(geomBounds, g.getBounds2D()))
|
|
172 |
{
|
|
173 |
g1 = g.toJTSGeometry();
|
|
174 |
m = getJTSgeom().relate(g1);
|
|
175 |
if (m.isTouches(g1.getDimension(), geom.getDimension())) {
|
|
176 |
bitset.set(index, true);
|
|
177 |
}
|
|
178 |
}
|
|
169 |
if (XRectangle2D.intersectInclusive(geomBounds, g.getBounds2D()))
|
|
170 |
{
|
|
171 |
g1 = g.toJTSGeometry();
|
|
172 |
m = getJTSgeom().relate(g1);
|
|
173 |
if (m.isTouches(g1.getDimension(), geom.getDimension())) {
|
|
174 |
bitset.set(index, true);
|
|
175 |
}
|
|
176 |
}
|
|
179 | 177 |
|
180 |
break;
|
|
178 |
break;
|
|
181 | 179 |
|
182 | 180 |
case WITHIN: |
183 |
// TODO: POR OPTIMIZAR
|
|
184 |
g1 = g.toJTSGeometry();
|
|
185 |
m = getJTSgeom().relate(g1);
|
|
181 |
if (XRectangle2D.intersectInclusive(geomBounds, g.getBounds2D())) {
|
|
182 |
g1 = g.toJTSGeometry();
|
|
183 |
m = getJTSgeom().relate(g1);
|
|
186 | 184 |
|
187 |
if (m.isWithin()) { |
|
188 |
bitset.set(index, true); |
|
189 |
} |
|
185 |
if (m.isWithin()) { |
|
186 |
bitset.set(index, true); |
|
187 |
} |
|
188 |
} |
|
190 | 189 |
|
191 |
break;
|
|
190 |
break;
|
|
192 | 191 |
} |
193 | 192 |
} |
194 | 193 |
|
Also available in: Unified diff