1 package org.apache.lucene.spatial.tier.projections;
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership.
7 * The ASF licenses this file to You under the Apache License, Version 2.0
8 * (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 import org.apache.lucene.util.LuceneTestCase;
21 import org.junit.Test;
28 public class SinusoidalProjectorTest extends LuceneTestCase {
31 public void testProjection() throws Exception {
32 SinusoidalProjector prj = new SinusoidalProjector();
33 //TODO: uncomment once SinusoidalProjector is fixed. Unfortunately, fixing it breaks a lot of other stuff
35 doubles = prj.coords(-89.0, 10);
36 assertEquals(0.003, doubles[0], 0.001);//x
37 assertEquals(-89.0 * DistanceUtils.DEGREES_TO_RADIANS, doubles[1]);
39 doubles = prj.coords(89.0, 0);
40 assertEquals(0.0, doubles[0]);//x
41 assertEquals(89.0 * DistanceUtils.DEGREES_TO_RADIANS, doubles[1]);
43 doubles = prj.coords(89.0, 10);
44 assertEquals(0.003, doubles[0], 0.001);//x
45 assertEquals(89.0 * DistanceUtils.DEGREES_TO_RADIANS, doubles[1]);
48 doubles = prj.coords(-89.0, 0);
49 assertEquals(0.0, doubles[0]);//x
50 assertEquals(-89.0 * DistanceUtils.DEGREES_TO_RADIANS, doubles[1]);*/
56 //This code demonstrates that the SinusoidalProjector is incorrect
58 public void testFoo() throws Exception {
59 CartesianTierPlotter plotter = new CartesianTierPlotter(11, new SinusoidalProjector(), "foo");
60 SinusoidalProjector prj = new SinusoidalProjector();
61 System.out.println("---- Equator ---");
62 printValues(plotter, prj, 0);
63 System.out.println("---- North ---");
64 printValues(plotter, prj, 89.0);
65 System.out.println("---- South ---");
66 printValues(plotter, prj, -89.0);
69 private void printValues(CartesianTierPlotter plotter, SinusoidalProjector prj, double latitude){
70 for (int i = 0; i <= 10; i++){
71 double boxId = plotter.getTierBoxId(latitude, i);
72 double[] doubles = prj.coords(latitude, i);
73 System.out.println("Box[" + latitude + ", " + i + "] = " + boxId + " sinusoidal: [" + doubles[0] + ", " + doubles[1] + "]");
75 for (int i = -10; i <= 0; i++){
76 double boxId = plotter.getTierBoxId(latitude, i);
77 double[] doubles = prj.coords(latitude, i);
78 System.out.println("Box[" + latitude + ", " + i + "] = " + boxId + " sinusoidal: [" + doubles[0] + ", " + doubles[1] + "]");