01: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
02: * This code is licensed under the GPL 2.0 license, availible at the root
03: * application directory.
04: */
05: package org.vfny.geoserver.wms.responses.map.metatile;
06:
07: import com.vividsolutions.jts.geom.Envelope;
08: import junit.framework.TestCase;
09: import java.awt.Point;
10: import java.awt.geom.Point2D;
11:
12: public class QuickTileCacheTest extends TestCase {
13: QuickTileCache cache = new QuickTileCache();
14:
15: public void testMetaCoordinates() {
16: Point orig = new Point(0, 0);
17: assertEquals(orig, cache.getMetaTileCoordinates(orig));
18:
19: Point t10 = new Point(1, 0);
20: assertEquals(orig, cache.getMetaTileCoordinates(t10));
21:
22: Point t01 = new Point(1, 0);
23: assertEquals(orig, cache.getMetaTileCoordinates(t01));
24:
25: Point t33 = new Point(3, 3);
26: assertEquals(new Point(3, 3), cache.getMetaTileCoordinates(t33));
27:
28: Point tm1m1 = new Point(-1, -1);
29: assertEquals(new Point(-3, -3), cache
30: .getMetaTileCoordinates(tm1m1));
31:
32: Point tm3m3 = new Point(-3, -3);
33: assertEquals(new Point(-3, -3), cache
34: .getMetaTileCoordinates(tm3m3));
35:
36: Point tm4m4 = new Point(-4, -4);
37: assertEquals(new Point(-6, -6), cache
38: .getMetaTileCoordinates(tm4m4));
39:
40: Point t4m4 = new Point(4, -4);
41: assertEquals(new Point(3, -6), cache
42: .getMetaTileCoordinates(t4m4));
43:
44: Point tm44 = new Point(-4, 4);
45: assertEquals(new Point(-6, 3), cache
46: .getMetaTileCoordinates(tm44));
47: }
48:
49: public void testTileCoordinatesNaturalOrigin() {
50: Point2D origin = new Point2D.Double(0, 0);
51: Envelope env = new Envelope(30, 60, 30, 60);
52: Point tc = cache.getTileCoordinates(env, origin);
53: assertEquals(new Point(1, 1), tc);
54:
55: env = new Envelope(-30, 0, -30, 0);
56: tc = cache.getTileCoordinates(env, origin);
57: assertEquals(new Point(-1, -1), tc);
58: }
59: }
|