Groonga 3.0.9 Source Code Document
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Data Structures | Macros | Typedefs | Enumerations | Functions
geo.c File Reference
#include "geo.h"
#include "pat.h"
#include "util.h"
#include <string.h>
#include <stdlib.h>
Include dependency graph for geo.c:

Go to the source code of this file.

Data Structures

struct  geo_entry
struct  mesh_entry
struct  in_rectangle_data
struct  grn_geo_select_in_rectangle_data

Macros

#define inspect_mesh(...)
#define inspect_mesh_entry(...)
#define inspect_tid(...)
#define inspect_key(...)
#define print_key_mark(...)
#define inspect_cursor_entry(...)
#define inspect_cursor_entry_targets(...)
#define add_mesh(lat_diff_, lng_diff_, key_size_)
#define SAME_BIT_P(a, b, n_bit)
#define CURSOR_ENTRY_UPDATE_STATUS(entry, name, other_key)
#define CURSOR_ENTRY_CHECK_STATUS(entry, name)   ((entry)->status_flags & GRN_GEO_CURSOR_ENTRY_STATUS_ ## name)
#define CURSOR_ENTRY_IS_INNER(entry)
#define CURSOR_ENTRY_INCLUDED_IN_LATITUDE_DIRECTION(entry)
#define CURSOR_ENTRY_INCLUDED_IN_LONGITUDE_DIRECTION(entry)
#define SET_N_BIT(a, n_bit)   (((uint8_t *)(a))[((n_bit) / 8)] ^= (1 << (7 - ((n_bit) % 8))))
#define N_BIT(a, n_bit)
#define QUADRANT_1ST_WITH_AXIS(point)   (point->longitude >= 0) && (point->latitude >= 0)
#define QUADRANT_2ND_WITH_AXIS(point)   (point->longitude <= 0) && (point->latitude >= 0)
#define QUADRANT_3RD_WITH_AXIS(point)   (point->longitude <= 0) && (point->latitude <= 0)
#define QUADRANT_4TH_WITH_AXIS(point)   (point->longitude >= 0) && (point->latitude <= 0)
#define M_2PI   6.28318530717958647692

Typedefs

typedef double(* grn_geo_distance_raw_func )(grn_ctx *ctx, grn_geo_point *point1, grn_geo_point *point2)
typedef grn_bool(* grn_geo_cursor_callback )(grn_ctx *ctx, grn_ii_posting *posting, void *user_data)

Enumerations

enum  mesh_position { MESH_LEFT_TOP, MESH_RIGHT_TOP, MESH_RIGHT_BOTTOM, MESH_LEFT_BOTTOM }
enum  distance_type { LONGITUDE_SHORT, LONGITUDE_LONG }
enum  quadrant_type {
  QUADRANT_1ST, QUADRANT_2ND, QUADRANT_3RD, QUADRANT_4TH,
  QUADRANT_1ST_TO_2ND, QUADRANT_1ST_TO_3RD, QUADRANT_1ST_TO_4TH, QUADRANT_2ND_TO_1ST,
  QUADRANT_2ND_TO_3RD, QUADRANT_2ND_TO_4TH, QUADRANT_3RD_TO_1ST, QUADRANT_3RD_TO_2ND,
  QUADRANT_3RD_TO_4TH, QUADRANT_4TH_TO_1ST, QUADRANT_4TH_TO_2ND, QUADRANT_4TH_TO_3RD
}

Functions

