[Groonga-commit] groonga/groonga [master] geo: return the value of correct distance according to quadrant type

Back to archive index

null+****@clear***** null+****@clear*****
2012年 6月 13日 (水) 16:30:12 JST


HAYASHI Kentaro	2012-06-13 16:30:12 +0900 (Wed, 13 Jun 2012)

  New Revision: 1efada4d78ba735e0276ad0a2ca41195648f58ba

  Log:
    geo: return the value of correct distance according to quadrant type
    
    refs #1389

  Modified files:
    lib/geo.c

  Modified: lib/geo.c (+15 -0)
===================================================================
--- lib/geo.c    2012-06-13 15:36:29 +0900 (ea58d82)
+++ lib/geo.c    2012-06-13 16:30:12 +0900 (e9eb6a1)
@@ -1974,6 +1974,21 @@ grn_geo_distance_rectangle_raw(grn_ctx *ctx,
                                                            M_PI,
                                                            intercept_edge);
         distance = (east_distance + west_distance) * GRN_GEO_RADIUS;
+      } else if (quad_type == QUADRANT_2ND_TO_1ST) {
+        longitude_delta = lng1 + M_2PI - lng2;
+        latitude_delta = lat1 - lat2;
+        slope = latitude_delta / longitude_delta;
+        intercept = lat2 - slope * lng2;
+        intercept_edge = slope * M_PI + intercept;
+        east_distance = geo_distance_rectangle_calculation(lng2,
+                                                           lat2,
+                                                           M_PI,
+                                                           intercept_edge);
+        west_distance = geo_distance_rectangle_calculation(-lng1,
+                                                           lat1,
+                                                           M_PI,
+                                                           intercept_edge);
+        distance = (east_distance + west_distance) * GRN_GEO_RADIUS;
       } else {
         x = (lng2 - lng1) * cos((lat1 + lat2) * 0.5);
         y = (lat2 - lat1);




Groonga-commit メーリングリストの案内
Back to archive index