add --shared
[pylucene.git] / lucene-java-3.4.0 / lucene / contrib / spatial / src / test / org / apache / lucene / spatial / tier / projections / SinusoidalProjectorTest.java
1 package org.apache.lucene.spatial.tier.projections;
2
3 /**
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
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  */
19
20 import org.apache.lucene.util.LuceneTestCase;
21 import org.junit.Test;
22
23
24 /**
25  *
26  *
27  **/
28 public class SinusoidalProjectorTest extends LuceneTestCase {
29
30   @Test
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
34     /*double[] doubles;
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]);
38     
39     doubles = prj.coords(89.0, 0);
40     assertEquals(0.0, doubles[0]);//x
41     assertEquals(89.0 * DistanceUtils.DEGREES_TO_RADIANS, doubles[1]);
42
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]);
46
47
48     doubles = prj.coords(-89.0, 0);
49     assertEquals(0.0, doubles[0]);//x
50     assertEquals(-89.0 * DistanceUtils.DEGREES_TO_RADIANS, doubles[1]);*/
51
52
53   }
54 }
55
56 //This code demonstrates that the SinusoidalProjector is incorrect
57   /*@Test
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);
67   }
68
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] + "]");
74     }
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] + "]");
79     }
80
81   }
82   */