Skip to content

Commit

Permalink
Version 5.16
Browse files Browse the repository at this point in the history
Added procedures to write to Neo4j DB
Also added a function to calculate the angle between two points (latitude and longitude)
  • Loading branch information
davidfauth committed Feb 9, 2024
1 parent 913cb2d commit 4d0b48f
Show file tree
Hide file tree
Showing 7 changed files with 341 additions and 76 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# CHANGELOG - 5.15 - 2023-12-127
# CHANGELOG - 5.16 - 2024-02-09
* [Updated] - Tested through Neo4j 5.16
* [Added] - Added two new procedures that write to the Neo4j database. These are com.neo4jh3.writeH3NodesRelsToDB and com.neo4jh3.writeH3StringNodesRelsToDB. These procedures take the from node, a list of hex addresses, a Label, a Property and a transaction size and write the H3 address nodes and create relationships between the H3 node and the From Node to the database. If you are using these procedures, it is highly recommended that you have a constraint or index for the Label and Property.
* [Added] - Added a function com.neo4jh3.angleBetweenPoints to calculate the angle between two points (latitude and longitude).

# CHANGELOG - 5.15 - 2023-12-17
* [Updated] - Tested through Neo4j 5.15
* [Added] - Added MIT license.
* [Added] - Added two new procedures that write to the Neo4j database. These are com.neo4jh3.writeH3StringToDB and com.neo4jh3.writeH3ToDB. These procedures take a list of hex addresses, a Label, a Property and a transaction size and write the results to the database. If you are using these procedures, it is highly recommended that you have a constraint or index for the Label and Property.
Expand Down
97 changes: 95 additions & 2 deletions Documentation.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
# Documentation
## com.neo4jh3.angleBetweenPoints( Latitude1, Longitude1, Latitude2, Longitude2 )
Returns the angle in degrees between two points.

### Syntax
RETURN com.neo4jh3.angleBetweenPoints( Latitude1, Longitude1, Latitude2, Longitude2 ) as value

### Arguments
* Latitude1: A DOUBLE expression representing the latitude (in degrees) of the first point
* Longitude1: A DOUBLE expression representing the longitude (in degrees) of the first point
* Latitude2: A DOUBLE expression representing the latitude (in degrees) of the second point
* Longitude2: A DOUBLE expression representing the longitude (in degrees) of the second point

### Returns
A value of the type DOUBLE representing the angle in degrees between the two points.

### Error conditions
If any of the latitude or longitude values are invalid, the function returns -1

### Example
RETURN com.neo4jh3.angleBetweenPoints(40.123,-78.111,40.555,-78.910) AS value
305.607560
RETURN com.neo4jh3.angleBetweenPoints(240.123,-78.111,40.555,-78.910) AS value
-1.0

## com.neo4jh3.boundaryaswkt( h3CellIdExpr )
Returns the polygonal boundary of the input H3 cell in WKT format.

Expand Down Expand Up @@ -199,7 +224,7 @@ RETURN com.neo4jh3.cellToLatLng( h3CellId1Expr ) AS value;
A STRING value consisting of the latitude and longitude of the h3CellIdExpr.

### Error conditions
If h3XellIdExpr is an invalid h3 address, the function returns -1.
If h3CellIdExpr is an invalid h3 address, the function returns -1.

### Example
RETURN com.neo4jh3.cellToLatLng(635714569676958015) AS value
Expand All @@ -221,7 +246,7 @@ RETURN com.neo4jh3.cellToLatLngString( h3CellIdExpr ) AS value;
A STRING value consisting of the latitude and longitude of the h3CellIdExpr.

### Error conditions
If h3XellIdExpr is an invalid h3 address, the function returns -1.
If h3CellIdExpr is an invalid h3 address, the function returns -1.

### Example
RETURN com.neo4jh3.cellToLatLngString('892830926cfffff') AS value
Expand Down Expand Up @@ -1542,6 +1567,74 @@ If the strLabel or strProperty is empty, the procedure returns "-5"
call com.neo4jh3.writeH3ToDBString(ch3,'','') yield value return value;
"-5"

## com.neo4jh3.writeH3NodesRelsToDB( From Node, ListOfCells, Neo4j Label, Neo4j Property, Relationships Type, Transaction Size )
Writes the H3 index values to the Neo4j database as a node using a user provided Label and Property.
Connects the H3 index values to the From Node using the specified Relationship value.

### Syntax
CALL com.neo4jh3.writeH3NodesRelsToDB(fromNode, listCells, strLabel, strProperty, relationshipType, txSize) yield value return value;

