Revert "HHH-11198 - Add Geometry cast to Postgis st_extent() function"
This reverts commit af301bc9ba
.
This commit is contained in:
parent
23688a7703
commit
19ae3a8220
|
@ -159,19 +159,9 @@ public enum SpatialFunction {
|
||||||
* <p>The semantics are those of the Postgis function ST_Transform(geometry, srid) : geometry. It returns new geometry
|
* <p>The semantics are those of the Postgis function ST_Transform(geometry, srid) : geometry. It returns new geometry
|
||||||
* with its coordinates transformed to the spatial reference system referenced by the srid parameter.
|
* with its coordinates transformed to the spatial reference system referenced by the srid parameter.
|
||||||
*/
|
*/
|
||||||
transform( "common" ),
|
transform( "common" );
|
||||||
|
|
||||||
/**
|
|
||||||
* the extents function
|
|
||||||
*/
|
|
||||||
extent( "common" );
|
|
||||||
|
|
||||||
|
|
||||||
private final String description;
|
private final String description;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SpatialFunction(String specification) {
|
SpatialFunction(String specification) {
|
||||||
this.description = specification;
|
this.description = specification;
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,6 @@ public class MySQLSpatialDialect extends MySQLDialect implements SpatialDialect
|
||||||
case geomunion:
|
case geomunion:
|
||||||
case dwithin:
|
case dwithin:
|
||||||
case transform:
|
case transform:
|
||||||
case extent:
|
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -7,12 +7,10 @@
|
||||||
package org.hibernate.spatial.dialect.postgis;
|
package org.hibernate.spatial.dialect.postgis;
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.hibernate.boot.model.TypeContributions;
|
import org.hibernate.boot.model.TypeContributions;
|
||||||
import org.hibernate.dialect.PostgreSQL82Dialect;
|
import org.hibernate.dialect.PostgreSQL82Dialect;
|
||||||
import org.hibernate.dialect.function.StandardSQLFunction;
|
import org.hibernate.dialect.function.StandardSQLFunction;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
import org.hibernate.spatial.GeolatteGeometryType;
|
import org.hibernate.spatial.GeolatteGeometryType;
|
||||||
import org.hibernate.spatial.JTSGeometryType;
|
import org.hibernate.spatial.JTSGeometryType;
|
||||||
|
@ -21,7 +19,6 @@ import org.hibernate.spatial.SpatialDialect;
|
||||||
import org.hibernate.spatial.SpatialFunction;
|
import org.hibernate.spatial.SpatialFunction;
|
||||||
import org.hibernate.spatial.SpatialRelation;
|
import org.hibernate.spatial.SpatialRelation;
|
||||||
import org.hibernate.type.StandardBasicTypes;
|
import org.hibernate.type.StandardBasicTypes;
|
||||||
import org.hibernate.type.Type;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Dialect for Postgresql with support for the Postgis spatial types, functions and operators (release 1.3 or higher)
|
* A Dialect for Postgresql with support for the Postgis spatial types, functions and operators (release 1.3 or higher)
|
||||||
|
@ -211,7 +208,9 @@ public class PostgisDialect extends PostgreSQL82Dialect implements SpatialDialec
|
||||||
|
|
||||||
//register Spatial Aggregate function
|
//register Spatial Aggregate function
|
||||||
registerFunction(
|
registerFunction(
|
||||||
"extent", new ExtentFunction()
|
"extent", new StandardSQLFunction(
|
||||||
|
"extent"
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
//other common functions
|
//other common functions
|
||||||
|
@ -282,7 +281,7 @@ public class PostgisDialect extends PostgreSQL82Dialect implements SpatialDialec
|
||||||
switch ( aggregation ) {
|
switch ( aggregation ) {
|
||||||
case SpatialAggregate.EXTENT:
|
case SpatialAggregate.EXTENT:
|
||||||
final StringBuilder stbuf = new StringBuilder();
|
final StringBuilder stbuf = new StringBuilder();
|
||||||
stbuf.append( "st_extent(" ).append( columnName ).append( ")::geometry" );
|
stbuf.append( "extent(" ).append( columnName ).append( ")" );
|
||||||
return stbuf.toString();
|
return stbuf.toString();
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
|
@ -299,21 +298,6 @@ public class PostgisDialect extends PostgreSQL82Dialect implements SpatialDialec
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supports(SpatialFunction function) {
|
public boolean supports(SpatialFunction function) {
|
||||||
return (getFunctions().get( function.toString() ) != null);
|
return ( getFunctions().get( function.toString() ) != null );
|
||||||
}
|
|
||||||
|
|
||||||
private static class ExtentFunction extends StandardSQLFunction {
|
|
||||||
|
|
||||||
public ExtentFunction() {
|
|
||||||
super( "st_extent" );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String render(
|
|
||||||
Type firstArgumentType, List arguments, SessionFactoryImplementor sessionFactory) {
|
|
||||||
String rendered = super.render( firstArgumentType, arguments, sessionFactory );
|
|
||||||
//add cast
|
|
||||||
return rendered + "::geometry";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,7 @@ public class PostgisUnmarshalTest {
|
||||||
|
|
||||||
public void testCase(String pgValue, Geometry<?> expected) throws SQLException {
|
public void testCase(String pgValue, Geometry<?> expected) throws SQLException {
|
||||||
PGobject pgo = new PGobject();
|
PGobject pgo = new PGobject();
|
||||||
|
System.out.println( "pgValue " + pgValue );
|
||||||
pgo.setValue( pgValue );
|
pgo.setValue( pgValue );
|
||||||
Geometry<?> received = PGGeometryTypeDescriptor.toGeometry( pgo );
|
Geometry<?> received = PGGeometryTypeDescriptor.toGeometry( pgo );
|
||||||
assertEquals( String.format( "Failure on %s", pgValue ), expected, received );
|
assertEquals( String.format( "Failure on %s", pgValue ), expected, received );
|
||||||
|
|
|
@ -676,28 +676,6 @@ public class TestSpatialFunctions extends SpatialFunctionalTestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test_extent_on_jts() throws SQLException {
|
|
||||||
extent( JTS );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test_extent_on_geolatte() throws SQLException {
|
|
||||||
extent( GEOLATTE );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void extent(String pckg) throws SQLException {
|
|
||||||
if ( !isSupportedByDialect( SpatialFunction.extent ) ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// here we just check if we get a result, and can read it
|
|
||||||
String hql = format(
|
|
||||||
"SELECT id, extent(geom) from org.hibernate.spatial.integration.%s.GeomEntity group by id", pckg
|
|
||||||
);
|
|
||||||
Map<Integer, Object> hsreceived = new HashMap<Integer, Object>();
|
|
||||||
doInSession( hql, hsreceived, new HashMap<String, Object>() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> void retrieveHQLResultsAndCompare(Map<Integer, T> dbexpected, String hql, String geometryType) {
|
public <T> void retrieveHQLResultsAndCompare(Map<Integer, T> dbexpected, String hql, String geometryType) {
|
||||||
retrieveHQLResultsAndCompare( dbexpected, hql, null, geometryType );
|
retrieveHQLResultsAndCompare( dbexpected, hql, null, geometryType );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue