[Groonga-commit] groonga/groonga at 9e849fa [master] geo_in_rectangle: support north/west area

Back to archive index

Kouhei Sutou null+****@clear*****
Sat Dec 7 21:54:41 JST 2013


Kouhei Sutou	2013-12-07 21:54:41 +0900 (Sat, 07 Dec 2013)

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

  Message:
    geo_in_rectangle: support north/west area

  Added files:
    test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/east_out.expected
    test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/east_out.test
    test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/east_west_out.expected
    test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/east_west_out.test
    test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/north_east_out.expected
    test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/north_east_out.test
    test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/north_out.expected
    test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/north_out.test
    test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/north_south_out.expected
    test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/north_south_out.test
    test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/north_west_out.expected
    test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/north_west_out.test
    test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/same_as_mesh.expected
    test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/same_as_mesh.test
    test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/south_east_out.expected
    test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/south_east_out.test
    test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/south_out.expected
    test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/south_out.test
    test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/south_west_out.expected
    test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/south_west_out.test
    test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/west_out.expected
    test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/west_out.test
  Modified files:
    lib/geo.c

  Modified: lib/geo.c (+24 -3)
===================================================================
--- lib/geo.c    2013-12-07 21:48:06 +0900 (6776731)
+++ lib/geo.c    2013-12-07 21:54:41 +0900 (0aa605b)
@@ -1057,10 +1057,9 @@ in_rectangle_data_validate(grn_ctx *ctx,
   top_left = data->top_left;
   bottom_right = data->bottom_right;
 
-  if (top_left->latitude < 0 || top_left->longitude < 0 ||
-      bottom_right->latitude < 0 || bottom_right->longitude < 0) {
+  if (top_left->latitude < 0 || bottom_right->latitude < 0) {
     ERR(GRN_FUNCTION_NOT_IMPLEMENTED,
-        "%s: negative coordinate is not implemented.", process_name);
+        "%s: the Southern Hemisphere is not implemented.", process_name);
     return;
   }
 
@@ -1086,6 +1085,17 @@ in_rectangle_data_validate(grn_ctx *ctx,
     return;
   }
 
+  if (top_left->longitude <= GRN_GEO_MIN_LONGITUDE) {
+    ERR(GRN_INVALID_ARGUMENT,
+        "%s: top left point's longitude is too small: "
+        "<%d>(max:%d): (%d,%d) (%d,%d)",
+        process_name,
+        GRN_GEO_MIN_LONGITUDE, top_left->longitude,
+        top_left->latitude, top_left->longitude,
+        bottom_right->latitude, bottom_right->longitude);
+    return;
+  }
+
   if (bottom_right->latitude >= GRN_GEO_MAX_LATITUDE) {
     ERR(GRN_INVALID_ARGUMENT,
         "%s: bottom right point's latitude is too big: "
@@ -1107,6 +1117,17 @@ in_rectangle_data_validate(grn_ctx *ctx,
         bottom_right->latitude, bottom_right->longitude);
     return;
   }
+
+  if (bottom_right->longitude <= GRN_GEO_MIN_LONGITUDE) {
+    ERR(GRN_INVALID_ARGUMENT,
+        "%s: bottom right point's longitude is too small: "
+        "<%d>(max:%d): (%d,%d) (%d,%d)",
+        process_name,
+        GRN_GEO_MIN_LONGITUDE, bottom_right->longitude,
+        top_left->latitude, top_left->longitude,
+        bottom_right->latitude, bottom_right->longitude);
+    return;
+  }
 }
 
 static void

  Added: test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/east_out.expected (+39 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/east_out.expected    2013-12-07 21:54:41 +0900 (2191b33)
@@ -0,0 +1,39 @@
+select LandMarks --sortby '_id' --output_columns 'point' --limit -1   --filter 'geo_in_rectangle(point, "3x-4", "2x-2")'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        6
+      ],
+      [
+        [
+          "point",
+          "WGS84GeoPoint"
+        ]
+      ],
+      [
+        "2x-2"
+      ],
+      [
+        "2x-3"
+      ],
+      [
+        "2x-4"
+      ],
+      [
+        "3x-2"
+      ],
+      [
+        "3x-3"
+      ],
+      [
+        "3x-4"
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/east_out.test (+4 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/east_out.test    2013-12-07 21:54:41 +0900 (d10638d)
@@ -0,0 +1,4 @@
+#@include fixture/geo/in_rectangle/north_west.grn
+
+select LandMarks --sortby '_id' --output_columns 'point' --limit -1 \
+  --filter 'geo_in_rectangle(point, "3x-4", "2x-2")'

  Added: test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/east_west_out.expected (+45 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/east_west_out.expected    2013-12-07 21:54:41 +0900 (1e710f7)
@@ -0,0 +1,45 @@
+select LandMarks --sortby '_id' --output_columns 'point' --limit -1   --filter 'geo_in_rectangle(point, "3x-5", "2x-2")'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        8
+      ],
+      [
+        [
+          "point",
+          "WGS84GeoPoint"
+        ]
+      ],
+      [
+        "2x-2"
+      ],
+      [
+        "2x-3"
+      ],
+      [
+        "2x-4"
+      ],
+      [
+        "2x-5"
+      ],
+      [
+        "3x-2"
+      ],
+      [
+        "3x-3"
+      ],
+      [
+        "3x-4"
+      ],
+      [
+        "3x-5"
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/east_west_out.test (+4 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/east_west_out.test    2013-12-07 21:54:41 +0900 (5439de9)
@@ -0,0 +1,4 @@
+#@include fixture/geo/in_rectangle/north_west.grn
+
+select LandMarks --sortby '_id' --output_columns 'point' --limit -1 \
+  --filter 'geo_in_rectangle(point, "3x-5", "2x-2")'

  Added: test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/north_east_out.expected (+48 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/north_east_out.expected    2013-12-07 21:54:41 +0900 (4c43f48)
@@ -0,0 +1,48 @@
+select LandMarks --sortby '_id' --output_columns 'point' --limit -1   --filter 'geo_in_rectangle(point, "4x-4", "2x-2")'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        9
+      ],
+      [
+        [
+          "point",
+          "WGS84GeoPoint"
+        ]
+      ],
+      [
+        "2x-2"
+      ],
+      [
+        "2x-3"
+      ],
+      [
+        "2x-4"
+      ],
+      [
+        "3x-2"
+      ],
+      [
+        "3x-3"
+      ],
+      [
+        "3x-4"
+      ],
+      [
+        "4x-2"
+      ],
+      [
+        "4x-3"
+      ],
+      [
+        "4x-4"
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/north_east_out.test (+4 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/north_east_out.test    2013-12-07 21:54:41 +0900 (fb37667)
@@ -0,0 +1,4 @@
+#@include fixture/geo/in_rectangle/north_west.grn
+
+select LandMarks --sortby '_id' --output_columns 'point' --limit -1 \
+  --filter 'geo_in_rectangle(point, "4x-4", "2x-2")'

  Added: test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/north_out.expected (+39 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/north_out.expected    2013-12-07 21:54:41 +0900 (ae1b08f)
@@ -0,0 +1,39 @@
+select LandMarks --sortby '_id' --output_columns 'point' --limit -1   --filter 'geo_in_rectangle(point, "4x-4", "2x-3")'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        6
+      ],
+      [
+        [
+          "point",
+          "WGS84GeoPoint"
+        ]
+      ],
+      [
+        "2x-3"
+      ],
+      [
+        "2x-4"
+      ],
+      [
+        "3x-3"
+      ],
+      [
+        "3x-4"
+      ],
+      [
+        "4x-3"
+      ],
+      [
+        "4x-4"
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/north_out.test (+4 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/north_out.test    2013-12-07 21:54:41 +0900 (1d57803)
@@ -0,0 +1,4 @@
+#@include fixture/geo/in_rectangle/north_west.grn
+
+select LandMarks --sortby '_id' --output_columns 'point' --limit -1 \
+  --filter 'geo_in_rectangle(point, "4x-4", "2x-3")'

  Added: test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/north_south_out.expected (+45 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/north_south_out.expected    2013-12-07 21:54:41 +0900 (e12a10e)
@@ -0,0 +1,45 @@
+select LandMarks --sortby '_id' --output_columns 'point' --limit -1   --filter 'geo_in_rectangle(point, "4x-4", "1x-3")'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        8
+      ],
+      [
+        [
+          "point",
+          "WGS84GeoPoint"
+        ]
+      ],
+      [
+        "1x-3"
+      ],
+      [
+        "1x-4"
+      ],
+      [
+        "2x-3"
+      ],
+      [
+        "2x-4"
+      ],
+      [
+        "3x-3"
+      ],
+      [
+        "3x-4"
+      ],
+      [
+        "4x-3"
+      ],
+      [
+        "4x-4"
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/north_south_out.test (+4 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/north_south_out.test    2013-12-07 21:54:41 +0900 (49ec9f1)
@@ -0,0 +1,4 @@
+#@include fixture/geo/in_rectangle/north_west.grn
+
+select LandMarks --sortby '_id' --output_columns 'point' --limit -1 \
+  --filter 'geo_in_rectangle(point, "4x-4", "1x-3")'

  Added: test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/north_west_out.expected (+48 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/north_west_out.expected    2013-12-07 21:54:41 +0900 (94871eb)
@@ -0,0 +1,48 @@
+select LandMarks --sortby '_id' --output_columns 'point' --limit -1   --filter 'geo_in_rectangle(point, "4x-5", "2x-3")'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        9
+      ],
+      [
+        [
+          "point",
+          "WGS84GeoPoint"
+        ]
+      ],
+      [
+        "2x-3"
+      ],
+      [
+        "2x-4"
+      ],
+      [
+        "2x-5"
+      ],
+      [
+        "3x-3"
+      ],
+      [
+        "3x-4"
+      ],
+      [
+        "3x-5"
+      ],
+      [
+        "4x-3"
+      ],
+      [
+        "4x-4"
+      ],
+      [
+        "4x-5"
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/north_west_out.test (+4 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/north_west_out.test    2013-12-07 21:54:41 +0900 (90ac1f8)
@@ -0,0 +1,4 @@
+#@include fixture/geo/in_rectangle/north_west.grn
+
+select LandMarks --sortby '_id' --output_columns 'point' --limit -1 \
+  --filter 'geo_in_rectangle(point, "4x-5", "2x-3")'

  Added: test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/same_as_mesh.expected (+33 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/same_as_mesh.expected    2013-12-07 21:54:41 +0900 (1262675)
@@ -0,0 +1,33 @@
+select LandMarks --sortby '_id' --output_columns 'point' --limit -1   --filter 'geo_in_rectangle(point, "3x-4", "2x-3")'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        4
+      ],
+      [
+        [
+          "point",
+          "WGS84GeoPoint"
+        ]
+      ],
+      [
+        "2x-3"
+      ],
+      [
+        "2x-4"
+      ],
+      [
+        "3x-3"
+      ],
+      [
+        "3x-4"
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/same_as_mesh.test (+4 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/same_as_mesh.test    2013-12-07 21:54:41 +0900 (b495fce)
@@ -0,0 +1,4 @@
+#@include fixture/geo/in_rectangle/north_west.grn
+
+select LandMarks --sortby '_id' --output_columns 'point' --limit -1 \
+  --filter 'geo_in_rectangle(point, "3x-4", "2x-3")'

  Added: test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/south_east_out.expected (+48 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/south_east_out.expected    2013-12-07 21:54:41 +0900 (72152be)
@@ -0,0 +1,48 @@
+select LandMarks --sortby '_id' --output_columns 'point' --limit -1   --filter 'geo_in_rectangle(point, "3x-4", "1x-2")'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        9
+      ],
+      [
+        [
+          "point",
+          "WGS84GeoPoint"
+        ]
+      ],
+      [
+        "1x-2"
+      ],
+      [
+        "1x-3"
+      ],
+      [
+        "1x-4"
+      ],
+      [
+        "2x-2"
+      ],
+      [
+        "2x-3"
+      ],
+      [
+        "2x-4"
+      ],
+      [
+        "3x-2"
+      ],
+      [
+        "3x-3"
+      ],
+      [
+        "3x-4"
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/south_east_out.test (+4 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/south_east_out.test    2013-12-07 21:54:41 +0900 (2ee8b81)
@@ -0,0 +1,4 @@
+#@include fixture/geo/in_rectangle/north_west.grn
+
+select LandMarks --sortby '_id' --output_columns 'point' --limit -1 \
+  --filter 'geo_in_rectangle(point, "3x-4", "1x-2")'

  Added: test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/south_out.expected (+39 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/south_out.expected    2013-12-07 21:54:41 +0900 (2c18dd9)
@@ -0,0 +1,39 @@
+select LandMarks --sortby '_id' --output_columns 'point' --limit -1   --filter 'geo_in_rectangle(point, "3x-4", "1x-3")'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        6
+      ],
+      [
+        [
+          "point",
+          "WGS84GeoPoint"
+        ]
+      ],
+      [
+        "1x-3"
+      ],
+      [
+        "1x-4"
+      ],
+      [
+        "2x-3"
+      ],
+      [
+        "2x-4"
+      ],
+      [
+        "3x-3"
+      ],
+      [
+        "3x-4"
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/south_out.test (+4 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/south_out.test    2013-12-07 21:54:41 +0900 (2863306)
@@ -0,0 +1,4 @@
+#@include fixture/geo/in_rectangle/north_west.grn
+
+select LandMarks --sortby '_id' --output_columns 'point' --limit -1 \
+  --filter 'geo_in_rectangle(point, "3x-4", "1x-3")'

  Added: test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/south_west_out.expected (+48 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/south_west_out.expected    2013-12-07 21:54:41 +0900 (eeb7856)
@@ -0,0 +1,48 @@
+select LandMarks --sortby '_id' --output_columns 'point' --limit -1   --filter 'geo_in_rectangle(point, "3x-5", "1x-3")'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        9
+      ],
+      [
+        [
+          "point",
+          "WGS84GeoPoint"
+        ]
+      ],
+      [
+        "1x-3"
+      ],
+      [
+        "1x-4"
+      ],
+      [
+        "1x-5"
+      ],
+      [
+        "2x-3"
+      ],
+      [
+        "2x-4"
+      ],
+      [
+        "2x-5"
+      ],
+      [
+        "3x-3"
+      ],
+      [
+        "3x-4"
+      ],
+      [
+        "3x-5"
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/south_west_out.test (+4 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/south_west_out.test    2013-12-07 21:54:41 +0900 (2cd5a4c)
@@ -0,0 +1,4 @@
+#@include fixture/geo/in_rectangle/north_west.grn
+
+select LandMarks --sortby '_id' --output_columns 'point' --limit -1 \
+  --filter 'geo_in_rectangle(point, "3x-5", "1x-3")'

  Added: test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/west_out.expected (+39 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/west_out.expected    2013-12-07 21:54:41 +0900 (d886ea0)
@@ -0,0 +1,39 @@
+select LandMarks --sortby '_id' --output_columns 'point' --limit -1   --filter 'geo_in_rectangle(point, "3x-5", "2x-3")'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        6
+      ],
+      [
+        [
+          "point",
+          "WGS84GeoPoint"
+        ]
+      ],
+      [
+        "2x-3"
+      ],
+      [
+        "2x-4"
+      ],
+      [
+        "2x-5"
+      ],
+      [
+        "3x-3"
+      ],
+      [
+        "3x-4"
+      ],
+      [
+        "3x-5"
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/west_out.test (+4 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/geo_in_rectangle/north_west/use_index/west_out.test    2013-12-07 21:54:41 +0900 (09ccc51)
@@ -0,0 +1,4 @@
+#@include fixture/geo/in_rectangle/north_west.grn
+
+select LandMarks --sortby '_id' --output_columns 'point' --limit -1 \
+  --filter 'geo_in_rectangle(point, "3x-5", "2x-3")'
-------------- next part --------------
HTML����������������������������...
Download 



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