### Arguments
* fromNode: An existing Node in the Neo4j database.
* listCells: A LIST of LONG values representing an H3 cell ID.
* strLabel: A STRING indicating what Neo4j Label will be applied to the nodes.
* strProperty: A STRING indicating what Neo4j Property will be applied to the nodes.
* relationshipType: A STRING indicating what relationship type will be used for the relationships.
* txSize: A LONG indicating the number of nodes to create in each transaction.

### Returns
A STRING indicating completion.

### Error conditions
If the strLabel or strProperty is empty, the procedure returns "-5"

### Example
match (cs:CountySubDivision {cousubns:value.COUSUBNS})
call com.neo4jh3.polygonToCells(value.Geometry,[],8,'lonlat') yield value as h3
with cs, collect(h3) as ch3
call com.neo4jh3.writeH3NodesRelsToDB(cs,ch3,'Hex','hexAddress8','HAS_HEXADDRESS', 10000) yield value return value;
"Success"
match (cs:CountySubDivision {cousubns:value.COUSUBNS})
call com.neo4jh3.polygonToCells(value.Geometry,[],8,'lonlat') yield value as h3
with cs, collect(h3) as ch3
call com.neo4jh3.writeH3NodesRelsToDB(cs,ch3,'Hex','','HAS_HEXADDRESS', 10000) yield value return value;
"-5"

# com.neo4jh3.writeH3StringNodesRelsToDB( From Node, ListOfCells, Neo4j Label, Neo4j Property, Relationships Type, Transaction Size )
Writes the H3 index values to the Neo4j database as a node using a user provided Label and Property.
Connects the H3 index values to the From Node using the specified Relationship value.

### Syntax
CALL com.neo4jh3.writeH3StringNodesRelsToDB(fromNode, listCells, strLabel, strProperty, relationshipType, txSize) yield value return value;

### Arguments
* fromNode: An existing Node in the Neo4j database.
* listCells: A LIST of STRING values representing an H3 cell ID.
* strLabel: A STRING indicating what Neo4j Label will be applied to the nodes.
* strProperty: A STRING indicating what Neo4j Property will be applied to the nodes.
* relationshipType: A STRING indicating what relationship type will be used for the relationships.
* txSize: A LONG indicating the number of nodes to create in each transaction.

### Returns
A STRING indicating completion.

### Error conditions
If the strLabel or strProperty is empty, the procedure returns "-5"

### Example
match (cs:CountySubDivision {cousubns:value.COUSUBNS})
call com.neo4jh3.polygonToCells(value.Geometry,[],8,'lonlat') yield value as h3
with cs, collect(h3) as ch3
call com.neo4jh3.writeH3StringNodesRelsToDB(cs,ch3,'Hex','hexAddress8','HAS_HEXADDRESS', 10000) yield value return value;
"Success"
match (cs:CountySubDivision {cousubns:value.COUSUBNS})
call com.neo4jh3.polygonToCells(value.Geometry,[],8,'lonlat') yield value as h3
with cs, collect(h3) as ch3
call com.neo4jh3.writeH3StringNodesRelsToDB(cs,ch3,'Hex','','HAS_HEXADDRESS', 10000) yield value return value;
"-5"

## Error Codes
* -1 or "-1" : Invalid H3 Address
* -2 or "-2" : Invalid Resolution
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ Edit your Neo4j/conf/neo4j.conf file by adding this line:
(Re)start Neo4j

# Documentation
Refer to the Documentation.md file for detailed documenation on the functions / procedures.
Refer to the Documentation.md file for detailed documentation on the functions / procedures.

# Note
The Neo4jH3 plugin requires the ability to write to the temp directory. If the temp directory configured with noexec, then you need to update the neo4j.conf with these two lines:

server.jvm.additional=-Djava.io.tmpdir=/path_to_a_new_directory/temp
server.jvm.additional=-Djna.tmpdir=/path_to_a_new_directory/temp

4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

<groupId>com.neo4jh3</groupId>
<artifactId>neo4jh3</artifactId>
<version>5.15.0</version>
<version>5.16.0</version>

<properties>
<neo4j.version>5.15.0</neo4j.version>
<neo4j.version>5.16.0</neo4j.version>
<csv.version>1.2</csv.version>
<lang3.version>3.13.0</lang3.version>
<uber.version>4.1.1</uber.version>
Expand Down
Loading

0 comments on commit 4d0b48f

Please sign in to comment.