[Groonga-commit] groonga/groonga at 9b5e783 [master] geo: name condition that checks whether longitude is wrapped

Back to archive index

Kouhei Sutou null+****@clear*****
Sun Dec 8 22:35:06 JST 2013


Kouhei Sutou	2013-12-08 22:35:06 +0900 (Sun, 08 Dec 2013)

  New Revision: 9b5e783c0a08e72304570582b5984c88cf7fa56c
  https://github.com/groonga/groonga/commit/9b5e783c0a08e72304570582b5984c88cf7fa56c

  Message:
    geo: name condition that checks whether longitude is wrapped

  Modified files:
    lib/geo.c

  Modified: lib/geo.c (+6 -3)
===================================================================
--- lib/geo.c    2013-12-08 22:25:17 +0900 (826467d)
+++ lib/geo.c    2013-12-08 22:35:06 +0900 (057d1b6)
@@ -31,6 +31,9 @@
 #define GRN_GEO_POINT_IN_SOUTH_EAST(point) \
   ((point)->latitude < 0 && (point)->longitude >= 0)
 
+#define GRN_GEO_LOGITUDE_IS_WRAPPED(top_left, bottom_right) \
+  ((top_left)->longitude > 0 && (bottom_right)->longitude < 0)
+
 typedef struct {
   grn_id id;
   double d;
@@ -1311,7 +1314,7 @@ extract_rectangle_in_area(grn_ctx *ctx,
         GRN_GEO_POINT_IN_NORTH_EAST(bottom_right)) {
       area_top_left->latitude     = MAX(top_left->latitude,      0);
       area_bottom_right->latitude = MAX(bottom_right->latitude,  0);
-      if (top_left->longitude > 0 && bottom_right->longitude < 0) {
+      if (GRN_GEO_LOGITUDE_IS_WRAPPED(top_left, bottom_right)) {
         area_top_left->longitude     = top_left->longitude;
         area_bottom_right->longitude = GRN_GEO_MAX_LONGITUDE;
       } else {
@@ -1327,7 +1330,7 @@ extract_rectangle_in_area(grn_ctx *ctx,
         GRN_GEO_POINT_IN_NORTH_WEST(bottom_right)) {
       area_top_left->latitude     = MAX(top_left->latitude,       0);
       area_bottom_right->latitude = MAX(bottom_right->latitude,   0);
-      if (top_left->longitude > 0 && bottom_right->longitude < 0) {
+      if (GRN_GEO_LOGITUDE_IS_WRAPPED(top_left, bottom_right)) {
         area_top_left->longitude     = GRN_GEO_MIN_LONGITUDE;
         area_bottom_right->longitude = bottom_right->longitude;
       } else {
@@ -2113,7 +2116,7 @@ grn_geo_in_rectangle_raw(grn_ctx *ctx, grn_geo_point *point,
     return GRN_FALSE;
   }
 
-  if (top_left->longitude > 0 && bottom_right->longitude < 0) {
+  if (GRN_GEO_LOGITUDE_IS_WRAPPED(top_left, bottom_right)) {
     if (point->longitude >= top_left->longitude) {
       return GRN_TRUE;
     }
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index