Skip to content

Commit 28723c7

Browse files
author
dcooley
committed
rebuilding the function defs
1 parent c32abc6 commit 28723c7

File tree

2 files changed

+99
-7
lines changed

2 files changed

+99
-7
lines changed

data-raw/DATASET.R

+26-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,32 @@
22

33
## Read `h3libapi.h` and write all 'inline' function defs to `init.c`
44

5-
# lines <- readLines("~/Documents/github/h3lib/inst/include/h3libapi.h")
6-
# fns <- lines[ grepl("inline ", lines) ]
7-
# fns <- gsub("inline ", "", fns)
8-
# fns <- gsub("\\(.*","",fns)
9-
# fns <- gsub(" ", " (*", fns)
10-
# fns <- paste0(fns, ");\n")
11-
# cat(fns)
5+
lines <- readLines("~/Documents/github/h3lib/inst/include/h3libapi.h")
6+
fns <- lines[ grepl("^inline ", lines) ]
7+
8+
fns <- gsub("inline ", "", fns)
9+
10+
args <- gsub(".*\\(","", fns)
11+
args <- trimws(gsub("\\) \\{", "", args))
12+
13+
## Replace arugments (space, followed by arg, followed by comma)
14+
## with a comma
15+
args <- gsub(" \\w+,", ",", args)
16+
17+
## remove final argument
18+
args <- gsub("\\w+$","", args)
19+
20+
## put 'void' back in
21+
args[ nchar(args) == 0 ] <- "void"
22+
23+
args <- trimws(args)
24+
25+
types <- trimws(gsub("\\w+$","",fns))
26+
names <- trimws(gsub("^ {0, }\\w+ ", "", fns))
27+
28+
## rebuild
29+
fns <- paste0(types, " (*", names, ")","(", args, ");\n")
30+
cat(fns)
1231

1332

