common_function/scalars/
geo.rs

1// Copyright 2023 Greptime Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15mod geohash;
16mod h3;
17pub(crate) mod helpers;
18mod measure;
19mod relation;
20mod s2;
21mod wkt;
22
23use crate::function_registry::FunctionRegistry;
24
25pub(crate) struct GeoFunctions;
26
27impl GeoFunctions {
28    pub fn register(registry: &FunctionRegistry) {
29        // geohash
30        registry.register_scalar(geohash::GeohashFunction);
31        registry.register_scalar(geohash::GeohashNeighboursFunction);
32
33        // h3 index
34        registry.register_scalar(h3::H3LatLngToCell);
35        registry.register_scalar(h3::H3LatLngToCellString);
36
37        // h3 index inspection
38        registry.register_scalar(h3::H3CellBase);
39        registry.register_scalar(h3::H3CellIsPentagon);
40        registry.register_scalar(h3::H3StringToCell);
41        registry.register_scalar(h3::H3CellToString);
42        registry.register_scalar(h3::H3CellCenterLatLng);
43        registry.register_scalar(h3::H3CellResolution);
44
45        // h3 hierarchical grid
46        registry.register_scalar(h3::H3CellCenterChild);
47        registry.register_scalar(h3::H3CellParent);
48        registry.register_scalar(h3::H3CellToChildren);
49        registry.register_scalar(h3::H3CellToChildrenSize);
50        registry.register_scalar(h3::H3CellToChildPos);
51        registry.register_scalar(h3::H3ChildPosToCell);
52        registry.register_scalar(h3::H3CellContains);
53
54        // h3 grid traversal
55        registry.register_scalar(h3::H3GridDisk);
56        registry.register_scalar(h3::H3GridDiskDistances);
57        registry.register_scalar(h3::H3GridDistance);
58        registry.register_scalar(h3::H3GridPathCells);
59
60        // h3 measurement
61        registry.register_scalar(h3::H3CellDistanceSphereKm);
62        registry.register_scalar(h3::H3CellDistanceEuclideanDegree);
63
64        // s2
65        registry.register_scalar(s2::S2LatLngToCell);
66        registry.register_scalar(s2::S2CellLevel);
67        registry.register_scalar(s2::S2CellToToken);
68        registry.register_scalar(s2::S2CellParent);
69
70        // spatial data type
71        registry.register_scalar(wkt::LatLngToPointWkt);
72
73        // spatial relation
74        registry.register_scalar(relation::STContains);
75        registry.register_scalar(relation::STWithin);
76        registry.register_scalar(relation::STIntersects);
77
78        // spatial measure
79        registry.register_scalar(measure::STDistance);
80        registry.register_scalar(measure::STDistanceSphere);
81        registry.register_scalar(measure::STArea);
82    }
83}