Groonga 3.0.9 Source Code Document
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
groonga
lib
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
{
60
GRN_GEO_APPROXIMATE_RECTANGLE
,
61
GRN_GEO_APPROXIMATE_SPHERE
,
62
GRN_GEO_APPROXIMATE_ELLIPSOID
63
}
grn_geo_approximate_type
;
64
65
typedef
enum
{
66
GRN_GEO_CURSOR_ENTRY_STATUS_NONE
= 0,
67
GRN_GEO_CURSOR_ENTRY_STATUS_TOP_INCLUDED
= 1 << 0,
68
GRN_GEO_CURSOR_ENTRY_STATUS_BOTTOM_INCLUDED
= 1 << 1,
69
GRN_GEO_CURSOR_ENTRY_STATUS_LEFT_INCLUDED
= 1 << 2,
70
GRN_GEO_CURSOR_ENTRY_STATUS_RIGHT_INCLUDED
= 1 << 3,
71
GRN_GEO_CURSOR_ENTRY_STATUS_LATITUDE_INNER
= 1 << 4,
72
GRN_GEO_CURSOR_ENTRY_STATUS_LONGITUDE_INNER
= 1 << 5
73
}
grn_geo_cursor_entry_status_flag
;
74
75
typedef
struct
{
76
uint8_t key[
sizeof
(
grn_geo_point
)];
77
int
target_bit
;
78
int
status_flags
;
79
}
grn_geo_cursor_entry
;
80
81
typedef
struct
{
82
grn_db_obj
obj
;
83
grn_obj
*
pat
;
84
grn_obj
*
index
;
85
grn_geo_point
top_left
;
86
grn_geo_point
bottom_right
;
87
uint8_t top_left_key[
sizeof
(
grn_geo_point
)];
88
uint8_t bottom_right_key[
sizeof
(
grn_geo_point
)];
89
grn_geo_point
current
;
90
grn_table_cursor
*
pat_cursor
;
91
grn_ii_cursor
*
ii_cursor
;
92
int
offset
;
93
int
rest
;
94
grn_geo_cursor_entry
entries[
GRN_GEO_KEY_MAX_BITS
];
95
int
current_entry
;
96
int
minimum_reduce_bit
;
97
}
grn_geo_cursor_in_rectangle
;
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
105
grn_rc
grn_geo_resolve_approximate_type
(
grn_ctx
*ctx,
grn_obj
*type_name,
106
grn_geo_approximate_type
*
type
);
107
128
grn_rc
grn_geo_select_in_circle
(
grn_ctx
*ctx,
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
136
grn_rc
grn_selector_geo_in_circle
(
grn_ctx
*ctx,
grn_obj
*table,
grn_obj
*
index
,
137
int
nargs,
grn_obj
**args,
138
grn_obj
*res,
grn_operator
op);
139
grn_rc
grn_selector_geo_in_rectangle
(
grn_ctx
*ctx,
140
grn_obj
*table,
grn_obj
*
index
,
141
int
nargs,
grn_obj
**args,
142
grn_obj
*res,
grn_operator
op);
143
144
GRN_API
grn_bool
grn_geo_in_circle
(
grn_ctx
*ctx,
grn_obj
*point,
grn_obj
*center,
145
grn_obj
*radius_or_point,
146
grn_geo_approximate_type
approximate_type);
147
GRN_API
grn_bool
grn_geo_in_rectangle
(
grn_ctx
*ctx,
grn_obj
*point,
148
grn_obj
*top_left,
grn_obj
*bottom_right);
149
grn_bool
grn_geo_in_rectangle_raw
(
grn_ctx
*ctx,
grn_geo_point
*point,
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,
153
grn_geo_approximate_type
type
);
154
GRN_API
double
grn_geo_distance_rectangle
(
grn_ctx
*ctx,
grn_obj
*point1,
155
grn_obj
*point2);
156
GRN_API
double
grn_geo_distance_sphere
(
grn_ctx
*ctx,
grn_obj
*point1,
157
grn_obj
*point2);
158
GRN_API
double
grn_geo_distance_ellipsoid
(
grn_ctx
*ctx,
grn_obj
*point1,
159
grn_obj
*point2);
160
double
grn_geo_distance_rectangle_raw
(
grn_ctx
*ctx,
161
grn_geo_point
*point1,
162
grn_geo_point
*point2);
163
double
grn_geo_distance_sphere_raw
(
grn_ctx
*ctx,
164
grn_geo_point
*point1,
165
grn_geo_point
*point2);
166
double
grn_geo_distance_ellipsoid_raw
(
grn_ctx
*ctx,
167
grn_geo_point
*point1,
168
grn_geo_point
*point2,
169
int
c1,
int
c2,
double
c3);
170
double
grn_geo_distance_ellipsoid_raw_tokyo
(
grn_ctx
*ctx,
171
grn_geo_point
*point1,
172
grn_geo_point
*point2);
173
double
grn_geo_distance_ellipsoid_raw_wgs84
(
grn_ctx
*ctx,
174
grn_geo_point
*point1,
175
grn_geo_point
*point2);
176
177
#ifdef __cplusplus
178
}
179
#endif
180
181
#endif
/* GRN_GEO_H */
Generated on Sun Nov 10 2013 09:49:02 for Groonga 3.0.9 Source Code Document by
1.8.1.2