1433
stations <- structure(list(stop_id = c("15351", "15353", "19827", "19828",

src/init.c

+73
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,79 @@ typedef struct {
192192
int j; ///< j component
193193
} CoordIJ;
194194

195+
H3Error (*latLngToCell)(const LatLng*, int, H3Index*);
196+
H3Error (*cellToLatLng)(H3Index, LatLng*);
197+
H3Error (*cellToBoundary)(H3Index, CellBoundary*);
198+
H3Error (*maxGridDiskSize)(int, int64_t*);
199+
H3Error (*gridDiskUnsafe)(H3Index, int, H3Index*);
200+
H3Error (*gridDiskDistancesUnsafe)(H3Index, int, H3Index*, int*);
201+
H3Error (*gridDiskDistancesSafe)(H3Index, int, H3Index*, int*);
202+
H3Error (*gridDisksUnsafe)(H3Index*, int, int, H3Index*);
203+
H3Error (*gridDisk)(H3Index, int, H3Index*);
204+
H3Error (*gridDiskDistances)(H3Index, int, H3Index*, int*);
205+
H3Error (*gridRingUnsafe)(H3Index, int, H3Index*);
206+
H3Error (*maxPolygonToCellsSize)(const GeoPolygon*, int, uint32_t, int64_t*);
207+
H3Error (*polygonToCells)(const GeoPolygon*, int, uint32_t, H3Index*);
208+
H3Error (*cellsToLinkedMultiPolygon)(const H3Index*, const int, LinkedGeoPolygon*);
209+
void (*destroyLinkedMultiPolygon)(LinkedGeoPolygon*);
210+
double (*degsToRads)(double);
211+
double (*radsToDegs)(double);
212+
double (*greatCircleDistanceRads)(const LatLng*, const LatLng*);
213+
double (*greatCircleDistanceKm)(const LatLng*, const LatLng*);
214+
double (*greatCircleDistanceM)(const LatLng*, const LatLng*);
215+
H3Error (*getHexagonAreaAvgKm2)(int, double*);
216+
H3Error (*getHexagonAreaAvgM2)(int, double*);
217+
H3Error (*cellAreaRads2)(H3Index, double*);
218+
H3Error (*cellAreaKm2)(H3Index, double*);
219+
H3Error (*cellAreaM2)(H3Index, double*);
220+
H3Error (*getHexagonEdgeLengthAvgKm)(int, double*);
221+
H3Error (*getHexagonEdgeLengthAvgM)(int, double*);
222+
H3Error (*edgeLengthRads)(H3Index, double*);
223+
H3Error (*edgeLengthKm)(H3Index, double*);
224+
H3Error (*edgeLengthM)(H3Index, double*);
225+
H3Error (*getNumCells)(int, int64_t*);
226+
int (*res0CellCount)(void);
227+
H3Error (*getRes0Cells)(H3Index*);
228+
int (*pentagonCount)(void);
229+
H3Error (*getPentagons)(int, H3Index*);
230+
int (*getResolution)(H3Index);
231+
int (*getBaseCellNumber)(H3Index);
232+
H3Error (*stringToH3)(const char*, H3Index*);
233+
int (*isValidCell)(H3Index);
234+
H3Error (*cellToParent)(H3Index, int, H3Index*);
235+
H3Error (*cellToChildrenSize)(H3Index, int, int64_t*);
236+
H3Error (*cellToChildren)(H3Index, int, H3Index*);
237+
H3Error (*cellToCenterChild)(H3Index, int, H3Index*);
238+
H3Error (*cellToChildPos)(H3Index, int, int64_t*);
239+
H3Error (*childPosToCell)(int64_t, H3Index, int, H3Index*);
240+
H3Error (*compactCells)(const H3Index*, H3Index*, const int64_t);
241+
H3Error (*uncompactCellsSize)(const H3Index*, const int64_t, const int, int64_t*);
242+
H3Error (*uncompactCells)(const H3Index*, const int64_t, H3Index*, const int64_t, const int);
243+
int (*isResClassIII)(H3Index);
244+
int (*isPentagon)(H3Index);
245+
H3Error (*maxFaceCount)(H3Index, int*);
246+
H3Error (*getIcosahedronFaces)(H3Index, int*);
247+
H3Error (*areNeighborCells)(H3Index, H3Index, int*);
248+
H3Error (*cellsToDirectedEdge)(H3Index, H3Index, H3Index*);
249+
int (*isValidDirectedEdge)(H3Index);
250+
H3Error (*getDirectedEdgeOrigin)(H3Index, H3Index*);
251+
H3Error (*getDirectedEdgeDestination)(H3Index, H3Index*);
252+
H3Error (*directedEdgeToCells)(H3Index, H3Index*);
253+
H3Error (*originToDirectedEdges)(H3Index, H3Index*);
254+
H3Error (*directedEdgeToBoundary)(H3Index, CellBoundary*);
255+
H3Error (*cellToVertex)(H3Index, int, H3Index*);
256+
H3Error (*cellToVertexes)(H3Index, H3Index*);
257+
H3Error (*vertexToLatLng)(H3Index, LatLng*);
258+
int (*isValidVertex)(H3Index);
259+
H3Error (*gridDistance)(H3Index, H3Index, int64_t*);
260+
H3Error (*gridPathCellsSize)(H3Index, H3Index, int64_t*);
261+
H3Error (*gridPathCells)(H3Index, H3Index, H3Index*);
262+
H3Error (*cellToLocalIj)(H3Index, H3Index, uint32_t, CoordIJ*);
263+
H3Error (*localIjToCell)(H3Index, const CoordIJ*, uint32_t, H3Index*);
264+
Direction (*directionForNeighbor)(H3Index, H3Index);
265+
void (*_geoToClosestFace)(const LatLng*, int*, double*);
266+
void (*h3lib_tests)(void);
267+
195268
void attribute_visible R_init_h3r(DllInfo *info)
196269
{
197270
R_registerRoutines(info, NULL, callMethods, NULL, NULL);

0 commit comments

Comments
 (0)