Groonga 3.0.9 Source Code Document
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
geo.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 2 -*- */
2 /* Copyright(C) 2009-2011 Brazil
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License version 2.1 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Lesser General Public License for more details.
12 
13  You should have received a copy of the GNU Lesser General Public
14  License along with this library; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 #ifndef GRN_GEO_H
18 #define GRN_GEO_H
19 
20 #ifndef GROONGA_IN_H
21 #include "groonga_in.h"
22 #endif /* GROONGA_IN_H */
23 
24 #include "ii.h"
25 #include "db.h"
26 
27 #ifdef WIN32
28 #define _USE_MATH_DEFINES
29 #endif /* WIN32 */
30 #include <math.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #define GRN_GEO_RESOLUTION 3600000
37 #define GRN_GEO_RADIUS 6357303
38 #define GRN_GEO_BES_C1 6334834
39 #define GRN_GEO_BES_C2 6377397
40 #define GRN_GEO_BES_C3 0.006674
41 #define GRN_GEO_GRS_C1 6335439
42 #define GRN_GEO_GRS_C2 6378137
43 #define GRN_GEO_GRS_C3 0.006694
44 #define GRN_GEO_INT2RAD(x) ((M_PI / (GRN_GEO_RESOLUTION * 180)) * (x))
45 #define GRN_GEO_RAD2INT(x) ((int)(((GRN_GEO_RESOLUTION * 180) / M_PI) * (x)))
46 
47 #define GRN_GEO_MAX_LATITUDE 324000000 /* 90 * 60 * 60 * 1000 */
48 #define GRN_GEO_MAX_LONGITUDE 648000000 /* 180 * 60 * 60 * 1000 */
49 
50 #define GRN_GEO_POINT_VALUE_RAW(obj) (grn_geo_point *)GRN_BULK_HEAD(obj)
51 #define GRN_GEO_POINT_VALUE_RADIUS(obj,_latitude,_longitude) do {\
52  grn_geo_point *_val = (grn_geo_point *)GRN_BULK_HEAD(obj);\
53  _latitude = GRN_GEO_INT2RAD(_val->latitude);\
54  _longitude = GRN_GEO_INT2RAD(_val->longitude);\
55 } while (0)
56 
57 #define GRN_GEO_KEY_MAX_BITS 64
58 
59 typedef enum {
64 
65 typedef enum {
74 
75 typedef struct {
76  uint8_t key[sizeof(grn_geo_point)];
80 
81 typedef struct {
87  uint8_t top_left_key[sizeof(grn_geo_point)];
88  uint8_t bottom_right_key[sizeof(grn_geo_point)];
92  int offset;
93  int rest;
98 
99 grn_rc grn_geo_cursor_close(grn_ctx *ctx, grn_obj *geo_cursor);
100 
101 
102 int grn_geo_table_sort(grn_ctx *ctx, grn_obj *table, int offset, int limit,
103  grn_obj *result, grn_table_sort_key *keys, int n_keys);
104 
107 
129  grn_obj *index,
130  grn_obj *center_point,
131  grn_obj *distance,
132  grn_geo_approximate_type approximate_type,
133  grn_obj *res,
134  grn_operator op);
135 
137  int nargs, grn_obj **args,
138  grn_obj *res, grn_operator op);
140  grn_obj *table, grn_obj *index,
141  int nargs, grn_obj **args,
142  grn_obj *res, grn_operator op);
143 
145  grn_obj *radius_or_point,
146  grn_geo_approximate_type approximate_type);
148  grn_obj *top_left, grn_obj *bottom_right);
150  grn_geo_point *top_left,
151  grn_geo_point *bottom_right);
152 double grn_geo_distance(grn_ctx *ctx, grn_obj *point1, grn_obj *point2,
155  grn_obj *point2);
156 GRN_API double grn_geo_distance_sphere(grn_ctx *ctx, grn_obj *point1,
157  grn_obj *point2);
159  grn_obj *point2);
161  grn_geo_point *point1,
162  grn_geo_point *point2);
164  grn_geo_point *point1,
165  grn_geo_point *point2);
167  grn_geo_point *point1,
168  grn_geo_point *point2,
169  int c1, int c2, double c3);
171  grn_geo_point *point1,
172  grn_geo_point *point2);
174  grn_geo_point *point1,
175  grn_geo_point *point2);
176 
177 #ifdef __cplusplus
178 }
179 #endif
180 
181 #endif /* GRN_GEO_H */