[fpc-pascal] UBER H3 Pascal Bindings (H2PAS produces bad output)

Skybuck Flying skybuck2000 at hotmail.com
Sun Jul 31 13:52:24 CEST 2022


Hexagon Grid library, I am trying to make a binding for Pascal with the help of H2PAS but it produces bad output, see example below.4

Any advise how to improve the output ? Any help with converting this API would also be great. The multiple files kinda confuse me a little bit as well as the includes of foreign/strange c libraries...

I will attach zip file containing debug and release DLLs so you don't need to build it yourself and save some time in case you want to try it out.

The zip also contains TDUMP output showing it might have some VCRuntime dependency...


https://h3geo.org/
H3 | H3<https://h3geo.org/>
Algorithms and optimizations. H3 enables a range of algorithms and optimizations based on the grid, including nearest neighbors, shortest path, gradient smoothing, and more.
h3geo.org


https://github.com/uber/h3
[https://repository-images.githubusercontent.com/114948816/18b86b00-4ccc-11ea-8c4b-48010a7f3c6c]<https://github.com/uber/h3>
GitHub - uber/h3: Hexagonal hierarchical geospatial indexing system<https://github.com/uber/h3>
Hexagonal hierarchical geospatial indexing system. Contribute to uber/h3 development by creating an account on GitHub.
github.com

https://github.com/uber/h3/tree/master/src/h3lib/include
[https://repository-images.githubusercontent.com/114948816/18b86b00-4ccc-11ea-8c4b-48010a7f3c6c]<https://github.com/uber/h3/tree/master/src/h3lib/include>
h3/src/h3lib/include at master · uber/h3<https://github.com/uber/h3/tree/master/src/h3lib/include>
Hexagonal hierarchical geospatial indexing system. Contribute to uber/h3 development by creating an account on GitHub.
github.com



Input:

/*
 * Copyright 2016-2021 Uber Technologies, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/** @file h3api.h
 * @brief   Primary H3 core library entry points.
 *
 * This file defines the public API of the H3 library. Incompatible changes to
 * these functions require the library's major version be increased.
 */

#ifndef H3API_H
#define H3API_H

/*
 * Preprocessor code to support renaming (prefixing) the public API.
 * All public functions should be wrapped in H3_EXPORT so they can be
 * renamed.
 */
#ifdef H3_PREFIX
#define XTJOIN(a, b) a##b
#define TJOIN(a, b) XTJOIN(a, b)

/* export joins the user provided prefix with our exported function name */
#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
#else
#define H3_EXPORT(name) name
#endif

/* Windows DLL requires attributes indicating what to export */
#if _WIN32 && BUILD_SHARED_LIBS
#if BUILDING_H3
#define DECLSPEC __declspec(dllexport)
#else
#define DECLSPEC __declspec(dllimport)
#endif
#else
#define DECLSPEC
#endif

/* For uint64_t */
#include <stdint.h>
/* For size_t */
#include <stdlib.h>

/*
 * H3 is compiled as C, not C++ code. `extern "C"` is needed for C++ code
 * to be able to use the library.
 */
#ifdef __cplusplus
extern "C" {
#endif

/** @brief Identifier for an object (cell, edge, etc) in the H3 system.
 *
 * The H3Index fits within a 64-bit unsigned integer.
 */
typedef uint64_t H3Index;

/**
 * Invalid index used to indicate an error from latLngToCell and related
 * functions or missing data in arrays of H3 indices. Analogous to NaN in
 * floating point.
 */
#define H3_NULL 0

/** @brief Result code (success or specific error) from an H3 operation */
typedef uint32_t H3Error;

typedef enum {
    E_SUCCESS = 0,  // Success (no error)
    E_FAILED =
        1,  // The operation failed but a more specific error is not available
    E_DOMAIN = 2,  // Argument was outside of acceptable range (when a more
                   // specific error code is not available)
    E_LATLNG_DOMAIN =
        3,  // Latitude or longitude arguments were outside of acceptable range
    E_RES_DOMAIN = 4,    // Resolution argument was outside of acceptable range
    E_CELL_INVALID = 5,  // `H3Index` cell argument was not valid
    E_DIR_EDGE_INVALID = 6,  // `H3Index` directed edge argument was not valid
    E_UNDIR_EDGE_INVALID =
        7,                 // `H3Index` undirected edge argument was not valid
    E_VERTEX_INVALID = 8,  // `H3Index` vertex argument was not valid
    E_PENTAGON = 9,  // Pentagon distortion was encountered which the algorithm
                     // could not handle it
    E_DUPLICATE_INPUT = 10,  // Duplicate input was encountered in the arguments
                             // and the algorithm could not handle it
    E_NOT_NEIGHBORS = 11,    // `H3Index` cell arguments were not neighbors
    E_RES_MISMATCH =
        12,  // `H3Index` cell arguments had incompatible resolutions
    E_MEMORY_ALLOC = 13,   // Necessary memory allocation failed
    E_MEMORY_BOUNDS = 14,  // Bounds of provided memory were not large enough
    E_OPTION_INVALID = 15  // Mode or flags argument was not valid.
} H3ErrorCodes;

/* library version numbers generated from VERSION file */
// clang-format off
#define H3_VERSION_MAJOR 4
#define H3_VERSION_MINOR 0
#define H3_VERSION_PATCH 0
// clang-format on

/** Maximum number of cell boundary vertices; worst case is pentagon:
 *  5 original verts + 5 edge crossings
 */
#define MAX_CELL_BNDRY_VERTS 10

/** @struct LatLng
    @brief latitude/longitude in radians
*/
typedef struct {
    double lat;  ///< latitude in radians
    double lng;  ///< longitude in radians
} LatLng;

/** @struct CellBoundary
    @brief cell boundary in latitude/longitude
*/
typedef struct {
    int numVerts;                        ///< number of vertices
    LatLng verts[MAX_CELL_BNDRY_VERTS];  ///< vertices in ccw order
} CellBoundary;

/** @struct GeoLoop
 *  @brief similar to CellBoundary, but requires more alloc work
 */
typedef struct {
    int numVerts;
    LatLng *verts;
} GeoLoop;

/** @struct GeoPolygon
 *  @brief Simplified core of GeoJSON Polygon coordinates definition
 */
typedef struct {
    GeoLoop geoloop;  ///< exterior boundary of the polygon
    int numHoles;     ///< number of elements in the array pointed to by holes
    GeoLoop *holes;   ///< interior boundaries (holes) in the polygon
} GeoPolygon;

/** @struct GeoMultiPolygon
 *  @brief Simplified core of GeoJSON MultiPolygon coordinates definition
 */
typedef struct {
    int numPolygons;
    GeoPolygon *polygons;
} GeoMultiPolygon;

/** @struct LinkedLatLng
 *  @brief A coordinate node in a linked geo structure, part of a linked list
 */
typedef struct LinkedLatLng LinkedLatLng;
struct LinkedLatLng {
    LatLng vertex;
    LinkedLatLng *next;
};

/** @struct LinkedGeoLoop
 *  @brief A loop node in a linked geo structure, part of a linked list
 */
typedef struct LinkedGeoLoop LinkedGeoLoop;
struct LinkedGeoLoop {
    LinkedLatLng *first;
    LinkedLatLng *last;
    LinkedGeoLoop *next;
};

/** @struct LinkedGeoPolygon
 *  @brief A polygon node in a linked geo structure, part of a linked list.
 */
typedef struct LinkedGeoPolygon LinkedGeoPolygon;
struct LinkedGeoPolygon {
    LinkedGeoLoop *first;
    LinkedGeoLoop *last;
    LinkedGeoPolygon *next;
};

/** @struct CoordIJ
 * @brief IJ hexagon coordinates
 *
 * Each axis is spaced 120 degrees apart.
 */
typedef struct {
    int i;  ///< i component
    int j;  ///< j component
} CoordIJ;

/** @defgroup latLngToCell latLngToCell
 * Functions for latLngToCell
 * @{
 */
/** @brief find the H3 index of the resolution res cell containing the lat/lng
 */
DECLSPEC H3Error H3_EXPORT(latLngToCell)(const LatLng *g, int res,
                                         H3Index *out);
/** @} */

/** @defgroup cellToLatLng cellToLatLng
 * Functions for cellToLatLng
 * @{
 */
/** @brief find the lat/lng center point g of the cell h3 */
DECLSPEC H3Error H3_EXPORT(cellToLatLng)(H3Index h3, LatLng *g);
/** @} */

/** @defgroup cellToBoundary cellToBoundary
 * Functions for cellToBoundary
 * @{
 */
/** @brief give the cell boundary in lat/lng coordinates for the cell h3 */
DECLSPEC H3Error H3_EXPORT(cellToBoundary)(H3Index h3, CellBoundary *gp);
/** @} */

/** @defgroup gridDisk gridDisk
 * Functions for gridDisk
 * @{
 */
/** @brief maximum number of hexagons in k-ring */
DECLSPEC H3Error H3_EXPORT(maxGridDiskSize)(int k, int64_t *out);

/** @brief hexagons neighbors in all directions, assuming no pentagons */
DECLSPEC H3Error H3_EXPORT(gridDiskUnsafe)(H3Index origin, int k, H3Index *out);
/** @} */

/** @brief hexagons neighbors in all directions, assuming no pentagons,
 * reporting distance from origin */
DECLSPEC H3Error H3_EXPORT(gridDiskDistancesUnsafe)(H3Index origin, int k,
                                                    H3Index *out,
                                                    int *distances);

/** @brief hexagons neighbors in all directions reporting distance from origin
 */
DECLSPEC H3Error H3_EXPORT(gridDiskDistancesSafe)(H3Index origin, int k,
                                                  H3Index *out, int *distances);

/** @brief collection of hex rings sorted by ring for all given hexagons */
DECLSPEC H3Error H3_EXPORT(gridDisksUnsafe)(H3Index *h3Set, int length, int k,
                                            H3Index *out);

/** @brief hexagon neighbors in all directions */
DECLSPEC H3Error H3_EXPORT(gridDisk)(H3Index origin, int k, H3Index *out);
/** @} */

/** @defgroup gridDiskDistances gridDiskDistances
 * Functions for gridDiskDistances
 * @{
 */
/** @brief hexagon neighbors in all directions, reporting distance from origin
 */
DECLSPEC H3Error H3_EXPORT(gridDiskDistances)(H3Index origin, int k,
                                              H3Index *out, int *distances);
/** @} */

/** @defgroup gridRingUnsafe gridRingUnsafe
 * Functions for gridRingUnsafe
 * @{
 */
/** @brief hollow hexagon ring at some origin */
DECLSPEC H3Error H3_EXPORT(gridRingUnsafe)(H3Index origin, int k, H3Index *out);
/** @} */

/** @defgroup polygonToCells polygonToCells
 * Functions for polygonToCells
 * @{
 */
/** @brief maximum number of hexagons that could be in the geoloop */
DECLSPEC H3Error H3_EXPORT(maxPolygonToCellsSize)(const GeoPolygon *geoPolygon,
                                                  int res, uint32_t flags,
                                                  int64_t *out);

/** @brief hexagons within the given geopolygon */
DECLSPEC H3Error H3_EXPORT(polygonToCells)(const GeoPolygon *geoPolygon,
                                           int res, uint32_t flags,
                                           H3Index *out);
/** @} */

/** @defgroup cellsToMultiPolygon cellsToMultiPolygon
 * Functions for cellsToMultiPolygon (currently a binding-only concept)
 * @{
 */
/** @brief Create a LinkedGeoPolygon from a set of contiguous hexagons */
DECLSPEC H3Error H3_EXPORT(cellsToLinkedMultiPolygon)(const H3Index *h3Set,
                                                      const int numHexes,
                                                      LinkedGeoPolygon *out);

/** @brief Free all memory created for a LinkedGeoPolygon */
DECLSPEC void H3_EXPORT(destroyLinkedMultiPolygon)(LinkedGeoPolygon *polygon);
/** @} */

/** @defgroup degsToRads degsToRads
 * Functions for degsToRads
 * @{
 */
/** @brief converts degrees to radians */
DECLSPEC double H3_EXPORT(degsToRads)(double degrees);
/** @} */

/** @defgroup radsToDegs radsToDegs
 * Functions for radsToDegs
 * @{
 */
/** @brief converts radians to degrees */
DECLSPEC double H3_EXPORT(radsToDegs)(double radians);
/** @} */

/** @defgroup greatCircleDistance greatCircleDistance
 * Functions for distance
 * @{
 */
/** @brief "great circle distance" between pairs of LatLng points in radians*/
DECLSPEC double H3_EXPORT(greatCircleDistanceRads)(const LatLng *a,
                                                   const LatLng *b);

/** @brief "great circle distance" between pairs of LatLng points in
 * kilometers*/
DECLSPEC double H3_EXPORT(greatCircleDistanceKm)(const LatLng *a,
                                                 const LatLng *b);

/** @brief "great circle distance" between pairs of LatLng points in meters*/
DECLSPEC double H3_EXPORT(greatCircleDistanceM)(const LatLng *a,
                                                const LatLng *b);
/** @} */

/** @defgroup getHexagonAreaAvg getHexagonAreaAvg
 * Functions for getHexagonAreaAvg
 * @{
 */
/** @brief average hexagon area in square kilometers (excludes pentagons) */
DECLSPEC H3Error H3_EXPORT(getHexagonAreaAvgKm2)(int res, double *out);

/** @brief average hexagon area in square meters (excludes pentagons) */
DECLSPEC H3Error H3_EXPORT(getHexagonAreaAvgM2)(int res, double *out);
/** @} */

/** @defgroup cellArea cellArea
 * Functions for cellArea
 * @{
 */
/** @brief exact area for a specific cell (hexagon or pentagon) in radians^2 */
DECLSPEC H3Error H3_EXPORT(cellAreaRads2)(H3Index h, double *out);

/** @brief exact area for a specific cell (hexagon or pentagon) in kilometers^2
 */
DECLSPEC H3Error H3_EXPORT(cellAreaKm2)(H3Index h, double *out);

/** @brief exact area for a specific cell (hexagon or pentagon) in meters^2 */
DECLSPEC H3Error H3_EXPORT(cellAreaM2)(H3Index h, double *out);
/** @} */

/** @defgroup getHexagonEdgeLengthAvg getHexagonEdgeLengthAvg
 * Functions for getHexagonEdgeLengthAvg
 * @{
 */
/** @brief average hexagon edge length in kilometers (excludes pentagons) */
DECLSPEC H3Error H3_EXPORT(getHexagonEdgeLengthAvgKm)(int res, double *out);

/** @brief average hexagon edge length in meters (excludes pentagons) */
DECLSPEC H3Error H3_EXPORT(getHexagonEdgeLengthAvgM)(int res, double *out);
/** @} */

/** @defgroup exactEdgeLength exactEdgeLength
 * Functions for exactEdgeLength
 * @{
 */
/** @brief exact length for a specific directed edge in radians*/
DECLSPEC H3Error H3_EXPORT(exactEdgeLengthRads)(H3Index edge, double *length);

/** @brief exact length for a specific directed edge in kilometers*/
DECLSPEC H3Error H3_EXPORT(exactEdgeLengthKm)(H3Index edge, double *length);

/** @brief exact length for a specific directed edge in meters*/
DECLSPEC H3Error H3_EXPORT(exactEdgeLengthM)(H3Index edge, double *length);
/** @} */

/** @defgroup getNumCells getNumCells
 * Functions for getNumCells
 * @{
 */
/** @brief number of cells (hexagons and pentagons) for a given resolution
 *
 * It works out to be `2 + 120*7^r` for resolution `r`.
 *
 * # Mathematical notes
 *
 * Let h(n) be the number of children n levels below
 * a single *hexagon*.
 *
 * Then h(n) = 7^n.
 *
 * Let p(n) be the number of children n levels below
 * a single *pentagon*.
 *
 * Then p(0) = 1, and p(1) = 6, since each pentagon
 * has 5 hexagonal immediate children and 1 pentagonal
 * immediate child.
 *
 * In general, we have the recurrence relation
 *
 * p(n) = 5*h(n-1) + p(n-1)
 *      = 5*7^(n-1) + p(n-1).
 *
 * Working through the recurrence, we get that
 *
 * p(n) = 1 + 5*\sum_{k=1}^n 7^{k-1}
 *      = 1 + 5*(7^n - 1)/6,
 *
 * using the closed form for a geometric series.
 *
 * Using the closed forms for h(n) and p(n), we can
 * get a closed form for the total number of cells
 * at resolution r:
 *
 * c(r) = 12*p(r) + 110*h(r)
 *      = 2 + 120*7^r.
 *
 *
 * @param   res  H3 cell resolution
 *
 * @return       number of cells at resolution `res`
 */
DECLSPEC H3Error H3_EXPORT(getNumCells)(int res, int64_t *out);
/** @} */

/** @defgroup getRes0Cells getRes0Cells
 * Functions for getRes0Cells
 * @{
 */
/** @brief returns the number of resolution 0 cells (hexagons and pentagons) */
DECLSPEC int H3_EXPORT(res0CellCount)();

/** @brief provides all base cells in H3Index format*/
DECLSPEC H3Error H3_EXPORT(getRes0Cells)(H3Index *out);
/** @} */

/** @defgroup getPentagons getPentagons
 * Functions for getPentagons
 * @{
 */
/** @brief returns the number of pentagons per resolution */
DECLSPEC int H3_EXPORT(pentagonCount)();

/** @brief generates all pentagons at the specified resolution */
DECLSPEC H3Error H3_EXPORT(getPentagons)(int res, H3Index *out);
/** @} */

/** @defgroup getResolution getResolution
 * Functions for getResolution
 * @{
 */
/** @brief returns the resolution of the provided H3 index
 * Works on both cells and directed edges. */
DECLSPEC int H3_EXPORT(getResolution)(H3Index h);
/** @} */

/** @defgroup getBaseCellNumber getBaseCellNumber
 * Functions for getBaseCellNumber
 * @{
 */
/** @brief returns the base cell "number" (0 to 121) of the provided H3 cell
 *
 * Note: Technically works on H3 edges, but will return base cell of the
 * origin cell. */
DECLSPEC int H3_EXPORT(getBaseCellNumber)(H3Index h);
/** @} */

/** @defgroup stringToH3 stringToH3
 * Functions for stringToH3
 * @{
 */
/** @brief converts the canonical string format to H3Index format */
DECLSPEC H3Error H3_EXPORT(stringToH3)(const char *str, H3Index *out);
/** @} */

/** @defgroup h3ToString h3ToString
 * Functions for h3ToString
 * @{
 */
/** @brief converts an H3Index to a canonical string */
DECLSPEC H3Error H3_EXPORT(h3ToString)(H3Index h, char *str, size_t sz);
/** @} */

/** @defgroup isValidCell isValidCell
 * Functions for isValidCell
 * @{
 */
/** @brief confirms if an H3Index is a valid cell (hexagon or pentagon)
 * In particular, returns 0 (False) for H3 directed edges or invalid data
 */
DECLSPEC int H3_EXPORT(isValidCell)(H3Index h);
/** @} */

/** @defgroup cellToParent cellToParent
 * Functions for cellToParent
 * @{
 */
/** @brief returns the parent (or grandparent, etc) cell of the given cell
 */
DECLSPEC H3Error H3_EXPORT(cellToParent)(H3Index h, int parentRes,
                                         H3Index *parent);
/** @} */

/** @defgroup cellToChildren cellToChildren
 * Functions for cellToChildren
 * @{
 */
/** @brief determines the exact number of children (or grandchildren, etc)
 * that would be returned for the given cell */
DECLSPEC H3Error H3_EXPORT(cellToChildrenSize)(H3Index h, int childRes,
                                               int64_t *out);

/** @brief provides the children (or grandchildren, etc) of the given cell */
DECLSPEC H3Error H3_EXPORT(cellToChildren)(H3Index h, int childRes,
                                           H3Index *children);
/** @} */

/** @defgroup cellToCenterChild cellToCenterChild
 * Functions for cellToCenterChild
 * @{
 */
/** @brief returns the center child of the given cell at the specified
 * resolution */
DECLSPEC H3Error H3_EXPORT(cellToCenterChild)(H3Index h, int childRes,
                                              H3Index *child);
/** @} */

/** @defgroup compactCells compactCells
 * Functions for compactCells
 * @{
 */
/** @brief compacts the given set of hexagons as best as possible */
DECLSPEC H3Error H3_EXPORT(compactCells)(const H3Index *h3Set,
                                         H3Index *compactedSet,
                                         const int64_t numHexes);
/** @} */

/** @defgroup uncompactCells uncompactCells
 * Functions for uncompactCells
 * @{
 */
/** @brief determines the exact number of hexagons that will be uncompacted
 * from the compacted set */
DECLSPEC H3Error H3_EXPORT(uncompactCellsSize)(const H3Index *compactedSet,
                                               const int64_t numCompacted,
                                               const int res, int64_t *out);

/** @brief uncompacts the compacted hexagon set */
DECLSPEC H3Error H3_EXPORT(uncompactCells)(const H3Index *compactedSet,
                                           const int64_t numCompacted,
                                           H3Index *outSet,
                                           const int64_t numOut, const int res);
/** @} */

/** @defgroup isResClassIII isResClassIII
 * Functions for isResClassIII
 * @{
 */
/** @brief determines if a hexagon is Class III (or Class II) */
DECLSPEC int H3_EXPORT(isResClassIII)(H3Index h);
/** @} */

/** @defgroup isPentagon isPentagon
 * Functions for isPentagon
 * @{
 */
/** @brief determines if an H3 cell is a pentagon */
DECLSPEC int H3_EXPORT(isPentagon)(H3Index h);
/** @} */

/** @defgroup getIcosahedronFaces getIcosahedronFaces
 * Functions for getIcosahedronFaces
 * @{
 */
/** @brief Max number of icosahedron faces intersected by an index */
DECLSPEC H3Error H3_EXPORT(maxFaceCount)(H3Index h3, int *out);

/** @brief Find all icosahedron faces intersected by a given H3 index */
DECLSPEC H3Error H3_EXPORT(getIcosahedronFaces)(H3Index h3, int *out);
/** @} */

/** @defgroup areNeighborCells areNeighborCells
 * Functions for areNeighborCells
 * @{
 */
/** @brief returns whether or not the provided hexagons border */
DECLSPEC H3Error H3_EXPORT(areNeighborCells)(H3Index origin,
                                             H3Index destination, int *out);
/** @} */

/** @defgroup cellsToDirectedEdge cellsToDirectedEdge
 * Functions for cellsToDirectedEdge
 * @{
 */
/** @brief returns the directed edge H3Index for the specified origin and
 * destination */
DECLSPEC H3Error H3_EXPORT(cellsToDirectedEdge)(H3Index origin,
                                                H3Index destination,
                                                H3Index *out);
/** @} */

/** @defgroup isValidDirectedEdge isValidDirectedEdge
 * Functions for isValidDirectedEdge
 * @{
 */
/** @brief returns whether the H3Index is a valid directed edge */
DECLSPEC int H3_EXPORT(isValidDirectedEdge)(H3Index edge);
/** @} */

/** @defgroup getDirectedEdgeOrigin \
 * getDirectedEdgeOrigin
 * Functions for getDirectedEdgeOrigin
 * @{
 */
/** @brief Returns the origin hexagon H3Index from the directed edge
 * H3Index */
DECLSPEC H3Error H3_EXPORT(getDirectedEdgeOrigin)(H3Index edge, H3Index *out);
/** @} */

/** @defgroup getDirectedEdgeDestination \
 * getDirectedEdgeDestination
 * Functions for getDirectedEdgeDestination
 * @{
 */
/** @brief Returns the destination hexagon H3Index from the directed edge
 * H3Index */
DECLSPEC H3Error H3_EXPORT(getDirectedEdgeDestination)(H3Index edge,
                                                       H3Index *out);
/** @} */

/** @defgroup directedEdgeToCells \
 * directedEdgeToCells
 * Functions for directedEdgeToCells
 * @{
 */
/** @brief Returns the origin and destination hexagons from the directed
 * edge H3Index */
DECLSPEC H3Error H3_EXPORT(directedEdgeToCells)(H3Index edge,
                                                H3Index *originDestination);
/** @} */

/** @defgroup originToDirectedEdges \
 * originToDirectedEdges
 * Functions for originToDirectedEdges
 * @{
 */
/** @brief Returns the 6 (or 5 for pentagons) edges associated with the H3Index
 */
DECLSPEC H3Error H3_EXPORT(originToDirectedEdges)(H3Index origin,
                                                  H3Index *edges);
/** @} */

/** @defgroup directedEdgeToBoundary directedEdgeToBoundary
 * Functions for directedEdgeToBoundary
 * @{
 */
/** @brief Returns the CellBoundary containing the coordinates of the edge */
DECLSPEC H3Error H3_EXPORT(directedEdgeToBoundary)(H3Index edge,
                                                   CellBoundary *gb);
/** @} */

/** @defgroup cellToVertex cellToVertex
 * Functions for cellToVertex
 * @{
 */
/** @brief Returns a single vertex for a given cell, as an H3 index */
DECLSPEC H3Error H3_EXPORT(cellToVertex)(H3Index origin, int vertexNum,
                                         H3Index *out);
/** @} */

/** @defgroup cellToVertexes cellToVertexes
 * Functions for cellToVertexes
 * @{
 */
/** @brief Returns all vertexes for a given cell, as H3 indexes */
DECLSPEC H3Error H3_EXPORT(cellToVertexes)(H3Index origin, H3Index *vertexes);
/** @} */

/** @defgroup vertexToLatLng vertexToLatLng
 * Functions for vertexToLatLng
 * @{
 */
/** @brief Returns a single vertex for a given cell, as an H3 index */
DECLSPEC H3Error H3_EXPORT(vertexToLatLng)(H3Index vertex, LatLng *point);
/** @} */

/** @defgroup isValidVertex isValidVertex
 * Functions for isValidVertex
 * @{
 */
/** @brief Whether the input is a valid H3 vertex */
DECLSPEC int H3_EXPORT(isValidVertex)(H3Index vertex);
/** @} */

/** @defgroup gridDistance gridDistance
 * Functions for gridDistance
 * @{
 */
/** @brief Returns grid distance between two indexes */
DECLSPEC H3Error H3_EXPORT(gridDistance)(H3Index origin, H3Index h3,
                                         int64_t *distance);
/** @} */

/** @defgroup gridPathCells gridPathCells
 * Functions for gridPathCells
 * @{
 */
/** @brief Number of indexes in a line connecting two indexes */
DECLSPEC H3Error H3_EXPORT(gridPathCellsSize)(H3Index start, H3Index end,
                                              int64_t *size);

/** @brief Line of h3 indexes connecting two indexes */
DECLSPEC H3Error H3_EXPORT(gridPathCells)(H3Index start, H3Index end,
                                          H3Index *out);
/** @} */

/** @defgroup cellToLocalIj cellToLocalIj
 * Functions for cellToLocalIj
 * @{
 */
/** @brief Returns two dimensional coordinates for the given index */
DECLSPEC H3Error H3_EXPORT(cellToLocalIj)(H3Index origin, H3Index h3,
                                          uint32_t mode, CoordIJ *out);
/** @} */

/** @defgroup localIjToCell localIjToCell
 * Functions for localIjToCell
 * @{
 */
/** @brief Returns index for the given two dimensional coordinates */
DECLSPEC H3Error H3_EXPORT(localIjToCell)(H3Index origin, const CoordIJ *ij,
                                          uint32_t mode, H3Index *out);
/** @} */

#ifdef __cplusplus
}  // extern "C"
#endif

#endif

Output:

unit h3api;
interface

{
  Automatically converted by H2Pas 1.0.0 from C:\crapho\h3api.tmp.h
  The following command line parameters were used:
    -e
    -p
    -D
    -w
    -o
    C:\crapho\h3api.pas
    C:\crapho\h3api.tmp.h
}

    const
      External_library='kernel32'; {Setup as you need}

    { Pointers to basic pascal types, inserted by h2pas conversion program.}
    Type
      PLongint  = ^Longint;
      PSmallInt = ^SmallInt;
      PByte     = ^Byte;
      PWord     = ^Word;
      PDWord    = ^DWord;
      PDouble   = ^Double;

    Type
    PCellBoundary  = ^CellBoundary;
    PCoordIJ  = ^CoordIJ;
    PGeoLoop  = ^GeoLoop;
    PGeoMultiPolygon  = ^GeoMultiPolygon;
    PGeoPolygon  = ^GeoPolygon;
    PH3Error  = ^H3Error;
    PH3ErrorCodes  = ^H3ErrorCodes;
    PH3Index  = ^H3Index;
    PLatLng  = ^LatLng;
    PLinkedGeoLoop  = ^LinkedGeoLoop;
    PLinkedGeoPolygon  = ^LinkedGeoPolygon;
    PLinkedLatLng  = ^LinkedLatLng;
{$IFDEF FPC}
{$PACKRECORDS C}
{$ENDIF}


  {
   * Copyright 2016-2021 Uber Technologies, Inc.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *         http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
    }
  {* @file h3api.h
   * @brief   Primary H3 core library entry points.
   *
   * This file defines the public API of the H3 library. Incompatible changes to
   * these functions require the library's major version be increased.
    }
{$ifndef H3API_H}
{$define H3API_H}
  {
   * Preprocessor code to support renaming (prefixing) the public API.
   * All public functions should be wrapped in H3_EXPORT so they can be
   * renamed.
    }
{$ifdef H3_PREFIX}
(* error
#define XTJOIN(a, b) a##b
in define line 32 *)
    { was #define dname(params) para_def_expr }
    { argument types are unknown }
    { return type might be wrong }

    function TJOIN(a,b : longint) : longint;

    { export joins the user provided prefix with our exported function name  }
    { was #define dname(params) para_def_expr }
    { argument types are unknown }
    { return type might be wrong }
    function H3_EXPORT(name : longint) : longint;

{$else}
    { was #define dname(params) para_def_expr }
    { argument types are unknown }
    { return type might be wrong }

    function H3_EXPORT(name : longint) : longint;

{$endif}
    { Windows DLL requires attributes indicating what to export  }
{$if _WIN32 && BUILD_SHARED_LIBS}
{$if BUILDING_H3}

    { was #define dname def_expr }
    function DECLSPEC : longint; { return type might be wrong }

{$else}

    { was #define dname def_expr }
    function DECLSPEC : longint; { return type might be wrong }

{$endif}
{$else}
{$define DECLSPEC}
{$endif}
    { For uint64_t  }
{$include <stdint.h>}
    { For size_t  }
{$include <stdlib.h>}
    {
     * H3 is compiled as C, not C++ code. `extern "C"` is needed for C++ code
     * to be able to use the library.
      }
{ C++ extern C conditionnal removed }
    {* @brief Identifier for an object (cell, edge, etc) in the H3 system.
     *
     * The H3Index fits within a 64-bit unsigned integer.
      }

    type
      PH3Index = ^H3Index;
      H3Index = uint64_t;
    {*
     * Invalid index used to indicate an error from latLngToCell and related
     * functions or missing data in arrays of H3 indices. Analogous to NaN in
     * floating point.
      }

    const
      H3_NULL = 0;
    {* @brief Result code (success or specific error) from an H3 operation  }

    type
      PH3Error = ^H3Error;
      H3Error = uint32_t;
    { Success (no error) }
    { The operation failed but a more specific error is not available }
    { Argument was outside of acceptable range (when a more }
    { specific error code is not available) }
    { Latitude or longitude arguments were outside of acceptable range }
    { Resolution argument was outside of acceptable range }
    { `H3Index` cell argument was not valid }
    { `H3Index` directed edge argument was not valid }
    { `H3Index` undirected edge argument was not valid }
    { `H3Index` vertex argument was not valid }
    { Pentagon distortion was encountered which the algorithm }
    { could not handle it }
    { Duplicate input was encountered in the arguments }
    { and the algorithm could not handle it }
    { `H3Index` cell arguments were not neighbors }
    { `H3Index` cell arguments had incompatible resolutions }
    { Necessary memory allocation failed }
    { Bounds of provided memory were not large enough }
    { Mode or flags argument was not valid. }

      PH3ErrorCodes = ^H3ErrorCodes;
      H3ErrorCodes =  Longint;
      Const
        E_SUCCESS = 0;
        E_FAILED = 1;
        E_DOMAIN = 2;
        E_LATLNG_DOMAIN = 3;
        E_RES_DOMAIN = 4;
        E_CELL_INVALID = 5;
        E_DIR_EDGE_INVALID = 6;
        E_UNDIR_EDGE_INVALID = 7;
        E_VERTEX_INVALID = 8;
        E_PENTAGON = 9;
        E_DUPLICATE_INPUT = 10;
        E_NOT_NEIGHBORS = 11;
        E_RES_MISMATCH = 12;
        E_MEMORY_ALLOC = 13;
        E_MEMORY_BOUNDS = 14;
        E_OPTION_INVALID = 15;
;
    { library version numbers generated from VERSION file  }
    { clang-format off }
      H3_VERSION_MAJOR = 4;
      H3_VERSION_MINOR = 0;
      H3_VERSION_PATCH = 0;
    { clang-format on }
    {* Maximum number of cell boundary vertices; worst case is pentagon:
     *  5 original verts + 5 edge crossings
      }
      MAX_CELL_BNDRY_VERTS = 10;
    {* @struct LatLng
        @brief latitude/longitude in radians
     }
    {/< latitude in radians }
    {/< longitude in radians }

    type
      PLatLng = ^LatLng;
      LatLng = record
          lat : double;
          lng : double;
        end;
    {* @struct CellBoundary
        @brief cell boundary in latitude/longitude
     }
    {/< number of vertices }
    {/< vertices in ccw order }

      PCellBoundary = ^CellBoundary;
      CellBoundary = record
          numVerts : longint;
          verts : array[0..(MAX_CELL_BNDRY_VERTS)-1] of LatLng;
        end;
    {* @struct GeoLoop
     *  @brief similar to CellBoundary, but requires more alloc work
      }

      PGeoLoop = ^GeoLoop;
      GeoLoop = record
          numVerts : longint;
          verts : PLatLng;
        end;
    {* @struct GeoPolygon
     *  @brief Simplified core of GeoJSON Polygon coordinates definition
      }
    {/< exterior boundary of the polygon }
    {/< number of elements in the array pointed to by holes }
    {/< interior boundaries (holes) in the polygon }

      PGeoPolygon = ^GeoPolygon;
      GeoPolygon = record
          geoloop : GeoLoop;
          numHoles : longint;
          holes : PGeoLoop;
        end;
    {* @struct GeoMultiPolygon
     *  @brief Simplified core of GeoJSON MultiPolygon coordinates definition
      }

      PGeoMultiPolygon = ^GeoMultiPolygon;
      GeoMultiPolygon = record
          numPolygons : longint;
          polygons : PGeoPolygon;
        end;
    {* @struct LinkedLatLng
     *  @brief A coordinate node in a linked geo structure, part of a linked list
      }
      PLinkedLatLng = ^LinkedLatLng;
      LinkedLatLng = record
          vertex : LatLng;
          next : PLinkedLatLng;
        end;

    {* @struct LinkedGeoLoop
     *  @brief A loop node in a linked geo structure, part of a linked list
      }
      PLinkedGeoLoop = ^LinkedGeoLoop;
      LinkedGeoLoop = record
          first : PLinkedLatLng;
          last : PLinkedLatLng;
          next : PLinkedGeoLoop;
        end;

    {* @struct LinkedGeoPolygon
     *  @brief A polygon node in a linked geo structure, part of a linked list.
      }
      PLinkedGeoPolygon = ^LinkedGeoPolygon;
      LinkedGeoPolygon = record
          first : PLinkedGeoLoop;
          last : PLinkedGeoLoop;
          next : PLinkedGeoPolygon;
        end;

    {* @struct CoordIJ
     * @brief IJ hexagon coordinates
     *
     * Each axis is spaced 120 degrees apart.
      }
    {/< i component }
    {/< j component }

      PCoordIJ = ^CoordIJ;
      CoordIJ = record
          i : longint;
          j : longint;
        end;
    {* @defgroup latLngToCell latLngToCell
     * Functions for latLngToCell
     * @
      }
    {* @brief find the H3 index of the resolution res cell containing the lat/lng
      }
(* error
DECLSPEC H3Error H3_EXPORT(latLngToCell)(const LatLng *g, int res,
(* error
DECLSPEC H3Error H3_EXPORT(latLngToCell)(const LatLng *g, int res,
(* error
                                         H3Index *out);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup cellToLatLng cellToLatLng
     * Functions for cellToLatLng
     * @
      }
    {* @brief find the lat/lng center point g of the cell h3  }
(* error
DECLSPEC H3Error H3_EXPORT(cellToLatLng)(H3Index h3, LatLng *g);
(* error
DECLSPEC H3Error H3_EXPORT(cellToLatLng)(H3Index h3, LatLng *g);
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup cellToBoundary cellToBoundary
     * Functions for cellToBoundary
     * @
      }
    {* @brief give the cell boundary in lat/lng coordinates for the cell h3  }
(* error
DECLSPEC H3Error H3_EXPORT(cellToBoundary)(H3Index h3, CellBoundary *gp);
(* error
DECLSPEC H3Error H3_EXPORT(cellToBoundary)(H3Index h3, CellBoundary *gp);
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup gridDisk gridDisk
     * Functions for gridDisk
     * @
      }
    {* @brief maximum number of hexagons in k-ring  }
(* error
DECLSPEC H3Error H3_EXPORT(maxGridDiskSize)(int k, int64_t *out);
(* error
DECLSPEC H3Error H3_EXPORT(maxGridDiskSize)(int k, int64_t *out);
 in declarator_list *)
 in declarator_list *)
    {* @brief hexagons neighbors in all directions, assuming no pentagons  }
(* error
DECLSPEC H3Error H3_EXPORT(gridDiskUnsafe)(H3Index origin, int k, H3Index *out);
(* error
DECLSPEC H3Error H3_EXPORT(gridDiskUnsafe)(H3Index origin, int k, H3Index *out);
(* error
DECLSPEC H3Error H3_EXPORT(gridDiskUnsafe)(H3Index origin, int k, H3Index *out);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @brief hexagons neighbors in all directions, assuming no pentagons,
     * reporting distance from origin  }
(* error
DECLSPEC H3Error H3_EXPORT(gridDiskDistancesUnsafe)(H3Index origin, int k,
(* error
DECLSPEC H3Error H3_EXPORT(gridDiskDistancesUnsafe)(H3Index origin, int k,
(* error
                                                    H3Index *out,
(* error
                                                    int *distances);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @brief hexagons neighbors in all directions reporting distance from origin
      }
(* error
DECLSPEC H3Error H3_EXPORT(gridDiskDistancesSafe)(H3Index origin, int k,
(* error
DECLSPEC H3Error H3_EXPORT(gridDiskDistancesSafe)(H3Index origin, int k,
(* error
                                                  H3Index *out, int *distances);
(* error
                                                  H3Index *out, int *distances);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @brief collection of hex rings sorted by ring for all given hexagons  }
(* error
DECLSPEC H3Error H3_EXPORT(gridDisksUnsafe)(H3Index *h3Set, int length, int k,
(* error
DECLSPEC H3Error H3_EXPORT(gridDisksUnsafe)(H3Index *h3Set, int length, int k,
(* error
DECLSPEC H3Error H3_EXPORT(gridDisksUnsafe)(H3Index *h3Set, int length, int k,
(* error
                                            H3Index *out);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @brief hexagon neighbors in all directions  }
(* error
DECLSPEC H3Error H3_EXPORT(gridDisk)(H3Index origin, int k, H3Index *out);
(* error
DECLSPEC H3Error H3_EXPORT(gridDisk)(H3Index origin, int k, H3Index *out);
(* error
DECLSPEC H3Error H3_EXPORT(gridDisk)(H3Index origin, int k, H3Index *out);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup gridDiskDistances gridDiskDistances
     * Functions for gridDiskDistances
     * @
      }
    {* @brief hexagon neighbors in all directions, reporting distance from origin
      }
(* error
DECLSPEC H3Error H3_EXPORT(gridDiskDistances)(H3Index origin, int k,
(* error
DECLSPEC H3Error H3_EXPORT(gridDiskDistances)(H3Index origin, int k,
(* error
                                              H3Index *out, int *distances);
(* error
                                              H3Index *out, int *distances);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup gridRingUnsafe gridRingUnsafe
     * Functions for gridRingUnsafe
     * @
      }
    {* @brief hollow hexagon ring at some origin  }
(* error
DECLSPEC H3Error H3_EXPORT(gridRingUnsafe)(H3Index origin, int k, H3Index *out);
(* error
DECLSPEC H3Error H3_EXPORT(gridRingUnsafe)(H3Index origin, int k, H3Index *out);
(* error
DECLSPEC H3Error H3_EXPORT(gridRingUnsafe)(H3Index origin, int k, H3Index *out);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup polygonToCells polygonToCells
     * Functions for polygonToCells
     * @
      }
    {* @brief maximum number of hexagons that could be in the geoloop  }
(* error
DECLSPEC H3Error H3_EXPORT(maxPolygonToCellsSize)(const GeoPolygon *geoPolygon,
(* error
                                                  int res, uint32_t flags,
(* error
                                                  int res, uint32_t flags,
(* error
                                                  int64_t *out);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @brief hexagons within the given geopolygon  }
(* error
DECLSPEC H3Error H3_EXPORT(polygonToCells)(const GeoPolygon *geoPolygon,
(* error
                                           int res, uint32_t flags,
(* error
                                           int res, uint32_t flags,
(* error
                                           H3Index *out);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup cellsToMultiPolygon cellsToMultiPolygon
     * Functions for cellsToMultiPolygon (currently a binding-only concept)
     * @
      }
    {* @brief Create a LinkedGeoPolygon from a set of contiguous hexagons  }
(* error
DECLSPEC H3Error H3_EXPORT(cellsToLinkedMultiPolygon)(const H3Index *h3Set,
(* error
                                                      const int numHexes,
(* error
                                                      LinkedGeoPolygon *out);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @brief Free all memory created for a LinkedGeoPolygon  }
(* error
DECLSPEC void H3_EXPORT(destroyLinkedMultiPolygon)(LinkedGeoPolygon *polygon);
in declaration at line 298 *)
    {* @  }
    {* @defgroup degsToRads degsToRads
     * Functions for degsToRads
     * @
      }
    {* @brief converts degrees to radians  }
(* error
DECLSPEC double H3_EXPORT(degsToRads)(double degrees);
 in declarator_list *)
    {* @  }
    {* @defgroup radsToDegs radsToDegs
     * Functions for radsToDegs
     * @
      }
    {* @brief converts radians to degrees  }
(* error
DECLSPEC double H3_EXPORT(radsToDegs)(double radians);
 in declarator_list *)
    {* @  }
    {* @defgroup greatCircleDistance greatCircleDistance
     * Functions for distance
     * @
      }
    {* @brief "great circle distance" between pairs of LatLng points in radians }
(* error
DECLSPEC double H3_EXPORT(greatCircleDistanceRads)(const LatLng *a,
(* error
                                                   const LatLng *b);
 in declarator_list *)
 in declarator_list *)
    {* @brief "great circle distance" between pairs of LatLng points in
     * kilometers }
(* error
DECLSPEC double H3_EXPORT(greatCircleDistanceKm)(const LatLng *a,
(* error
                                                 const LatLng *b);
 in declarator_list *)
 in declarator_list *)
    {* @brief "great circle distance" between pairs of LatLng points in meters }
(* error
DECLSPEC double H3_EXPORT(greatCircleDistanceM)(const LatLng *a,
(* error
                                                const LatLng *b);
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup getHexagonAreaAvg getHexagonAreaAvg
     * Functions for getHexagonAreaAvg
     * @
      }
    {* @brief average hexagon area in square kilometers (excludes pentagons)  }
(* error
DECLSPEC H3Error H3_EXPORT(getHexagonAreaAvgKm2)(int res, double *out);
(* error
DECLSPEC H3Error H3_EXPORT(getHexagonAreaAvgKm2)(int res, double *out);
 in declarator_list *)
 in declarator_list *)
    {* @brief average hexagon area in square meters (excludes pentagons)  }
(* error
DECLSPEC H3Error H3_EXPORT(getHexagonAreaAvgM2)(int res, double *out);
(* error
DECLSPEC H3Error H3_EXPORT(getHexagonAreaAvgM2)(int res, double *out);
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup cellArea cellArea
     * Functions for cellArea
     * @
      }
    {* @brief exact area for a specific cell (hexagon or pentagon) in radians^2  }
(* error
DECLSPEC H3Error H3_EXPORT(cellAreaRads2)(H3Index h, double *out);
(* error
DECLSPEC H3Error H3_EXPORT(cellAreaRads2)(H3Index h, double *out);
 in declarator_list *)
 in declarator_list *)
    {* @brief exact area for a specific cell (hexagon or pentagon) in kilometers^2
      }
(* error
DECLSPEC H3Error H3_EXPORT(cellAreaKm2)(H3Index h, double *out);
(* error
DECLSPEC H3Error H3_EXPORT(cellAreaKm2)(H3Index h, double *out);
 in declarator_list *)
 in declarator_list *)
    {* @brief exact area for a specific cell (hexagon or pentagon) in meters^2  }
(* error
DECLSPEC H3Error H3_EXPORT(cellAreaM2)(H3Index h, double *out);
(* error
DECLSPEC H3Error H3_EXPORT(cellAreaM2)(H3Index h, double *out);
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup getHexagonEdgeLengthAvg getHexagonEdgeLengthAvg
     * Functions for getHexagonEdgeLengthAvg
     * @
      }
    {* @brief average hexagon edge length in kilometers (excludes pentagons)  }
(* error
DECLSPEC H3Error H3_EXPORT(getHexagonEdgeLengthAvgKm)(int res, double *out);
(* error
DECLSPEC H3Error H3_EXPORT(getHexagonEdgeLengthAvgKm)(int res, double *out);
 in declarator_list *)
 in declarator_list *)
    {* @brief average hexagon edge length in meters (excludes pentagons)  }
(* error
DECLSPEC H3Error H3_EXPORT(getHexagonEdgeLengthAvgM)(int res, double *out);
(* error
DECLSPEC H3Error H3_EXPORT(getHexagonEdgeLengthAvgM)(int res, double *out);
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup exactEdgeLength exactEdgeLength
     * Functions for exactEdgeLength
     * @
      }
    {* @brief exact length for a specific directed edge in radians }
(* error
DECLSPEC H3Error H3_EXPORT(exactEdgeLengthRads)(H3Index edge, double *length);
(* error
DECLSPEC H3Error H3_EXPORT(exactEdgeLengthRads)(H3Index edge, double *length);
 in declarator_list *)
 in declarator_list *)
    {* @brief exact length for a specific directed edge in kilometers }
(* error
DECLSPEC H3Error H3_EXPORT(exactEdgeLengthKm)(H3Index edge, double *length);
(* error
DECLSPEC H3Error H3_EXPORT(exactEdgeLengthKm)(H3Index edge, double *length);
 in declarator_list *)
 in declarator_list *)
    {* @brief exact length for a specific directed edge in meters }
(* error
DECLSPEC H3Error H3_EXPORT(exactEdgeLengthM)(H3Index edge, double *length);
(* error
DECLSPEC H3Error H3_EXPORT(exactEdgeLengthM)(H3Index edge, double *length);
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup getNumCells getNumCells
     * Functions for getNumCells
     * @
      }
    {* @brief number of cells (hexagons and pentagons) for a given resolution
     *
     * It works out to be `2 + 120*7^r` for resolution `r`.
     *
     * # Mathematical notes
     *
     * Let h(n) be the number of children n levels below
     * a single *hexagon*.
     *
     * Then h(n) = 7^n.
     *
     * Let p(n) be the number of children n levels below
     * a single *pentagon*.
     *
     * Then p(0) = 1, and p(1) = 6, since each pentagon
     * has 5 hexagonal immediate children and 1 pentagonal
     * immediate child.
     *
     * In general, we have the recurrence relation
     *
     * p(n) = 5*h(n-1) + p(n-1)
     *      = 5*7^(n-1) + p(n-1).
     *
     * Working through the recurrence, we get that
     *
     * p(n) = 1 + 5*\sum_k=1^n 7^k-1
     *      = 1 + 5*(7^n - 1)/6,
     *
     * using the closed form for a geometric series.
     *
     * Using the closed forms for h(n) and p(n), we can
     * get a closed form for the total number of cells
     * at resolution r:
     *
     * c(r) = 12*p(r) + 110*h(r)
     *      = 2 + 120*7^r.
     *
     *
     * @param   res  H3 cell resolution
     *
     * @return       number of cells at resolution `res`
      }
(* error
DECLSPEC H3Error H3_EXPORT(getNumCells)(int res, int64_t *out);
(* error
DECLSPEC H3Error H3_EXPORT(getNumCells)(int res, int64_t *out);
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup getRes0Cells getRes0Cells
     * Functions for getRes0Cells
     * @
      }
    {* @brief returns the number of resolution 0 cells (hexagons and pentagons)  }
(* error
DECLSPEC int H3_EXPORT(res0CellCount)();
in declaration at line 440 *)
    {* @brief provides all base cells in H3Index format }
(* error
DECLSPEC H3Error H3_EXPORT(getRes0Cells)(H3Index *out);
 in declarator_list *)
    {* @  }
    {* @defgroup getPentagons getPentagons
     * Functions for getPentagons
     * @
      }
    {* @brief returns the number of pentagons per resolution  }
(* error
DECLSPEC int H3_EXPORT(pentagonCount)();
in declaration at line 451 *)
    {* @brief generates all pentagons at the specified resolution  }
(* error
DECLSPEC H3Error H3_EXPORT(getPentagons)(int res, H3Index *out);
(* error
DECLSPEC H3Error H3_EXPORT(getPentagons)(int res, H3Index *out);
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup getResolution getResolution
     * Functions for getResolution
     * @
      }
    {* @brief returns the resolution of the provided H3 index
     * Works on both cells and directed edges.  }
(* error
DECLSPEC int H3_EXPORT(getResolution)(H3Index h);
in declaration at line 463 *)
    {* @  }
    {* @defgroup getBaseCellNumber getBaseCellNumber
     * Functions for getBaseCellNumber
     * @
      }
    {* @brief returns the base cell "number" (0 to 121) of the provided H3 cell
     *
     * Note: Technically works on H3 edges, but will return base cell of the
     * origin cell.  }
(* error
DECLSPEC int H3_EXPORT(getBaseCellNumber)(H3Index h);
in declaration at line 474 *)
    {* @  }
    {* @defgroup stringToH3 stringToH3
     * Functions for stringToH3
     * @
      }
    {* @brief converts the canonical string format to H3Index format  }
(* error
DECLSPEC H3Error H3_EXPORT(stringToH3)(const char *str, H3Index *out);
(* error
DECLSPEC H3Error H3_EXPORT(stringToH3)(const char *str, H3Index *out);
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup h3ToString h3ToString
     * Functions for h3ToString
     * @
      }
    {* @brief converts an H3Index to a canonical string  }
(* error
DECLSPEC H3Error H3_EXPORT(h3ToString)(H3Index h, char *str, size_t sz);
(* error
DECLSPEC H3Error H3_EXPORT(h3ToString)(H3Index h, char *str, size_t sz);
(* error
DECLSPEC H3Error H3_EXPORT(h3ToString)(H3Index h, char *str, size_t sz);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup isValidCell isValidCell
     * Functions for isValidCell
     * @
      }
    {* @brief confirms if an H3Index is a valid cell (hexagon or pentagon)
     * In particular, returns 0 (False) for H3 directed edges or invalid data
      }
(* error
DECLSPEC int H3_EXPORT(isValidCell)(H3Index h);
in declaration at line 500 *)
    {* @  }
    {* @defgroup cellToParent cellToParent
     * Functions for cellToParent
     * @
      }
    {* @brief returns the parent (or grandparent, etc) cell of the given cell
      }
(* error
DECLSPEC H3Error H3_EXPORT(cellToParent)(H3Index h, int parentRes,
(* error
DECLSPEC H3Error H3_EXPORT(cellToParent)(H3Index h, int parentRes,
(* error
                                         H3Index *parent);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup cellToChildren cellToChildren
     * Functions for cellToChildren
     * @
      }
    {* @brief determines the exact number of children (or grandchildren, etc)
     * that would be returned for the given cell  }
(* error
DECLSPEC H3Error H3_EXPORT(cellToChildrenSize)(H3Index h, int childRes,
(* error
DECLSPEC H3Error H3_EXPORT(cellToChildrenSize)(H3Index h, int childRes,
(* error
                                               int64_t *out);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @brief provides the children (or grandchildren, etc) of the given cell  }
(* error
DECLSPEC H3Error H3_EXPORT(cellToChildren)(H3Index h, int childRes,
(* error
DECLSPEC H3Error H3_EXPORT(cellToChildren)(H3Index h, int childRes,
(* error
                                           H3Index *children);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup cellToCenterChild cellToCenterChild
     * Functions for cellToCenterChild
     * @
      }
    {* @brief returns the center child of the given cell at the specified
     * resolution  }
(* error
DECLSPEC H3Error H3_EXPORT(cellToCenterChild)(H3Index h, int childRes,
(* error
DECLSPEC H3Error H3_EXPORT(cellToCenterChild)(H3Index h, int childRes,
(* error
                                              H3Index *child);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup compactCells compactCells
     * Functions for compactCells
     * @
      }
    {* @brief compacts the given set of hexagons as best as possible  }
(* error
DECLSPEC H3Error H3_EXPORT(compactCells)(const H3Index *h3Set,
(* error
                                         H3Index *compactedSet,
(* error
                                         const int64_t numHexes);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup uncompactCells uncompactCells
     * Functions for uncompactCells
     * @
      }
    {* @brief determines the exact number of hexagons that will be uncompacted
     * from the compacted set  }
(* error
DECLSPEC H3Error H3_EXPORT(uncompactCellsSize)(const H3Index *compactedSet,
(* error
                                               const int64_t numCompacted,
(* error
                                               const int res, int64_t *out);
(* error
                                               const int res, int64_t *out);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @brief uncompacts the compacted hexagon set  }
(* error
DECLSPEC H3Error H3_EXPORT(uncompactCells)(const H3Index *compactedSet,
(* error
                                           const int64_t numCompacted,
(* error
                                           H3Index *outSet,
(* error
                                           const int64_t numOut, const int res);
(* error
                                           const int64_t numOut, const int res);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup isResClassIII isResClassIII
     * Functions for isResClassIII
     * @
      }
    {* @brief determines if a hexagon is Class III (or Class II)  }
(* error
DECLSPEC int H3_EXPORT(isResClassIII)(H3Index h);
in declaration at line 569 *)
    {* @  }
    {* @defgroup isPentagon isPentagon
     * Functions for isPentagon
     * @
      }
    {* @brief determines if an H3 cell is a pentagon  }
(* error
DECLSPEC int H3_EXPORT(isPentagon)(H3Index h);
in declaration at line 577 *)
    {* @  }
    {* @defgroup getIcosahedronFaces getIcosahedronFaces
     * Functions for getIcosahedronFaces
     * @
      }
    {* @brief Max number of icosahedron faces intersected by an index  }
(* error
DECLSPEC H3Error H3_EXPORT(maxFaceCount)(H3Index h3, int *out);
(* error
DECLSPEC H3Error H3_EXPORT(maxFaceCount)(H3Index h3, int *out);
 in declarator_list *)
 in declarator_list *)
    {* @brief Find all icosahedron faces intersected by a given H3 index  }
(* error
DECLSPEC H3Error H3_EXPORT(getIcosahedronFaces)(H3Index h3, int *out);
(* error
DECLSPEC H3Error H3_EXPORT(getIcosahedronFaces)(H3Index h3, int *out);
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup areNeighborCells areNeighborCells
     * Functions for areNeighborCells
     * @
      }
    {* @brief returns whether or not the provided hexagons border  }
(* error
DECLSPEC H3Error H3_EXPORT(areNeighborCells)(H3Index origin,
(* error
                                             H3Index destination, int *out);
(* error
                                             H3Index destination, int *out);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup cellsToDirectedEdge cellsToDirectedEdge
     * Functions for cellsToDirectedEdge
     * @
      }
    {* @brief returns the directed edge H3Index for the specified origin and
     * destination  }
(* error
DECLSPEC H3Error H3_EXPORT(cellsToDirectedEdge)(H3Index origin,
(* error
                                                H3Index destination,
(* error
                                                H3Index *out);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup isValidDirectedEdge isValidDirectedEdge
     * Functions for isValidDirectedEdge
     * @
      }
    {* @brief returns whether the H3Index is a valid directed edge  }
(* error
DECLSPEC int H3_EXPORT(isValidDirectedEdge)(H3Index edge);
in declaration at line 616 *)
    {* @  }
    {* @defgroup getDirectedEdgeOrigin \
     * getDirectedEdgeOrigin
     * Functions for getDirectedEdgeOrigin
     * @
      }
    {* @brief Returns the origin hexagon H3Index from the directed edge
     * H3Index  }
(* error
DECLSPEC H3Error H3_EXPORT(getDirectedEdgeOrigin)(H3Index edge, H3Index *out);
(* error
DECLSPEC H3Error H3_EXPORT(getDirectedEdgeOrigin)(H3Index edge, H3Index *out);
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup getDirectedEdgeDestination \
     * getDirectedEdgeDestination
     * Functions for getDirectedEdgeDestination
     * @
      }
    {* @brief Returns the destination hexagon H3Index from the directed edge
     * H3Index  }
(* error
DECLSPEC H3Error H3_EXPORT(getDirectedEdgeDestination)(H3Index edge,
(* error
                                                       H3Index *out);
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup directedEdgeToCells \
     * directedEdgeToCells
     * Functions for directedEdgeToCells
     * @
      }
    {* @brief Returns the origin and destination hexagons from the directed
     * edge H3Index  }
(* error
DECLSPEC H3Error H3_EXPORT(directedEdgeToCells)(H3Index edge,
(* error
                                                H3Index *originDestination);
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup originToDirectedEdges \
     * originToDirectedEdges
     * Functions for originToDirectedEdges
     * @
      }
    {* @brief Returns the 6 (or 5 for pentagons) edges associated with the H3Index
      }
(* error
DECLSPEC H3Error H3_EXPORT(originToDirectedEdges)(H3Index origin,
(* error
                                                  H3Index *edges);
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup directedEdgeToBoundary directedEdgeToBoundary
     * Functions for directedEdgeToBoundary
     * @
      }
    {* @brief Returns the CellBoundary containing the coordinates of the edge  }
(* error
DECLSPEC H3Error H3_EXPORT(directedEdgeToBoundary)(H3Index edge,
(* error
                                                   CellBoundary *gb);
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup cellToVertex cellToVertex
     * Functions for cellToVertex
     * @
      }
    {* @brief Returns a single vertex for a given cell, as an H3 index  }
(* error
DECLSPEC H3Error H3_EXPORT(cellToVertex)(H3Index origin, int vertexNum,
(* error
DECLSPEC H3Error H3_EXPORT(cellToVertex)(H3Index origin, int vertexNum,
(* error
                                         H3Index *out);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup cellToVertexes cellToVertexes
     * Functions for cellToVertexes
     * @
      }
    {* @brief Returns all vertexes for a given cell, as H3 indexes  }
(* error
DECLSPEC H3Error H3_EXPORT(cellToVertexes)(H3Index origin, H3Index *vertexes);
(* error
DECLSPEC H3Error H3_EXPORT(cellToVertexes)(H3Index origin, H3Index *vertexes);
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup vertexToLatLng vertexToLatLng
     * Functions for vertexToLatLng
     * @
      }
    {* @brief Returns a single vertex for a given cell, as an H3 index  }
(* error
DECLSPEC H3Error H3_EXPORT(vertexToLatLng)(H3Index vertex, LatLng *point);
(* error
DECLSPEC H3Error H3_EXPORT(vertexToLatLng)(H3Index vertex, LatLng *point);
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup isValidVertex isValidVertex
     * Functions for isValidVertex
     * @
      }
    {* @brief Whether the input is a valid H3 vertex  }
(* error
DECLSPEC int H3_EXPORT(isValidVertex)(H3Index vertex);
in declaration at line 701 *)
    {* @  }
    {* @defgroup gridDistance gridDistance
     * Functions for gridDistance
     * @
      }
    {* @brief Returns grid distance between two indexes  }
(* error
DECLSPEC H3Error H3_EXPORT(gridDistance)(H3Index origin, H3Index h3,
(* error
DECLSPEC H3Error H3_EXPORT(gridDistance)(H3Index origin, H3Index h3,
(* error
                                         int64_t *distance);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup gridPathCells gridPathCells
     * Functions for gridPathCells
     * @
      }
    {* @brief Number of indexes in a line connecting two indexes  }
(* error
DECLSPEC H3Error H3_EXPORT(gridPathCellsSize)(H3Index start, H3Index end,
(* error
DECLSPEC H3Error H3_EXPORT(gridPathCellsSize)(H3Index start, H3Index end,
(* error
                                              int64_t *size);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @brief Line of h3 indexes connecting two indexes  }
(* error
DECLSPEC H3Error H3_EXPORT(gridPathCells)(H3Index start, H3Index end,
(* error
DECLSPEC H3Error H3_EXPORT(gridPathCells)(H3Index start, H3Index end,
(* error
                                          H3Index *out);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup cellToLocalIj cellToLocalIj
     * Functions for cellToLocalIj
     * @
      }
    {* @brief Returns two dimensional coordinates for the given index  }
(* error
DECLSPEC H3Error H3_EXPORT(cellToLocalIj)(H3Index origin, H3Index h3,
(* error
DECLSPEC H3Error H3_EXPORT(cellToLocalIj)(H3Index origin, H3Index h3,
(* error
                                          uint32_t mode, CoordIJ *out);
(* error
                                          uint32_t mode, CoordIJ *out);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @  }
    {* @defgroup localIjToCell localIjToCell
     * Functions for localIjToCell
     * @
      }
    {* @brief Returns index for the given two dimensional coordinates  }
(* error
DECLSPEC H3Error H3_EXPORT(localIjToCell)(H3Index origin, const CoordIJ *ij,
(* error
DECLSPEC H3Error H3_EXPORT(localIjToCell)(H3Index origin, const CoordIJ *ij,
(* error
                                          uint32_t mode, H3Index *out);
(* error
                                          uint32_t mode, H3Index *out);
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
 in declarator_list *)
    {* @  }
{$endif}

implementation

    { was #define dname(params) para_def_expr }
    { argument types are unknown }
    { return type might be wrong }
    function TJOIN(a,b : longint) : longint;
    begin
      TJOIN:=XTJOIN(a,b);
    end;

    { was #define dname(params) para_def_expr }
    { argument types are unknown }
    { return type might be wrong }
    function H3_EXPORT(name : longint) : longint;
    begin
      H3_EXPORT:=TJOIN(H3_PREFIX,name);
    end;

    { was #define dname(params) para_def_expr }
    { argument types are unknown }
    { return type might be wrong }
    function H3_EXPORT(name : longint) : longint;
    begin
      H3_EXPORT:=name;
    end;

    { was #define dname def_expr }
    function DECLSPEC : longint; { return type might be wrong }
      begin
        DECLSPEC:=__declspec(dllexport);
      end;

    { was #define dname def_expr }
    function DECLSPEC : longint; { return type might be wrong }
      begin
        DECLSPEC:=__declspec(dllimport);
      end;


end.

Bye,
  Skybuck.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20220731/d8672f7d/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ConversionAttemptVersion001.zip
Type: application/zip
Size: 95888 bytes
Desc: ConversionAttemptVersion001.zip
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20220731/d8672f7d/attachment-0001.zip>


More information about the fpc-pascal mailing list