You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using the 0.8 version and there is a problem with ST_EXTENT:
@OverRide
protected void add(Geometry geometry) {
if (result == null) {
result = geometry;
} else {
if (geometry != null) {
result = result.union(geometry.getEnvelope());
}
}
}
If result is null you set it to geometry. The next geometry gets its envelope added with union. Now, this will work if the geometries are polygon. But when the geometry is for example LineString, the first union will create a geometry collection (linestring from the first iteration and the polygon from GetEnvelope...) which can not be unified (JTS union actually has a check: checkNotGeometryCollection(this);)
The solution is to set the result to geometry.getEnvelope in the first iteration.
The text was updated successfully, but these errors were encountered:
Thanks for reporting the issue. It makes sense but when I tried to reproduce I could not. Any chance you can provide a sample of geometries that lead to the issue?
Here is how i can replicate the problem. Firstly i create a database using the geotools (so all the aliases get setup) then i connected the DBeaver to this database and executed the following lines: (also note that the same thing happens on purely geotools created tables)
CREATE TABLE PUBLIC.TEST_EXTENT (
ID INTEGER NOT NULL,
GEOM BLOB
);
-- all fine
SELECT ST_ENVELOPE(geom) FROM TEST_EXTENT
-- exception: General error: java.lang.IllegalArgumentException: This method does not support GeometryCollection arguments; SQL statement:
SELECT ST_Extent(geom) FROM TEST_EXTENT
And with the proposed fix, the last SQL works as intended.
I'm using the 0.8 version and there is a problem with ST_EXTENT:
@OverRide
protected void add(Geometry geometry) {
if (result == null) {
result = geometry;
} else {
if (geometry != null) {
result = result.union(geometry.getEnvelope());
}
}
}
If result is null you set it to geometry. The next geometry gets its envelope added with union. Now, this will work if the geometries are polygon. But when the geometry is for example LineString, the first union will create a geometry collection (linestring from the first iteration and the polygon from GetEnvelope...) which can not be unified (JTS union actually has a check: checkNotGeometryCollection(this);)
The solution is to set the result to geometry.getEnvelope in the first iteration.
The text was updated successfully, but these errors were encountered: