diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml
index 1650636..520891c 100644
--- a/.github/workflows/build-and-test.yml
+++ b/.github/workflows/build-and-test.yml
@@ -6,8 +6,8 @@ jobs:
strategy:
matrix:
- php: [ '8.1', '8.2', '8.3' ]
- h3: [ '3.7.2' ]
+ php: [ '8.1', '8.2', '8.3', '8.4', '8.5' ]
+ h3: [ '4.2.1' ]
steps:
- name: Checkout
@@ -20,6 +20,11 @@ jobs:
ref: v${{ matrix.h3 }}
path: h3-lib
+ - name: Install dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y cmake make gcc g++
+
- name: Build H3 lib
working-directory: h3-lib
run: |
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..643b23e
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,82 @@
+name: Release
+
+on:
+ release:
+ types: [created]
+
+jobs:
+ build:
+ strategy:
+ matrix:
+ php: [ '8.1', '8.2', '8.3', '8.4', '8.5' ]
+ h3: [ '4.2.1' ]
+ os: [ ubuntu-latest, macos-latest ]
+
+ runs-on: ${{ matrix.os }}
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+
+ - name: Checkout H3 lib
+ uses: actions/checkout@v3
+ with:
+ repository: uber/h3
+ ref: v${{ matrix.h3 }}
+ path: h3-lib
+
+ - name: Install dependencies (Linux)
+ if: runner.os == 'Linux'
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y cmake make gcc g++
+
+ - name: Install dependencies (macOS)
+ if: runner.os == 'macOS'
+ run: |
+ brew install cmake
+
+ - name: Build H3 lib
+ working-directory: h3-lib
+ run: |
+ cmake -DBUILD_SHARED_LIBS=ON .
+ make
+ sudo make install
+
+ - name: Fix shared library cache (Linux)
+ if: runner.os == 'Linux'
+ run: sudo ldconfig
+
+ - name: Setup PHP
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+
+ - name: Build extension
+ run: |
+ phpize
+ ./configure --with-h3
+ make
+ sudo make install
+
+ - name: Run tests
+ run: |
+ export NO_INTERACTION=1
+ export REPORT_EXIT_STATUS=1
+ export TEST_PHP_EXECUTABLE=$(which php)
+ php run-tests.php --show-diff -d extension=h3.so ./tests/*.phpt
+
+ - name: Prepare release asset
+ run: |
+ if [ "${{ runner.os }}" = "Linux" ]; then
+ cp modules/h3.so "h3-php${{ matrix.php }}-linux-$(uname -m).so"
+ else
+ cp modules/h3.so "h3-php${{ matrix.php }}-macos-$(uname -m).so"
+ fi
+
+ - name: Upload release asset
+ uses: softprops/action-gh-release@v2
+ with:
+ files: h3-php${{ matrix.php }}-*
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/README.md b/README.md
index fe7d7bf..809e5bd 100644
--- a/README.md
+++ b/README.md
@@ -5,14 +5,14 @@ PHP extension that implements [H3 library](https://github.com/uber/h3) bindings
# Requirements
* PHP: `^8.1`
-* H3 Library: `^3.7.2`
+* H3 Library: `^4.0`
# Examples
```php
getResolution(); // 8
$kRing = $h3->kRing(k: 3); // H3Index[]
@@ -42,7 +42,7 @@ $edgeLength = edge_length(res: 8, unit: H3_LENGTH_UNIT_M); // 461.3546837
```bash
git clone https://github.com/uber/h3.git
cd h3
-git checkout v3.7.2
+git checkout v4.2.1
cmake -DBUILD_SHARED_LIBS=ON .
make -j "$(nproc)"
sudo make install
@@ -62,94 +62,94 @@ sudo make install
# Binding table
## Indexing
-| C | PHP |
-|-------------------|-----------------------------|
-| geoToH3() | H3\H3Index::fromGeo() |
-| h3ToGeo() | H3\H3Index::toGeo() |
-| h3ToGeoBoundary() | H3\H3Index::toGeoBoundary() |
+| C | PHP |
+|--------------------|-----------------------------|
+| latLngToCell() | H3\H3Index::fromGeo() |
+| cellToLatLng() | H3\H3Index::toGeo() |
+| cellToBoundary() | H3\H3Index::toGeoBoundary() |
## Inspection
-| C | PHP |
-|-------------------|-----------------------------|
-| h3GetResolution() | H3\H3Index::getResolution() |
-| h3GetBaseCell() | H3\H3Index::getBaseCell() |
-| stringToH3() | H3\H3Index::fromString() |
-| h3ToString() | H3\H3Index::toString() |
-| h3IsValid() | H3\H3Index::isValid() |
-| h3IsResClassIII() | H3\H3Index::isResClassIII() |
-| h3IsPentagon() | H3\H3Index::isPentagon() |
-| h3GetFaces() | H3\H3Index::getFaces() |
-| maxFaceCount() | - |
+| C | PHP |
+|----------------------|-----------------------------|
+| getResolution() | H3\H3Index::getResolution() |
+| getBaseCellNumber() | H3\H3Index::getBaseCell() |
+| stringToH3() | H3\H3Index::fromString() |
+| h3ToString() | H3\H3Index::toString() |
+| isValidCell() | H3\H3Index::isValid() |
+| isResClassIII() | H3\H3Index::isResClassIII() |
+| isPentagon() | H3\H3Index::isPentagon() |
+| getIcosahedronFaces()| H3\H3Index::getFaces() |
+| maxFaceCount() | - |
## Traversal
-| C | PHP |
-|---------------------------|-----------------------------------------------|
-| kRing() | H3\H3Index::kRing() |
-| maxKringSize() | - |
-| kRingDistances() | H3\H3Index::kRingDistances() |
-| hexRange() | H3\H3Index::hexRange() |
-| hexRangeDistances() | H3\H3Index::hexRangeDistances() |
-| hexRanges() | H3\H3Index::hexRanges() |
-| hexRing() | H3\H3Index::hexRing() |
-| h3Line() | H3\line()
H3\H3Index::getLineTo() |
-| h3LineSize() | - |
-| h3Distance() | H3\distance()
H3\H3Index::getDistanceTo() |
-| experimentalH3ToLocalIj() | H3\experimental_h3_to_local_ij |
-| experimentalLocalIjToH3() | H3\experimental_local_ij_to_h3 |
+| C | PHP |
+|----------------------|-----------------------------------------------|
+| gridDisk() | H3\H3Index::kRing() |
+| maxGridDiskSize() | - |
+| gridDiskDistances() | H3\H3Index::kRingDistances() |
+| gridDiskUnsafe() | H3\H3Index::hexRange() |
+| gridDiskDistancesUnsafe() | H3\H3Index::hexRangeDistances() |
+| gridRingUnsafe() | H3\H3Index::hexRing() |
+| gridPathCells() | H3\line()
H3\H3Index::getLineTo() |
+| gridPathCellsSize() | - |
+| gridDistance() | H3\distance()
H3\H3Index::getDistanceTo() |
+| cellToLocalIj() | H3\experimental_h3_to_local_ij |
+| localIjToCell() | H3\experimental_local_ij_to_h3 |
## Hierarchy
-| C | PHP |
-|-----------------------|-----------------------------|
-| h3ToParent() | H3\H3Index::toParent() |
-| h3ToChildren() | H3\H3Index::toChildren() |
-| maxH3ToChildrenSize() | - |
-| h3ToCenterChild() | H3\H3Index::toCenterChild() |
-| compact() | H3\compact() |
-| uncompact() | H3\uncompact() |
-| maxUncompactSize() | - |
+| C | PHP |
+|----------------------|-----------------------------|
+| cellToParent() | H3\H3Index::toParent() |
+| cellToChildren() | H3\H3Index::toChildren() |
+| cellToChildrenSize() | - |
+| cellToCenterChild() | H3\H3Index::toCenterChild() |
+| compactCells() | H3\compact() |
+| uncompactCells() | H3\uncompact() |
+| uncompactCellsSize() | - |
## Regions
-| C | PHP |
-|------------------------|------------------------------|
-| polyfill() | H3\polyfill() |
-| maxPolyfillSize() | - |
-| h3SetToLinkedGeo() | H3\h3_set_to_multi_polygon() |
-| destroyLinkedPolygon() | - |
-
-## Unidirectional edges
-| C | PHP |
-|-----------------------------------------------|---------------------------------------------------------|
-| h3IndexesAreNeighbors() | H3\indexes_are_neighbors
H3\H3Index::isNeighborTo() |
-| getH3UnidirectionalEdge() | H3\H3Index::getUnidirectionalEdge() |
-| h3UnidirectionalEdgeIsValid() | H3\UniEdge::isValid() |
-| getOriginH3IndexFromUnidirectionalEdge() | H3\UniEdge::getOrigin() |
-| getDestinationH3IndexFromUnidirectionalEdge() | H3\UniEdge::getDestination() |
-| getH3IndexesFromUnidirectionalEdge() | H3\UniEdge::getIndexes() |
-| getH3UnidirectionalEdgesFromHexagon() | H3\H3Index::getUnidirectionalEdges() |
-| getH3UnidirectionalEdgeBoundary() | H3\UniEdge::getBoundary() |
+| C | PHP |
+|------------------------------|------------------------------|
+| polygonToCells() | H3\polyfill() |
+| maxPolygonToCellsSize() | - |
+| cellsToLinkedMultiPolygon() | H3\h3_set_to_multi_polygon() |
+| destroyLinkedMultiPolygon() | - |
+
+## Directed edges
+| C | PHP |
+|-------------------------------|--------------------------------------------------------------|
+| areNeighborCells() | H3\indexes_are_neighbors
H3\H3Index::isNeighborTo() |
+| cellsToDirectedEdge() | H3\H3Index::getDirectedEdge() |
+| isValidDirectedEdge() | H3\H3DirectedEdge::isValid() |
+| getDirectedEdgeOrigin() | H3\H3DirectedEdge::getOrigin() |
+| getDirectedEdgeDestination() | H3\H3DirectedEdge::getDestination() |
+| directedEdgeToCells() | H3\H3DirectedEdge::getIndexes() |
+| originToDirectedEdges() | H3\H3Index::getDirectedEdges() |
+| directedEdgeToBoundary() | H3\H3DirectedEdge::getBoundary() |
## Miscellaneous
-| C | PHP |
-|-----------------------|---------------------------|
-| degsToRads() | H3\degs_to_rads() |
-| radsToDegs() | H3\rads_to_degs() |
-| hexAreaKm2() | H3\hex_area() |
-| hexAreaM2() | H3\hex_area() |
-| cellAreaM2() | H3\H3Index::getCellArea() |
-| cellAreaRads2() | H3\H3Index::getCellArea() |
-| edgeLengthKm() | H3\edge_length() |
-| edgeLengthM() | H3\edge_length() |
-| exactEdgeLengthKm() | H3\UniEdge::getLength() |
-| exactEdgeLengthM() | H3\UniEdge::getLength() |
-| exactEdgeLengthRads() | H3\UniEdge::getLength() |
-| numHexagons() | H3\num_hexagons() |
-| getRes0Indexes() | H3\get_res0_indexes() |
-| res0IndexCount() | - |
-| getPentagonIndexes() | H3\get_pentagon_indexes() |
-| pentagonIndexCount() | - |
-| pointDistKm() | H3\point_dist() |
-| pointDistM() | H3\point_dist() |
-| pointDistRads() | H3\point_dist() |
+| C | PHP |
+|------------------------------|----------------------------------|
+| degsToRads() | H3\degs_to_rads() |
+| radsToDegs() | H3\rads_to_degs() |
+| getHexagonAreaAvgKm2() | H3\hex_area() |
+| getHexagonAreaAvgM2() | H3\hex_area() |
+| cellAreaKm2() | H3\H3Index::getCellArea() |
+| cellAreaM2() | H3\H3Index::getCellArea() |
+| cellAreaRads2() | H3\H3Index::getCellArea() |
+| getHexagonEdgeLengthAvgKm() | H3\edge_length() |
+| getHexagonEdgeLengthAvgM() | H3\edge_length() |
+| edgeLengthKm() | H3\H3DirectedEdge::getLength() |
+| edgeLengthM() | H3\H3DirectedEdge::getLength() |
+| edgeLengthRads() | H3\H3DirectedEdge::getLength() |
+| getNumCells() | H3\num_hexagons() |
+| getRes0Cells() | H3\get_res0_indexes() |
+| res0CellCount() | - |
+| getPentagons() | H3\get_pentagon_indexes() |
+| pentagonCount() | - |
+| greatCircleDistanceKm() | H3\point_dist() |
+| greatCircleDistanceM() | H3\point_dist() |
+| greatCircleDistanceRads() | H3\point_dist() |
# License
diff --git a/config.m4 b/config.m4
index c3cf521..1be7c4d 100644
--- a/config.m4
+++ b/config.m4
@@ -27,10 +27,10 @@ if test "$PHP_H3" != "no"; then
AC_MSG_ERROR([Could not find $SEARCH_FOR])
fi
- PHP_ADD_INCLUDE($LIBH3_DIR/include/h3)
+ PHP_ADD_INCLUDE($LIBH3_DIR/include)
LIBNAME=h3
- LIBSYMBOL=geoToH3
+ LIBSYMBOL=latLngToCell
PHP_CHECK_LIBRARY($LIBNAME, $LIBSYMBOL,
[
diff --git a/h3.c b/h3.c
index e6af0dc..ad31554 100644
--- a/h3.c
+++ b/h3.c
@@ -46,26 +46,26 @@ ZEND_DECLARE_MODULE_GLOBALS(h3)
}
#define VALIDATE_H3_INDEX(index) \
- if (H3_G(validate_index) && !h3IsValid(index)) { \
+ if (H3_G(validate_index) && !isValidCell(index)) { \
H3_THROW("Invalid H3 index", H3_ERR_CODE_INVALID_INDEX); \
RETURN_THROWS(); \
}
#define VALIDATE_H3_UNI_EDGE(index) \
- if (H3_G(validate_index) && !h3UnidirectionalEdgeIsValid(index)) { \
+ if (H3_G(validate_index) && !isValidDirectedEdge(index)) { \
H3_THROW("Invalid H3 unidirectional edge", H3_ERR_CODE_INVALID_INDEX); \
RETURN_THROWS(); \
}
#define OBJ_IS_A(val, ce) (Z_TYPE_P(val) == IS_OBJECT && instanceof_function(Z_OBJCE_P(val), ce))
-typedef H3Index H3UniEdge;
+typedef H3Index H3DirectedEdge;
zend_class_entry *H3_H3Exception_ce;
zend_class_entry *H3_H3Index_ce;
-zend_class_entry *H3_H3UniEdge_ce;
-zend_class_entry *H3_GeoCoord_ce;
-zend_class_entry *H3_GeoBoundary_ce;
+zend_class_entry *H3_H3DirectedEdge_ce;
+zend_class_entry *H3_LatLng_ce;
+zend_class_entry *H3_CellBoundary_ce;
zend_class_entry *H3_GeoPolygon_ce;
zend_class_entry *H3_GeoMultiPolygon_ce;
zend_class_entry *H3_CoordIJ_ce;
@@ -94,9 +94,9 @@ zend_object *h3_to_obj(H3Index index)
return obj;
}
-void h3_array_to_zend_array(H3Index *in, int size, zval *out)
+void h3_array_to_zend_array(H3Index *in, int64_t size, zval *out)
{
- for (int i = 0; i < size; i++) {
+ for (int64_t i = 0; i < size; i++) {
if (in[i] != H3_INVALID_INDEX) {
add_next_index_object(out, h3_to_obj(in[i]));
}
@@ -121,57 +121,57 @@ int zend_array_to_h3_array(zend_array *arr, H3Index *out)
return 0;
}
-H3UniEdge obj_to_h3ue(zend_object *obj)
+H3DirectedEdge obj_to_h3de(zend_object *obj)
{
zval *prop;
zval rv;
- prop = zend_read_property(H3_H3UniEdge_ce, obj, "index", sizeof("index") - 1, 1, &rv);
+ prop = zend_read_property(H3_H3DirectedEdge_ce, obj, "index", sizeof("index") - 1, 1, &rv);
return zval_get_long(prop);
}
-zend_object *h3ue_to_obj(H3UniEdge index)
+zend_object *h3de_to_obj(H3DirectedEdge index)
{
- zend_object *obj = zend_objects_new(H3_H3UniEdge_ce);
- object_properties_init(obj, H3_H3UniEdge_ce);
- zend_update_property_long(H3_H3UniEdge_ce, obj, "index", sizeof("index") - 1, index);
+ zend_object *obj = zend_objects_new(H3_H3DirectedEdge_ce);
+ object_properties_init(obj, H3_H3DirectedEdge_ce);
+ zend_update_property_long(H3_H3DirectedEdge_ce, obj, "index", sizeof("index") - 1, index);
return obj;
}
-void h3ue_array_to_zend_array(H3UniEdge *in, int size, zval *out)
+void h3de_array_to_zend_array(H3DirectedEdge *in, int size, zval *out)
{
for (int i = 0; i < size; i++) {
if (in[i] != H3_INVALID_INDEX) {
- add_next_index_object(out, h3ue_to_obj(in[i]));
+ add_next_index_object(out, h3de_to_obj(in[i]));
}
}
}
-void obj_to_geo(zend_object *obj, GeoCoord *geo)
+void obj_to_geo(zend_object *obj, LatLng *geo)
{
zval *prop;
zval rv;
- prop = zend_read_property(H3_GeoCoord_ce, obj, "lat", sizeof("lat") - 1, 1, &rv);
+ prop = zend_read_property(H3_LatLng_ce, obj, "lat", sizeof("lat") - 1, 1, &rv);
geo->lat = degsToRads(zval_get_double(prop));
- prop = zend_read_property(H3_GeoCoord_ce, obj, "lon", sizeof("lon") - 1, 1, &rv);
- geo->lon = degsToRads(zval_get_double(prop));
+ prop = zend_read_property(H3_LatLng_ce, obj, "lon", sizeof("lon") - 1, 1, &rv);
+ geo->lng = degsToRads(zval_get_double(prop));
}
-zend_object *geo_to_obj(GeoCoord *geo)
+zend_object *geo_to_obj(LatLng *geo)
{
- zend_object *obj = zend_objects_new(H3_GeoCoord_ce);
- object_properties_init(obj, H3_GeoCoord_ce);
+ zend_object *obj = zend_objects_new(H3_LatLng_ce);
+ object_properties_init(obj, H3_LatLng_ce);
- zend_update_property_double(H3_GeoCoord_ce, obj, "lat", sizeof("lat") - 1, radsToDegs(geo->lat));
- zend_update_property_double(H3_GeoCoord_ce, obj, "lon", sizeof("lon") - 1, radsToDegs(geo->lon));
+ zend_update_property_double(H3_LatLng_ce, obj, "lat", sizeof("lat") - 1, radsToDegs(geo->lat));
+ zend_update_property_double(H3_LatLng_ce, obj, "lon", sizeof("lon") - 1, radsToDegs(geo->lng));
return obj;
}
-zend_object *geo_boundary_to_obj(GeoBoundary *boundary)
+zend_object *geo_boundary_to_obj(CellBoundary *boundary)
{
zval val;
array_init_size(&val, boundary->numVerts);
@@ -180,24 +180,24 @@ zend_object *geo_boundary_to_obj(GeoBoundary *boundary)
add_next_index_object(&val, geo_to_obj(&boundary->verts[i]));
}
- zend_object *obj = zend_objects_new(H3_GeoBoundary_ce);
- object_properties_init(obj, H3_GeoBoundary_ce);
+ zend_object *obj = zend_objects_new(H3_CellBoundary_ce);
+ object_properties_init(obj, H3_CellBoundary_ce);
- zend_update_property(H3_GeoBoundary_ce, obj, "vertices", sizeof("vertices") - 1, &val);
+ zend_update_property(H3_CellBoundary_ce, obj, "vertices", sizeof("vertices") - 1, &val);
zval_ptr_dtor(&val);
return obj;
}
-int zend_array_to_geocoord_array(zend_array *arr, GeoCoord *out)
+int zend_array_to_geocoord_array(zend_array *arr, LatLng *out)
{
int idx = 0;
zval *val;
ZEND_HASH_FOREACH_VAL(arr, val)
{
- if (OBJ_IS_A(val, H3_GeoCoord_ce)) {
+ if (OBJ_IS_A(val, H3_LatLng_ce)) {
obj_to_geo(Z_OBJ_P(val), &out[idx++]);
} else {
return -1;
@@ -208,7 +208,7 @@ int zend_array_to_geocoord_array(zend_array *arr, GeoCoord *out)
return 0;
}
-int obj_to_geofence(zend_object *obj, Geofence *out)
+int obj_to_geoloop(zend_object *obj, GeoLoop *out)
{
zval *prop;
zval rv;
@@ -216,15 +216,15 @@ int obj_to_geofence(zend_object *obj, Geofence *out)
int idx = 0;
zval *val;
- prop = zend_read_property(H3_GeoBoundary_ce, obj, "vertices", sizeof("vertices") - 1, 1, &rv);
+ prop = zend_read_property(H3_CellBoundary_ce, obj, "vertices", sizeof("vertices") - 1, 1, &rv);
arr = Z_ARR_P(prop);
uint32_t num_verts = zend_array_count(arr);
- GeoCoord *verts = ecalloc(num_verts, sizeof(GeoCoord));
+ LatLng *verts = ecalloc(num_verts, sizeof(LatLng));
ZEND_HASH_FOREACH_VAL(arr, val)
{
- if (OBJ_IS_A(val, H3_GeoCoord_ce)) {
+ if (OBJ_IS_A(val, H3_LatLng_ce)) {
obj_to_geo(Z_OBJ_P(val), &verts[idx++]);
} else {
efree(verts);
@@ -241,15 +241,15 @@ int obj_to_geofence(zend_object *obj, Geofence *out)
return 0;
}
-int zend_array_to_geofence_array(zend_array *arr, Geofence *out)
+int zend_array_to_geoloop_array(zend_array *arr, GeoLoop *out)
{
int idx = 0;
zval *val;
- Geofence tmp;
+ GeoLoop tmp;
ZEND_HASH_FOREACH_VAL(arr, val)
{
- if (OBJ_IS_A(val, H3_GeoBoundary_ce) && obj_to_geofence(Z_OBJ_P(val), &tmp) == 0) {
+ if (OBJ_IS_A(val, H3_CellBoundary_ce) && obj_to_geoloop(Z_OBJ_P(val), &tmp) == 0) {
out[idx++] = tmp;
} else {
return -1;
@@ -265,15 +265,22 @@ void h3_line(zend_object *start, zend_object *end, INTERNAL_FUNCTION_PARAMETERS)
H3Index startIndex = obj_to_h3(start);
H3Index endIndex = obj_to_h3(end);
- int size = h3LineSize(startIndex, endIndex);
+ int64_t size;
+ H3Error err = gridPathCellsSize(startIndex, endIndex, &size);
- if (size < 0) {
- H3_THROW("Failed to caluclate line size", H3_ERR_CODE_LINE_SIZE_ERROR);
+ if (err) {
+ H3_THROW("Failed to calculate line size", H3_ERR_CODE_LINE_SIZE_ERROR);
RETURN_THROWS();
}
H3Index *out = ecalloc(size, sizeof(H3Index));
- h3Line(startIndex, endIndex, out);
+ err = gridPathCells(startIndex, endIndex, out);
+
+ if (err) {
+ H3_THROW("Failed to calculate line", H3_ERR_CODE_LINE_SIZE_ERROR);
+ efree(out);
+ RETURN_THROWS();
+ }
array_init(return_value);
h3_array_to_zend_array(out, size, return_value);
@@ -293,7 +300,7 @@ int geofence_obj_to_geojson_arr(zend_object *geofence_obj, zval *geojson_geofenc
int idx = 0;
uint32_t verts_count;
- prop = zend_read_property(H3_GeoBoundary_ce, geofence_obj, "vertices", sizeof("vertices") - 1, 1, &rv);
+ prop = zend_read_property(H3_CellBoundary_ce, geofence_obj, "vertices", sizeof("vertices") - 1, 1, &rv);
geofence_verts_arr = Z_ARRVAL_P(prop);
verts_count = zend_array_count(geofence_verts_arr);
@@ -305,12 +312,12 @@ int geofence_obj_to_geojson_arr(zend_object *geofence_obj, zval *geojson_geofenc
ZEND_HASH_FOREACH_VAL(geofence_verts_arr, geofence_vert_val)
{
- if (Z_TYPE_P(geofence_vert_val) == IS_OBJECT && OBJ_IS_A(geofence_vert_val, H3_GeoCoord_ce)) {
+ if (Z_TYPE_P(geofence_vert_val) == IS_OBJECT && OBJ_IS_A(geofence_vert_val, H3_LatLng_ce)) {
coord_obj = Z_OBJ_P(geofence_vert_val);
array_init_size(&coords_val, 2);
- prop = zend_read_property(H3_GeoCoord_ce, coord_obj, "lon", sizeof("lon") - 1, 1, &rv);
+ prop = zend_read_property(H3_LatLng_ce, coord_obj, "lon", sizeof("lon") - 1, 1, &rv);
add_next_index_double(&coords_val, Z_DVAL_P(prop));
- prop = zend_read_property(H3_GeoCoord_ce, coord_obj, "lat", sizeof("lat") - 1, 1, &rv);
+ prop = zend_read_property(H3_LatLng_ce, coord_obj, "lat", sizeof("lat") - 1, 1, &rv);
add_next_index_double(&coords_val, Z_DVAL_P(prop));
add_next_index_zval(geojson_geofence_val, &coords_val);
if (idx++ == 0) {
@@ -368,7 +375,7 @@ int multi_polygon_obj_to_geo_json(zend_object *obj, zval *return_value)
ZEND_HASH_FOREACH_VAL(holes_arr, hole_val)
{
- if (Z_TYPE_P(hole_val) == IS_OBJECT && OBJ_IS_A(hole_val, H3_GeoBoundary_ce)) {
+ if (Z_TYPE_P(hole_val) == IS_OBJECT && OBJ_IS_A(hole_val, H3_CellBoundary_ce)) {
if (geofence_obj_to_geojson_arr(Z_OBJ_P(hole_val), &coords_val) == 0) {
add_next_index_zval(&geojson_polygon_val, &coords_val);
} else {
@@ -394,7 +401,7 @@ int multi_polygon_obj_to_geo_json(zend_object *obj, zval *return_value)
zend_object *geo_loop_to_geo_boundary_obj(LinkedGeoLoop *geo_loop)
{
- LinkedGeoCoord *geo_coord;
+ LinkedLatLng *geo_coord;
zval coords_val;
zend_object *obj;
@@ -406,9 +413,9 @@ zend_object *geo_loop_to_geo_boundary_obj(LinkedGeoLoop *geo_loop)
geo_coord = geo_coord->next;
}
- obj = zend_objects_new(H3_GeoBoundary_ce);
- object_properties_init(obj, H3_GeoBoundary_ce);
- zend_update_property(H3_GeoBoundary_ce, obj, "vertices", sizeof("vertices") - 1, &coords_val);
+ obj = zend_objects_new(H3_CellBoundary_ce);
+ object_properties_init(obj, H3_CellBoundary_ce);
+ zend_update_property(H3_CellBoundary_ce, obj, "vertices", sizeof("vertices") - 1, &coords_val);
Z_TRY_DELREF(coords_val);
@@ -455,11 +462,24 @@ PHP_FUNCTION(hex_area)
VALIDATE_H3_RES(res);
+ double out;
+ H3Error err;
+
switch (unit) {
case H3_AREA_UNIT_KM2:
- RETURN_DOUBLE(hexAreaKm2(res));
+ err = getHexagonAreaAvgKm2(res, &out);
+ if (err) {
+ H3_THROW("Failed to get hex area", H3_ERR_CODE_INVALID_RES);
+ RETURN_THROWS();
+ }
+ RETURN_DOUBLE(out);
case H3_AREA_UNIT_M2:
- RETURN_DOUBLE(hexAreaM2(res));
+ err = getHexagonAreaAvgM2(res, &out);
+ if (err) {
+ H3_THROW("Failed to get hex area", H3_ERR_CODE_INVALID_RES);
+ RETURN_THROWS();
+ }
+ RETURN_DOUBLE(out);
default:
H3_THROW("Unsupported unit (must be one of H3_AREA_UNIT_KM2, or H3_AREA_UNIT_M2)",
H3_ERR_CODE_UNSUPPORTED_UNIT);
@@ -481,11 +501,24 @@ PHP_FUNCTION(edge_length)
VALIDATE_H3_RES(res);
+ double out;
+ H3Error err;
+
switch (unit) {
case H3_LENGTH_UNIT_KM:
- RETURN_DOUBLE(edgeLengthKm(res));
+ err = getHexagonEdgeLengthAvgKm(res, &out);
+ if (err) {
+ H3_THROW("Failed to get edge length", H3_ERR_CODE_INVALID_RES);
+ RETURN_THROWS();
+ }
+ RETURN_DOUBLE(out);
case H3_LENGTH_UNIT_M:
- RETURN_DOUBLE(edgeLengthM(res));
+ err = getHexagonEdgeLengthAvgM(res, &out);
+ if (err) {
+ H3_THROW("Failed to get edge length", H3_ERR_CODE_INVALID_RES);
+ RETURN_THROWS();
+ }
+ RETURN_DOUBLE(out);
default:
H3_THROW("Unsupported unit (must be one of H3_LENGTH_UNIT_KM, or H3_LENGTH_UNIT_RADS)",
H3_ERR_CODE_UNSUPPORTED_UNIT);
@@ -505,17 +538,29 @@ PHP_FUNCTION(num_hexagons)
VALIDATE_H3_RES(res);
- RETURN_LONG(numHexagons(res));
+ int64_t out;
+ H3Error err = getNumCells(res, &out);
+ if (err) {
+ H3_THROW("Failed to get number of hexagons", H3_ERR_CODE_INVALID_RES);
+ RETURN_THROWS();
+ }
+
+ RETURN_LONG(out);
}
PHP_FUNCTION(get_res0_indexes)
{
ZEND_PARSE_PARAMETERS_NONE();
- int max = res0IndexCount();
+ int max = res0CellCount();
H3Index *indexes = ecalloc(max, sizeof(H3Index));
- getRes0Indexes(indexes);
+ H3Error err = getRes0Cells(indexes);
+ if (err) {
+ efree(indexes);
+ H3_THROW("Failed to get res0 indexes", 0);
+ RETURN_THROWS();
+ }
array_init_size(return_value, max);
h3_array_to_zend_array(indexes, max, return_value);
@@ -535,10 +580,15 @@ PHP_FUNCTION(get_pentagon_indexes)
VALIDATE_H3_RES(res);
- int max = pentagonIndexCount();
+ int max = pentagonCount();
H3Index *indexes = ecalloc(max, sizeof(H3Index));
- getPentagonIndexes(res, indexes);
+ H3Error err = getPentagons(res, indexes);
+ if (err) {
+ efree(indexes);
+ H3_THROW("Failed to get pentagon indexes", H3_ERR_CODE_INVALID_RES);
+ RETURN_THROWS();
+ }
array_init_size(return_value, max);
h3_array_to_zend_array(indexes, max, return_value);
@@ -554,27 +604,27 @@ PHP_FUNCTION(point_dist)
// clang-format off
ZEND_PARSE_PARAMETERS_START(3, 3)
- Z_PARAM_OBJ_OF_CLASS(a, H3_GeoCoord_ce)
- Z_PARAM_OBJ_OF_CLASS(b, H3_GeoCoord_ce)
+ Z_PARAM_OBJ_OF_CLASS(a, H3_LatLng_ce)
+ Z_PARAM_OBJ_OF_CLASS(b, H3_LatLng_ce)
Z_PARAM_LONG(unit)
ZEND_PARSE_PARAMETERS_END();
// clang-format on
- GeoCoord *geoA = emalloc(sizeof(GeoCoord));
- GeoCoord *geoB = emalloc(sizeof(GeoCoord));
+ LatLng *geoA = emalloc(sizeof(LatLng));
+ LatLng *geoB = emalloc(sizeof(LatLng));
obj_to_geo(a, geoA);
obj_to_geo(b, geoB);
switch (unit) {
case H3_LENGTH_UNIT_KM:
- RETVAL_DOUBLE(pointDistKm(geoA, geoB));
+ RETVAL_DOUBLE(greatCircleDistanceKm(geoA, geoB));
break;
case H3_LENGTH_UNIT_M:
- RETVAL_DOUBLE(pointDistM(geoA, geoB));
+ RETVAL_DOUBLE(greatCircleDistanceM(geoA, geoB));
break;
case H3_LENGTH_UNIT_RADS:
- RETVAL_DOUBLE(pointDistRads(geoA, geoB));
+ RETVAL_DOUBLE(greatCircleDistanceRads(geoA, geoB));
break;
default:
H3_THROW("Unsupported unit (must be one of H3_LENGTH_UNIT_KM, H3_LENGTH_UNIT_M, or H3_LENGTH_UNIT_RADS)",
@@ -613,7 +663,8 @@ PHP_FUNCTION(compact)
RETURN_THROWS();
}
- if (compact(set, compactedSet, count) != 0) {
+ H3Error err = compactCells(set, compactedSet, count);
+ if (err) {
H3_THROW("Failed to compact", H3_ERR_CODE_COMPACT_ERROR);
efree(set);
efree(compactedSet);
@@ -651,9 +702,10 @@ PHP_FUNCTION(uncompact)
RETURN_THROWS();
}
- int max = maxUncompactSize(compactedSet, count, res);
+ int64_t max;
+ H3Error err = uncompactCellsSize(compactedSet, count, res, &max);
- if (max < 0) {
+ if (err) {
H3_THROW("Unknown uncompact error", H3_ERR_CODE_UNCOMPACT_ERROR);
efree(compactedSet);
RETURN_THROWS();
@@ -661,7 +713,8 @@ PHP_FUNCTION(uncompact)
H3Index *set = ecalloc(max, sizeof(H3Index));
- if (uncompact(compactedSet, count, set, max, res) != 0) {
+ err = uncompactCells(compactedSet, count, set, max, res);
+ if (err) {
H3_THROW("Failed to uncompact", H3_ERR_CODE_UNCOMPACT_ERROR);
efree(compactedSet);
efree(set);
@@ -702,7 +755,14 @@ PHP_FUNCTION(distance)
ZEND_PARSE_PARAMETERS_END();
// clang-format on
- RETURN_LONG(h3Distance(obj_to_h3(a), obj_to_h3(b)));
+ int64_t dist;
+ H3Error err = gridDistance(obj_to_h3(a), obj_to_h3(b), &dist);
+ if (err) {
+ H3_THROW("Failed to calculate distance", 0);
+ RETURN_THROWS();
+ }
+
+ RETURN_LONG(dist);
}
PHP_FUNCTION(indexes_are_neighbors)
@@ -720,7 +780,14 @@ PHP_FUNCTION(indexes_are_neighbors)
H3Index origin = obj_to_h3(org);
H3Index destination = obj_to_h3(dest);
- RETURN_BOOL(h3IndexesAreNeighbors(origin, destination));
+ int out;
+ H3Error err = areNeighborCells(origin, destination, &out);
+ if (err) {
+ H3_THROW("Failed to check neighbors", 0);
+ RETURN_THROWS();
+ }
+
+ RETURN_BOOL(out);
}
PHP_FUNCTION(polyfill)
@@ -748,11 +815,11 @@ PHP_FUNCTION(polyfill)
geofence_val = zend_read_property(H3_GeoPolygon_ce, polygon, "geofence", sizeof("geofence") - 1, 1, &rv);
geofence_obj = Z_OBJ_P(geofence_val);
- geofence_verts_val = zend_read_property(H3_GeoBoundary_ce, geofence_obj, "vertices", sizeof("vertices") - 1, 1, &rv);
+ geofence_verts_val = zend_read_property(H3_CellBoundary_ce, geofence_obj, "vertices", sizeof("vertices") - 1, 1, &rv);
geofence_verts_arr = Z_ARR_P(geofence_verts_val);
uint32_t geofence_num_verts = zend_array_count(geofence_verts_arr);
- GeoCoord *geofence_verts = ecalloc(geofence_num_verts, sizeof(GeoCoord));
+ LatLng *geofence_verts = ecalloc(geofence_num_verts, sizeof(LatLng));
if (zend_array_to_geocoord_array(geofence_verts_arr, geofence_verts) != 0) {
zend_argument_error(H3_H3Exception_ce, 1, "must be valid GeoPolygon object");
@@ -764,9 +831,9 @@ PHP_FUNCTION(polyfill)
holes_arr = Z_ARR_P(holes_val);
uint32_t num_holes = zend_array_count(holes_arr);
- Geofence *holes = ecalloc(num_holes, sizeof(Geofence));
+ GeoLoop *holes = ecalloc(num_holes, sizeof(GeoLoop));
- if (zend_array_to_geofence_array(holes_arr, holes) != 0) {
+ if (zend_array_to_geoloop_array(holes_arr, holes) != 0) {
zend_argument_error(H3_H3Exception_ce, 1, "must be valid GeoPolygon object");
efree(geofence_verts);
efree(holes);
@@ -774,7 +841,7 @@ PHP_FUNCTION(polyfill)
}
GeoPolygon geo_polygon = {
- .geofence = {
+ .geoloop = {
.numVerts = geofence_num_verts,
.verts = geofence_verts,
},
@@ -782,9 +849,24 @@ PHP_FUNCTION(polyfill)
.holes = holes,
};
- int max = maxPolyfillSize(&geo_polygon, res);
+ int64_t max;
+ H3Error err = maxPolygonToCellsSize(&geo_polygon, res, 0, &max);
+ if (err) {
+ efree(geofence_verts);
+ efree(holes);
+ H3_THROW("Failed to calculate polyfill size", 0);
+ RETURN_THROWS();
+ }
+
H3Index *out = ecalloc(max, sizeof(H3Index));
- polyfill(&geo_polygon, res, out);
+ err = polygonToCells(&geo_polygon, res, 0, out);
+ if (err) {
+ efree(geofence_verts);
+ efree(holes);
+ efree(out);
+ H3_THROW("Failed to polyfill", 0);
+ RETURN_THROWS();
+ }
array_init(return_value);
h3_array_to_zend_array(out, max, return_value);
@@ -815,11 +897,17 @@ PHP_FUNCTION(h3_set_to_multi_polygon)
}
LinkedGeoPolygon *out = emalloc(sizeof(LinkedGeoPolygon));
- h3SetToLinkedGeo(set, num_indexes, out);
+ H3Error err = cellsToLinkedMultiPolygon(set, num_indexes, out);
+ if (err) {
+ efree(set);
+ efree(out);
+ H3_THROW("Failed to convert to multi polygon", 0);
+ RETURN_THROWS();
+ }
LinkedGeoPolygon *polygon = out;
LinkedGeoLoop *geo_loop;
- LinkedGeoCoord *geo_coord;
+ LinkedLatLng *geo_coord;
zval polygons_val;
zval holes_val;
@@ -863,7 +951,7 @@ PHP_FUNCTION(h3_set_to_multi_polygon)
object_properties_init(result, H3_GeoMultiPolygon_ce);
zend_update_property(H3_GeoMultiPolygon_ce, result, "polygons", sizeof("polygons") - 1, &polygons_val);
- destroyLinkedPolygon(out);
+ destroyLinkedMultiPolygon(out);
zval_ptr_dtor(&polygons_val);
@@ -886,7 +974,11 @@ PHP_FUNCTION(experimental_h3_to_local_ij)
// clang-format on
CoordIJ ij;
- experimentalH3ToLocalIj(obj_to_h3(origin_obj), obj_to_h3(h_obj), &ij);
+ H3Error err = cellToLocalIj(obj_to_h3(origin_obj), obj_to_h3(h_obj), 0, &ij);
+ if (err) {
+ H3_THROW("Failed to convert to local IJ", 0);
+ RETURN_THROWS();
+ }
zend_object *ij_obj = zend_objects_new(H3_CoordIJ_ce);
object_properties_init(ij_obj, H3_CoordIJ_ce);
@@ -918,7 +1010,11 @@ PHP_FUNCTION(experimental_local_ij_to_h3)
ij.j = Z_LVAL_P(prop);
H3Index result;
- experimentalLocalIjToH3(obj_to_h3(origin_obj), &ij, &result);
+ H3Error err = localIjToCell(obj_to_h3(origin_obj), &ij, 0, &result);
+ if (err) {
+ H3_THROW("Failed to convert from local IJ", 0);
+ RETURN_THROWS();
+ }
RETURN_OBJ(h3_to_obj(result));
}
@@ -967,7 +1063,12 @@ PHP_METHOD(H3_H3Index, fromString)
ZEND_PARSE_PARAMETERS_END();
// clang-format on
- H3Index index = stringToH3(ZSTR_VAL(value));
+ H3Index index;
+ H3Error err = stringToH3(ZSTR_VAL(value), &index);
+ if (err) {
+ H3_THROW("Failed to parse H3 index string", H3_ERR_CODE_INVALID_INDEX);
+ RETURN_THROWS();
+ }
VALIDATE_H3_INDEX(index);
@@ -981,19 +1082,21 @@ PHP_METHOD(H3_H3Index, fromGeo)
// clang-format off
ZEND_PARSE_PARAMETERS_START(2, 2)
- Z_PARAM_OBJ_OF_CLASS(geo_obj, H3_GeoCoord_ce)
+ Z_PARAM_OBJ_OF_CLASS(geo_obj, H3_LatLng_ce)
Z_PARAM_LONG(res)
ZEND_PARSE_PARAMETERS_END();
// clang-format on
VALIDATE_H3_RES(res);
- GeoCoord *geo = emalloc(sizeof(GeoCoord));
+ LatLng *geo = emalloc(sizeof(LatLng));
obj_to_geo(geo_obj, geo);
- H3Index index = geoToH3(geo, res);
+
+ H3Index index;
+ H3Error err = latLngToCell(geo, res, &index);
efree(geo);
- if (index == H3_INVALID_INDEX) {
+ if (err) {
H3_THROW("Failed to create H3 index from geo coordinates", 0);
RETURN_THROWS();
}
@@ -1005,35 +1108,35 @@ PHP_METHOD(H3_H3Index, isValid)
{
ZEND_PARSE_PARAMETERS_NONE();
- RETURN_BOOL(h3IsValid(obj_to_h3(Z_OBJ_P(ZEND_THIS))));
+ RETURN_BOOL(isValidCell(obj_to_h3(Z_OBJ_P(ZEND_THIS))));
}
PHP_METHOD(H3_H3Index, isResClassIII)
{
ZEND_PARSE_PARAMETERS_NONE();
- RETURN_BOOL(h3IsResClassIII(obj_to_h3(Z_OBJ_P(ZEND_THIS))));
+ RETURN_BOOL(isResClassIII(obj_to_h3(Z_OBJ_P(ZEND_THIS))));
}
PHP_METHOD(H3_H3Index, isPentagon)
{
ZEND_PARSE_PARAMETERS_NONE();
- RETURN_BOOL(h3IsPentagon(obj_to_h3(Z_OBJ_P(ZEND_THIS))));
+ RETURN_BOOL(isPentagon(obj_to_h3(Z_OBJ_P(ZEND_THIS))));
}
PHP_METHOD(H3_H3Index, getResolution)
{
ZEND_PARSE_PARAMETERS_NONE();
- RETURN_LONG(h3GetResolution(obj_to_h3(Z_OBJ_P(ZEND_THIS))));
+ RETURN_LONG(getResolution(obj_to_h3(Z_OBJ_P(ZEND_THIS))));
}
PHP_METHOD(H3_H3Index, getBaseCell)
{
ZEND_PARSE_PARAMETERS_NONE();
- RETURN_LONG(h3GetBaseCell(obj_to_h3(Z_OBJ_P(ZEND_THIS))));
+ RETURN_LONG(getBaseCellNumber(obj_to_h3(Z_OBJ_P(ZEND_THIS))));
}
PHP_METHOD(H3_H3Index, getFaces)
@@ -1041,10 +1144,21 @@ PHP_METHOD(H3_H3Index, getFaces)
ZEND_PARSE_PARAMETERS_NONE();
H3Index index = obj_to_h3(Z_OBJ_P(ZEND_THIS));
- int max = maxFaceCount(index);
+
+ int max;
+ H3Error err = maxFaceCount(index, &max);
+ if (err) {
+ H3_THROW("Failed to get max face count", 0);
+ RETURN_THROWS();
+ }
int *out = ecalloc(max, sizeof(int));
- h3GetFaces(index, out);
+ err = getIcosahedronFaces(index, out);
+ if (err) {
+ efree(out);
+ H3_THROW("Failed to get faces", 0);
+ RETURN_THROWS();
+ }
array_init(return_value);
@@ -1067,11 +1181,21 @@ PHP_METHOD(H3_H3Index, kRing)
ZEND_PARSE_PARAMETERS_END();
// clang-format on
- int max = maxKringSize(k);
+ int64_t max;
+ H3Error err = maxGridDiskSize(k, &max);
+ if (err) {
+ H3_THROW("Failed to get max grid disk size", 0);
+ RETURN_THROWS();
+ }
H3Index index = obj_to_h3(Z_OBJ_P(ZEND_THIS));
H3Index *out = ecalloc(max, sizeof(H3Index));
- kRing(index, k, out);
+ err = gridDisk(index, k, out);
+ if (err) {
+ efree(out);
+ H3_THROW("Failed to get grid disk", 0);
+ RETURN_THROWS();
+ }
array_init(return_value);
h3_array_to_zend_array(out, max, return_value);
@@ -1089,12 +1213,23 @@ PHP_METHOD(H3_H3Index, kRingDistances)
ZEND_PARSE_PARAMETERS_END();
// clang-format on
- int max = maxKringSize(k);
+ int64_t max;
+ H3Error err = maxGridDiskSize(k, &max);
+ if (err) {
+ H3_THROW("Failed to get max grid disk size", 0);
+ RETURN_THROWS();
+ }
H3Index index = obj_to_h3(Z_OBJ_P(ZEND_THIS));
H3Index *out = ecalloc(max, sizeof(H3Index));
int *distances = ecalloc(max, sizeof(int));
- kRingDistances(index, k, out, distances);
+ err = gridDiskDistances(index, k, out, distances);
+ if (err) {
+ efree(out);
+ efree(distances);
+ H3_THROW("Failed to get grid disk distances", 0);
+ RETURN_THROWS();
+ }
array_init_size(return_value, k + 1);
@@ -1105,7 +1240,7 @@ PHP_METHOD(H3_H3Index, kRingDistances)
add_next_index_zval(return_value, &values[i]);
}
- for (int i = 0; i < max; i++) {
+ for (int64_t i = 0; i < max; i++) {
if (out[i] != H3_INVALID_INDEX) {
add_next_index_object(&values[distances[i]], h3_to_obj(out[i]));
}
@@ -1126,12 +1261,18 @@ PHP_METHOD(H3_H3Index, hexRange)
ZEND_PARSE_PARAMETERS_END();
// clang-format on
- int max = maxKringSize(k);
+ int64_t max;
+ H3Error err = maxGridDiskSize(k, &max);
+ if (err) {
+ H3_THROW("Failed to get max grid disk size", 0);
+ RETURN_THROWS();
+ }
H3Index index = obj_to_h3(Z_OBJ_P(ZEND_THIS));
H3Index *out = ecalloc(max, sizeof(H3Index));
- if (hexRange(index, k, out) != 0) {
+ err = gridDiskUnsafe(index, k, out);
+ if (err) {
H3_THROW("Pentagonal distortion is encountered", H3_ERR_CODE_PENTAGON_ENCOUNTERED);
efree(out);
RETURN_THROWS();
@@ -1158,7 +1299,8 @@ PHP_METHOD(H3_H3Index, hexRing)
H3Index index = obj_to_h3(Z_OBJ_P(ZEND_THIS));
H3Index *out = ecalloc(max, sizeof(H3Index));
- if (hexRing(index, k, out) != 0) {
+ H3Error err = gridRingUnsafe(index, k, out);
+ if (err) {
H3_THROW("Pentagonal distortion is encountered", H3_ERR_CODE_PENTAGON_ENCOUNTERED);
efree(out);
RETURN_THROWS();
@@ -1180,13 +1322,19 @@ PHP_METHOD(H3_H3Index, hexRangeDistances)
ZEND_PARSE_PARAMETERS_END();
// clang-format on
- int max = maxKringSize(k);
+ int64_t max;
+ H3Error err = maxGridDiskSize(k, &max);
+ if (err) {
+ H3_THROW("Failed to get max grid disk size", 0);
+ RETURN_THROWS();
+ }
H3Index index = obj_to_h3(Z_OBJ_P(ZEND_THIS));
H3Index *out = ecalloc(max, sizeof(H3Index));
int *distances = ecalloc(max, sizeof(int));
- if (hexRangeDistances(index, k, out, distances) != 0) {
+ err = gridDiskDistancesUnsafe(index, k, out, distances);
+ if (err) {
H3_THROW("Pentagonal distortion is encountered", H3_ERR_CODE_PENTAGON_ENCOUNTERED);
efree(out);
efree(distances);
@@ -1202,7 +1350,7 @@ PHP_METHOD(H3_H3Index, hexRangeDistances)
add_next_index_zval(return_value, &values[i]);
}
- for (int i = 0; i < max; i++) {
+ for (int64_t i = 0; i < max; i++) {
if (out[i] != H3_INVALID_INDEX) {
add_next_index_object(&values[distances[i]], h3_to_obj(out[i]));
}
@@ -1224,14 +1372,31 @@ PHP_METHOD(H3_H3Index, getCellArea)
// clang-format on
H3Index index = obj_to_h3(Z_OBJ_P(ZEND_THIS));
+ double out;
+ H3Error err;
switch (unit) {
case H3_AREA_UNIT_KM2:
- RETURN_DOUBLE(cellAreaKm2(index));
+ err = cellAreaKm2(index, &out);
+ if (err) {
+ H3_THROW("Failed to get cell area", 0);
+ RETURN_THROWS();
+ }
+ RETURN_DOUBLE(out);
case H3_AREA_UNIT_M2:
- RETURN_DOUBLE(cellAreaM2(index));
+ err = cellAreaM2(index, &out);
+ if (err) {
+ H3_THROW("Failed to get cell area", 0);
+ RETURN_THROWS();
+ }
+ RETURN_DOUBLE(out);
case H3_AREA_UNIT_RADS2:
- RETURN_DOUBLE(cellAreaRads2(index));
+ err = cellAreaRads2(index, &out);
+ if (err) {
+ H3_THROW("Failed to get cell area", 0);
+ RETURN_THROWS();
+ }
+ RETURN_DOUBLE(out);
default:
H3_THROW("Unsupported unit (must be one of H3_AREA_UNIT_KM2, H3_AREA_UNIT_M2, or H3_AREA_UNIT_RADS2)",
H3_ERR_CODE_UNSUPPORTED_UNIT);
@@ -1252,7 +1417,14 @@ PHP_METHOD(H3_H3Index, isNeighborTo)
H3Index origin = obj_to_h3(Z_OBJ_P(ZEND_THIS));
H3Index destination = obj_to_h3(dest);
- RETURN_BOOL(h3IndexesAreNeighbors(origin, destination));
+ int out;
+ H3Error err = areNeighborCells(origin, destination, &out);
+ if (err) {
+ H3_THROW("Failed to check neighbors", 0);
+ RETURN_THROWS();
+ }
+
+ RETURN_BOOL(out);
}
PHP_METHOD(H3_H3Index, getLineTo)
@@ -1278,24 +1450,36 @@ PHP_METHOD(H3_H3Index, getDistanceTo)
ZEND_PARSE_PARAMETERS_END();
// clang-format on
- RETURN_LONG(h3Distance(obj_to_h3(Z_OBJ_P(ZEND_THIS)), obj_to_h3(dest)));
+ int64_t dist;
+ H3Error err = gridDistance(obj_to_h3(Z_OBJ_P(ZEND_THIS)), obj_to_h3(dest), &dist);
+ if (err) {
+ H3_THROW("Failed to calculate distance", 0);
+ RETURN_THROWS();
+ }
+
+ RETURN_LONG(dist);
}
-PHP_METHOD(H3_H3Index, getUnidirectionalEdges)
+PHP_METHOD(H3_H3Index, getDirectedEdges)
{
ZEND_PARSE_PARAMETERS_NONE();
H3Index index = obj_to_h3(Z_OBJ_P(ZEND_THIS));
- H3UniEdge *edges = ecalloc(H3_HEX_NUM_EDGES, sizeof(H3UniEdge));
- getH3UnidirectionalEdgesFromHexagon(index, edges);
+ H3DirectedEdge *edges = ecalloc(H3_HEX_NUM_EDGES, sizeof(H3DirectedEdge));
+ H3Error err = originToDirectedEdges(index, edges);
+ if (err) {
+ efree(edges);
+ H3_THROW("Failed to get directed edges", 0);
+ RETURN_THROWS();
+ }
array_init_size(return_value, H3_HEX_NUM_EDGES);
- h3ue_array_to_zend_array(edges, H3_HEX_NUM_EDGES, return_value);
+ h3de_array_to_zend_array(edges, H3_HEX_NUM_EDGES, return_value);
efree(edges);
}
-PHP_METHOD(H3_H3Index, getUnidirectionalEdge)
+PHP_METHOD(H3_H3Index, getDirectedEdge)
{
zend_object *dest;
@@ -1307,14 +1491,16 @@ PHP_METHOD(H3_H3Index, getUnidirectionalEdge)
H3Index origin = obj_to_h3(Z_OBJ_P(ZEND_THIS));
H3Index destination = obj_to_h3(dest);
- H3UniEdge edge = getH3UnidirectionalEdge(origin, destination);
- if (edge == H3_INVALID_INDEX) {
- H3_THROW("Failed to get unidirectional edge", 0);
+ H3DirectedEdge edge;
+ H3Error err = cellsToDirectedEdge(origin, destination, &edge);
+
+ if (err) {
+ H3_THROW("Failed to get directed edge", 0);
RETURN_THROWS();
}
- RETURN_OBJ(h3ue_to_obj(edge));
+ RETURN_OBJ(h3de_to_obj(edge));
}
PHP_METHOD(H3_H3Index, toParent)
@@ -1330,7 +1516,12 @@ PHP_METHOD(H3_H3Index, toParent)
VALIDATE_H3_RES(res);
H3Index index = obj_to_h3(Z_OBJ_P(ZEND_THIS));
- H3Index parent = h3ToParent(index, res);
+ H3Index parent;
+ H3Error err = cellToParent(index, res, &parent);
+ if (err) {
+ H3_THROW("Failed to get parent", H3_ERR_CODE_INVALID_RES);
+ RETURN_THROWS();
+ }
RETURN_OBJ(h3_to_obj(parent));
}
@@ -1348,10 +1539,21 @@ PHP_METHOD(H3_H3Index, toChildren)
VALIDATE_H3_RES(res);
H3Index index = obj_to_h3(Z_OBJ_P(ZEND_THIS));
- int max = maxH3ToChildrenSize(index, res);
+
+ int64_t max;
+ H3Error err = cellToChildrenSize(index, res, &max);
+ if (err) {
+ H3_THROW("Failed to get children size", H3_ERR_CODE_INVALID_RES);
+ RETURN_THROWS();
+ }
H3Index *children = ecalloc(max, sizeof(H3Index));
- h3ToChildren(index, res, children);
+ err = cellToChildren(index, res, children);
+ if (err) {
+ efree(children);
+ H3_THROW("Failed to get children", H3_ERR_CODE_INVALID_RES);
+ RETURN_THROWS();
+ }
array_init(return_value);
h3_array_to_zend_array(children, max, return_value);
@@ -1372,7 +1574,12 @@ PHP_METHOD(H3_H3Index, toCenterChild)
VALIDATE_H3_RES(res);
H3Index index = obj_to_h3(Z_OBJ_P(ZEND_THIS));
- H3Index child = h3ToCenterChild(index, res);
+ H3Index child;
+ H3Error err = cellToCenterChild(index, res, &child);
+ if (err) {
+ H3_THROW("Failed to get center child", H3_ERR_CODE_INVALID_RES);
+ RETURN_THROWS();
+ }
RETURN_OBJ(h3_to_obj(child));
}
@@ -1391,7 +1598,12 @@ PHP_METHOD(H3_H3Index, toString)
H3Index index = obj_to_h3(Z_OBJ_P(ZEND_THIS));
char *out = emalloc(H3_STRVAL_LEN);
- h3ToString(index, out, H3_STRVAL_LEN);
+ H3Error err = h3ToString(index, out, H3_STRVAL_LEN);
+ if (err) {
+ efree(out);
+ H3_THROW("Failed to convert H3 index to string", 0);
+ RETURN_THROWS();
+ }
RETVAL_STRINGL(out, strlen(out));
efree(out);
}
@@ -1402,8 +1614,13 @@ PHP_METHOD(H3_H3Index, toGeo)
H3Index index = obj_to_h3(Z_OBJ_P(ZEND_THIS));
- GeoCoord *geo = emalloc(sizeof(GeoCoord));
- h3ToGeo(index, geo);
+ LatLng *geo = emalloc(sizeof(LatLng));
+ H3Error err = cellToLatLng(index, geo);
+ if (err) {
+ efree(geo);
+ H3_THROW("Failed to convert to geo", 0);
+ RETURN_THROWS();
+ }
RETVAL_OBJ(geo_to_obj(geo));
efree(geo);
}
@@ -1414,8 +1631,13 @@ PHP_METHOD(H3_H3Index, toGeoBoundary)
H3Index index = obj_to_h3(Z_OBJ_P(ZEND_THIS));
- GeoBoundary *boundary = emalloc(sizeof(GeoBoundary));
- h3ToGeoBoundary(index, boundary);
+ CellBoundary *boundary = emalloc(sizeof(CellBoundary));
+ H3Error err = cellToBoundary(index, boundary);
+ if (err) {
+ efree(boundary);
+ H3_THROW("Failed to convert to boundary", 0);
+ RETURN_THROWS();
+ }
RETVAL_OBJ(geo_boundary_to_obj(boundary));
efree(boundary);
}
@@ -1427,12 +1649,17 @@ PHP_METHOD(H3_H3Index, __toString)
H3Index index = obj_to_h3(Z_OBJ_P(ZEND_THIS));
char *out = emalloc(H3_STRVAL_LEN);
- h3ToString(index, out, H3_STRVAL_LEN);
+ H3Error err = h3ToString(index, out, H3_STRVAL_LEN);
+ if (err) {
+ efree(out);
+ H3_THROW("Failed to convert H3 index to string", 0);
+ RETURN_THROWS();
+ }
RETVAL_STRINGL(out, strlen(out));
efree(out);
}
-PHP_METHOD(H3_H3UniEdge, __construct)
+PHP_METHOD(H3_H3DirectedEdge, __construct)
{
zend_ulong index;
@@ -1444,10 +1671,10 @@ PHP_METHOD(H3_H3UniEdge, __construct)
VALIDATE_H3_UNI_EDGE(index);
- zend_update_property_long(H3_H3UniEdge_ce, Z_OBJ_P(ZEND_THIS), "index", sizeof("index") - 1, index);
+ zend_update_property_long(H3_H3DirectedEdge_ce, Z_OBJ_P(ZEND_THIS), "index", sizeof("index") - 1, index);
}
-PHP_METHOD(H3_H3UniEdge, fromLong)
+PHP_METHOD(H3_H3DirectedEdge, fromLong)
{
zend_ulong index;
@@ -1459,14 +1686,14 @@ PHP_METHOD(H3_H3UniEdge, fromLong)
VALIDATE_H3_UNI_EDGE(index);
- zend_object *obj = zend_objects_new(H3_H3UniEdge_ce);
- object_properties_init(obj, H3_H3UniEdge_ce);
- zend_update_property_long(H3_H3UniEdge_ce, obj, "index", sizeof("index") - 1, index);
+ zend_object *obj = zend_objects_new(H3_H3DirectedEdge_ce);
+ object_properties_init(obj, H3_H3DirectedEdge_ce);
+ zend_update_property_long(H3_H3DirectedEdge_ce, obj, "index", sizeof("index") - 1, index);
RETURN_OBJ(obj);
}
-PHP_METHOD(H3_H3UniEdge, fromString)
+PHP_METHOD(H3_H3DirectedEdge, fromString)
{
zend_string *value;
@@ -1476,49 +1703,69 @@ PHP_METHOD(H3_H3UniEdge, fromString)
ZEND_PARSE_PARAMETERS_END();
// clang-format on
- H3UniEdge edge = stringToH3(ZSTR_VAL(value));
+ H3DirectedEdge edge;
+ H3Error err = stringToH3(ZSTR_VAL(value), &edge);
+ if (err) {
+ H3_THROW("Failed to parse H3 edge string", H3_ERR_CODE_INVALID_INDEX);
+ RETURN_THROWS();
+ }
VALIDATE_H3_UNI_EDGE(edge);
- RETURN_OBJ(h3ue_to_obj(edge));
+ RETURN_OBJ(h3de_to_obj(edge));
}
-PHP_METHOD(H3_H3UniEdge, isValid)
+PHP_METHOD(H3_H3DirectedEdge, isValid)
{
ZEND_PARSE_PARAMETERS_NONE();
- H3UniEdge edge = obj_to_h3ue(Z_OBJ_P(ZEND_THIS));
+ H3DirectedEdge edge = obj_to_h3de(Z_OBJ_P(ZEND_THIS));
- RETURN_BOOL(h3UnidirectionalEdgeIsValid(edge));
+ RETURN_BOOL(isValidDirectedEdge(edge));
}
-PHP_METHOD(H3_H3UniEdge, getOrigin)
+PHP_METHOD(H3_H3DirectedEdge, getOrigin)
{
ZEND_PARSE_PARAMETERS_NONE();
- H3UniEdge edge = obj_to_h3ue(Z_OBJ_P(ZEND_THIS));
- H3Index origin = getOriginH3IndexFromUnidirectionalEdge(edge);
+ H3DirectedEdge edge = obj_to_h3de(Z_OBJ_P(ZEND_THIS));
+ H3Index origin;
+ H3Error err = getDirectedEdgeOrigin(edge, &origin);
+ if (err) {
+ H3_THROW("Failed to get origin", 0);
+ RETURN_THROWS();
+ }
RETURN_OBJ(h3_to_obj(origin));
}
-PHP_METHOD(H3_H3UniEdge, getDestination)
+PHP_METHOD(H3_H3DirectedEdge, getDestination)
{
ZEND_PARSE_PARAMETERS_NONE();
- H3UniEdge edge = obj_to_h3ue(Z_OBJ_P(ZEND_THIS));
- H3Index destination = getDestinationH3IndexFromUnidirectionalEdge(edge);
+ H3DirectedEdge edge = obj_to_h3de(Z_OBJ_P(ZEND_THIS));
+ H3Index destination;
+ H3Error err = getDirectedEdgeDestination(edge, &destination);
+ if (err) {
+ H3_THROW("Failed to get destination", 0);
+ RETURN_THROWS();
+ }
RETURN_OBJ(h3_to_obj(destination));
}
-PHP_METHOD(H3_H3UniEdge, getIndexes)
+PHP_METHOD(H3_H3DirectedEdge, getIndexes)
{
ZEND_PARSE_PARAMETERS_NONE();
- H3UniEdge edge = obj_to_h3ue(Z_OBJ_P(ZEND_THIS));
+ H3DirectedEdge edge = obj_to_h3de(Z_OBJ_P(ZEND_THIS));
H3Index *out = ecalloc(H3_EDGE_NUM_INDX, sizeof(H3Index));
- getH3IndexesFromUnidirectionalEdge(edge, out);
+ H3Error err = directedEdgeToCells(edge, out);
+ if (err) {
+ efree(out);
+ H3_THROW("Failed to get edge cells", 0);
+ RETURN_THROWS();
+ }
array_init_size(return_value, H3_EDGE_NUM_INDX);
h3_array_to_zend_array(out, H3_EDGE_NUM_INDX, return_value);
@@ -1526,20 +1773,25 @@ PHP_METHOD(H3_H3UniEdge, getIndexes)
efree(out);
}
-PHP_METHOD(H3_H3UniEdge, getBoundary)
+PHP_METHOD(H3_H3DirectedEdge, getBoundary)
{
ZEND_PARSE_PARAMETERS_NONE();
- H3UniEdge edge = obj_to_h3ue(Z_OBJ_P(ZEND_THIS));
- GeoBoundary *boundary = emalloc(sizeof(GeoBoundary));
- getH3UnidirectionalEdgeBoundary(edge, boundary);
+ H3DirectedEdge edge = obj_to_h3de(Z_OBJ_P(ZEND_THIS));
+ CellBoundary *boundary = emalloc(sizeof(CellBoundary));
+ H3Error err = directedEdgeToBoundary(edge, boundary);
+ if (err) {
+ efree(boundary);
+ H3_THROW("Failed to get edge boundary", 0);
+ RETURN_THROWS();
+ }
RETVAL_OBJ(geo_boundary_to_obj(boundary));
efree(boundary);
}
-PHP_METHOD(H3_H3UniEdge, getLength)
+PHP_METHOD(H3_H3DirectedEdge, getLength)
{
zend_long unit;
@@ -1549,15 +1801,32 @@ PHP_METHOD(H3_H3UniEdge, getLength)
ZEND_PARSE_PARAMETERS_END();
// clang-format on
- H3UniEdge edge = obj_to_h3ue(Z_OBJ_P(ZEND_THIS));
+ H3DirectedEdge edge = obj_to_h3de(Z_OBJ_P(ZEND_THIS));
+ double out;
+ H3Error err;
switch (unit) {
case H3_LENGTH_UNIT_KM:
- RETURN_DOUBLE(exactEdgeLengthKm(edge));
+ err = edgeLengthKm(edge, &out);
+ if (err) {
+ H3_THROW("Failed to get edge length", 0);
+ RETURN_THROWS();
+ }
+ RETURN_DOUBLE(out);
case H3_LENGTH_UNIT_M:
- RETURN_DOUBLE(exactEdgeLengthM(edge));
+ err = edgeLengthM(edge, &out);
+ if (err) {
+ H3_THROW("Failed to get edge length", 0);
+ RETURN_THROWS();
+ }
+ RETURN_DOUBLE(out);
case H3_LENGTH_UNIT_RADS:
- RETURN_DOUBLE(exactEdgeLengthRads(edge));
+ err = edgeLengthRads(edge, &out);
+ if (err) {
+ H3_THROW("Failed to get edge length", 0);
+ RETURN_THROWS();
+ }
+ RETURN_DOUBLE(out);
default:
H3_THROW("Unsupported unit (must be one of H3_LENGTH_UNIT_KM, H3_LENGTH_UNIT_M, or H3_LENGTH_UNIT_RADS)",
H3_ERR_CODE_UNSUPPORTED_UNIT);
@@ -1565,38 +1834,48 @@ PHP_METHOD(H3_H3UniEdge, getLength)
}
}
-PHP_METHOD(H3_H3UniEdge, toLong)
+PHP_METHOD(H3_H3DirectedEdge, toLong)
{
ZEND_PARSE_PARAMETERS_NONE();
- RETURN_LONG(obj_to_h3ue(Z_OBJ_P(ZEND_THIS)));
+ RETURN_LONG(obj_to_h3de(Z_OBJ_P(ZEND_THIS)));
}
-PHP_METHOD(H3_H3UniEdge, toString)
+PHP_METHOD(H3_H3DirectedEdge, toString)
{
ZEND_PARSE_PARAMETERS_NONE();
- H3UniEdge edge = obj_to_h3ue(Z_OBJ_P(ZEND_THIS));
+ H3DirectedEdge edge = obj_to_h3de(Z_OBJ_P(ZEND_THIS));
char *out = emalloc(H3_STRVAL_LEN);
- h3ToString(edge, out, H3_STRVAL_LEN);
+ H3Error err = h3ToString(edge, out, H3_STRVAL_LEN);
+ if (err) {
+ efree(out);
+ H3_THROW("Failed to convert edge to string", 0);
+ RETURN_THROWS();
+ }
RETVAL_STRINGL(out, strlen(out));
efree(out);
}
-PHP_METHOD(H3_H3UniEdge, __toString)
+PHP_METHOD(H3_H3DirectedEdge, __toString)
{
ZEND_PARSE_PARAMETERS_NONE();
- H3UniEdge edge = obj_to_h3ue(Z_OBJ_P(ZEND_THIS));
+ H3DirectedEdge edge = obj_to_h3de(Z_OBJ_P(ZEND_THIS));
char *out = emalloc(H3_STRVAL_LEN);
- h3ToString(edge, out, H3_STRVAL_LEN);
+ H3Error err = h3ToString(edge, out, H3_STRVAL_LEN);
+ if (err) {
+ efree(out);
+ H3_THROW("Failed to convert edge to string", 0);
+ RETURN_THROWS();
+ }
RETVAL_STRINGL(out, strlen(out));
efree(out);
}
-PHP_METHOD(H3_GeoCoord, __construct)
+PHP_METHOD(H3_LatLng, __construct)
{
double lat, lon;
@@ -1607,35 +1886,35 @@ PHP_METHOD(H3_GeoCoord, __construct)
ZEND_PARSE_PARAMETERS_END();
// clang-format on
- zend_update_property_double(H3_GeoCoord_ce, Z_OBJ_P(ZEND_THIS), "lat", sizeof("lat") - 1, lat);
- zend_update_property_double(H3_GeoCoord_ce, Z_OBJ_P(ZEND_THIS), "lon", sizeof("lon") - 1, lon);
+ zend_update_property_double(H3_LatLng_ce, Z_OBJ_P(ZEND_THIS), "lat", sizeof("lat") - 1, lat);
+ zend_update_property_double(H3_LatLng_ce, Z_OBJ_P(ZEND_THIS), "lon", sizeof("lon") - 1, lon);
}
-PHP_METHOD(H3_GeoCoord, getLat)
+PHP_METHOD(H3_LatLng, getLat)
{
ZEND_PARSE_PARAMETERS_NONE();
zval *prop;
zval rv;
- prop = zend_read_property(H3_GeoCoord_ce, Z_OBJ_P(ZEND_THIS), "lat", sizeof("lat") - 1, 1, &rv);
+ prop = zend_read_property(H3_LatLng_ce, Z_OBJ_P(ZEND_THIS), "lat", sizeof("lat") - 1, 1, &rv);
RETURN_DOUBLE(Z_DVAL_P(prop));
}
-PHP_METHOD(H3_GeoCoord, getLon)
+PHP_METHOD(H3_LatLng, getLon)
{
ZEND_PARSE_PARAMETERS_NONE();
zval *prop;
zval rv;
- prop = zend_read_property(H3_GeoCoord_ce, Z_OBJ_P(ZEND_THIS), "lon", sizeof("lon") - 1, 1, &rv);
+ prop = zend_read_property(H3_LatLng_ce, Z_OBJ_P(ZEND_THIS), "lon", sizeof("lon") - 1, 1, &rv);
RETURN_DOUBLE(Z_DVAL_P(prop));
}
-PHP_METHOD(H3_GeoBoundary, __construct)
+PHP_METHOD(H3_CellBoundary, __construct)
{
zval *vertices;
@@ -1645,17 +1924,17 @@ PHP_METHOD(H3_GeoBoundary, __construct)
ZEND_PARSE_PARAMETERS_END();
// clang-format on
- zend_update_property(H3_GeoBoundary_ce, Z_OBJ_P(ZEND_THIS), "vertices", sizeof("vertices") - 1, vertices);
+ zend_update_property(H3_CellBoundary_ce, Z_OBJ_P(ZEND_THIS), "vertices", sizeof("vertices") - 1, vertices);
}
-PHP_METHOD(H3_GeoBoundary, getVertices)
+PHP_METHOD(H3_CellBoundary, getVertices)
{
ZEND_PARSE_PARAMETERS_NONE();
zval *prop;
zval rv;
- prop = zend_read_property(H3_GeoBoundary_ce, Z_OBJ_P(ZEND_THIS), "vertices", sizeof("vertices") - 1, 1, &rv);
+ prop = zend_read_property(H3_CellBoundary_ce, Z_OBJ_P(ZEND_THIS), "vertices", sizeof("vertices") - 1, 1, &rv);
Z_TRY_ADDREF_P(prop);
@@ -1670,7 +1949,7 @@ PHP_METHOD(H3_GeoPolygon, __construct)
// clang-format off
ZEND_PARSE_PARAMETERS_START(1, 2)
- Z_PARAM_OBJ_OF_CLASS(geofence, H3_GeoBoundary_ce)
+ Z_PARAM_OBJ_OF_CLASS(geofence, H3_CellBoundary_ce)
Z_PARAM_OPTIONAL
Z_PARAM_ARRAY_OR_NULL(holes)
ZEND_PARSE_PARAMETERS_END();
@@ -1823,9 +2102,9 @@ PHP_MINIT_FUNCTION(h3)
H3_H3Exception_ce = register_class_H3_H3Exception(spl_ce_RuntimeException);
H3_H3Index_ce = register_class_H3_H3Index();
- H3_H3UniEdge_ce = register_class_H3_H3UniEdge();
- H3_GeoCoord_ce = register_class_H3_GeoCoord();
- H3_GeoBoundary_ce = register_class_H3_GeoBoundary();
+ H3_H3DirectedEdge_ce = register_class_H3_H3DirectedEdge();
+ H3_LatLng_ce = register_class_H3_LatLng();
+ H3_CellBoundary_ce = register_class_H3_CellBoundary();
H3_GeoPolygon_ce = register_class_H3_GeoPolygon();
H3_GeoMultiPolygon_ce = register_class_H3_GeoMultiPolygon();
H3_CoordIJ_ce = register_class_H3_CoordIJ();
diff --git a/h3.stub.php b/h3.stub.php
index da0d2c5..3e20b32 100644
--- a/h3.stub.php
+++ b/h3.stub.php
@@ -34,7 +34,7 @@ function get_res0_indexes(): array {}
*/
function get_pentagon_indexes(int $res): array {}
-function point_dist(GeoCoord $a, GeoCoord $b, int $unit): float {}
+function point_dist(LatLng $a, LatLng $b, int $unit): float {}
/**
* @param H3Index[] $indexes
@@ -91,7 +91,7 @@ public static function fromString(string $value): H3Index {}
/**
* @throws H3Exception
*/
- public static function fromGeo(GeoCoord $geo, int $res): H3Index {}
+ public static function fromGeo(LatLng $geo, int $res): H3Index {}
public function isValid(): bool {}
@@ -118,13 +118,13 @@ public function kRing(int $k): array {}
*/
public function kRingDistances(int $k): array {}
- /**
+ /**
* @return H3Index[]
* @throws H3Exception if pentagonal distortion is encountered
*/
public function hexRange(int $k): array {}
- /**
+ /**
* @return H3Index[]
* @throws H3Exception if pentagonal distortion is encountered
*/
@@ -148,11 +148,11 @@ public function getLineTo(H3Index $destination): array {}
public function getDistanceTo(H3Index $destination): int {}
/**
- * @return H3UniEdge[]
+ * @return H3DirectedEdge[]
*/
- public function getUnidirectionalEdges(): array {}
+ public function getDirectedEdges(): array {}
- public function getUnidirectionalEdge(H3Index $destination): H3UniEdge {}
+ public function getDirectedEdge(H3Index $destination): H3DirectedEdge {}
/**
* @throws H3Exception if invalid resolution given
@@ -174,22 +174,22 @@ public function toLong(): int {}
public function toString(): string {}
- public function toGeo(): GeoCoord {}
+ public function toGeo(): LatLng {}
- public function toGeoBoundary(): GeoBoundary {}
+ public function toGeoBoundary(): CellBoundary {}
public function __toString(): string {}
}
-final class H3UniEdge {
+final class H3DirectedEdge {
private int $index;
public function __construct(int $index) {}
- public static function fromLong(int $index): H3UniEdge {}
+ public static function fromLong(int $index): H3DirectedEdge {}
- public static function fromString(string $value): H3UniEdge {}
+ public static function fromString(string $value): H3DirectedEdge {}
public function isValid(): bool {}
@@ -202,7 +202,7 @@ public function getDestination(): H3Index {}
*/
public function getIndexes(): array {}
- public function getBoundary(): GeoBoundary {}
+ public function getBoundary(): CellBoundary {}
public function getLength(int $unit): float {}
@@ -213,7 +213,7 @@ public function toString(): string {}
public function __toString(): string {}
}
-final class GeoCoord {
+final class LatLng {
private float $lat;
@@ -226,42 +226,42 @@ public function getLat(): float {}
public function getLon(): float {}
}
-final class GeoBoundary {
+final class CellBoundary {
/**
- * @var GeoCoord[]
+ * @var LatLng[]
*/
private array $vertices;
/**
- * @param GeoCoord[] $vertices
+ * @param LatLng[] $vertices
*/
public function __construct(array $vertices) {}
/**
- * @return GeoCoord[]
+ * @return LatLng[]
*/
public function getVertices(): array {}
}
final class GeoPolygon {
- private GeoBoundary $geofence;
+ private CellBoundary $geofence;
/**
- * @var GeoBoundary[]
+ * @var CellBoundary[]
*/
private array $holes;
/**
- * @param GeoBoundary[] $holes
+ * @param CellBoundary[] $holes
*/
- public function __construct(GeoBoundary $geofence, array $holes = []) {}
+ public function __construct(CellBoundary $geofence, array $holes = []) {}
- public function getGeofence(): GeoBoundary {}
+ public function getGeofence(): CellBoundary {}
/**
- * @return GeoBoundary[]
+ * @return CellBoundary[]
*/
public function getHoles(): array {}
}
diff --git a/h3_arginfo.h b/h3_arginfo.h
index 45df1ba..1796a96 100644
--- a/h3_arginfo.h
+++ b/h3_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 438fc6281b05d84e505cb265790171f28d5e9303 */
+ * Stub hash: h3v4-upgrade */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_H3_degs_to_rads, 0, 1, IS_DOUBLE, 0)
ZEND_ARG_TYPE_INFO(0, degrees, IS_DOUBLE, 0)
@@ -28,8 +28,8 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_H3_get_pentagon_indexes, 0, 1, I
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_H3_point_dist, 0, 3, IS_DOUBLE, 0)
- ZEND_ARG_OBJ_INFO(0, a, H3\\GeoCoord, 0)
- ZEND_ARG_OBJ_INFO(0, b, H3\\GeoCoord, 0)
+ ZEND_ARG_OBJ_INFO(0, a, H3\\LatLng, 0)
+ ZEND_ARG_OBJ_INFO(0, b, H3\\LatLng, 0)
ZEND_ARG_TYPE_INFO(0, unit, IS_LONG, 0)
ZEND_END_ARG_INFO()
@@ -89,7 +89,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_H3_H3Index_fromString, 0, 1
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_H3_H3Index_fromGeo, 0, 2, H3\\H3Index, 0)
- ZEND_ARG_OBJ_INFO(0, geo, H3\\GeoCoord, 0)
+ ZEND_ARG_OBJ_INFO(0, geo, H3\\LatLng, 0)
ZEND_ARG_TYPE_INFO(0, res, IS_LONG, 0)
ZEND_END_ARG_INFO()
@@ -135,9 +135,9 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_H3_H3Index_getDistanceTo,
ZEND_ARG_OBJ_INFO(0, destination, H3\\H3Index, 0)
ZEND_END_ARG_INFO()
-#define arginfo_class_H3_H3Index_getUnidirectionalEdges arginfo_H3_get_res0_indexes
+#define arginfo_class_H3_H3Index_getDirectedEdges arginfo_H3_get_res0_indexes
-ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_H3_H3Index_getUnidirectionalEdge, 0, 1, H3\\H3UniEdge, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_H3_H3Index_getDirectedEdge, 0, 1, H3\\H3DirectedEdge, 0)
ZEND_ARG_OBJ_INFO(0, destination, H3\\H3Index, 0)
ZEND_END_ARG_INFO()
@@ -154,61 +154,61 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_H3_H3Index_toString, 0, 0, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_H3_H3Index_toGeo, 0, 0, H3\\GeoCoord, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_H3_H3Index_toGeo, 0, 0, H3\\LatLng, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_H3_H3Index_toGeoBoundary, 0, 0, H3\\GeoBoundary, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_H3_H3Index_toGeoBoundary, 0, 0, H3\\CellBoundary, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_H3_H3Index___toString arginfo_class_H3_H3Index_toString
-#define arginfo_class_H3_H3UniEdge___construct arginfo_class_H3_H3Index___construct
+#define arginfo_class_H3_H3DirectedEdge___construct arginfo_class_H3_H3Index___construct
-ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_H3_H3UniEdge_fromLong, 0, 1, H3\\H3UniEdge, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_H3_H3DirectedEdge_fromLong, 0, 1, H3\\H3DirectedEdge, 0)
ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_H3_H3UniEdge_fromString, 0, 1, H3\\H3UniEdge, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_H3_H3DirectedEdge_fromString, 0, 1, H3\\H3DirectedEdge, 0)
ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0)
ZEND_END_ARG_INFO()
-#define arginfo_class_H3_H3UniEdge_isValid arginfo_class_H3_H3Index_isValid
+#define arginfo_class_H3_H3DirectedEdge_isValid arginfo_class_H3_H3Index_isValid
-ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_H3_H3UniEdge_getOrigin, 0, 0, H3\\H3Index, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_H3_H3DirectedEdge_getOrigin, 0, 0, H3\\H3Index, 0)
ZEND_END_ARG_INFO()
-#define arginfo_class_H3_H3UniEdge_getDestination arginfo_class_H3_H3UniEdge_getOrigin
+#define arginfo_class_H3_H3DirectedEdge_getDestination arginfo_class_H3_H3DirectedEdge_getOrigin
-#define arginfo_class_H3_H3UniEdge_getIndexes arginfo_H3_get_res0_indexes
+#define arginfo_class_H3_H3DirectedEdge_getIndexes arginfo_H3_get_res0_indexes
-#define arginfo_class_H3_H3UniEdge_getBoundary arginfo_class_H3_H3Index_toGeoBoundary
+#define arginfo_class_H3_H3DirectedEdge_getBoundary arginfo_class_H3_H3Index_toGeoBoundary
-#define arginfo_class_H3_H3UniEdge_getLength arginfo_class_H3_H3Index_getCellArea
+#define arginfo_class_H3_H3DirectedEdge_getLength arginfo_class_H3_H3Index_getCellArea
-#define arginfo_class_H3_H3UniEdge_toLong arginfo_class_H3_H3Index_getResolution
+#define arginfo_class_H3_H3DirectedEdge_toLong arginfo_class_H3_H3Index_getResolution
-#define arginfo_class_H3_H3UniEdge_toString arginfo_class_H3_H3Index_toString
+#define arginfo_class_H3_H3DirectedEdge_toString arginfo_class_H3_H3Index_toString
-#define arginfo_class_H3_H3UniEdge___toString arginfo_class_H3_H3Index_toString
+#define arginfo_class_H3_H3DirectedEdge___toString arginfo_class_H3_H3Index_toString
-ZEND_BEGIN_ARG_INFO_EX(arginfo_class_H3_GeoCoord___construct, 0, 0, 2)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_H3_LatLng___construct, 0, 0, 2)
ZEND_ARG_TYPE_INFO(0, lat, IS_DOUBLE, 0)
ZEND_ARG_TYPE_INFO(0, lon, IS_DOUBLE, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_H3_GeoCoord_getLat, 0, 0, IS_DOUBLE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_H3_LatLng_getLat, 0, 0, IS_DOUBLE, 0)
ZEND_END_ARG_INFO()
-#define arginfo_class_H3_GeoCoord_getLon arginfo_class_H3_GeoCoord_getLat
+#define arginfo_class_H3_LatLng_getLon arginfo_class_H3_LatLng_getLat
-ZEND_BEGIN_ARG_INFO_EX(arginfo_class_H3_GeoBoundary___construct, 0, 0, 1)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_H3_CellBoundary___construct, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, vertices, IS_ARRAY, 0)
ZEND_END_ARG_INFO()
-#define arginfo_class_H3_GeoBoundary_getVertices arginfo_H3_get_res0_indexes
+#define arginfo_class_H3_CellBoundary_getVertices arginfo_H3_get_res0_indexes
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_H3_GeoPolygon___construct, 0, 0, 1)
- ZEND_ARG_OBJ_INFO(0, geofence, H3\\GeoBoundary, 0)
+ ZEND_ARG_OBJ_INFO(0, geofence, H3\\CellBoundary, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, holes, IS_ARRAY, 0, "[]")
ZEND_END_ARG_INFO()
@@ -270,8 +270,8 @@ ZEND_METHOD(H3_H3Index, getCellArea);
ZEND_METHOD(H3_H3Index, isNeighborTo);
ZEND_METHOD(H3_H3Index, getLineTo);
ZEND_METHOD(H3_H3Index, getDistanceTo);
-ZEND_METHOD(H3_H3Index, getUnidirectionalEdges);
-ZEND_METHOD(H3_H3Index, getUnidirectionalEdge);
+ZEND_METHOD(H3_H3Index, getDirectedEdges);
+ZEND_METHOD(H3_H3Index, getDirectedEdge);
ZEND_METHOD(H3_H3Index, toParent);
ZEND_METHOD(H3_H3Index, toChildren);
ZEND_METHOD(H3_H3Index, toCenterChild);
@@ -280,23 +280,23 @@ ZEND_METHOD(H3_H3Index, toString);
ZEND_METHOD(H3_H3Index, toGeo);
ZEND_METHOD(H3_H3Index, toGeoBoundary);
ZEND_METHOD(H3_H3Index, __toString);
-ZEND_METHOD(H3_H3UniEdge, __construct);
-ZEND_METHOD(H3_H3UniEdge, fromLong);
-ZEND_METHOD(H3_H3UniEdge, fromString);
-ZEND_METHOD(H3_H3UniEdge, isValid);
-ZEND_METHOD(H3_H3UniEdge, getOrigin);
-ZEND_METHOD(H3_H3UniEdge, getDestination);
-ZEND_METHOD(H3_H3UniEdge, getIndexes);
-ZEND_METHOD(H3_H3UniEdge, getBoundary);
-ZEND_METHOD(H3_H3UniEdge, getLength);
-ZEND_METHOD(H3_H3UniEdge, toLong);
-ZEND_METHOD(H3_H3UniEdge, toString);
-ZEND_METHOD(H3_H3UniEdge, __toString);
-ZEND_METHOD(H3_GeoCoord, __construct);
-ZEND_METHOD(H3_GeoCoord, getLat);
-ZEND_METHOD(H3_GeoCoord, getLon);
-ZEND_METHOD(H3_GeoBoundary, __construct);
-ZEND_METHOD(H3_GeoBoundary, getVertices);
+ZEND_METHOD(H3_H3DirectedEdge, __construct);
+ZEND_METHOD(H3_H3DirectedEdge, fromLong);
+ZEND_METHOD(H3_H3DirectedEdge, fromString);
+ZEND_METHOD(H3_H3DirectedEdge, isValid);
+ZEND_METHOD(H3_H3DirectedEdge, getOrigin);
+ZEND_METHOD(H3_H3DirectedEdge, getDestination);
+ZEND_METHOD(H3_H3DirectedEdge, getIndexes);
+ZEND_METHOD(H3_H3DirectedEdge, getBoundary);
+ZEND_METHOD(H3_H3DirectedEdge, getLength);
+ZEND_METHOD(H3_H3DirectedEdge, toLong);
+ZEND_METHOD(H3_H3DirectedEdge, toString);
+ZEND_METHOD(H3_H3DirectedEdge, __toString);
+ZEND_METHOD(H3_LatLng, __construct);
+ZEND_METHOD(H3_LatLng, getLat);
+ZEND_METHOD(H3_LatLng, getLon);
+ZEND_METHOD(H3_CellBoundary, __construct);
+ZEND_METHOD(H3_CellBoundary, getVertices);
ZEND_METHOD(H3_GeoPolygon, __construct);
ZEND_METHOD(H3_GeoPolygon, getGeofence);
ZEND_METHOD(H3_GeoPolygon, getHoles);
@@ -355,8 +355,8 @@ static const zend_function_entry class_H3_H3Index_methods[] = {
ZEND_ME(H3_H3Index, isNeighborTo, arginfo_class_H3_H3Index_isNeighborTo, ZEND_ACC_PUBLIC)
ZEND_ME(H3_H3Index, getLineTo, arginfo_class_H3_H3Index_getLineTo, ZEND_ACC_PUBLIC)
ZEND_ME(H3_H3Index, getDistanceTo, arginfo_class_H3_H3Index_getDistanceTo, ZEND_ACC_PUBLIC)
- ZEND_ME(H3_H3Index, getUnidirectionalEdges, arginfo_class_H3_H3Index_getUnidirectionalEdges, ZEND_ACC_PUBLIC)
- ZEND_ME(H3_H3Index, getUnidirectionalEdge, arginfo_class_H3_H3Index_getUnidirectionalEdge, ZEND_ACC_PUBLIC)
+ ZEND_ME(H3_H3Index, getDirectedEdges, arginfo_class_H3_H3Index_getDirectedEdges, ZEND_ACC_PUBLIC)
+ ZEND_ME(H3_H3Index, getDirectedEdge, arginfo_class_H3_H3Index_getDirectedEdge, ZEND_ACC_PUBLIC)
ZEND_ME(H3_H3Index, toParent, arginfo_class_H3_H3Index_toParent, ZEND_ACC_PUBLIC)
ZEND_ME(H3_H3Index, toChildren, arginfo_class_H3_H3Index_toChildren, ZEND_ACC_PUBLIC)
ZEND_ME(H3_H3Index, toCenterChild, arginfo_class_H3_H3Index_toCenterChild, ZEND_ACC_PUBLIC)
@@ -369,34 +369,34 @@ static const zend_function_entry class_H3_H3Index_methods[] = {
};
-static const zend_function_entry class_H3_H3UniEdge_methods[] = {
- ZEND_ME(H3_H3UniEdge, __construct, arginfo_class_H3_H3UniEdge___construct, ZEND_ACC_PUBLIC)
- ZEND_ME(H3_H3UniEdge, fromLong, arginfo_class_H3_H3UniEdge_fromLong, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
- ZEND_ME(H3_H3UniEdge, fromString, arginfo_class_H3_H3UniEdge_fromString, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
- ZEND_ME(H3_H3UniEdge, isValid, arginfo_class_H3_H3UniEdge_isValid, ZEND_ACC_PUBLIC)
- ZEND_ME(H3_H3UniEdge, getOrigin, arginfo_class_H3_H3UniEdge_getOrigin, ZEND_ACC_PUBLIC)
- ZEND_ME(H3_H3UniEdge, getDestination, arginfo_class_H3_H3UniEdge_getDestination, ZEND_ACC_PUBLIC)
- ZEND_ME(H3_H3UniEdge, getIndexes, arginfo_class_H3_H3UniEdge_getIndexes, ZEND_ACC_PUBLIC)
- ZEND_ME(H3_H3UniEdge, getBoundary, arginfo_class_H3_H3UniEdge_getBoundary, ZEND_ACC_PUBLIC)
- ZEND_ME(H3_H3UniEdge, getLength, arginfo_class_H3_H3UniEdge_getLength, ZEND_ACC_PUBLIC)
- ZEND_ME(H3_H3UniEdge, toLong, arginfo_class_H3_H3UniEdge_toLong, ZEND_ACC_PUBLIC)
- ZEND_ME(H3_H3UniEdge, toString, arginfo_class_H3_H3UniEdge_toString, ZEND_ACC_PUBLIC)
- ZEND_ME(H3_H3UniEdge, __toString, arginfo_class_H3_H3UniEdge___toString, ZEND_ACC_PUBLIC)
+static const zend_function_entry class_H3_H3DirectedEdge_methods[] = {
+ ZEND_ME(H3_H3DirectedEdge, __construct, arginfo_class_H3_H3DirectedEdge___construct, ZEND_ACC_PUBLIC)
+ ZEND_ME(H3_H3DirectedEdge, fromLong, arginfo_class_H3_H3DirectedEdge_fromLong, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+ ZEND_ME(H3_H3DirectedEdge, fromString, arginfo_class_H3_H3DirectedEdge_fromString, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+ ZEND_ME(H3_H3DirectedEdge, isValid, arginfo_class_H3_H3DirectedEdge_isValid, ZEND_ACC_PUBLIC)
+ ZEND_ME(H3_H3DirectedEdge, getOrigin, arginfo_class_H3_H3DirectedEdge_getOrigin, ZEND_ACC_PUBLIC)
+ ZEND_ME(H3_H3DirectedEdge, getDestination, arginfo_class_H3_H3DirectedEdge_getDestination, ZEND_ACC_PUBLIC)
+ ZEND_ME(H3_H3DirectedEdge, getIndexes, arginfo_class_H3_H3DirectedEdge_getIndexes, ZEND_ACC_PUBLIC)
+ ZEND_ME(H3_H3DirectedEdge, getBoundary, arginfo_class_H3_H3DirectedEdge_getBoundary, ZEND_ACC_PUBLIC)
+ ZEND_ME(H3_H3DirectedEdge, getLength, arginfo_class_H3_H3DirectedEdge_getLength, ZEND_ACC_PUBLIC)
+ ZEND_ME(H3_H3DirectedEdge, toLong, arginfo_class_H3_H3DirectedEdge_toLong, ZEND_ACC_PUBLIC)
+ ZEND_ME(H3_H3DirectedEdge, toString, arginfo_class_H3_H3DirectedEdge_toString, ZEND_ACC_PUBLIC)
+ ZEND_ME(H3_H3DirectedEdge, __toString, arginfo_class_H3_H3DirectedEdge___toString, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
-static const zend_function_entry class_H3_GeoCoord_methods[] = {
- ZEND_ME(H3_GeoCoord, __construct, arginfo_class_H3_GeoCoord___construct, ZEND_ACC_PUBLIC)
- ZEND_ME(H3_GeoCoord, getLat, arginfo_class_H3_GeoCoord_getLat, ZEND_ACC_PUBLIC)
- ZEND_ME(H3_GeoCoord, getLon, arginfo_class_H3_GeoCoord_getLon, ZEND_ACC_PUBLIC)
+static const zend_function_entry class_H3_LatLng_methods[] = {
+ ZEND_ME(H3_LatLng, __construct, arginfo_class_H3_LatLng___construct, ZEND_ACC_PUBLIC)
+ ZEND_ME(H3_LatLng, getLat, arginfo_class_H3_LatLng_getLat, ZEND_ACC_PUBLIC)
+ ZEND_ME(H3_LatLng, getLon, arginfo_class_H3_LatLng_getLon, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
-static const zend_function_entry class_H3_GeoBoundary_methods[] = {
- ZEND_ME(H3_GeoBoundary, __construct, arginfo_class_H3_GeoBoundary___construct, ZEND_ACC_PUBLIC)
- ZEND_ME(H3_GeoBoundary, getVertices, arginfo_class_H3_GeoBoundary_getVertices, ZEND_ACC_PUBLIC)
+static const zend_function_entry class_H3_CellBoundary_methods[] = {
+ ZEND_ME(H3_CellBoundary, __construct, arginfo_class_H3_CellBoundary___construct, ZEND_ACC_PUBLIC)
+ ZEND_ME(H3_CellBoundary, getVertices, arginfo_class_H3_CellBoundary_getVertices, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
@@ -452,11 +452,11 @@ static zend_class_entry *register_class_H3_H3Index(void)
return class_entry;
}
-static zend_class_entry *register_class_H3_H3UniEdge(void)
+static zend_class_entry *register_class_H3_H3DirectedEdge(void)
{
zend_class_entry ce, *class_entry;
- INIT_NS_CLASS_ENTRY(ce, "H3", "H3UniEdge", class_H3_H3UniEdge_methods);
+ INIT_NS_CLASS_ENTRY(ce, "H3", "H3DirectedEdge", class_H3_H3DirectedEdge_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ZEND_ACC_FINAL;
@@ -469,11 +469,11 @@ static zend_class_entry *register_class_H3_H3UniEdge(void)
return class_entry;
}
-static zend_class_entry *register_class_H3_GeoCoord(void)
+static zend_class_entry *register_class_H3_LatLng(void)
{
zend_class_entry ce, *class_entry;
- INIT_NS_CLASS_ENTRY(ce, "H3", "GeoCoord", class_H3_GeoCoord_methods);
+ INIT_NS_CLASS_ENTRY(ce, "H3", "LatLng", class_H3_LatLng_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ZEND_ACC_FINAL;
@@ -492,11 +492,11 @@ static zend_class_entry *register_class_H3_GeoCoord(void)
return class_entry;
}
-static zend_class_entry *register_class_H3_GeoBoundary(void)
+static zend_class_entry *register_class_H3_CellBoundary(void)
{
zend_class_entry ce, *class_entry;
- INIT_NS_CLASS_ENTRY(ce, "H3", "GeoBoundary", class_H3_GeoBoundary_methods);
+ INIT_NS_CLASS_ENTRY(ce, "H3", "CellBoundary", class_H3_CellBoundary_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ZEND_ACC_FINAL;
@@ -517,11 +517,11 @@ static zend_class_entry *register_class_H3_GeoPolygon(void)
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ZEND_ACC_FINAL;
- zend_string *property_geofence_class_H3_GeoBoundary = zend_string_init("H3\\GeoBoundary", sizeof("H3\\GeoBoundary")-1, 1);
+ zend_string *property_geofence_class_H3_CellBoundary = zend_string_init("H3\\CellBoundary", sizeof("H3\\CellBoundary")-1, 1);
zval property_geofence_default_value;
ZVAL_UNDEF(&property_geofence_default_value);
zend_string *property_geofence_name = zend_string_init("geofence", sizeof("geofence") - 1, 1);
- zend_declare_typed_property(class_entry, property_geofence_name, &property_geofence_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_geofence_class_H3_GeoBoundary, 0, 0));
+ zend_declare_typed_property(class_entry, property_geofence_name, &property_geofence_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_geofence_class_H3_CellBoundary, 0, 0));
zend_string_release(property_geofence_name);
zval property_holes_default_value;
diff --git a/h3_consts.php b/h3_consts.php
index 678839e..59faf02 100644
--- a/h3_consts.php
+++ b/h3_consts.php
@@ -15,3 +15,21 @@
const H3_LENGTH_UNIT_KM = 0;
const H3_LENGTH_UNIT_M = 1;
const H3_LENGTH_UNIT_RADS = 2;
+
+// H3 v4 error codes
+const H3_E_SUCCESS = 0;
+const H3_E_FAILED = 1;
+const H3_E_DOMAIN = 2;
+const H3_E_LATLNG_DOMAIN = 3;
+const H3_E_RES_DOMAIN = 4;
+const H3_E_CELL_INVALID = 5;
+const H3_E_DIR_EDGE_INVALID = 6;
+const H3_E_UNDIR_EDGE_INVALID = 7;
+const H3_E_VERTEX_INVALID = 8;
+const H3_E_PENTAGON = 9;
+const H3_E_DUPLICATE_INPUT = 10;
+const H3_E_NOT_NEIGHBORS = 11;
+const H3_E_RES_MISMATCH = 12;
+const H3_E_MEMORY_ALLOC = 13;
+const H3_E_MEMORY_BOUNDS = 14;
+const H3_E_OPTION_INVALID = 15;
diff --git a/tests/GeoBoundary___construct.phpt b/tests/CellBoundary___construct.phpt
similarity index 55%
rename from tests/GeoBoundary___construct.phpt
rename to tests/CellBoundary___construct.phpt
index 69222b0..7c4f110 100644
--- a/tests/GeoBoundary___construct.phpt
+++ b/tests/CellBoundary___construct.phpt
@@ -1,12 +1,12 @@
--TEST--
-H3\GeoBoundary::__construct() Test
+H3\CellBoundary::__construct() Test
--EXTENSIONS--
h3
--FILE--
getVertices()));
diff --git a/tests/GeoMultiPolygon___construct.phpt b/tests/GeoMultiPolygon___construct.phpt
index 6d082a7..c401b08 100644
--- a/tests/GeoMultiPolygon___construct.phpt
+++ b/tests/GeoMultiPolygon___construct.phpt
@@ -4,9 +4,9 @@ H3\GeoMultiPolygon::__construct() Test
h3
--FILE--
toGeoJson();
} catch (\Throwable $e) {
@@ -24,7 +24,7 @@ try {
try {
$multiPolygon = new \H3\GeoMultiPolygon([
- new \H3\GeoPolygon(new \H3\GeoBoundary(['invalid coord'])),
+ new \H3\GeoPolygon(new \H3\CellBoundary(['invalid coord'])),
]);
$multiPolygon->toGeoJson();
} catch (\Throwable $e) {
@@ -33,7 +33,7 @@ try {
try {
$multiPolygon = new \H3\GeoMultiPolygon([
- new \H3\GeoPolygon(new \H3\GeoBoundary([])),
+ new \H3\GeoPolygon(new \H3\CellBoundary([])),
]);
$multiPolygon->toGeoJson();
} catch (\Throwable $e) {
@@ -42,7 +42,7 @@ try {
try {
$multiPolygon = new \H3\GeoMultiPolygon([
- new \H3\GeoPolygon(new \H3\GeoBoundary([new \H3\GeoCoord(0, 0)])),
+ new \H3\GeoPolygon(new \H3\CellBoundary([new \H3\LatLng(0, 0)])),
'invalid polygon',
]);
$multiPolygon->toGeoJson();
diff --git a/tests/GeoPolygon___construct.phpt b/tests/GeoPolygon___construct.phpt
index aab76e1..0f2526f 100644
--- a/tests/GeoPolygon___construct.phpt
+++ b/tests/GeoPolygon___construct.phpt
@@ -4,9 +4,9 @@ H3\GeoPolygon::__construct() Test
h3
--FILE--
toString());
?>
diff --git a/tests/H3UniEdge___toString.phpt b/tests/H3DirectedEdge___toString.phpt
similarity index 53%
rename from tests/H3UniEdge___toString.phpt
rename to tests/H3DirectedEdge___toString.phpt
index 19f6a9c..a468f67 100644
--- a/tests/H3UniEdge___toString.phpt
+++ b/tests/H3DirectedEdge___toString.phpt
@@ -1,10 +1,10 @@
--TEST--
-H3\H3UniEdge::__toString() Test
+H3\H3DirectedEdge::__toString() Test
--EXTENSIONS--
h3
--FILE--
diff --git a/tests/H3UniEdge_fromString.phpt b/tests/H3DirectedEdge_fromLong.phpt
similarity index 52%
rename from tests/H3UniEdge_fromString.phpt
rename to tests/H3DirectedEdge_fromLong.phpt
index 9738240..4992d69 100644
--- a/tests/H3UniEdge_fromString.phpt
+++ b/tests/H3DirectedEdge_fromLong.phpt
@@ -1,10 +1,10 @@
--TEST--
-H3\H3UniEdge::fromString() Test
+H3\H3DirectedEdge::fromLong() Test
--EXTENSIONS--
h3
--FILE--
toString());
?>
diff --git a/tests/H3UniEdge_toString.phpt b/tests/H3DirectedEdge_fromString.phpt
similarity index 51%
rename from tests/H3UniEdge_toString.phpt
rename to tests/H3DirectedEdge_fromString.phpt
index 109ef8c..c7a80ee 100644
--- a/tests/H3UniEdge_toString.phpt
+++ b/tests/H3DirectedEdge_fromString.phpt
@@ -1,10 +1,10 @@
--TEST--
-H3\H3UniEdge::toString() Test
+H3\H3DirectedEdge::fromString() Test
--EXTENSIONS--
h3
--FILE--
toString());
?>
diff --git a/tests/H3UniEdge_getBoundary.phpt b/tests/H3DirectedEdge_getBoundary.phpt
similarity index 78%
rename from tests/H3UniEdge_getBoundary.phpt
rename to tests/H3DirectedEdge_getBoundary.phpt
index 08ba91e..ddc4f23 100644
--- a/tests/H3UniEdge_getBoundary.phpt
+++ b/tests/H3DirectedEdge_getBoundary.phpt
@@ -1,10 +1,10 @@
--TEST--
-H3\H3UniEdge::getBoundary() Test
+H3\H3DirectedEdge::getBoundary() Test
--EXTENSIONS--
h3
--FILE--
getBoundary();
var_dump(count($boundary->getVertices()));
diff --git a/tests/H3UniEdge_getDestination.phpt b/tests/H3DirectedEdge_getDestination.phpt
similarity index 58%
rename from tests/H3UniEdge_getDestination.phpt
rename to tests/H3DirectedEdge_getDestination.phpt
index b16d29f..3110697 100644
--- a/tests/H3UniEdge_getDestination.phpt
+++ b/tests/H3DirectedEdge_getDestination.phpt
@@ -1,10 +1,10 @@
--TEST--
-H3\H3UniEdge::getDestination() Test
+H3\H3DirectedEdge::getDestination() Test
--EXTENSIONS--
h3
--FILE--
getDestination();
var_dump($destination->toString());
diff --git a/tests/H3UniEdge_getIndexes.phpt b/tests/H3DirectedEdge_getIndexes.phpt
similarity index 71%
rename from tests/H3UniEdge_getIndexes.phpt
rename to tests/H3DirectedEdge_getIndexes.phpt
index 290777d..edc03f2 100644
--- a/tests/H3UniEdge_getIndexes.phpt
+++ b/tests/H3DirectedEdge_getIndexes.phpt
@@ -1,10 +1,10 @@
--TEST--
-H3\H3UniEdge::getIndexes() Test
+H3\H3DirectedEdge::getIndexes() Test
--EXTENSIONS--
h3
--FILE--
getIndexes();
[$origin, $destination] = $indexes;
diff --git a/tests/H3UniEdge_getLength.phpt b/tests/H3DirectedEdge_getLength.phpt
similarity index 54%
rename from tests/H3UniEdge_getLength.phpt
rename to tests/H3DirectedEdge_getLength.phpt
index 9503758..f5f692f 100644
--- a/tests/H3UniEdge_getLength.phpt
+++ b/tests/H3DirectedEdge_getLength.phpt
@@ -1,10 +1,10 @@
--TEST--
-H3\H3UniEdge::getLength() Test
+H3\H3DirectedEdge::getLength() Test
--EXTENSIONS--
h3
--FILE--
getLength(H3_AREA_UNIT_KM2));
?>
diff --git a/tests/H3UniEdge_getOrigin.phpt b/tests/H3DirectedEdge_getOrigin.phpt
similarity index 57%
rename from tests/H3UniEdge_getOrigin.phpt
rename to tests/H3DirectedEdge_getOrigin.phpt
index 0e27c3a..cfe193d 100644
--- a/tests/H3UniEdge_getOrigin.phpt
+++ b/tests/H3DirectedEdge_getOrigin.phpt
@@ -1,10 +1,10 @@
--TEST--
-H3\H3UniEdge::getOrigin() Test
+H3\H3DirectedEdge::getOrigin() Test
--EXTENSIONS--
h3
--FILE--
getOrigin();
var_dump($origin->toString());
diff --git a/tests/H3DirectedEdge_isValid.phpt b/tests/H3DirectedEdge_isValid.phpt
new file mode 100644
index 0000000..410b4ad
--- /dev/null
+++ b/tests/H3DirectedEdge_isValid.phpt
@@ -0,0 +1,15 @@
+--TEST--
+H3\H3DirectedEdge::isValid() Test
+--EXTENSIONS--
+h3
+--FILE--
+isValid());
+var_dump($invalid->isValid());
+?>
+--EXPECT--
+bool(true)
+bool(false)
diff --git a/tests/H3UniEdge___construct.phpt b/tests/H3DirectedEdge_toString.phpt
similarity index 54%
rename from tests/H3UniEdge___construct.phpt
rename to tests/H3DirectedEdge_toString.phpt
index 7eba0a9..8066142 100644
--- a/tests/H3UniEdge___construct.phpt
+++ b/tests/H3DirectedEdge_toString.phpt
@@ -1,10 +1,10 @@
--TEST--
-H3\H3UniEdge::__construct() Test
+H3\H3DirectedEdge::toString() Test
--EXTENSIONS--
h3
--FILE--
toString());
?>
diff --git a/tests/H3Index_fromGeo.phpt b/tests/H3Index_fromGeo.phpt
index f927784..4aa5b29 100644
--- a/tests/H3Index_fromGeo.phpt
+++ b/tests/H3Index_fromGeo.phpt
@@ -4,7 +4,7 @@ H3\H3Index::fromGeo() Test
h3
--FILE--
toString());
@@ -15,5 +15,5 @@ var_dump($h3Geo->getLon());
?>
--EXPECTF--
string(%d) "8811964009fffff"
-float(49.99549092422341)
-float(36.247513580515694)
+float(49.9954909242234%s)
+float(36.2475135805156%s)
diff --git a/tests/H3Index_getCellArea.phpt b/tests/H3Index_getCellArea.phpt
index fd6c58f..1a6666f 100644
--- a/tests/H3Index_getCellArea.phpt
+++ b/tests/H3Index_getCellArea.phpt
@@ -8,5 +8,5 @@ $h3 = new \H3\H3Index(0x85119643fffffff);
var_dump($h3->getCellArea(H3_AREA_UNIT_M2));
?>
---EXPECT--
-float(234305268.4166469)
+--EXPECTF--
+float(234305268.4166%s)
diff --git a/tests/H3Index_getUnidirectionalEdge.phpt b/tests/H3Index_getDirectedEdge.phpt
similarity index 66%
rename from tests/H3Index_getUnidirectionalEdge.phpt
rename to tests/H3Index_getDirectedEdge.phpt
index 3885d4d..534c2f1 100644
--- a/tests/H3Index_getUnidirectionalEdge.phpt
+++ b/tests/H3Index_getDirectedEdge.phpt
@@ -1,12 +1,12 @@
--TEST--
-H3\H3Index::getUnidirectionalEdge() Test
+H3\H3Index::getDirectedEdge() Test
--EXTENSIONS--
h3
--FILE--
getUnidirectionalEdge($destination);
+$edge = $origin->getDirectedEdge($destination);
var_dump($edge->toString());
?>
diff --git a/tests/H3Index_getUnidirectionalEdges.phpt b/tests/H3Index_getDirectedEdges.phpt
similarity index 77%
rename from tests/H3Index_getUnidirectionalEdges.phpt
rename to tests/H3Index_getDirectedEdges.phpt
index 4c36bf5..7a4aa63 100644
--- a/tests/H3Index_getUnidirectionalEdges.phpt
+++ b/tests/H3Index_getDirectedEdges.phpt
@@ -1,11 +1,11 @@
--TEST--
-H3\H3Index::getUnidirectionalEdges() Test
+H3\H3Index::getDirectedEdges() Test
--EXTENSIONS--
h3
--FILE--
getUnidirectionalEdges();
+$edges = $h3->getDirectedEdges();
foreach ($edges as $edge) {
var_dump($edge->toString());
diff --git a/tests/H3Index_kRing.phpt b/tests/H3Index_kRing.phpt
index f13eb75..ac0282c 100644
--- a/tests/H3Index_kRing.phpt
+++ b/tests/H3Index_kRing.phpt
@@ -4,7 +4,7 @@ H3\H3Index::kRing() Test
h3
--FILE--
kRing(1);
diff --git a/tests/H3Index_toGeoBoundary.phpt b/tests/H3Index_toGeoBoundary.phpt
index 005cdd7..128b166 100644
--- a/tests/H3Index_toGeoBoundary.phpt
+++ b/tests/H3Index_toGeoBoundary.phpt
@@ -4,7 +4,7 @@ H3\H3Index::toGeoBoundary() Test
h3
--FILE--
toGeoBoundary();
@@ -12,7 +12,7 @@ var_dump(count($boundary->getVertices()));
var_dump($boundary->getVertices()[0]->getLat());
var_dump($boundary->getVertices()[0]->getLon());
?>
---EXPECT--
+--EXPECTF--
int(6)
float(49.99513207773801)
-float(36.24067279957268)
+float(36.24067279957266%S)
diff --git a/tests/H3UniEdge_isValid.phpt b/tests/H3UniEdge_isValid.phpt
deleted file mode 100644
index a403d12..0000000
--- a/tests/H3UniEdge_isValid.phpt
+++ /dev/null
@@ -1,15 +0,0 @@
---TEST--
-H3\H3UniEdge::isValid() Test
---EXTENSIONS--
-h3
---FILE--
-isValid());
-var_dump($invalid->isValid());
-?>
---EXPECT--
-bool(true)
-bool(false)
diff --git a/tests/GeoCoord___construct.phpt b/tests/LatLng___construct.phpt
similarity index 59%
rename from tests/GeoCoord___construct.phpt
rename to tests/LatLng___construct.phpt
index ac58df2..14ef14b 100644
--- a/tests/GeoCoord___construct.phpt
+++ b/tests/LatLng___construct.phpt
@@ -1,10 +1,10 @@
--TEST--
-H3\GeoCoord::__construct() Test
+H3\LatLng::__construct() Test
--EXTENSIONS--
h3
--FILE--
getLat());
var_dump($geo->getLon());
diff --git a/tests/fn_edge_length.phpt b/tests/fn_edge_length.phpt
index 4475a1c..1aea5c1 100644
--- a/tests/fn_edge_length.phpt
+++ b/tests/fn_edge_length.phpt
@@ -20,7 +20,7 @@ try {
}
?>
--EXPECT--
-float(0.461354684)
-float(461.3546837)
+float(0.53141401)
+float(531.4140101)
bool(true)
bool(true)
diff --git a/tests/fn_h3_set_to_multi_polygon.phpt b/tests/fn_h3_set_to_multi_polygon.phpt
index 2320bda..d3dc477 100644
--- a/tests/fn_h3_set_to_multi_polygon.phpt
+++ b/tests/fn_h3_set_to_multi_polygon.phpt
@@ -18,38 +18,38 @@ foreach ($multiPolygon->getPolygons() as $i => $polygon) {
}
}
?>
---EXPECT--
+--EXPECTF--
int(0)
-float(37.784046222598775)
-float(-122.42708872508095)
-float(37.77226734985152)
-float(-122.43458610784575)
-float(37.76173573392154)
-float(-122.42576908738396)
-float(37.76298184766419)
-float(-122.40945463242252)
-float(37.75244647475627)
-float(-122.40063951171167)
-float(37.75368882535418)
-float(-122.38432356237523)
-float(37.76546768434345)
-float(-122.37681938644465)
-float(37.77600420067386)
-float(-122.38563455403627)
-float(37.7747607144902)
-float(-122.4019538515761)
-float(37.78529347359727)
-float(-122.41077092287512)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
int(1)
-float(49.9032631114296)
-float(36.245217108096654)
-float(49.93856707502108)
-float(36.36123536894076)
-float(50.02721542024701)
-float(36.374554973476705)
-float(50.0804922035258)
-float(36.27141860004053)
-float(50.04502776747484)
-float(36.15521929341623)
-float(49.956447234438116)
-float(36.14233727552816)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
+float(%f)
diff --git a/tests/fn_hex_area.phpt b/tests/fn_hex_area.phpt
index 99089f0..05653ab 100644
--- a/tests/fn_hex_area.phpt
+++ b/tests/fn_hex_area.phpt
@@ -20,7 +20,7 @@ try {
}
?>
--EXPECT--
-float(0.7373276)
-float(737327.6)
+float(0.7373275975944177)
+float(737327.5975944188)
bool(true)
bool(true)
diff --git a/tests/fn_point_dist.phpt b/tests/fn_point_dist.phpt
index e719edf..1874acc 100644
--- a/tests/fn_point_dist.phpt
+++ b/tests/fn_point_dist.phpt
@@ -4,14 +4,14 @@ H3\rads_to_degs() Test
h3
--FILE--
--EXPECT--
-float(409.4233686756976)
-float(409423.3686756976)
-float(0.06426352334085317)
+float(409.4233686756975)
+float(409423.3686756975)
+float(0.06426352334085315)
diff --git a/tests/fn_polyfill.phpt b/tests/fn_polyfill.phpt
index 865a695..0968d84 100644
--- a/tests/fn_polyfill.phpt
+++ b/tests/fn_polyfill.phpt
@@ -5,10 +5,10 @@ h3
--FILE--
new \H3\GeoCoord(37.813318999983238, -122.4089866999972145),
- 'test2' => new \H3\GeoCoord(37.7198061999978478, -122.3544736999993603),
- 'test2' => new \H3\GeoCoord(37.8151571999998453, -122.4798767000009008),
+ new \H3\CellBoundary([
+ 'test1' => new \H3\LatLng(37.813318999983238, -122.4089866999972145),
+ 'test2' => new \H3\LatLng(37.7198061999978478, -122.3544736999993603),
+ 'test2' => new \H3\LatLng(37.8151571999998453, -122.4798767000009008),
])
);
@@ -20,14 +20,14 @@ try {
}
try {
- \H3\polyfill(new \H3\GeoPolygon(new \H3\GeoBoundary(['invalid data'])), 7);
+ \H3\polyfill(new \H3\GeoPolygon(new \H3\CellBoundary(['invalid data'])), 7);
var_dump(true);
} catch (\Throwable $e) {
var_dump(false);
}
try {
- \H3\polyfill(new \H3\GeoPolygon(new \H3\GeoBoundary([null])), 7);
+ \H3\polyfill(new \H3\GeoPolygon(new \H3\CellBoundary([null])), 7);
var_dump(true);
} catch (\Throwable $e) {
var_dump(false);
diff --git a/tests/fn_rads_to_degs.phpt b/tests/fn_rads_to_degs.phpt
index a92b786..c2d0afc 100644
--- a/tests/fn_rads_to_degs.phpt
+++ b/tests/fn_rads_to_degs.phpt
@@ -7,4 +7,4 @@ h3
var_dump(\H3\rads_to_degs(3.14159));
?>
--EXPECT--
-float(179.99984796050427)
+float(179.9998479605043)
diff --git a/tests/ini_validate_index_false.phpt b/tests/ini_validate_index_false.phpt
index 290c5ed..8c6dc86 100644
--- a/tests/ini_validate_index_false.phpt
+++ b/tests/ini_validate_index_false.phpt
@@ -21,14 +21,14 @@ try {
}
try {
- \H3\H3UniEdge::fromLong(0x85283473fffffff);
+ \H3\H3DirectedEdge::fromLong(0x85283473fffffff);
var_dump(true);
} catch (\H3\H3Exception $e) {
var_dump(false);
}
try {
- \H3\H3UniEdge::fromLong(0x115283473fffffff);
+ \H3\H3DirectedEdge::fromLong(0x115283473fffffff);
var_dump(true);
} catch (\H3\H3Exception $e) {
var_dump(false);
diff --git a/tests/ini_validate_index_true.phpt b/tests/ini_validate_index_true.phpt
index bd6b894..d55d7fd 100644
--- a/tests/ini_validate_index_true.phpt
+++ b/tests/ini_validate_index_true.phpt
@@ -21,14 +21,14 @@ try {
}
try {
- \H3\H3UniEdge::fromLong(0x85283473fffffff);
+ \H3\H3DirectedEdge::fromLong(0x85283473fffffff);
var_dump(true);
} catch (\H3\H3Exception $e) {
var_dump(false);
}
try {
- \H3\H3UniEdge::fromLong(0x115283473fffffff);
+ \H3\H3DirectedEdge::fromLong(0x115283473fffffff);
var_dump(true);
} catch (\H3\H3Exception $e) {
var_dump(false);
diff --git a/tests/ini_validate_res_false.phpt b/tests/ini_validate_res_false.phpt
index 56a5784..ea38b26 100644
--- a/tests/ini_validate_res_false.phpt
+++ b/tests/ini_validate_res_false.phpt
@@ -14,4 +14,4 @@ try {
}
?>
--EXPECT--
-bool(true)
+bool(false)