int grn_geo_table_sort (grn_ctx *ctx, grn_obj *table, int offset, int limit, grn_obj *result, grn_table_sort_key *keys, int n_keys)
grn_rc grn_geo_resolve_approximate_type (grn_ctx *ctx, grn_obj *type_name, grn_geo_approximate_type *type)
grn_rc grn_selector_geo_in_circle (grn_ctx *ctx, grn_obj *table, grn_obj *index, int nargs, grn_obj **args, grn_obj *res, grn_operator op)
grn_rc grn_geo_select_in_circle (grn_ctx *ctx, grn_obj *index, grn_obj *center_point, grn_obj *distance, grn_geo_approximate_type approximate_type, grn_obj *res, grn_operator op)
grn_rc grn_selector_geo_in_rectangle (grn_ctx *ctx, grn_obj *table, grn_obj *index, int nargs, grn_obj **args, grn_obj *res, grn_operator op)
grn_objgrn_geo_cursor_open_in_rectangle (grn_ctx *ctx, grn_obj *index, grn_obj *top_left_point, grn_obj *bottom_right_point, int offset, int limit)
grn_postinggrn_geo_cursor_next (grn_ctx *ctx, grn_obj *geo_cursor)
grn_rc grn_geo_cursor_close (grn_ctx *ctx, grn_obj *geo_cursor)
grn_rc grn_geo_select_in_rectangle (grn_ctx *ctx, grn_obj *index, grn_obj *top_left_point, grn_obj *bottom_right_point, grn_obj *res, grn_operator op)
int grn_geo_estimate_in_rectangle (grn_ctx *ctx, grn_obj *index, grn_obj *top_left_point, grn_obj *bottom_right_point)
grn_bool grn_geo_in_circle (grn_ctx *ctx, grn_obj *point, grn_obj *center, grn_obj *radius_or_point, grn_geo_approximate_type approximate_type)
grn_bool grn_geo_in_rectangle_raw (grn_ctx *ctx, grn_geo_point *point, grn_geo_point *top_left, grn_geo_point *bottom_right)
grn_bool grn_geo_in_rectangle (grn_ctx *ctx, grn_obj *point, grn_obj *top_left, grn_obj *bottom_right)
double grn_geo_distance_rectangle_raw (grn_ctx *ctx, grn_geo_point *point1, grn_geo_point *point2)
double grn_geo_distance_sphere_raw (grn_ctx *ctx, grn_geo_point *point1, grn_geo_point *point2)
double grn_geo_distance_ellipsoid_raw (grn_ctx *ctx, grn_geo_point *point1, grn_geo_point *point2, int c1, int c2, double c3)
double grn_geo_distance_ellipsoid_raw_tokyo (grn_ctx *ctx, grn_geo_point *point1, grn_geo_point *point2)
double grn_geo_distance_ellipsoid_raw_wgs84 (grn_ctx *ctx, grn_geo_point *point1, grn_geo_point *point2)
double grn_geo_distance (grn_ctx *ctx, grn_obj *point1, grn_obj *point2, grn_geo_approximate_type type)
double grn_geo_distance_rectangle (grn_ctx *ctx, grn_obj *point1, grn_obj *point2)
double grn_geo_distance_sphere (grn_ctx *ctx, grn_obj *point1, grn_obj *point2)
double grn_geo_distance_ellipsoid (grn_ctx *ctx, grn_obj *point1, grn_obj *point2)

Macro Definition Documentation

#define add_mesh (   lat_diff_,
  lng_diff_,
  key_size_ 
)
Value:
do {\
meshes[n_meshes].key.latitude = geo_base.latitude + (lat_diff_);\
meshes[n_meshes].key.longitude = geo_base.longitude + (lng_diff_);\
meshes[n_meshes].key_size = key_size_;\
n_meshes++;\
} while (0)
#define CURSOR_ENTRY_CHECK_STATUS (   entry,
  name 
)    ((entry)->status_flags & GRN_GEO_CURSOR_ENTRY_STATUS_ ## name)

Definition at line 1182 of file geo.c.

#define CURSOR_ENTRY_INCLUDED_IN_LATITUDE_DIRECTION (   entry)
#define CURSOR_ENTRY_INCLUDED_IN_LONGITUDE_DIRECTION (   entry)
#define CURSOR_ENTRY_IS_INNER (   entry)
#define CURSOR_ENTRY_UPDATE_STATUS (   entry,
  name,
  other_key 
)
Value:
do {\
if (SAME_BIT_P((entry)->key, (other_key), (entry)->target_bit)) {\
(entry)->status_flags |= GRN_GEO_CURSOR_ENTRY_STATUS_ ## name;\
} else {\
(entry)->status_flags &= ~GRN_GEO_CURSOR_ENTRY_STATUS_ ## name;\
}\
} while (0)

Definition at line 1174 of file geo.c.

#define inspect_cursor_entry (   ...)

Definition at line 238 of file geo.c.

#define inspect_cursor_entry_targets (   ...)

Definition at line 239 of file geo.c.

#define inspect_key (   ...)

Definition at line 236 of file geo.c.

#define inspect_mesh (   ...)

Definition at line 233 of file geo.c.

#define inspect_mesh_entry (   ...)

Definition at line 234 of file geo.c.

#define inspect_tid (   ...)

Definition at line 235 of file geo.c.

#define M_2PI   6.28318530717958647692
#define N_BIT (   a,
  n_bit 
)
Value:
((((uint8_t *)(a))[((n_bit) / 8)] &\
(1 << (7 - ((n_bit) % 8)))) >> (1 << (7 - ((n_bit) % 8))))

