20 #include <glib/gstdio.h>
22 #include "../lib/grn-assertions.h"
42 static gchar *tmp_directory;
58 g_free(tmp_directory);
62 remove_tmp_directory(
void)
64 cut_remove_path(tmp_directory, NULL);
70 const gchar *database_path;
78 remove_tmp_directory();
79 g_mkdir_with_parents(tmp_directory, 0700);
84 database_path = cut_build_path(tmp_directory,
"database.groonga", NULL);
103 remove_tmp_directory();
109 gdouble yurakucho_latitude = 35.67487;
110 gdouble yurakucho_longitude = 139.76352;
111 gint distance = 3 * 1000;
113 cut_assert_equal_string(
115 "[[\"name\",\"ShortText\"],[\"_score\",\"Int32\"],"
116 "[\"location\",\"WGS84GeoPoint\"]],"
117 "[\"銀座 かずや\",280,\"128424629x503139222\"],"
118 "[\"たい焼き鉄次 大丸東京店\",810,\"128451283x503166852\"],"
119 "[\"たいやき神田達磨 八重洲店\",970,\"128453260x503174156\"],"
120 "[\"にしみや 甘味処\",1056,\"128418570x503188661\"],"
121 "[\"築地 さのきや\",1186,\"128397312x503174596\"],"
122 "[\"しげ田\",1530,\"128421454x503208983\"],"
123 "[\"柳屋 たい焼き\",2179,\"128467228x503222332\"]"
128 "--sortby '+_score, +name' "
129 "--output_columns 'name, _score, location' "
130 "--filter 'geo_in_circle(location, \"%s\", %d)' "
131 "--scorer '_score=geo_distance(location, \"%s\")'",
140 gdouble sugamo_latitude = 35.73360;
141 gdouble sugamo_longitude = 139.7394;
142 gdouble daiba_latitude = 35.62614;
143 gdouble daiba_longitude = 139.7714;
144 gdouble budoukan_latitude = 35.69328;
145 gdouble budoukan_longitude = 139.74968;
147 cut_assert_equal_string(
149 "[[\"name\",\"ShortText\"],[\"_score\",\"Int32\"],"
150 "[\"location\",\"WGS84GeoPoint\"]],"
151 "[\"たい焼き鉄次 大丸東京店\",2186,\"128451283x503166852\"],"
152 "[\"たいやき神田達磨 八重洲店\",2296,\"128453260x503174156\"],"
153 "[\"銀座 かずや\",2415,\"128424629x503139222\"],"
154 "[\"根津のたいやき\",3210,\"128592911x503145263\"],"
155 "[\"築地 さのきや\",3579,\"128397312x503174596\"]"
160 "--sortby '+_score, +name' "
161 "--output_columns 'name, _score, location' "
162 "--filter 'geo_in_rectangle(location, \"%s\", \"%s\")' "
163 "--scorer '_score=geo_distance(location, \"%s\")'",
172 gdouble takada_no_baba_latitude = 35.7121;
173 gdouble takada_no_baba_longitude = 139.7038;
174 gdouble tsukiji_latitude = 35.6684;
175 gdouble tsukiji_longitude = 139.7727;
176 gdouble budoukan_latitude = 35.69328;
177 gdouble budoukan_longitude = 139.74968;
179 cut_assert_equal_string(
181 "[[\"name\",\"ShortText\"],[\"_score\",\"Int32\"],"
182 "[\"location\",\"WGS84GeoPoint\"]],"
183 "[\"たい焼き鉄次 大丸東京店\",2186,\"128451283x503166852\"],"
184 "[\"たいやき神田達磨 八重洲店\",2296,\"128453260x503174156\"],"
185 "[\"銀座 かずや\",2415,\"128424629x503139222\"]"
190 "--sortby '+_score, +name' "
191 "--output_columns 'name, _score, location' "
192 "--filter 'geo_in_rectangle(location, \"%s\", \"%s\")' "
193 "--scorer '_score=geo_distance(location, \"%s\")'",
195 takada_no_baba_longitude),
203 gdouble takada_no_baba_latitude = 35.7121;
204 gdouble takada_no_baba_longitude = 139.7038;
205 gdouble budoukan_latitude = 35.69328;
206 gdouble budoukan_longitude = 139.74968;
208 cut_assert_equal_string(
210 "[[\"name\",\"ShortText\"],[\"_score\",\"Int32\"],"
211 "[\"location\",\"WGS84GeoPoint\"]]"
216 "--sortby '+_score, +name' "
217 "--output_columns 'name, _score, location' "
218 "--filter 'geo_in_rectangle(location, \"%s\", \"%s\")' "
219 "--scorer '_score=geo_distance(location, \"%s\")'",
221 takada_no_baba_longitude),
223 takada_no_baba_longitude),
233 "geo_in_rectangle(): negative coordinate is not implemented.",
236 "--output_columns 'name, location' "
237 "--filter 'geo_in_rectangle(location, "
238 "\"35.73360x-139.7394\", \"-35.62614x139.7714\")'");
247 "geo_in_rectangle(): top left point's latitude is too big: "
248 "<324000000>(max:324000000): "
249 "(324000000,503061840) (128254104,50317704",
252 "--output_columns 'name, location' "
254 "'geo_in_rectangle(location, \"90.0x139.7394\", \"35.62614x139.7714\")'");
263 "geo_in_rectangle(): top left point's longitude is too big: "
264 "<648000000>(max:648000000): "
265 "(128640960,648000000) (128254104,5031770",
268 "--output_columns 'name, location' "
270 "'geo_in_rectangle(location, \"35.73360x180.0\", \"35.62614x139.7714\")'");
279 "geo_in_rectangle(): bottom right point's latitude is too big: "
280 "<324000000>(max:324000000): "
281 "(128640960,503061840) (324000000,5031",
284 "--output_columns 'name, location' "
286 "'geo_in_rectangle(location, \"35.73360x139.7394\", \"90.0x139.7714\")'");
295 "geo_in_rectangle(): bottom right point's longitude is too big: "
296 "<648000000>(max:648000000): "
297 "(128640960,503061840) (128254104,648",
300 "--output_columns 'name, location' "
302 "'geo_in_rectangle(location, \"35.73360x139.7394\", \"35.62614x180.0\")'");
308 gdouble yurakucho_latitude = 35.67487;
309 gdouble yurakucho_longitude = 139.76352;
310 gint distance = 3 * 1000;
312 cut_assert_equal_string(
314 "[[\"name\",\"ShortText\"],[\"_score\",\"Int32\"]],"
316 "[\"たい焼き鉄次 大丸東京店\",810],"
317 "[\"たいやき神田達磨 八重洲店\",970],"
318 "[\"にしみや 甘味処\",1056],"
319 "[\"築地 さのきや\",1186],"
326 "--sortby 'geo_distance(location, \"%s\")' "
327 "--output_columns 'name, _score' "
328 "--filter 'geo_in_circle(location, \"%s\", %d)' "
329 "--scorer '_score=geo_distance(location, \"%s\")'",
339 gdouble tokyo_tocho_latitude = 35.689444;
340 gdouble tokyo_tocho_longitude = 139.69166701;
342 cut_assert_equal_string(
344 "[[\"name\",\"ShortText\"],[\"_score\",\"Int32\"]],"
347 "[\"そばたいやき空\",3004],"
348 "[\"たい焼 カタオカ\",3347],"
351 "[\"代官山たい焼き黒鯛\",4497],"
352 "[\"たいやきひいらぎ\",4965],"
353 "[\"たいやき工房白家 阿佐ヶ谷店\",5102],"
354 "[\"たいやき本舗 藤家 阿佐ヶ谷店\",5172]"
359 "--sortby '+_score, +name' "
360 "--output_columns 'name, _score' "
361 "--filter 'tags @ \"たいやき\"' "
362 "--scorer '_score=geo_distance2(location, \"%s\")'",
369 gdouble tokyo_tocho_latitude = 35.689444;
370 gdouble tokyo_tocho_longitude = 139.691667;
371 gint distance = 4 * 1000;
373 cut_assert_equal_string(
375 "[[\"name\",\"ShortText\"],[\"_score\",\"Int32\"]],"
378 "[\"そばたいやき空\",3016],"
379 "[\"たい焼 カタオカ\",3353],"
385 "--sortby '+_score, +name' "
386 "--output_columns 'name, _score' "
387 "--filter 'geo_in_circle(location, \"%s\", %d) && tags @ \"たいやき\"' "
388 "--scorer '_score=geo_distance3(location, \"%s\")'",
397 gdouble asagaya_latitude = 35.70452;
398 gdouble asagaya_longitude = 139.6351;
399 gint distance = 5 * 1000;
401 cut_assert_equal_string(
403 "[[\"name\",\"ShortText\"],[\"_score\",\"Int32\"]],"
405 "[\"そばたいやき空\",3162],"
406 "[\"たい焼き / たつみや\",4341],"
413 "--sortby '+_score, +name' "
414 "--output_columns 'name, _score' "
416 "geo_in_circle(location, \"%s\", %d) && " \
417 "tags @ \"たいやき\" &! tags @ \"白\"' "
418 "--scorer '_score=geo_distance(location, \"%s\")'",
427 gdouble yurakucho_latitude = 35.67487;
428 gdouble yurakucho_longitude = 139.76352;
429 gint distance = 10 * 1000;
431 cut_assert_equal_string(
433 "[[\"name\",\"ShortText\"],[\"_score\",\"Int32\"]],"
434 "[\"たい焼き鉄次 大丸東京店\",810],"
435 "[\"たいやき神田達磨 八重洲店\",970],"
436 "[\"にしみや 甘味処\",1056],"
437 "[\"築地 さのきや\",1186],"
439 "[\"柳屋 たい焼き\",2179],"
440 "[\"尾長屋 錦糸町店\",5007],"
441 "[\"根津のたいやき\",5036],"
442 "[\"横浜 くりこ庵 浅草店\",5098],"
443 "[\"たい焼き写楽\",5457]],"
445 "[[\"_key\",\"ShortText\"],"
446 "[\"name\",\"ShortText\"],"
447 "[\"_nsubrecs\",\"Int32\"]],"
449 "[\"たいやき\",\"\",23],"
456 "[[\"_key\",\"ShortText\"],"
457 "[\"name\",\"ShortText\"],"
458 "[\"_nsubrecs\",\"Int32\"]],"
459 "[\"category0001\",\"和食\",1],"
460 "[\"category0003\",\"おやつ\",1]],"
462 "[[\"_key\",\"ShortText\"],"
463 "[\"name\",\"ShortText\"],"
464 "[\"_nsubrecs\",\"Int32\"]],"
465 "[\"area0002\",\"東京都中央区\",3],"
466 "[\"area0005\",\"東京都文京区\",1],"
467 "[\"area0013\",\"東京都渋谷区\",1]]"
472 "--sortby '+_score, +name' "
473 "--output_columns 'name, _score' "
474 "--filter 'geo_in_circle(location, \"%s\", %d) && tags @ \"たいやき\"' "
475 "--scorer '_score=geo_distance2(location, \"%s\")' "
476 "--drilldown 'tags categories area' "
477 "--drilldown_output_columns '_key, name, _nsubrecs' "
478 "--drilldown_sortby '_key'",
487 gdouble yurakucho_latitude = 35.67487;
488 gdouble yurakucho_longitude = 139.76352;
489 gint distance = 10 * 1000;
493 cut_assert_equal_string(
495 "[[\"name\",\"ShortText\"],[\"_score\",\"Int32\"]],"
496 "[\"たい焼き鉄次 大丸東京店\",811],"
497 "[\"たいやき神田達磨 八重洲店\",972],"
498 "[\"にしみや 甘味処\",1060],"
499 "[\"築地 さのきや\",1187],"
501 "[\"柳屋 たい焼き\",2186],"
502 "[\"尾長屋 錦糸町店\",5024],"
503 "[\"根津のたいやき\",5036],"
504 "[\"横浜 くりこ庵 浅草店\",5106],"
505 "[\"たい焼き写楽\",5464]],"
507 "[[\"_key\",\"ShortText\"],"
508 "[\"name\",\"ShortText\"],"
509 "[\"_nsubrecs\",\"Int32\"]],"
510 "[\"area0013\",\"東京都渋谷区\",1]]"
515 "--sortby '+_score, +name' "
516 "--output_columns 'name, _score' "
517 "--filter 'geo_in_circle(location, \"%s\", %d) && tags @ \"たいやき\"' "
518 "--scorer '_score=geo_distance3(location, \"%s\")' "
519 "--drilldown 'area' "
520 "--drilldown_output_columns '_key, name, _nsubrecs' "
521 "--drilldown_sortby '_key'",
530 gdouble yurakucho_latitude = 35.67487;
531 gdouble yurakucho_longitude = 139.76352;
532 gint distance = 10 * 1000;
534 cut_assert_equal_string(
536 "[[\"name\",\"ShortText\"],[\"_score\",\"Int32\"]],"
537 "[\"たいやき神田達磨 八重洲店\",10031],"
538 "[\"たい焼き鉄次 大丸東京店\",9191],"
539 "[\"にしみや 甘味処\",8945],"
540 "[\"築地 さのきや\",8815],"
542 "[\"柳屋 たい焼き\",7822],"
543 "[\"根津のたいやき\",5965],"
544 "[\"たいやきひいらぎ\",5428],"
545 "[\"尾長屋 錦糸町店\",4994],"
546 "[\"横浜 くりこ庵 浅草店\",4903]],"
548 "[[\"_key\",\"ShortText\"],[\"_nsubrecs\",\"Int32\"]],"
560 "--sortby '-_score, +name' "
561 "--output_columns 'name, _score' "
562 "--match_columns 'name * 1000 || tags * 10000' "
564 "--filter 'geo_in_circle(location, \"%s\", %d)' "
565 "--scorer '_score -= geo_distance(location, \"%s\")' "
566 "--drilldown_output_columns '_key, _nsubrecs' "
567 "--drilldown_sortby '-_nsubrecs' "
568 "--drilldown 'tags' ",
577 gdouble yurakucho_latitude = 35.67487;
578 gdouble yurakucho_longitude = 139.76352;
579 gint distance = 3 * 1000;
581 cut_assert_equal_string(
583 "[[\"name\",\"ShortText\"],[\"_score\",\"Int32\"]],"
584 "[\"たいやき神田達磨 八重洲店\",10032]"
589 "--sortby '-_score, +name' "
590 "--output_columns 'name, _score' "
591 "--match_columns 'name * 1000 || tags * 10000' "
594 " (geo_in_circle(location1, \"%s\", %d) ||"
595 " geo_in_circle(location2, \"%s\", %d) ||"
596 " geo_in_circle(location3, \"%s\", %d))' "
597 "--scorer '_score = _score - geo_distance(location, \"%s\")'",
610 cut_assert_equal_string(
612 "[[\"name\",\"ShortText\"]],"
613 "[\"おめで鯛焼き本舗錦糸町東急店\"],"
620 "--output_columns 'name' "
622 "--match_columns name "
624 "--query_expansion Synonyms.words"));