001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: */
016: package org.geotools.filter.v1_0;
017:
018: import org.w3c.dom.Document;
019: import org.opengis.filter.spatial.Beyond;
020: import org.opengis.filter.spatial.BinarySpatialOperator;
021: import org.opengis.filter.spatial.Contains;
022: import org.opengis.filter.spatial.Crosses;
023: import org.opengis.filter.spatial.DWithin;
024: import org.opengis.filter.spatial.Disjoint;
025: import org.opengis.filter.spatial.DistanceBufferOperator;
026: import org.opengis.filter.spatial.Equals;
027: import org.opengis.filter.spatial.Intersects;
028: import org.opengis.filter.spatial.Overlaps;
029: import org.opengis.filter.spatial.Touches;
030: import org.opengis.filter.spatial.Within;
031: import org.geotools.gml3.bindings.GML;
032:
033: public class BinarySpatialOpTypeBindingTest extends FilterTestSupport {
034: public void testDistanceBufferType() {
035: assertEquals(DistanceBufferOperator.class, binding(
036: OGC.DistanceBufferType).getType());
037: }
038:
039: public void testBeyondType() {
040: assertEquals(Beyond.class, binding(OGC.Beyond).getType());
041: }
042:
043: public void testBeyondParse() throws Exception {
044: FilterMockData.beyond(document, document);
045:
046: Beyond beyond = (Beyond) parse();
047:
048: assertNotNull(beyond.getExpression1());
049: assertNotNull(beyond.getExpression2());
050: assertEquals(1.0, beyond.getDistance(), 0.1);
051: }
052:
053: public void testBeyondEncode() throws Exception {
054: Document dom = encode(FilterMockData.beyond(), OGC.Beyond);
055:
056: assertEquals(1, dom.getElementsByTagNameNS(OGC.NAMESPACE,
057: OGC.PropertyName.getLocalPart()).getLength());
058: assertEquals(1, dom.getElementsByTagNameNS(GML.NAMESPACE,
059: GML.Point.getLocalPart()).getLength());
060: assertEquals(1, dom.getElementsByTagNameNS(OGC.NAMESPACE,
061: "Distance").getLength());
062: assertEquals("1.0", dom.getElementsByTagNameNS(OGC.NAMESPACE,
063: "Distance").item(0).getFirstChild().getNodeValue());
064: }
065:
066: public void testDWithinType() {
067: assertEquals(DWithin.class, binding(OGC.DWithin).getType());
068: }
069:
070: public void testDWithinParse() throws Exception {
071: FilterMockData.dwithin(document, document);
072:
073: DWithin dwithin = (DWithin) parse();
074:
075: assertNotNull(dwithin.getExpression1());
076: assertNotNull(dwithin.getExpression2());
077: assertEquals(1.0, dwithin.getDistance(), 0.1);
078: }
079:
080: public void testDWithinEncode() throws Exception {
081: Document dom = encode(FilterMockData.beyond(), OGC.DWithin);
082:
083: assertEquals(1, dom.getElementsByTagNameNS(OGC.NAMESPACE,
084: OGC.PropertyName.getLocalPart()).getLength());
085: assertEquals(1, dom.getElementsByTagNameNS(GML.NAMESPACE,
086: GML.Point.getLocalPart()).getLength());
087: assertEquals(1, dom.getElementsByTagNameNS(OGC.NAMESPACE,
088: "Distance").getLength());
089: assertEquals("1.0", dom.getElementsByTagNameNS(OGC.NAMESPACE,
090: "Distance").item(0).getFirstChild().getNodeValue());
091: }
092:
093: public void testBinarySpatialOpType() {
094: assertEquals(BinarySpatialOperator.class, binding(
095: OGC.BinarySpatialOpType).getType());
096: }
097:
098: public void testContainsType() {
099: assertEquals(Contains.class, binding(OGC.Contains).getType());
100: }
101:
102: public void testContainsParse() throws Exception {
103: FilterMockData.contains(document, document);
104:
105: Contains contains = (Contains) parse();
106:
107: assertNotNull(contains.getExpression1());
108: assertNotNull(contains.getExpression2());
109: }
110:
111: public void testContainsEncode() throws Exception {
112: Document dom = encode(FilterMockData.contains(), OGC.Contains);
113:
114: assertEquals(1, dom.getElementsByTagNameNS(OGC.NAMESPACE,
115: OGC.PropertyName.getLocalPart()).getLength());
116: assertEquals(1, dom.getElementsByTagNameNS(GML.NAMESPACE,
117: GML.Point.getLocalPart()).getLength());
118: }
119:
120: public void testCrossesType() {
121: assertEquals(Crosses.class, binding(OGC.Crosses).getType());
122: }
123:
124: public void testCrossesParse() throws Exception {
125: FilterMockData.crosses(document, document);
126:
127: Crosses crosses = (Crosses) parse();
128:
129: assertNotNull(crosses.getExpression1());
130: assertNotNull(crosses.getExpression2());
131: }
132:
133: public void testCrossesEncode() throws Exception {
134: Document dom = encode(FilterMockData.crosses(), OGC.Crosses);
135:
136: assertEquals(1, dom.getElementsByTagNameNS(OGC.NAMESPACE,
137: OGC.PropertyName.getLocalPart()).getLength());
138: assertEquals(1, dom.getElementsByTagNameNS(GML.NAMESPACE,
139: GML.Point.getLocalPart()).getLength());
140: }
141:
142: public void testDisjointType() {
143: assertEquals(Disjoint.class, binding(OGC.Disjoint).getType());
144: }
145:
146: public void testDisjointParse() throws Exception {
147: FilterMockData.disjoint(document, document);
148:
149: Disjoint disjoint = (Disjoint) parse();
150:
151: assertNotNull(disjoint.getExpression1());
152: assertNotNull(disjoint.getExpression2());
153: }
154:
155: public void testDisjointEncode() throws Exception {
156: Document dom = encode(FilterMockData.disjoint(), OGC.Disjoint);
157:
158: assertEquals(1, dom.getElementsByTagNameNS(OGC.NAMESPACE,
159: OGC.PropertyName.getLocalPart()).getLength());
160: assertEquals(1, dom.getElementsByTagNameNS(GML.NAMESPACE,
161: GML.Point.getLocalPart()).getLength());
162: }
163:
164: public void testEqualsType() {
165: assertEquals(Equals.class, binding(OGC.Equals).getType());
166: }
167:
168: public void testEqualsParse() throws Exception {
169: FilterMockData.equals(document, document);
170:
171: Equals equals = (Equals) parse();
172:
173: assertNotNull(equals.getExpression1());
174: assertNotNull(equals.getExpression2());
175: }
176:
177: public void testEqualsEncode() throws Exception {
178: Document dom = encode(FilterMockData.equals(), OGC.Equals);
179:
180: assertEquals(1, dom.getElementsByTagNameNS(OGC.NAMESPACE,
181: OGC.PropertyName.getLocalPart()).getLength());
182: assertEquals(1, dom.getElementsByTagNameNS(GML.NAMESPACE,
183: GML.Point.getLocalPart()).getLength());
184: }
185:
186: public void testIntersectsType() {
187: assertEquals(Intersects.class, binding(OGC.Intersects)
188: .getType());
189: }
190:
191: public void testIntersectsParse() throws Exception {
192: FilterMockData.intersects(document, document);
193:
194: Intersects intersects = (Intersects) parse();
195:
196: assertNotNull(intersects.getExpression1());
197: assertNotNull(intersects.getExpression2());
198: }
199:
200: public void testIntersectsEncode() throws Exception {
201: Document dom = encode(FilterMockData.intersects(),
202: OGC.Intersects);
203:
204: assertEquals(1, dom.getElementsByTagNameNS(OGC.NAMESPACE,
205: OGC.PropertyName.getLocalPart()).getLength());
206: assertEquals(1, dom.getElementsByTagNameNS(GML.NAMESPACE,
207: GML.Point.getLocalPart()).getLength());
208: }
209:
210: public void testOverlapsType() {
211: assertEquals(Overlaps.class, binding(OGC.Overlaps).getType());
212: }
213:
214: public void testOverlapsParse() throws Exception {
215: FilterMockData.overlaps(document, document);
216:
217: Overlaps overlaps = (Overlaps) parse();
218:
219: assertNotNull(overlaps.getExpression1());
220: assertNotNull(overlaps.getExpression2());
221: }
222:
223: public void testOverlapsEncode() throws Exception {
224: Document dom = encode(FilterMockData.overlaps(), OGC.Overlaps);
225:
226: assertEquals(1, dom.getElementsByTagNameNS(OGC.NAMESPACE,
227: OGC.PropertyName.getLocalPart()).getLength());
228: assertEquals(1, dom.getElementsByTagNameNS(GML.NAMESPACE,
229: GML.Point.getLocalPart()).getLength());
230: }
231:
232: public void testTouchesType() {
233: assertEquals(Touches.class, binding(OGC.Touches).getType());
234: }
235:
236: public void testTouchesParse() throws Exception {
237: FilterMockData.touches(document, document);
238:
239: Touches touches = (Touches) parse();
240:
241: assertNotNull(touches.getExpression1());
242: assertNotNull(touches.getExpression2());
243: }
244:
245: public void testTouchesEncode() throws Exception {
246: Document dom = encode(FilterMockData.touches(), OGC.Touches);
247:
248: assertEquals(1, dom.getElementsByTagNameNS(OGC.NAMESPACE,
249: OGC.PropertyName.getLocalPart()).getLength());
250: assertEquals(1, dom.getElementsByTagNameNS(GML.NAMESPACE,
251: GML.Point.getLocalPart()).getLength());
252: }
253:
254: public void testWithinType() {
255: assertEquals(Within.class, binding(OGC.Within).getType());
256: }
257:
258: public void testWithinParse() throws Exception {
259: FilterMockData.within(document, document);
260:
261: Within within = (Within) parse();
262:
263: assertNotNull(within.getExpression1());
264: assertNotNull(within.getExpression2());
265: }
266:
267: public void testWithinEncode() throws Exception {
268: Document dom = encode(FilterMockData.within(), OGC.Within);
269:
270: assertEquals(1, dom.getElementsByTagNameNS(OGC.NAMESPACE,
271: OGC.PropertyName.getLocalPart()).getLength());
272: assertEquals(1, dom.getElementsByTagNameNS(GML.NAMESPACE,
273: GML.Point.getLocalPart()).getLength());
274: }
275: }
|