Definition at line 1204 of file geo.c.

#define print_key_mark (   ...)

Definition at line 237 of file geo.c.

#define QUADRANT_1ST_WITH_AXIS (   point)    (point->longitude >= 0) && (point->latitude >= 0)
#define QUADRANT_2ND_WITH_AXIS (   point)    (point->longitude <= 0) && (point->latitude >= 0)
#define QUADRANT_3RD_WITH_AXIS (   point)    (point->longitude <= 0) && (point->latitude <= 0)
#define QUADRANT_4TH_WITH_AXIS (   point)    (point->longitude >= 0) && (point->latitude <= 0)
#define SAME_BIT_P (   a,
  b,
  n_bit 
)
Value:
((((uint8_t *)(a))[(n_bit) / 8] & (1 << (7 - ((n_bit) % 8)))) ==\
(((uint8_t *)(b))[(n_bit) / 8] & (1 << (7 - ((n_bit) % 8)))))

Definition at line 1170 of file geo.c.

#define SET_N_BIT (   a,
  n_bit 
)    (((uint8_t *)(a))[((n_bit) / 8)] ^= (1 << (7 - ((n_bit) % 8))))

Definition at line 1201 of file geo.c.

Typedef Documentation

typedef grn_bool(* grn_geo_cursor_callback)(grn_ctx *ctx, grn_ii_posting *posting, void *user_data)

Definition at line 1545 of file geo.c.

typedef double(* grn_geo_distance_raw_func)(grn_ctx *ctx, grn_geo_point *point1, grn_geo_point *point2)

Definition at line 752 of file geo.c.

Enumeration Type Documentation

Enumerator:
LONGITUDE_SHORT 
LONGITUDE_LONG 

Definition at line 1920 of file geo.c.

Enumerator:
MESH_LEFT_TOP 
MESH_RIGHT_TOP 
MESH_RIGHT_BOTTOM 
MESH_LEFT_BOTTOM 

Definition at line 318 of file geo.c.

Enumerator:
QUADRANT_1ST 
QUADRANT_2ND 
QUADRANT_3RD 
QUADRANT_4TH 
QUADRANT_1ST_TO_2ND 
QUADRANT_1ST_TO_3RD 
QUADRANT_1ST_TO_4TH 
QUADRANT_2ND_TO_1ST 
QUADRANT_2ND_TO_3RD 
QUADRANT_2ND_TO_4TH 
QUADRANT_3RD_TO_1ST 
QUADRANT_3RD_TO_2ND 
QUADRANT_3RD_TO_4TH 
QUADRANT_4TH_TO_1ST 
QUADRANT_4TH_TO_2ND 
QUADRANT_4TH_TO_3RD 

Definition at line 1925 of file geo.c.

Function Documentation

grn_rc grn_geo_cursor_close ( grn_ctx ctx,
grn_obj geo_cursor 
)

Definition at line 1660 of file geo.c.

Here is the call graph for this function:

Here is the caller graph for this function:

grn_posting* grn_geo_cursor_next ( grn_ctx ctx,
grn_obj geo_cursor 
)

Definition at line 1652 of file geo.c.

Here is the caller graph for this function:

grn_obj* grn_geo_cursor_open_in_rectangle ( grn_ctx ctx,
grn_obj index,
grn_obj top_left_point,
grn_obj bottom_right_point,
int  offset,
int  limit 
)

Definition at line 1209 of file geo.c.

Here is the call graph for this function:

Here is the caller graph for this function:

double grn_geo_distance ( grn_ctx ctx,
grn_obj point1,
grn_obj point2,
grn_geo_approximate_type  type 
)

Definition at line 2282 of file geo.c.

Here is the call graph for this function:

double grn_geo_distance_ellipsoid ( grn_ctx ctx,
grn_obj point1,
grn_obj point2 
)

Definition at line 2381 of file geo.c.

Here is the call graph for this function:

Here is the caller graph for this function:

double grn_geo_distance_ellipsoid_raw ( grn_ctx ctx,
grn_geo_point point1,
grn_geo_point point2,
int  c1,
int  c2,
double  c3 
)

Definition at line 2239 of file geo.c.

Here is the caller graph for this function:

double grn_geo_distance_ellipsoid_raw_tokyo ( grn_ctx ctx,
grn_geo_point point1,
grn_geo_point point2 
)

Definition at line 2260 of file geo.c.

Here is the call graph for this function:

Here is the caller graph for this function:

double grn_geo_distance_ellipsoid_raw_wgs84 ( grn_ctx ctx,
grn_geo_point point1,
grn_geo_point point2 
)

Definition at line 2271 of file geo.c.

Here is the call graph for this function:

Here is the caller graph for this function:

double grn_geo_distance_rectangle ( grn_ctx ctx,
grn_obj point1,
grn_obj point2 
)

Definition at line 2305 of file geo.c.

Here is the call graph for this function:

Here is the caller graph for this function:

double grn_geo_distance_rectangle_raw ( grn_ctx ctx,
grn_geo_point point1,
grn_geo_point point2 
)

Definition at line 2189 of file geo.c.

Here is the caller graph for this function:

double grn_geo_distance_sphere ( grn_ctx ctx,
grn_obj point1,
grn_obj point2 
)

Definition at line 2354 of file geo.c.

Here is the call graph for this function:

Here is the caller graph for this function:

double grn_geo_distance_sphere_raw ( grn_ctx ctx,
grn_geo_point point1,
grn_geo_point point2 
)

Definition at line 2224 of file geo.c.

Here is the caller graph for this function:

int grn_geo_estimate_in_rectangle ( grn_ctx ctx,
grn_obj index,
grn_obj top_left_point,
grn_obj bottom_right_point 
)

Definition at line 1749 of file geo.c.

Here is the call graph for this function:

Here is the caller graph for this function:

grn_bool grn_geo_in_circle ( grn_ctx ctx,
grn_obj point,
grn_obj center,
grn_obj radius_or_point,
grn_geo_approximate_type  approximate_type 
)

Definition at line 1814 of file geo.c.

Here is the call graph for this function:

Here is the caller graph for this function:

grn_bool grn_geo_in_rectangle ( grn_ctx ctx,
grn_obj point,
grn_obj top_left,
grn_obj bottom_right 
)

Definition at line 1892 of file geo.c.

Here is the call graph for this function:

Here is the caller graph for this function:

grn_bool grn_geo_in_rectangle_raw ( grn_ctx ctx,
grn_geo_point point,
grn_geo_point top_left,
grn_geo_point bottom_right 
)

Definition at line 1882 of file geo.c.

Here is the caller graph for this function:

grn_rc grn_geo_resolve_approximate_type ( grn_ctx ctx,
grn_obj type_name,
grn_geo_approximate_type type 
)

Definition at line 717 of file geo.c.

Here is the call graph for this function:

Here is the caller graph for this function:

grn_rc grn_geo_select_in_circle ( grn_ctx ctx,
grn_obj index,
grn_obj center_point,
grn_obj distance,
grn_geo_approximate_type  approximate_type,
grn_obj res,
grn_operator  op 
)

grn_geo_select_in_circle: : the index column for TokyoGeoPoint or WGS84GeoPpoint type. : the center point of the target circle. (ShortText, Text, LongText, TokyoGeoPoint or WGS84GeoPoint) : the radius of the target circle (Int32, UInt32, Int64, UInt64 or Float) or the point on the circumference of the target circle. (ShortText, Text, LongText, TokyoGeoPoint or WGS84GeoPoint) : the approximate type to compute distance. : the table to store found record IDs. It must be GRN_TABLE_HASH_KEY type table. : the operator for matched records.

It selects records that are in the circle specified by and from . Records are searched by . Found records are added to table with operation.

Definition at line 828 of file geo.c.

Here is the call graph for this function:

Here is the caller graph for this function:

grn_rc grn_geo_select_in_rectangle ( grn_ctx ctx,
grn_obj index,
grn_obj top_left_point,
grn_obj bottom_right_point,
grn_obj res,
grn_operator  op 
)

Definition at line 1691 of file geo.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int grn_geo_table_sort ( grn_ctx ctx,
grn_obj table,
int  offset,
int  limit,
grn_obj result,
grn_table_sort_key keys,
int  n_keys 
)

Definition at line 673 of file geo.c.

Here is the call graph for this function:

Here is the caller graph for this function:

grn_rc grn_selector_geo_in_circle ( grn_ctx ctx,
grn_obj table,
grn_obj index,
int  nargs,
grn_obj **  args,
grn_obj res,
grn_operator  op 
)

Definition at line 757 of file geo.c.

Here is the call graph for this function:

Here is the caller graph for this function:

grn_rc grn_selector_geo_in_rectangle ( grn_ctx ctx,
grn_obj table,
grn_obj index,
int  nargs,
grn_obj **  args,
grn_obj res,
grn_operator  op 
)

Definition at line 980 of file geo.c.

Here is the call graph for this function:

Here is the caller graph for this function: