HHH-14738 Refactor spatial functions integration tests
This commit is contained in:
parent
f5f0ccfdd3
commit
71b197d362
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial;
|
||||
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
|
||||
/**
|
||||
* TODO -- documentation
|
||||
*/
|
||||
public enum CommonSpatialFunction {
|
||||
|
||||
ST_ASTEXT( FunctionKey.apply( "st_astext", "astext" ), StandardBasicTypes.STRING ),
|
||||
ST_GEOMETRYTYPE( FunctionKey.apply( "st_geometrytype", "geometrytype" ), StandardBasicTypes.STRING ),
|
||||
ST_DIMENSION( FunctionKey.apply( "st_dimension", "dimension" ), StandardBasicTypes.INTEGER );
|
||||
|
||||
private final FunctionKey key;
|
||||
private final BasicType<?> ReturnType;
|
||||
|
||||
CommonSpatialFunction(FunctionKey key, BasicType<?> returnType) {
|
||||
this.key = key;
|
||||
ReturnType = returnType;
|
||||
}
|
||||
|
||||
public FunctionKey getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public BasicType<?> getReturnType() {
|
||||
return ReturnType;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* A the key vor a SpatialFunction
|
||||
*/
|
||||
public class FunctionKey {
|
||||
|
||||
final private String name;
|
||||
final private String altName;
|
||||
|
||||
private FunctionKey(String name, String altName) {
|
||||
this.name = name;
|
||||
this.altName = altName;
|
||||
}
|
||||
|
||||
public static FunctionKey apply(String name, String altName) {
|
||||
return new FunctionKey( name, altName );
|
||||
}
|
||||
|
||||
public static FunctionKey apply(String name) {
|
||||
return new FunctionKey( name, null );
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Optional<String> getAltName() {
|
||||
return Optional.ofNullable( altName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ( this == o ) {
|
||||
return true;
|
||||
}
|
||||
if ( o == null || getClass() != o.getClass() ) {
|
||||
return false;
|
||||
}
|
||||
FunctionKey that = (FunctionKey) o;
|
||||
return Objects.equals( name, that.name ) && Objects.equals( altName, that.altName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash( name, altName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SpatialFunctionKey{" + name + '}';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
|
||||
|
||||
/**
|
||||
* Internal contract for a collection of SqmFunctionDescriptors, together with their key
|
||||
*/
|
||||
public interface KeyedSqmFunctionDescriptors {
|
||||
|
||||
/**
|
||||
* Return the SqmFunctionDescriptors as map of {@code FunctionKey} to {@code SqmFunctionDescriptor}
|
||||
*
|
||||
* @return the SqmFunctionDescriptors as map of {@code FunctionKey} to {@code SqmFunctionDescriptor}
|
||||
*/
|
||||
Map<FunctionKey, SqmFunctionDescriptor> asMap();
|
||||
|
||||
}
|
|
@ -13,6 +13,7 @@ package org.hibernate.spatial;
|
|||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 4/18/13
|
||||
*/
|
||||
@Deprecated
|
||||
public interface Spatial {
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ package org.hibernate.spatial;
|
|||
*
|
||||
* @author Karel Maesen
|
||||
*/
|
||||
@Deprecated
|
||||
public interface SpatialAggregate {
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,6 +11,7 @@ package org.hibernate.spatial;
|
|||
*
|
||||
* @author Karel Maesen
|
||||
*/
|
||||
@Deprecated
|
||||
public interface SpatialAnalysis {
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,7 +12,9 @@ import java.io.Serializable;
|
|||
* Describes the features of a spatially enabled dialect.
|
||||
*
|
||||
* @author Karel Maesen
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public interface SpatialDialect extends Serializable {
|
||||
|
||||
// /**
|
||||
|
|
|
@ -16,8 +16,11 @@ package org.hibernate.spatial;
|
|||
* </ul>
|
||||
*
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
*
|
||||
* creation-date: Oct 7, 2010
|
||||
* @deprecated To be replaced by {@link CommonSpatialFunction}
|
||||
*/
|
||||
@Deprecated
|
||||
public enum SpatialFunction {
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,6 +14,7 @@ package org.hibernate.spatial;
|
|||
*
|
||||
* @author Karel Maesen
|
||||
*/
|
||||
@Deprecated
|
||||
public interface SpatialRelation {
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,24 +9,16 @@ package org.hibernate.spatial.contributor;
|
|||
|
||||
import org.hibernate.boot.model.FunctionContributions;
|
||||
import org.hibernate.boot.model.TypeContributions;
|
||||
import org.hibernate.boot.model.TypeContributor;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
||||
/**
|
||||
* Internal contract for TypeContributor
|
||||
* Internal contract for Type and Function Contributors
|
||||
*/
|
||||
abstract class ContributorImplementor {
|
||||
private final ServiceRegistry serviceRegistryegistry;
|
||||
public interface ContributorImplementor {
|
||||
|
||||
ContributorImplementor(ServiceRegistry serviceRegistry) {
|
||||
this.serviceRegistryegistry = serviceRegistry;
|
||||
}
|
||||
void contributeTypes(TypeContributions typeContributions);
|
||||
|
||||
abstract void contributeTypes(TypeContributions typeContributions);
|
||||
void contributeFunctions(FunctionContributions functionContributions);
|
||||
|
||||
abstract void contributeFunctions(FunctionContributions functionContributions);
|
||||
|
||||
ServiceRegistry getServiceRegistryegistry() {
|
||||
return serviceRegistryegistry;
|
||||
}
|
||||
ServiceRegistry getServiceRegistry();
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.hibernate.dialect.Dialect;
|
|||
import org.hibernate.dialect.PostgreSQLDialect;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.spatial.dialect.postgis.PostgisDialectContributor;
|
||||
|
||||
class ContributorResolver {
|
||||
|
||||
|
@ -24,7 +25,7 @@ class ContributorResolver {
|
|||
|
||||
static {
|
||||
//TypeContributorImplementor
|
||||
ContributorMap.put( PostgreSQLDialect.class, PostgreSQLDialectContributor::new );
|
||||
ContributorMap.put( PostgreSQLDialect.class, PostgisDialectContributor::new );
|
||||
}
|
||||
|
||||
private ContributorResolver() {
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
|
|||
* Registers all available spatial functions for a <code>Dialect</code>
|
||||
* <p>
|
||||
* Created by Karel Maesen, Geovise BVBA on 29/10/16.
|
||||
* @Deprecated Use
|
||||
*/
|
||||
public abstract class SpatialFunctionsRegistry implements Iterable<Map.Entry<String, SqmFunctionDescriptor>>, Serializable {
|
||||
protected final Map<String, SqmFunctionDescriptor> functionMap = new HashMap<String, SqmFunctionDescriptor>();
|
||||
|
|
|
@ -1,139 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial.dialect.postgis;
|
||||
|
||||
import java.sql.Types;
|
||||
|
||||
import org.hibernate.spatial.SpatialDialect;
|
||||
import org.hibernate.spatial.SpatialFunction;
|
||||
import org.hibernate.spatial.dialect.SpatialFunctionsRegistry;
|
||||
|
||||
interface PGSpatialDialectTrait {
|
||||
|
||||
PostgisSupport support = new PostgisSupport();
|
||||
|
||||
|
||||
default SpatialFunctionsRegistry functionsToRegister() {
|
||||
return support.functionsToRegister();
|
||||
}
|
||||
/**
|
||||
* Returns the SQL fragment for the SQL WHERE-clause when parsing
|
||||
* <code>org.hibernatespatial.criterion.SpatialRelateExpression</code>s
|
||||
* into prepared statements.
|
||||
* <p/>
|
||||
*
|
||||
* @param columnName The name of the geometry-typed column to which the relation is
|
||||
* applied
|
||||
* @param spatialRelation The type of spatial relation (as defined in
|
||||
* <code>SpatialRelation</code>).
|
||||
*
|
||||
* @return SQL fragment {@code SpatialRelateExpression}
|
||||
*/
|
||||
|
||||
default String getSpatialRelateSQL(String columnName, int spatialRelation) {
|
||||
return support.getSpatialRelateSQL( columnName, spatialRelation );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the SQL fragment for the SQL WHERE-expression when parsing
|
||||
* <code>org.hibernate.spatial.criterion.SpatialFilterExpression</code>s
|
||||
* into prepared statements.
|
||||
*
|
||||
* @param columnName The name of the geometry-typed column to which the filter is
|
||||
* be applied
|
||||
*
|
||||
* @return Rhe SQL fragment for the {@code SpatialFilterExpression}
|
||||
*/
|
||||
|
||||
default String getSpatialFilterExpression(String columnName) {
|
||||
return support.getSpatialFilterExpression( columnName );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the SQL fragment for the specfied Spatial aggregate expression.
|
||||
*
|
||||
* @param columnName The name of the Geometry property
|
||||
* @param aggregation The type of <code>SpatialAggregate</code>
|
||||
*
|
||||
* @return The SQL fragment for the projection
|
||||
*/
|
||||
|
||||
default String getSpatialAggregateSQL(String columnName, int aggregation) {
|
||||
return support.getSpatialAggregateSQL( columnName, aggregation );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns The SQL fragment when parsing a <code>DWithinExpression</code>.
|
||||
*
|
||||
* @param columnName The geometry column to test against
|
||||
*
|
||||
* @return The SQL fragment when parsing a <code>DWithinExpression</code>.
|
||||
*/
|
||||
|
||||
default String getDWithinSQL(String columnName) {
|
||||
return support.getDWithinSQL( columnName );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the SQL fragment when parsing a <code>HavingSridExpression</code>.
|
||||
*
|
||||
* @param columnName The geometry column to test against
|
||||
*
|
||||
* @return The SQL fragment for a <code>HavingSridExpression</code>.
|
||||
*/
|
||||
|
||||
default String getHavingSridSQL(String columnName) {
|
||||
return support.getHavingSridSQL( columnName );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the SQL fragment when parsing a <code>IsEmptyExpression</code> or
|
||||
* <code>IsNotEmpty</code> expression.
|
||||
*
|
||||
* @param columnName The geometry column
|
||||
* @param isEmpty Whether the geometry is tested for empty or non-empty
|
||||
*
|
||||
* @return The SQL fragment for the isempty function
|
||||
*/
|
||||
|
||||
default String getIsEmptySQL(String columnName, boolean isEmpty) {
|
||||
return support.getIsEmptySQL( columnName, isEmpty );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this <code>SpatialDialect</code> supports a specific filtering function.
|
||||
* <p> This is intended to signal DB-support for fast window queries, or MBR-overlap queries.</p>
|
||||
*
|
||||
* @return True if filtering is supported
|
||||
*/
|
||||
|
||||
default boolean supportsFiltering() {
|
||||
return support.supportsFiltering();
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this dialect supports the specified <code>SpatialFunction</code>.
|
||||
*
|
||||
* @param function <code>SpatialFunction</code>
|
||||
*
|
||||
* @return True if this <code>SpatialDialect</code> supports the spatial function specified by the function parameter.
|
||||
*/
|
||||
|
||||
default boolean supports(SpatialFunction function) {
|
||||
return support.supports( function );
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the typeCode is (potentially) the code for a spatial type
|
||||
* @param typeCode the JDBC type code
|
||||
* @return if the typecode corresponds with a spatialt type
|
||||
*/
|
||||
default boolean isSpatial(int typeCode){
|
||||
return support.isSpatial( typeCode );
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.spatial.dialect.postgis;
|
||||
|
||||
|
||||
/**
|
||||
* Extends the {@code PostgreSQL82Dialect} to add support for the Postgis spatial types, functions and operators .
|
||||
*
|
||||
* @author Karel Maesen
|
||||
* @deprecated "Use one of the PostgisPGNNDialect classes"
|
||||
*/
|
||||
@Deprecated
|
||||
public class PostgisDialect extends PostgisPG82Dialect {
|
||||
|
||||
}
|
|
@ -5,33 +5,24 @@
|
|||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial.contributor;
|
||||
|
||||
import java.util.Map;
|
||||
package org.hibernate.spatial.dialect.postgis;
|
||||
|
||||
import org.hibernate.boot.model.FunctionContributions;
|
||||
import org.hibernate.boot.model.TypeContributions;
|
||||
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.spatial.GeolatteGeometryJavaTypeDescriptor;
|
||||
import org.hibernate.spatial.GeolatteGeometryType;
|
||||
import org.hibernate.spatial.HSMessageLogger;
|
||||
import org.hibernate.spatial.JTSGeometryJavaTypeDescriptor;
|
||||
import org.hibernate.spatial.JTSGeometryType;
|
||||
import org.hibernate.spatial.dialect.postgis.PGGeometryTypeDescriptor;
|
||||
import org.hibernate.spatial.dialect.postgis.PostgisFunctions;
|
||||
import org.hibernate.spatial.contributor.ContributorImplementor;
|
||||
|
||||
public class PostgreSQLDialectContributor extends ContributorImplementor {
|
||||
public class PostgisDialectContributor implements ContributorImplementor {
|
||||
|
||||
PostgreSQLDialectContributor(ServiceRegistry serviceRegistry) {
|
||||
super( serviceRegistry );
|
||||
private final ServiceRegistry serviceRegistryegistry;
|
||||
|
||||
public PostgisDialectContributor(ServiceRegistry serviceRegistry) {
|
||||
this.serviceRegistryegistry = serviceRegistry;
|
||||
}
|
||||
|
||||
public void contributeTypes(TypeContributions typeContributions) {
|
||||
|
@ -45,11 +36,19 @@ public class PostgreSQLDialectContributor extends ContributorImplementor {
|
|||
}
|
||||
|
||||
@Override
|
||||
void contributeFunctions(FunctionContributions functionContributions) {
|
||||
public void contributeFunctions(FunctionContributions functionContributions) {
|
||||
HSMessageLogger.LOGGER.functionContributions( this.getClass().getCanonicalName() );
|
||||
PostgisFunctions functions = new PostgisFunctions();
|
||||
for( Map.Entry<String, SqmFunctionDescriptor> kv: functions) {
|
||||
functionContributions.contributeFunction( kv.getKey(), kv.getValue() );
|
||||
}
|
||||
PostgisSqmFunctionDescriptors postgisFunctions = new PostgisSqmFunctionDescriptors();
|
||||
|
||||
postgisFunctions.asMap().forEach( (key, desc) -> {
|
||||
functionContributions.contributeFunction( key.getName(), desc );
|
||||
key.getAltName().ifPresent( altName -> functionContributions.contributeFunction( altName, desc ) );
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ServiceRegistry getServiceRegistry() {
|
||||
return this.serviceRegistryegistry;
|
||||
}
|
||||
}
|
|
@ -14,6 +14,11 @@ import java.util.stream.Stream;
|
|||
import org.hibernate.QueryException;
|
||||
import org.hibernate.dialect.function.StandardSQLFunction;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.query.sqm.function.NamedSqmFunctionDescriptor;
|
||||
import org.hibernate.query.sqm.produce.function.ArgumentsValidator;
|
||||
import org.hibernate.query.sqm.produce.function.NamedFunctionDescriptorBuilder;
|
||||
import org.hibernate.query.sqm.produce.function.StandardArgumentsValidators;
|
||||
import org.hibernate.query.sqm.produce.function.StandardFunctionReturnTypeResolvers;
|
||||
import org.hibernate.spatial.SpatialFunction;
|
||||
import org.hibernate.spatial.dialect.SpatialFunctionsRegistry;
|
||||
import org.hibernate.sql.ast.SqlAstTranslator;
|
||||
|
@ -23,11 +28,16 @@ import org.hibernate.sql.ast.tree.predicate.Predicate;
|
|||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
import static org.hibernate.spatial.CommonSpatialFunction.ST_ASTEXT;
|
||||
import static org.hibernate.spatial.CommonSpatialFunction.ST_GEOMETRYTYPE;
|
||||
|
||||
/**
|
||||
* Functions registered in all Postgis Dialects
|
||||
* <p>
|
||||
* Created by Karel Maesen, Geovise BVBA on 29/10/16.
|
||||
* @deprecated replaced by DialectSpatialSqmFunctionDescriptors
|
||||
*/
|
||||
@Deprecated
|
||||
public class PostgisFunctions extends SpatialFunctionsRegistry {
|
||||
|
||||
public PostgisFunctions() {
|
||||
|
@ -38,11 +48,7 @@ public class PostgisFunctions extends SpatialFunctionsRegistry {
|
|||
StandardBasicTypes.INTEGER
|
||||
)
|
||||
);
|
||||
put(
|
||||
"geometrytype", new StandardSQLFunction(
|
||||
"st_geometrytype", StandardBasicTypes.STRING
|
||||
)
|
||||
);
|
||||
|
||||
put(
|
||||
"srid", new StandardSQLFunction(
|
||||
"st_srid",
|
||||
|
@ -59,12 +65,7 @@ public class PostgisFunctions extends SpatialFunctionsRegistry {
|
|||
"st_makeenvelope"
|
||||
)
|
||||
);
|
||||
put(
|
||||
"astext", new StandardSQLFunction(
|
||||
"st_astext",
|
||||
StandardBasicTypes.STRING
|
||||
)
|
||||
);
|
||||
|
||||
put(
|
||||
"asbinary", new StandardSQLFunction(
|
||||
"st_asbinary",
|
||||
|
@ -212,14 +213,13 @@ public class PostgisFunctions extends SpatialFunctionsRegistry {
|
|||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void render(
|
||||
SqlAppender sqlAppender,
|
||||
List<SqlAstNode> sqlAstArguments,
|
||||
Predicate filter,
|
||||
SqlAstTranslator<?> translator) {
|
||||
super.render( sqlAppender, sqlAstArguments, filter, translator ) ;
|
||||
super.render( sqlAppender, sqlAstArguments, filter, translator );
|
||||
sqlAppender.appendSql( "::geometry" );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial.dialect.postgis;
|
||||
|
||||
/**
|
||||
* A Dialect for Postgresql with support for the Postgis spatial types, functions and operators (release 1.x - 1.3)
|
||||
*
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: Dec 18, 2010
|
||||
*/
|
||||
public class PostgisNoSQLMM extends PostgisDialect {
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.spatial.dialect.postgis;
|
||||
|
||||
import org.hibernate.dialect.PostgreSQL82Dialect;
|
||||
import org.hibernate.spatial.SpatialDialect;
|
||||
|
||||
/**
|
||||
* Extends the {@code PostgreSQL82Dialect} to add support for the Postgis spatial types, functions and operators .
|
||||
* <p>
|
||||
* Created by Karel Maesen, Geovise BVBA on 01/11/16.
|
||||
*/
|
||||
public class PostgisPG82Dialect extends PostgreSQL82Dialect implements SpatialDialect {
|
||||
}
|
|
@ -6,13 +6,27 @@
|
|||
*/
|
||||
package org.hibernate.spatial.dialect.postgis;
|
||||
|
||||
import org.hibernate.dialect.PostgreSQL91Dialect;
|
||||
import org.hibernate.spatial.SpatialDialect;
|
||||
import org.hibernate.dialect.PostgreSQLDialect;
|
||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||
|
||||
/**
|
||||
* Extends the {@code PostgreSQL91Dialect} to add support for the Postgis spatial types, functions and operators .
|
||||
* <p>
|
||||
* Created by Karel Maesen, Geovise BVBA on 01/11/16.
|
||||
*
|
||||
* @deprecated A SpatialDialect is no longer required. Use the standard Dialect for this database.
|
||||
*/
|
||||
public class PostgisPG91Dialect extends PostgreSQL91Dialect implements SpatialDialect {
|
||||
@Deprecated
|
||||
public class PostgisPG91Dialect extends PostgreSQLDialect {
|
||||
public PostgisPG91Dialect(DialectResolutionInfo info) {
|
||||
super( info );
|
||||
}
|
||||
|
||||
public PostgisPG91Dialect() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PostgisPG91Dialect(int version) {
|
||||
super( version );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,12 +7,28 @@
|
|||
package org.hibernate.spatial.dialect.postgis;
|
||||
|
||||
import org.hibernate.dialect.PostgreSQL92Dialect;
|
||||
import org.hibernate.dialect.PostgreSQLDialect;
|
||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||
import org.hibernate.spatial.SpatialDialect;
|
||||
|
||||
/**
|
||||
* Extends the {@code PostgreSQL92Dialect} to add support for the Postgis spatial types, functions and operators .
|
||||
* <p>
|
||||
* Created by Karel Maesen, Geovise BVBA on 01/11/16.
|
||||
*
|
||||
* @deprecated A SpatialDialect is no longer required. Use the standard Dialect for this database.
|
||||
*/
|
||||
public class PostgisPG92Dialect extends PostgreSQL92Dialect implements SpatialDialect {
|
||||
@Deprecated
|
||||
public class PostgisPG92Dialect extends PostgreSQLDialect {
|
||||
public PostgisPG92Dialect(DialectResolutionInfo info) {
|
||||
super( info );
|
||||
}
|
||||
|
||||
public PostgisPG92Dialect() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PostgisPG92Dialect(int version) {
|
||||
super( version );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,13 +6,27 @@
|
|||
*/
|
||||
package org.hibernate.spatial.dialect.postgis;
|
||||
|
||||
import org.hibernate.dialect.PostgreSQL93Dialect;
|
||||
import org.hibernate.spatial.SpatialDialect;
|
||||
import org.hibernate.dialect.PostgreSQLDialect;
|
||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||
|
||||
/**
|
||||
* Extends the {@code PostgreSQL93Dialect} to add support for the Postgis spatial types, functions and operators .
|
||||
* <p>
|
||||
* Created by Karel Maesen, Geovise BVBA on 01/11/16.
|
||||
*
|
||||
* @deprecated A SpatialDialect is no longer required. Use the standard Dialect for this database.
|
||||
*/
|
||||
public class PostgisPG93Dialect extends PostgreSQL93Dialect implements SpatialDialect {
|
||||
@Deprecated
|
||||
public class PostgisPG93Dialect extends PostgreSQLDialect {
|
||||
public PostgisPG93Dialect(DialectResolutionInfo info) {
|
||||
super( info );
|
||||
}
|
||||
|
||||
public PostgisPG93Dialect() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PostgisPG93Dialect(int version) {
|
||||
super( version );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,13 +6,27 @@
|
|||
*/
|
||||
package org.hibernate.spatial.dialect.postgis;
|
||||
|
||||
import org.hibernate.dialect.PostgreSQL94Dialect;
|
||||
import org.hibernate.spatial.SpatialDialect;
|
||||
import org.hibernate.dialect.PostgreSQLDialect;
|
||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||
|
||||
/**
|
||||
* Extends the {@code PostgreSQL94Dialect} to add support for the Postgis spatial types, functions and operators .
|
||||
* <p>
|
||||
* Created by Karel Maesen, Geovise BVBA on 01/11/16.
|
||||
*
|
||||
* @deprecated A SpatialDialect is no longer required. Use the standard Dialect for this database.
|
||||
*/
|
||||
public class PostgisPG94Dialect extends PostgreSQL94Dialect implements SpatialDialect {
|
||||
@Deprecated
|
||||
public class PostgisPG94Dialect extends PostgreSQLDialect {
|
||||
public PostgisPG94Dialect(DialectResolutionInfo info) {
|
||||
super( info );
|
||||
}
|
||||
|
||||
public PostgisPG94Dialect() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PostgisPG94Dialect(int version) {
|
||||
super( version );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,26 @@
|
|||
*/
|
||||
package org.hibernate.spatial.dialect.postgis;
|
||||
|
||||
import org.hibernate.dialect.PostgreSQL95Dialect;
|
||||
import org.hibernate.dialect.PostgreSQLDialect;
|
||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||
|
||||
/**
|
||||
* Extends the {@code PostgreSQL95Dialect} to add support for the Postgis spatial types, functions and operators .
|
||||
* Created by Karel Maesen, Geovise BVBA on 01/11/16.
|
||||
*
|
||||
* @deprecated A SpatialDialect is no longer required. Use the standard Dialect for this database.
|
||||
*/
|
||||
public class PostgisPG95Dialect extends PostgreSQL95Dialect implements PGSpatialDialectTrait {
|
||||
@Deprecated
|
||||
public class PostgisPG95Dialect extends PostgreSQLDialect {
|
||||
public PostgisPG95Dialect(DialectResolutionInfo info) {
|
||||
super( info );
|
||||
}
|
||||
|
||||
public PostgisPG95Dialect() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PostgisPG95Dialect(int version) {
|
||||
super( version );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,13 +6,26 @@
|
|||
*/
|
||||
package org.hibernate.spatial.dialect.postgis;
|
||||
|
||||
import org.hibernate.dialect.PostgreSQL9Dialect;
|
||||
import org.hibernate.spatial.SpatialDialect;
|
||||
import org.hibernate.dialect.PostgreSQLDialect;
|
||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||
|
||||
/**
|
||||
* * Extends the {@code PostgreSQL9Dialect} to add support for the Postgis spatial types, functions and operators .
|
||||
* <p>
|
||||
* Created by Karel Maesen, Geovise BVBA on 01/11/16.
|
||||
*
|
||||
* @deprecated A SpatialDialect is no longer required. Use the standard Dialect for this database.
|
||||
*/
|
||||
public class PostgisPG9Dialect extends PostgreSQL9Dialect implements SpatialDialect {
|
||||
@Deprecated
|
||||
public class PostgisPG9Dialect extends PostgreSQLDialect {
|
||||
public PostgisPG9Dialect(DialectResolutionInfo info) {
|
||||
}
|
||||
|
||||
public PostgisPG9Dialect() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PostgisPG9Dialect(int version) {
|
||||
super( version );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial.dialect.postgis;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.query.sqm.function.NamedSqmFunctionDescriptor;
|
||||
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
|
||||
import org.hibernate.query.sqm.produce.function.StandardArgumentsValidators;
|
||||
import org.hibernate.query.sqm.produce.function.StandardFunctionReturnTypeResolvers;
|
||||
import org.hibernate.spatial.KeyedSqmFunctionDescriptors;
|
||||
import org.hibernate.spatial.FunctionKey;
|
||||
|
||||
import static org.hibernate.spatial.CommonSpatialFunction.*;
|
||||
|
||||
public class PostgisSqmFunctionDescriptors implements KeyedSqmFunctionDescriptors {
|
||||
|
||||
private final Map<FunctionKey, SqmFunctionDescriptor> map = new HashMap<>();
|
||||
|
||||
PostgisSqmFunctionDescriptors() {
|
||||
map.put(
|
||||
ST_GEOMETRYTYPE.getKey(), new NamedSqmFunctionDescriptor(
|
||||
ST_GEOMETRYTYPE.getKey().getName(),
|
||||
true,
|
||||
StandardArgumentsValidators.exactly( 1 ),
|
||||
StandardFunctionReturnTypeResolvers.invariant( ST_GEOMETRYTYPE.getReturnType() )
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
map.put(
|
||||
ST_ASTEXT.getKey(), new NamedSqmFunctionDescriptor(
|
||||
ST_ASTEXT.getKey().getName(),
|
||||
true,
|
||||
StandardArgumentsValidators.exactly( 1 ),
|
||||
StandardFunctionReturnTypeResolvers.invariant( ST_ASTEXT.getReturnType() )
|
||||
)
|
||||
);
|
||||
|
||||
map.put(
|
||||
ST_DIMENSION.getKey(), new NamedSqmFunctionDescriptor(
|
||||
ST_DIMENSION.getKey().getName(),
|
||||
true,
|
||||
StandardArgumentsValidators.exactly( 1 ),
|
||||
StandardFunctionReturnTypeResolvers.invariant( ST_DIMENSION.getReturnType() )
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public Map<FunctionKey, SqmFunctionDescriptor> asMap() {
|
||||
return Collections.unmodifiableMap( map );
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ package org.hibernate.spatial.dialect.postgis;
|
|||
import java.io.Serializable;
|
||||
import java.sql.Types;
|
||||
|
||||
import org.hibernate.annotations.Remove;
|
||||
import org.hibernate.boot.model.TypeContributions;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.spatial.GeolatteGeometryJavaTypeDescriptor;
|
||||
|
@ -24,6 +25,7 @@ import org.hibernate.spatial.dialect.SpatialFunctionsRegistry;
|
|||
/**
|
||||
* Created by Karel Maesen, Geovise BVBA on 29/10/16.
|
||||
*/
|
||||
@Deprecated
|
||||
public class PostgisSupport implements SpatialDialect, Serializable {
|
||||
|
||||
private final SpatialFunctionsRegistry postgisFunctions;
|
||||
|
|
|
@ -12,14 +12,5 @@
|
|||
<p>
|
||||
This package contains the spatial extensions for the Postgresql dialect.
|
||||
</p>
|
||||
<p>We provide two dialects for postgis</p>
|
||||
<ul>
|
||||
<li>PostgisDialect: this dialect uses the SQL/MM convention for spatial function names (using a 'ST_' prefix).
|
||||
It is recommended for use with Postgis version 1.3 or higher
|
||||
</li>
|
||||
<li>PostgisNoSQLMM: this dialect does not use the SQL/MM convention. Use it with older, pre-1.3 versions of
|
||||
Postgis
|
||||
</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<head></head>
|
||||
<body>
|
||||
<p>
|
||||
This package defines the central Hibernate Spatial APIs.
|
||||
This package defines the central Hibernate Spatial types and functions.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.locationtech.jts.io.WKBWriter;
|
|||
import org.locationtech.jts.io.WKTWriter;
|
||||
|
||||
@RequiresDialect(value = HANASpatialDialect.class, comment = "This test tests the HANA spatial functions not covered by Hibernate Spatial", jiraKey = "HHH-12426")
|
||||
@Deprecated
|
||||
public class TestHANASpatialFunctions extends TestSpatialFunctions {
|
||||
|
||||
private static final HSMessageLogger LOG = Logger.getMessageLogger(
|
||||
|
|
|
@ -23,4 +23,6 @@ public interface GeomEntityLike<G> {
|
|||
G getGeom();
|
||||
|
||||
void setGeom(G geom);
|
||||
|
||||
void setGeomFromWkt(String wkt);
|
||||
}
|
||||
|
|
|
@ -7,18 +7,16 @@
|
|||
|
||||
package org.hibernate.spatial.integration;
|
||||
|
||||
import java.sql.BatchUpdateException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Query;
|
||||
|
||||
import org.hibernate.cfg.NotYetImplementedException;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.spatial.testing.AbstractExpectationsFactory;
|
||||
import org.hibernate.spatial.testing.DataSourceUtils;
|
||||
import org.hibernate.spatial.testing.JTSGeometryEquality;
|
||||
import org.hibernate.spatial.testing.NativeSqlTemplates;
|
||||
import org.hibernate.spatial.testing.SQLExpressionTemplate;
|
||||
import org.hibernate.spatial.testing.TestSupportFactories;
|
||||
import org.hibernate.spatial.testing.datareader.TestData;
|
||||
import org.hibernate.spatial.testing.datareader.TestDataElement;
|
||||
import org.hibernate.spatial.testing.datareader.TestSupport;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DialectContext;
|
||||
|
@ -28,12 +26,14 @@ public class SpatialTestDataProvider {
|
|||
|
||||
protected TestData testData;
|
||||
protected JTSGeometryEquality geometryEquality;
|
||||
protected AbstractExpectationsFactory expectationsFactory;
|
||||
protected NativeSqlTemplates templates;
|
||||
|
||||
|
||||
|
||||
public SpatialTestDataProvider() {
|
||||
try {
|
||||
TestSupport support = TestSupportFactories.instance().getTestSupportFactory( DialectContext.getDialect() );
|
||||
templates = support.getNativeSqlTemplates();
|
||||
testData = support.createTestData( TestSupport.TestDataPurpose.StoreRetrieveData );
|
||||
geometryEquality = support.createGeometryEquality();
|
||||
}
|
||||
|
@ -42,22 +42,21 @@ public class SpatialTestDataProvider {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts the test data via a direct route (JDBC).
|
||||
*/
|
||||
public void prepareTest(SessionImplementor session) {
|
||||
throw new NotYetImplementedException();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected String entityName(String pckg) {
|
||||
if ( JTS.equalsIgnoreCase( pckg ) ) {
|
||||
return "org.hibernate.spatial.testing.domain.JtsGeomEntity";
|
||||
protected <T extends GeomEntityLike<?>> List<T> entities(Class<T> clazz) {
|
||||
try {
|
||||
List<T> entities = new ArrayList<>();
|
||||
for ( TestDataElement testDataElement : testData ) {
|
||||
T entity = clazz.getDeclaredConstructor().newInstance();
|
||||
entity.setGeomFromWkt( testDataElement.wkt );
|
||||
entity.setId( testDataElement.id );
|
||||
entity.setType( testDataElement.type );
|
||||
entities.add( entity );
|
||||
}
|
||||
return entities;
|
||||
}
|
||||
else {
|
||||
return "org.hibernate.spatial.testing.domain.GeomEntity";
|
||||
catch (Throwable ex) {
|
||||
throw new RuntimeException( ex );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -67,24 +67,6 @@ public class TestSpatialFunctions extends SpatialFunctionalTestCase {
|
|||
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_astext_on_jts() throws SQLException {
|
||||
astext( JTS );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_astext_on_geolatte() throws SQLException {
|
||||
astext( GEOLATTE );
|
||||
}
|
||||
|
||||
public void astext(String pckg) throws SQLException {
|
||||
if ( !isSupportedByDialect( SpatialFunction.astext ) ) {
|
||||
return;
|
||||
}
|
||||
Map<Integer, String> dbexpected = expectationsFactory.getAsText();
|
||||
String hql = format( "SELECT id, astext(geom) from %s", entityName( pckg ) );
|
||||
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_asbinary_on_jts() throws SQLException {
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial.integration.functions;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.hibernate.spatial.testing.BaseSpatialFunctionTestCase;
|
||||
import org.hibernate.spatial.testing.HQLTemplate;
|
||||
import org.hibernate.spatial.testing.NativeSQLTemplate;
|
||||
import org.hibernate.spatial.testing.RequiresFunction;
|
||||
import org.hibernate.spatial.testing.RowObjectMapper;
|
||||
|
||||
@RequiresFunction( key="st_astext" )
|
||||
public class AsTextFunctionTest extends BaseSpatialFunctionTestCase {
|
||||
@Override
|
||||
protected HQLTemplate jqlQueryTemplate() {
|
||||
return HQLTemplate.from("select g.id, st_astext(g.geom) from %s g");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLTemplate sqlTemplate() {
|
||||
return templates.createNativeAsTextTemplate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Function<Object, Object> mapper() {
|
||||
RowObjectMapper<String> rowObject = new RowObjectMapper<>() {};
|
||||
return rowObject.mapper();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial.integration.functions;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.hibernate.spatial.testing.BaseSpatialFunctionTestCase;
|
||||
import org.hibernate.spatial.testing.HQLTemplate;
|
||||
import org.hibernate.spatial.testing.NativeSQLTemplate;
|
||||
import org.hibernate.spatial.testing.RequiresFunction;
|
||||
import org.hibernate.spatial.testing.RowObjectMapper;
|
||||
|
||||
@RequiresFunction(key = "st_dimension")
|
||||
public class GetDimensionTest extends BaseSpatialFunctionTestCase {
|
||||
|
||||
@Override
|
||||
protected HQLTemplate jqlQueryTemplate() {
|
||||
return HQLTemplate.from( "select g.id, st_dimension(g.geom) from %s g" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLTemplate sqlTemplate() {
|
||||
return templates.createNativeDimensionTemplate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Function<Object, Object> mapper() {
|
||||
RowObjectMapper<Integer> rowObject = new RowObjectMapper<>() {
|
||||
};
|
||||
return rowObject.mapper();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial.integration.functions;/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.hibernate.spatial.testing.BaseSpatialFunctionTestCase;
|
||||
import org.hibernate.spatial.testing.HQLTemplate;
|
||||
import org.hibernate.spatial.testing.NativeSQLTemplate;
|
||||
import org.hibernate.spatial.testing.RequiresFunction;
|
||||
import org.hibernate.spatial.testing.RowObjectMapper;
|
||||
|
||||
@RequiresFunction(key = "st_geometrytype")
|
||||
public class GetGeometryTypeTest extends BaseSpatialFunctionTestCase {
|
||||
|
||||
@Override
|
||||
protected HQLTemplate jqlQueryTemplate() {
|
||||
return HQLTemplate.from( "select g.id, st_geometrytype(g.geom) from %s g" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLTemplate sqlTemplate() {
|
||||
return templates.createNativeGeometryTypeTemplate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Function<Object, Object> mapper() {
|
||||
RowObjectMapper<String> rowObject = new RowObjectMapper<>() {
|
||||
};
|
||||
return rowObject.mapper();
|
||||
}
|
||||
|
||||
}
|
|
@ -26,7 +26,6 @@ import org.locationtech.jts.io.ParseException;
|
|||
* This testsuite-suite class verifies whether the <code>Geometry</code>s retrieved
|
||||
* are equal to the <code>Geometry</code>s stored.
|
||||
*/
|
||||
@Skip(condition = SpatialDialectMatcher.class, message = "No Spatial Dialect")
|
||||
public class TestStoreRetrieveUsingJTS extends AbstractTestStoreRetrieve<Geometry, JtsGeomEntity> {
|
||||
|
||||
private static final HSMessageLogger LOG = Logger.getMessageLogger(
|
||||
|
|
|
@ -443,7 +443,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeTouchesStatement(Geometry geom);
|
||||
public abstract NativeSQLStatement createNativeTouchesStatement(Geometry geom);
|
||||
|
||||
/**
|
||||
* Returns a statement corresponding to the HQL statement:
|
||||
|
@ -453,7 +453,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeOverlapsStatement(Geometry geom);
|
||||
public abstract NativeSQLStatement createNativeOverlapsStatement(Geometry geom);
|
||||
|
||||
/**
|
||||
* Returns a statement corresponding to the HQL statement:
|
||||
|
@ -464,7 +464,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeRelateStatement(Geometry geom, String matrix);
|
||||
public abstract NativeSQLStatement createNativeRelateStatement(Geometry geom, String matrix);
|
||||
|
||||
/**
|
||||
* Returns a statement corresponding to the HQL statement:
|
||||
|
@ -475,7 +475,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeDwithinStatement(Point geom, double distance);
|
||||
public abstract NativeSQLStatement createNativeDwithinStatement(Point geom, double distance);
|
||||
|
||||
/**
|
||||
* Returns a statement corresponding to the HQL statement:
|
||||
|
@ -485,7 +485,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeIntersectsStatement(Geometry geom);
|
||||
public abstract NativeSQLStatement createNativeIntersectsStatement(Geometry geom);
|
||||
|
||||
/**
|
||||
* Returns the statement corresponding to the SpatialRestrictions.filter() method.
|
||||
|
@ -494,7 +494,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeFilterStatement(Geometry geom);
|
||||
public abstract NativeSQLStatement createNativeFilterStatement(Geometry geom);
|
||||
|
||||
/**
|
||||
* Returns a statement corresponding to the HQL statement:
|
||||
|
@ -504,7 +504,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeDistanceStatement(Geometry geom);
|
||||
public abstract NativeSQLStatement createNativeDistanceStatement(Geometry geom);
|
||||
|
||||
/**
|
||||
* Returns a statement corresponding to the HQL statement:
|
||||
|
@ -512,7 +512,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return the SQL String
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeDimensionSQL();
|
||||
public abstract NativeSQLStatement createNativeDimensionSQL();
|
||||
|
||||
/**
|
||||
* Returns a statement corresponding to the HQL statement:
|
||||
|
@ -522,7 +522,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return the native SQL Statement
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeBufferStatement(Double distance);
|
||||
public abstract NativeSQLStatement createNativeBufferStatement(Double distance);
|
||||
|
||||
/**
|
||||
* Returns a statement corresponding to the HQL statement:
|
||||
|
@ -532,7 +532,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeConvexHullStatement(Geometry geom);
|
||||
public abstract NativeSQLStatement createNativeConvexHullStatement(Geometry geom);
|
||||
|
||||
/**
|
||||
* Returns a statement corresponding to the HQL statement:
|
||||
|
@ -542,7 +542,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeIntersectionStatement(Geometry geom);
|
||||
public abstract NativeSQLStatement createNativeIntersectionStatement(Geometry geom);
|
||||
|
||||
/**
|
||||
* Returns a statement corresponding to the HQL statement:
|
||||
|
@ -552,7 +552,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeDifferenceStatement(Geometry geom);
|
||||
public abstract NativeSQLStatement createNativeDifferenceStatement(Geometry geom);
|
||||
|
||||
/**
|
||||
* Returns a statement corresponding to the HQL statement:
|
||||
|
@ -562,7 +562,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeSymDifferenceStatement(Geometry geom);
|
||||
public abstract NativeSQLStatement createNativeSymDifferenceStatement(Geometry geom);
|
||||
|
||||
/**
|
||||
* Returns a statement corresponding to the HQL statement:
|
||||
|
@ -572,7 +572,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeGeomUnionStatement(Geometry geom);
|
||||
public abstract NativeSQLStatement createNativeGeomUnionStatement(Geometry geom);
|
||||
|
||||
/**
|
||||
* Returns a statement corresponding to the HQL statement:
|
||||
|
@ -580,7 +580,11 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return the native SQL Statement
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeAsTextStatement();
|
||||
public abstract NativeSQLStatement createNativeAsTextStatement();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns a statement corresponding to the HQL statement:
|
||||
|
@ -588,7 +592,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return the native SQL Statement
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeSridStatement();
|
||||
public abstract NativeSQLStatement createNativeSridStatement();
|
||||
|
||||
/**
|
||||
* Returns a statement corresponding to the HQL statement:
|
||||
|
@ -596,7 +600,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return the native SQL Statement
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeIsSimpleStatement();
|
||||
public abstract NativeSQLStatement createNativeIsSimpleStatement();
|
||||
|
||||
/**
|
||||
* Returns a statement corresponding to the HQL statement:
|
||||
|
@ -604,7 +608,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return the native SQL Statement
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeIsEmptyStatement();
|
||||
public abstract NativeSQLStatement createNativeIsEmptyStatement();
|
||||
|
||||
|
||||
/**
|
||||
|
@ -613,7 +617,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeIsNotEmptyStatement();
|
||||
public abstract NativeSQLStatement createNativeIsNotEmptyStatement();
|
||||
|
||||
/**
|
||||
* Returns a statement corresponding to the HQL statement:
|
||||
|
@ -621,7 +625,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return the native SQL Statement
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeBoundaryStatement();
|
||||
public abstract NativeSQLStatement createNativeBoundaryStatement();
|
||||
|
||||
/**
|
||||
* Returns a statement corresponding to the HQL statement:
|
||||
|
@ -629,7 +633,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return the native SQL Statement
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeEnvelopeStatement();
|
||||
public abstract NativeSQLStatement createNativeEnvelopeStatement();
|
||||
|
||||
/**
|
||||
* Returns a statement corresponding to the HQL statement:
|
||||
|
@ -637,7 +641,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return the native SQL Statement
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeAsBinaryStatement();
|
||||
public abstract NativeSQLStatement createNativeAsBinaryStatement();
|
||||
|
||||
/**
|
||||
* Returns a statement corresponding to the HQL statement:
|
||||
|
@ -645,7 +649,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return the SQL String
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeGeometryTypeStatement();
|
||||
public abstract NativeSQLStatement createNativeGeometryTypeStatement();
|
||||
|
||||
/**
|
||||
* Returns a statement corresponding to the HQL statement
|
||||
|
@ -655,7 +659,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeWithinStatement(Geometry testPolygon);
|
||||
public abstract NativeSQLStatement createNativeWithinStatement(Geometry testPolygon);
|
||||
|
||||
/**
|
||||
* Returns a statement corresponding to the HQL statement
|
||||
|
@ -665,7 +669,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeEqualsStatement(Geometry geom);
|
||||
public abstract NativeSQLStatement createNativeEqualsStatement(Geometry geom);
|
||||
|
||||
/**
|
||||
* Returns a statement corresponding to the HQL statement
|
||||
|
@ -675,7 +679,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeCrossesStatement(Geometry geom);
|
||||
public abstract NativeSQLStatement createNativeCrossesStatement(Geometry geom);
|
||||
|
||||
/**
|
||||
* Returns a statement corresponding to the HQL statement:
|
||||
|
@ -685,7 +689,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeContainsStatement(Geometry geom);
|
||||
public abstract NativeSQLStatement createNativeContainsStatement(Geometry geom);
|
||||
|
||||
/**
|
||||
* Returns a statement corresponding to the HQL statement
|
||||
|
@ -695,7 +699,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeDisjointStatement(Geometry geom);
|
||||
public abstract NativeSQLStatement createNativeDisjointStatement(Geometry geom);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -706,7 +710,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeTransformStatement(int epsg);
|
||||
public abstract NativeSQLStatement createNativeTransformStatement(int epsg);
|
||||
|
||||
/**
|
||||
* Returns the statement corresponding to the HQL statement
|
||||
|
@ -716,7 +720,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract NativeSQLStatement createNativeHavingSRIDStatement(int srid);
|
||||
public abstract NativeSQLStatement createNativeHavingSRIDStatement(int srid);
|
||||
|
||||
/**
|
||||
* Creates a connection to the database
|
||||
|
@ -849,7 +853,12 @@ public abstract class AbstractExpectationsFactory {
|
|||
}
|
||||
}
|
||||
|
||||
protected NativeSQLStatement createNativeSQLStatement(final String sql) {
|
||||
|
||||
public NativeSQLStatement createNativeSQSStatement(final NativeSQLTemplate template, final String table) {
|
||||
return createNativeSQLStatement( template.mkNativeSQLString( table ) );
|
||||
}
|
||||
|
||||
public NativeSQLStatement createNativeSQLStatement(final String sql) {
|
||||
return new NativeSQLStatement() {
|
||||
public PreparedStatement prepare(Connection connection) throws SQLException {
|
||||
return connection.prepareStatement( sql );
|
||||
|
@ -861,7 +870,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
};
|
||||
}
|
||||
|
||||
protected NativeSQLStatement createNativeSQLStatementAllWKTParams(final String sql, final String wkt) {
|
||||
public NativeSQLStatement createNativeSQLStatementAllWKTParams(final String sql, final String wkt) {
|
||||
return new NativeSQLStatement() {
|
||||
public PreparedStatement prepare(Connection connection) throws SQLException {
|
||||
PreparedStatement pstmt = connection.prepareStatement( sql );
|
||||
|
@ -877,7 +886,7 @@ public abstract class AbstractExpectationsFactory {
|
|||
};
|
||||
}
|
||||
|
||||
protected NativeSQLStatement createNativeSQLStatement(final String sql, final Object[] params) {
|
||||
public NativeSQLStatement createNativeSQLStatement(final String sql, final Object[] params) {
|
||||
return new NativeSQLStatement() {
|
||||
public PreparedStatement prepare(Connection connection) throws SQLException {
|
||||
PreparedStatement pstmt = connection.prepareStatement( sql );
|
||||
|
@ -898,4 +907,6 @@ public abstract class AbstractExpectationsFactory {
|
|||
protected int numPlaceHoldersInSQL(String sql) {
|
||||
return sql.replaceAll( "[^?]", "" ).length();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial.testing;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.spatial.integration.SpatialTestDataProvider;
|
||||
import org.hibernate.spatial.testing.HQLTemplate;
|
||||
import org.hibernate.spatial.testing.NativeSQLTemplate;
|
||||
import org.hibernate.spatial.testing.domain.GeomEntity;
|
||||
import org.hibernate.spatial.testing.domain.JtsGeomEntity;
|
||||
import org.hibernate.spatial.testing.domain.SpatialDomainModel;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScopeAware;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
@DomainModel(modelDescriptorClasses = SpatialDomainModel.class)
|
||||
@SessionFactory
|
||||
public abstract class BaseSpatialFunctionTestCase extends SpatialTestDataProvider
|
||||
implements SessionFactoryScopeAware {
|
||||
|
||||
private SessionFactoryScope scope;
|
||||
List received;
|
||||
List expected;
|
||||
|
||||
@Override
|
||||
public void injectSessionFactoryScope(SessionFactoryScope scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
public void beforeEach() {
|
||||
scope.inTransaction( session -> super.entities( JtsGeomEntity.class ).forEach( session::save ) );
|
||||
scope.inTransaction( session -> super.entities( GeomEntity.class ).forEach( session::save ) );
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void cleanup() {
|
||||
scope.inTransaction( session -> session.createQuery( "delete from GeomEntity" ).executeUpdate() );
|
||||
scope.inTransaction( session -> session.createQuery( "delete from JtsGeomEntity" ).executeUpdate() );
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(classes = { GeomEntity.class, JtsGeomEntity.class })
|
||||
public void testFunction(Class entityClass) {
|
||||
PersistentClass geomEntity = scope.getMetadataImplementor().getEntityBinding( entityClass.getCanonicalName() );
|
||||
String table = geomEntity.getTable().getName();
|
||||
scope.inSession( session -> {
|
||||
expected = (List) session.createNativeQuery(
|
||||
sqlTemplate().mkNativeSQLString( table ) )
|
||||
.getResultList()
|
||||
.stream().map( mapper() )
|
||||
.collect( Collectors.toList() );
|
||||
} );
|
||||
|
||||
scope.inSession( session -> {
|
||||
received = (List) session.createQuery( jqlQueryTemplate().mkHQLString( entityClass.getCanonicalName() ) )
|
||||
.getResultList()
|
||||
.stream()
|
||||
.map( mapper() )
|
||||
.collect( Collectors.toList() );
|
||||
} );
|
||||
assertEquals( expected, received );
|
||||
}
|
||||
|
||||
protected abstract HQLTemplate jqlQueryTemplate();
|
||||
|
||||
protected abstract NativeSQLTemplate sqlTemplate();
|
||||
|
||||
protected abstract Function<Object, Object> mapper();
|
||||
|
||||
}
|
|
@ -42,6 +42,7 @@ import org.geolatte.geom.codec.WktDecoder;
|
|||
*
|
||||
* @author Karel Maesen, Geovise BVBA.
|
||||
*/
|
||||
@Deprecated
|
||||
public class DataSourceUtils {
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial.testing;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class HQLTemplate {
|
||||
|
||||
final private String hqlTemplate;
|
||||
|
||||
public HQLTemplate(String template) {
|
||||
this.hqlTemplate = template;
|
||||
}
|
||||
|
||||
public static HQLTemplate from(String s) {
|
||||
return new HQLTemplate( s );
|
||||
}
|
||||
|
||||
public String mkHQLString(Object... params) {
|
||||
return String.format( Locale.ROOT, hqlTemplate, params );
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@ import java.sql.SQLException;
|
|||
*
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
*/
|
||||
@Deprecated
|
||||
public interface NativeSQLStatement {
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial.testing;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Template for native SQL statement
|
||||
* <p>
|
||||
* This is mainly introduced to avoid a confusion between template and non-template Strings.
|
||||
*/
|
||||
public class NativeSQLTemplate {
|
||||
|
||||
final private String nativeSql;
|
||||
|
||||
public NativeSQLTemplate(String template) {
|
||||
this.nativeSql = template;
|
||||
}
|
||||
|
||||
public String mkNativeSQLString(Object... params) {
|
||||
return String.format( Locale.ROOT, nativeSql, params );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial.testing;
|
||||
|
||||
public class NativeSqlTemplates {
|
||||
|
||||
|
||||
public NativeSQLTemplate createNativeAsTextTemplate() {
|
||||
return new NativeSQLTemplate( "select id, st_astext(geom) from %s" );
|
||||
}
|
||||
|
||||
public NativeSQLTemplate createNativeGeometryTypeTemplate() {
|
||||
return new NativeSQLTemplate( "select id, st_geometrytype(geom) from %s" );
|
||||
}
|
||||
|
||||
public NativeSQLTemplate createNativeDimensionTemplate() {
|
||||
return new NativeSQLTemplate( "select id, st_dimension(geom) from %s" );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial.testing;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
|
||||
import org.hibernate.spatial.contributor.SpatialFunctionContributor;
|
||||
|
||||
import org.hibernate.testing.orm.junit.JUnitHelper;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryExtension;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.hibernate.testing.orm.junit.TestingUtil;
|
||||
import org.junit.jupiter.api.extension.ConditionEvaluationResult;
|
||||
import org.junit.jupiter.api.extension.ExecutionCondition;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
public class RequireFunctionExtension implements ExecutionCondition {
|
||||
|
||||
private static final ConditionEvaluationResult ENABLED = ConditionEvaluationResult.enabled(
|
||||
"No applicable @RequireFunction annotation" );
|
||||
|
||||
private static final Logger log = Logger.getLogger( RequireFunctionExtension.class );
|
||||
|
||||
@Override
|
||||
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
|
||||
Optional<Object> testInstance = context.getTestInstance();
|
||||
|
||||
if ( testInstance.isEmpty() ) {
|
||||
return ENABLED;
|
||||
}
|
||||
|
||||
final SqmFunctionRegistry functionRegistry = new SqmFunctionRegistry();
|
||||
|
||||
ExtensionContext.Store store = JUnitHelper.locateExtensionStore(
|
||||
SessionFactoryExtension.class,
|
||||
context,
|
||||
testInstance.get()
|
||||
);
|
||||
|
||||
final SessionFactoryScope existing = (SessionFactoryScope) store.get( SessionFactoryScope.class.getName() );
|
||||
|
||||
if ( existing == null ) {
|
||||
return ConditionEvaluationResult.enabled( "" );
|
||||
}
|
||||
|
||||
final Optional<RequiresFunction> requiresFunctions = TestingUtil.findEffectiveAnnotation(
|
||||
context,
|
||||
RequiresFunction.class
|
||||
);
|
||||
|
||||
if ( requiresFunctions.isPresent() ) {
|
||||
String functionKey = requiresFunctions.get().key();
|
||||
SpatialFunctionContributor contributor = new SpatialFunctionContributor();
|
||||
contributor.contributeTypes(
|
||||
functionRegistry::register,
|
||||
existing.getSessionFactory().getServiceRegistry()
|
||||
);
|
||||
if ( functionRegistry.findFunctionDescriptor( functionKey ) == null ) {
|
||||
return ConditionEvaluationResult.disabled( String.format(
|
||||
Locale.ROOT,
|
||||
"Failed: Required function %s is not available", functionKey
|
||||
) );
|
||||
}
|
||||
return ConditionEvaluationResult.enabled( "Required function is supported" );
|
||||
}
|
||||
|
||||
return ENABLED;
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial.testing;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistryExtension;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryExtension;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
|
||||
/**
|
||||
* Indicates that the annotated test class/method should
|
||||
* only be run when the current Dialect supports the function.
|
||||
*
|
||||
* @author Karel Maesen
|
||||
*/
|
||||
|
||||
@Inherited
|
||||
@Target({ ElementType.METHOD, ElementType.TYPE, ElementType.ANNOTATION_TYPE })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
||||
@ExtendWith({ SessionFactoryExtension.class, RequireFunctionExtension.class })
|
||||
public @interface RequiresFunction {
|
||||
/**
|
||||
* The key for the function (as used in the SqmFunctionRegistry)
|
||||
*/
|
||||
String key();
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial.testing;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
|
||||
public interface RowObjectMapper<T> {
|
||||
|
||||
|
||||
default Function<Object, Object> mapper() {
|
||||
return obj -> {
|
||||
Object[] row = (Object[]) obj;
|
||||
return new Data<>( (Integer) row[0], (T) row[1] );
|
||||
};
|
||||
}
|
||||
|
||||
static class Data<T> {
|
||||
final private Integer id;
|
||||
final private T datum;
|
||||
|
||||
Data(Integer id, T datum) {
|
||||
this.id = id;
|
||||
this.datum = datum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ( this == o ) {
|
||||
return true;
|
||||
}
|
||||
if ( o == null || getClass() != o.getClass() ) {
|
||||
return false;
|
||||
}
|
||||
Data data = (Data) o;
|
||||
return Objects.equals( id, data.id ) && Objects.equals( datum, data.datum );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash( id, datum );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Data{" +
|
||||
"id=" + id +
|
||||
", datum=" + datum +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
package org.hibernate.spatial.testing;
|
||||
|
||||
import org.hibernate.cfg.NotYetImplementedException;
|
||||
import org.hibernate.spatial.testing.datareader.TestDataElement;
|
||||
|
||||
/**
|
||||
|
@ -15,6 +16,7 @@ import org.hibernate.spatial.testing.datareader.TestDataElement;
|
|||
*
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
*/
|
||||
@Deprecated
|
||||
public interface SQLExpressionTemplate {
|
||||
|
||||
/**
|
||||
|
@ -26,4 +28,8 @@ public interface SQLExpressionTemplate {
|
|||
*/
|
||||
String toInsertSql(TestDataElement testDataElement);
|
||||
|
||||
default String toInsertSql(TestDataElement testDataElement, String tableName) {
|
||||
throw new NotYetImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ import static org.junit.Assert.fail;
|
|||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: Sep 30, 2010
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class SpatialFunctionalTestCase extends BaseCoreFunctionalTestCase {
|
||||
|
||||
protected final static String JTS = "jts";
|
||||
|
@ -111,8 +112,7 @@ public abstract class SpatialFunctionalTestCase extends BaseCoreFunctionalTestCa
|
|||
private void initializeSpatialTestSupport(ServiceRegistry serviceRegistry) {
|
||||
try {
|
||||
TestSupport support = TestSupportFactories.instance().getTestSupportFactory( getDialect() );
|
||||
dataSourceUtils = support.createDataSourceUtil( serviceRegistry );
|
||||
expectationsFactory = support.createExpectationsFactory( dataSourceUtils );
|
||||
expectationsFactory = support.createExpectationsFactory( null );
|
||||
testData = support.createTestData( TestSupport.TestDataPurpose.StoreRetrieveData );
|
||||
geometryEquality = support.createGeometryEquality();
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.hibernate.spatial.testing.dialects.sqlserver.SQLServerTestSupport;
|
|||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: Sep 30, 2010
|
||||
*/
|
||||
@Deprecated
|
||||
public class TestSupportFactories {
|
||||
|
||||
private static final TestSupportFactories instance = new TestSupportFactories();
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.hibernate.service.ServiceRegistry;
|
|||
import org.hibernate.spatial.testing.AbstractExpectationsFactory;
|
||||
import org.hibernate.spatial.testing.DataSourceUtils;
|
||||
import org.hibernate.spatial.testing.JTSGeometryEquality;
|
||||
import org.hibernate.spatial.testing.NativeSqlTemplates;
|
||||
import org.hibernate.spatial.testing.SQLExpressionTemplate;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
|
@ -33,6 +34,12 @@ import junit.framework.TestCase;
|
|||
@Deprecated
|
||||
public abstract class TestSupport {
|
||||
|
||||
//TODO -- make this abstract
|
||||
|
||||
public NativeSqlTemplates getNativeSqlTemplates() {
|
||||
return null;
|
||||
};
|
||||
|
||||
public enum TestDataPurpose {
|
||||
SpatialFunctionsData,
|
||||
StoreRetrieveData
|
||||
|
@ -40,10 +47,7 @@ public abstract class TestSupport {
|
|||
|
||||
protected ConfigurationService configurationService;
|
||||
|
||||
public DataSourceUtils createDataSourceUtil(ServiceRegistry serviceRegistry) {
|
||||
this.configurationService = serviceRegistry.getService( ConfigurationService.class );
|
||||
return new DataSourceUtils( driver(), url(), user(), passwd(), getSQLExpressionTemplate() );
|
||||
}
|
||||
|
||||
|
||||
public JTSGeometryEquality createGeometryEquality() {
|
||||
return new JTSGeometryEquality();
|
||||
|
|
|
@ -44,13 +44,13 @@ public class DB2ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
return retrieveExpected( createNativeExtentStatement(), GEOMETRY );
|
||||
}
|
||||
|
||||
protected NativeSQLStatement createNativeExtentStatement() {
|
||||
public NativeSQLStatement createNativeExtentStatement() {
|
||||
return createNativeSQLStatement(
|
||||
"select max(t.id), db2gse.ST_GetAggrResult(MAX(db2gse.st_BuildMBRAggr(t.geom))) from GeomTest t where db2gse.st_srid(t.geom) = 4326" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, DB2GSE.ST_touches(t.geom, DB2GSE.ST_GeomFromText(?, 4326)) from GeomTest t where DB2GSE.ST_touches(t.geom, DB2GSE.ST_geomFromText(?, 4326)) = 1 and db2gse.st_srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -58,7 +58,7 @@ public class DB2ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, DB2GSE.ST_overlaps(t.geom, DB2GSE.ST_GeomFromText(?, 4326)) from GeomTest t where DB2GSE.ST_overlaps(t.geom, DB2GSE.ST_GeomFromText(?, 4326)) = 1 and db2gse.st_srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -66,19 +66,19 @@ public class DB2ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeRelateStatement(Geometry geom, String matrix) {
|
||||
public NativeSQLStatement createNativeRelateStatement(Geometry geom, String matrix) {
|
||||
String sql = "select t.id, DB2GSE.ST_relate(t.geom, DB2GSE.ST_GeomFromText(?, 4326), '" + matrix + "' ) from GeomTest t where DB2GSE.ST_relate(t.geom, DB2GSE.ST_GeomFromText(?, 4326), '" + matrix + "') = 1 and db2gse.st_srid(t.geom) = 4326";
|
||||
return createNativeSQLStatementAllWKTParams( sql, geom.toText() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDwithinStatement(Point geom, double distance) {
|
||||
public NativeSQLStatement createNativeDwithinStatement(Point geom, double distance) {
|
||||
String sql = "select t.id, DB2GSE.ST_dwithin(DB2GSE.ST_GeomFromText(?, 4326), t.geom, " + distance + " , 'METER') from GeomTest t where DB2GSE.ST_dwithin(DB2GSE.ST_GeomFromText(?, 4326), t.geom, " + distance + ", 'METER') = 1 and db2gse.st_srid(t.geom) = 4326";
|
||||
return createNativeSQLStatementAllWKTParams( sql, geom.toText() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, DB2GSE.ST_intersects(t.geom, DB2GSE.ST_GeomFromText(?, 4326)) from GeomTest t where DB2GSE.ST_intersects(t.geom, DB2GSE.ST_GeomFromText(?, 4326)) = 1 and db2gse.st_srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -86,7 +86,7 @@ public class DB2ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeFilterStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeFilterStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom && ST_GeomFromText(?, 4326) from GeomTest t where DB2GSE.ST_intersects(t.geom, DB2GSE.ST_GeomFromText(?, 4326)) = 1 and db2gse.st_srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -94,7 +94,7 @@ public class DB2ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDistanceStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDistanceStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, DB2GSE.ST_distance(t.geom, DB2GSE.ST_GeomFromText(?, 4326)) from GeomTest t where DB2GSE.ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -102,12 +102,12 @@ public class DB2ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDimensionSQL() {
|
||||
public NativeSQLStatement createNativeDimensionSQL() {
|
||||
return createNativeSQLStatement( "select id, DB2GSE.ST_dimension(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeBufferStatement(Double distance) {
|
||||
public NativeSQLStatement createNativeBufferStatement(Double distance) {
|
||||
return createNativeSQLStatement(
|
||||
"select t.id, DB2GSE.ST_buffer(t.geom,?) from GeomTest t where DB2GSE.ST_SRID(t.geom) = 4326",
|
||||
new Object[] { distance }
|
||||
|
@ -115,7 +115,7 @@ public class DB2ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeConvexHullStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeConvexHullStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, DB2GSE.ST_convexhull(DB2GSE.ST_Union(t.geom, DB2GSE.ST_GeomFromText(?, 4326))) from GeomTest t where DB2GSE.ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -123,7 +123,7 @@ public class DB2ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIntersectionStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeIntersectionStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, DB2GSE.ST_intersection(t.geom, DB2GSE.ST_GeomFromText(?, 4326)) from GeomTest t where DB2GSE.ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -131,7 +131,7 @@ public class DB2ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDifferenceStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDifferenceStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, DB2GSE.ST_difference(t.geom, DB2GSE.ST_GeomFromText(?, 4326)) from GeomTest t where DB2GSE.ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -139,7 +139,7 @@ public class DB2ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeSymDifferenceStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeSymDifferenceStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, DB2GSE.ST_symdifference(t.geom, DB2GSE.ST_GeomFromText(?, 4326)) from GeomTest t where DB2GSE.ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -147,7 +147,7 @@ public class DB2ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeGeomUnionStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeGeomUnionStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, DB2GSE.ST_union(t.geom, DB2GSE.ST_GeomFromText(?, 4326)) from GeomTest t where DB2GSE.ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -155,68 +155,68 @@ public class DB2ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeTransformStatement(int epsg) {
|
||||
public NativeSQLStatement createNativeTransformStatement(int epsg) {
|
||||
return createNativeSQLStatement(
|
||||
"select t.id, DB2GSE.ST_transform(t.geom," + epsg + ") from GeomTest t where DB2GSE.ST_SRID(t.geom) = 4326"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeHavingSRIDStatement(int srid) {
|
||||
public NativeSQLStatement createNativeHavingSRIDStatement(int srid) {
|
||||
return createNativeSQLStatement(
|
||||
"select t.id, DB2GSE.st_srid(t.geom) from GeomTest t where DB2GSE.ST_SRID(t.geom) = " + srid );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeAsTextStatement() {
|
||||
public NativeSQLStatement createNativeAsTextStatement() {
|
||||
return createNativeSQLStatement( "select id, DB2GSE.st_astext(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeSridStatement() {
|
||||
public NativeSQLStatement createNativeSridStatement() {
|
||||
return createNativeSQLStatement( "select id, DB2GSE.ST_SRID(geom) from geomtest" );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsSimpleStatement() {
|
||||
public NativeSQLStatement createNativeIsSimpleStatement() {
|
||||
return createNativeSQLStatement( "select id, DB2GSE.ST_issimple(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsEmptyStatement() {
|
||||
public NativeSQLStatement createNativeIsEmptyStatement() {
|
||||
return createNativeSQLStatement(
|
||||
"select id, DB2GSE.ST_isempty(geom) from geomtest where db2gse.ST_IsEmpty(geom) = 1" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsNotEmptyStatement() { // return 'not ST_IsEmpty', 'not' is not supported by DB2
|
||||
public NativeSQLStatement createNativeIsNotEmptyStatement() { // return 'not ST_IsEmpty', 'not' is not supported by DB2
|
||||
return createNativeSQLStatement(
|
||||
"select id, case when DB2GSE.ST_isempty(geom) = 0 then 1 else 0 end from geomtest where db2gse.ST_IsEmpty(geom) = 0" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeBoundaryStatement() {
|
||||
public NativeSQLStatement createNativeBoundaryStatement() {
|
||||
return createNativeSQLStatement( "select id, DB2GSE.ST_boundary(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeEnvelopeStatement() {
|
||||
public NativeSQLStatement createNativeEnvelopeStatement() {
|
||||
return createNativeSQLStatement( "select id, DB2GSE.ST_envelope(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeAsBinaryStatement() {
|
||||
public NativeSQLStatement createNativeAsBinaryStatement() {
|
||||
return createNativeSQLStatement( "select id, DB2GSE.ST_asbinary(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeGeometryTypeStatement() {
|
||||
public NativeSQLStatement createNativeGeometryTypeStatement() {
|
||||
return createNativeSQLStatement( "select id, DB2GSE.ST_GeometryType(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeWithinStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeWithinStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, DB2GSE.ST_within(t.geom, DB2GSE.ST_GeomFromText(?, 4326)) from GeomTest t where DB2GSE.ST_within(t.geom, DB2GSE.ST_GeomFromText(?, 4326)) = 1 and db2gse.st_srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -224,7 +224,7 @@ public class DB2ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeEqualsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeEqualsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, DB2GSE.ST_equals(t.geom, DB2GSE.ST_GeomFromText(?, 4326)) from GeomTest t where DB2GSE.ST_equals(t.geom, DB2GSE.ST_GeomFromText(?, 4326)) = 1 and db2gse.st_srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -232,7 +232,7 @@ public class DB2ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, DB2GSE.ST_crosses(t.geom, DB2GSE.ST_GeomFromText(?, 4326)) from GeomTest t where DB2GSE.ST_crosses(t.geom, DB2GSE.ST_GeomFromText(?, 4326)) = 1 and db2gse.st_srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -240,7 +240,7 @@ public class DB2ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeContainsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeContainsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, DB2GSE.ST_contains(t.geom, DB2GSE.ST_GeomFromText(?, 4326)) from GeomTest t where DB2GSE.ST_contains(t.geom, DB2GSE.ST_GeomFromText(?, 4326)) = 1 and db2gse.st_srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -248,7 +248,7 @@ public class DB2ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, DB2GSE.ST_disjoint(t.geom, DB2GSE.ST_GeomFromText(?, 4326)) from GeomTest t where DB2GSE.ST_disjoint(t.geom, DB2GSE.ST_GeomFromText(?, 4326)) = 1 and db2gse.st_srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
|
|
@ -32,22 +32,22 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeAsBinaryStatement() {
|
||||
public NativeSQLStatement createNativeAsBinaryStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_AsEWKB(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeAsTextStatement() {
|
||||
public NativeSQLStatement createNativeAsTextStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_AsText(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeBoundaryStatement() {
|
||||
public NativeSQLStatement createNativeBoundaryStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_Boundary(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeBufferStatement(Double distance) {
|
||||
public NativeSQLStatement createNativeBufferStatement(Double distance) {
|
||||
return createNativeSQLStatement(
|
||||
"select t.id, ST_Buffer(t.geom,?) from GEOMTEST t where ST_SRID(t.geom) = 4326",
|
||||
new Object[] { distance }
|
||||
|
@ -55,7 +55,7 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeContainsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeContainsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Contains(t.geom, ST_GeomFromText(?, 4326)) from GEOMTEST t where ST_Contains(t.geom, ST_GeomFromText(?, 4326)) = 1 and ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -63,7 +63,7 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeConvexHullStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeConvexHullStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_ConvexHull(ST_Union(t.geom, ST_GeomFromText(?, 4326))) from GeomTest t where ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -71,7 +71,7 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Crosses(t.geom, ST_GeomFromText(?, 4326)) from GEOMTEST t where ST_Crosses(t.geom, ST_GeomFromText(?, 4326)) = 1 and ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -79,19 +79,19 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDifferenceStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDifferenceStatement(Geometry geom) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Method ST_Difference() is not implemented in the current version of GeoDB."
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDimensionSQL() {
|
||||
public NativeSQLStatement createNativeDimensionSQL() {
|
||||
return createNativeSQLStatement( "select id, ST_Dimension(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Disjoint(t.geom, ST_GeomFromText(?, 4326)) from GEOMTEST t where ST_Disjoint(t.geom, ST_GeomFromText(?, 4326)) = 1 and ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -99,12 +99,12 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeTransformStatement(int epsg) {
|
||||
public NativeSQLStatement createNativeTransformStatement(int epsg) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeHavingSRIDStatement(int srid) {
|
||||
public NativeSQLStatement createNativeHavingSRIDStatement(int srid) {
|
||||
return createNativeSQLStatement(
|
||||
"select t.id, (ST_SRID(t.geom) = "
|
||||
+ srid + ") from GeomTest t where ST_SRID(t.geom) = " + srid
|
||||
|
@ -119,7 +119,7 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDistanceStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDistanceStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, st_distance(t.geom, ST_GeomFromText(?, 4326)) from GeomTest t where ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -134,7 +134,7 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeEnvelopeStatement() {
|
||||
public NativeSQLStatement createNativeEnvelopeStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_Envelope(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeEqualsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeEqualsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Equals(t.geom, ST_GeomFromText(?, 4326)) from GEOMTEST t where ST_Equals(t.geom, ST_GeomFromText(?, 4326)) = 1 and ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -161,7 +161,7 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeFilterStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeFilterStatement(Geometry geom) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Filter is not implemented in the current version of GeoDB."
|
||||
);
|
||||
|
@ -175,7 +175,7 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeGeomUnionStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeGeomUnionStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Union(t.geom, ST_GeomFromText(?, 4326)) from GEOMTEST t where ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -190,7 +190,7 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeGeometryTypeStatement() {
|
||||
public NativeSQLStatement createNativeGeometryTypeStatement() {
|
||||
return createNativeSQLStatement( "select id, GeometryType(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
|
@ -202,7 +202,7 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIntersectionStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeIntersectionStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Intersection(t.geom, ST_GeomFromText(?, 4326)) from GEOMTEST t where ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -217,7 +217,7 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Intersects(t.geom, ST_GeomFromText(?, 4326)) from GEOMTEST t where ST_Intersects(t.geom, ST_GeomFromText(?, 4326)) = 1 and ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -232,12 +232,12 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsEmptyStatement() {
|
||||
public NativeSQLStatement createNativeIsEmptyStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_IsEmpty(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsNotEmptyStatement() {
|
||||
public NativeSQLStatement createNativeIsNotEmptyStatement() {
|
||||
return createNativeSQLStatement( "select id, not ST_IsEmpty(geom) from geomtest" );
|
||||
}
|
||||
|
||||
|
@ -249,7 +249,7 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsSimpleStatement() {
|
||||
public NativeSQLStatement createNativeIsSimpleStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_IsSimple(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
|
@ -261,7 +261,7 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Overlaps(t.geom, ST_GeomFromText(?, 4326)) from GEOMTEST t where ST_Overlaps(t.geom, ST_GeomFromText(?, 4326)) = 1 and ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -277,7 +277,7 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeRelateStatement(
|
||||
public NativeSQLStatement createNativeRelateStatement(
|
||||
Geometry geom,
|
||||
String matrix) {
|
||||
String sql = "select t.id, ST_Relate(t.geom, ST_GeomFromText(?, 4326), '" + matrix + "' ) from GEOMTEST t where ST_Relate(t.geom, ST_GeomFromText(?, 4326), '" + matrix + "') = 'true' and ST_SRID(t.geom) = 4326";
|
||||
|
@ -285,7 +285,7 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDwithinStatement(
|
||||
public NativeSQLStatement createNativeDwithinStatement(
|
||||
Point geom,
|
||||
double distance) {
|
||||
String sql = "select t.id, ST_DWithin(t.geom, ST_GeomFromText(?, 4326), "
|
||||
|
@ -303,7 +303,7 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeSridStatement() {
|
||||
public NativeSQLStatement createNativeSridStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_SRID(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,7 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeSymDifferenceStatement(
|
||||
public NativeSQLStatement createNativeSymDifferenceStatement(
|
||||
Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_SymDifference(t.geom, ST_GeomFromText(?, 4326)) from GEOMTEST t where ST_SRID(t.geom) = 4326",
|
||||
|
@ -331,7 +331,7 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Touches(t.geom, ST_GeomFromText(?, 4326)) from GEOMTEST t where ST_Touches(t.geom, ST_GeomFromText(?, 4326)) = 1 and ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -346,7 +346,7 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeWithinStatement(
|
||||
public NativeSQLStatement createNativeWithinStatement(
|
||||
Geometry testPolygon) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Within(t.geom, ST_GeomFromText(?, 4326)) from GEOMTEST t where ST_Within(t.geom, ST_GeomFromText(?, 4326)) = 1 and ST_SRID(t.geom) = 4326",
|
||||
|
|
|
@ -35,24 +35,24 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeAsBinaryStatement() {
|
||||
public NativeSQLStatement createNativeAsBinaryStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_AsEWKB(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeAsTextStatement() {
|
||||
public NativeSQLStatement createNativeAsTextStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_AsText(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeBoundaryStatement() {
|
||||
public NativeSQLStatement createNativeBoundaryStatement() {
|
||||
throw new UnsupportedOperationException(
|
||||
"Method ST_Bounday() is not implemented in the current version of GeoDB."
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeBufferStatement(Double distance) {
|
||||
public NativeSQLStatement createNativeBufferStatement(Double distance) {
|
||||
return createNativeSQLStatement(
|
||||
"select t.id, ST_Buffer(t.geom,?) from GEOMTEST t where ST_SRID(t.geom) = 4326",
|
||||
new Object[] { distance }
|
||||
|
@ -60,7 +60,7 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeContainsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeContainsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Contains(t.geom, ST_GeomFromText(?, 4326)) from GEOMTEST t where ST_Contains(t.geom, ST_GeomFromText(?, 4326)) = 1",
|
||||
geom.toText()
|
||||
|
@ -68,14 +68,14 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeConvexHullStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeConvexHullStatement(Geometry geom) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Method ST_ConvexHull() is not implemented in the current version of GeoDB."
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Crosses(t.geom, ST_GeomFromText(?, 4326)) from GEOMTEST t where ST_Crosses(t.geom, ST_GeomFromText(?, 4326)) = 1",
|
||||
geom.toText()
|
||||
|
@ -83,21 +83,21 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDifferenceStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDifferenceStatement(Geometry geom) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Method ST_Difference() is not implemented in the current version of GeoDB."
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDimensionSQL() {
|
||||
public NativeSQLStatement createNativeDimensionSQL() {
|
||||
throw new UnsupportedOperationException(
|
||||
"Method ST_Dimension() is not implemented in the current version of GeoDB."
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Disjoint(t.geom, ST_GeomFromText(?, 4326)) from GEOMTEST t where ST_Disjoint(t.geom, ST_GeomFromText(?, 4326)) = 1",
|
||||
geom.toText()
|
||||
|
@ -105,17 +105,17 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeTransformStatement(int epsg) {
|
||||
public NativeSQLStatement createNativeTransformStatement(int epsg) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeHavingSRIDStatement(int srid) {
|
||||
public NativeSQLStatement createNativeHavingSRIDStatement(int srid) {
|
||||
return createNativeSQLStatement( "select t.id, (st_srid(t.geom) = " + srid + ") from GeomTest t where ST_SRID(t.geom) = " + srid );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDistanceStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDistanceStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, st_distance(t.geom, ST_GeomFromText(?, 4326)) from GeomTest t where ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -123,12 +123,12 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeEnvelopeStatement() {
|
||||
public NativeSQLStatement createNativeEnvelopeStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_Envelope(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeEqualsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeEqualsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Equals(t.geom, ST_GeomFromText(?, 4326)) from GEOMTEST t where ST_Equals(t.geom, ST_GeomFromText(?, 4326)) = 1",
|
||||
geom.toText()
|
||||
|
@ -136,33 +136,33 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeFilterStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeFilterStatement(Geometry geom) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Method ST_MBRIntersects() is not implemented in the current version of GeoDB."
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeGeomUnionStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeGeomUnionStatement(Geometry geom) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Method ST_GeomUnion() is not implemented in the current version of GeoDB."
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeGeometryTypeStatement() {
|
||||
public NativeSQLStatement createNativeGeometryTypeStatement() {
|
||||
return createNativeSQLStatement( "select id, GeometryType(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIntersectionStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeIntersectionStatement(Geometry geom) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Method ST_Intersection() is not implemented in the current version of GeoDB."
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Intersects(t.geom, ST_GeomFromText(?, 4326)) from GEOMTEST t where ST_Intersects(t.geom, ST_GeomFromText(?, 4326)) = 1",
|
||||
geom.toText()
|
||||
|
@ -170,22 +170,22 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsEmptyStatement() {
|
||||
public NativeSQLStatement createNativeIsEmptyStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_IsEmpty(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsNotEmptyStatement() {
|
||||
public NativeSQLStatement createNativeIsNotEmptyStatement() {
|
||||
return createNativeSQLStatement( "select id, not ST_IsEmpty(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsSimpleStatement() {
|
||||
public NativeSQLStatement createNativeIsSimpleStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_IsSimple(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Overlaps(t.geom, ST_GeomFromText(?, 4326)) from GEOMTEST t where ST_Overlaps(t.geom, ST_GeomFromText(?, 4326)) = 1",
|
||||
geom.toText()
|
||||
|
@ -193,7 +193,7 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeRelateStatement(
|
||||
public NativeSQLStatement createNativeRelateStatement(
|
||||
Geometry geom,
|
||||
String matrix) {
|
||||
throw new UnsupportedOperationException(
|
||||
|
@ -202,7 +202,7 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDwithinStatement(Point geom, double distance) {
|
||||
public NativeSQLStatement createNativeDwithinStatement(Point geom, double distance) {
|
||||
String sql = "select t.id, st_dwithin(t.geom, ST_GeomFromText(?, 4326), " + distance + " ) from GeomTest t where st_dwithin(t.geom, ST_GeomFromText(?, 4326), " + distance + ") = 'true' and ST_SRID(t.geom) = 4326";
|
||||
return createNativeSQLStatementAllWKTParams( sql, geom.toText() );
|
||||
}
|
||||
|
@ -215,12 +215,12 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeSridStatement() {
|
||||
public NativeSQLStatement createNativeSridStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_SRID(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeSymDifferenceStatement(
|
||||
public NativeSQLStatement createNativeSymDifferenceStatement(
|
||||
Geometry geom) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Method ST_SymDifference() is not implemented in the current version of GeoDB."
|
||||
|
@ -228,7 +228,7 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Touches(t.geom, ST_GeomFromText(?, 4326)) from GEOMTEST t where ST_Touches(t.geom, ST_GeomFromText(?, 4326)) = 1",
|
||||
geom.toText()
|
||||
|
@ -236,7 +236,7 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeWithinStatement(
|
||||
public NativeSQLStatement createNativeWithinStatement(
|
||||
Geometry testPolygon) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Within(t.geom, ST_GeomFromText(?, 4326)) from GEOMTEST t where ST_Within(t.geom, ST_GeomFromText(?, 4326)) = 1 and ST_SRID(t.geom) = 4326",
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
|||
public class GeoDBTestSupport extends TestSupport {
|
||||
|
||||
public DataSourceUtils createDataSourceUtil(ServiceRegistry serviceRegistry) {
|
||||
super.createDataSourceUtil( serviceRegistry );
|
||||
|
||||
try {
|
||||
return new GeoDBDataSourceUtils( driver(), url(), user(), passwd(), getSQLExpressionTemplate() );
|
||||
}
|
||||
|
|
|
@ -30,12 +30,12 @@ public class HANAExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDimensionSQL() {
|
||||
public NativeSQLStatement createNativeDimensionSQL() {
|
||||
return createNativeSQLStatement( "select t.id, t.geom.ST_Dimension() from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeBufferStatement(Double distance) {
|
||||
public NativeSQLStatement createNativeBufferStatement(Double distance) {
|
||||
return createNativeSQLStatement(
|
||||
"select t.id, t.geom.ST_Buffer(?) from GeomTest t where t.geom.ST_SRID() = " + getTestSrid(),
|
||||
new Object[] { distance }
|
||||
|
@ -43,7 +43,7 @@ public class HANAExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeConvexHullStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeConvexHullStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.ST_Union(ST_GeomFromText(?, " + getTestSrid() + ")).ST_ConvexHull().ST_AsEWKB() from GeomTest t where t.geom.ST_SRID() = "
|
||||
+ getTestSrid(),
|
||||
|
@ -52,7 +52,7 @@ public class HANAExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIntersectionStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeIntersectionStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.ST_Intersection(ST_GeomFromText(?, " + getTestSrid() + ")).ST_AsEWKB() from GeomTest t where t.geom.ST_SRID() = "
|
||||
+ getTestSrid(),
|
||||
|
@ -61,7 +61,7 @@ public class HANAExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDifferenceStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDifferenceStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.ST_Difference(ST_GeomFromText(?, " + getTestSrid() + ")).ST_AsEWKB() from GeomTest t where t.geom.ST_SRID() = "
|
||||
+ getTestSrid(),
|
||||
|
@ -70,7 +70,7 @@ public class HANAExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeSymDifferenceStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeSymDifferenceStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.ST_SymDifference(ST_GeomFromText(?, " + getTestSrid() + ")).ST_AsEWKB() from GeomTest t where t.geom.ST_SRID() = "
|
||||
+ getTestSrid(),
|
||||
|
@ -79,7 +79,7 @@ public class HANAExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeGeomUnionStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeGeomUnionStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.ST_Union(ST_GeomFromText(?, " + getTestSrid() + ")).ST_AsEWKB() from GeomTest t where t.geom.ST_SRID() = " + getTestSrid(),
|
||||
geom.toText()
|
||||
|
@ -87,47 +87,47 @@ public class HANAExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeAsTextStatement() {
|
||||
public NativeSQLStatement createNativeAsTextStatement() {
|
||||
return createNativeSQLStatement( "select t.id, t.geom.ST_AsText() from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeSridStatement() {
|
||||
public NativeSQLStatement createNativeSridStatement() {
|
||||
return createNativeSQLStatement( "select t.id, t.geom.ST_SRID() from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsSimpleStatement() {
|
||||
public NativeSQLStatement createNativeIsSimpleStatement() {
|
||||
return createNativeSQLStatement( "select t.id, t.geom.ST_IsSimple() from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsEmptyStatement() {
|
||||
public NativeSQLStatement createNativeIsEmptyStatement() {
|
||||
return createNativeSQLStatement( "select t.id, t.geom.ST_IsEmpty() from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsNotEmptyStatement() {
|
||||
public NativeSQLStatement createNativeIsNotEmptyStatement() {
|
||||
return createNativeSQLStatement( "select t.id, map(t.geom.ST_IsEmpty(), 1, 0, 1) from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeBoundaryStatement() {
|
||||
public NativeSQLStatement createNativeBoundaryStatement() {
|
||||
return createNativeSQLStatement( "select t.id, t.geom.ST_Boundary().ST_AsEWKB() from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeEnvelopeStatement() {
|
||||
public NativeSQLStatement createNativeEnvelopeStatement() {
|
||||
return createNativeSQLStatement( "select t.id, t.geom.ST_Envelope().ST_AsEWKB() from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeAsBinaryStatement() {
|
||||
public NativeSQLStatement createNativeAsBinaryStatement() {
|
||||
return createNativeSQLStatement( "select t.id, t.geom.ST_AsBinary() from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeGeometryTypeStatement() {
|
||||
public NativeSQLStatement createNativeGeometryTypeStatement() {
|
||||
return createNativeSQLStatement( "select t.id, t.geom.ST_GeometryType() from GeomTest t" );
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ public class HANAExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeWithinStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeWithinStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.ST_Within(ST_GeomFromText(?, " + getTestSrid() + ")) from GeomTest t where t.geom.ST_Within(ST_GeomFromText(?, "
|
||||
+ getTestSrid() + ")) = 1 and t.geom.ST_SRID() = " + getTestSrid(),
|
||||
|
@ -149,7 +149,7 @@ public class HANAExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeEqualsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeEqualsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.ST_Equals(ST_GeomFromText(?, " + getTestSrid() + ")) from GeomTest t where t.geom.ST_Equals(ST_GeomFromText(?, "
|
||||
+ getTestSrid() + ")) = 1 and t.geom.ST_SRID() = " + getTestSrid(),
|
||||
|
@ -158,7 +158,7 @@ public class HANAExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.ST_Crosses(ST_GeomFromText(?, " + getTestSrid() + ")) from GeomTest t where t.geom.ST_Crosses(ST_GeomFromText(?, "
|
||||
+ getTestSrid() + ")) = 1 and t.geom.ST_SRID() = " + getTestSrid(),
|
||||
|
@ -167,7 +167,7 @@ public class HANAExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeContainsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeContainsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.ST_Contains(ST_GeomFromText(?, " + getTestSrid() + ")) from GeomTest t where t.geom.ST_Contains(ST_GeomFromText(?, "
|
||||
+ getTestSrid() + ")) = 1 and t.geom.ST_SRID() = " + getTestSrid(),
|
||||
|
@ -176,7 +176,7 @@ public class HANAExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.ST_Disjoint(ST_GeomFromText(?, " + getTestSrid() + ")) from GeomTest t where t.geom.ST_Disjoint(ST_GeomFromText(?, "
|
||||
+ getTestSrid() + ")) = 1 and t.geom.ST_SRID() = " + getTestSrid(),
|
||||
|
@ -185,18 +185,18 @@ public class HANAExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeTransformStatement(int epsg) {
|
||||
public NativeSQLStatement createNativeTransformStatement(int epsg) {
|
||||
return createNativeSQLStatement(
|
||||
"select t.id, t.geom.ST_Transform(" + epsg + ") from GeomTest t where t.geom.ST_SRID() = " + getTestSrid() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeHavingSRIDStatement(int srid) {
|
||||
public NativeSQLStatement createNativeHavingSRIDStatement(int srid) {
|
||||
return createNativeSQLStatement( "select t.id, 1 from GeomTest t where t.geom.ST_SRID() = " + srid );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.ST_Intersects(ST_GeomFromText(?, " + getTestSrid() + ")) from GeomTest t where t.geom.ST_Intersects(ST_GeomFromText(?, "
|
||||
+ getTestSrid() + ")) = 1 and t.geom.ST_SRID() = " + getTestSrid(),
|
||||
|
@ -205,7 +205,7 @@ public class HANAExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeFilterStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeFilterStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.ST_IntersectsFilter(ST_GeomFromText(?, " + getTestSrid()
|
||||
+ ")) from GeomTest t where t.geom.ST_IntersectsFilter(ST_GeomFromText(?, " + getTestSrid() + ")) = 1 and t.geom.ST_SRID() = "
|
||||
|
@ -215,7 +215,7 @@ public class HANAExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.ST_Touches(ST_GeomFromText(?, " + getTestSrid() + ")) from GeomTest t where t.geom.ST_Touches(ST_GeomFromText(?, "
|
||||
+ getTestSrid() + ")) = 1 and t.geom.ST_SRID() = " + getTestSrid(),
|
||||
|
@ -224,7 +224,7 @@ public class HANAExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.ST_Overlaps(ST_GeomFromText(?, " + getTestSrid() + ")) from GeomTest t where t.geom.ST_Overlaps(ST_GeomFromText(?, "
|
||||
+ getTestSrid() + ")) = 1 and t.geom.ST_SRID() = " + getTestSrid(),
|
||||
|
@ -233,7 +233,7 @@ public class HANAExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeRelateStatement(Geometry geom, String matrix) {
|
||||
public NativeSQLStatement createNativeRelateStatement(Geometry geom, String matrix) {
|
||||
String sql = "select t.id, t.geom.ST_Relate(ST_GeomFromText(?, " + getTestSrid() + "), '" + matrix
|
||||
+ "' ) from GeomTest t where t.geom.ST_Relate(ST_GeomFromText(?, " + getTestSrid() + "), '" + matrix
|
||||
+ "') = 1 and t.geom.ST_SRID() = " + getTestSrid();
|
||||
|
@ -241,7 +241,7 @@ public class HANAExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDwithinStatement(Point geom, double distance) {
|
||||
public NativeSQLStatement createNativeDwithinStatement(Point geom, double distance) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.ST_WithinDistance(ST_GeomFromText(?, " + getTestSrid() + "), "
|
||||
+ distance + ") from GeomTest t where t.geom.ST_WithinDistance(ST_GeomFromText(?, " + getTestSrid() + "), " + distance
|
||||
|
@ -251,7 +251,7 @@ public class HANAExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDistanceStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDistanceStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.ST_Distance(ST_GeomFromText(?, " + getTestSrid() + ")) from GeomTest t where t.geom.ST_SRID() = " + getTestSrid(),
|
||||
geom.toText()
|
||||
|
|
|
@ -23,7 +23,7 @@ public class MySQL56ExpectationsFactory extends MySQLExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Touches(t.geom, GeomFromText(?, 4326)) from geomtest t where ST_Touches(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -31,7 +31,7 @@ public class MySQL56ExpectationsFactory extends MySQLExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_overlaps(t.geom, GeomFromText(?, 4326)) from geomtest t where ST_Overlaps(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -39,7 +39,7 @@ public class MySQL56ExpectationsFactory extends MySQLExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Intersects(t.geom, GeomFromText(?, 4326)) from geomtest t where ST_Intersects(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -47,7 +47,7 @@ public class MySQL56ExpectationsFactory extends MySQLExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeWithinStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeWithinStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Within(t.geom, GeomFromText(?, 4326)) from geomtest t where ST_Within(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -55,7 +55,7 @@ public class MySQL56ExpectationsFactory extends MySQLExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeEqualsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeEqualsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Equals(t.geom, GeomFromText(?, 4326)) from geomtest t where ST_Equals(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -63,7 +63,7 @@ public class MySQL56ExpectationsFactory extends MySQLExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Crosses(t.geom, GeomFromText(?, 4326)) from geomtest t where ST_Crosses(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -71,7 +71,7 @@ public class MySQL56ExpectationsFactory extends MySQLExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeContainsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeContainsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Contains(t.geom, GeomFromText(?, 4326)) from geomtest t where ST_Contains(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -79,7 +79,7 @@ public class MySQL56ExpectationsFactory extends MySQLExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Disjoint(t.geom, GeomFromText(?, 4326)) from geomtest t where ST_Disjoint(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
|
|
@ -29,7 +29,7 @@ public class MySQL8ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Touches(t.geom, ST_GeomFromText(?, 31370)) from geomtest t where ST_Touches(t.geom, ST_geomFromText(?, 31370)) = 1 ",
|
||||
geom.toText()
|
||||
|
@ -37,7 +37,7 @@ public class MySQL8ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_overlaps(t.geom, ST_GeomFromText(?, 31370)) from geomtest t where ST_Overlaps(t.geom, ST_geomFromText(?, 31370)) = 1 ",
|
||||
geom.toText()
|
||||
|
@ -45,7 +45,7 @@ public class MySQL8ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Intersects(t.geom, ST_GeomFromText(?, 31370)) from geomtest t where ST_Intersects(t.geom, ST_GeomFromText(?, 31370)) = 1 ",
|
||||
geom.toText()
|
||||
|
@ -53,7 +53,7 @@ public class MySQL8ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeWithinStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeWithinStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Within(t.geom, ST_GeomFromText(?, 31370)) from geomtest t where ST_Within(t.geom, ST_GeomFromText(?, 31370)) = 1 ",
|
||||
geom.toText()
|
||||
|
@ -61,7 +61,7 @@ public class MySQL8ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeEqualsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeEqualsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Equals(t.geom, ST_GeomFromText(?, 31370)) from geomtest t where ST_Equals(t.geom, ST_GeomFromText(?, 31370)) = 1 ",
|
||||
geom.toText()
|
||||
|
@ -69,7 +69,7 @@ public class MySQL8ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Crosses(t.geom, ST_GeomFromText(?, 31370)) from geomtest t where ST_Crosses(t.geom, ST_geomFromText(?, 31370)) = 1 ",
|
||||
geom.toText()
|
||||
|
@ -77,7 +77,7 @@ public class MySQL8ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeContainsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeContainsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Contains(t.geom, ST_GeomFromText(?, 31370)) from geomtest t where ST_Contains(t.geom, ST_geomFromText(?, 31370)) = 1 ",
|
||||
geom.toText()
|
||||
|
@ -85,7 +85,7 @@ public class MySQL8ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Disjoint(t.geom, ST_GeomFromText(?, 31370)) from geomtest t where ST_Disjoint(t.geom, ST_geomFromText(?, 31370)) = 1 ",
|
||||
geom.toText()
|
||||
|
@ -94,19 +94,19 @@ public class MySQL8ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeRelateStatement(Geometry geom, String matrix) {
|
||||
public NativeSQLStatement createNativeRelateStatement(Geometry geom, String matrix) {
|
||||
String sql = "select t.id, ST_Relate(t.geom, ST_GeomFromText(?, 31370), '" + matrix + "' ) from geomtest t where ST_Relate(t.geom, ST_GeomFromText(?, 31370), '" + matrix + "') = 1 ";
|
||||
return createNativeSQLStatementAllWKTParams( sql, geom.toText() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDwithinStatement(Point geom, double distance) {
|
||||
public NativeSQLStatement createNativeDwithinStatement(Point geom, double distance) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeFilterStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeFilterStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, MBRIntersects(t.geom, ST_GeomFromtext(?, 31370)) from geomtest t where MBRIntersects(t.geom, ST_GeomFromtext(?, 31370)) = 1",
|
||||
geom.toText()
|
||||
|
@ -114,7 +114,7 @@ public class MySQL8ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDistanceStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDistanceStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_distance(t.geom, ST_GeomFromText(?, 31370)) from geomtest t ",
|
||||
geom.toText()
|
||||
|
@ -122,12 +122,12 @@ public class MySQL8ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDimensionSQL() {
|
||||
public NativeSQLStatement createNativeDimensionSQL() {
|
||||
return createNativeSQLStatement( "select id, ST_dimension(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeBufferStatement(Double distance) {
|
||||
public NativeSQLStatement createNativeBufferStatement(Double distance) {
|
||||
return createNativeSQLStatement(
|
||||
"select t.id, ST_buffer(t.geom,?) from geomtest t ",
|
||||
new Object[] { distance }
|
||||
|
@ -135,7 +135,7 @@ public class MySQL8ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeConvexHullStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeConvexHullStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_convexhull(ST_Union(t.geom, ST_GeomFromText(?, 31370))) from geomtest t",
|
||||
geom.toText()
|
||||
|
@ -143,7 +143,7 @@ public class MySQL8ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIntersectionStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeIntersectionStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_intersection(t.geom, ST_GeomFromtext(?, 31370)) from geomtest t ",
|
||||
geom.toText()
|
||||
|
@ -151,7 +151,7 @@ public class MySQL8ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDifferenceStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDifferenceStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Difference(t.geom, ST_GeomFromtext(?, 31370)) from geomtest t ",
|
||||
geom.toText()
|
||||
|
@ -159,7 +159,7 @@ public class MySQL8ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeSymDifferenceStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeSymDifferenceStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Symdifference(t.geom, ST_GeomFromtext(?, 31370)) from geomtest t ",
|
||||
geom.toText()
|
||||
|
@ -167,7 +167,7 @@ public class MySQL8ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeGeomUnionStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeGeomUnionStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, ST_Union(t.geom, ST_GeomFromtext(?, 31370)) from geomtest t",
|
||||
geom.toText()
|
||||
|
@ -175,57 +175,57 @@ public class MySQL8ExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeAsTextStatement() {
|
||||
public NativeSQLStatement createNativeAsTextStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_astext(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeSridStatement() {
|
||||
public NativeSQLStatement createNativeSridStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_SRID(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsSimpleStatement() {
|
||||
public NativeSQLStatement createNativeIsSimpleStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_IsSimple(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsEmptyStatement() {
|
||||
public NativeSQLStatement createNativeIsEmptyStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_IsEmpty(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsNotEmptyStatement() {
|
||||
public NativeSQLStatement createNativeIsNotEmptyStatement() {
|
||||
return createNativeSQLStatement( "select id, not ST_IsEmpty(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeBoundaryStatement() {
|
||||
public NativeSQLStatement createNativeBoundaryStatement() {
|
||||
return createNativeSQLStatement( "select id, st_boundary(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeEnvelopeStatement() {
|
||||
public NativeSQLStatement createNativeEnvelopeStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_Envelope(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeAsBinaryStatement() {
|
||||
public NativeSQLStatement createNativeAsBinaryStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_AsBinary(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeGeometryTypeStatement() {
|
||||
public NativeSQLStatement createNativeGeometryTypeStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_GeometryType(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeTransformStatement(int epsg) {
|
||||
public NativeSQLStatement createNativeTransformStatement(int epsg) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeHavingSRIDStatement(int srid) {
|
||||
public NativeSQLStatement createNativeHavingSRIDStatement(int srid) {
|
||||
return createNativeSQLStatement( "select t.id, (ST_Srid(t.geom) = " + srid + ") from geomtest t where ST_SRID(t.geom) = " + srid );
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public class MySQLExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, touches(t.geom, GeomFromText(?, 4326)) from geomtest t where touches(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -40,7 +40,7 @@ public class MySQLExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, overlaps(t.geom, GeomFromText(?, 4326)) from geomtest t where overlaps(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -48,18 +48,18 @@ public class MySQLExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeRelateStatement(Geometry geom, String matrix) {
|
||||
public NativeSQLStatement createNativeRelateStatement(Geometry geom, String matrix) {
|
||||
String sql = "select t.id, relate(t.geom, GeomFromText(?, 4326), '" + matrix + "' ) from geomtest t where relate(t.geom, GeomFromText(?, 4326), '" + matrix + "') = 1 and srid(t.geom) = 4326";
|
||||
return createNativeSQLStatementAllWKTParams( sql, geom.toText() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDwithinStatement(Point geom, double distance) {
|
||||
public NativeSQLStatement createNativeDwithinStatement(Point geom, double distance) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, intersects(t.geom, GeomFromText(?, 4326)) from geomtest t where intersects(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -67,7 +67,7 @@ public class MySQLExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeFilterStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeFilterStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, MBRIntersects(t.geom, GeomFromText(?, 4326)) from geomtest t where MBRIntersects(t.geom, GeomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -75,7 +75,7 @@ public class MySQLExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDistanceStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDistanceStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, distance(t.geom, GeomFromText(?, 4326)) from geomtest t where srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -83,12 +83,12 @@ public class MySQLExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDimensionSQL() {
|
||||
public NativeSQLStatement createNativeDimensionSQL() {
|
||||
return createNativeSQLStatement( "select id, dimension(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeBufferStatement(Double distance) {
|
||||
public NativeSQLStatement createNativeBufferStatement(Double distance) {
|
||||
return createNativeSQLStatement(
|
||||
"select t.id, buffer(t.geom,?) from geomtest t where srid(t.geom) = 4326",
|
||||
new Object[] { distance }
|
||||
|
@ -96,7 +96,7 @@ public class MySQLExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeConvexHullStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeConvexHullStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, convexhull(geomunion(t.geom, GeomFromText(?, 4326))) from geomtest t where srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -104,7 +104,7 @@ public class MySQLExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIntersectionStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeIntersectionStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, intersection(t.geom, GeomFromText(?, 4326)) from geomtest t where srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -112,7 +112,7 @@ public class MySQLExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDifferenceStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDifferenceStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, difference(t.geom, GeomFromText(?, 4326)) from geomtest t where srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -120,7 +120,7 @@ public class MySQLExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeSymDifferenceStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeSymDifferenceStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, symdifference(t.geom, GeomFromText(?, 4326)) from geomtest t where srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -128,7 +128,7 @@ public class MySQLExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeGeomUnionStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeGeomUnionStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, geomunion(t.geom, GeomFromText(?, 4326)) from geomtest t where srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -136,52 +136,52 @@ public class MySQLExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeAsTextStatement() {
|
||||
public NativeSQLStatement createNativeAsTextStatement() {
|
||||
return createNativeSQLStatement( "select id, astext(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeSridStatement() {
|
||||
public NativeSQLStatement createNativeSridStatement() {
|
||||
return createNativeSQLStatement( "select id, srid(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsSimpleStatement() {
|
||||
public NativeSQLStatement createNativeIsSimpleStatement() {
|
||||
return createNativeSQLStatement( "select id, issimple(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsEmptyStatement() {
|
||||
public NativeSQLStatement createNativeIsEmptyStatement() {
|
||||
return createNativeSQLStatement( "select id, isempty(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsNotEmptyStatement() {
|
||||
public NativeSQLStatement createNativeIsNotEmptyStatement() {
|
||||
return createNativeSQLStatement( "select id, not isempty(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeBoundaryStatement() {
|
||||
public NativeSQLStatement createNativeBoundaryStatement() {
|
||||
return createNativeSQLStatement( "select id, boundary(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeEnvelopeStatement() {
|
||||
public NativeSQLStatement createNativeEnvelopeStatement() {
|
||||
return createNativeSQLStatement( "select id, envelope(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeAsBinaryStatement() {
|
||||
public NativeSQLStatement createNativeAsBinaryStatement() {
|
||||
return createNativeSQLStatement( "select id, asbinary(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeGeometryTypeStatement() {
|
||||
public NativeSQLStatement createNativeGeometryTypeStatement() {
|
||||
return createNativeSQLStatement( "select id, GeometryType(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeWithinStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeWithinStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, within(t.geom, GeomFromText(?, 4326)) from geomtest t where within(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -189,7 +189,7 @@ public class MySQLExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeEqualsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeEqualsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, equals(t.geom, GeomFromText(?, 4326)) from geomtest t where equals(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -197,7 +197,7 @@ public class MySQLExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, crosses(t.geom, GeomFromText(?, 4326)) from geomtest t where crosses(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -205,7 +205,7 @@ public class MySQLExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeContainsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeContainsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, contains(t.geom, GeomFromText(?, 4326)) from geomtest t where contains(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -213,7 +213,7 @@ public class MySQLExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, disjoint(t.geom, GeomFromText(?, 4326)) from geomtest t where disjoint(t.geom, geomFromText(?, 4326)) = 1 and srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -221,12 +221,12 @@ public class MySQLExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeTransformStatement(int epsg) {
|
||||
public NativeSQLStatement createNativeTransformStatement(int epsg) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeHavingSRIDStatement(int srid) {
|
||||
public NativeSQLStatement createNativeHavingSRIDStatement(int srid) {
|
||||
return createNativeSQLStatement( "select t.id, (srid(t.geom) = " + srid + ") from geomtest t where SRID(t.geom) = " + srid );
|
||||
}
|
||||
|
||||
|
|
|
@ -38,9 +38,8 @@ public class OracleSDOTestSupport extends TestSupport {
|
|||
return new SDOGeometryExpressionTemplate();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public DataSourceUtils createDataSourceUtil(ServiceRegistry serviceRegistry) {
|
||||
super.createDataSourceUtil( serviceRegistry );
|
||||
return new SDODataSourceUtils( driver(), url(), user(), passwd(), getSQLExpressionTemplate() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public class SDOGeometryExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM).ST_Touch(MDSYS.ST_GEOMETRY.FROM_WKT(?, 4326)) from GEOMTEST T where MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM).ST_Touch(MDSYS.ST_GEOMETRY.FROM_WKT(?, 4326)) = 1 and t.GEOM.SDO_SRID = 4326",
|
||||
geom.toText()
|
||||
|
@ -42,7 +42,7 @@ public class SDOGeometryExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM).ST_Overlap(MDSYS.ST_GEOMETRY.FROM_WKT(?, 4326)) from GEOMTEST T where MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM).ST_Overlap(MDSYS.ST_GEOMETRY.FROM_WKT(?, 4326)) = 1 and t.GEOM.SDO_SRID = 4326",
|
||||
geom.toText()
|
||||
|
@ -50,7 +50,7 @@ public class SDOGeometryExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeRelateStatement(Geometry geom, String matrix) {
|
||||
public NativeSQLStatement createNativeRelateStatement(Geometry geom, String matrix) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM).ST_Relate(MDSYS.ST_GEOMETRY.FROM_WKT(?, 4326), '" + matrix + "') from GEOMTEST T where MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM).ST_Relate(MDSYS.ST_GEOMETRY.FROM_WKT(?, 4326), '" + matrix + "') = 1 and t.GEOM.SDO_SRID = 4326",
|
||||
geom.toText()
|
||||
|
@ -58,7 +58,7 @@ public class SDOGeometryExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDwithinStatement(Point geom, double distance) {
|
||||
public NativeSQLStatement createNativeDwithinStatement(Point geom, double distance) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, 1 from GEOMTEST T where MDSYS.SDO_WITHIN_DISTANCE(t.GEOM, SDO_GEOMETRY(? , 4326), 'distance = " + distance + "') = 'TRUE' and t.GEOM.SDO_SRID = 4326",
|
||||
geom.toText()
|
||||
|
@ -66,7 +66,7 @@ public class SDOGeometryExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM).ST_Intersects(MDSYS.ST_GEOMETRY.FROM_WKT(?, 4326)) from GEOMTEST T where MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM).ST_Intersects(MDSYS.ST_GEOMETRY.FROM_WKT(?, 4326)) = 1 and t.GEOM.SDO_SRID = 4326",
|
||||
geom.toText()
|
||||
|
@ -74,7 +74,7 @@ public class SDOGeometryExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeFilterStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeFilterStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, 1 from GEOMTEST t where SDO_FILTER(t.GEOM, MDSYS.ST_GEOMETRY.FROM_WKT(?, 4326).GEOM) = 'TRUE' ",
|
||||
geom.toText()
|
||||
|
@ -82,7 +82,7 @@ public class SDOGeometryExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDistanceStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDistanceStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM).ST_Distance(MDSYS.ST_GEOMETRY.FROM_WKT(?, 4326)) from GEOMTEST T where t.GEOM.SDO_SRID = 4326",
|
||||
geom.toText()
|
||||
|
@ -90,14 +90,14 @@ public class SDOGeometryExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDimensionSQL() {
|
||||
public NativeSQLStatement createNativeDimensionSQL() {
|
||||
return createNativeSQLStatement(
|
||||
"select ID, MDSYS.OGC_DIMENSION(MDSYS.ST_GEOMETRY.FROM_SDO_GEOM( T.GEOM)) FROM GEOMTEST T"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeBufferStatement(Double distance) {
|
||||
public NativeSQLStatement createNativeBufferStatement(Double distance) {
|
||||
return createNativeSQLStatement(
|
||||
"select t.id, MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM).ST_Buffer(?).GEOM from GEOMTEST T where t.GEOM.SDO_SRID = 4326",
|
||||
new Double[] { distance }
|
||||
|
@ -105,7 +105,7 @@ public class SDOGeometryExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeConvexHullStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeConvexHullStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM).ST_Union(MDSYS.ST_GEOMETRY.FROM_WKT(?, 4326)).ST_ConvexHull().GEOM from GEOMTEST T where t.GEOM.SDO_SRID = 4326",
|
||||
geom.toText()
|
||||
|
@ -113,7 +113,7 @@ public class SDOGeometryExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIntersectionStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeIntersectionStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM).ST_Intersection(MDSYS.ST_GEOMETRY.FROM_WKT(?,4326)).GEOM FROM GEOMTEST t where t.GEOM.SDO_SRID = 4326",
|
||||
geom.toText()
|
||||
|
@ -121,7 +121,7 @@ public class SDOGeometryExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDifferenceStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDifferenceStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM).ST_Difference(MDSYS.ST_GEOMETRY.FROM_WKT(?,4326)).GEOM FROM GEOMTEST t where t.GEOM.SDO_SRID = 4326",
|
||||
geom.toText()
|
||||
|
@ -129,7 +129,7 @@ public class SDOGeometryExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeSymDifferenceStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeSymDifferenceStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM).ST_SymmetricDifference(MDSYS.ST_GEOMETRY.FROM_WKT(?,4326)).GEOM FROM GEOMTEST t where t.GEOM.SDO_SRID = 4326",
|
||||
geom.toText()
|
||||
|
@ -137,7 +137,7 @@ public class SDOGeometryExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeGeomUnionStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeGeomUnionStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM).ST_Union(MDSYS.ST_GEOMETRY.FROM_WKT(?,4326)).GEOM FROM GEOMTEST t where t.GEOM.SDO_SRID = 4326",
|
||||
geom.toText()
|
||||
|
@ -145,17 +145,17 @@ public class SDOGeometryExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeAsTextStatement() {
|
||||
public NativeSQLStatement createNativeAsTextStatement() {
|
||||
return createNativeSQLStatement( "select t.ID, t.GEOM.GET_WKT() FROM GEOMTEST T" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeSridStatement() {
|
||||
public NativeSQLStatement createNativeSridStatement() {
|
||||
return createNativeSQLStatement( "SELECT t.ID, t.GEOM.SDO_SRID FROM GEOMTEST t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsSimpleStatement() {
|
||||
public NativeSQLStatement createNativeIsSimpleStatement() {
|
||||
return createNativeSQLStatement(
|
||||
"SELECT t.ID, MDSYS.OGC_ISSIMPLE(MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM)) FROM GEOMTEST t where MDSYS.OGC_ISSIMPLE(MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM)) = 1"
|
||||
);
|
||||
|
@ -163,47 +163,47 @@ public class SDOGeometryExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsEmptyStatement() {
|
||||
public NativeSQLStatement createNativeIsEmptyStatement() {
|
||||
return createNativeSQLStatement(
|
||||
"SELECT t.ID, MDSYS.OGC_ISEMPTY(MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM)) FROM GEOMTEST t"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsNotEmptyStatement() {
|
||||
public NativeSQLStatement createNativeIsNotEmptyStatement() {
|
||||
return createNativeSQLStatement(
|
||||
"SELECT t.ID, CASE MDSYS.OGC_ISEMPTY(MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM)) WHEN 0 THEN 1 ELSE 0 END FROM GEOMTEST t"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeBoundaryStatement() {
|
||||
public NativeSQLStatement createNativeBoundaryStatement() {
|
||||
return createNativeSQLStatement(
|
||||
"SELECT t.ID, MDSYS.OGC_BOUNDARY(MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM)).GEOM FROM GEOMTEST t"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeEnvelopeStatement() {
|
||||
public NativeSQLStatement createNativeEnvelopeStatement() {
|
||||
return createNativeSQLStatement(
|
||||
"SELECT t.ID, MDSYS.OGC_ENVELOPE(MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM)).GEOM FROM GEOMTEST t"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeAsBinaryStatement() {
|
||||
public NativeSQLStatement createNativeAsBinaryStatement() {
|
||||
return createNativeSQLStatement( "select t.ID, t.GEOM.GET_WKB() FROM GEOMTEST T" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeGeometryTypeStatement() {
|
||||
public NativeSQLStatement createNativeGeometryTypeStatement() {
|
||||
return createNativeSQLStatement(
|
||||
"select t.id, CASE t.geom.Get_GType() WHEN 1 THEN 'POINT' WHEN 2 THEN 'LINESTRING' WHEN 3 THEN 'POLYGON' WHEN 5 THEN 'MULTIPOINT' WHEN 6 THEN 'MULTILINE' WHEN 7 THEN 'MULTIPOLYGON' END from GEOMTEST t"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeWithinStatement(Geometry testPolygon) {
|
||||
public NativeSQLStatement createNativeWithinStatement(Geometry testPolygon) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, mdsys.OGC_WITHIN( MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM), MDSYS.ST_GEOMETRY.FROM_WKT(?, 4326)) from GEOMTEST T where mdsys.OGC_WITHIN( MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM), MDSYS.ST_GEOMETRY.FROM_WKT(?, 4326)) = 1 and t.GEOM.SDO_SRID = 4326",
|
||||
testPolygon.toText()
|
||||
|
@ -211,7 +211,7 @@ public class SDOGeometryExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeEqualsStatement(Geometry testPolygon) {
|
||||
public NativeSQLStatement createNativeEqualsStatement(Geometry testPolygon) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM).ST_Equals(MDSYS.ST_GEOMETRY.FROM_WKT(?, 4326)) from GEOMTEST T where MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM).ST_Equals(MDSYS.ST_GEOMETRY.FROM_WKT(?, 4326)) = 1 and t.GEOM.SDO_SRID = 4326",
|
||||
testPolygon.toText()
|
||||
|
@ -219,7 +219,7 @@ public class SDOGeometryExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM).ST_Cross(MDSYS.ST_GEOMETRY.FROM_WKT(?, 4326)) from GEOMTEST T where MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM).ST_Cross(MDSYS.ST_GEOMETRY.FROM_WKT(?, 4326)) = 1 and t.GEOM.SDO_SRID = 4326",
|
||||
geom.toText()
|
||||
|
@ -227,7 +227,7 @@ public class SDOGeometryExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeContainsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeContainsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM).ST_Contains(MDSYS.ST_GEOMETRY.FROM_WKT(?, 4326)) from GEOMTEST T where MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM).ST_Contains(MDSYS.ST_GEOMETRY.FROM_WKT(?, 4326)) = 1 and t.GEOM.SDO_SRID = 4326",
|
||||
geom.toText()
|
||||
|
@ -235,7 +235,7 @@ public class SDOGeometryExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM).ST_Disjoint(MDSYS.ST_GEOMETRY.FROM_WKT(?, 4326)) from GEOMTEST T where MDSYS.ST_GEOMETRY.FROM_SDO_GEOM(t.GEOM).ST_Disjoint(MDSYS.ST_GEOMETRY.FROM_WKT(?, 4326)) = 1 and t.GEOM.SDO_SRID = 4326",
|
||||
geom.toText()
|
||||
|
@ -243,14 +243,14 @@ public class SDOGeometryExpectationsFactory extends AbstractExpectationsFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeTransformStatement(int epsg) {
|
||||
public NativeSQLStatement createNativeTransformStatement(int epsg) {
|
||||
return createNativeSQLStatement(
|
||||
"select t.id, MDSYS.SDO_CS.transform(t.geom," + epsg + ") from GeomTest t where t.geom.SDO_SRID = 4326"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeHavingSRIDStatement(int srid) {
|
||||
public NativeSQLStatement createNativeHavingSRIDStatement(int srid) {
|
||||
return createNativeSQLStatement( "select t.id, 1 from GeomTest t where t.geom.SDO_SRID = " + srid );
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public class PostgisExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, st_touches(t.geom, ST_GeomFromText(?, 4326)) from GeomTest t where st_touches(t.geom, ST_geomFromText(?, 4326)) = 'true' and st_srid(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -45,7 +45,7 @@ public class PostgisExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, st_overlaps(t.geom, ST_GeomFromText(?, 4326)) from GeomTest t where st_overlaps(t.geom, ST_GeomFromText(?, 4326)) = 'true' and ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -53,19 +53,19 @@ public class PostgisExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeRelateStatement(Geometry geom, String matrix) {
|
||||
public NativeSQLStatement createNativeRelateStatement(Geometry geom, String matrix) {
|
||||
String sql = "select t.id, st_relate(t.geom, ST_GeomFromText(?, 4326), '" + matrix + "' ) from GeomTest t where st_relate(t.geom, ST_GeomFromText(?, 4326), '" + matrix + "') = 'true' and ST_SRID(t.geom) = 4326";
|
||||
return createNativeSQLStatementAllWKTParams( sql, geom.toText() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDwithinStatement(Point geom, double distance) {
|
||||
public NativeSQLStatement createNativeDwithinStatement(Point geom, double distance) {
|
||||
String sql = "select t.id, st_dwithin(t.geom, ST_GeomFromText(?, 4326), " + distance + " ) from GeomTest t where st_dwithin(t.geom, ST_GeomFromText(?, 4326), " + distance + ") = 'true' and ST_SRID(t.geom) = 4326";
|
||||
return createNativeSQLStatementAllWKTParams( sql, geom.toText() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, st_intersects(t.geom, ST_GeomFromText(?, 4326)) from GeomTest t where st_intersects(t.geom, ST_GeomFromText(?, 4326)) = 'true' and ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -73,7 +73,7 @@ public class PostgisExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeFilterStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeFilterStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom && ST_GeomFromText(?, 4326) from GeomTest t where st_intersects(t.geom, ST_GeomFromText(?, 4326)) = 'true' and ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -81,7 +81,7 @@ public class PostgisExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDistanceStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDistanceStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, st_distance(t.geom, ST_GeomFromText(?, 4326)) from GeomTest t where ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -89,12 +89,12 @@ public class PostgisExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDimensionSQL() {
|
||||
public NativeSQLStatement createNativeDimensionSQL() {
|
||||
return createNativeSQLStatement( "select id, st_dimension(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeBufferStatement(Double distance) {
|
||||
public NativeSQLStatement createNativeBufferStatement(Double distance) {
|
||||
return createNativeSQLStatement(
|
||||
"select t.id, st_buffer(t.geom,?) from GeomTest t where ST_SRID(t.geom) = 4326",
|
||||
new Object[] { distance }
|
||||
|
@ -102,7 +102,7 @@ public class PostgisExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeConvexHullStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeConvexHullStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, st_convexhull(st_union(t.geom, ST_GeomFromText(?, 4326))) from GeomTest t where ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -110,7 +110,7 @@ public class PostgisExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIntersectionStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeIntersectionStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, st_intersection(t.geom, ST_GeomFromText(?, 4326)) from GeomTest t where ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -118,7 +118,7 @@ public class PostgisExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDifferenceStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDifferenceStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, st_difference(t.geom, ST_GeomFromText(?, 4326)) from GeomTest t where ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -126,7 +126,7 @@ public class PostgisExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeSymDifferenceStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeSymDifferenceStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, st_symdifference(t.geom, ST_GeomFromText(?, 4326)) from GeomTest t where ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -134,7 +134,7 @@ public class PostgisExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeGeomUnionStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeGeomUnionStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, st_union(t.geom, ST_GeomFromText(?, 4326)) from GeomTest t where ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -142,64 +142,64 @@ public class PostgisExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeTransformStatement(int epsg) {
|
||||
public NativeSQLStatement createNativeTransformStatement(int epsg) {
|
||||
return createNativeSQLStatement(
|
||||
"select t.id, st_transform(t.geom," + epsg + ") from GeomTest t where ST_SRID(t.geom) = 4326"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeHavingSRIDStatement(int srid) {
|
||||
public NativeSQLStatement createNativeHavingSRIDStatement(int srid) {
|
||||
return createNativeSQLStatement( "select t.id, (st_srid(t.geom) = " + srid + ") from GeomTest t where ST_SRID(t.geom) = " + srid );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeAsTextStatement() {
|
||||
public NativeSQLStatement createNativeAsTextStatement() {
|
||||
return createNativeSQLStatement( "select id, st_astext(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeSridStatement() {
|
||||
public NativeSQLStatement createNativeSridStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_SRID(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsSimpleStatement() {
|
||||
public NativeSQLStatement createNativeIsSimpleStatement() {
|
||||
return createNativeSQLStatement( "select id, st_issimple(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsEmptyStatement() {
|
||||
public NativeSQLStatement createNativeIsEmptyStatement() {
|
||||
return createNativeSQLStatement( "select id, st_isempty(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsNotEmptyStatement() {
|
||||
public NativeSQLStatement createNativeIsNotEmptyStatement() {
|
||||
return createNativeSQLStatement( "select id, not st_isempty(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeBoundaryStatement() {
|
||||
public NativeSQLStatement createNativeBoundaryStatement() {
|
||||
return createNativeSQLStatement( "select id, st_boundary(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeEnvelopeStatement() {
|
||||
public NativeSQLStatement createNativeEnvelopeStatement() {
|
||||
return createNativeSQLStatement( "select id, st_envelope(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeAsBinaryStatement() {
|
||||
public NativeSQLStatement createNativeAsBinaryStatement() {
|
||||
return createNativeSQLStatement( "select id, st_asbinary(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeGeometryTypeStatement() {
|
||||
public NativeSQLStatement createNativeGeometryTypeStatement() {
|
||||
return createNativeSQLStatement( "select id, st_GeometryType(geom) from geomtest" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeWithinStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeWithinStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, st_within(t.geom, ST_GeomFromText(?, 4326)) from GeomTest t where st_within(t.geom, ST_GeomFromText(?, 4326)) = 'true' and ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -207,7 +207,7 @@ public class PostgisExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeEqualsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeEqualsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, st_equals(t.geom, ST_GeomFromText(?, 4326)) from GeomTest t where st_equals(t.geom, ST_GeomFromText(?, 4326)) = 'true' and ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -215,7 +215,7 @@ public class PostgisExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, st_crosses(t.geom, ST_GeomFromText(?, 4326)) from GeomTest t where st_crosses(t.geom, ST_GeomFromText(?, 4326)) = 'true' and ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -223,7 +223,7 @@ public class PostgisExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeContainsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeContainsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, st_contains(t.geom, ST_GeomFromText(?, 4326)) from GeomTest t where st_contains(t.geom, ST_GeomFromText(?, 4326)) = 'true' and ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
@ -231,7 +231,7 @@ public class PostgisExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, st_disjoint(t.geom, ST_GeomFromText(?, 4326)) from GeomTest t where st_disjoint(t.geom, ST_GeomFromText(?, 4326)) = 'true' and ST_SRID(t.geom) = 4326",
|
||||
geom.toText()
|
||||
|
|
|
@ -17,11 +17,22 @@ import org.hibernate.spatial.testing.datareader.TestDataElement;
|
|||
*/
|
||||
public class PostgisExpressionTemplate implements SQLExpressionTemplate {
|
||||
|
||||
static final String SQL_TEMPLATE = "insert into geomtest (id, type, geom) values (%d, '%s', ST_GeomFromText('%s'))";
|
||||
static final String SQL_TEMPLATE = "insert into %s (id, type, geom) values (%d, '%s', ST_GeomFromText('%s'))";
|
||||
|
||||
public String toInsertSql(TestDataElement testDataElement, String table) {
|
||||
return String.format(
|
||||
SQL_TEMPLATE,
|
||||
table,
|
||||
testDataElement.id,
|
||||
testDataElement.type,
|
||||
testDataElement.wkt
|
||||
);
|
||||
}
|
||||
|
||||
public String toInsertSql(TestDataElement testDataElement) {
|
||||
return String.format(
|
||||
SQL_TEMPLATE,
|
||||
"geomtest",
|
||||
testDataElement.id,
|
||||
testDataElement.type,
|
||||
testDataElement.wkt
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial.testing.dialects.postgis;
|
||||
|
||||
import org.hibernate.spatial.testing.NativeSqlTemplates;
|
||||
|
||||
public class PostgisNativeSqlTemplates extends NativeSqlTemplates {
|
||||
|
||||
|
||||
}
|
|
@ -13,6 +13,7 @@ import org.hibernate.spatial.integration.TestJTSSpatialPredicates;
|
|||
import org.hibernate.spatial.integration.TestSpatialFunctions;
|
||||
import org.hibernate.spatial.testing.AbstractExpectationsFactory;
|
||||
import org.hibernate.spatial.testing.DataSourceUtils;
|
||||
import org.hibernate.spatial.testing.NativeSqlTemplates;
|
||||
import org.hibernate.spatial.testing.SQLExpressionTemplate;
|
||||
import org.hibernate.spatial.testing.datareader.TestData;
|
||||
import org.hibernate.spatial.testing.datareader.TestSupport;
|
||||
|
@ -25,6 +26,10 @@ import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
|||
*/
|
||||
public class PostgisTestSupport extends TestSupport {
|
||||
|
||||
@Override
|
||||
public NativeSqlTemplates getNativeSqlTemplates() {
|
||||
return new PostgisNativeSqlTemplates();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TestData createTestData(TestDataPurpose purpose) {
|
||||
|
|
|
@ -29,12 +29,12 @@ public class SqlServerExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDimensionSQL() {
|
||||
public NativeSQLStatement createNativeDimensionSQL() {
|
||||
return createNativeSQLStatement( "select t.id, t.geom.STDimension() from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeBufferStatement(Double distance) {
|
||||
public NativeSQLStatement createNativeBufferStatement(Double distance) {
|
||||
return createNativeSQLStatement(
|
||||
"select t.id, t.geom.STBuffer(?) from GeomTest t where t.geom.STSrid = 4326",
|
||||
new Object[] { distance }
|
||||
|
@ -42,7 +42,7 @@ public class SqlServerExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeConvexHullStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeConvexHullStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.STUnion(geometry::STGeomFromText(?, 4326)).STConvexHull() from GeomTest t where t.geom.STSrid = 4326",
|
||||
geom.toText()
|
||||
|
@ -50,7 +50,7 @@ public class SqlServerExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIntersectionStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeIntersectionStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.STIntersection(geometry::STGeomFromText(?, 4326)) from GeomTest t where t.geom.STSrid = 4326",
|
||||
geom.toText()
|
||||
|
@ -58,7 +58,7 @@ public class SqlServerExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDifferenceStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDifferenceStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.STDifference(geometry::STGeomFromText(?, 4326)) from GeomTest t where t.geom.STSrid = 4326",
|
||||
geom.toText()
|
||||
|
@ -66,7 +66,7 @@ public class SqlServerExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeSymDifferenceStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeSymDifferenceStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.STSymDifference(geometry::STGeomFromText(?, 4326)) from GeomTest t where t.geom.STSrid = 4326",
|
||||
geom.toText()
|
||||
|
@ -74,7 +74,7 @@ public class SqlServerExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeGeomUnionStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeGeomUnionStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.STUnion(geometry::STGeomFromText(?, 4326)) from GeomTest t where t.geom.STSrid = 4326",
|
||||
geom.toText()
|
||||
|
@ -82,47 +82,47 @@ public class SqlServerExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeAsTextStatement() {
|
||||
public NativeSQLStatement createNativeAsTextStatement() {
|
||||
return createNativeSQLStatement( "select t.id, t.geom.STAsText() from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeSridStatement() {
|
||||
public NativeSQLStatement createNativeSridStatement() {
|
||||
return createNativeSQLStatement( "select t.id, t.geom.STSrid from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsSimpleStatement() {
|
||||
public NativeSQLStatement createNativeIsSimpleStatement() {
|
||||
return createNativeSQLStatement( "select t.id, t.geom.STIsSimple() from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsEmptyStatement() {
|
||||
public NativeSQLStatement createNativeIsEmptyStatement() {
|
||||
return createNativeSQLStatement( "select t.id, t.geom.STIsEmpty() from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsNotEmptyStatement() {
|
||||
public NativeSQLStatement createNativeIsNotEmptyStatement() {
|
||||
return createNativeSQLStatement( "select t.id, ~t.geom.STIsEmpty() from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeBoundaryStatement() {
|
||||
public NativeSQLStatement createNativeBoundaryStatement() {
|
||||
return createNativeSQLStatement( "select t.id, t.geom.STBoundary() from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeEnvelopeStatement() {
|
||||
public NativeSQLStatement createNativeEnvelopeStatement() {
|
||||
return createNativeSQLStatement( "select t.id, t.geom.STEnvelope() from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeAsBinaryStatement() {
|
||||
public NativeSQLStatement createNativeAsBinaryStatement() {
|
||||
return createNativeSQLStatement( "select t.id, t.geom.STAsBinary() from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeGeometryTypeStatement() {
|
||||
public NativeSQLStatement createNativeGeometryTypeStatement() {
|
||||
return createNativeSQLStatement( "select t.id, t.geom.STGeometryType() from GeomTest t" );
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ public class SqlServerExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeWithinStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeWithinStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.STWithin(geometry::STGeomFromText(?, 4326)) from GeomTest t where t.geom.STWithin(geometry::STGeomFromText(?, 4326)) = 'true' and t.geom.STSrid = 4326",
|
||||
geom.toText()
|
||||
|
@ -140,7 +140,7 @@ public class SqlServerExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeEqualsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeEqualsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.STEquals(geometry::STGeomFromText(?, 4326)) from GeomTest t where t.geom.STEquals(geometry::STGeomFromText(?, 4326)) = 'true' and t.geom.STSrid = 4326",
|
||||
geom.toText()
|
||||
|
@ -148,7 +148,7 @@ public class SqlServerExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.STCrosses(geometry::STGeomFromText(?, 4326)) from GeomTest t where t.geom.STCrosses(geometry::STGeomFromText(?, 4326)) = 'true' and t.geom.STSrid = 4326",
|
||||
geom.toText()
|
||||
|
@ -156,7 +156,7 @@ public class SqlServerExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeContainsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeContainsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.STContains(geometry::STGeomFromText(?, 4326)) from GeomTest t where t.geom.STContains(geometry::STGeomFromText(?, 4326)) = 'true' and t.geom.STSrid = 4326",
|
||||
geom.toText()
|
||||
|
@ -164,7 +164,7 @@ public class SqlServerExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.STDisjoint(geometry::STGeomFromText(?, 4326)) from GeomTest t where t.geom.STDisjoint(geometry::STGeomFromText(?, 4326)) = 'true' and t.geom.STSrid = 4326",
|
||||
geom.toText()
|
||||
|
@ -172,17 +172,17 @@ public class SqlServerExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeTransformStatement(int epsg) {
|
||||
public NativeSQLStatement createNativeTransformStatement(int epsg) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeHavingSRIDStatement(int srid) {
|
||||
public NativeSQLStatement createNativeHavingSRIDStatement(int srid) {
|
||||
return createNativeSQLStatement( "select t.id, 1 from GeomTest t where t.geom.STSrid = " + srid );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.STIntersects(geometry::STGeomFromText(?, 4326)) from GeomTest t where t.geom.STIntersects(geometry::STGeomFromText(?, 4326)) = 'true' and t.geom.STSrid = 4326",
|
||||
geom.toText()
|
||||
|
@ -190,7 +190,7 @@ public class SqlServerExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeFilterStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeFilterStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.Filter(geometry::STGeomFromText(?, 4326)) from GeomTest t where t.geom.Filter(geometry::STGeomFromText(?, 4326)) = 1 and t.geom.STSrid = 4326",
|
||||
geom.toText()
|
||||
|
@ -198,7 +198,7 @@ public class SqlServerExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.STTouches(geometry::STGeomFromText(?, 4326)) from GeomTest t where t.geom.STTouches(geometry::STGeomFromText(?, 4326)) = 'true' and t.geom.STSrid = 4326",
|
||||
geom.toText()
|
||||
|
@ -206,7 +206,7 @@ public class SqlServerExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.STOverlaps(geometry::STGeomFromText(?, 4326)) from GeomTest t where t.geom.STOverlaps(geometry::STGeomFromText(?, 4326)) = 'true' and t.geom.STSrid = 4326",
|
||||
geom.toText()
|
||||
|
@ -214,18 +214,18 @@ public class SqlServerExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeRelateStatement(Geometry geom, String matrix) {
|
||||
public NativeSQLStatement createNativeRelateStatement(Geometry geom, String matrix) {
|
||||
String sql = "select t.id, t.geom.STRelate(geometry::STGeomFromText(?, 4326), '" + matrix + "' ) from GeomTest t where t.geom.STRelate(geometry::STGeomFromText(?, 4326), '" + matrix + "') = 'true' and t.geom.STSrid = 4326";
|
||||
return createNativeSQLStatementAllWKTParams( sql, geom.toText() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDwithinStatement(Point geom, double distance) {
|
||||
public NativeSQLStatement createNativeDwithinStatement(Point geom, double distance) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDistanceStatement(Geometry geom) {
|
||||
public NativeSQLStatement createNativeDistanceStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
"select t.id, t.geom.STDistance(geometry::STGeomFromText(?, 4326)) from GeomTest t where t.geom.STSrid = 4326",
|
||||
geom.toText()
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.hibernate.spatial.integration.GeomEntityLike;
|
|||
import org.hibernate.spatial.testing.datareader.TestDataElement;
|
||||
|
||||
import org.geolatte.geom.Geometry;
|
||||
import org.geolatte.geom.codec.Wkt;
|
||||
import org.geolatte.geom.codec.WktDecodeException;
|
||||
import org.geolatte.geom.codec.WktDecoder;
|
||||
|
||||
|
@ -98,6 +99,11 @@ public class GeomEntity implements GeomEntityLike<Geometry> {
|
|||
return id.equals( geomEntity.id );
|
||||
}
|
||||
|
||||
public void setGeomFromWkt(String wkt) {
|
||||
this.geom = Wkt.fromWkt( wkt );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id;
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.hibernate.dialect.Dialect;
|
|||
import org.hibernate.spatial.integration.GeomEntityLike;
|
||||
import org.hibernate.spatial.testing.datareader.TestDataElement;
|
||||
|
||||
import org.geolatte.geom.codec.Wkt;
|
||||
import org.locationtech.jts.geom.Geometry;
|
||||
import org.locationtech.jts.io.ParseException;
|
||||
import org.geolatte.geom.codec.WktDecoder;
|
||||
|
@ -33,7 +34,7 @@ import static org.hibernate.spatial.integration.DecodeUtil.getWktDecoder;
|
|||
* Test class used in unit testing.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "geomtest")
|
||||
@Table(name = "jtsgeomtest")
|
||||
public class JtsGeomEntity implements GeomEntityLike<Geometry> {
|
||||
|
||||
|
||||
|
@ -92,6 +93,10 @@ public class JtsGeomEntity implements GeomEntityLike<Geometry> {
|
|||
return id.equals( geomEntity.id );
|
||||
}
|
||||
|
||||
public void setGeomFromWkt(String wkt) {
|
||||
this.geom = JTS.to( Wkt.fromWkt( wkt ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id;
|
||||
|
|
Loading…
Reference in New Issue