Skip to content

Commit c7c3057

Browse files
committed
Updated for Neo4j 5.11
Modified the functions com.neo4jh3.pointash3String and com.neo4jh3.pointash3 to accept a lat/lon or lon/lat parameter Updated for Neo4j 5.11 Fixed a documentation bug Fixed some tests so they would work on Windows
1 parent 39c65de commit c7c3057

File tree

5 files changed

+134
-50
lines changed

5 files changed

+134
-50
lines changed

CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
# CHANGELOG - Neo4jH3
22

3-
## 5.10 2023-0809
3+
## 5.11 2023-08-18
4+
* [Added] Tested through Neo4j 5.11
5+
* [Updated] Updated the com.neo4jh3.pointash3String and com.neo4jh3.pointash3 functions to take a 3rd parameter to indicate if the point is in lat/lon format or lon/lat format.
6+
* [Updated] Updated tests to address issues between Linux and Windows
7+
8+
## 5.10 2023-08-09
49

510
* [Added] Tested through Neo4j 5.10
611
* [Updated] Bumped org.apache.commons.commons-lang3 to 3.13.0
712

8-
## 5.8 2023-0519
13+
## 5.8 2023-05-19
914

1015
* [Added] Tested through Neo4j 5.8
1116
* [Added] Added support for converting a LINESTRING geospatial object to H3 number - com.neo4jh3.lineash3

Documentation.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ If resolutionExpr is smaller than 0 or larger than 15, the function returns -2
943943
RETURN com.neo4jh3.multilineash3String('MULTILINESTRING((37.2713558667319 -121.91508032705622), (37.353926450852256 -121.86222328902491))',16) AS value
944944
-2
945945

946-
## com.neo4jh3.pointash3( geographyExpr, resolutionExpr )
946+
## com.neo4jh3.pointash3( geographyExpr, resolutionExpr, LatLonOrder )
947947
Returns the H3 cell ID (as a LONG) corresponding to the provided point at the specified resolution.
948948

949949
### Syntax
@@ -952,6 +952,7 @@ RETURN com.neo4jh3.pointash3( geographyExpr, resolutionExpr )
952952
### Arguments
953953
* geographyExpr: A LONG expression representing a point geography in WKT format
954954
* resolutionExpr: An INT expression, whose value is expected to be between 0 and 15 inclusive, specifying the resolution of the child H3 cell ID.
955+
* LatLonOrder A STRING that indicates the order of the geometry (latlon or lonlat)
955956

956957
### Returns
957958
Returns the H3 cell ID (as a LONG) corresponding to the provided point at the specified resolution.
@@ -962,16 +963,16 @@ If geographyExpr is of type STRING and the value is either an invalid WKT or doe
962963
If resolutionExpr is smaller than 0 or larger than 15, the function returns -2
963964

964965
### Example
965-
RETURN com.neo4jh3.pointash3('POINT(37.8199 -122.4783)',13) AS value
966+
RETURN com.neo4jh3.pointash3('POINT(37.8199 -122.4783)',13, 'latlon') AS value
966967
635714569676958015
967968

968-
RETURN com.neo4jh3.pointash3('zzz(37.8199 -122.4783)',13) AS value
969+
RETURN com.neo4jh3.pointash3('zzz(37.8199 -122.4783)',13, 'latlon') AS value
969970
-1
970971

971-
RETURN com.neo4jh3.maxChildString('POINT(37.8199 -122.4783)',16) AS value
972+
RETURN com.neo4jh3.pointash3('POINT(37.8199 -122.4783)',16, 'latlon') AS value
972973
-2
973974

974-
## com.neo4jh3.pointash3String( geographyExpr, resolutionExpr )
975+
## com.neo4jh3.pointash3String( geographyExpr, resolutionExpr, LatLonOrder )
975976
Returns the H3 cell ID (as a STRING) corresponding to the provided point at the specified resolution.
976977

977978
### Syntax
@@ -980,6 +981,7 @@ RETURN com.neo4jh3.pointash3String( geographyExpr, resolutionExpr )
980981
### Arguments
981982
* geographyExpr: A STRING expression representing a point geography in WKT format
982983
* resolutionExpr: An INT expression, whose value is expected to be between 0 and 15 inclusive, specifying the resolution of the child H3 cell ID.
984+
* LatLonOrder A STRING that indicates the order of the geometry (latlon or lonlat)
983985

984986
### Returns
985987
Returns the H3 cell ID (as a STRING) corresponding to the provided point at the specified resolution.
@@ -990,13 +992,13 @@ If geographyExpr is of type STRING and the value is either an invalid WKT or doe
990992
If resolutionExpr is smaller than 0 or larger than 15, the function returns -2
991993

992994
### Example
993-
RETURN com.neo4jh3.pointash3String('POINT(37.8199 -122.4783)',13) AS value
995+
RETURN com.neo4jh3.pointash3String('POINT(37.8199 -122.4783)',13, 'latlon') AS value
994996
8d283087022a93f
995997

