01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.renderer.shape;
17:
18: import junit.framework.TestCase;
19:
20: import org.geotools.data.FeatureSource;
21: import org.geotools.data.FeatureStore;
22: import org.geotools.data.memory.MemoryDataStore;
23: import org.geotools.data.shapefile.indexed.IndexedShapefileDataStore;
24: import org.geotools.feature.FeatureCollection;
25: import org.geotools.map.DefaultMapContext;
26: import org.geotools.map.DefaultMapLayer;
27: import org.geotools.map.MapContext;
28: import org.geotools.map.MapLayer;
29:
30: import com.vividsolutions.jts.geom.Envelope;
31:
32: /**
33: * Shapefile renderer delegates to Streaming Renderer if a layer is not a Shapefile layer. This tests that.
34: * @author Jesse
35: */
36: public class RenderNonShapefileTest extends TestCase {
37:
38: public void testRender() throws Exception {
39: MemoryDataStore store = new MemoryDataStore();
40:
41: IndexedShapefileDataStore polys = TestUtilites.getPolygons();
42:
43: FeatureCollection featureCollection = polys.getFeatureSource()
44: .getFeatures();
45: store.createSchema(polys.getSchema());
46:
47: FeatureSource target = store.getFeatureSource(store
48: .getTypeNames()[0]);
49: ((FeatureStore) target).addFeatures(featureCollection);
50:
51: MapLayer layer = new DefaultMapLayer(target,
52: TestUtilites.createTestStyle(target.getSchema()
53: .getTypeName(), null));
54: MapContext context = new DefaultMapContext(
55: new MapLayer[] { layer });
56:
57: ShapefileRenderer renderer = new ShapefileRenderer(context);
58:
59: Envelope env = context.getLayerBounds();
60: env = new Envelope(env.getMinX(), env.getMaxX(), env.getMinY(),
61: env.getMaxY());
62: TestUtilites
63: .showRender("testSimpleRender", renderer, 1000, env);
64:
65: }
66: }
|