Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ file [H3Core.java](./src/main/java/com/uber/h3core/H3Core.java), and support
for the Linux x64 and Darwin x64 platforms.

## Unreleased Changes
### Added
- `reverseDirectedEdge` function. (#207)

### Changed
- Upgraded the core library to v4.5.0. (#207)

## [4.4.0] - 2025-12-12
### Added
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Coverage Status](https://coveralls.io/repos/github/uber/h3-java/badge.svg?branch=master)](https://coveralls.io/github/uber/h3-java?branch=master)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.uber/h3/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.uber/h3)
[![H3 Version](https://img.shields.io/badge/h3-v4.4.1-blue.svg)](https://github.com/uber/h3/releases/tag/v4.4.1)
[![H3 Version](https://img.shields.io/badge/h3-v4.5.0-blue.svg)](https://github.com/uber/h3/releases/tag/v4.5.0)

This library provides Java bindings for the [H3 Core Library](https://github.com/uber/h3). For API reference, please see the [H3 Documentation](https://h3geo.org/).

Expand All @@ -18,14 +18,14 @@ Add it to your pom.xml:
<dependency>
<groupId>com.uber</groupId>
<artifactId>h3</artifactId>
<version>4.4.0</version>
<version>4.5.0</version>
</dependency>
```

Or, using Gradle:

```gradle
compile("com.uber:h3:4.4.0")
compile("com.uber:h3:4.5.0")
```

Encode a location into a hexagon address:
Expand Down
2 changes: 1 addition & 1 deletion h3version.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
h3.git.reference=v4.4.1
h3.git.reference=v4.5.0
17 changes: 17 additions & 0 deletions src/main/c/h3-java/src/jniapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,23 @@ Java_com_uber_h3core_NativeMethods_directedEdgeToBoundary(JNIEnv *env,
}
}

/*
* Class: com_uber_h3core_NativeMethods
* Method: reverseDirectedEdge
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL Java_com_uber_h3core_NativeMethods_reverseDirectedEdge(
JNIEnv *env, jobject thiz, jlong h3) {
H3Index out;
H3Error err = reverseDirectedEdge(h3, &out);
if (err) {
ThrowH3Exception(env, err);
return -1;
}

return out;
}

/*
* Class: com_uber_h3core_NativeMethods
* Method: maxFaceCount
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/uber/h3core/H3Core.java
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,16 @@ public List<LatLng> directedEdgeToBoundary(String h3) {
return directedEdgeToBoundary(stringToH3(h3));
}

/** Returns the directed edge with origin and destination cells reversed. */
public long reverseDirectedEdge(long h3) {
return h3Api.reverseDirectedEdge(h3);
}

/** Returns the directed edge with origin and destination cells reversed. */
public String reverseDirectedEdge(String h3) {
return h3ToString(reverseDirectedEdge(stringToH3(h3)));
}

/**
* Find all icosahedron faces intersected by a given H3 index, represented as integers from 0-19.
*
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/uber/h3core/NativeMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ native void polygonToCells(

native int directedEdgeToBoundary(long h3, double[] verts);

native long reverseDirectedEdge(long h3);

native int maxFaceCount(long h3);

native void getIcosahedronFaces(long h3, int[] faces);
Expand Down
4 changes: 4 additions & 0 deletions src/test/java/com/uber/h3core/TestDirectedEdges.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ void unidirectionalEdges() {

List<LatLng> boundary = h3.directedEdgeToBoundary(edge);
assertEquals(2, boundary.size());

String reversed = h3.reverseDirectedEdge(edge);
assertEquals(adjacent, h3.getDirectedEdgeOrigin(reversed));
assertEquals(start, h3.getDirectedEdgeDestination(reversed));
}

@Test
Expand Down
Loading