Skip to content

Commit

Permalink
Added in two additional procedures and updated documentation
Browse files Browse the repository at this point in the history
Added in two additional procedures and updated documentation
  • Loading branch information
davidfauth committed Jun 6, 2024
1 parent 17d26bd commit 784b0f5
Show file tree
Hide file tree
Showing 7 changed files with 1,289 additions and 955 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# CHANGELOG - 5.19.1 - 2024-06-05
* [Added] - Added two new procedures to read a WKT polygon file and return the Hex Addresss. These are com.neo4jh3.polygonash3 and com.neo4jh3.polygonash3String. These procedures expect the POLYGON in Longitude, Latitude order.
* [Updated] - Updated Documentation with bug fixes.
* [Updated] - Added optional LatLon argument to com.neo4jh3.multilineash3, com.neo4jh3.multilineash3String, com.neo4jh3.lineash3, and com.neo4jh3.lineash3String

# CHANGELOG - 5.19 - 2024-04-15
* [Updated] - Tested through Neo4j 5.19

Expand Down
165 changes: 111 additions & 54 deletions Documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ If resolutionExpr is an invalid resolution or smaller than h3_resolution(h3CellI
Returns the H3 cell ID (as a LONG) corresponding to the provided point at the specified resolution.

### Syntax
RETURN com.neo4jh3.pointash3( geographyExpr, resolutionExpr )
RETURN com.neo4jh3.pointash3( geographyExpr, resolutionExpr, LatLonOrder )

### Arguments
* geographyExpr: A LONG expression representing a point geography in WKT format
Expand Down Expand Up @@ -932,7 +932,7 @@ If resolutionExpr is smaller than 0 or larger than 15, the function returns -2
Returns the H3 cell ID (as a STRING) corresponding to the provided point at the specified resolution.

### Syntax
RETURN com.neo4jh3.pointash3String( geographyExpr, resolutionExpr )
RETURN com.neo4jh3.pointash3String( geographyExpr, resolutionExpr, LatLonOrder )

### Arguments
* geographyExpr: A STRING expression representing a point geography in WKT format
Expand Down Expand Up @@ -980,6 +980,45 @@ If h3CellIdExpr is not a valid H3 cell ID, the function returns -1.
-1
# Procedures
## com.neo4jh3.compact( h3CellIdsExpr )
Compacts the input set of H3 cells. The compacted set covers the same set of H3 cells as the original one.

### Syntax
CALL com.neo4jh3.compact( h3CellIdsExpr );

### Arguments
* h3CellIdsExpr: A LIST of LONG expressions representing H3 cell IDs.

### Returns
An LIST of H3 cell IDs of the same type as the values in the input LIST expression h3CellIdsExpr.

### Error conditions


### Example
CALL com.neo4jh3.compact([599686042433355775,599686030622195711,599686044580839423,599686038138388479,599686043507097599,599686015589810175,599686014516068351,599686034917163007,599686029548453887,599686032769679359,599686198125920255,599686040285872127,599686041359613951,599686039212130303,599686023106002943,599686027400970239,599686013442326527,599686012368584703,599686018811035647]) yield value return value;
599686030622195711,599686015589810175,599686014516068351,599686034917163007,599686029548453887,599686032769679359,599686198125920255,599686023106002943,599686027400970239,599686013442326527,599686012368584703,599686018811035647,595182446027210751

## com.neo4jh3.compactString( h3CellIdsExpr )
Compacts the input set of H3 cells. The compacted set covers the same set of H3 cells as the original one.

### Syntax
CALL com.neo4jh3.compactString( h3CellIdsExpr );

### Arguments
* h3CellIdsExpr: A LIST of STRING expressions representing H3 cell IDs.

### Returns
An LIST of H3 cell IDs of the same type as the values in the input LIST expression h3CellIdsExpr.

### Error conditions


### Example
CALL com.neo4jh3.compactString(['85283473fffffff', '85283447fffffff', '8528347bfffffff', '85283463fffffff', '85283477fffffff', '8528340ffffffff', '8528340bfffffff', '85283457fffffff', '85283443fffffff', '8528344ffffffff', '852836b7fffffff', '8528346bfffffff', '8528346ffffffff', '85283467fffffff', '8528342bfffffff', '8528343bfffffff', '85283407fffffff', '85283403fffffff', '8528341bfffffff']) yield value return value;

"85283447fffffff", "8528340ffffffff", "8528340bfffffff", "85283457fffffff", "85283443fffffff", "8528344ffffffff", "852836b7fffffff", "8528342bfffffff", "8528343bfffffff", "85283407fffffff", "85283403fffffff", "8528341bfffffff", "8428347ffffffff"

## com.neo4jh3.gridDisk( h3CellIdExpr, kExpr )
Returns the H3 cells that are within (grid) distance k of the origin cell. The set of these H3 cells is called the k-ring of the origin cell.

Expand Down Expand Up @@ -1049,7 +1088,7 @@ call com.neo4jh3.lineash3( geographyExpr, resolutionExpr ) yield value
Returns a list of H3 cell IDs (as a LONG) corresponding to the provided point at the specified resolution.

### Error conditions
If geographyExpr is of type STRING and the value is either an invalid WKT or does not represent a point, the function returns -1
If geographyExpr is of type STRING and the value is either an invalid WKT or does not represent a LINESTRING, the function returns -1

If resolutionExpr is smaller than 0 or larger than 15, the function returns -2

Expand Down Expand Up @@ -1077,7 +1116,7 @@ RETURN com.neo4jh3.lineash3String( geographyExpr, resolutionExpr )
Returns a list of H3 cell IDs (as a STRING) corresponding to the provided LINESTRING at the specified resolution.

### Error conditions
If geographyExpr is of type STRING and the value is either an invalid WKT or does not represent a point, the function returns -1
If geographyExpr is of type STRING and the value is either an invalid WKT or does not represent a LINESTRING, the function returns -1

If resolutionExpr is smaller than 0 or larger than 15, the function returns -2

Expand All @@ -1091,7 +1130,7 @@ If resolutionExpr is smaller than 0 or larger than 15, the function returns -2
call com.neo4jh3.lineash3String('LINESTRING((37.2713558667319 -121.91508032705622), (37.353926450852256 -121.86222328902491))',16) yield value return value
-2

## com.neo4jh3.multilineash3( geographyExpr, resolutionExpr )
## com.neo4jh3.multilineash3( geographyExpr, resolutionExpr, LatLonOrder )
Returns the H3 cell ID (as a LONG) corresponding to the provided MULTILINESTRING at the specified resolution.

### Syntax
Expand All @@ -1100,26 +1139,27 @@ RETURN com.neo4jh3.multilineash3( geographyExpr, resolutionExpr )
### Arguments
* geographyExpr: A STRING expression representing a MULTILINESTRING geography in WKT format
* resolutionExpr: An INT expression, whose value is expected to be between 0 and 15 inclusive, specifying the resolution of the child H3 cell ID.
* LatLonOrder A STRING that indicates the order of the geometry (latlon or lonlat)

### Returns
Returns the H3 cell ID (as a LONG) corresponding to the provided point at the specified resolution.

### Error conditions
If geographyExpr is of type STRING and the value is either an invalid WKT or does not represent a point, the function returns -1
If geographyExpr is of type STRING and the value is either an invalid WKT or does not represent a MULTILINESTRING, the function returns -1

If resolutionExpr is smaller than 0 or larger than 15, the function returns -2

### Example
CALL com.neo4jh3.multilineash3('MULTILINESTRING((37.2713558667319 -121.91508032705622), (37.353926450852256 -121.86222328902491))',6) yield value return value;
CALL com.neo4jh3.multilineash3('MULTILINESTRING((37.2713558667319 -121.91508032705622), (37.353926450852256 -121.86222328902491))',6, 'latlon') yield value return value;
604189629981130751, 604189629444259839, 604189629444259839

call com.neo4jh3.multilineash3('ZZZ((37.271355 -121.915080), (37.353926 -121.862223))',7) yield value return value
call com.neo4jh3.multilineash3('ZZZ((37.271355 -121.915080), (37.353926 -121.862223))',7, 'latlon') yield value return value
-1

call com.neo4jh3.multilineash3('MULTILINESTRING((40.736691045913472 73.99311953429248), (40.73733046783797 -73.99265431029018) , (40.93733046783797 -74.00265431029018))',17) yield value return value
call com.neo4jh3.multilineash3('MULTILINESTRING((40.736691045913472 73.99311953429248), (40.73733046783797 -73.99265431029018) , (40.93733046783797 -74.00265431029018))',17, 'latlon') yield value return value
-2

## com.neo4jh3.multilineash3String( geographyExpr, resolutionExpr )
## com.neo4jh3.multilineash3String( geographyExpr, resolutionExpr, LatLonOrder )
Returns the H3 cell ID (as a STRING) corresponding to the provided MULTILINESTRING at the specified resolution.

### Syntax
Expand All @@ -1128,26 +1168,83 @@ call com.neo4jh3.multilineash3String( geographyExpr, resolutionExpr ) yield valu
### Arguments
* geographyExpr: A STRING expression representing a MULTILINESTRING geography in WKT format
* resolutionExpr: An INT expression, whose value is expected to be between 0 and 15 inclusive, specifying the resolution of the child H3 cell ID.
* LatLonOrder A STRING that indicates the order of the geometry (latlon or lonlat)


### Returns
Returns the H3 cell ID (as a STRING) corresponding to the provided MULTILINESTRING at the specified resolution.

### Error conditions
If geographyExpr is of type STRING and the value is either an invalid WKT or does not represent a point, the function returns -1
If geographyExpr is of type STRING and the value is either an invalid WKT or does not represent a MULTILINESTRING, the function returns -1

If resolutionExpr is smaller than 0 or larger than 15, the function returns -2

### Example
CALL com.neo4jh3.multilineash3String('MULTILINESTRING((37.2713558667319 -121.91508032705622), (37.353926450852256 -121.86222328902491))',6) yield value return value;
CALL com.neo4jh3.multilineash3String('MULTILINESTRING((37.2713558667319 -121.91508032705622), (37.353926450852256 -121.86222328902491))',6, 'latlon') yield value return value;
'86283446fffffff', '86283444fffffff', '86283444fffffff'

call com.neo4jh3.multilineash3String('ZZZ((37.271355 -121.915080), (37.353926 -121.862223))',7) yield value return value
call com.neo4jh3.multilineash3String('ZZZ((37.271355 -121.915080), (37.353926 -121.862223))',7, 'latlon') yield value return value
'-1'

call com.neo4jh3.multilineash3String('MULTILINESTRING((40.736691045913472 73.99311953429248), (40.73733046783797 -73.99265431029018) , (40.93733046783797 -74.00265431029018))',17) yield value return value
call com.neo4jh3.multilineash3String('MULTILINESTRING((40.736691045913472 73.99311953429248), (40.73733046783797 -73.99265431029018) , (40.93733046783797 -74.00265431029018))',17, 'latlon') yield value return value
'-2'

## com.neo4jh3.polygonash3( geographyExpr, resolutionExpr )
Returns a list of H3 cell IDs (as a LONG) corresponding to the provided POLYGON at the specified resolution.

### Syntax
call com.neo4jh3. polygonash3( geographyExpr, resolutionExpr ) yield value

### Arguments
* geographyExpr: A STRING expression representing a POLYGON geography in WKT format (Longitude and then Latitude)
* resolutionExpr: An INT expression, whose value is expected to be between 0 and 15 inclusive, specifying the resolution of the child H3 cell ID.

### Returns
Returns a list of H3 cell IDs (as a LONG) corresponding to the provided point at the specified resolution.

### Error conditions
If geographyExpr is of type STRING and the value is either an invalid WKT or does not represent a POLYGON, the function returns -1

If resolutionExpr is smaller than 0 or larger than 15, the function returns -2

### Example
call com.neo4jh3.polygonash3('POLYGON((-77.436031 38.471420, -77.395123 38.536569, -77.294124 38.511703, -77.310611 38.395709, -77.436031 38.471420))',6) yield value return value
604233031162527743, 604233025391165439, 604233031699398655

call com.neo4jh3.polygonash3('ZZZ((-77.436031 38.471420, -77.395123 38.536569, -77.294124 38.511703, -77.310611 38.395709, -77.436031 38.471420))',7) yield value return value
-1

call com.neo4jh3.polygonash3('POLYGON((-77.436031 38.471420, -77.395123 38.536569, -77.294124 38.511703, -77.310611 38.395709, -77.436031 38.471420))',16) yield value return value
-2

## com.neo4jh3.polygonash3String( geographyExpr, resolutionExpr )
Returns a list of H3 cell IDs (as a STRING) corresponding to the provided POLYGON at the specified resolution.

### Syntax
RETURN com.neo4jh3. polygonash3String( geographyExpr, resolutionExpr )

### Arguments
* geographyExpr: A STRING expression representing a POLYGON geography in WKT format (Longitude and then Latitude)
* resolutionExpr: An INT expression, whose value is expected to be between 0 and 15 inclusive, specifying the resolution of the child H3 cell ID.

### Returns
Returns a list of H3 cell IDs (as a STRING) corresponding to the provided POLYGON at the specified resolution.

### Error conditions
If geographyExpr is of type STRING and the value is either an invalid WKT or does not represent a polygon, the function returns -1

If resolutionExpr is smaller than 0 or larger than 15, the function returns -2

### Example
call com.neo4jh3.polygonash3String('POLYGON((-77.436031 38.471420, -77.395123 38.536569, -77.294124 38.511703, -77.310611 38.395709, -77.436031 38.471420))',6) yield value return value
'862aabd8fffffff','862aabc37ffffff','862aabdafffffff'
call com.neo4jh3. polygonash3String('ZZZPOLYGON((-77.436031 38.471420, -77.395123 38.536569, -77.294124 38.511703, -77.310611 38.395709, -77.436031 38.471420))',7) yield value return value
-1

call com.neo4jh3.polygonash3String('POLYGON((-77.436031 38.471420, -77.395123 38.536569, -77.294124 38.511703, -77.310611 38.395709, -77.436031 38.471420))',16) yield value return value
-2

## com.neo4jh3.polygonToCells( ListOuterGeography, ListHoleGeography, resolutionExpr, LatLonOrder )
Returns a list of H3 cell IDs (represented as LONGs) corresponding to hexagons or pentagons, of the specified resolution, that are contained by the input area geography.

Expand Down Expand Up @@ -1197,45 +1294,6 @@ If resolutionExpr is invalid, the function returns -2
call com.neo4jh3.polygonToCellsString(['37.7866,-122.3805','37.7198,-122.3544','37.7076,-122.5123','37.7835,-122.5247','37.8151,-122.4798'],[],20,'latlon') yield value return value
-2

## com.neo4jh3.compact( h3CellIdsExpr )
Compacts the input set of H3 cells. The compacted set covers the same set of H3 cells as the original one.

### Syntax
CALL com.neo4jh3.compact( h3CellIdsExpr );

### Arguments
* h3CellIdsExpr: A LIST of LONG expressions representing H3 cell IDs.

### Returns
An LIST of H3 cell IDs of the same type as the values in the input LIST expression h3CellIdsExpr.

### Error conditions


### Example
CALL com.neo4jh3.compact([599686042433355775,599686030622195711,599686044580839423,599686038138388479,599686043507097599,599686015589810175,599686014516068351,599686034917163007,599686029548453887,599686032769679359,599686198125920255,599686040285872127,599686041359613951,599686039212130303,599686023106002943,599686027400970239,599686013442326527,599686012368584703,599686018811035647]) yield value return value;
599686030622195711,599686015589810175,599686014516068351,599686034917163007,599686029548453887,599686032769679359,599686198125920255,599686023106002943,599686027400970239,599686013442326527,599686012368584703,599686018811035647,595182446027210751

## com.neo4jh3.compactString( h3CellIdsExpr )
Compacts the input set of H3 cells. The compacted set covers the same set of H3 cells as the original one.

### Syntax
CALL com.neo4jh3.compactString( h3CellIdsExpr );

### Arguments
* h3CellIdsExpr: A LIST of STRING expressions representing H3 cell IDs.

### Returns
An LIST of H3 cell IDs of the same type as the values in the input LIST expression h3CellIdsExpr.

### Error conditions


### Example
CALL com.neo4jh3.compactString(['85283473fffffff', '85283447fffffff', '8528347bfffffff', '85283463fffffff', '85283477fffffff', '8528340ffffffff', '8528340bfffffff', '85283457fffffff', '85283443fffffff', '8528344ffffffff', '852836b7fffffff', '8528346bfffffff', '8528346ffffffff', '85283467fffffff', '8528342bfffffff', '8528343bfffffff', '85283407fffffff', '85283403fffffff', '8528341bfffffff']) yield value return value;

"85283447fffffff", "8528340ffffffff", "8528340bfffffff", "85283457fffffff", "85283443fffffff", "8528344ffffffff", "852836b7fffffff", "8528342bfffffff", "8528343bfffffff", "85283407fffffff", "85283403fffffff", "8528341bfffffff", "8428347ffffffff"

## com.neo4jh3.gridpathcell( h3CellId1Expr, h3CellId2Expr )
Returns the line of indexes as LONGs between two H3 indexes (inclusive).
Expand Down Expand Up @@ -1266,7 +1324,6 @@ Returns the line of indexes as STRINGs between two H3 indexes (inclusive).
### Syntax
CALL com.neo4jh3.gridpathcellString( h3CellId1Expr, h3CellId2Expr ) yield value return value


### Arguments
* h3CellId1Expr: A hexadecimal STRING expression representing an H3 cell ID.
* h3CellId2Expr: A hexadecimal STRING expression representing an H3 cell ID.
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Neo4j H3 Library
This library provides a set of H3 functions and procedures for Neo4j 5
This library provides a set of H3 functions and procedures for Neo4j 5.


H3 is a hexagonal hierarchical geospatial indexing system (https://h3geo.org)
This library uses the H3 api which can be found at https://h3geo.org/docs/api/indexing

Expand All @@ -11,10 +13,10 @@ project, simply package the project with maven:

mvn clean package

This will produce a jar-file, `neo4jh3-5.15.0.jar`,
This will produce a jar-file, `neo4jh3-5.19.1.jar`,
that can be copied to the `plugins` directory of your Neo4j instance.

cp target/neo4jh3-5.13.0.jar neo4j-enterprise-5.x.0/plugins/.
cp target/neo4jh3-5.19.1.jar neo4j-enterprise-5.x.0/plugins/.


Edit your Neo4j/conf/neo4j.conf file by adding this line:
Expand Down
4 changes: 2 additions & 2 deletions dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.neo4jh3</groupId>
<artifactId>neo4jh3</artifactId>
<version>5.11.0</version>
<version>5.19.0</version>
<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -210,7 +210,7 @@
</dependency>
</dependencies>
<properties>
<neo4j.version>5.11.0</neo4j.version>
<neo4j.version>5.19.0</neo4j.version>
<commons.version>4.1</commons.version>
<csv.version>1.2</csv.version>
<lang3.version>3.13.0</lang3.version>
Expand Down
5 changes: 2 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@

<groupId>com.neo4jh3</groupId>
<artifactId>neo4jh3</artifactId>
<version>5.19.0</version>
<version>5.19.1</version>

<properties>
<neo4j.version>5.19.0</neo4j.version>
<csv.version>1.2</csv.version>
<lang3.version>3.13.0</lang3.version>
<lang3.version>3.13.0</lang3.version>
<uber.version>4.1.1</uber.version>
<commons.version>4.1</commons.version>
<commons.math.version>3.6.1</commons.math.version>
Expand Down
Loading

0 comments on commit 784b0f5

Please sign in to comment.