20 #include <glib/gstdio.h>
22 #include "../lib/grn-assertions.h"
27 #define get(name) grn_ctx_get(context, name, strlen(name))
37 static gchar *tmp_directory;
42 #define DEFINE_GEO_POINT(name) \
43 static grn_obj *name ## _tokyo, *name ## _wgs84, *name ## _text
51 #undef DEFINE_GEO_POINT
53 static grn_obj *takane, *shinjuku;
66 g_free(tmp_directory);
70 remove_tmp_directory(
void)
72 cut_remove_path(tmp_directory, NULL);
76 tokyo_geo_point_open(
int latitude,
int longitude)
88 wgs84_geo_point_open(
int latitude,
int longitude)
98 text_geo_point_open(
int latitude,
int longitude)
103 GRN_TEXT_PUTS(context, point, cut_take_printf(
"%d,%d", latitude, longitude));
110 #define SETUP_GEO_POINT(name, latitude, longitude) \
111 name ## _tokyo = tokyo_geo_point_open(latitude, longitude); \
112 name ## _wgs84 = wgs84_geo_point_open(latitude, longitude); \
113 name ## _text = text_geo_point_open(latitude, longitude)
124 #undef SETUP_GEO_POINT
130 const gchar *database_path;
138 remove_tmp_directory();
139 g_mkdir_with_parents(tmp_directory, 0700);
144 database_path = cut_build_path(tmp_directory,
"database.groonga", NULL);
151 teardown_values(
void)
153 #define UNLINK_GEO_POINT(name) \
154 grn_obj_unlink(context, name ## _tokyo); \
155 grn_obj_unlink(context, name ## _wgs84); \
156 grn_obj_unlink(context, name ## _text)
167 #undef UNLINK_GEO_POINT
179 remove_tmp_directory();
211 assign_shinjuku_and_takane(gconstpointer data)
213 switch (gcut_data_get_int(data,
"shinjuku-geographic-coordinate-system")) {
215 shinjuku = shinjuku_tokyo;
218 shinjuku = shinjuku_wgs84;
221 shinjuku = shinjuku_text;
225 switch (gcut_data_get_int(data,
"takane-geographic-coordinate-system")) {
227 takane = takane_tokyo;
230 takane = takane_wgs84;
233 takane = takane_text;
241 #define ADD_DATUM(label, shinjuku, takane) \
242 gcut_add_datum(label, \
243 "shinjuku-geographic-coordinate-system", \
244 G_TYPE_INT, shinjuku, \
245 "takane-geographic-coordinate-system", \
246 G_TYPE_INT, takane, \
278 assign_shinjuku_and_takane(data);
279 cut_assert_equal_double(12585.4, 10,
286 cut_assert_equal_double(12585.4, 10,
295 cut_assert_equal_double(12640.8, 10,
309 location_index =
get(
"Locations.shop");
310 cut_assert_equal_int(4,