pylucene 3.5.0-3
[pylucene.git] / lucene-java-3.5.0 / lucene / contrib / spatial / src / java / org / apache / lucene / spatial / tier / projections / SinusoidalProjector.java
1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements.  See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License.  You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 package org.apache.lucene.spatial.tier.projections;
19
20 /**
21  * Based on Sinusoidal Projections
22  * Project a latitude / longitude on a 2D cartesian map
23  * <p/>
24  * THIS PROJECTION IS WRONG, but it's not going to be fixed b/c it will break a lot of existing tests, plus we are deprecating
25  * most of the existing spatial and replacing with a more reliable approach.
26  *
27  * <p><font color="red"><b>NOTE:</b> This API is still in
28  * flux and might change in incompatible ways in the next
29  * release.</font>
30  *
31  * @deprecated Until we can put in place proper tests and a proper fix. 
32  */
33 @Deprecated
34 public class SinusoidalProjector implements IProjector {
35
36
37   public String coordsAsString(double latitude, double longitude) {
38     return null;
39   }
40
41   public double[] coords(double latitude, double longitude) {
42     double rlat = Math.toRadians(latitude);
43     double rlong = Math.toRadians(longitude);
44     double nlat = rlong * Math.cos(rlat);
45     double r[] = {nlat, rlong};
46     return r;
47     
48   }
49   
50 }
51
52 /*
53 This whole file should really be:*/
54
55 /**
56  * Based on Sinusoidal Projections
57  * Project a latitude / longitude on a 2D cartesian map using the Prime Meridian as the "central meridian"
58  *
59  * See http://en.wikipedia.org/wiki/Sinusoidal_projection
60  *
61  * <p><font color="red"><b>NOTE:</b> This API is still in
62  * flux and might change in incompatible ways in the next
63  * release.</font>
64  */
65 /*
66 public class SinusoidalProjector implements IProjector {
67
68
69   public String coordsAsString(double latitude, double longitude) {
70     double [] coords = coords(latitude, longitude);
71     return coords[0] + "," + coords[1];
72   }
73
74   public double[] coords(double latitude, double longitude) {
75     double rlat = latitude * DistanceUtils.DEGREES_TO_RADIANS;
76     double rlong = longitude * DistanceUtils.DEGREES_TO_RADIANS;
77     double x = rlong * Math.cos(rlat);
78     return new double[]{x, rlat};
79
80   }
81
82 }
83 */
84
85
86