996-
RETURN com.neo4jh3.pointash3String('zzz(37.8199 -122.4783)',13) AS value
998+
RETURN com.neo4jh3.pointash3String('zzz(37.8199 -122.4783)',13, 'latlon') AS value
997999
-1
9981000

999-
RETURN com.neo4jh3. pointash3String('POINT(37.8199 -122.4783)',16) AS value
1001+
RETURN com.neo4jh3.pointash3String('POINT(37.8199 -122.4783)',16, 'latlon') AS value
10001002
-2
10011003

10021004
## com.neo4jh3.stringToH3( h3CellIdExpr )

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
<groupId>com.neo4jh3</groupId>
88
<artifactId>neo4jh3</artifactId>
9-
<version>5.10.0</version>
9+
<version>5.11.0</version>
1010

1111
<properties>
12-
<neo4j.version>5.10.0</neo4j.version>
12+
<neo4j.version>5.11.0</neo4j.version>
1313
<csv.version>1.2</csv.version>
1414
<lang3.version>3.13.0</lang3.version>
1515
<uber.version>4.1.1</uber.version>

src/main/java/com/neo4jh3/uber/Uberh3.java

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -679,10 +679,11 @@ public String maxChild(@Name("fromHexAddress") String fromHexAddress, @Name("h3R
679679

680680
// Geography Functions
681681
@UserFunction(name = "com.neo4jh3.pointash3")
682-
@Description("com.neo4jh3.pointash3(wktString, resolution) - Provides the distance in grid cells between the two indexes.")
682+
@Description("com.neo4jh3.pointash3(wktString, resolution, latlon order) - Provides the distance in grid cells between the two indexes.")
683683
public Long pointash3(
684684
@Name("wktString") String wktString,
685-
@Name("h3Res") Long h3Res) throws InterruptedException
685+
@Name("h3Res") Long h3Res,
686+
@Name("latlonorder") String latlonorder) throws InterruptedException
686687
{
687688
Long h3Address = 0L;
688689
if (h3 == null) {
@@ -694,8 +695,17 @@ public Long pointash3(
694695
try {
695696
if (h3Resolution > 0 && h3Resolution <= 15) {
696697
Geometry geometry = GeometryReader.readGeometry(wktString);
697-
if (geometry.getGeometryType().toString().equalsIgnoreCase("Point")){
698-
h3Address=h3.latLngToCell(geometry.getEnvelope().getMinX(), geometry.getEnvelope().getMinY(), h3Resolution);
698+
System.out.println(geometry.getEnvelope().getMinX());
699+
System.out.println(geometry.getEnvelope().getMinY());
700+
701+
if (latlonorder.equalsIgnoreCase("latlon")){
702+
if (geometry.getGeometryType().toString().equalsIgnoreCase("Point")){
703+
h3Address=h3.latLngToCell(geometry.getEnvelope().getMinX(), geometry.getEnvelope().getMinY(), h3Resolution);
704+
}
705+
} else {
706+
if (geometry.getGeometryType().toString().equalsIgnoreCase("Point")){
707+
h3Address=h3.latLngToCell(geometry.getEnvelope().getMinY(), geometry.getEnvelope().getMinX(), h3Resolution);
708+
}
699709
}
700710
} else {
701711
h3Address = -2L;
@@ -709,10 +719,11 @@ public Long pointash3(
709719
return h3Address;
710720
}
711721
@UserFunction(name = "com.neo4jh3.pointash3String")
712-
@Description("com.neo4jh3.pointash3String(wktString, resolution) - Provides the distance in grid cells between the two indexes.")
722+
@Description("com.neo4jh3.pointash3String(wktString, resolution, latlon order) - Provides the distance in grid cells between the two indexes.")
713723
public String pointash3String(
714724
@Name("wktString") String wktString,
715-
@Name("h3Res") Long h3Res) throws InterruptedException
725+
@Name("h3Res") Long h3Res,
726+
@Name("latlonorder") String latlonorder) throws InterruptedException
716727
{
717728
String h3Address = "";
718729
if (h3 == null) {
@@ -724,8 +735,14 @@ public String pointash3String(
724735
try {
725736
if (h3Resolution > 0 && h3Resolution <= 15) {
726737
Geometry geometry = GeometryReader.readGeometry(wktString);
727-
if (geometry.getGeometryType().toString().equalsIgnoreCase("Point")){
728-
h3Address=h3.latLngToCellAddress(geometry.getEnvelope().getMinX(), geometry.getEnvelope().getMinY(), h3Resolution);
738+
if (latlonorder.equalsIgnoreCase("latlon")){
739+
if (geometry.getGeometryType().toString().equalsIgnoreCase("Point")){
740+
h3Address=h3.latLngToCellAddress(geometry.getEnvelope().getMinX(), geometry.getEnvelope().getMinY(), h3Resolution);
741+
}
742+
} else {
743+
if (geometry.getGeometryType().toString().equalsIgnoreCase("Point")){
744+
h3Address=h3.latLngToCellAddress(geometry.getEnvelope().getMinY(), geometry.getEnvelope().getMinX(), h3Resolution);
745+
}
729746
}
730747
} else {
731748
h3Address = "-2";

0 commit comments

Comments
 (0)