jiayuasu opened a new issue, #2723:
URL: https://github.com/apache/sedona/issues/2723

   ### Description
   
   `ST_VoronoiPolygons` is implemented in `FunctionsGeoTools.java`, but it does 
not use any GeoTools APIs. It only uses JTS classes:
   
   - `org.locationtech.jts.triangulate.VoronoiDiagramBuilder`
   - `org.locationtech.jts.geom.Geometry`
   - `org.locationtech.jts.geom.Envelope`
   
   Because it lives in `FunctionsGeoTools`, loading the class triggers all 
GeoTools imports at the top of the file (`org.geotools.api.referencing.*`, 
etc.), which means `ST_VoronoiPolygons` fails with `NoClassDefFoundError` when 
GeoTools is not on the classpath — even though the function itself has no 
GeoTools dependency.
   
   ### Location
   
   [`FunctionsGeoTools.java` lines 
177-192](https://github.com/apache/sedona/blob/master/common/src/main/java/org/apache/sedona/common/FunctionsGeoTools.java#L177-L192):
   
   ```java
   public static Geometry voronoiPolygons(Geometry geom, double tolerance, 
Geometry extendTo) {
       if (geom == null) {
         return null;
       }
       VoronoiDiagramBuilder builder = new VoronoiDiagramBuilder();
       builder.setSites(geom);
       builder.setTolerance(tolerance);
       if (extendTo != null) {
         builder.setClipEnvelope(extendTo.getEnvelopeInternal());
       } else {
         Envelope e = geom.getEnvelopeInternal();
         e.expandBy(Math.max(e.getWidth(), e.getHeight()));
         builder.setClipEnvelope(e);
       }
       return builder.getDiagram(geom.getFactory());
   }
   ```
   
   ### Suggested fix
   
   Move `voronoiPolygons` from `FunctionsGeoTools.java` to `Functions.java` so 
that it is available without GeoTools on the classpath, consistent with 
`ST_DelaunayTriangles` which is already in `Functions.java` and similarly uses 
only JTS (`org.locationtech.jts.triangulate.DelaunayTriangulationBuilder`).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to