Skip to content

Commit

Permalink
Minor fixes and error handling changes. Now version 1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
wlaforest committed Jul 23, 2020
1 parent 2d85cde commit a9bb576
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<groupId>io.confluent.ksql.udf</groupId>
<artifactId>ksqlgeo</artifactId>
<version>1.1</version>
<version>1.2.1</version>
<packaging>jar</packaging>

<name>KSQL Geo</name>
Expand Down
19 changes: 12 additions & 7 deletions src/main/java/com/github/wlaforest/ksql/udf/GeoContainedUDF.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@

@UdfDescription(
name = "geo_contained",
description = "UDF function to test containment of a geometry in another geometry. The container " +
"argument will always be a polygon but the geometry to test for containment inside of the container " +
"can be any Geometry",
version = "1.2",
description = "UDF function to test containment of a point in a geometry. Geometry can be encoded in WKT" +
"or GeoJSON. null paremeters will always result in false",
version = "1.2.1",
author = "Will LaForest"
)
public class GeoContainedUDF extends GeometryBase {
Expand All @@ -20,9 +19,14 @@ public boolean geo_contained(
@UdfParameter(value = "latitude", description = "the latitude of the point") final double latitude,
@UdfParameter(value = "longitude", description = "the longitude of the point") final double longitude,
@UdfParameter(value = "geo", description = "WKT or GeoJSON Encoded Geometry to check for enclosure") final String geo) throws GeometryParseException {

return getSpatial4JHelper().contained(geo, latitude, longitude, true);

try {
if (geo == null) return false;
return getSpatial4JHelper().contained(geo, latitude, longitude, true);
}
catch (Exception e) {
e.printStackTrace();
throw e;
}
}

@Udf(description = "determines if a String value lat/long is inside or outside the geometry passed as the" +
Expand All @@ -31,6 +35,7 @@ public boolean geo_contained(
@UdfParameter(value = "latitude", description = "the latitude of the point") final String latitude,
@UdfParameter(value = "longitude", description = "the longitude of the point") final String longitude,
@UdfParameter(value = "geo", description = "WKT or GeoJSON Encoded Geometry to check for enclosure") final String geo) throws GeometryParseException {
if (latitude == null || longitude == null) return false;
return geo_contained(Double.parseDouble(latitude), Double.parseDouble(longitude), geo);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
name = "geo_hash",
description = "Function to calculate the geohash of a given point. Based on the Lucene code" +
"https://lucene.apache.org/core/5_5_0/spatial/org/apache/lucene/spatial/util/GeoHashUtils.html",
version = "1.2",
version = "1.2.1",
author = "Will LaForest"
)
public class GeoHashUDF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

@UdfDescription(
name = "geo_intersected_sphere",
description = "UDF function to test for geometry intersection.",
version = "1.2",
description = "UDF function to test for geometry intersection on a spherical model. geometry should be" +
"encoded in WKT or GeoJSON. null value will result in a false result being returned.",
version = "1.2.1",
author = "Will LaForest"
)
public class GeoIntersectedSphereUDF extends GeometryBase {
Expand All @@ -19,6 +20,7 @@ public boolean geo_intersected_sphere(
@UdfParameter(value = "geo2", description = "WKT or GeoJSON Encoded Geometry to check for intersection with geo1") final String geo2)
throws GeometryParseException {

if (geo1 == null || geo2 == null) return false;
return getSpatial4JHelper().intersect(geo1,geo2, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@

@UdfDescription(
name = "geo_intersected",
description = "UDF function to test for geometry intersection.",
version = "1.2",
description = "UDF function to test for geometry intersection in euclidean space. geometry encoded in " +
"WKT or GeoJSON. null value result in false being returned.",
version = "1.2.1",
author = "Will LaForest"
)
public class GeoIntersectedUDF extends GeometryBase {
Expand Down

0 comments on commit a9bb576

Please sign in to comment.