001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2004-2006, Geotools Project Managment Committee (PMC)
005: * (C) 2004 TOPP - www.openplans.org
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * Created on Apr 29, 2004
018: */
019: package org.geotools.validation.relate;
020:
021: import junit.framework.TestCase;
022:
023: import org.geotools.data.DataUtilities;
024: import org.geotools.data.memory.MemoryDataStore;
025: import org.geotools.feature.Feature;
026: import org.geotools.feature.FeatureType;
027: import org.geotools.filter.Filter;
028: import org.geotools.filter.FilterFactory;
029: import org.geotools.validation.ValidationResults;
030:
031: import com.vividsolutions.jts.geom.Coordinate;
032: import com.vividsolutions.jts.geom.Envelope;
033: import com.vividsolutions.jts.geom.GeometryFactory;
034: import com.vividsolutions.jts.geom.LineString;
035:
036: /**
037: * SpatialTestCase<br>
038: * @author bowens<br>
039: * Created Apr 29, 2004<br>
040: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/extension/validation/src/main/java/org/geotools/validation/relate/SpatialTestCase.java $
041: * @version <br>
042: *
043: * <b>Puropse:</b><br>
044: * <p>
045: * DOCUMENT ME!!
046: * </p>
047: *
048: * <b>Description:</b><br>
049: * <p>
050: * DOCUMENT ME!!
051: * </p>
052: *
053: * <b>Usage:</b><br>
054: * <p>
055: * DOCUMENT ME!!
056: * </p>
057: */
058: public class SpatialTestCase extends TestCase {
059: protected GeometryFactory gf;
060: protected FeatureType lineType;
061: protected Feature[] lineFeatures;
062: protected Envelope lineBounds;
063: protected LineString ls0, ls1, ls2, ls3;
064: protected String namespace;
065: protected FilterFactory filterFactory;
066: protected Filter lineFilter;
067:
068: MemoryDataStore mds; // assumes a consistant data type
069: ValidationResults vr;
070:
071: /**
072: * Constructor for OverlapsIntegrityTest.
073: * @param arg0
074: */
075: public SpatialTestCase(String arg0) {
076: super (arg0);
077: }
078:
079: /**
080: * @see junit.framework.TestCase#setUp()
081: *
082: * <code><pre>
083: *
084: * (0,2) (2.6,2)
085: * x x
086: * \ |
087: * \ls1 |ls2
088: * \ |
089: * (1,1)+ +
090: * | |
091: * | |
092: * ls0 | (2,0.1) | ls3
093: * (0,0)x----------+----------+----------+==========x----------x
094: * | | (4,0) (5,0.1)
095: * | |
096: * | |
097: * x x
098: * (1,-1) (2,-1)
099: *
100: * </pre></code>
101: */
102: protected void setUp() throws Exception {
103: gf = new GeometryFactory();
104: mds = new MemoryDataStore();
105: namespace = getName();
106: vr = new TempFeatureResults();
107:
108: lineFeatures = new Feature[4];
109: ls0 = gf.createLineString(new Coordinate[] {
110: new Coordinate(0, 0), new Coordinate(2, 0.1),
111: new Coordinate(3, 0), new Coordinate(4, 0) });
112: ls1 = gf.createLineString(new Coordinate[] {
113: new Coordinate(0, 2), new Coordinate(1, 1),
114: new Coordinate(1, 0), new Coordinate(1, -1) });
115: ls2 = gf.createLineString(new Coordinate[] {
116: new Coordinate(2.6, 2), new Coordinate(2.5, 1),
117: new Coordinate(2.5, -1) });
118: ls3 = gf.createLineString(new Coordinate[] {
119: new Coordinate(3, 0), new Coordinate(4, 0),
120: new Coordinate(5, 0.1) });
121:
122: lineType = DataUtilities.createType("my.line",
123: "id:0,geom:LineString,name:String");
124: lineFeatures[0] = lineType.create(new Object[] {
125: new Integer(0), ls0, "line0" }, "line.line0");
126: lineFeatures[1] = lineType.create(new Object[] {
127: new Integer(1), ls1, "line1" }, "line.line1");
128: lineFeatures[2] = lineType.create(new Object[] {
129: new Integer(2), ls2, "line2" }, "line.line2");
130: lineFeatures[3] = lineType.create(new Object[] {
131: new Integer(3), ls3, "line3" }, "line.line3");
132: lineBounds = new Envelope();
133: lineBounds.expandToInclude(lineFeatures[0].getBounds());
134: lineBounds.expandToInclude(lineFeatures[1].getBounds());
135: lineBounds.expandToInclude(lineFeatures[2].getBounds());
136: lineBounds.expandToInclude(lineFeatures[3].getBounds());
137:
138: // filterFactory = FilterFactoryFinder.createFilterFactory();
139: // BBoxExpression bbex = filterFactory.createBBoxExpression(lineBounds);
140:
141: mds.addFeature(lineFeatures[0]);
142: mds.addFeature(lineFeatures[1]);
143: mds.addFeature(lineFeatures[2]);
144: mds.addFeature(lineFeatures[3]);
145: }
146:
147: protected void tearDown() throws Exception {
148: gf = null;
149: lineType = null;
150: lineFeatures = null;
151: lineBounds = null;
152: ls0 = null;
153: ls1 = null;
154: ls2 = null;
155: ls3 = null;
156: namespace = null;
157: vr = null;
158: }
159:
160: }
|