mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-16 16:15:06 +00:00
HHH-11790 - Update code style for spatial module
This commit is contained in:
parent
2072ac0d0d
commit
a7a9170e4e
@ -7,19 +7,19 @@
|
||||
|
||||
package org.hibernate.spatial;
|
||||
|
||||
import org.geolatte.geom.Geometry;
|
||||
import org.geolatte.geom.codec.Wkt;
|
||||
import org.geolatte.geom.jts.JTS;
|
||||
|
||||
import org.hibernate.type.descriptor.WrapperOptions;
|
||||
import org.hibernate.type.descriptor.java.AbstractTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptorRegistry;
|
||||
|
||||
import org.geolatte.geom.Geometry;
|
||||
import org.geolatte.geom.codec.Wkt;
|
||||
import org.geolatte.geom.jts.JTS;
|
||||
|
||||
/**
|
||||
* Descriptor for geolatte-geom {@code Geometry}s.
|
||||
*
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 10/12/12
|
||||
* creation-date: 10/12/12
|
||||
*/
|
||||
public class GeolatteGeometryJavaTypeDescriptor extends AbstractTypeDescriptor<Geometry> {
|
||||
|
||||
|
@ -7,6 +7,9 @@
|
||||
|
||||
package org.hibernate.spatial;
|
||||
|
||||
import org.hibernate.type.AbstractSingleColumnStandardBasicType;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
|
||||
import org.geolatte.geom.Geometry;
|
||||
import org.geolatte.geom.GeometryCollection;
|
||||
import org.geolatte.geom.LineString;
|
||||
@ -16,14 +19,11 @@
|
||||
import org.geolatte.geom.Point;
|
||||
import org.geolatte.geom.Polygon;
|
||||
|
||||
import org.hibernate.type.AbstractSingleColumnStandardBasicType;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
|
||||
/**
|
||||
* a {@code Type} that maps between the database geometry type and geolatte-geom {@code Geometry}.
|
||||
*
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 10/12/12
|
||||
* creation-date: 10/12/12
|
||||
*/
|
||||
public class GeolatteGeometryType extends AbstractSingleColumnStandardBasicType<Geometry> implements Spatial {
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
*/
|
||||
@MessageLogger(projectCode = "HHH")
|
||||
@ValidIdRange( min = 80000001, max = 80001000 )
|
||||
@ValidIdRange(min = 80000001, max = 80001000)
|
||||
public interface HSMessageLogger extends BasicLogger {
|
||||
@LogMessage(level = INFO)
|
||||
@Message(value = "hibernate-spatial integration enabled : %s", id = 80000001)
|
||||
|
@ -12,27 +12,24 @@
|
||||
* Hibernate Spatial specific configuration settings.
|
||||
*
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 8/16/13
|
||||
* creation-date: 8/16/13
|
||||
*/
|
||||
public class HibernateSpatialConfigurationSettings implements Serializable {
|
||||
|
||||
private HibernateSpatialConfigurationSettings() {
|
||||
//prevent this object from being instantiated
|
||||
}
|
||||
|
||||
/**
|
||||
* The canonical class name of the Oracle ConnectionFinder implementation that will be used by the
|
||||
* Oracle spatial dialects
|
||||
*/
|
||||
|
||||
public static final String CONNECTION_FINDER = "hibernate.spatial.connection_finder";
|
||||
|
||||
/**
|
||||
* SRID to use for the DB2 Spatial Dialects.
|
||||
*
|
||||
*/
|
||||
public static final String DB2_DEFAULT_SRID = "hibernate.spatial.db2.srid";
|
||||
|
||||
private HibernateSpatialConfigurationSettings() {
|
||||
//prevent this object from being instantiated
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -7,21 +7,21 @@
|
||||
|
||||
package org.hibernate.spatial;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.io.ParseException;
|
||||
import com.vividsolutions.jts.io.WKTReader;
|
||||
import org.geolatte.geom.jts.JTS;
|
||||
|
||||
import org.hibernate.type.descriptor.WrapperOptions;
|
||||
import org.hibernate.type.descriptor.java.AbstractTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptorRegistry;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.io.ParseException;
|
||||
import com.vividsolutions.jts.io.WKTReader;
|
||||
import org.geolatte.geom.jts.JTS;
|
||||
|
||||
/**
|
||||
* Descriptor for JTS {@code Geometry}s.
|
||||
*
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 7/27/11
|
||||
* creation-date: 7/27/11
|
||||
*/
|
||||
public class JTSGeometryJavaTypeDescriptor extends AbstractTypeDescriptor<Geometry> {
|
||||
|
||||
@ -49,7 +49,7 @@ public Geometry fromString(String string) {
|
||||
try {
|
||||
return reader.read( string );
|
||||
}
|
||||
catch ( ParseException e ) {
|
||||
catch (ParseException e) {
|
||||
throw new RuntimeException( String.format( "Can't parse string %s as WKT", string ) );
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,11 @@
|
||||
*/
|
||||
package org.hibernate.spatial;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
import org.hibernate.type.AbstractSingleColumnStandardBasicType;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
/**
|
||||
* A {@code Type} that maps between the database geometry type and JTS {@code Geometry}.
|
||||
*
|
||||
|
@ -11,7 +11,7 @@
|
||||
* A marker interface for spatial (geometric/geographic) types.
|
||||
*
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 4/18/13
|
||||
* creation-date: 4/18/13
|
||||
*/
|
||||
public interface Spatial {
|
||||
|
||||
|
@ -9,14 +9,14 @@
|
||||
|
||||
/**
|
||||
* Spatial functions that users generally expect in a database.
|
||||
*
|
||||
* <p>
|
||||
* <p>The javadoc contains references to these specifications.</p>
|
||||
* <ul>
|
||||
* <li>OpenGIS Simple Features Specification for SQL, rev. 1.1 (OGC 99-049)</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: Oct 7, 2010
|
||||
* creation-date: Oct 7, 2010
|
||||
*/
|
||||
public enum SpatialFunction {
|
||||
|
||||
@ -147,7 +147,7 @@ public enum SpatialFunction {
|
||||
|
||||
/**
|
||||
* the distance within function
|
||||
*
|
||||
* <p>
|
||||
* <p>The semantics are those of Postgis function ST_Dwithin (geom1, geom2, distance) : boolean. It returns true
|
||||
* if geom1 and geom2 are within the specified distance of one another (in units of the spatial reference system).</p>
|
||||
*/
|
||||
@ -155,7 +155,7 @@ public enum SpatialFunction {
|
||||
|
||||
/**
|
||||
* the transform function
|
||||
*
|
||||
* <p>
|
||||
* <p>The semantics are those of the Postgis function ST_Transform(geometry, srid) : geometry. It returns new geometry
|
||||
* with its coordinates transformed to the spatial reference system referenced by the srid parameter.
|
||||
*/
|
||||
@ -170,8 +170,6 @@ public enum SpatialFunction {
|
||||
private final String description;
|
||||
|
||||
|
||||
|
||||
|
||||
SpatialFunction(String specification) {
|
||||
this.description = specification;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
/**
|
||||
* Enumerates the supported spatial relations.
|
||||
*
|
||||
* <p>
|
||||
* <p>Most of these relations are defined in "OpenGIS Simple Features Specification for SQL, rev. 1.1 (OGC 99-049),
|
||||
* section 2.1.13.3. "</p>
|
||||
*
|
||||
@ -58,7 +58,7 @@ public interface SpatialRelation {
|
||||
|
||||
/**
|
||||
* The bounding box of the first geometry intersects the bounding box of the second
|
||||
*
|
||||
* <p>
|
||||
* <p>This relation is not defined in OGC 99-049, it corresponds to the Postgis '&&' operator.</p>
|
||||
*/
|
||||
public static int FILTER = 8;
|
||||
|
@ -7,8 +7,6 @@
|
||||
|
||||
package org.hibernate.spatial.criterion;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.criterion.CriteriaQuery;
|
||||
@ -16,15 +14,16 @@
|
||||
import org.hibernate.engine.spi.TypedValue;
|
||||
import org.hibernate.spatial.SpatialDialect;
|
||||
import org.hibernate.spatial.SpatialFunction;
|
||||
|
||||
import org.hibernate.spatial.dialect.oracle.OracleSpatial10gDialect;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
/**
|
||||
* A {@code Criterion} constraining a geometry property to be within a specified distance of a search geometry.
|
||||
*
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 2/1/11
|
||||
* creation-date: 2/1/11
|
||||
*/
|
||||
public class DWithinExpression implements Criterion {
|
||||
|
||||
@ -59,9 +58,12 @@ public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws
|
||||
|
||||
@Override
|
||||
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
|
||||
final SpatialDialect spatialDialect = ExpressionUtil.getSpatialDialect( criteriaQuery, SpatialFunction.dwithin );
|
||||
final SpatialDialect spatialDialect = ExpressionUtil.getSpatialDialect(
|
||||
criteriaQuery,
|
||||
SpatialFunction.dwithin
|
||||
);
|
||||
TypedValue typedDistanceValue = new TypedValue( StandardBasicTypes.DOUBLE, distance );
|
||||
if ( spatialDialect instanceof OracleSpatial10gDialect) {
|
||||
if ( spatialDialect instanceof OracleSpatial10gDialect ) {
|
||||
typedDistanceValue = new TypedValue( StandardBasicTypes.STRING, "distance=" + distance );
|
||||
}
|
||||
return new TypedValue[] {
|
||||
|
@ -18,7 +18,7 @@
|
||||
* This class assists in the formation of a SQL-fragment in the various spatial query expressions.
|
||||
*
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 2/15/11
|
||||
* creation-date: 2/15/11
|
||||
*/
|
||||
public class ExpressionUtil {
|
||||
|
||||
@ -58,7 +58,9 @@ public static SpatialDialect getSpatialDialect(CriteriaQuery criteriaQuery, Spat
|
||||
* @param propertyName The property path
|
||||
* @param criteria The criteria
|
||||
* @param criteriaQuery The criteria query
|
||||
*
|
||||
* @return The column name
|
||||
*
|
||||
* @throws HibernateException If the property could not be resolved, or more than one column is mapped by the property path.
|
||||
*/
|
||||
public static String findColumn(String propertyName, Criteria criteria, CriteriaQuery criteriaQuery) {
|
||||
|
@ -20,7 +20,6 @@
|
||||
* A {@code Criterion} constraining a geometry property to have a specified SRID.
|
||||
*
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
*
|
||||
*/
|
||||
public class HavingSridExpression implements Criterion {
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
* A {@code Criterion} constraining a geometry property to be (non-)empty.
|
||||
*
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
*
|
||||
*/
|
||||
public class IsEmptyExpression implements Criterion {
|
||||
|
||||
@ -42,7 +41,10 @@ public IsEmptyExpression(String propertyName, boolean isEmpty) {
|
||||
@Override
|
||||
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
|
||||
final String column = ExpressionUtil.findColumn( propertyName, criteria, criteriaQuery );
|
||||
final SpatialDialect spatialDialect = ExpressionUtil.getSpatialDialect( criteriaQuery, SpatialFunction.isempty );
|
||||
final SpatialDialect spatialDialect = ExpressionUtil.getSpatialDialect(
|
||||
criteriaQuery,
|
||||
SpatialFunction.isempty
|
||||
);
|
||||
return spatialDialect.getIsEmptySQL( column, isEmpty );
|
||||
}
|
||||
|
||||
|
@ -6,9 +6,6 @@
|
||||
*/
|
||||
package org.hibernate.spatial.criterion;
|
||||
|
||||
import com.vividsolutions.jts.geom.Envelope;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.criterion.CriteriaQuery;
|
||||
@ -19,6 +16,9 @@
|
||||
import org.hibernate.spatial.SpatialDialect;
|
||||
import org.hibernate.spatial.jts.EnvelopeAdapter;
|
||||
|
||||
import com.vividsolutions.jts.geom.Envelope;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
/**
|
||||
* A <code>Criterion</code> constraining a geometry property to have a bounding box that overlaps with
|
||||
* a specified bounding box.
|
||||
|
@ -29,7 +29,7 @@ private SpatialProjections() {
|
||||
|
||||
/**
|
||||
* Applies an extent projection to the specified geometry function
|
||||
*
|
||||
* <p>
|
||||
* <p>The extent of a set of {@code Geometry}s is the union of their bounding boxes.</p>
|
||||
*
|
||||
* @param propertyName The property to use for calculating the extent
|
||||
|
@ -6,8 +6,6 @@
|
||||
*/
|
||||
package org.hibernate.spatial.criterion;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.criterion.CriteriaQuery;
|
||||
@ -17,6 +15,8 @@
|
||||
import org.hibernate.engine.spi.TypedValue;
|
||||
import org.hibernate.spatial.SpatialDialect;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
/**
|
||||
* A {@code Criterion} constraining a {@code Geometry} property to have specific spatial relation
|
||||
* to a search {@code Geometry}.
|
||||
|
@ -6,15 +6,15 @@
|
||||
*/
|
||||
package org.hibernate.spatial.criterion;
|
||||
|
||||
import com.vividsolutions.jts.geom.Envelope;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
import org.hibernate.criterion.Criterion;
|
||||
import org.hibernate.spatial.SpatialRelation;
|
||||
|
||||
import com.vividsolutions.jts.geom.Envelope;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
/**
|
||||
* A factory for spatial criteria.
|
||||
*
|
||||
* <p>
|
||||
* The criterion types created by this class implement the spatial query
|
||||
* expressions of the OpenGIS Simple Features Specification for SQL, Revision
|
||||
* 1.1. In addition, it provides for a simple spatial <code>filter</code> that
|
||||
|
@ -10,7 +10,7 @@
|
||||
<head></head>
|
||||
<body>
|
||||
<p>
|
||||
This extends the criterion API with spatial query expressions.
|
||||
This extends the criterion API with spatial query expressions.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -13,10 +13,6 @@
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
|
||||
import org.geolatte.geom.Geometry;
|
||||
import org.geolatte.geom.codec.db.db2.Db2ClobDecoder;
|
||||
import org.geolatte.geom.codec.db.db2.Db2ClobEncoder;
|
||||
|
||||
import org.hibernate.type.descriptor.ValueBinder;
|
||||
import org.hibernate.type.descriptor.ValueExtractor;
|
||||
import org.hibernate.type.descriptor.WrapperOptions;
|
||||
@ -25,6 +21,10 @@
|
||||
import org.hibernate.type.descriptor.sql.BasicExtractor;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
|
||||
import org.geolatte.geom.Geometry;
|
||||
import org.geolatte.geom.codec.db.db2.Db2ClobDecoder;
|
||||
import org.geolatte.geom.codec.db.db2.Db2ClobEncoder;
|
||||
|
||||
/**
|
||||
* Type Descriptor for the DB2 Geometry type (as Clob)
|
||||
* <p>
|
||||
@ -103,8 +103,8 @@ public Geometry<?> toGeometry(Object object) {
|
||||
}
|
||||
|
||||
if ( object instanceof Clob ) {
|
||||
Db2ClobDecoder decoder = new Db2ClobDecoder(srid);
|
||||
return decoder.decode( (Clob) object );
|
||||
Db2ClobDecoder decoder = new Db2ClobDecoder( srid );
|
||||
return decoder.decode( (Clob) object );
|
||||
}
|
||||
|
||||
throw new IllegalStateException( "Object of type " + object.getClass()
|
||||
|
@ -305,7 +305,7 @@ public String getSpatialRelateSQL(String columnName, int spatialRelation) {
|
||||
|
||||
@Override
|
||||
public boolean supports(SpatialFunction function) {
|
||||
return (getFunctions().get( function.toString() ) != null);
|
||||
return ( getFunctions().get( function.toString() ) != null );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,8 +11,6 @@
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.dialect.function.StandardSQLFunction;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
||||
|
||||
import org.hibernate.spatial.GeolatteGeometryType;
|
||||
import org.hibernate.spatial.JTSGeometryType;
|
||||
import org.hibernate.spatial.SpatialDialect;
|
||||
@ -151,7 +149,7 @@ public boolean supportsFiltering() {
|
||||
|
||||
@Override
|
||||
public boolean supports(SpatialFunction function) {
|
||||
return function != SpatialFunction.difference && (getFunctions().get( function.toString() ) != null);
|
||||
return function != SpatialFunction.difference && ( getFunctions().get( function.toString() ) != null );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,8 +13,6 @@
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
|
||||
import org.geolatte.geom.Geometry;
|
||||
|
||||
import org.hibernate.type.descriptor.ValueBinder;
|
||||
import org.hibernate.type.descriptor.ValueExtractor;
|
||||
import org.hibernate.type.descriptor.WrapperOptions;
|
||||
@ -23,6 +21,8 @@
|
||||
import org.hibernate.type.descriptor.sql.BasicExtractor;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
|
||||
import org.geolatte.geom.Geometry;
|
||||
|
||||
/**
|
||||
* Descriptor for GeoDB Geometries.
|
||||
*
|
||||
|
@ -13,6 +13,11 @@
|
||||
import java.io.InputStream;
|
||||
import java.sql.Blob;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.spatial.HSMessageLogger;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import org.geolatte.geom.ByteBuffer;
|
||||
import org.geolatte.geom.ByteOrder;
|
||||
import org.geolatte.geom.C2D;
|
||||
@ -27,11 +32,6 @@
|
||||
import org.geolatte.geom.crs.CoordinateReferenceSystems;
|
||||
import org.geolatte.geom.jts.JTS;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.spatial.HSMessageLogger;
|
||||
|
||||
/**
|
||||
* A utility class to serialize from/to GeoDB WKB's.
|
||||
* <p/>
|
||||
@ -60,7 +60,7 @@ private GeoDbWkb() {
|
||||
public static byte[] to(Geometry geometry) {
|
||||
final WkbEncoder encoder = Wkb.newEncoder( Wkb.Dialect.POSTGIS_EWKB_1 );
|
||||
final ByteBuffer buffer = encoder.encode( geometry, ByteOrder.NDR );
|
||||
return (buffer == null ? null : buffer.toByteArray());
|
||||
return ( buffer == null ? null : buffer.toByteArray() );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -76,7 +76,7 @@ public static Geometry from(Object object) {
|
||||
}
|
||||
try {
|
||||
|
||||
if (object instanceof com.vividsolutions.jts.geom.Geometry) {
|
||||
if ( object instanceof com.vividsolutions.jts.geom.Geometry ) {
|
||||
return JTS.from( (com.vividsolutions.jts.geom.Geometry) object );
|
||||
}
|
||||
final WkbDecoder decoder = Wkb.newDecoder( Wkb.Dialect.POSTGIS_EWKB_1 );
|
||||
@ -121,7 +121,7 @@ private static ByteBuffer toByteBuffer(Blob blob) {
|
||||
try {
|
||||
in = blob.getBinaryStream();
|
||||
int n = 0;
|
||||
while ( (n = in.read( buf )) >= 0 ) {
|
||||
while ( ( n = in.read( buf ) ) >= 0 ) {
|
||||
baos.write( buf, 0, n );
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
<head></head>
|
||||
<body>
|
||||
<p>
|
||||
This package contains the H2 Dialect extensions for the GeoDB dialect.
|
||||
This package contains the H2 Dialect extensions for the GeoDB dialect.
|
||||
</p>
|
||||
<p>
|
||||
For more information on GeoDB, see <a href="https://github.com/jdeolive/geodb">https://github.com/jdeolive/geodb</a>.
|
||||
|
@ -12,7 +12,6 @@
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
|
||||
import org.geolatte.geom.Geometry;
|
||||
import org.hibernate.type.descriptor.ValueBinder;
|
||||
import org.hibernate.type.descriptor.ValueExtractor;
|
||||
import org.hibernate.type.descriptor.WrapperOptions;
|
||||
@ -21,13 +20,13 @@
|
||||
import org.hibernate.type.descriptor.sql.BasicExtractor;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
|
||||
public class HANAGeometryTypeDescriptor implements SqlTypeDescriptor {
|
||||
import org.geolatte.geom.Geometry;
|
||||
|
||||
private static final long serialVersionUID = -6978798264716544804L;
|
||||
public class HANAGeometryTypeDescriptor implements SqlTypeDescriptor {
|
||||
|
||||
public static final HANAGeometryTypeDescriptor CRS_LOADING_INSTANCE = new HANAGeometryTypeDescriptor( true );
|
||||
public static final HANAGeometryTypeDescriptor INSTANCE = new HANAGeometryTypeDescriptor( false );
|
||||
|
||||
private static final long serialVersionUID = -6978798264716544804L;
|
||||
final boolean determineCrsIdFromDatabase;
|
||||
|
||||
public HANAGeometryTypeDescriptor(boolean determineCrsIdFromDatabase) {
|
||||
|
@ -12,7 +12,6 @@
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
|
||||
import org.geolatte.geom.Point;
|
||||
import org.hibernate.type.descriptor.ValueBinder;
|
||||
import org.hibernate.type.descriptor.ValueExtractor;
|
||||
import org.hibernate.type.descriptor.WrapperOptions;
|
||||
@ -21,14 +20,15 @@
|
||||
import org.hibernate.type.descriptor.sql.BasicExtractor;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
|
||||
public class HANAPointTypeDescriptor implements SqlTypeDescriptor {
|
||||
import org.geolatte.geom.Point;
|
||||
|
||||
private static final long serialVersionUID = -6978798264716544804L;
|
||||
public class HANAPointTypeDescriptor implements SqlTypeDescriptor {
|
||||
|
||||
/**
|
||||
* An instance of the descrtiptor
|
||||
*/
|
||||
public static final HANAPointTypeDescriptor INSTANCE = new HANAPointTypeDescriptor();
|
||||
private static final long serialVersionUID = -6978798264716544804L;
|
||||
|
||||
@Override
|
||||
public int getSqlType() {
|
||||
|
@ -29,52 +29,88 @@ public HANASpatialDialect() {
|
||||
registerColumnType( HANAGeometryTypeDescriptor.INSTANCE.getSqlType(), "ST_GEOMETRY" );
|
||||
registerColumnType( HANAPointTypeDescriptor.INSTANCE.getSqlType(), "ST_POINT" );
|
||||
|
||||
registerFunction( SpatialFunction.asbinary.name(),
|
||||
new HANASpatialFunction( "ST_AsBinary", StandardBasicTypes.MATERIALIZED_BLOB, false ) );
|
||||
registerFunction( SpatialFunction.astext.name(),
|
||||
new HANASpatialFunction( "ST_AsText", StandardBasicTypes.MATERIALIZED_CLOB, false ) );
|
||||
registerFunction(
|
||||
SpatialFunction.asbinary.name(),
|
||||
new HANASpatialFunction( "ST_AsBinary", StandardBasicTypes.MATERIALIZED_BLOB, false )
|
||||
);
|
||||
registerFunction(
|
||||
SpatialFunction.astext.name(),
|
||||
new HANASpatialFunction( "ST_AsText", StandardBasicTypes.MATERIALIZED_CLOB, false )
|
||||
);
|
||||
registerFunction( SpatialFunction.boundary.name(), new HANASpatialFunction( "ST_Boundary", false ) );
|
||||
registerFunction( SpatialFunction.buffer.name(), new HANASpatialFunction( "ST_Buffer", false ) );
|
||||
registerFunction( SpatialFunction.contains.name(),
|
||||
new HANASpatialFunction( "ST_Contains", StandardBasicTypes.NUMERIC_BOOLEAN, true ) );
|
||||
registerFunction(
|
||||
SpatialFunction.contains.name(),
|
||||
new HANASpatialFunction( "ST_Contains", StandardBasicTypes.NUMERIC_BOOLEAN, true )
|
||||
);
|
||||
registerFunction( SpatialFunction.convexhull.name(), new HANASpatialFunction( "ST_ConvexHull", false ) );
|
||||
registerFunction( SpatialFunction.crosses.name(),
|
||||
new HANASpatialFunction( "ST_Crosses", StandardBasicTypes.NUMERIC_BOOLEAN, true ) );
|
||||
registerFunction(
|
||||
SpatialFunction.crosses.name(),
|
||||
new HANASpatialFunction( "ST_Crosses", StandardBasicTypes.NUMERIC_BOOLEAN, true )
|
||||
);
|
||||
registerFunction( SpatialFunction.difference.name(), new HANASpatialFunction( "ST_Difference", true ) );
|
||||
registerFunction( SpatialFunction.dimension.name(),
|
||||
new HANASpatialFunction( "ST_Dimension ", StandardBasicTypes.INTEGER, false ) );
|
||||
registerFunction( SpatialFunction.disjoint.name(),
|
||||
new HANASpatialFunction( "ST_Disjoint", StandardBasicTypes.NUMERIC_BOOLEAN, true ) );
|
||||
registerFunction( SpatialFunction.distance.name(),
|
||||
new HANASpatialFunction( "ST_Distance", StandardBasicTypes.DOUBLE, true ) );
|
||||
registerFunction( SpatialFunction.dwithin.name(),
|
||||
new HANASpatialFunction( "ST_WithinDistance", StandardBasicTypes.NUMERIC_BOOLEAN, true ) );
|
||||
registerFunction(
|
||||
SpatialFunction.dimension.name(),
|
||||
new HANASpatialFunction( "ST_Dimension ", StandardBasicTypes.INTEGER, false )
|
||||
);
|
||||
registerFunction(
|
||||
SpatialFunction.disjoint.name(),
|
||||
new HANASpatialFunction( "ST_Disjoint", StandardBasicTypes.NUMERIC_BOOLEAN, true )
|
||||
);
|
||||
registerFunction(
|
||||
SpatialFunction.distance.name(),
|
||||
new HANASpatialFunction( "ST_Distance", StandardBasicTypes.DOUBLE, true )
|
||||
);
|
||||
registerFunction(
|
||||
SpatialFunction.dwithin.name(),
|
||||
new HANASpatialFunction( "ST_WithinDistance", StandardBasicTypes.NUMERIC_BOOLEAN, true )
|
||||
);
|
||||
registerFunction( SpatialFunction.envelope.name(), new HANASpatialFunction( "ST_Envelope", true ) );
|
||||
registerFunction( SpatialFunction.equals.name(),
|
||||
new HANASpatialFunction( "ST_Equals", StandardBasicTypes.NUMERIC_BOOLEAN, true ) );
|
||||
registerFunction(
|
||||
SpatialFunction.equals.name(),
|
||||
new HANASpatialFunction( "ST_Equals", StandardBasicTypes.NUMERIC_BOOLEAN, true )
|
||||
);
|
||||
registerFunction( SpatialFunction.extent.name(), new HANASpatialAggregate( "ST_EnvelopeAggr" ) );
|
||||
registerFunction( SpatialFunction.geometrytype.name(),
|
||||
new HANASpatialFunction( "ST_GeometryType", StandardBasicTypes.STRING, false ) );
|
||||
registerFunction(
|
||||
SpatialFunction.geometrytype.name(),
|
||||
new HANASpatialFunction( "ST_GeometryType", StandardBasicTypes.STRING, false )
|
||||
);
|
||||
registerFunction( SpatialFunction.geomunion.name(), new HANASpatialFunction( "ST_Union", true ) );
|
||||
registerFunction( SpatialFunction.intersection.name(), new HANASpatialFunction( "ST_Intersection", true ) );
|
||||
registerFunction( SpatialFunction.intersects.name(),
|
||||
new HANASpatialFunction( "ST_Intersects", StandardBasicTypes.NUMERIC_BOOLEAN, true ) );
|
||||
registerFunction( SpatialFunction.isempty.name(),
|
||||
new HANASpatialFunction( "ST_IsEmpty", StandardBasicTypes.NUMERIC_BOOLEAN, false ) );
|
||||
registerFunction( SpatialFunction.issimple.name(),
|
||||
new HANASpatialFunction( "ST_IsSimple", StandardBasicTypes.NUMERIC_BOOLEAN, false ) );
|
||||
registerFunction( SpatialFunction.overlaps.name(),
|
||||
new HANASpatialFunction( "ST_Overlaps", StandardBasicTypes.NUMERIC_BOOLEAN, true ) );
|
||||
registerFunction( SpatialFunction.relate.name(),
|
||||
new HANASpatialFunction( "ST_Relate", StandardBasicTypes.NUMERIC_BOOLEAN, true ) );
|
||||
registerFunction( SpatialFunction.srid.name(),
|
||||
new HANASpatialFunction( "ST_SRID", StandardBasicTypes.INTEGER, false ) );
|
||||
registerFunction(
|
||||
SpatialFunction.intersects.name(),
|
||||
new HANASpatialFunction( "ST_Intersects", StandardBasicTypes.NUMERIC_BOOLEAN, true )
|
||||
);
|
||||
registerFunction(
|
||||
SpatialFunction.isempty.name(),
|
||||
new HANASpatialFunction( "ST_IsEmpty", StandardBasicTypes.NUMERIC_BOOLEAN, false )
|
||||
);
|
||||
registerFunction(
|
||||
SpatialFunction.issimple.name(),
|
||||
new HANASpatialFunction( "ST_IsSimple", StandardBasicTypes.NUMERIC_BOOLEAN, false )
|
||||
);
|
||||
registerFunction(
|
||||
SpatialFunction.overlaps.name(),
|
||||
new HANASpatialFunction( "ST_Overlaps", StandardBasicTypes.NUMERIC_BOOLEAN, true )
|
||||
);
|
||||
registerFunction(
|
||||
SpatialFunction.relate.name(),
|
||||
new HANASpatialFunction( "ST_Relate", StandardBasicTypes.NUMERIC_BOOLEAN, true )
|
||||
);
|
||||
registerFunction(
|
||||
SpatialFunction.srid.name(),
|
||||
new HANASpatialFunction( "ST_SRID", StandardBasicTypes.INTEGER, false )
|
||||
);
|
||||
registerFunction( SpatialFunction.symdifference.name(), new HANASpatialFunction( "ST_SymDifference", true ) );
|
||||
registerFunction( SpatialFunction.touches.name(),
|
||||
new HANASpatialFunction( "ST_Touches", StandardBasicTypes.NUMERIC_BOOLEAN, true ) );
|
||||
registerFunction(
|
||||
SpatialFunction.touches.name(),
|
||||
new HANASpatialFunction( "ST_Touches", StandardBasicTypes.NUMERIC_BOOLEAN, true )
|
||||
);
|
||||
registerFunction( SpatialFunction.transform.name(), new HANASpatialFunction( "ST_Transform", false ) );
|
||||
registerFunction( SpatialFunction.within.name(),
|
||||
new HANASpatialFunction( "ST_Within", StandardBasicTypes.NUMERIC_BOOLEAN, true ) );
|
||||
registerFunction(
|
||||
SpatialFunction.within.name(),
|
||||
new HANASpatialFunction( "ST_Within", StandardBasicTypes.NUMERIC_BOOLEAN, true )
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -118,7 +154,8 @@ public Boolean convert(Object value) {
|
||||
}
|
||||
|
||||
},
|
||||
Boolean.FALSE ).booleanValue();
|
||||
Boolean.FALSE
|
||||
).booleanValue();
|
||||
|
||||
if ( determineCrsIdFromDatabase ) {
|
||||
typeContributions.contributeType( new GeolatteGeometryType( HANAGeometryTypeDescriptor.CRS_LOADING_INSTANCE ) );
|
||||
|
@ -35,7 +35,8 @@ public static Geometry<?> toGeometry(ResultSet rs, String name) throws SQLExcept
|
||||
String tableName = null;
|
||||
String columnName = null;
|
||||
for ( int i = 1; i <= rs.getMetaData().getColumnCount(); i++ ) {
|
||||
if ( name.equals( rs.getMetaData().getColumnLabel( i ) ) || name.toUpperCase().equals( rs.getMetaData().getColumnLabel( i ) ) ) {
|
||||
if ( name.equals( rs.getMetaData().getColumnLabel( i ) ) ||
|
||||
name.toUpperCase().equals( rs.getMetaData().getColumnLabel( i ) ) ) {
|
||||
tableName = rs.getMetaData().getTableName( i );
|
||||
columnName = rs.getMetaData().getColumnName( i );
|
||||
}
|
||||
@ -53,16 +54,17 @@ public static Geometry<?> toGeometry(ResultSet rs, String name) throws SQLExcept
|
||||
int typeCode = (int) buffer.getUInt();
|
||||
|
||||
Connection connection = rs.getStatement().getConnection();
|
||||
|
||||
|
||||
// Check if SRID is set
|
||||
if ( ( typeCode & POSTGIS_SRID_FLAG ) != POSTGIS_SRID_FLAG ) {
|
||||
// No SRID set => try to get SRID from the database
|
||||
try ( PreparedStatement psSrid = connection
|
||||
.prepareStatement( "SELECT SRS_ID FROM SYS.ST_GEOMETRY_COLUMNS WHERE SCHEMA_NAME=CURRENT_SCHEMA AND TABLE_NAME=? AND COLUMN_NAME=?" ) ) {
|
||||
try (PreparedStatement psSrid = connection
|
||||
.prepareStatement(
|
||||
"SELECT SRS_ID FROM SYS.ST_GEOMETRY_COLUMNS WHERE SCHEMA_NAME=CURRENT_SCHEMA AND TABLE_NAME=? AND COLUMN_NAME=?" )) {
|
||||
psSrid.setString( 1, tableName );
|
||||
psSrid.setString( 2, columnName );
|
||||
|
||||
try ( ResultSet rsSrid = psSrid.executeQuery() ) {
|
||||
try (ResultSet rsSrid = psSrid.executeQuery()) {
|
||||
if ( rsSrid.next() ) {
|
||||
int crsId = rsSrid.getInt( 1 );
|
||||
buffer = addCrsId( buffer.toByteArray(), orderByte, typeCode, crsId );
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Spatial Dialect for MySQL 5.6 with InnoDB engine.
|
||||
*
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 9/13/13
|
||||
* creation-date: 9/13/13
|
||||
* @deprecated Use "hibernate.dialect.storage_engine=innodb" environment variable or JVM system property instead.
|
||||
*/
|
||||
@Deprecated
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
/**
|
||||
* Extends the MySQL5Dialect by including support for the spatial operators.
|
||||
*
|
||||
* <p>
|
||||
* This <code>SpatialDialect</code> uses the ST_* spatial operators that operate on exact geometries which have been
|
||||
* added in MySQL version 5.6.1. Previous versions of MySQL only supported operators that operated on Minimum Bounding
|
||||
* Rectangles (MBR's). This dialect my therefore produce different results than the other MySQL spatial dialects.
|
||||
|
@ -13,13 +13,6 @@
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
|
||||
import org.geolatte.geom.ByteBuffer;
|
||||
import org.geolatte.geom.ByteOrder;
|
||||
import org.geolatte.geom.Geometry;
|
||||
import org.geolatte.geom.codec.Wkb;
|
||||
import org.geolatte.geom.codec.WkbDecoder;
|
||||
import org.geolatte.geom.codec.WkbEncoder;
|
||||
|
||||
import org.hibernate.type.descriptor.ValueBinder;
|
||||
import org.hibernate.type.descriptor.ValueExtractor;
|
||||
import org.hibernate.type.descriptor.WrapperOptions;
|
||||
@ -28,6 +21,13 @@
|
||||
import org.hibernate.type.descriptor.sql.BasicExtractor;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
|
||||
import org.geolatte.geom.ByteBuffer;
|
||||
import org.geolatte.geom.ByteOrder;
|
||||
import org.geolatte.geom.Geometry;
|
||||
import org.geolatte.geom.codec.Wkb;
|
||||
import org.geolatte.geom.codec.WkbDecoder;
|
||||
import org.geolatte.geom.codec.WkbEncoder;
|
||||
|
||||
/**
|
||||
* Descriptor for MySQL Geometries.
|
||||
*
|
||||
|
@ -14,56 +14,55 @@
|
||||
* An {@code Iterable} over the spatial functions supported by MySQL.
|
||||
*
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
*
|
||||
*/
|
||||
class MySQLSpatialFunctions extends SpatialFunctionsRegistry {
|
||||
|
||||
MySQLSpatialFunctions(){
|
||||
MySQLSpatialFunctions() {
|
||||
functionMap.put(
|
||||
"dimension", new StandardSQLFunction(
|
||||
"dimension",
|
||||
StandardBasicTypes.INTEGER
|
||||
)
|
||||
"dimension",
|
||||
StandardBasicTypes.INTEGER
|
||||
)
|
||||
);
|
||||
functionMap.put(
|
||||
"geometrytype", new StandardSQLFunction(
|
||||
"geometrytype", StandardBasicTypes.STRING
|
||||
)
|
||||
"geometrytype", StandardBasicTypes.STRING
|
||||
)
|
||||
);
|
||||
functionMap.put(
|
||||
"srid", new StandardSQLFunction(
|
||||
"srid",
|
||||
StandardBasicTypes.INTEGER
|
||||
)
|
||||
"srid",
|
||||
StandardBasicTypes.INTEGER
|
||||
)
|
||||
);
|
||||
functionMap.put(
|
||||
"envelope", new StandardSQLFunction(
|
||||
"envelope"
|
||||
)
|
||||
"envelope"
|
||||
)
|
||||
);
|
||||
functionMap.put(
|
||||
"astext", new StandardSQLFunction(
|
||||
"astext",
|
||||
StandardBasicTypes.STRING
|
||||
)
|
||||
"astext",
|
||||
StandardBasicTypes.STRING
|
||||
)
|
||||
);
|
||||
functionMap.put(
|
||||
"asbinary", new StandardSQLFunction(
|
||||
"asbinary",
|
||||
StandardBasicTypes.BINARY
|
||||
)
|
||||
"asbinary",
|
||||
StandardBasicTypes.BINARY
|
||||
)
|
||||
);
|
||||
functionMap.put(
|
||||
"isempty", new StandardSQLFunction(
|
||||
"isempty",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
"isempty",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
);
|
||||
functionMap.put(
|
||||
"issimple", new StandardSQLFunction(
|
||||
"issimple",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
"issimple",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
);
|
||||
// functionMap.put(
|
||||
// "boundary", new StandardSQLFunction(
|
||||
@ -74,51 +73,51 @@ class MySQLSpatialFunctions extends SpatialFunctionsRegistry {
|
||||
// Register functions for spatial relation constructs
|
||||
functionMap.put(
|
||||
"overlaps", new StandardSQLFunction(
|
||||
"overlaps",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
"overlaps",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
);
|
||||
functionMap.put(
|
||||
"intersects", new StandardSQLFunction(
|
||||
"intersects",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
"intersects",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
);
|
||||
functionMap.put(
|
||||
"equals", new StandardSQLFunction(
|
||||
"equals",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
"equals",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
);
|
||||
functionMap.put(
|
||||
"contains", new StandardSQLFunction(
|
||||
"contains",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
"contains",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
);
|
||||
functionMap.put(
|
||||
"crosses", new StandardSQLFunction(
|
||||
"crosses",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
"crosses",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
);
|
||||
functionMap.put(
|
||||
"disjoint", new StandardSQLFunction(
|
||||
"disjoint",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
"disjoint",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
);
|
||||
functionMap.put(
|
||||
"touches", new StandardSQLFunction(
|
||||
"touches",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
"touches",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
);
|
||||
functionMap.put(
|
||||
"within", new StandardSQLFunction(
|
||||
"within",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
"within",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
);
|
||||
// functionMap.put(
|
||||
// "relate", new StandardSQLFunction(
|
||||
|
@ -10,7 +10,7 @@
|
||||
<head></head>
|
||||
<body>
|
||||
<p>
|
||||
This package contains the spatial extensions for the MySQL dialect.
|
||||
This package contains the spatial extensions for the MySQL dialect.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -8,11 +8,6 @@
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.geolatte.geom.codec.db.oracle.ConnectionFinder;
|
||||
import org.geolatte.geom.codec.db.oracle.OracleJDBCTypeFactory;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import org.hibernate.boot.model.TypeContributions;
|
||||
import org.hibernate.boot.registry.selector.spi.StrategySelector;
|
||||
import org.hibernate.engine.config.spi.ConfigurationService;
|
||||
@ -26,6 +21,11 @@
|
||||
import org.hibernate.spatial.SpatialRelation;
|
||||
import org.hibernate.spatial.dialect.SpatialFunctionsRegistry;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import org.geolatte.geom.codec.db.oracle.ConnectionFinder;
|
||||
import org.geolatte.geom.codec.db.oracle.OracleJDBCTypeFactory;
|
||||
|
||||
/**
|
||||
* SDO Geometry support for Oracle dialects
|
||||
* <p>
|
||||
@ -93,7 +93,7 @@ private SDOGeometryTypeDescriptor mkSdoGeometryTypeDescriptor(ServiceRegistry se
|
||||
*/
|
||||
@Override
|
||||
public String getSpatialRelateSQL(String columnName, int spatialRelation) {
|
||||
String sql = getOGCSpatialRelateSQL( columnName, "?", spatialRelation ) + " = 1";
|
||||
String sql = getOGCSpatialRelateSQL( columnName, "?", spatialRelation ) + " = 1";
|
||||
sql += " and " + columnName + " is not null";
|
||||
return sql;
|
||||
}
|
||||
@ -154,7 +154,7 @@ public String getOGCSpatialRelateSQL(String arg1, String arg2, int spatialRelati
|
||||
* @return SQL fragment {@code SpatialRelateExpression}
|
||||
*/
|
||||
public String getSDOSpatialRelateSQL(String columnName, int spatialRelation) {
|
||||
String sql = getNativeSpatialRelateSQL( columnName, "?", spatialRelation ) + " = 1";
|
||||
String sql = getNativeSpatialRelateSQL( columnName, "?", spatialRelation ) + " = 1";
|
||||
sql += " and " + columnName + " is not null";
|
||||
return sql;
|
||||
}
|
||||
|
@ -11,24 +11,16 @@
|
||||
import java.sql.Types;
|
||||
import java.util.Map;
|
||||
|
||||
import org.geolatte.geom.codec.db.oracle.ConnectionFinder;
|
||||
import org.geolatte.geom.codec.db.oracle.OracleJDBCTypeFactory;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import org.hibernate.boot.model.TypeContributions;
|
||||
import org.hibernate.boot.registry.selector.spi.StrategySelector;
|
||||
import org.hibernate.dialect.Oracle10gDialect;
|
||||
import org.hibernate.dialect.function.SQLFunction;
|
||||
import org.hibernate.engine.config.spi.ConfigurationService;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.spatial.GeolatteGeometryType;
|
||||
import org.hibernate.spatial.HSMessageLogger;
|
||||
import org.hibernate.spatial.HibernateSpatialConfigurationSettings;
|
||||
import org.hibernate.spatial.JTSGeometryType;
|
||||
import org.hibernate.spatial.SpatialDialect;
|
||||
import org.hibernate.spatial.SpatialFunction;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
/**
|
||||
* Spatial Dialect for Oracle10g databases.
|
||||
*
|
||||
@ -106,7 +98,7 @@ public boolean supportsFiltering() {
|
||||
|
||||
@Override
|
||||
public boolean supports(SpatialFunction function) {
|
||||
return (getFunctions().get( function.toString() ) != null);
|
||||
return ( getFunctions().get( function.toString() ) != null );
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,13 +37,13 @@ class OracleSpatialFunctions extends SpatialFunctionsRegistry {
|
||||
);
|
||||
put(
|
||||
"isempty",
|
||||
new WrappedOGCFunction( "OGC_ISEMPTY", StandardBasicTypes.BOOLEAN, new boolean[] {true} )
|
||||
new WrappedOGCFunction( "OGC_ISEMPTY", StandardBasicTypes.BOOLEAN, new boolean[] { true } )
|
||||
);
|
||||
put(
|
||||
"issimple",
|
||||
new WrappedOGCFunction( "OGC_ISSIMPLE", StandardBasicTypes.BOOLEAN, new boolean[] {true} )
|
||||
new WrappedOGCFunction( "OGC_ISSIMPLE", StandardBasicTypes.BOOLEAN, new boolean[] { true } )
|
||||
);
|
||||
put( "boundary", new WrappedOGCFunction( "OGC_BOUNDARY", new boolean[] {true} ) );
|
||||
put( "boundary", new WrappedOGCFunction( "OGC_BOUNDARY", new boolean[] { true } ) );
|
||||
|
||||
// put("area", new AreaFunction());
|
||||
|
||||
@ -83,7 +83,7 @@ class OracleSpatialFunctions extends SpatialFunctionsRegistry {
|
||||
);
|
||||
put(
|
||||
"relate",
|
||||
new WrappedOGCFunction( "OGC_RELATE", StandardBasicTypes.BOOLEAN, new boolean[] {true, true, false} )
|
||||
new WrappedOGCFunction( "OGC_RELATE", StandardBasicTypes.BOOLEAN, new boolean[] { true, true, false } )
|
||||
);
|
||||
|
||||
// Register spatial analysis functions.
|
||||
@ -166,25 +166,6 @@ class OracleSpatialFunctions extends SpatialFunctionsRegistry {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of the OGC astext function for HQL.
|
||||
*/
|
||||
private static class AsTextFunction extends StandardSQLFunction {
|
||||
|
||||
private AsTextFunction() {
|
||||
super( "astext", StandardBasicTypes.STRING );
|
||||
}
|
||||
|
||||
public String render(Type firstArgumentType, final List args, final SessionFactoryImplementor factory) {
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
if ( args.isEmpty() ) {
|
||||
throw new IllegalArgumentException( "First Argument in arglist must be object " + "to which method is applied" );
|
||||
}
|
||||
buf.append( "TO_CHAR(SDO_UTIL.TO_WKTGEOMETRY(" ).append( args.get( 0 ) ).append( "))" );
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static String getOGCSpatialAnalysisSQL(List args, int spatialAnalysisFunction) {
|
||||
boolean[] geomArgs;
|
||||
final StringBuffer ogcFunction = new StringBuffer( "MDSYS." );
|
||||
@ -192,32 +173,32 @@ static String getOGCSpatialAnalysisSQL(List args, int spatialAnalysisFunction) {
|
||||
switch ( spatialAnalysisFunction ) {
|
||||
case SpatialAnalysis.BUFFER:
|
||||
ogcFunction.append( "OGC_BUFFER" );
|
||||
geomArgs = new boolean[] {true, false};
|
||||
geomArgs = new boolean[] { true, false };
|
||||
break;
|
||||
case SpatialAnalysis.CONVEXHULL:
|
||||
ogcFunction.append( "OGC_CONVEXHULL" );
|
||||
geomArgs = new boolean[] {true};
|
||||
geomArgs = new boolean[] { true };
|
||||
break;
|
||||
case SpatialAnalysis.DIFFERENCE:
|
||||
ogcFunction.append( "OGC_DIFFERENCE" );
|
||||
geomArgs = new boolean[] {true, true};
|
||||
geomArgs = new boolean[] { true, true };
|
||||
break;
|
||||
case SpatialAnalysis.DISTANCE:
|
||||
ogcFunction.append( "OGC_DISTANCE" );
|
||||
geomArgs = new boolean[] {true, true};
|
||||
geomArgs = new boolean[] { true, true };
|
||||
isGeomReturn = false;
|
||||
break;
|
||||
case SpatialAnalysis.INTERSECTION:
|
||||
ogcFunction.append( "OGC_INTERSECTION" );
|
||||
geomArgs = new boolean[] {true, true};
|
||||
geomArgs = new boolean[] { true, true };
|
||||
break;
|
||||
case SpatialAnalysis.SYMDIFFERENCE:
|
||||
ogcFunction.append( "OGC_SYMMETRICDIFFERENCE" );
|
||||
geomArgs = new boolean[] {true, true};
|
||||
geomArgs = new boolean[] { true, true };
|
||||
break;
|
||||
case SpatialAnalysis.UNION:
|
||||
ogcFunction.append( "OGC_UNION" );
|
||||
geomArgs = new boolean[] {true, true};
|
||||
geomArgs = new boolean[] { true, true };
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
@ -265,6 +246,24 @@ static String getSpatialAnalysisSQL(List args, int spatialAnalysisFunction) {
|
||||
return getOGCSpatialAnalysisSQL( args, spatialAnalysisFunction );
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of the OGC astext function for HQL.
|
||||
*/
|
||||
private static class AsTextFunction extends StandardSQLFunction {
|
||||
|
||||
private AsTextFunction() {
|
||||
super( "astext", StandardBasicTypes.STRING );
|
||||
}
|
||||
|
||||
public String render(Type firstArgumentType, final List args, final SessionFactoryImplementor factory) {
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
if ( args.isEmpty() ) {
|
||||
throw new IllegalArgumentException( "First Argument in arglist must be object " + "to which method is applied" );
|
||||
}
|
||||
buf.append( "TO_CHAR(SDO_UTIL.TO_WKTGEOMETRY(" ).append( args.get( 0 ) ).append( "))" );
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* HQL Spatial relation function.
|
||||
@ -279,7 +278,7 @@ private SpatialRelateFunction(
|
||||
final int relation,
|
||||
final boolean isOGCStrict,
|
||||
OracleSDOSupport sdo) {
|
||||
super( name, StandardBasicTypes.BOOLEAN );
|
||||
super( name, StandardBasicTypes.BOOLEAN );
|
||||
this.relation = relation;
|
||||
this.isOGCStrict = isOGCStrict;
|
||||
this.sdo = sdo;
|
||||
|
@ -10,8 +10,6 @@
|
||||
import java.sql.Types;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import org.hibernate.boot.model.TypeContributions;
|
||||
import org.hibernate.dialect.Oracle10gDialect;
|
||||
import org.hibernate.dialect.function.SQLFunction;
|
||||
@ -20,6 +18,8 @@
|
||||
import org.hibernate.spatial.SpatialDialect;
|
||||
import org.hibernate.spatial.SpatialFunction;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
/**
|
||||
* A Spatial Dialect for Oracle 10g/11g that uses the "native" SDO spatial operators.
|
||||
* <p>
|
||||
@ -97,7 +97,7 @@ public boolean supportsFiltering() {
|
||||
|
||||
@Override
|
||||
public boolean supports(SpatialFunction function) {
|
||||
return !function.equals( SpatialFunction.crosses ) && (getFunctions().get( function.toString() ) != null);
|
||||
return !function.equals( SpatialFunction.crosses ) && ( getFunctions().get( function.toString() ) != null );
|
||||
}
|
||||
|
||||
|
||||
|
@ -9,17 +9,17 @@
|
||||
|
||||
import java.sql.Types;
|
||||
|
||||
import org.geolatte.geom.codec.db.oracle.OracleJDBCTypeFactory;
|
||||
import org.hibernate.type.descriptor.ValueBinder;
|
||||
import org.hibernate.type.descriptor.ValueExtractor;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
|
||||
import org.geolatte.geom.codec.db.oracle.OracleJDBCTypeFactory;
|
||||
|
||||
/**
|
||||
* Descriptor for the Oracle Spatial SDO_GEOMETRY type
|
||||
*
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
*
|
||||
*/
|
||||
public class SDOGeometryTypeDescriptor implements SqlTypeDescriptor {
|
||||
|
||||
@ -56,6 +56,7 @@ public <X> ValueExtractor<X> getExtractor(final JavaTypeDescriptor<X> javaTypeDe
|
||||
|
||||
/**
|
||||
* Returns the Oracle type name for SDOGeometry.
|
||||
*
|
||||
* @return the Oracle type name
|
||||
*/
|
||||
public String getTypeName() {
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
/**
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 8/22/11
|
||||
* creation-date: 8/22/11
|
||||
*/
|
||||
class SDOGeometryValueBinder<J> implements ValueBinder<J> {
|
||||
|
||||
@ -84,7 +84,7 @@ private Object toNative(Geometry geom, Connection connection) {
|
||||
//we get here if the type of geometry is unsupported by geolatte encoders
|
||||
throw new HibernateException( e.getMessage() );
|
||||
}
|
||||
catch(Exception e) {
|
||||
catch (Exception e) {
|
||||
throw new HibernateException( e );
|
||||
}
|
||||
}
|
||||
|
@ -12,16 +12,15 @@
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Struct;
|
||||
|
||||
|
||||
import org.geolatte.geom.Geometry;
|
||||
import org.geolatte.geom.codec.db.oracle.Decoders;
|
||||
import org.geolatte.geom.codec.db.oracle.SDOGeometry;
|
||||
|
||||
import org.hibernate.type.descriptor.WrapperOptions;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.sql.BasicExtractor;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
|
||||
import org.geolatte.geom.Geometry;
|
||||
import org.geolatte.geom.codec.db.oracle.Decoders;
|
||||
import org.geolatte.geom.codec.db.oracle.SDOGeometry;
|
||||
|
||||
|
||||
//TODO -- requires cleanup and must be made package local
|
||||
|
||||
@ -29,7 +28,7 @@
|
||||
* ValueExtractor for SDO_GEOMETRY
|
||||
*
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 8/22/11
|
||||
* creation-date: 8/22/11
|
||||
*/
|
||||
public class SDOGeometryValueExtractor<X> extends BasicExtractor<X> {
|
||||
|
||||
|
@ -36,20 +36,20 @@ public Type getReturnType(Type columnType, Mapping mapping)
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.hibernate.dialect.function.SQLFunction#hasArguments()
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.hibernate.dialect.function.SQLFunction#hasArguments()
|
||||
*/
|
||||
|
||||
public boolean hasArguments() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.hibernate.dialect.function.SQLFunction#hasParenthesesIfNoArguments()
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.hibernate.dialect.function.SQLFunction#hasParenthesesIfNoArguments()
|
||||
*/
|
||||
|
||||
public boolean hasParenthesesIfNoArguments() {
|
||||
return true;
|
||||
@ -60,11 +60,11 @@ public String getName() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.hibernate.dialect.function.SQLFunction#render(java.util.List,
|
||||
* org.hibernate.engine.SessionFactoryImplementor)
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.hibernate.dialect.function.SQLFunction#render(java.util.List,
|
||||
* org.hibernate.engine.SessionFactoryImplementor)
|
||||
*/
|
||||
|
||||
public String render(Type firstArgumentType, List args, SessionFactoryImplementor factory) throws QueryException {
|
||||
final StringBuffer buf = new StringBuffer();
|
||||
|
@ -36,20 +36,20 @@ public Type getReturnType(Type columnType, Mapping mapping)
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.hibernate.dialect.function.SQLFunction#hasArguments()
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.hibernate.dialect.function.SQLFunction#hasArguments()
|
||||
*/
|
||||
|
||||
public boolean hasArguments() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.hibernate.dialect.function.SQLFunction#hasParenthesesIfNoArguments()
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.hibernate.dialect.function.SQLFunction#hasParenthesesIfNoArguments()
|
||||
*/
|
||||
|
||||
public boolean hasParenthesesIfNoArguments() {
|
||||
return false;
|
||||
@ -60,11 +60,11 @@ public String getName() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.hibernate.dialect.function.SQLFunction#render(java.util.List,
|
||||
* org.hibernate.engine.SessionFactoryImplementor)
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.hibernate.dialect.function.SQLFunction#render(java.util.List,
|
||||
* org.hibernate.engine.SessionFactoryImplementor)
|
||||
*/
|
||||
|
||||
public String render(Type firstArgtype, List args, SessionFactoryImplementor factory)
|
||||
throws QueryException {
|
||||
|
@ -15,11 +15,9 @@
|
||||
*/
|
||||
class SpatialAggregate {
|
||||
|
||||
private boolean aggregateType;
|
||||
|
||||
private String aggregateSyntax;
|
||||
|
||||
private static final String SDO_AGGR = "SDO_AGGR_";
|
||||
private boolean aggregateType;
|
||||
private String aggregateSyntax;
|
||||
|
||||
SpatialAggregate() {
|
||||
}
|
||||
|
@ -86,7 +86,12 @@ public static Criterion SDOFilter(String propertyName, Geometry geom, Double min
|
||||
* @return The Criterion
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public static Criterion SDONN(String propertyName, Geometry geom, Double distance, Integer numResults, String unit) {
|
||||
public static Criterion SDONN(
|
||||
String propertyName,
|
||||
Geometry geom,
|
||||
Double distance,
|
||||
Integer numResults,
|
||||
String unit) {
|
||||
if ( distance == null && numResults == null && unit == null ) {
|
||||
return SDONN( propertyName, geom, null );
|
||||
}
|
||||
@ -163,7 +168,12 @@ public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws
|
||||
* @return The Criterion
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public static Criterion SDORelate(String propertyName, Geometry geom, RelationshipMask[] mask, Double minResolution, Double maxResolution) {
|
||||
public static Criterion SDORelate(
|
||||
String propertyName,
|
||||
Geometry geom,
|
||||
RelationshipMask[] mask,
|
||||
Double minResolution,
|
||||
Double maxResolution) {
|
||||
final SDOParameterMap param = new SDOParameterMap();
|
||||
param.setMask( RelationshipMask.booleanCombination( mask ) );
|
||||
param.setMinResolution( minResolution );
|
||||
@ -208,7 +218,11 @@ public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws
|
||||
*
|
||||
* @return The Criterion
|
||||
*/
|
||||
public static Criterion SDOWithinDistance(String propertyName, Geometry geom, Double distance, SDOParameterMap param) {
|
||||
public static Criterion SDOWithinDistance(
|
||||
String propertyName,
|
||||
Geometry geom,
|
||||
Double distance,
|
||||
SDOParameterMap param) {
|
||||
if ( param == null ) {
|
||||
param = new SDOParameterMap();
|
||||
}
|
||||
@ -229,11 +243,11 @@ public OracleSpatialCriterion(String propertyName, Geometry value, SDOParameterM
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.hibernate.criterion.Criterion#getTypedValues(org.hibernate.Criteria,
|
||||
* org.hibernate.criterion.CriteriaQuery)
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.hibernate.criterion.Criterion#getTypedValues(org.hibernate.Criteria,
|
||||
* org.hibernate.criterion.CriteriaQuery)
|
||||
*/
|
||||
|
||||
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
|
||||
return new TypedValue[] {
|
||||
|
@ -64,6 +64,7 @@ public enum RelationshipMask {
|
||||
* Combines the passed "{@code RelationshipMask}s
|
||||
*
|
||||
* @param masks The array of masks to combine
|
||||
*
|
||||
* @return A {@code String} representing the combined relationship mask
|
||||
*/
|
||||
public static String booleanCombination(RelationshipMask[] masks) {
|
||||
|
@ -251,7 +251,7 @@ public void removeQueryType() {
|
||||
/**
|
||||
* Returns all parameters contained in this instance as a quoted String containing
|
||||
* the <parameter name>=<parameter value> pairs separated by spaces.
|
||||
*
|
||||
* <p>
|
||||
* The return format is as expected by the various SDO_GEOMETRY spatial functions.
|
||||
*
|
||||
* @return String
|
||||
|
@ -10,7 +10,7 @@
|
||||
<head></head>
|
||||
<body>
|
||||
<p>
|
||||
A criterion API for Oracle Spatial (10g and later) using SDOGeometry.
|
||||
A criterion API for Oracle Spatial (10g and later) using SDOGeometry.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -10,7 +10,7 @@
|
||||
<head></head>
|
||||
<body>
|
||||
<p>
|
||||
This package contains the spatial extensions for the Oracle 10g dialect. It currently supports only the SDO_GEOMETRY
|
||||
This package contains the spatial extensions for the Oracle 10g dialect. It currently supports only the SDO_GEOMETRY
|
||||
spatial data type.
|
||||
</p>
|
||||
</body>
|
||||
|
@ -10,7 +10,7 @@
|
||||
<head></head>
|
||||
<body>
|
||||
<p>
|
||||
This package contains the Spatial Dialects supported by Hibnerate Spatial
|
||||
This package contains the Spatial Dialects supported by Hibnerate Spatial
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -13,6 +13,14 @@
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
|
||||
import org.hibernate.type.descriptor.ValueBinder;
|
||||
import org.hibernate.type.descriptor.ValueExtractor;
|
||||
import org.hibernate.type.descriptor.WrapperOptions;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.sql.BasicBinder;
|
||||
import org.hibernate.type.descriptor.sql.BasicExtractor;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
|
||||
import org.geolatte.geom.ByteBuffer;
|
||||
import org.geolatte.geom.ByteOrder;
|
||||
import org.geolatte.geom.Geometry;
|
||||
@ -23,14 +31,6 @@
|
||||
import org.geolatte.geom.codec.WktDecoder;
|
||||
import org.postgresql.util.PGobject;
|
||||
|
||||
import org.hibernate.type.descriptor.ValueBinder;
|
||||
import org.hibernate.type.descriptor.ValueExtractor;
|
||||
import org.hibernate.type.descriptor.WrapperOptions;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.sql.BasicBinder;
|
||||
import org.hibernate.type.descriptor.sql.BasicExtractor;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
|
||||
/**
|
||||
* Type Descriptor for the Postgis Geometry type
|
||||
*
|
||||
@ -44,6 +44,34 @@ public class PGGeometryTypeDescriptor implements SqlTypeDescriptor {
|
||||
*/
|
||||
public static final PGGeometryTypeDescriptor INSTANCE = new PGGeometryTypeDescriptor();
|
||||
|
||||
public static Geometry<?> toGeometry(Object object) {
|
||||
if ( object == null ) {
|
||||
return null;
|
||||
}
|
||||
ByteBuffer buffer = null;
|
||||
if ( object instanceof PGobject ) {
|
||||
String pgValue = ( (PGobject) object ).getValue();
|
||||
|
||||
if ( pgValue.startsWith( "00" ) || pgValue.startsWith( "01" ) ) {
|
||||
//we have a WKB because this pgValue starts with the bit-order byte
|
||||
buffer = ByteBuffer.from( pgValue );
|
||||
final WkbDecoder decoder = Wkb.newDecoder( Wkb.Dialect.POSTGIS_EWKB_1 );
|
||||
return decoder.decode( buffer );
|
||||
|
||||
}
|
||||
else {
|
||||
return parseWkt( pgValue );
|
||||
}
|
||||
|
||||
}
|
||||
throw new IllegalStateException( "Received object of type " + object.getClass().getCanonicalName() );
|
||||
}
|
||||
|
||||
private static Geometry<?> parseWkt(String pgValue) {
|
||||
final WktDecoder decoder = Wkt.newDecoder( Wkt.Dialect.POSTGIS_EWKT_1 );
|
||||
return decoder.decode( pgValue );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSqlType() {
|
||||
return Types.OTHER;
|
||||
@ -105,32 +133,4 @@ protected X doExtract(CallableStatement statement, String name, WrapperOptions o
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Geometry<?> toGeometry(Object object) {
|
||||
if ( object == null ) {
|
||||
return null;
|
||||
}
|
||||
ByteBuffer buffer = null;
|
||||
if ( object instanceof PGobject ) {
|
||||
String pgValue = ((PGobject) object).getValue();
|
||||
|
||||
if ( pgValue.startsWith( "00" ) || pgValue.startsWith( "01" ) ) {
|
||||
//we have a WKB because this pgValue starts with the bit-order byte
|
||||
buffer = ByteBuffer.from( pgValue );
|
||||
final WkbDecoder decoder = Wkb.newDecoder( Wkb.Dialect.POSTGIS_EWKB_1 );
|
||||
return decoder.decode( buffer );
|
||||
|
||||
}
|
||||
else {
|
||||
return parseWkt( pgValue );
|
||||
}
|
||||
|
||||
}
|
||||
throw new IllegalStateException( "Received object of type " + object.getClass().getCanonicalName() );
|
||||
}
|
||||
|
||||
private static Geometry<?> parseWkt(String pgValue) {
|
||||
final WktDecoder decoder = Wkt.newDecoder( Wkt.Dialect.POSTGIS_EWKT_1 );
|
||||
return decoder.decode( pgValue );
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
|
||||
/**
|
||||
* Extends the {@code PostgreSQL82Dialect} to add support for the Postgis spatial types, functions and operators .
|
||||
* 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"
|
||||
|
@ -13,10 +13,10 @@
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
|
||||
/**
|
||||
* A Dialect for Postgresql with support for the Postgis spatial types, functions and operators (release 1.x - 1.3)
|
||||
* 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
|
||||
* creation-date: Dec 18, 2010
|
||||
*/
|
||||
public class PostgisNoSQLMM extends PostgisDialect {
|
||||
|
||||
@ -36,138 +36,138 @@ public PostgisNoSQLMM() {
|
||||
// it occurs in the spatial dialect
|
||||
registerFunction(
|
||||
"dimension", new StandardSQLFunction(
|
||||
"dimension",
|
||||
StandardBasicTypes.INTEGER
|
||||
)
|
||||
"dimension",
|
||||
StandardBasicTypes.INTEGER
|
||||
)
|
||||
);
|
||||
registerFunction(
|
||||
"geometrytype", new StandardSQLFunction(
|
||||
"geometrytype", StandardBasicTypes.STRING
|
||||
)
|
||||
"geometrytype", StandardBasicTypes.STRING
|
||||
)
|
||||
);
|
||||
registerFunction(
|
||||
"srid", new StandardSQLFunction(
|
||||
"srid",
|
||||
StandardBasicTypes.INTEGER
|
||||
)
|
||||
"srid",
|
||||
StandardBasicTypes.INTEGER
|
||||
)
|
||||
);
|
||||
registerFunction(
|
||||
"envelope", new StandardSQLFunction(
|
||||
"envelope"
|
||||
)
|
||||
"envelope"
|
||||
)
|
||||
);
|
||||
registerFunction(
|
||||
"astext", new StandardSQLFunction(
|
||||
"astext",
|
||||
StandardBasicTypes.STRING
|
||||
)
|
||||
"astext",
|
||||
StandardBasicTypes.STRING
|
||||
)
|
||||
);
|
||||
registerFunction(
|
||||
"asbinary", new StandardSQLFunction(
|
||||
"asbinary",
|
||||
StandardBasicTypes.BINARY
|
||||
)
|
||||
"asbinary",
|
||||
StandardBasicTypes.BINARY
|
||||
)
|
||||
);
|
||||
registerFunction(
|
||||
"isempty", new StandardSQLFunction(
|
||||
"isempty",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
"isempty",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
);
|
||||
registerFunction(
|
||||
"issimple", new StandardSQLFunction(
|
||||
"issimple",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
"issimple",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
);
|
||||
registerFunction(
|
||||
"boundary", new StandardSQLFunction(
|
||||
"boundary"
|
||||
)
|
||||
"boundary"
|
||||
)
|
||||
);
|
||||
|
||||
// Register functions for spatial relation constructs
|
||||
registerFunction(
|
||||
"overlaps", new StandardSQLFunction(
|
||||
"overlaps",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
"overlaps",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
);
|
||||
registerFunction(
|
||||
"intersects", new StandardSQLFunction(
|
||||
"intersects",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
"intersects",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
);
|
||||
registerFunction(
|
||||
"equals", new StandardSQLFunction(
|
||||
"equals",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
"equals",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
);
|
||||
registerFunction(
|
||||
"contains", new StandardSQLFunction(
|
||||
"contains",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
"contains",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
);
|
||||
registerFunction(
|
||||
"crosses", new StandardSQLFunction(
|
||||
"crosses",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
"crosses",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
);
|
||||
registerFunction(
|
||||
"disjoint", new StandardSQLFunction(
|
||||
"disjoint",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
"disjoint",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
);
|
||||
registerFunction(
|
||||
"touches", new StandardSQLFunction(
|
||||
"touches",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
"touches",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
);
|
||||
registerFunction(
|
||||
"within", new StandardSQLFunction(
|
||||
"within",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
"within",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
);
|
||||
registerFunction(
|
||||
"relate", new StandardSQLFunction(
|
||||
"relate",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
"relate",
|
||||
StandardBasicTypes.BOOLEAN
|
||||
)
|
||||
);
|
||||
|
||||
// register the spatial analysis functions
|
||||
registerFunction(
|
||||
"distance", new StandardSQLFunction(
|
||||
"distance",
|
||||
StandardBasicTypes.DOUBLE
|
||||
)
|
||||
"distance",
|
||||
StandardBasicTypes.DOUBLE
|
||||
)
|
||||
);
|
||||
registerFunction(
|
||||
"buffer", new StandardSQLFunction(
|
||||
"buffer"
|
||||
)
|
||||
"buffer"
|
||||
)
|
||||
);
|
||||
registerFunction(
|
||||
"convexhull", new StandardSQLFunction(
|
||||
"convexhull"
|
||||
)
|
||||
"convexhull"
|
||||
)
|
||||
);
|
||||
registerFunction(
|
||||
"difference", new StandardSQLFunction(
|
||||
"difference"
|
||||
)
|
||||
"difference"
|
||||
)
|
||||
);
|
||||
registerFunction(
|
||||
"intersection", new StandardSQLFunction(
|
||||
"intersection"
|
||||
)
|
||||
"intersection"
|
||||
)
|
||||
);
|
||||
registerFunction(
|
||||
"symdifference",
|
||||
@ -175,22 +175,22 @@ public PostgisNoSQLMM() {
|
||||
);
|
||||
registerFunction(
|
||||
"geomunion", new StandardSQLFunction(
|
||||
"geomunion"
|
||||
)
|
||||
"geomunion"
|
||||
)
|
||||
);
|
||||
|
||||
//register Spatial Aggregate function
|
||||
registerFunction(
|
||||
"extent", new StandardSQLFunction(
|
||||
"extent"
|
||||
)
|
||||
"extent"
|
||||
)
|
||||
);
|
||||
|
||||
//other common spatial functions
|
||||
registerFunction(
|
||||
"transform", new StandardSQLFunction(
|
||||
"transform"
|
||||
)
|
||||
"transform"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ public boolean supportsFiltering() {
|
||||
* @return True if this <code>SpatialDialect</code> supports the spatial function specified by the function parameter.
|
||||
*/
|
||||
@Override
|
||||
public boolean supports( SpatialFunction function) {
|
||||
return (postgisFunctions.get( function.toString() ) != null);
|
||||
public boolean supports(SpatialFunction function) {
|
||||
return ( postgisFunctions.get( function.toString() ) != null );
|
||||
}
|
||||
}
|
||||
|
@ -10,13 +10,16 @@
|
||||
<head></head>
|
||||
<body>
|
||||
<p>
|
||||
This package contains the spatial extensions for the Postgresql dialect.
|
||||
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>
|
||||
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>
|
||||
|
@ -14,11 +14,6 @@
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
|
||||
import org.geolatte.geom.Geometry;
|
||||
|
||||
import org.geolatte.geom.codec.db.sqlserver.Decoders;
|
||||
import org.geolatte.geom.codec.db.sqlserver.Encoders;
|
||||
|
||||
import org.hibernate.type.descriptor.ValueBinder;
|
||||
import org.hibernate.type.descriptor.ValueExtractor;
|
||||
import org.hibernate.type.descriptor.WrapperOptions;
|
||||
@ -27,11 +22,15 @@
|
||||
import org.hibernate.type.descriptor.sql.BasicExtractor;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
|
||||
import org.geolatte.geom.Geometry;
|
||||
import org.geolatte.geom.codec.db.sqlserver.Decoders;
|
||||
import org.geolatte.geom.codec.db.sqlserver.Encoders;
|
||||
|
||||
/**
|
||||
* Type descriptor for the SQL Server 2008 Geometry type.
|
||||
*
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 8/23/11
|
||||
* creation-date: 8/23/11
|
||||
*/
|
||||
public class SqlServer2008GeometryTypeDescriptor implements SqlTypeDescriptor {
|
||||
|
||||
@ -99,7 +98,7 @@ private Geometry toGeometry(Object obj) {
|
||||
if ( obj == null ) {
|
||||
return null;
|
||||
}
|
||||
if ( (obj instanceof byte[]) ) {
|
||||
if ( ( obj instanceof byte[] ) ) {
|
||||
raw = (byte[]) obj;
|
||||
}
|
||||
else if ( obj instanceof Blob ) {
|
||||
|
@ -11,7 +11,6 @@
|
||||
import org.hibernate.boot.model.TypeContributions;
|
||||
import org.hibernate.dialect.SQLServer2008Dialect;
|
||||
import org.hibernate.dialect.function.SQLFunctionTemplate;
|
||||
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.spatial.GeolatteGeometryType;
|
||||
import org.hibernate.spatial.JTSGeometryType;
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
/**
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 4/8/13
|
||||
* creation-date: 4/8/13
|
||||
*/
|
||||
class SqlServerMethod extends StandardSQLFunction {
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
<head></head>
|
||||
<body>
|
||||
<p>
|
||||
This package contains the spatial extensions for the SqlServer2008 dialect.
|
||||
This package contains the spatial extensions for the SqlServer2008 dialect.
|
||||
</p>
|
||||
<p>Currently, only the Geometry type is supported.</p>
|
||||
</body>
|
||||
|
@ -11,7 +11,6 @@
|
||||
import org.hibernate.service.Service;
|
||||
import org.hibernate.spatial.HSMessageLogger;
|
||||
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
/**
|
||||
|
@ -10,7 +10,7 @@
|
||||
<head></head>
|
||||
<body>
|
||||
<p>
|
||||
This package contains the integration classes to hook into Hibernate-ORM.
|
||||
This package contains the integration classes to hook into Hibernate-ORM.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -24,8 +24,10 @@ private EnvelopeAdapter() {
|
||||
|
||||
/**
|
||||
* Converts the specified {@code Envelope} to a {@code Polygon} having the specified srid.
|
||||
*
|
||||
* @param env The envelope to convert
|
||||
* @param srid The srid for the polygon
|
||||
*
|
||||
* @return The Polygon
|
||||
*/
|
||||
public static Polygon toPolygon(Envelope env, int srid) {
|
||||
|
@ -10,7 +10,7 @@
|
||||
<head></head>
|
||||
<body>
|
||||
<p>
|
||||
This package contains utility classes for use with JTS.
|
||||
This package contains utility classes for use with JTS.
|
||||
</p>
|
||||
</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 APIs.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -7,17 +7,17 @@
|
||||
|
||||
package org.hibernate.spatial.dialect.postgis;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.spatial.SpatialDialect;
|
||||
import org.hibernate.spatial.SpatialFunction;
|
||||
|
||||
import org.junit.Test;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Tests support for
|
||||
*
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 1/19/11
|
||||
* creation-date: 1/19/11
|
||||
*/
|
||||
public class PostgisDialectTest extends TestCase {
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.geolatte.geom.ByteOrder;
|
||||
import org.geolatte.geom.C2D;
|
||||
import org.geolatte.geom.G2D;
|
||||
@ -18,9 +20,9 @@
|
||||
import org.geolatte.geom.crs.CoordinateReferenceSystems;
|
||||
import org.postgresql.util.PGobject;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.geolatte.geom.builder.DSL.*;
|
||||
import static org.geolatte.geom.builder.DSL.c;
|
||||
import static org.geolatte.geom.builder.DSL.g;
|
||||
import static org.geolatte.geom.builder.DSL.linestring;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
|
@ -4,12 +4,6 @@
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
//import org.geolatte.geom.C3DM;
|
||||
//import org.geolatte.geom.Geometry;
|
||||
//import org.geolatte.geom.GeometryEquality;
|
||||
//import org.geolatte.geom.GeometryPointEquality;
|
||||
import org.geolatte.geom.codec.WktDecodeException;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
@ -21,10 +15,17 @@
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.geolatte.geom.codec.WktDecodeException;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
//import org.geolatte.geom.C3DM;
|
||||
//import org.geolatte.geom.Geometry;
|
||||
//import org.geolatte.geom.GeometryEquality;
|
||||
//import org.geolatte.geom.GeometryPointEquality;
|
||||
|
||||
/**
|
||||
* Created by Karel Maesen, Geovise BVBA on 15/02/2018.
|
||||
*/
|
||||
@ -73,7 +74,7 @@ private void retrieveAndCompare(Map<Integer, E> stored) {
|
||||
}
|
||||
tx.commit();
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
catch (Exception e) {
|
||||
if ( tx != null ) {
|
||||
tx.rollback();
|
||||
}
|
||||
@ -116,7 +117,7 @@ private void storeTestObjects(Map<Integer, E> stored) {
|
||||
tx.commit();
|
||||
}
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
catch (Exception e) {
|
||||
if ( tx != null ) {
|
||||
tx.rollback();
|
||||
}
|
||||
@ -142,7 +143,7 @@ private void storeNullGeometry() {
|
||||
session.save( entity );
|
||||
tx.commit();
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
catch (Exception e) {
|
||||
if ( tx != null ) {
|
||||
tx.rollback();
|
||||
}
|
||||
@ -169,7 +170,7 @@ private void retrieveNullGeometry() {
|
||||
assertNull( entity.getGeom() );
|
||||
tx.commit();
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
catch (Exception e) {
|
||||
if ( tx != null ) {
|
||||
tx.rollback();
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
package org.hibernate.spatial.integration;
|
||||
|
||||
import org.geolatte.geom.codec.Wkt;
|
||||
import org.geolatte.geom.codec.WktDecoder;
|
||||
|
||||
import org.hibernate.dialect.AbstractHANADialect;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.spatial.dialect.db2.DB2SpatialDialect;
|
||||
|
||||
import org.geolatte.geom.codec.Wkt;
|
||||
import org.geolatte.geom.codec.WktDecoder;
|
||||
|
||||
/**
|
||||
* Created by Karel Maesen, Geovise BVBA on 15/02/2018.
|
||||
*/
|
||||
@ -20,7 +20,7 @@ public static WktDecoder getWktDecoder(Dialect dialect) {
|
||||
else if ( dialect instanceof DB2SpatialDialect ) {
|
||||
decoder = Wkt.newDecoder( Wkt.Dialect.DB2_WKT );
|
||||
}
|
||||
else{
|
||||
else {
|
||||
decoder = Wkt.newDecoder( Wkt.Dialect.POSTGIS_EWKT_1 );
|
||||
}
|
||||
return decoder;
|
||||
|
@ -1,13 +1,5 @@
|
||||
package org.hibernate.spatial.integration;
|
||||
|
||||
import org.geolatte.geom.codec.WktDecodeException;
|
||||
import org.geolatte.geom.codec.WktDecoder;
|
||||
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.spatial.testing.TestDataElement;
|
||||
|
||||
import static org.hibernate.spatial.integration.DecodeUtil.getWktDecoder;
|
||||
|
||||
/**
|
||||
* Created by Karel Maesen, Geovise BVBA on 15/02/2018.
|
||||
*/
|
||||
|
@ -11,10 +11,6 @@
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
@ -26,10 +22,13 @@
|
||||
import org.hibernate.spatial.testing.SpatialDialectMatcher;
|
||||
import org.hibernate.spatial.testing.SpatialFunctionalTestCase;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.testing.Skip;
|
||||
import org.hibernate.testing.SkipForDialect;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
import static java.lang.String.format;
|
||||
|
||||
@ -240,7 +239,9 @@ public void within(String pckg) throws SQLException {
|
||||
Map<Integer, Boolean> dbexpected = expectationsFactory.getWithin( expectationsFactory.getTestPolygon() );
|
||||
String hql = format(
|
||||
"SELECT id, within(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " +
|
||||
"where within(geom, :filter) = true and srid(geom) = %d", pckg, expectationsFactory.getTestSrid()
|
||||
"where within(geom, :filter) = true and srid(geom) = %d",
|
||||
pckg,
|
||||
expectationsFactory.getTestSrid()
|
||||
);
|
||||
Map<String, Object> params = createQueryParams( "filter", expectationsFactory.getTestPolygon() );
|
||||
retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg );
|
||||
@ -263,7 +264,9 @@ public void equals(String pckg) throws SQLException {
|
||||
Map<Integer, Boolean> dbexpected = expectationsFactory.getEquals( expectationsFactory.getTestPolygon() );
|
||||
String hql = format(
|
||||
"SELECT id, equals(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " +
|
||||
"where equals(geom, :filter) = true and srid(geom) = %d", pckg, expectationsFactory.getTestSrid()
|
||||
"where equals(geom, :filter) = true and srid(geom) = %d",
|
||||
pckg,
|
||||
expectationsFactory.getTestSrid()
|
||||
);
|
||||
Map<String, Object> params = createQueryParams( "filter", expectationsFactory.getTestPolygon() );
|
||||
retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg );
|
||||
@ -286,7 +289,9 @@ public void crosses(String pckg) throws SQLException {
|
||||
Map<Integer, Boolean> dbexpected = expectationsFactory.getCrosses( expectationsFactory.getTestPolygon() );
|
||||
String hql = format(
|
||||
"SELECT id, crosses(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " +
|
||||
"where crosses(geom, :filter) = true and srid(geom) = %d", pckg, expectationsFactory.getTestSrid()
|
||||
"where crosses(geom, :filter) = true and srid(geom) = %d",
|
||||
pckg,
|
||||
expectationsFactory.getTestSrid()
|
||||
);
|
||||
Map<String, Object> params = createQueryParams( "filter", expectationsFactory.getTestPolygon() );
|
||||
retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg );
|
||||
@ -310,7 +315,9 @@ public void contains(String pckg) throws SQLException {
|
||||
Map<Integer, Boolean> dbexpected = expectationsFactory.getContains( expectationsFactory.getTestPolygon() );
|
||||
String hql = format(
|
||||
"SELECT id, contains(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " +
|
||||
"where contains(geom, :filter) = true and srid(geom) = %d", pckg, expectationsFactory.getTestSrid()
|
||||
"where contains(geom, :filter) = true and srid(geom) = %d",
|
||||
pckg,
|
||||
expectationsFactory.getTestSrid()
|
||||
);
|
||||
Map<String, Object> params = createQueryParams( "filter", expectationsFactory.getTestPolygon() );
|
||||
retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg );
|
||||
@ -333,7 +340,9 @@ public void disjoint(String pckg) throws SQLException {
|
||||
Map<Integer, Boolean> dbexpected = expectationsFactory.getDisjoint( expectationsFactory.getTestPolygon() );
|
||||
String hql = format(
|
||||
"SELECT id, disjoint(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " +
|
||||
"where disjoint(geom, :filter) = true and srid(geom) = %d", pckg, expectationsFactory.getTestSrid()
|
||||
"where disjoint(geom, :filter) = true and srid(geom) = %d",
|
||||
pckg,
|
||||
expectationsFactory.getTestSrid()
|
||||
);
|
||||
Map<String, Object> params = createQueryParams( "filter", expectationsFactory.getTestPolygon() );
|
||||
retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg );
|
||||
@ -356,7 +365,9 @@ public void intersects(String pckg) throws SQLException {
|
||||
Map<Integer, Boolean> dbexpected = expectationsFactory.getIntersects( expectationsFactory.getTestPolygon() );
|
||||
String hql = format(
|
||||
"SELECT id, intersects(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " +
|
||||
"where intersects(geom, :filter) = true and srid(geom) = %d", pckg, expectationsFactory.getTestSrid()
|
||||
"where intersects(geom, :filter) = true and srid(geom) = %d",
|
||||
pckg,
|
||||
expectationsFactory.getTestSrid()
|
||||
);
|
||||
Map<String, Object> params = createQueryParams( "filter", expectationsFactory.getTestPolygon() );
|
||||
retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg );
|
||||
@ -379,7 +390,9 @@ public void overlaps(String pckg) throws SQLException {
|
||||
Map<Integer, Boolean> dbexpected = expectationsFactory.getOverlaps( expectationsFactory.getTestPolygon() );
|
||||
String hql = format(
|
||||
"SELECT id, overlaps(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " +
|
||||
"where overlaps(geom, :filter) = true and srid(geom) = %d", pckg, expectationsFactory.getTestSrid()
|
||||
"where overlaps(geom, :filter) = true and srid(geom) = %d",
|
||||
pckg,
|
||||
expectationsFactory.getTestSrid()
|
||||
);
|
||||
Map<String, Object> params = createQueryParams( "filter", expectationsFactory.getTestPolygon() );
|
||||
retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg );
|
||||
@ -401,7 +414,9 @@ public void touches(String pckg) throws SQLException {
|
||||
}
|
||||
String hql = format(
|
||||
"SELECT id, touches(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " +
|
||||
"where touches(geom, :filter) = true and srid(geom) = %d", pckg, expectationsFactory.getTestSrid()
|
||||
"where touches(geom, :filter) = true and srid(geom) = %d",
|
||||
pckg,
|
||||
expectationsFactory.getTestSrid()
|
||||
);
|
||||
Map<Integer, Boolean> dbexpected = expectationsFactory.getTouches( expectationsFactory.getTestPolygon() );
|
||||
Map<String, Object> params = createQueryParams( "filter", expectationsFactory.getTestPolygon() );
|
||||
@ -429,7 +444,9 @@ public void relate(String pckg) throws SQLException {
|
||||
);
|
||||
String hql = format(
|
||||
"SELECT id, relate(geom, :filter, :matrix) from org.hibernate.spatial.integration.%s.GeomEntity " +
|
||||
"where relate(geom, :filter, :matrix) = true and srid(geom) = %d", pckg, expectationsFactory.getTestSrid()
|
||||
"where relate(geom, :filter, :matrix) = true and srid(geom) = %d",
|
||||
pckg,
|
||||
expectationsFactory.getTestSrid()
|
||||
);
|
||||
Map<String, Object> params = createQueryParams( "filter", expectationsFactory.getTestPolygon() );
|
||||
params.put( "matrix", matrix );
|
||||
@ -586,7 +603,9 @@ public void symdifference(String pckg) throws SQLException {
|
||||
Map<Integer, Geometry> dbexpected = expectationsFactory.getSymDifference( expectationsFactory.getTestPolygon() );
|
||||
String hql = format(
|
||||
"SELECT id, symdifference(geom, :polygon) from " +
|
||||
"org.hibernate.spatial.integration.%s.GeomEntity where srid(geom) = %d", pckg, expectationsFactory.getTestSrid()
|
||||
"org.hibernate.spatial.integration.%s.GeomEntity where srid(geom) = %d",
|
||||
pckg,
|
||||
expectationsFactory.getTestSrid()
|
||||
);
|
||||
Map<String, Object> params = createQueryParams( "polygon", expectationsFactory.getTestPolygon() );
|
||||
retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg );
|
||||
@ -643,7 +662,8 @@ public void dwithin(String pckg) throws SQLException {
|
||||
if ( getDialect() instanceof OracleSpatial10gDialect ) {
|
||||
//because this uses the weird syntax and conventions of SDO_WITHIN_DISTANCE which returns a string (really)
|
||||
// we use a different boolean expression guaranteed to be true, and we set the third parameter to key/value string
|
||||
hql = "SELECT id, issimple(geom) from org.hibernate.spatial.integration.GeomEntity where dwithin(geom, :filter, :distance) = true and srid(geom) = " + expectationsFactory.getTestSrid();
|
||||
hql = "SELECT id, issimple(geom) from org.hibernate.spatial.integration.GeomEntity where dwithin(geom, :filter, :distance) = true and srid(geom) = " + expectationsFactory
|
||||
.getTestSrid();
|
||||
params.put( "distance", "distance = 30" );
|
||||
}
|
||||
else {
|
||||
@ -651,7 +671,7 @@ public void dwithin(String pckg) throws SQLException {
|
||||
}
|
||||
retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg );
|
||||
}
|
||||
|
||||
|
||||
// The transform tests are skipped for HANA because there is no transform definition for SRID 0
|
||||
|
||||
@Test
|
||||
|
@ -11,8 +11,6 @@
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
@ -24,9 +22,10 @@
|
||||
import org.hibernate.spatial.testing.SpatialDialectMatcher;
|
||||
import org.hibernate.spatial.testing.SpatialFunctionalTestCase;
|
||||
|
||||
import org.hibernate.testing.Skip;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.testing.Skip;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
@ -23,15 +23,19 @@
|
||||
|
||||
/**
|
||||
* Test class used in unit testing.
|
||||
*
|
||||
* <p>
|
||||
* Not that this is Entity class uses raw Geometries, because in test classes a wide variety of SRIDs and
|
||||
* coordinate spaces are mixed. (This creates notable problems for Oracle, which is very, very strict in what it accepts)
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "geomtest")
|
||||
public class GeomEntity implements GeomEntityLike<Geometry> {
|
||||
|
||||
@Id
|
||||
private Integer id;
|
||||
private String type;
|
||||
private Geometry geom;
|
||||
|
||||
static GeomEntity createFrom(TestDataElement element, Dialect dialect) throws WktDecodeException {
|
||||
WktDecoder decoder = getWktDecoder( dialect );
|
||||
Geometry geom = decoder.decode( element.wkt );
|
||||
@ -42,14 +46,6 @@ static GeomEntity createFrom(TestDataElement element, Dialect dialect) throws Wk
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Id
|
||||
private Integer id;
|
||||
|
||||
private String type;
|
||||
|
||||
private Geometry geom;
|
||||
|
||||
@Override
|
||||
public Integer getId() {
|
||||
return id;
|
||||
@ -92,7 +88,7 @@ public boolean equals(Object o) {
|
||||
|
||||
GeomEntity geomEntity = (GeomEntity) o;
|
||||
|
||||
if ( ! id.equals(geomEntity.id) ) {
|
||||
if ( !id.equals( geomEntity.id ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -6,9 +6,15 @@
|
||||
*/
|
||||
package org.hibernate.spatial.integration.geolatte;
|
||||
|
||||
import java.util.List;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.spatial.dialect.postgis.PostgisPG95Dialect;
|
||||
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.geolatte.geom.C2D;
|
||||
import org.geolatte.geom.Point;
|
||||
@ -16,13 +22,6 @@
|
||||
import org.geolatte.geom.crs.CoordinateReferenceSystem;
|
||||
import org.geolatte.geom.crs.CoordinateReferenceSystems;
|
||||
|
||||
import org.hibernate.spatial.dialect.postgis.PostgisPG95Dialect;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
|
||||
import static org.geolatte.geom.builder.DSL.c;
|
||||
import static org.geolatte.geom.builder.DSL.point;
|
||||
import static org.geolatte.geom.builder.DSL.polygon;
|
||||
|
@ -6,15 +6,9 @@
|
||||
*/
|
||||
package org.hibernate.spatial.integration.geolatte;
|
||||
|
||||
import org.geolatte.geom.Geometry;
|
||||
import org.geolatte.geom.codec.WktDecodeException;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.spatial.HSMessageLogger;
|
||||
import org.hibernate.spatial.integration.AbstractTestStoreRetrieve;
|
||||
import org.hibernate.spatial.integration.GeomEntityLike;
|
||||
import org.hibernate.spatial.testing.GeolatteGeometryEquality;
|
||||
import org.hibernate.spatial.testing.GeometryEquality;
|
||||
import org.hibernate.spatial.testing.SpatialDialectMatcher;
|
||||
@ -22,9 +16,10 @@
|
||||
|
||||
import org.hibernate.testing.Skip;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import org.geolatte.geom.Geometry;
|
||||
import org.geolatte.geom.codec.WktDecodeException;
|
||||
|
||||
/**
|
||||
* This testsuite-suite class verifies whether the <code>Geometry</code>s retrieved
|
||||
|
@ -11,16 +11,15 @@
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.io.ParseException;
|
||||
import org.geolatte.geom.codec.Wkt;
|
||||
import org.geolatte.geom.codec.WktDecoder;
|
||||
import org.geolatte.geom.jts.JTS;
|
||||
import org.hibernate.dialect.AbstractHANADialect;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.spatial.integration.GeomEntityLike;
|
||||
import org.hibernate.spatial.testing.TestDataElement;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.io.ParseException;
|
||||
import org.geolatte.geom.codec.WktDecoder;
|
||||
import org.geolatte.geom.jts.JTS;
|
||||
|
||||
import static org.hibernate.spatial.integration.DecodeUtil.getWktDecoder;
|
||||
|
||||
/**
|
||||
@ -38,6 +37,16 @@ public class GeomEntity implements GeomEntityLike<Geometry> {
|
||||
|
||||
private Geometry geom;
|
||||
|
||||
public static GeomEntity createFrom(TestDataElement element, Dialect dialect) throws ParseException {
|
||||
WktDecoder decoder = getWktDecoder( dialect );
|
||||
Geometry geom = JTS.to( decoder.decode( element.wkt ) );
|
||||
GeomEntity result = new GeomEntity();
|
||||
result.setId( element.id );
|
||||
result.setGeom( geom );
|
||||
result.setType( element.type );
|
||||
return result;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
@ -62,16 +71,6 @@ public void setGeom(Geometry geom) {
|
||||
this.geom = geom;
|
||||
}
|
||||
|
||||
public static GeomEntity createFrom(TestDataElement element, Dialect dialect) throws ParseException {
|
||||
WktDecoder decoder = getWktDecoder( dialect );
|
||||
Geometry geom = JTS.to( decoder.decode( element.wkt ) );
|
||||
GeomEntity result = new GeomEntity();
|
||||
result.setId( element.id );
|
||||
result.setGeom( geom );
|
||||
result.setType( element.type );
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ( this == o ) {
|
||||
|
@ -6,11 +6,6 @@
|
||||
*/
|
||||
package org.hibernate.spatial.integration.jts;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.io.ParseException;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.spatial.HSMessageLogger;
|
||||
import org.hibernate.spatial.integration.AbstractTestStoreRetrieve;
|
||||
@ -21,6 +16,11 @@
|
||||
|
||||
import org.hibernate.testing.Skip;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.io.ParseException;
|
||||
|
||||
/**
|
||||
* This testsuite-suite class verifies whether the <code>Geometry</code>s retrieved
|
||||
* are equal to the <code>Geometry</code>s stored.
|
||||
|
@ -15,16 +15,16 @@
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.spatial.HSMessageLogger;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.geom.Point;
|
||||
import com.vividsolutions.jts.geom.Polygon;
|
||||
import com.vividsolutions.jts.io.ParseException;
|
||||
import com.vividsolutions.jts.io.WKTReader;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import org.hibernate.spatial.HSMessageLogger;
|
||||
|
||||
/**
|
||||
* An <code>AbstractExpectationsFactory</code> provides the expected
|
||||
* values to be used in the integration tests of the spatial functions
|
||||
@ -36,25 +36,21 @@
|
||||
*/
|
||||
public abstract class AbstractExpectationsFactory {
|
||||
|
||||
private static final HSMessageLogger LOG = Logger.getMessageLogger(
|
||||
HSMessageLogger.class,
|
||||
AbstractExpectationsFactory.class.getName()
|
||||
);
|
||||
|
||||
public final static String TEST_POLYGON_WKT = "POLYGON((0 0, 50 0, 100 100, 0 100, 0 0))";
|
||||
public final static String TEST_POINT_WKT = "POINT(0 0)";
|
||||
|
||||
public final static int INTEGER = 1;
|
||||
public final static int DOUBLE = 2;
|
||||
public final static int GEOMETRY = 3;
|
||||
public final static int STRING = 4;
|
||||
public final static int BOOLEAN = 5;
|
||||
public final static int OBJECT = -1;
|
||||
|
||||
private static final HSMessageLogger LOG = Logger.getMessageLogger(
|
||||
HSMessageLogger.class,
|
||||
AbstractExpectationsFactory.class.getName()
|
||||
);
|
||||
private final static int TEST_SRID = 4326;
|
||||
|
||||
private final DataSourceUtils dataSourceUtils;
|
||||
private static final int MAX_BYTE_LEN = 1024;
|
||||
private final DataSourceUtils dataSourceUtils;
|
||||
|
||||
public AbstractExpectationsFactory(DataSourceUtils dataSourceUtils) {
|
||||
this.dataSourceUtils = dataSourceUtils;
|
||||
@ -815,7 +811,7 @@ protected <T> Map<Integer, T> retrieveExpected(NativeSQLStatement nativeSQLState
|
||||
//this code is a hack to deal with Oracle Spatial that returns Blob's for asWKB() function
|
||||
//TODO -- clean up
|
||||
if ( val instanceof Blob ) {
|
||||
val = (T) ((Blob) val).getBytes( 1, MAX_BYTE_LEN );
|
||||
val = (T) ( (Blob) val ).getBytes( 1, MAX_BYTE_LEN );
|
||||
}
|
||||
expected.put( id, val );
|
||||
}
|
||||
@ -852,6 +848,7 @@ protected NativeSQLStatement createNativeSQLStatement(final String sql) {
|
||||
public PreparedStatement prepare(Connection connection) throws SQLException {
|
||||
return connection.prepareStatement( sql );
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return sql;
|
||||
}
|
||||
@ -867,8 +864,9 @@ public PreparedStatement prepare(Connection connection) throws SQLException {
|
||||
}
|
||||
return pstmt;
|
||||
}
|
||||
public String toString(){
|
||||
return String.format("sql; %s, wkt: %s", sql, wkt);
|
||||
|
||||
public String toString() {
|
||||
return String.format( "sql; %s, wkt: %s", sql, wkt );
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -883,7 +881,8 @@ public PreparedStatement prepare(Connection connection) throws SQLException {
|
||||
}
|
||||
return pstmt;
|
||||
}
|
||||
public String toString(){
|
||||
|
||||
public String toString() {
|
||||
return sql;
|
||||
}
|
||||
};
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
package org.hibernate.spatial.testing;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
@ -23,6 +22,11 @@
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.hibernate.spatial.HSMessageLogger;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import org.apache.commons.dbcp.BasicDataSource;
|
||||
import org.geolatte.geom.Geometry;
|
||||
@ -30,10 +34,6 @@
|
||||
import org.geolatte.geom.codec.WktDecodeException;
|
||||
import org.geolatte.geom.codec.WktDecoder;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import org.hibernate.spatial.HSMessageLogger;
|
||||
|
||||
/**
|
||||
* <p>Unit testsuite-suite support class.</p>
|
||||
*
|
||||
@ -104,6 +104,14 @@ public DataSourceUtils(String propertyFile, SQLExpressionTemplate template) {
|
||||
createBasicDataSource();
|
||||
}
|
||||
|
||||
private static int sum(int[] insCounts) {
|
||||
int result = 0;
|
||||
for ( int idx = 0; idx < insCounts.length; idx++ ) {
|
||||
result += insCounts[idx];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private Properties readProperties(String propertyFile) {
|
||||
InputStream is = null;
|
||||
try {
|
||||
@ -116,7 +124,7 @@ private Properties readProperties(String propertyFile) {
|
||||
return properties;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw (new RuntimeException( e ));
|
||||
throw ( new RuntimeException( e ) );
|
||||
}
|
||||
finally {
|
||||
if ( is != null ) {
|
||||
@ -139,14 +147,13 @@ private void createBasicDataSource() {
|
||||
dataSource = bds;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Closes the connections to the database.
|
||||
*
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void close() throws SQLException {
|
||||
((BasicDataSource) dataSource).close();
|
||||
( (BasicDataSource) dataSource ).close();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -233,7 +240,6 @@ public void insertTestData(TestData testData) throws SQLException {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parses the content of a file into an executable SQL statement.
|
||||
*
|
||||
@ -400,12 +406,4 @@ public Map<Integer, Geometry> expectedGeoms(String type, TestData testData) {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static int sum(int[] insCounts) {
|
||||
int result = 0;
|
||||
for ( int idx = 0; idx < insCounts.length; idx++ ) {
|
||||
result += insCounts[idx];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,12 +7,12 @@
|
||||
/**
|
||||
* Created by Karel Maesen, Geovise BVBA on 15/02/2018.
|
||||
*/
|
||||
public class GeolatteGeometryEquality<P extends Position> implements GeometryEquality<Geometry<P>>{
|
||||
public class GeolatteGeometryEquality<P extends Position> implements GeometryEquality<Geometry<P>> {
|
||||
|
||||
private final org.geolatte.geom.GeometryEquality delegate;
|
||||
|
||||
public GeolatteGeometryEquality(){
|
||||
this( new GeometryPointEquality());
|
||||
public GeolatteGeometryEquality() {
|
||||
this( new GeometryPointEquality() );
|
||||
}
|
||||
|
||||
public GeolatteGeometryEquality(org.geolatte.geom.GeometryEquality delegate) {
|
||||
|
@ -1,7 +1,5 @@
|
||||
package org.hibernate.spatial.testing;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
/**
|
||||
* Created by Karel Maesen, Geovise BVBA on 15/02/2018.
|
||||
*/
|
||||
|
@ -33,7 +33,7 @@ public boolean test(Geometry geom1, Geometry geom2) {
|
||||
}
|
||||
|
||||
if ( geom1 instanceof GeometryCollection ) {
|
||||
if ( !(geom2 instanceof GeometryCollection) ) {
|
||||
if ( !( geom2 instanceof GeometryCollection ) ) {
|
||||
return false;
|
||||
}
|
||||
GeometryCollection expectedCollection = (GeometryCollection) geom1;
|
||||
@ -62,7 +62,7 @@ public boolean test(Geometry geom1, Geometry geom2) {
|
||||
*/
|
||||
private boolean equalSRID(Geometry geom1, Geometry geom2) {
|
||||
return geom1.getSRID() == geom2.getSRID() ||
|
||||
(geom1.getSRID() < 1 && geom2.getSRID() < 1);
|
||||
( geom1.getSRID() < 1 && geom2.getSRID() < 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,6 +101,6 @@ protected boolean testTypeAndVertexEquality(Geometry geom1, Geometry geom2) {
|
||||
}
|
||||
|
||||
private boolean testCoordinateEquality(Coordinate c1, Coordinate c2) {
|
||||
return (Double.isNaN( c1.z ) || !(c1.z != c2.z)) && c1.x == c2.x && c1.y == c2.y;
|
||||
return ( Double.isNaN( c1.z ) || !( c1.z != c2.z ) ) && c1.x == c2.x && c1.y == c2.y;
|
||||
}
|
||||
}
|
||||
|
@ -9,11 +9,12 @@
|
||||
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.spatial.SpatialDialect;
|
||||
|
||||
import org.hibernate.testing.Skip;
|
||||
|
||||
/**
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 1/13/12
|
||||
* creation-date: 1/13/12
|
||||
*/
|
||||
public class SpatialDialectMatcher implements Skip.Matcher {
|
||||
@Override
|
||||
|
@ -12,8 +12,6 @@
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
@ -26,6 +24,8 @@
|
||||
import org.hibernate.testing.AfterClassOnce;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@ -33,7 +33,7 @@
|
||||
|
||||
/**
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: Sep 30, 2010
|
||||
* creation-date: Sep 30, 2010
|
||||
*/
|
||||
public abstract class SpatialFunctionalTestCase extends BaseCoreFunctionalTestCase {
|
||||
|
||||
@ -215,7 +215,7 @@ protected void compare(Integer id, Object expected, Object received, String geom
|
||||
}
|
||||
else if ( expected instanceof Geometry ) {
|
||||
if ( JTS.equals( geometryType ) ) {
|
||||
if ( !(received instanceof Geometry) ) {
|
||||
if ( !( received instanceof Geometry ) ) {
|
||||
fail(
|
||||
"Expected a JTS Geometry, but received an object of type " + received.getClass()
|
||||
.getCanonicalName()
|
||||
@ -227,7 +227,7 @@ else if ( expected instanceof Geometry ) {
|
||||
);
|
||||
}
|
||||
else {
|
||||
if ( !(received instanceof org.geolatte.geom.Geometry) ) {
|
||||
if ( !( received instanceof org.geolatte.geom.Geometry ) ) {
|
||||
fail(
|
||||
"Expected a Geolatte Geometry, but received an object of type " + received.getClass()
|
||||
.getCanonicalName()
|
||||
@ -245,7 +245,7 @@ else if ( expected instanceof Geometry ) {
|
||||
}
|
||||
else {
|
||||
if ( expected instanceof Long ) {
|
||||
assertEquals( "Failure on testsuite-suite for case " + id, ((Long) expected).intValue(), received );
|
||||
assertEquals( "Failure on testsuite-suite for case " + id, ( (Long) expected ).intValue(), received );
|
||||
}
|
||||
else {
|
||||
assertEquals( "Failure on testsuite-suite for case " + id, expected, received );
|
||||
|
@ -28,6 +28,18 @@ protected TestData() {
|
||||
|
||||
;
|
||||
|
||||
public static TestData fromFile(String fileName) {
|
||||
TestDataReader reader = new TestDataReader();
|
||||
return fromFile( fileName, reader );
|
||||
}
|
||||
|
||||
public static TestData fromFile(String fileName, TestDataReader reader) {
|
||||
List<TestDataElement> elements = reader.read( fileName );
|
||||
TestData testData = new TestData();
|
||||
testData.testDataElements = elements;
|
||||
return testData;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return testDataElements.size();
|
||||
}
|
||||
@ -128,16 +140,4 @@ public List<TestDataElement> subList(int fromIndex, int toIndex) {
|
||||
return testDataElements.subList( fromIndex, toIndex );
|
||||
}
|
||||
|
||||
public static TestData fromFile(String fileName) {
|
||||
TestDataReader reader = new TestDataReader();
|
||||
return fromFile( fileName, reader );
|
||||
}
|
||||
|
||||
public static TestData fromFile(String fileName, TestDataReader reader) {
|
||||
List<TestDataElement> elements = reader.read( fileName );
|
||||
TestData testData = new TestData();
|
||||
testData.testDataElements = elements;
|
||||
return testData;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
/**
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: Sep 30, 2010
|
||||
* creation-date: Sep 30, 2010
|
||||
*/
|
||||
public abstract class TestSupport {
|
||||
|
||||
|
@ -22,17 +22,52 @@
|
||||
|
||||
/**
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: Sep 30, 2010
|
||||
* creation-date: Sep 30, 2010
|
||||
*/
|
||||
public class TestSupportFactories {
|
||||
|
||||
private static TestSupportFactories instance = new TestSupportFactories();
|
||||
|
||||
private TestSupportFactories() {
|
||||
}
|
||||
|
||||
public static TestSupportFactories instance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private TestSupportFactories() {
|
||||
private static Class<? extends TestSupport> getSupportFactoryClass(Dialect dialect) {
|
||||
String canonicalName = dialect.getClass().getCanonicalName();
|
||||
|
||||
if ( ( dialect instanceof SpatialDialect ) && PostgreSQL82Dialect.class.isAssignableFrom( dialect.getClass() ) ) {
|
||||
//this test works because all postgis dialects ultimately derive of the Postgresql82Dialect
|
||||
return PostgisTestSupport.class;
|
||||
}
|
||||
if ( "org.hibernate.spatial.dialect.h2geodb.GeoDBDialect".equals( canonicalName ) ) {
|
||||
return GeoDBTestSupport.class;
|
||||
}
|
||||
if ( "org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect".equals( canonicalName ) ) {
|
||||
return SQLServerTestSupport.class;
|
||||
}
|
||||
if ( "org.hibernate.spatial.dialect.mysql.MySQLSpatialDialect".equals( canonicalName ) ||
|
||||
"org.hibernate.spatial.dialect.mysql.MySQL5InnoDBSpatialDialect".equals( canonicalName ) ) {
|
||||
return MySQLTestSupport.class;
|
||||
}
|
||||
if ( "org.hibernate.spatial.dialect.mysql.MySQL56SpatialDialect".equals( canonicalName ) ||
|
||||
"org.hibernate.spatial.dialect.mysql.MySQL56InnoDBSpatialDialect".equals( canonicalName ) ) {
|
||||
return MySQL56TestSupport.class;
|
||||
}
|
||||
if ( "org.hibernate.spatial.dialect.oracle.OracleSpatial10gDialect".equals( canonicalName ) ||
|
||||
"org.hibernate.spatial.dialect.oracle.OracleSpatialSDO10gDialect".equals( canonicalName ) ) {
|
||||
return OracleSDOTestSupport.class;
|
||||
}
|
||||
if ( "org.hibernate.spatial.dialect.hana.HANASpatialDialect".equals( canonicalName ) ) {
|
||||
return HANATestSupport.class;
|
||||
}
|
||||
|
||||
if ( "org.hibernate.spatial.dialect.db2.DB2SpatialDialect".equals( canonicalName ) ) {
|
||||
return DB2TestSupport.class;
|
||||
}
|
||||
throw new IllegalArgumentException( "Dialect not known in test suite" );
|
||||
}
|
||||
|
||||
public TestSupport getTestSupportFactory(Dialect dialect) throws InstantiationException, IllegalAccessException {
|
||||
@ -53,39 +88,4 @@ private ClassLoader getClassLoader() {
|
||||
return this.getClass().getClassLoader();
|
||||
}
|
||||
|
||||
private static Class<? extends TestSupport> getSupportFactoryClass(Dialect dialect) {
|
||||
String canonicalName = dialect.getClass().getCanonicalName();
|
||||
|
||||
if ( (dialect instanceof SpatialDialect) && PostgreSQL82Dialect.class.isAssignableFrom( dialect.getClass() ) ) {
|
||||
//this test works because all postgis dialects ultimately derive of the Postgresql82Dialect
|
||||
return PostgisTestSupport.class;
|
||||
}
|
||||
if ( "org.hibernate.spatial.dialect.h2geodb.GeoDBDialect".equals( canonicalName ) ) {
|
||||
return GeoDBTestSupport.class;
|
||||
}
|
||||
if ( "org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect".equals( canonicalName ) ) {
|
||||
return SQLServerTestSupport.class;
|
||||
}
|
||||
if ( "org.hibernate.spatial.dialect.mysql.MySQLSpatialDialect".equals( canonicalName ) ||
|
||||
"org.hibernate.spatial.dialect.mysql.MySQL5InnoDBSpatialDialect".equals( canonicalName ) ) {
|
||||
return MySQLTestSupport.class;
|
||||
}
|
||||
if ( "org.hibernate.spatial.dialect.mysql.MySQL56SpatialDialect".equals( canonicalName ) ||
|
||||
"org.hibernate.spatial.dialect.mysql.MySQL56InnoDBSpatialDialect".equals( canonicalName ) ) {
|
||||
return MySQL56TestSupport.class;
|
||||
}
|
||||
if ( "org.hibernate.spatial.dialect.oracle.OracleSpatial10gDialect".equals( canonicalName ) ||
|
||||
"org.hibernate.spatial.dialect.oracle.OracleSpatialSDO10gDialect".equals( canonicalName )) {
|
||||
return OracleSDOTestSupport.class;
|
||||
}
|
||||
if ( "org.hibernate.spatial.dialect.hana.HANASpatialDialect".equals( canonicalName ) ) {
|
||||
return HANATestSupport.class;
|
||||
}
|
||||
|
||||
if ("org.hibernate.spatial.dialect.db2.DB2SpatialDialect".equals( canonicalName )) {
|
||||
return DB2TestSupport.class;
|
||||
}
|
||||
throw new IllegalArgumentException( "Dialect not known in test suite" );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
/**
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 1/24/13
|
||||
* creation-date: 1/24/13
|
||||
*/
|
||||
public class WktUtility {
|
||||
|
||||
|
@ -21,24 +21,29 @@
|
||||
|
||||
package org.hibernate.spatial.testing.dialects.db2;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.hibernate.spatial.testing.DataSourceUtils;
|
||||
import org.hibernate.spatial.testing.SQLExpressionTemplate;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* @author David Adler, Adtech Geospatial
|
||||
* creation-date: 5/22/2014
|
||||
* creation-date: 5/22/2014
|
||||
*/
|
||||
public class DB2DataSourceUtils extends DataSourceUtils {
|
||||
|
||||
public DB2DataSourceUtils(String jdbcDriver, String jdbcUrl, String jdbcUser, String jdbcPass, SQLExpressionTemplate sqlExpressionTemplate) {
|
||||
super(jdbcDriver, jdbcUrl, jdbcUser, jdbcPass, sqlExpressionTemplate);
|
||||
public DB2DataSourceUtils(
|
||||
String jdbcDriver,
|
||||
String jdbcUrl,
|
||||
String jdbcUser,
|
||||
String jdbcPass,
|
||||
SQLExpressionTemplate sqlExpressionTemplate) {
|
||||
super( jdbcDriver, jdbcUrl, jdbcUser, jdbcPass, sqlExpressionTemplate );
|
||||
}
|
||||
|
||||
private void createIndex() throws SQLException {
|
||||
String sql = "create index idx_spatial_geomtest on geomtest (geom) extend using db2gse.spatial_index(0.1,0,0)";
|
||||
executeStatement(sql);
|
||||
executeStatement( sql );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,29 +24,30 @@
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.geom.Point;
|
||||
import org.geolatte.geom.jts.JTS;
|
||||
|
||||
import org.hibernate.spatial.dialect.db2.DB2GeometryTypeDescriptor;
|
||||
import org.hibernate.spatial.testing.AbstractExpectationsFactory;
|
||||
import org.hibernate.spatial.testing.DataSourceUtils;
|
||||
import org.hibernate.spatial.testing.NativeSQLStatement;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.geom.Point;
|
||||
import org.geolatte.geom.jts.JTS;
|
||||
|
||||
/**
|
||||
* This class provides the DB2 native spatial queries to generate the
|
||||
* results which will be compared with the HQL spatial results.
|
||||
*
|
||||
* @author David Adler, Adtech Geospatial
|
||||
* creation-date: 5/22/2014
|
||||
* creation-date: 5/22/2014
|
||||
*/
|
||||
public class DB2ExpectationsFactory extends AbstractExpectationsFactory {
|
||||
|
||||
private final DB2GeometryTypeDescriptor desc = new DB2GeometryTypeDescriptor( 4326 );
|
||||
|
||||
public DB2ExpectationsFactory(DataSourceUtils utils) {
|
||||
super( utils );
|
||||
}
|
||||
|
||||
private final DB2GeometryTypeDescriptor desc = new DB2GeometryTypeDescriptor(4326);
|
||||
/**
|
||||
* Returns the expected extent of all testsuite-suite geometries.
|
||||
*
|
||||
@ -124,7 +125,7 @@ protected NativeSQLStatement createNativeDimensionSQL() {
|
||||
protected 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}
|
||||
new Object[] { distance }
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
/**
|
||||
* @author David Adler
|
||||
* creation-date: 5/22/2014
|
||||
* creation-date: 5/22/2014
|
||||
*/
|
||||
public class DB2ExpressionTemplate implements SQLExpressionTemplate {
|
||||
|
||||
|
@ -35,7 +35,8 @@
|
||||
public class DB2TestSupport extends TestSupport {
|
||||
|
||||
public TestData createTestData(BaseCoreFunctionalTestCase testcase) {
|
||||
if ( "org.hibernate.spatial.integration.TestSpatialFunctions".equals( testcase.getClass().getCanonicalName() ) ) {
|
||||
if ( "org.hibernate.spatial.integration.TestSpatialFunctions".equals( testcase.getClass()
|
||||
.getCanonicalName() ) ) {
|
||||
return TestData.fromFile( "db2/test-db2nozm-only-polygon.xml" );
|
||||
}
|
||||
return TestData.fromFile( "db2/test-db2nozm-data-set.xml" );
|
||||
|
@ -29,8 +29,9 @@
|
||||
*/
|
||||
public class GeoDBDataSourceUtils extends DataSourceUtils {
|
||||
|
||||
public GeoDBDataSourceUtils(String jdbcDriver, String jdbcUrl, String jdbcUser, String jdbcPass,
|
||||
SQLExpressionTemplate sqlExpressionTemplate)
|
||||
public GeoDBDataSourceUtils(
|
||||
String jdbcDriver, String jdbcUrl, String jdbcUser, String jdbcPass,
|
||||
SQLExpressionTemplate sqlExpressionTemplate)
|
||||
throws SQLException, IOException {
|
||||
super( jdbcDriver, jdbcUrl, jdbcUser, jdbcPass, sqlExpressionTemplate );
|
||||
Connection conn = this.getConnection();
|
||||
@ -46,16 +47,16 @@ private void initGeoDB(Connection conn) {
|
||||
Method m = geoDB.getDeclaredMethod( "InitGeoDB", new Class[] { Connection.class } );
|
||||
m.invoke( null, conn );
|
||||
}
|
||||
catch ( ClassNotFoundException e ) {
|
||||
catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException( errorMsg, e );
|
||||
}
|
||||
catch ( NoSuchMethodException e ) {
|
||||
catch (NoSuchMethodException e) {
|
||||
throw new RuntimeException( errorMsg, e );
|
||||
}
|
||||
catch ( InvocationTargetException e ) {
|
||||
catch (InvocationTargetException e) {
|
||||
throw new RuntimeException( errorMsg, e );
|
||||
}
|
||||
catch ( IllegalAccessException e ) {
|
||||
catch (IllegalAccessException e) {
|
||||
throw new RuntimeException( errorMsg, e );
|
||||
}
|
||||
}
|
||||
|
@ -10,14 +10,14 @@
|
||||
*/
|
||||
package org.hibernate.spatial.testing.dialects.h2geodb;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.geom.Point;
|
||||
import org.geolatte.geom.jts.JTS;
|
||||
|
||||
import org.hibernate.spatial.dialect.h2geodb.GeoDbWkb;
|
||||
import org.hibernate.spatial.testing.AbstractExpectationsFactory;
|
||||
import org.hibernate.spatial.testing.NativeSQLStatement;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.geom.Point;
|
||||
import org.geolatte.geom.jts.JTS;
|
||||
|
||||
|
||||
/**
|
||||
* A Factory class that generates expected {@link NativeSQLStatement}s for
|
||||
@ -50,7 +50,7 @@ protected NativeSQLStatement createNativeBoundaryStatement() {
|
||||
protected 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}
|
||||
new Object[] { distance }
|
||||
);
|
||||
}
|
||||
|
||||
@ -112,11 +112,11 @@ protected NativeSQLStatement createNativeHavingSRIDStatement(int srid) {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeDistanceStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeDistanceStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDistanceStatement(Geometry geom) {
|
||||
@ -127,11 +127,11 @@ protected NativeSQLStatement createNativeDistanceStatement(Geometry geom) {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeEnvelopeStatement()
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeEnvelopeStatement()
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeEnvelopeStatement() {
|
||||
@ -139,11 +139,11 @@ protected NativeSQLStatement createNativeEnvelopeStatement() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeEqualsStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeEqualsStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeEqualsStatement(Geometry geom) {
|
||||
@ -154,11 +154,11 @@ protected NativeSQLStatement createNativeEqualsStatement(Geometry geom) {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeFilterStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeFilterStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeFilterStatement(Geometry geom) {
|
||||
@ -168,11 +168,11 @@ protected NativeSQLStatement createNativeFilterStatement(Geometry geom) {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeGeomUnionStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeGeomUnionStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeGeomUnionStatement(Geometry geom) {
|
||||
@ -183,11 +183,11 @@ protected NativeSQLStatement createNativeGeomUnionStatement(Geometry geom) {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeGeometryTypeStatement()
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeGeometryTypeStatement()
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeGeometryTypeStatement() {
|
||||
@ -195,11 +195,11 @@ protected NativeSQLStatement createNativeGeometryTypeStatement() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeIntersectionStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeIntersectionStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIntersectionStatement(Geometry geom) {
|
||||
@ -210,11 +210,11 @@ protected NativeSQLStatement createNativeIntersectionStatement(Geometry geom) {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeIntersectsStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeIntersectsStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
||||
@ -225,11 +225,11 @@ protected NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeIsEmptyStatement()
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeIsEmptyStatement()
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsEmptyStatement() {
|
||||
@ -242,11 +242,11 @@ protected NativeSQLStatement createNativeIsNotEmptyStatement() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeIsSimpleStatement()
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeIsSimpleStatement()
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsSimpleStatement() {
|
||||
@ -254,11 +254,11 @@ protected NativeSQLStatement createNativeIsSimpleStatement() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeOverlapsStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeOverlapsStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
||||
@ -269,12 +269,12 @@ protected NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeRelateStatement(com.vividsolutions.jts.geom.Geometry,
|
||||
* java.lang.String)
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeRelateStatement(com.vividsolutions.jts.geom.Geometry,
|
||||
* java.lang.String)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeRelateStatement(
|
||||
@ -296,11 +296,11 @@ protected NativeSQLStatement createNativeDwithinStatement(
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeSridStatement()
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeSridStatement()
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeSridStatement() {
|
||||
@ -308,11 +308,11 @@ protected NativeSQLStatement createNativeSridStatement() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeSymDifferenceStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeSymDifferenceStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeSymDifferenceStatement(
|
||||
@ -324,11 +324,11 @@ protected NativeSQLStatement createNativeSymDifferenceStatement(
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeTouchesStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeTouchesStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
||||
@ -339,11 +339,11 @@ protected NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeWithinStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeWithinStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeWithinStatement(
|
||||
|
@ -22,16 +22,17 @@ public class GeoDBExpressionTemplate implements SQLExpressionTemplate {
|
||||
static final String SQL_TEMPLATE = "insert into GEOMTEST (id, type, geom) values (%d, '%s', ST_GeomFromText('%s', %d))";
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.SQLExpressionTemplate#toInsertSql(org.
|
||||
* hibernatespatial.test.TestDataElement)
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.SQLExpressionTemplate#toInsertSql(org.
|
||||
* hibernatespatial.test.TestDataElement)
|
||||
*/
|
||||
public String toInsertSql(TestDataElement testDataElement) {
|
||||
String wkt = WktUtility.getWkt( testDataElement.wkt );
|
||||
int srid = WktUtility.getSRID( testDataElement.wkt );
|
||||
return String
|
||||
.format( SQL_TEMPLATE,
|
||||
.format(
|
||||
SQL_TEMPLATE,
|
||||
testDataElement.id,
|
||||
testDataElement.type,
|
||||
wkt,
|
||||
|
@ -10,11 +10,11 @@
|
||||
*/
|
||||
package org.hibernate.spatial.testing.dialects.h2geodb;
|
||||
|
||||
import org.hibernate.spatial.testing.JTSGeometryEquality;
|
||||
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
import org.hibernate.spatial.testing.JTSGeometryEquality;
|
||||
|
||||
/**
|
||||
* Extends the test for {@link Geometry} equality, because GeoDB uses JTS
|
||||
* Geometry objects, which cannot be cast to {@link org.hibernate.spatial.jts.mgeom.MGeometry} objects.
|
||||
|
@ -10,15 +10,15 @@
|
||||
*/
|
||||
package org.hibernate.spatial.testing.dialects.h2geodb;
|
||||
|
||||
import org.hibernate.spatial.testing.AbstractExpectationsFactory;
|
||||
import org.hibernate.spatial.testing.NativeSQLStatement;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.geom.Point;
|
||||
import org.geolatte.geom.ByteBuffer;
|
||||
import org.geolatte.geom.codec.Wkb;
|
||||
import org.geolatte.geom.jts.JTS;
|
||||
|
||||
import org.hibernate.spatial.testing.AbstractExpectationsFactory;
|
||||
import org.hibernate.spatial.testing.NativeSQLStatement;
|
||||
|
||||
/**
|
||||
* A Factory class that generates expected {@link org.hibernate.spatial.testing.NativeSQLStatement}s for GeoDB
|
||||
* version < 0.4. These versions don't support storage of the SRID value with
|
||||
@ -55,7 +55,7 @@ protected NativeSQLStatement createNativeBoundaryStatement() {
|
||||
protected 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}
|
||||
new Object[] { distance }
|
||||
);
|
||||
}
|
||||
|
||||
@ -208,11 +208,11 @@ protected NativeSQLStatement createNativeDwithinStatement(Point geom, double dis
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeSridStatement()
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeSridStatement()
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeSridStatement() {
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
/**
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: Oct 2, 2010
|
||||
* creation-date: Oct 2, 2010
|
||||
*/
|
||||
public class GeoDBTestSupport extends TestSupport {
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
package org.hibernate.spatial.testing.dialects.hana;
|
||||
|
||||
import org.geolatte.geom.jts.JTS;
|
||||
import org.hibernate.spatial.dialect.hana.HANASpatialUtils;
|
||||
import org.hibernate.spatial.testing.AbstractExpectationsFactory;
|
||||
import org.hibernate.spatial.testing.DataSourceUtils;
|
||||
@ -18,185 +17,201 @@
|
||||
import com.vividsolutions.jts.geom.Polygon;
|
||||
import com.vividsolutions.jts.io.ParseException;
|
||||
import com.vividsolutions.jts.io.WKTReader;
|
||||
import org.geolatte.geom.jts.JTS;
|
||||
|
||||
public class HANAExpectationsFactory extends AbstractExpectationsFactory {
|
||||
|
||||
public HANAExpectationsFactory(DataSourceUtils utils) {
|
||||
super(utils);
|
||||
super( utils );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDimensionSQL() {
|
||||
return createNativeSQLStatement("select t.id, t.geom.ST_Dimension() from GeomTest t");
|
||||
return createNativeSQLStatement( "select t.id, t.geom.ST_Dimension() from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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 });
|
||||
new Object[] { distance }
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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(),
|
||||
geom.toText());
|
||||
geom.toText()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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(),
|
||||
geom.toText());
|
||||
geom.toText()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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(),
|
||||
geom.toText());
|
||||
geom.toText()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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(),
|
||||
geom.toText());
|
||||
geom.toText()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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());
|
||||
geom.toText()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeAsTextStatement() {
|
||||
return createNativeSQLStatement("select t.id, t.geom.ST_AsText() from GeomTest t");
|
||||
return createNativeSQLStatement( "select t.id, t.geom.ST_AsText() from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeSridStatement() {
|
||||
return createNativeSQLStatement("select t.id, t.geom.ST_SRID() from GeomTest t");
|
||||
return createNativeSQLStatement( "select t.id, t.geom.ST_SRID() from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsSimpleStatement() {
|
||||
return createNativeSQLStatement("select t.id, t.geom.ST_IsSimple() from GeomTest t");
|
||||
return createNativeSQLStatement( "select t.id, t.geom.ST_IsSimple() from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsEmptyStatement() {
|
||||
return createNativeSQLStatement("select t.id, t.geom.ST_IsEmpty() from GeomTest t");
|
||||
return createNativeSQLStatement( "select t.id, t.geom.ST_IsEmpty() from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsNotEmptyStatement() {
|
||||
return createNativeSQLStatement("select t.id, map(t.geom.ST_IsEmpty(), 1, 0, 1) from GeomTest t");
|
||||
return createNativeSQLStatement( "select t.id, map(t.geom.ST_IsEmpty(), 1, 0, 1) from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeBoundaryStatement() {
|
||||
return createNativeSQLStatement("select t.id, t.geom.ST_Boundary().ST_AsEWKB() from GeomTest t");
|
||||
return createNativeSQLStatement( "select t.id, t.geom.ST_Boundary().ST_AsEWKB() from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeEnvelopeStatement() {
|
||||
return createNativeSQLStatement("select t.id, t.geom.ST_Envelope().ST_AsEWKB() from GeomTest t");
|
||||
return createNativeSQLStatement( "select t.id, t.geom.ST_Envelope().ST_AsEWKB() from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeAsBinaryStatement() {
|
||||
return createNativeSQLStatement("select t.id, t.geom.ST_AsBinary() from GeomTest t");
|
||||
return createNativeSQLStatement( "select t.id, t.geom.ST_AsBinary() from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeGeometryTypeStatement() {
|
||||
return createNativeSQLStatement("select t.id, t.geom.ST_GeometryType() from GeomTest t");
|
||||
return createNativeSQLStatement( "select t.id, t.geom.ST_GeometryType() from GeomTest t" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Geometry decode(Object o) {
|
||||
if (o == null) {
|
||||
if ( o == null ) {
|
||||
return null;
|
||||
}
|
||||
return JTS.to(HANASpatialUtils.toGeometry(o));
|
||||
return JTS.to( HANASpatialUtils.toGeometry( o ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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(),
|
||||
geom.toText());
|
||||
geom.toText()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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(),
|
||||
geom.toText());
|
||||
geom.toText()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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(),
|
||||
geom.toText());
|
||||
geom.toText()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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(),
|
||||
geom.toText());
|
||||
geom.toText()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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(),
|
||||
geom.toText());
|
||||
geom.toText()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeTransformStatement(int epsg) {
|
||||
return createNativeSQLStatement(
|
||||
"select t.id, t.geom.ST_Transform(" + epsg + ") from GeomTest t where t.geom.ST_SRID() = " + getTestSrid());
|
||||
"select t.id, t.geom.ST_Transform(" + epsg + ") from GeomTest t where t.geom.ST_SRID() = " + getTestSrid() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeHavingSRIDStatement(int srid) {
|
||||
return createNativeSQLStatement("select t.id, 1 from GeomTest t where t.geom.ST_SRID() = " + srid);
|
||||
return createNativeSQLStatement( "select t.id, 1 from GeomTest t where t.geom.ST_SRID() = " + srid );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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(),
|
||||
geom.toText());
|
||||
geom.toText()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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() = " + getTestSrid(),
|
||||
geom.toText());
|
||||
geom.toText()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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(),
|
||||
geom.toText());
|
||||
geom.toText()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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(),
|
||||
geom.toText());
|
||||
geom.toText()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -204,23 +219,27 @@ protected NativeSQLStatement createNativeRelateStatement(Geometry geom, String m
|
||||
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();
|
||||
return createNativeSQLStatementAllWKTParams(sql, geom.toText());
|
||||
return createNativeSQLStatementAllWKTParams( sql, geom.toText() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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
|
||||
+ ") = 1 and t.geom.ST_SRID() = " + getTestSrid(), geom.toText());
|
||||
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
|
||||
+ ") = 1 and t.geom.ST_SRID() = " + getTestSrid(),
|
||||
geom.toText()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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());
|
||||
geom.toText()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Polygon getTestPolygon() {
|
||||
WKTReader reader = new WKTReader();
|
||||
@ -233,10 +252,10 @@ public Polygon getTestPolygon() {
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getTestSrid() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -20,9 +20,9 @@ public class HANAExpressionTemplate implements SQLExpressionTemplate {
|
||||
|
||||
@Override
|
||||
public String toInsertSql(TestDataElement testDataElement) {
|
||||
Integer srid = Integer.valueOf(WktUtility.getSRID(testDataElement.wkt));
|
||||
String wkt = WktUtility.getWkt(testDataElement.wkt);
|
||||
return String.format(SQL_TEMPLATE, Integer.valueOf(testDataElement.id), testDataElement.type, wkt, srid);
|
||||
Integer srid = Integer.valueOf( WktUtility.getSRID( testDataElement.wkt ) );
|
||||
String wkt = WktUtility.getWkt( testDataElement.wkt );
|
||||
return String.format( SQL_TEMPLATE, Integer.valueOf( testDataElement.id ), testDataElement.type, wkt, srid );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
import org.hibernate.spatial.testing.SQLExpressionTemplate;
|
||||
import org.hibernate.spatial.testing.TestData;
|
||||
import org.hibernate.spatial.testing.TestSupport;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
|
||||
public class HANATestSupport extends TestSupport {
|
||||
|
@ -6,14 +6,14 @@
|
||||
*/
|
||||
package org.hibernate.spatial.testing.dialects.mysql;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
import org.hibernate.spatial.testing.DataSourceUtils;
|
||||
import org.hibernate.spatial.testing.NativeSQLStatement;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
/**
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 10/9/13
|
||||
* creation-date: 10/9/13
|
||||
*/
|
||||
public class MySQL56ExpectationsFactory extends MySQLExpectationsFactory {
|
||||
|
||||
@ -26,56 +26,64 @@ public MySQL56ExpectationsFactory(DataSourceUtils dataSourceUtils) {
|
||||
protected 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());
|
||||
geom.toText()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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());
|
||||
geom.toText()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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());
|
||||
geom.toText()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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());
|
||||
geom.toText()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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());
|
||||
geom.toText()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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());
|
||||
geom.toText()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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());
|
||||
geom.toText()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected 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());
|
||||
geom.toText()
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user