HHH-6511 - Uses Geolatte-Geom WKB encoder/decoder for Postgis dialect.
HHH-7126 - Uses Geolatte-Geom WKB encoder/decoder for GeoDB dialect.
This commit is contained in:
parent
24e7762a3a
commit
c9f27779dd
Binary file not shown.
|
@ -22,6 +22,7 @@
|
|||
# Boston, MA 02110-1301 USA
|
||||
#
|
||||
|
||||
hibernate.test.new_metadata_mappings = true
|
||||
hibernate.dialect org.hibernate.spatial.dialect.postgis.PostgisDialect
|
||||
hibernate.connection.driver_class org.postgresql.Driver
|
||||
hibernate.connection.url jdbc:postgresql://localhost:5432:hibbrtru
|
||||
|
|
|
@ -24,15 +24,9 @@ apply plugin: org.hibernate.build.gradle.testing.matrix.MatrixTestingPlugin
|
|||
|
||||
dependencies {
|
||||
compile(project(':hibernate-core'))
|
||||
compile([group: 'com.vividsolutions', name: 'jts', version: '1.12']) {
|
||||
transitive = false
|
||||
}
|
||||
compile([group: 'org.postgis', name: 'postgis-jdbc', version: '1.5.3'])
|
||||
compile([group: 'postgresql', name: 'postgresql', version: '8.4-701.jdbc4'])
|
||||
|
||||
|
||||
compile([group: 'org.geolatte', name: 'geolatte-geom', version: '0.12-SNAPSHOT'])
|
||||
|
||||
compile([group: 'com.vividsolutions', name: 'jts', version: '1.12'])
|
||||
|
||||
compile(libraries.dom4j) {
|
||||
transitive = false
|
||||
|
@ -41,12 +35,12 @@ dependencies {
|
|||
|
||||
testCompile(libraries.junit)
|
||||
testCompile(project(':hibernate-testing'))
|
||||
testRuntime([group: 'commons-dbcp', name: 'commons-dbcp', version: '1.4'])
|
||||
testCompile([group: 'commons-dbcp', name: 'commons-dbcp', version: '1.4'])
|
||||
// testRuntime([group: 'com.oracle.jdbc', name: 'ojdbc6', version: '11.2.0.3'])
|
||||
testRuntime([group: 'com.microsoft', name: 'sqljdbc', version: '2.0'])
|
||||
// testRuntime([group: 'com.microsoft', name: 'sqljdbc', version: '2.0'])
|
||||
// testRuntime("org.opengeo:geodb:0.7")
|
||||
// testRuntime("mysql:mysql-connector-java:5.1.15")
|
||||
testRuntime("postgresql:postgresql:8.4-701.jdbc4")
|
||||
// testRuntime("postgresql:postgresql:8.4-701.jdbc4")
|
||||
testCompile(libraries.validation)
|
||||
testCompile(libraries.jandex)
|
||||
testCompile(libraries.classmate)
|
||||
|
|
|
@ -21,18 +21,28 @@
|
|||
|
||||
package org.hibernate.spatial.dialect.h2geodb;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
|
||||
import org.geolatte.geom.Geometry;
|
||||
|
||||
import org.hibernate.spatial.GeometrySqlTypeDescriptor;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 2/29/12
|
||||
*/
|
||||
public class GeoDBGeometryTypeDescriptor extends GeometrySqlTypeDescriptor {
|
||||
|
||||
public static final GeoDBGeometryTypeDescriptor INSTANCE = new GeoDBGeometryTypeDescriptor();
|
||||
|
||||
@Override
|
||||
|
@ -51,12 +61,39 @@ public class GeoDBGeometryTypeDescriptor extends GeometrySqlTypeDescriptor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public <X> ValueBinder<X> getBinder(JavaTypeDescriptor<X> javaTypeDescriptor) {
|
||||
return (ValueBinder<X>) new GeoDBValueBinder(javaTypeDescriptor);
|
||||
public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
|
||||
return new BasicBinder<X>( javaTypeDescriptor, this ) {
|
||||
@Override
|
||||
protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options)
|
||||
throws SQLException {
|
||||
Geometry geometry = getJavaDescriptor().unwrap( value, Geometry.class, options );
|
||||
st.setBytes( index, GeoDbWkb.to( geometry ) );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X> ValueExtractor<X> getExtractor(JavaTypeDescriptor<X> javaTypeDescriptor) {
|
||||
return (ValueExtractor<X>) new GeoDBValueExtractor(javaTypeDescriptor);
|
||||
public <X> ValueExtractor<X> getExtractor(final JavaTypeDescriptor<X> javaTypeDescriptor) {
|
||||
return new BasicExtractor<X>( javaTypeDescriptor, this ) {
|
||||
|
||||
@Override
|
||||
protected X doExtract(ResultSet rs, String name, WrapperOptions options) throws SQLException {
|
||||
return getJavaDescriptor().wrap( GeoDbWkb.from( rs.getObject( name ) ), options );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected X doExtract(CallableStatement statement, int index, WrapperOptions options) throws SQLException {
|
||||
return getJavaDescriptor().wrap( GeoDbWkb.from( statement.getObject( index ) ), options );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected X doExtract(CallableStatement statement, String name, WrapperOptions options)
|
||||
throws SQLException {
|
||||
return getJavaDescriptor().wrap( GeoDbWkb.from( statement.getObject( name ) ), options );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
* This file is part of Hibernate Spatial, an extension to the
|
||||
* hibernate ORM solution for spatial (geographic) data.
|
||||
*
|
||||
* Copyright © 2007-2012 Geovise BVBA, Geodan IT b.v.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial.dialect.h2geodb;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
import org.hibernate.spatial.Log;
|
||||
import org.hibernate.spatial.LogFactory;
|
||||
import org.hibernate.spatial.dialect.AbstractGeometryValueBinder;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
|
||||
/**
|
||||
* @author Jan Boonen, Geodan IT b.v.
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 2/29/12
|
||||
*/
|
||||
public class GeoDBValueBinder<X> extends AbstractGeometryValueBinder {
|
||||
|
||||
private static Log LOG = LogFactory.make();
|
||||
|
||||
public GeoDBValueBinder(JavaTypeDescriptor<X> javaDescriptor) {
|
||||
super( javaDescriptor, GeoDBGeometryTypeDescriptor.INSTANCE );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object toNative(Geometry jtsGeom, Connection connection) {
|
||||
try {
|
||||
return WKB.toWKB( jtsGeom );
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
LOG.warn( "Could not convert JTS Geometry to a database object." );
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,164 +0,0 @@
|
|||
/*
|
||||
* This file is part of Hibernate Spatial, an extension to the
|
||||
* hibernate ORM solution for spatial (geographic) data.
|
||||
*
|
||||
* Copyright © 2007-2012 Geovise BVBA, Geodan IT b.v.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial.dialect.h2geodb;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.sql.Blob;
|
||||
|
||||
import com.vividsolutions.jts.geom.Envelope;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.io.ParseException;
|
||||
import com.vividsolutions.jts.io.WKBConstants;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.spatial.Log;
|
||||
import org.hibernate.spatial.LogFactory;
|
||||
import org.hibernate.spatial.dialect.AbstractGeometryValueExtractor;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
|
||||
/**
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 2/29/12
|
||||
*/
|
||||
public class GeoDBValueExtractor<X> extends AbstractGeometryValueExtractor<X> {
|
||||
|
||||
private static Log LOG = LogFactory.make();
|
||||
|
||||
public GeoDBValueExtractor(JavaTypeDescriptor<X> javaDescriptor) {
|
||||
super( javaDescriptor, GeoDBGeometryTypeDescriptor.INSTANCE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Geometry toJTS(Object object) {
|
||||
if ( object == null ) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
if ( object instanceof Blob ) {
|
||||
return WKB.fromWKB( toByteArray( (Blob) object ), getGeometryFactory() );
|
||||
}
|
||||
else if ( object instanceof byte[] ) {
|
||||
return geometryFromByteArray( (byte[]) object );
|
||||
}
|
||||
else if ( object instanceof Envelope ) {
|
||||
return getGeometryFactory().toGeometry( (Envelope) object );
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException(
|
||||
"Can't convert database object of type "
|
||||
+ object.getClass().getCanonicalName()
|
||||
);
|
||||
}
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
LOG.warn( "Could not convert database object to a JTS Geometry." );
|
||||
throw new HibernateException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert a WKB or EWKB byte array to a {@link Geometry}. To figure out
|
||||
* whether the byte array is either a WKB or EWK the following checks are
|
||||
* performed: <br/>
|
||||
* <ol>
|
||||
* <li>If the first byte is not 0 or 1, the geometry must be an EWKB (with
|
||||
* the first 32 bytes as a bounding box)</li>
|
||||
* <li>Otherwise, the the byte array is parsed as a WKB</li>
|
||||
* <li>When a parse error occurs it is assumed that the byte array is a EWKB
|
||||
* (with the first byte accidentally a 0 or 1), and parsed as EWKB</li>
|
||||
* </ol>
|
||||
*
|
||||
* @param bytes
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private Geometry geometryFromByteArray(byte[] bytes) throws ParseException {
|
||||
/*
|
||||
* wkbXDR = 0, // Big Endian
|
||||
* wkbNDR = 1 // Little Endian
|
||||
*/
|
||||
if ( bytes[0] != WKBConstants.wkbNDR && bytes[0] != WKBConstants.wkbXDR ) {
|
||||
// process as EWKB
|
||||
return WKB.fromEWKB( bytes, getGeometryFactory() );
|
||||
}
|
||||
else {
|
||||
// process as WKB
|
||||
try {
|
||||
return WKB.fromWKB( bytes, getGeometryFactory() );
|
||||
}
|
||||
catch ( RuntimeException e ) {
|
||||
// note: ParseException is wrapped in a RuntimeException in
|
||||
// geodb.GeoDB
|
||||
if ( e.getCause() != null
|
||||
&& e.getCause() instanceof ParseException ) {
|
||||
// retry as EWKB, this should rarely happen, but may occur
|
||||
// when the first byte of the EWKB bounding-box is '0'.
|
||||
// this should not be considered as a error
|
||||
LOG.debug(
|
||||
"Caught parse exception while parsing byte array as WKB. Retrying as EWKB.",
|
||||
e
|
||||
);
|
||||
return WKB.fromEWKB( bytes, getGeometryFactory() );
|
||||
}
|
||||
else {
|
||||
// this is an other exception, simply re-throw
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] toByteArray(Blob blob) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
byte[] buf = new byte[1024];
|
||||
|
||||
InputStream in = null;
|
||||
try {
|
||||
in = blob.getBinaryStream();
|
||||
int n = 0;
|
||||
while ( ( n = in.read( buf ) ) >= 0 ) {
|
||||
baos.write( buf, 0, n );
|
||||
|
||||
}
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
LOG.warn( "Could not convert database BLOB object to binary stream.", e );
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if ( in != null ) {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
catch ( IOException e ) {
|
||||
LOG.warn( "Could not close binary stream." );
|
||||
}
|
||||
}
|
||||
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
* This file is part of Hibernate Spatial, an extension to the
|
||||
* hibernate ORM solution for spatial (geographic) data.
|
||||
*
|
||||
* Copyright © 2007-2012 Geovise BVBA, Geodan IT b.v.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial.dialect.h2geodb;
|
||||
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.sql.Blob;
|
||||
|
||||
import org.geolatte.geom.ByteBuffer;
|
||||
import org.geolatte.geom.ByteOrder;
|
||||
import org.geolatte.geom.DimensionalFlag;
|
||||
import org.geolatte.geom.Envelope;
|
||||
import org.geolatte.geom.Geometry;
|
||||
import org.geolatte.geom.PointSequence;
|
||||
import org.geolatte.geom.PointSequenceBuilders;
|
||||
import org.geolatte.geom.Polygon;
|
||||
import org.geolatte.geom.codec.Wkb;
|
||||
import org.geolatte.geom.codec.WkbDecoder;
|
||||
import org.geolatte.geom.codec.WkbEncoder;
|
||||
import org.geolatte.geom.crs.CrsId;
|
||||
import org.geolatte.geom.jts.JTS;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.spatial.Log;
|
||||
import org.hibernate.spatial.LogFactory;
|
||||
|
||||
/**
|
||||
* A utility class to serialize from/to GeoDB WKB's.
|
||||
* <p/>
|
||||
* <p>Note: this utility makes it unnecessary to have a dependency on GeoDB. As long as GeoDB is
|
||||
* not available in common maven repositories, such a dependency is to be avoided.</p>
|
||||
*
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 2/29/12
|
||||
*/
|
||||
public class GeoDbWkb {
|
||||
|
||||
private static Log LOG = LogFactory.make();
|
||||
|
||||
|
||||
public static byte[] to(Geometry geometry) {
|
||||
WkbEncoder encoder = Wkb.newEncoder( Wkb.Dialect.POSTGIS_EWKB_1 );
|
||||
ByteBuffer buffer = encoder.encode( geometry, ByteOrder.NDR );
|
||||
return ( buffer == null ? null : buffer.toByteArray() );
|
||||
}
|
||||
|
||||
public static Geometry from(Object object) {
|
||||
if ( object == null ) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
WkbDecoder decoder = Wkb.newDecoder( Wkb.Dialect.POSTGIS_EWKB_1 );
|
||||
if ( object instanceof Blob ) {
|
||||
return decoder.decode( toByteBuffer( (Blob) object ) );
|
||||
}
|
||||
else if ( object instanceof byte[] ) {
|
||||
return decoder.decode( ByteBuffer.from( (byte[]) object ) );
|
||||
}
|
||||
else if ( object instanceof com.vividsolutions.jts.geom.Envelope ) {
|
||||
return toPolygon( JTS.from( (com.vividsolutions.jts.geom.Envelope) object ) );
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException(
|
||||
"Can't convert database object of type "
|
||||
+ object.getClass().getCanonicalName()
|
||||
);
|
||||
}
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
LOG.warn( "Could not convert database object to a Geometry." );
|
||||
throw new HibernateException( e );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static Geometry toPolygon(Envelope env) {
|
||||
PointSequence ps = PointSequenceBuilders.fixedSized( 4, DimensionalFlag.d2D, CrsId.UNDEFINED )
|
||||
.add( env.getMinX(), env.getMinY() )
|
||||
.add( env.getMinX(), env.getMaxY() )
|
||||
.add( env.getMaxX(), env.getMaxY() )
|
||||
.add( env.getMinX(), env.getMinY() ).toPointSequence();
|
||||
return new Polygon( ps );
|
||||
}
|
||||
|
||||
private static ByteBuffer toByteBuffer(Blob blob) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
byte[] buf = new byte[1024];
|
||||
|
||||
InputStream in = null;
|
||||
try {
|
||||
in = blob.getBinaryStream();
|
||||
int n = 0;
|
||||
while ( ( n = in.read( buf ) ) >= 0 ) {
|
||||
baos.write( buf, 0, n );
|
||||
}
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
LOG.warn( "Could not convert database BLOB object to binary stream.", e );
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if ( in != null ) {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
catch ( IOException e ) {
|
||||
LOG.warn( "Could not close binary stream." );
|
||||
}
|
||||
}
|
||||
return ByteBuffer.from( baos.toByteArray() );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
/*
|
||||
* This file is part of Hibernate Spatial, an extension to the
|
||||
* hibernate ORM solution for spatial (geographic) data.
|
||||
*
|
||||
* Copyright © 2007-2012 Geovise BVBA, Geodan IT b.v.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial.dialect.h2geodb;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.geom.GeometryFactory;
|
||||
import com.vividsolutions.jts.io.ParseException;
|
||||
import com.vividsolutions.jts.io.WKBReader;
|
||||
import com.vividsolutions.jts.io.WKBWriter;
|
||||
|
||||
/**
|
||||
* A utility class to serialize from/to GeoDB WKB's.
|
||||
* <p/>
|
||||
* <p>Note: this utility makes it unnecessary to have a dependency on GeoDB. As long as GeoDB is
|
||||
* not available in common maven repositories, such a dependency is to be avoided.</p>
|
||||
*
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 2/29/12
|
||||
*/
|
||||
class WKB {
|
||||
|
||||
static Geometry fromWKB(byte[] bytes, GeometryFactory factory) throws ParseException {
|
||||
WKBReader reader = new WKBReader( factory );
|
||||
return reader.read( bytes );
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a EWKB byte (which is just a WKB prepended with an envelope of 32 bytes.
|
||||
*
|
||||
* @param bytes
|
||||
* @param factory
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws ParseException
|
||||
*/
|
||||
static Geometry fromEWKB(byte[] bytes, GeometryFactory factory) throws ParseException {
|
||||
byte[] wkbBytes = new byte[bytes.length - 32];
|
||||
System.arraycopy( bytes, 32, wkbBytes, 0, bytes.length - 32 );
|
||||
return fromWKB( wkbBytes, factory );
|
||||
}
|
||||
|
||||
|
||||
static byte[] toWKB(Geometry jtsGeom) {
|
||||
WKBWriter writer = new WKBWriter( 2, true );
|
||||
return writer.write( jtsGeom );
|
||||
}
|
||||
}
|
||||
|
|
@ -21,12 +21,26 @@
|
|||
|
||||
package org.hibernate.spatial.dialect.mysql;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
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.spatial.GeometrySqlTypeDescriptor;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
|
@ -51,13 +65,51 @@ public class MySQLGeometryTypeDescriptor extends GeometrySqlTypeDescriptor {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <X> ValueBinder<X> getBinder(JavaTypeDescriptor<X> javaTypeDescriptor) {
|
||||
return (ValueBinder<X>) new MySQLGeometryValueBinder(javaTypeDescriptor);
|
||||
public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
|
||||
return new BasicBinder<X>( javaTypeDescriptor, this ) {
|
||||
@Override
|
||||
protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options)
|
||||
throws SQLException {
|
||||
WkbEncoder encoder = Wkb.newEncoder( Wkb.Dialect.MYSQL_WKB );
|
||||
Geometry geometry = getJavaDescriptor().unwrap( value, Geometry.class, options );
|
||||
ByteBuffer buffer = encoder.encode( geometry, ByteOrder.NDR );
|
||||
byte[] bytes = ( buffer == null ? null : buffer.toByteArray() );
|
||||
st.setBytes( index, bytes );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X> ValueExtractor<X> getExtractor(JavaTypeDescriptor<X> javaTypeDescriptor) {
|
||||
return (ValueExtractor<X>) new MySQLGeometryValueExtractor(javaTypeDescriptor);
|
||||
public <X> ValueExtractor<X> getExtractor(final JavaTypeDescriptor<X> javaTypeDescriptor) {
|
||||
return new BasicExtractor<X>( javaTypeDescriptor, this ) {
|
||||
|
||||
@Override
|
||||
protected X doExtract(ResultSet rs, String name, WrapperOptions options) throws SQLException {
|
||||
return getJavaDescriptor().wrap( toGeometry( rs.getBytes( name ) ), options );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected X doExtract(CallableStatement statement, int index, WrapperOptions options) throws SQLException {
|
||||
return getJavaDescriptor().wrap( toGeometry( statement.getBytes( index ) ), options );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected X doExtract(CallableStatement statement, String name, WrapperOptions options)
|
||||
throws SQLException {
|
||||
return getJavaDescriptor().wrap( toGeometry( statement.getBytes( name ) ), options );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private Geometry toGeometry(byte[] bytes) {
|
||||
if ( bytes == null ) {
|
||||
return null;
|
||||
}
|
||||
ByteBuffer buffer = ByteBuffer.from( bytes );
|
||||
WkbDecoder decoder = Wkb.newDecoder( Wkb.Dialect.MYSQL_WKB );
|
||||
return decoder.decode( buffer );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,103 +0,0 @@
|
|||
/*
|
||||
* This file is part of Hibernate Spatial, an extension to the
|
||||
* hibernate ORM solution for spatial (geographic) data.
|
||||
*
|
||||
* Copyright © 2007-2012 Geovise BVBA
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial.dialect.mysql;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.geom.GeometryCollection;
|
||||
import com.vividsolutions.jts.geom.GeometryFactory;
|
||||
import com.vividsolutions.jts.io.ByteOrderValues;
|
||||
import com.vividsolutions.jts.io.WKBWriter;
|
||||
|
||||
import org.hibernate.spatial.dialect.AbstractGeometryValueBinder;
|
||||
import org.hibernate.spatial.jts.JTS;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
|
||||
/**
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 1/19/12
|
||||
*/
|
||||
public class MySQLGeometryValueBinder<X> extends AbstractGeometryValueBinder {
|
||||
|
||||
private static final int SRIDLEN = 4;
|
||||
|
||||
public MySQLGeometryValueBinder(JavaTypeDescriptor<X> javaDescriptor) {
|
||||
super( javaDescriptor, MySQLGeometryTypeDescriptor.INSTANCE );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object toNative(Geometry jtsGeom, Connection connection) {
|
||||
if ( jtsGeom.isEmpty() ) {
|
||||
return null;
|
||||
}
|
||||
jtsGeom = forceGeometryCollection( jtsGeom );
|
||||
int srid = jtsGeom.getSRID();
|
||||
|
||||
WKBWriter writer = new WKBWriter(
|
||||
2,
|
||||
ByteOrderValues.LITTLE_ENDIAN
|
||||
);
|
||||
byte[] wkb = writer.write( jtsGeom );
|
||||
|
||||
byte[] byteArr = new byte[wkb.length + SRIDLEN];
|
||||
byteArr[3] = (byte) ( ( srid >> 24 ) & 0xFF );
|
||||
byteArr[2] = (byte) ( ( srid >> 16 ) & 0xFF );
|
||||
byteArr[1] = (byte) ( ( srid >> 8 ) & 0xFF );
|
||||
byteArr[0] = (byte) ( srid & 0xFF );
|
||||
System.arraycopy( wkb, 0, byteArr, SRIDLEN, wkb.length );
|
||||
return byteArr;
|
||||
}
|
||||
|
||||
private Geometry forceGeometryCollection(Geometry jtsGeom) {
|
||||
if ( jtsGeom.isEmpty() ) {
|
||||
return createEmptyGeometryCollection( jtsGeom );
|
||||
}
|
||||
if ( jtsGeom instanceof GeometryCollection ) {
|
||||
GeometryCollection gc = (GeometryCollection) jtsGeom;
|
||||
Geometry[] components = new Geometry[gc.getNumGeometries()];
|
||||
for ( int i = 0; i < gc.getNumGeometries(); i++ ) {
|
||||
Geometry component = gc.getGeometryN( i );
|
||||
if ( component.isEmpty() ) {
|
||||
components[i] = jtsGeom.getFactory().createGeometryCollection( null );
|
||||
}
|
||||
else {
|
||||
components[i] = component;
|
||||
}
|
||||
}
|
||||
Geometry geometryCollection = jtsGeom.getFactory().createGeometryCollection( components );
|
||||
geometryCollection.setSRID( jtsGeom.getSRID() );
|
||||
return geometryCollection;
|
||||
}
|
||||
return jtsGeom;
|
||||
}
|
||||
|
||||
private Geometry createEmptyGeometryCollection(Geometry jtsGeom) {
|
||||
GeometryFactory factory = jtsGeom.getFactory();
|
||||
if ( factory == null ) {
|
||||
factory = JTS.getDefaultGeometryFactory();
|
||||
}
|
||||
Geometry empty = factory.createGeometryCollection( null );
|
||||
empty.setSRID( jtsGeom.getSRID() );
|
||||
return empty;
|
||||
}
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* This file is part of Hibernate Spatial, an extension to the
|
||||
* hibernate ORM solution for spatial (geographic) data.
|
||||
*
|
||||
* Copyright © 2007-2012 Geovise BVBA
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial.dialect.mysql;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.io.WKBReader;
|
||||
|
||||
import org.hibernate.spatial.dialect.AbstractGeometryValueExtractor;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
|
||||
/**
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 1/19/12
|
||||
*/
|
||||
public class MySQLGeometryValueExtractor<X> extends AbstractGeometryValueExtractor<X> {
|
||||
|
||||
private static final int SRIDLEN = 4;
|
||||
|
||||
public MySQLGeometryValueExtractor(JavaTypeDescriptor<X> javaDescriptor) {
|
||||
super( javaDescriptor, MySQLGeometryTypeDescriptor.INSTANCE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the native geometry object to a JTS <code>Geometry</code>.
|
||||
*
|
||||
* @param object native database geometry object (depends on the JDBC spatial
|
||||
* extension of the database)
|
||||
*
|
||||
* @return JTS geometry corresponding to geomObj.
|
||||
*/
|
||||
public Geometry toJTS(Object object) {
|
||||
if ( object == null ) {
|
||||
return null;
|
||||
}
|
||||
byte[] data = (byte[]) object;
|
||||
byte[] wkb = new byte[data.length - SRIDLEN];
|
||||
System.arraycopy( data, SRIDLEN, wkb, 0, wkb.length );
|
||||
int srid = 0;
|
||||
// WKB in MySQL Spatial is always little endian.
|
||||
srid = data[3] << 24 | ( data[2] & 0xff ) << 16 | ( data[1] & 0xff ) << 8
|
||||
| ( data[0] & 0xff );
|
||||
Geometry geom = null;
|
||||
try {
|
||||
WKBReader reader = new WKBReader();
|
||||
geom = reader.read( wkb );
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
throw new RuntimeException(
|
||||
"Couldn't parse incoming MySQL Spatial data."
|
||||
);
|
||||
}
|
||||
geom.setSRID( srid );
|
||||
return geom;
|
||||
}
|
||||
|
||||
}
|
|
@ -21,12 +21,27 @@
|
|||
|
||||
package org.hibernate.spatial.dialect.postgis;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
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.postgresql.util.PGobject;
|
||||
|
||||
import org.hibernate.spatial.GeometrySqlTypeDescriptor;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
|
@ -54,11 +69,52 @@ public class PGGeometryTypeDescriptor extends GeometrySqlTypeDescriptor {
|
|||
|
||||
@Override
|
||||
public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
|
||||
return (ValueBinder<X>) new PGGeometryValueBinder(javaTypeDescriptor);
|
||||
return new BasicBinder<X>( javaTypeDescriptor, this ) {
|
||||
@Override
|
||||
protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options)
|
||||
throws SQLException {
|
||||
WkbEncoder encoder = Wkb.newEncoder( Wkb.Dialect.POSTGIS_EWKB_1 );
|
||||
Geometry geometry = getJavaDescriptor().unwrap( value, Geometry.class, options );
|
||||
byte[] bytes = encoder.encode( geometry, ByteOrder.NDR ).toByteArray();
|
||||
st.setBytes( index, bytes );
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X> ValueExtractor<X> getExtractor(final JavaTypeDescriptor<X> javaTypeDescriptor) {
|
||||
return (ValueExtractor<X>) new PGGeometryValueExtractor(javaTypeDescriptor);
|
||||
return new BasicExtractor<X>( javaTypeDescriptor, this ) {
|
||||
|
||||
@Override
|
||||
protected X doExtract(ResultSet rs, String name, WrapperOptions options) throws SQLException {
|
||||
return getJavaDescriptor().wrap( toGeometry( rs.getObject( name ) ), options );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected X doExtract(CallableStatement statement, int index, WrapperOptions options) throws SQLException {
|
||||
return getJavaDescriptor().wrap( toGeometry( statement.getObject( index ) ), options );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected X doExtract(CallableStatement statement, String name, WrapperOptions options)
|
||||
throws SQLException {
|
||||
return getJavaDescriptor().wrap( toGeometry( statement.getObject( name ) ), options );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private Geometry toGeometry(Object object) {
|
||||
if ( object == null ) {
|
||||
return null;
|
||||
}
|
||||
ByteBuffer buffer = null;
|
||||
if ( object instanceof PGobject ) {
|
||||
buffer = ByteBuffer.from( ( (PGobject) object ).getValue() );
|
||||
WkbDecoder decoder = Wkb.newDecoder( Wkb.Dialect.POSTGIS_EWKB_1 );
|
||||
return decoder.decode( buffer );
|
||||
}
|
||||
throw new IllegalStateException( "Received object of type " + object.getClass().getCanonicalName() );
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,293 +0,0 @@
|
|||
/*
|
||||
* This file is part of Hibernate Spatial, an extension to the
|
||||
* hibernate ORM solution for spatial (geographic) data.
|
||||
*
|
||||
* Copyright © 2007-2012 Geovise BVBA
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial.dialect.postgis;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.geom.GeometryFactory;
|
||||
import org.postgis.GeometryCollection;
|
||||
import org.postgis.LineString;
|
||||
import org.postgis.LinearRing;
|
||||
import org.postgis.MultiLineString;
|
||||
import org.postgis.MultiPoint;
|
||||
import org.postgis.MultiPolygon;
|
||||
import org.postgis.PGgeometry;
|
||||
import org.postgis.Point;
|
||||
import org.postgis.Polygon;
|
||||
|
||||
import org.hibernate.spatial.dialect.AbstractGeometryValueBinder;
|
||||
import org.hibernate.spatial.jts.JTS;
|
||||
import org.hibernate.spatial.jts.mgeom.MCoordinate;
|
||||
import org.hibernate.spatial.jts.mgeom.MGeometry;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
|
||||
/**
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 7/27/11
|
||||
*/
|
||||
public class PGGeometryValueBinder<X> extends AbstractGeometryValueBinder<X> {
|
||||
|
||||
|
||||
public PGGeometryValueBinder(JavaTypeDescriptor<X> javaDescriptor) {
|
||||
super( javaDescriptor, PGGeometryTypeDescriptor.INSTANCE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a JTS <code>Geometry</code> to a native geometry object.
|
||||
*
|
||||
* @param jtsGeom JTS Geometry to convert
|
||||
* @param connection the current database connection
|
||||
*
|
||||
* @return native database geometry object corresponding to jtsGeom.
|
||||
*/
|
||||
protected Object toNative(Geometry jtsGeom, Connection connection) {
|
||||
org.postgis.Geometry geom = null;
|
||||
jtsGeom = forceEmptyToGeometryCollection( jtsGeom );
|
||||
if ( jtsGeom instanceof com.vividsolutions.jts.geom.Point ) {
|
||||
geom = convertJTSPoint( (com.vividsolutions.jts.geom.Point) jtsGeom );
|
||||
}
|
||||
else if ( jtsGeom instanceof com.vividsolutions.jts.geom.LineString ) {
|
||||
geom = convertJTSLineString( (com.vividsolutions.jts.geom.LineString) jtsGeom );
|
||||
}
|
||||
else if ( jtsGeom instanceof com.vividsolutions.jts.geom.MultiLineString ) {
|
||||
geom = convertJTSMultiLineString( (com.vividsolutions.jts.geom.MultiLineString) jtsGeom );
|
||||
}
|
||||
else if ( jtsGeom instanceof com.vividsolutions.jts.geom.Polygon ) {
|
||||
geom = convertJTSPolygon( (com.vividsolutions.jts.geom.Polygon) jtsGeom );
|
||||
}
|
||||
else if ( jtsGeom instanceof com.vividsolutions.jts.geom.MultiPoint ) {
|
||||
geom = convertJTSMultiPoint( (com.vividsolutions.jts.geom.MultiPoint) jtsGeom );
|
||||
}
|
||||
else if ( jtsGeom instanceof com.vividsolutions.jts.geom.MultiPolygon ) {
|
||||
geom = convertJTSMultiPolygon( (com.vividsolutions.jts.geom.MultiPolygon) jtsGeom );
|
||||
}
|
||||
else if ( jtsGeom instanceof com.vividsolutions.jts.geom.GeometryCollection ) {
|
||||
geom = convertJTSGeometryCollection( (com.vividsolutions.jts.geom.GeometryCollection) jtsGeom );
|
||||
}
|
||||
|
||||
if ( geom != null ) {
|
||||
return new PGgeometry( geom );
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedOperationException(
|
||||
"Conversion of "
|
||||
+ jtsGeom.getClass().getSimpleName()
|
||||
+ " to PGgeometry not supported"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//Postgis treats every empty geometry as an empty geometrycollection
|
||||
|
||||
private Geometry forceEmptyToGeometryCollection(Geometry jtsGeom) {
|
||||
Geometry forced = jtsGeom;
|
||||
if ( forced.isEmpty() ) {
|
||||
GeometryFactory factory = jtsGeom.getFactory();
|
||||
if ( factory == null ) {
|
||||
factory = JTS.getDefaultGeometryFactory();
|
||||
}
|
||||
forced = factory.createGeometryCollection( null );
|
||||
forced.setSRID( jtsGeom.getSRID() );
|
||||
}
|
||||
return forced;
|
||||
}
|
||||
|
||||
private MultiPolygon convertJTSMultiPolygon(
|
||||
com.vividsolutions.jts.geom.MultiPolygon multiPolygon) {
|
||||
Polygon[] pgPolygons = new Polygon[multiPolygon.getNumGeometries()];
|
||||
for ( int i = 0; i < pgPolygons.length; i++ ) {
|
||||
pgPolygons[i] = convertJTSPolygon(
|
||||
(com.vividsolutions.jts.geom.Polygon) multiPolygon
|
||||
.getGeometryN( i )
|
||||
);
|
||||
}
|
||||
MultiPolygon mpg = new MultiPolygon( pgPolygons );
|
||||
mpg.setSrid( multiPolygon.getSRID() );
|
||||
return mpg;
|
||||
}
|
||||
|
||||
private MultiPoint convertJTSMultiPoint(
|
||||
com.vividsolutions.jts.geom.MultiPoint multiPoint) {
|
||||
Point[] pgPoints = new Point[multiPoint.getNumGeometries()];
|
||||
for ( int i = 0; i < pgPoints.length; i++ ) {
|
||||
pgPoints[i] = convertJTSPoint(
|
||||
(com.vividsolutions.jts.geom.Point) multiPoint
|
||||
.getGeometryN( i )
|
||||
);
|
||||
}
|
||||
MultiPoint mp = new MultiPoint( pgPoints );
|
||||
mp.setSrid( multiPoint.getSRID() );
|
||||
return mp;
|
||||
}
|
||||
|
||||
private Polygon convertJTSPolygon(
|
||||
com.vividsolutions.jts.geom.Polygon jtsPolygon) {
|
||||
int numRings = jtsPolygon.getNumInteriorRing();
|
||||
org.postgis.LinearRing[] rings = new org.postgis.LinearRing[numRings + 1];
|
||||
rings[0] = convertJTSLineStringToLinearRing(
|
||||
jtsPolygon
|
||||
.getExteriorRing()
|
||||
);
|
||||
for ( int i = 0; i < numRings; i++ ) {
|
||||
rings[i + 1] = convertJTSLineStringToLinearRing(
|
||||
jtsPolygon
|
||||
.getInteriorRingN( i )
|
||||
);
|
||||
}
|
||||
Polygon polygon = new org.postgis.Polygon( rings );
|
||||
polygon.setSrid( jtsPolygon.getSRID() );
|
||||
return polygon;
|
||||
}
|
||||
|
||||
private LinearRing convertJTSLineStringToLinearRing(
|
||||
com.vividsolutions.jts.geom.LineString lineString) {
|
||||
LinearRing lr = new org.postgis.LinearRing(
|
||||
toPoints(
|
||||
lineString
|
||||
.getCoordinates()
|
||||
)
|
||||
);
|
||||
lr.setSrid( lineString.getSRID() );
|
||||
return lr;
|
||||
}
|
||||
|
||||
private LineString convertJTSLineString(
|
||||
com.vividsolutions.jts.geom.LineString string) {
|
||||
LineString ls = new org.postgis.LineString(
|
||||
toPoints(
|
||||
string
|
||||
.getCoordinates()
|
||||
)
|
||||
);
|
||||
if ( string instanceof MGeometry ) {
|
||||
ls.haveMeasure = true;
|
||||
}
|
||||
ls.setSrid( string.getSRID() );
|
||||
return ls;
|
||||
}
|
||||
|
||||
private MultiLineString convertJTSMultiLineString(
|
||||
com.vividsolutions.jts.geom.MultiLineString string) {
|
||||
org.postgis.LineString[] lines = new org.postgis.LineString[string
|
||||
.getNumGeometries()];
|
||||
for ( int i = 0; i < string.getNumGeometries(); i++ ) {
|
||||
lines[i] = new org.postgis.LineString(
|
||||
toPoints(
|
||||
string.getGeometryN(
|
||||
i
|
||||
).getCoordinates()
|
||||
)
|
||||
);
|
||||
}
|
||||
MultiLineString mls = new MultiLineString( lines );
|
||||
if ( string instanceof MGeometry ) {
|
||||
mls.haveMeasure = true;
|
||||
}
|
||||
mls.setSrid( string.getSRID() );
|
||||
return mls;
|
||||
}
|
||||
|
||||
private Point convertJTSPoint(com.vividsolutions.jts.geom.Point point) {
|
||||
org.postgis.Point pgPoint = new org.postgis.Point();
|
||||
pgPoint.srid = point.getSRID();
|
||||
pgPoint.x = point.getX();
|
||||
pgPoint.y = point.getY();
|
||||
Coordinate coordinate = point.getCoordinate();
|
||||
if ( Double.isNaN( coordinate.z ) ) {
|
||||
pgPoint.dimension = 2;
|
||||
}
|
||||
else {
|
||||
pgPoint.z = coordinate.z;
|
||||
pgPoint.dimension = 3;
|
||||
}
|
||||
pgPoint.haveMeasure = false;
|
||||
if ( coordinate instanceof MCoordinate && !Double.isNaN( ( (MCoordinate) coordinate ).m ) ) {
|
||||
pgPoint.m = ( (MCoordinate) coordinate ).m;
|
||||
pgPoint.haveMeasure = true;
|
||||
}
|
||||
return pgPoint;
|
||||
}
|
||||
|
||||
private GeometryCollection convertJTSGeometryCollection(
|
||||
com.vividsolutions.jts.geom.GeometryCollection collection) {
|
||||
com.vividsolutions.jts.geom.Geometry currentGeom;
|
||||
org.postgis.Geometry[] pgCollections = new org.postgis.Geometry[collection
|
||||
.getNumGeometries()];
|
||||
for ( int i = 0; i < pgCollections.length; i++ ) {
|
||||
currentGeom = collection.getGeometryN( i );
|
||||
currentGeom = forceEmptyToGeometryCollection( currentGeom );
|
||||
if ( currentGeom.getClass() == com.vividsolutions.jts.geom.LineString.class ) {
|
||||
pgCollections[i] = convertJTSLineString( (com.vividsolutions.jts.geom.LineString) currentGeom );
|
||||
}
|
||||
else if ( currentGeom.getClass() == com.vividsolutions.jts.geom.LinearRing.class ) {
|
||||
pgCollections[i] = convertJTSLineStringToLinearRing( (com.vividsolutions.jts.geom.LinearRing) currentGeom );
|
||||
}
|
||||
else if ( currentGeom.getClass() == com.vividsolutions.jts.geom.MultiLineString.class ) {
|
||||
pgCollections[i] = convertJTSMultiLineString( (com.vividsolutions.jts.geom.MultiLineString) currentGeom );
|
||||
}
|
||||
else if ( currentGeom.getClass() == com.vividsolutions.jts.geom.MultiPoint.class ) {
|
||||
pgCollections[i] = convertJTSMultiPoint( (com.vividsolutions.jts.geom.MultiPoint) currentGeom );
|
||||
}
|
||||
else if ( currentGeom.getClass() == com.vividsolutions.jts.geom.MultiPolygon.class ) {
|
||||
pgCollections[i] = convertJTSMultiPolygon( (com.vividsolutions.jts.geom.MultiPolygon) currentGeom );
|
||||
}
|
||||
else if ( currentGeom.getClass() == com.vividsolutions.jts.geom.Point.class ) {
|
||||
pgCollections[i] = convertJTSPoint( (com.vividsolutions.jts.geom.Point) currentGeom );
|
||||
}
|
||||
else if ( currentGeom.getClass() == com.vividsolutions.jts.geom.Polygon.class ) {
|
||||
pgCollections[i] = convertJTSPolygon( (com.vividsolutions.jts.geom.Polygon) currentGeom );
|
||||
}
|
||||
else if ( currentGeom.getClass() == com.vividsolutions.jts.geom.GeometryCollection.class ) {
|
||||
pgCollections[i] = convertJTSGeometryCollection( (com.vividsolutions.jts.geom.GeometryCollection) currentGeom );
|
||||
}
|
||||
}
|
||||
GeometryCollection gc = new GeometryCollection( pgCollections );
|
||||
gc.setSrid( collection.getSRID() );
|
||||
return gc;
|
||||
}
|
||||
|
||||
|
||||
private Point[] toPoints(Coordinate[] coordinates) {
|
||||
Point[] points = new Point[coordinates.length];
|
||||
for ( int i = 0; i < coordinates.length; i++ ) {
|
||||
Coordinate c = coordinates[i];
|
||||
Point pt;
|
||||
if ( Double.isNaN( c.z ) ) {
|
||||
pt = new Point( c.x, c.y );
|
||||
}
|
||||
else {
|
||||
pt = new Point( c.x, c.y, c.z );
|
||||
}
|
||||
if ( c instanceof MCoordinate ) {
|
||||
MCoordinate mc = (MCoordinate) c;
|
||||
if ( !Double.isNaN( mc.m ) ) {
|
||||
pt.setM( mc.m );
|
||||
}
|
||||
}
|
||||
points[i] = pt;
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,284 +0,0 @@
|
|||
/*
|
||||
* This file is part of Hibernate Spatial, an extension to the
|
||||
* hibernate ORM solution for spatial (geographic) data.
|
||||
*
|
||||
* Copyright © 2007-2012 Geovise BVBA
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package org.hibernate.spatial.dialect.postgis;
|
||||
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import org.postgis.GeometryCollection;
|
||||
import org.postgis.MultiLineString;
|
||||
import org.postgis.MultiPoint;
|
||||
import org.postgis.MultiPolygon;
|
||||
import org.postgis.PGboxbase;
|
||||
import org.postgis.PGgeometry;
|
||||
import org.postgis.Point;
|
||||
import org.postgis.Polygon;
|
||||
|
||||
import org.hibernate.spatial.dialect.AbstractGeometryValueExtractor;
|
||||
import org.hibernate.spatial.jts.mgeom.MCoordinate;
|
||||
import org.hibernate.spatial.jts.mgeom.MLineString;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
|
||||
/**
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 7/27/11
|
||||
*/
|
||||
public class PGGeometryValueExtractor<X> extends AbstractGeometryValueExtractor<X> {
|
||||
|
||||
public PGGeometryValueExtractor(JavaTypeDescriptor<X> javaDescriptor) {
|
||||
super( javaDescriptor , PGGeometryTypeDescriptor.INSTANCE);
|
||||
}
|
||||
|
||||
public Geometry toJTS(Object object) {
|
||||
if ( object == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// in some cases, Postgis returns not PGgeometry objects
|
||||
// but org.postgis.Geometry instances.
|
||||
// This has been observed when retrieving GeometryCollections
|
||||
// as the result of an SQL-operation such as Union.
|
||||
if ( object instanceof org.postgis.Geometry ) {
|
||||
object = new PGgeometry( (org.postgis.Geometry) object );
|
||||
}
|
||||
|
||||
if ( object instanceof PGgeometry ) {
|
||||
PGgeometry geom = (PGgeometry) object;
|
||||
com.vividsolutions.jts.geom.Geometry out = null;
|
||||
switch ( geom.getGeoType() ) {
|
||||
case org.postgis.Geometry.POINT:
|
||||
out = convertPoint( (org.postgis.Point) geom.getGeometry() );
|
||||
break;
|
||||
case org.postgis.Geometry.LINESTRING:
|
||||
out = convertLineString(
|
||||
(org.postgis.LineString) geom
|
||||
.getGeometry()
|
||||
);
|
||||
break;
|
||||
case org.postgis.Geometry.POLYGON:
|
||||
out = convertPolygon( (org.postgis.Polygon) geom.getGeometry() );
|
||||
break;
|
||||
case org.postgis.Geometry.MULTILINESTRING:
|
||||
out = convertMultiLineString(
|
||||
(org.postgis.MultiLineString) geom
|
||||
.getGeometry()
|
||||
);
|
||||
break;
|
||||
case org.postgis.Geometry.MULTIPOINT:
|
||||
out = convertMultiPoint(
|
||||
(org.postgis.MultiPoint) geom
|
||||
.getGeometry()
|
||||
);
|
||||
break;
|
||||
case org.postgis.Geometry.MULTIPOLYGON:
|
||||
out = convertMultiPolygon(
|
||||
(org.postgis.MultiPolygon) geom
|
||||
.getGeometry()
|
||||
);
|
||||
break;
|
||||
case org.postgis.Geometry.GEOMETRYCOLLECTION:
|
||||
out = convertGeometryCollection(
|
||||
(org.postgis.GeometryCollection) geom
|
||||
.getGeometry()
|
||||
);
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException( "Unknown type of PGgeometry" );
|
||||
}
|
||||
out.setSRID( geom.getGeometry().srid );
|
||||
return out;
|
||||
}
|
||||
else if ( object instanceof org.postgis.PGboxbase ) {
|
||||
return convertBox( (org.postgis.PGboxbase) object );
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException(
|
||||
"Can't convert object of type "
|
||||
+ object.getClass().getCanonicalName()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Geometry convertBox(PGboxbase box) {
|
||||
Point ll = box.getLLB();
|
||||
Point ur = box.getURT();
|
||||
Coordinate[] ringCoords = new Coordinate[5];
|
||||
if ( box instanceof org.postgis.PGbox2d ) {
|
||||
ringCoords[0] = new Coordinate( ll.x, ll.y );
|
||||
ringCoords[1] = new Coordinate( ur.x, ll.y );
|
||||
ringCoords[2] = new Coordinate( ur.x, ur.y );
|
||||
ringCoords[3] = new Coordinate( ll.x, ur.y );
|
||||
ringCoords[4] = new Coordinate( ll.x, ll.y );
|
||||
}
|
||||
else {
|
||||
ringCoords[0] = new Coordinate( ll.x, ll.y, ll.z );
|
||||
ringCoords[1] = new Coordinate( ur.x, ll.y, ll.z );
|
||||
ringCoords[2] = new Coordinate( ur.x, ur.y, ur.z );
|
||||
ringCoords[3] = new Coordinate( ll.x, ur.y, ur.z );
|
||||
ringCoords[4] = new Coordinate( ll.x, ll.y, ll.z );
|
||||
}
|
||||
com.vividsolutions.jts.geom.LinearRing shell = getGeometryFactory()
|
||||
.createLinearRing( ringCoords );
|
||||
return getGeometryFactory().createPolygon( shell, null );
|
||||
}
|
||||
|
||||
private Geometry convertGeometryCollection(GeometryCollection collection) {
|
||||
org.postgis.Geometry[] geometries = collection.getGeometries();
|
||||
com.vividsolutions.jts.geom.Geometry[] jtsGeometries = new com.vividsolutions.jts.geom.Geometry[geometries.length];
|
||||
for ( int i = 0; i < geometries.length; i++ ) {
|
||||
jtsGeometries[i] = toJTS( geometries[i] );
|
||||
//TODO - refactor this so the following line is not necessary
|
||||
jtsGeometries[i].setSRID( 0 ); // convert2JTS sets SRIDs, but constituent geometries in a collection must have srid == 0
|
||||
}
|
||||
com.vividsolutions.jts.geom.GeometryCollection jtsGCollection = getGeometryFactory()
|
||||
.createGeometryCollection( jtsGeometries );
|
||||
return jtsGCollection;
|
||||
}
|
||||
|
||||
private Geometry convertMultiPolygon(MultiPolygon pgMultiPolygon) {
|
||||
com.vividsolutions.jts.geom.Polygon[] polygons = new com.vividsolutions.jts.geom.Polygon[pgMultiPolygon
|
||||
.numPolygons()];
|
||||
|
||||
for ( int i = 0; i < polygons.length; i++ ) {
|
||||
Polygon pgPolygon = pgMultiPolygon.getPolygon( i );
|
||||
polygons[i] = (com.vividsolutions.jts.geom.Polygon) convertPolygon( pgPolygon );
|
||||
}
|
||||
|
||||
com.vividsolutions.jts.geom.MultiPolygon out = getGeometryFactory()
|
||||
.createMultiPolygon( polygons );
|
||||
return out;
|
||||
}
|
||||
|
||||
private Geometry convertMultiPoint(MultiPoint pgMultiPoint) {
|
||||
com.vividsolutions.jts.geom.Point[] points = new com.vividsolutions.jts.geom.Point[pgMultiPoint
|
||||
.numPoints()];
|
||||
|
||||
for ( int i = 0; i < points.length; i++ ) {
|
||||
points[i] = convertPoint( pgMultiPoint.getPoint( i ) );
|
||||
}
|
||||
com.vividsolutions.jts.geom.MultiPoint out = getGeometryFactory()
|
||||
.createMultiPoint( points );
|
||||
out.setSRID( pgMultiPoint.srid );
|
||||
return out;
|
||||
}
|
||||
|
||||
private com.vividsolutions.jts.geom.Geometry convertMultiLineString(
|
||||
MultiLineString mlstr) {
|
||||
com.vividsolutions.jts.geom.MultiLineString out;
|
||||
if ( mlstr.haveMeasure ) {
|
||||
MLineString[] lstrs = new MLineString[mlstr.numLines()];
|
||||
for ( int i = 0; i < mlstr.numLines(); i++ ) {
|
||||
MCoordinate[] coordinates = toJTSCoordinates(
|
||||
mlstr.getLine( i )
|
||||
.getPoints()
|
||||
);
|
||||
lstrs[i] = getGeometryFactory().createMLineString( coordinates );
|
||||
}
|
||||
out = getGeometryFactory().createMultiMLineString( lstrs );
|
||||
}
|
||||
else {
|
||||
com.vividsolutions.jts.geom.LineString[] lstrs = new com.vividsolutions.jts.geom.LineString[mlstr
|
||||
.numLines()];
|
||||
for ( int i = 0; i < mlstr.numLines(); i++ ) {
|
||||
lstrs[i] = getGeometryFactory().createLineString(
|
||||
toJTSCoordinates( mlstr.getLine( i ).getPoints() )
|
||||
);
|
||||
}
|
||||
out = getGeometryFactory().createMultiLineString( lstrs );
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
private com.vividsolutions.jts.geom.Geometry convertPolygon(
|
||||
Polygon polygon) {
|
||||
com.vividsolutions.jts.geom.LinearRing shell = getGeometryFactory()
|
||||
.createLinearRing(
|
||||
toJTSCoordinates( polygon.getRing( 0 ).getPoints() )
|
||||
);
|
||||
com.vividsolutions.jts.geom.Polygon out = null;
|
||||
if ( polygon.numRings() > 1 ) {
|
||||
com.vividsolutions.jts.geom.LinearRing[] rings = new com.vividsolutions.jts.geom.LinearRing[polygon
|
||||
.numRings() - 1];
|
||||
for ( int r = 1; r < polygon.numRings(); r++ ) {
|
||||
rings[r - 1] = getGeometryFactory().createLinearRing(
|
||||
toJTSCoordinates( polygon.getRing( r ).getPoints() )
|
||||
);
|
||||
}
|
||||
out = getGeometryFactory().createPolygon( shell, rings );
|
||||
}
|
||||
else {
|
||||
out = getGeometryFactory().createPolygon( shell, null );
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
private com.vividsolutions.jts.geom.Point convertPoint(Point pnt) {
|
||||
com.vividsolutions.jts.geom.Point g = getGeometryFactory().createPoint(
|
||||
this.toJTSCoordinate( pnt )
|
||||
);
|
||||
return g;
|
||||
}
|
||||
|
||||
private com.vividsolutions.jts.geom.LineString convertLineString(
|
||||
org.postgis.LineString lstr) {
|
||||
com.vividsolutions.jts.geom.LineString out = lstr.haveMeasure ? getGeometryFactory()
|
||||
.createMLineString( toJTSCoordinates( lstr.getPoints() ) )
|
||||
: getGeometryFactory().createLineString(
|
||||
toJTSCoordinates( lstr.getPoints() )
|
||||
);
|
||||
return out;
|
||||
}
|
||||
|
||||
private MCoordinate[] toJTSCoordinates(Point[] points) {
|
||||
MCoordinate[] coordinates = new MCoordinate[points.length];
|
||||
for ( int i = 0; i < points.length; i++ ) {
|
||||
coordinates[i] = this.toJTSCoordinate( points[i] );
|
||||
}
|
||||
return coordinates;
|
||||
}
|
||||
|
||||
private MCoordinate toJTSCoordinate(Point pt) {
|
||||
MCoordinate mc;
|
||||
if ( pt.dimension == 2 ) {
|
||||
mc = pt.haveMeasure ? MCoordinate.create2dWithMeasure(
|
||||
pt.getX(), pt
|
||||
.getY(), pt.getM()
|
||||
) : MCoordinate.create2d(
|
||||
pt.getX(), pt
|
||||
.getY()
|
||||
);
|
||||
}
|
||||
else {
|
||||
mc = pt.haveMeasure ? MCoordinate.create3dWithMeasure(
|
||||
pt.getX(), pt
|
||||
.getY(), pt.getZ(), pt.getM()
|
||||
) : MCoordinate.create3d(
|
||||
pt
|
||||
.getX(), pt.getY(), pt.getZ()
|
||||
);
|
||||
}
|
||||
return mc;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -40,7 +40,7 @@ abstract class AbstractEncoder<G extends Geometry> implements Encoder<G> {
|
|||
nativeGeom.setHasMValues();
|
||||
}
|
||||
|
||||
CountingPointSequenceBuilder coordinates = new CountingPointSequenceBuilder(geom.getDimensionalFlag());
|
||||
CountingPointSequenceBuilder coordinates = new CountingPointSequenceBuilder(geom.getDimensionalFlag(), geom.getCrsId());
|
||||
List<Figure> figures = new ArrayList<Figure>();
|
||||
List<Shape> shapes = new ArrayList<Shape>();
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.hibernate.spatial.dialect.sqlserver.convertors;
|
||||
|
||||
import org.geolatte.geom.*;
|
||||
import org.geolatte.geom.crs.CrsId;
|
||||
|
||||
/**
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
|
@ -11,8 +12,8 @@ public class CountingPointSequenceBuilder implements PointSequenceBuilder {
|
|||
final private PointSequenceBuilder delegate;
|
||||
private int num = 0;
|
||||
|
||||
public CountingPointSequenceBuilder(DimensionalFlag df) {
|
||||
delegate = PointSequenceBuilders.variableSized(df);
|
||||
public CountingPointSequenceBuilder(DimensionalFlag df, CrsId crsId) {
|
||||
delegate = PointSequenceBuilders.variableSized(df, crsId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -50,7 +51,12 @@ public class CountingPointSequenceBuilder implements PointSequenceBuilder {
|
|||
return delegate.getDimensionalFlag();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public CrsId getCrsId() {
|
||||
return delegate.getCrsId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PointSequence toPointSequence() {
|
||||
return delegate.toPointSequence();
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ package org.hibernate.spatial.dialect.sqlserver.convertors;
|
|||
|
||||
import org.geolatte.geom.LineString;
|
||||
import org.geolatte.geom.PointSequence;
|
||||
import org.geolatte.geom.crs.CrsId;
|
||||
|
||||
class LineStringDecoder extends AbstractDecoder<LineString> {
|
||||
|
||||
|
@ -53,6 +52,6 @@ class LineStringDecoder extends AbstractDecoder<LineString> {
|
|||
|
||||
protected LineString createLineString(SqlServerGeometry nativeGeom, IndexRange pntIndexRange) {
|
||||
PointSequence coordinates = nativeGeom.coordinateRange( pntIndexRange );
|
||||
return new LineString(coordinates, CrsId.valueOf(nativeGeom.getSrid()));
|
||||
return new LineString(coordinates);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ package org.hibernate.spatial.dialect.sqlserver.convertors;
|
|||
import org.geolatte.geom.DimensionalFlag;
|
||||
import org.geolatte.geom.Point;
|
||||
import org.geolatte.geom.PointSequence;
|
||||
import org.geolatte.geom.crs.CrsId;
|
||||
|
||||
/**
|
||||
* @author Karel Maesen, Geovise BVBA.
|
||||
|
@ -60,7 +59,7 @@ class PointDecoder extends AbstractDecoder<Point> {
|
|||
private Point createPoint(SqlServerGeometry nativeGeom, int pntOffset) {
|
||||
DimensionalFlag df = DimensionalFlag.valueOf(nativeGeom.hasZValues(), nativeGeom.hasMValues());
|
||||
PointSequence pointSequence = nativeGeom.coordinateRange(new IndexRange(pntOffset, pntOffset + 1));
|
||||
return new Point(pointSequence, CrsId.valueOf(nativeGeom.getSrid()));
|
||||
return new Point(pointSequence);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ package org.hibernate.spatial.dialect.sqlserver.convertors;
|
|||
import org.geolatte.geom.LinearRing;
|
||||
import org.geolatte.geom.PointSequence;
|
||||
import org.geolatte.geom.Polygon;
|
||||
import org.geolatte.geom.crs.CrsId;
|
||||
|
||||
/**
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
|
@ -67,7 +66,7 @@ class PolygonDecoder extends AbstractDecoder<Polygon> {
|
|||
|
||||
private LinearRing toLinearRing(SqlServerGeometry nativeGeom, IndexRange range) {
|
||||
PointSequence pointSequence = nativeGeom.coordinateRange(range);
|
||||
return new LinearRing(pointSequence, CrsId.valueOf(nativeGeom.getSrid()));
|
||||
return new LinearRing(pointSequence);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.geolatte.geom.PointCollection;
|
|||
import org.geolatte.geom.PointSequence;
|
||||
import org.geolatte.geom.PointSequenceBuilder;
|
||||
import org.geolatte.geom.PointSequenceBuilders;
|
||||
import org.geolatte.geom.crs.CrsId;
|
||||
|
||||
import org.hibernate.spatial.jts.mgeom.MCoordinate;
|
||||
|
||||
|
@ -123,17 +124,17 @@ public class SqlServerGeometry {
|
|||
}
|
||||
|
||||
void copyCoordinate(int index, double[] coords, DimensionalFlag df) {
|
||||
coords[0] = points[2 * index];
|
||||
coords[1] = points[2 * index + 1];
|
||||
if (hasZValues()) {
|
||||
assert(df.is3D());
|
||||
coords[df.Z] = zValues[index];
|
||||
}
|
||||
if (hasMValues()) {
|
||||
assert (df.isMeasured());
|
||||
coords[df.M] = mValues[index];
|
||||
}
|
||||
}
|
||||
coords[0] = points[2 * index];
|
||||
coords[1] = points[2 * index + 1];
|
||||
if ( hasZValues() ) {
|
||||
assert ( df.is3D() );
|
||||
coords[df.Z] = zValues[index];
|
||||
}
|
||||
if ( hasMValues() ) {
|
||||
assert ( df.isMeasured() );
|
||||
coords[df.M] = mValues[index];
|
||||
}
|
||||
}
|
||||
|
||||
boolean isParentShapeOf(int parent, int child) {
|
||||
return getShape( child ).parentOffset == parent;
|
||||
|
@ -188,15 +189,19 @@ public class SqlServerGeometry {
|
|||
}
|
||||
|
||||
PointSequence coordinateRange(IndexRange range) {
|
||||
DimensionalFlag df = DimensionalFlag.valueOf(hasZValues(), hasMValues());
|
||||
PointSequenceBuilder psBuilder = PointSequenceBuilders.fixedSized(range.end - range.start, df);
|
||||
double[] coordinates = new double[df.getCoordinateDimension()];
|
||||
for (int idx = range.start, i = 0; idx < range.end; idx++, i++) {
|
||||
copyCoordinate(idx, coordinates, df);
|
||||
psBuilder.add(coordinates);
|
||||
}
|
||||
return psBuilder.toPointSequence();
|
||||
}
|
||||
DimensionalFlag df = DimensionalFlag.valueOf( hasZValues(), hasMValues() );
|
||||
PointSequenceBuilder psBuilder = PointSequenceBuilders.fixedSized(
|
||||
range.end - range.start,
|
||||
df,
|
||||
CrsId.valueOf( getSrid() )
|
||||
);
|
||||
double[] coordinates = new double[df.getCoordinateDimension()];
|
||||
for ( int idx = range.start, i = 0; idx < range.end; idx++, i++ ) {
|
||||
copyCoordinate( idx, coordinates, df );
|
||||
psBuilder.add( coordinates );
|
||||
}
|
||||
return psBuilder.toPointSequence();
|
||||
}
|
||||
|
||||
private Coordinate[] createCoordinateArray(int size) {
|
||||
if ( hasMValues() ) {
|
||||
|
@ -217,13 +222,13 @@ public class SqlServerGeometry {
|
|||
}
|
||||
|
||||
void setCoordinate(int index, PointCollection coordinate) {
|
||||
points[2 * index] = coordinate.getX(index);
|
||||
points[2 * index + 1] = coordinate.getY(index);
|
||||
points[2 * index] = coordinate.getX( index );
|
||||
points[2 * index + 1] = coordinate.getY( index );
|
||||
if ( hasZValues() ) {
|
||||
zValues[index] = coordinate.getZ(index);
|
||||
zValues[index] = coordinate.getZ( index );
|
||||
}
|
||||
if ( hasMValues() ) {
|
||||
mValues[index] = coordinate.getM(index);
|
||||
mValues[index] = coordinate.getM( index );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.geolatte.geom.DimensionalFlag;
|
|||
import org.geolatte.geom.LineString;
|
||||
import org.geolatte.geom.PointCollection;
|
||||
import org.geolatte.geom.PointSequenceBuilders;
|
||||
import org.geolatte.geom.crs.CrsId;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect;
|
||||
|
@ -38,6 +39,8 @@ import static org.junit.Assert.assertTrue;
|
|||
@RequiresDialect(SqlServer2008SpatialDialect.class)
|
||||
public class LineStringConvertorTest extends AbstractConvertorTest {
|
||||
|
||||
CrsId WGS84 = CrsId.valueOf( 4326 );
|
||||
|
||||
@BeforeClassOnce
|
||||
public void beforeClass() {
|
||||
super.beforeClass();
|
||||
|
@ -67,26 +70,26 @@ public class LineStringConvertorTest extends AbstractConvertorTest {
|
|||
public void test_coordinates() {
|
||||
|
||||
PointCollection received = decodedGeoms.get( 5 ).getPoints();
|
||||
PointCollection expected = PointSequenceBuilders.fixedSized( 2, DimensionalFlag.XY ).add(10, 5).add(20,15).toPointSequence();
|
||||
PointCollection expected = PointSequenceBuilders.fixedSized( 2, DimensionalFlag.d2D, WGS84 ).add(10, 5).add(20,15).toPointSequence();
|
||||
assertPointCollectionEquality( received, expected );
|
||||
|
||||
received = decodedGeoms.get( 6 ).getPoints();
|
||||
expected = PointSequenceBuilders.fixedSized( 4, DimensionalFlag.XY).add(10,5).add(20,15).add(30.3, 22.4).add(10,30).toPointSequence();
|
||||
expected = PointSequenceBuilders.fixedSized( 4, DimensionalFlag.d2D, WGS84).add(10,5).add(20,15).add(30.3, 22.4).add(10,30).toPointSequence();
|
||||
assertPointCollectionEquality( received, expected );
|
||||
|
||||
|
||||
received = decodedGeoms.get( 7 ).getPoints();
|
||||
expected = PointSequenceBuilders.fixedSized( 2, DimensionalFlag.XYZ).add(10,5,0).add(20,15,3).toPointSequence();
|
||||
expected = PointSequenceBuilders.fixedSized( 2, DimensionalFlag.d3D, WGS84).add(10,5,0).add(20,15,3).toPointSequence();
|
||||
assertPointCollectionEquality( received, expected );
|
||||
|
||||
//case 9
|
||||
received = decodedGeoms.get( 9 ).getPoints();
|
||||
expected = PointSequenceBuilders.fixedSized( 4, DimensionalFlag.XYZ).add(10,5,1).add(20,15,2).add(30.3, 22.4,5).add(10,30,2).toPointSequence();
|
||||
expected = PointSequenceBuilders.fixedSized( 4, DimensionalFlag.d3D, WGS84).add(10,5,1).add(20,15,2).add(30.3, 22.4,5).add(10,30,2).toPointSequence();
|
||||
assertPointCollectionEquality( received, expected );
|
||||
|
||||
//case 10
|
||||
received = decodedGeoms.get( 10 ).getPoints();
|
||||
expected = PointSequenceBuilders.fixedSized( 4, DimensionalFlag.XYZM).add(10,5,1,1).add(20,15,2,3).add(30.3, 22.4,5,10).add(10,30,2,12).toPointSequence();
|
||||
expected = PointSequenceBuilders.fixedSized( 4, DimensionalFlag.d3DM, WGS84).add(10,5,1,1).add(20,15,2,3).add(30.3, 22.4,5,10).add(10,30,2,12).toPointSequence();
|
||||
assertPointCollectionEquality( received, expected );
|
||||
|
||||
}
|
||||
|
|
|
@ -63,13 +63,13 @@ public class PointConvertorTest extends AbstractConvertorTest {
|
|||
@Test
|
||||
public void test_coordinates() {
|
||||
Point expected;
|
||||
expected = Points.create( 10.0, 5.0);
|
||||
expected = Points.create2D( 10.0, 5.0);
|
||||
assertEquals( expected, decodedGeoms.get( 1 ).getPointN(0) );
|
||||
expected = Points.create(52.25, 2.53, CrsId.valueOf(4326));
|
||||
expected = Points.create2D(52.25, 2.53, CrsId.valueOf(4326));
|
||||
assertEquals( expected, decodedGeoms.get( 2 ).getPointN( 0 ) );
|
||||
expected = Points.create(150000.0, 200000.0, CrsId.valueOf(31370));
|
||||
expected = Points.create2D(150000.0, 200000.0, CrsId.valueOf(31370));
|
||||
assertEquals( expected, decodedGeoms.get( 3 ).getPointN( 0 ) );
|
||||
expected = Points.create(10.0, 2.0, 1.0, 3.0, CrsId.valueOf(4326));
|
||||
expected = Points.create3DM(10.0, 2.0, 1.0, 3.0, CrsId.valueOf(4326));
|
||||
assertEquals( expected, decodedGeoms.get( 4 ).getPointN( 0 ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -73,11 +73,10 @@ public class GeomEntity {
|
|||
}
|
||||
|
||||
public static GeomEntity createFrom(TestDataElement element) throws ParseException {
|
||||
WktDecoder<org.geolatte.geom.Geometry> decoder = Wkt.newWktDecoder( Wkt.Dialect.POSTGIS_EWKT_1 );
|
||||
Geometry geom = JTS.to( decoder.decode( element.wkt ) );
|
||||
WktDecoder decoder = Wkt.newDecoder( Wkt.Dialect.POSTGIS_EWKT_1 );
|
||||
Geometry geom = JTS.to( decoder.decode( element.wkt) );
|
||||
GeomEntity result = new GeomEntity();
|
||||
result.setId( element.id );
|
||||
geom.setSRID( element.srid );
|
||||
result.setGeom( geom );
|
||||
result.setType( element.type );
|
||||
return result;
|
||||
|
|
|
@ -21,21 +21,31 @@
|
|||
|
||||
package org.hibernate.spatial.testing;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.StringWriter;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.commons.dbcp.BasicDataSource;
|
||||
import org.geolatte.geom.Geometry;
|
||||
import org.geolatte.geom.codec.Wkt;
|
||||
import org.geolatte.geom.codec.WktDecodeException;
|
||||
import org.geolatte.geom.codec.WktDecoder;
|
||||
|
||||
import org.hibernate.spatial.Log;
|
||||
import org.hibernate.spatial.LogFactory;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.io.*;
|
||||
import java.sql.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* <p>Unit testsuite-suite support class.</p>
|
||||
*
|
||||
|
@ -347,13 +357,11 @@ public class DataSourceUtils {
|
|||
*/
|
||||
public Map<Integer, Geometry> expectedGeoms(String type, TestData testData) {
|
||||
Map<Integer, Geometry> result = new HashMap<Integer, Geometry>();
|
||||
WktDecoder<org.geolatte.geom.Geometry> decoder = Wkt.newWktDecoder();
|
||||
WktDecoder decoder = Wkt.newDecoder();
|
||||
for ( TestDataElement testDataElement : testData ) {
|
||||
if ( testDataElement.type.equalsIgnoreCase( type ) ) {
|
||||
try {
|
||||
//to ensure expected geometries have the correct SRID, we prepend to the WKT string
|
||||
String wkt = "SRID=" + testDataElement.srid + ";"+testDataElement.wkt;
|
||||
result.put( testDataElement.id, decoder.decode( wkt ) );
|
||||
result.put( testDataElement.id, decoder.decode( testDataElement.wkt ) );
|
||||
}
|
||||
catch ( WktDecodeException e ) {
|
||||
System.out
|
||||
|
|
|
@ -31,14 +31,12 @@ public class TestDataElement {
|
|||
|
||||
final public String wkt;
|
||||
final public int id;
|
||||
final public int srid;
|
||||
final public String type;
|
||||
|
||||
protected TestDataElement(int id, String type, String wkt, int srid) {
|
||||
protected TestDataElement(int id, String type, String wkt) {
|
||||
this.wkt = wkt;
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
this.srid = srid;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -61,8 +61,7 @@ public class TestDataReader {
|
|||
int id = Integer.valueOf( element.selectSingleNode( "id" ).getText() );
|
||||
String type = element.selectSingleNode( "type" ).getText();
|
||||
String wkt = element.selectSingleNode( "wkt" ).getText();
|
||||
int srid = Integer.valueOf( element.selectSingleNode( "srid" ).getText() );
|
||||
TestDataElement testDataElement = new TestDataElement( id, type, wkt, srid );
|
||||
TestDataElement testDataElement = new TestDataElement( id, type, wkt);
|
||||
testDataElements.add( testDataElement );
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package org.hibernate.spatial.testing;
|
||||
|
||||
/**
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 1/24/13
|
||||
*/
|
||||
public class WktUtility {
|
||||
|
||||
static public int getSRID(String wkt) {
|
||||
String[] tokens = wkt.split( ";" );
|
||||
if (tokens.length == 1){
|
||||
return 0;
|
||||
}
|
||||
String[] sridTokens = tokens[0].split("=");
|
||||
if ( sridTokens.length < 2 ) {
|
||||
throw new IllegalArgumentException( "Can't parse " + wkt );
|
||||
}
|
||||
return Integer.parseInt( sridTokens[1] );
|
||||
}
|
||||
|
||||
static public String getWkt(String wkt) {
|
||||
String[] tokens = wkt.split(";");
|
||||
if ( tokens.length > 1 ) {
|
||||
return tokens[1];
|
||||
} else {
|
||||
return wkt;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -26,9 +26,9 @@ 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.JTSGeometryJavaTypeDescriptor;
|
||||
import org.hibernate.spatial.dialect.h2geodb.GeoDBValueExtractor;
|
||||
import org.hibernate.spatial.dialect.h2geodb.GeoDbWkb;
|
||||
import org.hibernate.spatial.testing.AbstractExpectationsFactory;
|
||||
import org.hibernate.spatial.testing.NativeSQLStatement;
|
||||
|
||||
|
@ -41,43 +41,20 @@ import org.hibernate.spatial.testing.NativeSQLStatement;
|
|||
*/
|
||||
public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
||||
|
||||
private final GeoDBValueExtractor decoder = new GeoDBValueExtractor( JTSGeometryJavaTypeDescriptor.INSTANCE );
|
||||
|
||||
public GeoDBExpectationsFactory(GeoDBDataSourceUtils dataSourceUtils) {
|
||||
super( dataSourceUtils );
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeAsBinaryStatement()
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeAsBinaryStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_AsEWKB(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeAsTextStatement()
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeAsTextStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_AsText(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeBoundaryStatement()
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeBoundaryStatement() {
|
||||
throw new UnsupportedOperationException(
|
||||
|
@ -85,13 +62,6 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeBufferStatement(java.lang.Double)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeBufferStatement(Double distance) {
|
||||
return createNativeSQLStatement(
|
||||
|
@ -100,13 +70,6 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeContainsStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeContainsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
|
@ -115,13 +78,6 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeConvexHullStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeConvexHullStatement(Geometry geom) {
|
||||
throw new UnsupportedOperationException(
|
||||
|
@ -129,13 +85,6 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeCrossesStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
|
@ -144,13 +93,6 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeDifferenceStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDifferenceStatement(Geometry geom) {
|
||||
throw new UnsupportedOperationException(
|
||||
|
@ -158,13 +100,6 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeDimensionSQL()
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDimensionSQL() {
|
||||
throw new UnsupportedOperationException(
|
||||
|
@ -172,13 +107,6 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeDisjointStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
|
@ -439,17 +367,9 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.hibernatespatial.test.AbstractExpectationsFactory#decode(java.lang
|
||||
* .Object)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected Geometry decode(Object o) {
|
||||
return decoder.toJTS( o );
|
||||
return JTS.to( GeoDbWkb.from( o ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ package org.hibernate.spatial.testing.dialects.h2geodb;
|
|||
|
||||
import org.hibernate.spatial.testing.SQLExpressionTemplate;
|
||||
import org.hibernate.spatial.testing.TestDataElement;
|
||||
import org.hibernate.spatial.testing.WktUtility;
|
||||
|
||||
/**
|
||||
* This is the template for insert SQL statements into the geomtest test table
|
||||
|
@ -41,10 +42,14 @@ public class GeoDBExpressionTemplate implements SQLExpressionTemplate {
|
|||
* 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, testDataElement.id, testDataElement.type,
|
||||
testDataElement.wkt, testDataElement.srid
|
||||
.format( SQL_TEMPLATE,
|
||||
testDataElement.id,
|
||||
testDataElement.type,
|
||||
wkt,
|
||||
srid
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,9 +26,10 @@ package org.hibernate.spatial.testing.dialects.h2geodb;
|
|||
|
||||
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.JTSGeometryJavaTypeDescriptor;
|
||||
import org.hibernate.spatial.dialect.h2geodb.GeoDBValueExtractor;
|
||||
import org.hibernate.spatial.testing.AbstractExpectationsFactory;
|
||||
import org.hibernate.spatial.testing.NativeSQLStatement;
|
||||
|
||||
|
@ -41,43 +42,20 @@ import org.hibernate.spatial.testing.NativeSQLStatement;
|
|||
*/
|
||||
public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory {
|
||||
|
||||
private final GeoDBValueExtractor decoder = new GeoDBValueExtractor( JTSGeometryJavaTypeDescriptor.INSTANCE );
|
||||
|
||||
public GeoDBNoSRIDExpectationsFactory(GeoDBDataSourceUtils dataSourceUtils) {
|
||||
super( dataSourceUtils );
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeAsBinaryStatement()
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeAsBinaryStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_AsEWKB(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeAsTextStatement()
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeAsTextStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_AsText(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeBoundaryStatement()
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeBoundaryStatement() {
|
||||
throw new UnsupportedOperationException(
|
||||
|
@ -85,13 +63,6 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeBufferStatement(java.lang.Double)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeBufferStatement(Double distance) {
|
||||
return createNativeSQLStatement(
|
||||
|
@ -100,13 +71,6 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeContainsStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeContainsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
|
@ -115,13 +79,6 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeConvexHullStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeConvexHullStatement(Geometry geom) {
|
||||
throw new UnsupportedOperationException(
|
||||
|
@ -129,13 +86,6 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeCrossesStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeCrossesStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
|
@ -144,13 +94,6 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeDifferenceStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDifferenceStatement(Geometry geom) {
|
||||
throw new UnsupportedOperationException(
|
||||
|
@ -158,13 +101,6 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeDimensionSQL()
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDimensionSQL() {
|
||||
throw new UnsupportedOperationException(
|
||||
|
@ -172,13 +108,6 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeDisjointStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDisjointStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
|
@ -197,13 +126,6 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
return createNativeSQLStatement( "select t.id, (st_srid(t.geom) = " + srid + ") from GeomTest t where ST_SRID(t.geom) = " + srid );
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeDistanceStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeDistanceStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
|
@ -212,25 +134,11 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeEnvelopeStatement()
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeEnvelopeStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_Envelope(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeEqualsStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeEqualsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
|
@ -239,13 +147,6 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeFilterStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeFilterStatement(Geometry geom) {
|
||||
throw new UnsupportedOperationException(
|
||||
|
@ -253,13 +154,6 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeGeomUnionStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeGeomUnionStatement(Geometry geom) {
|
||||
throw new UnsupportedOperationException(
|
||||
|
@ -267,25 +161,11 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeGeometryTypeStatement()
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeGeometryTypeStatement() {
|
||||
return createNativeSQLStatement( "select id, GeometryType(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeIntersectionStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIntersectionStatement(Geometry geom) {
|
||||
throw new UnsupportedOperationException(
|
||||
|
@ -293,13 +173,6 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeIntersectsStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIntersectsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
|
@ -308,13 +181,6 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeIsEmptyStatement()
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsEmptyStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_IsEmpty(geom) from GEOMTEST" );
|
||||
|
@ -325,25 +191,11 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
return createNativeSQLStatement( "select id, not ST_IsEmpty(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeIsSimpleStatement()
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeIsSimpleStatement() {
|
||||
return createNativeSQLStatement( "select id, ST_IsSimple(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeOverlapsStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeOverlapsStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
|
@ -352,14 +204,6 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeRelateStatement(com.vividsolutions.jts.geom.Geometry,
|
||||
* java.lang.String)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeRelateStatement(Geometry geom,
|
||||
String matrix) {
|
||||
|
@ -386,13 +230,6 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
return createNativeSQLStatement( "select id, ST_SRID(geom) from GEOMTEST" );
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeSymDifferenceStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeSymDifferenceStatement(
|
||||
Geometry geom) {
|
||||
|
@ -401,13 +238,6 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeTouchesStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeTouchesStatement(Geometry geom) {
|
||||
return createNativeSQLStatementAllWKTParams(
|
||||
|
@ -416,13 +246,6 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.hibernatespatial.test.AbstractExpectationsFactory#
|
||||
* createNativeWithinStatement(com.vividsolutions.jts.geom.Geometry)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected NativeSQLStatement createNativeWithinStatement(
|
||||
Geometry testPolygon) {
|
||||
|
@ -432,17 +255,8 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
|
|||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.hibernatespatial.test.AbstractExpectationsFactory#decode(java.lang
|
||||
* .Object)
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected Geometry decode(Object o) {
|
||||
return decoder.toJTS( o );
|
||||
return JTS.to( Wkb.fromWkb( ByteBuffer.from( (byte[]) o ) ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,9 +23,11 @@ package org.hibernate.spatial.testing.dialects.mysql;
|
|||
|
||||
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.codec.WkbDecoder;
|
||||
import org.geolatte.geom.jts.JTS;
|
||||
|
||||
import org.hibernate.spatial.JTSGeometryJavaTypeDescriptor;
|
||||
import org.hibernate.spatial.dialect.mysql.MySQLGeometryValueExtractor;
|
||||
import org.hibernate.spatial.testing.AbstractExpectationsFactory;
|
||||
import org.hibernate.spatial.testing.DataSourceUtils;
|
||||
import org.hibernate.spatial.testing.NativeSQLStatement;
|
||||
|
@ -39,8 +41,6 @@ import org.hibernate.spatial.testing.NativeSQLStatement;
|
|||
|
||||
public class MySQLExpectationsFactory extends AbstractExpectationsFactory {
|
||||
|
||||
private final MySQLGeometryValueExtractor decoder = new MySQLGeometryValueExtractor( JTSGeometryJavaTypeDescriptor.INSTANCE);
|
||||
|
||||
public MySQLExpectationsFactory(DataSourceUtils dataSourceUtils) {
|
||||
super( dataSourceUtils );
|
||||
}
|
||||
|
@ -245,7 +245,12 @@ public class MySQLExpectationsFactory extends AbstractExpectationsFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Geometry decode(Object o) {
|
||||
return decoder.toJTS( o );
|
||||
protected Geometry decode(Object bytes) {
|
||||
if ( bytes == null ) {
|
||||
return null;
|
||||
}
|
||||
ByteBuffer buffer = ByteBuffer.from( (byte[])bytes );
|
||||
WkbDecoder decoder = Wkb.newDecoder( Wkb.Dialect.MYSQL_WKB );
|
||||
return JTS.to( decoder.decode( buffer ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ package org.hibernate.spatial.testing.dialects.mysql;
|
|||
|
||||
import org.hibernate.spatial.testing.SQLExpressionTemplate;
|
||||
import org.hibernate.spatial.testing.TestDataElement;
|
||||
import org.hibernate.spatial.testing.WktUtility;
|
||||
|
||||
/**
|
||||
* This is the template for insert SQL statements into the geomtest test table for MySQL.
|
||||
|
@ -35,12 +36,14 @@ public class MySQLExpressionTemplate implements SQLExpressionTemplate {
|
|||
final String SQL_TEMPLATE = "insert into geomtest (id, type, geom) values (%d, '%s', GeomFromText('%s', %d))";
|
||||
|
||||
public String toInsertSql(TestDataElement testDataElement) {
|
||||
String wkt = WktUtility.getWkt( testDataElement.wkt );
|
||||
int srid = WktUtility.getSRID( testDataElement.wkt );
|
||||
return String.format(
|
||||
SQL_TEMPLATE,
|
||||
testDataElement.id,
|
||||
testDataElement.type,
|
||||
testDataElement.wkt,
|
||||
testDataElement.srid
|
||||
wkt,
|
||||
srid
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,11 +38,8 @@ public class MySQLTestSupport extends TestSupport {
|
|||
|
||||
@Override
|
||||
public TestData createTestData(BaseCoreFunctionalTestCase testcase) {
|
||||
if ( testcase.getClass().getCanonicalName().contains( "TestSpatialFunctions" ) ||
|
||||
testcase.getClass().getCanonicalName().contains( "TestSpatialRestrictions" ) ) {
|
||||
return TestData.fromFile( "mysql/test-mysql-functions-data-set.xml" );
|
||||
}
|
||||
return TestData.fromFile( "test-data-set.xml" );
|
||||
return TestData.fromFile( "mysql/test-mysql-functions-data-set.xml" );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -35,8 +35,8 @@ public class SDOTestDataElement extends TestDataElement {
|
|||
|
||||
public final String sdo;
|
||||
|
||||
public SDOTestDataElement(int id, String type, String wkt, int srid, String sdo) {
|
||||
super( id, type, wkt, srid );
|
||||
public SDOTestDataElement(int id, String type, String wkt, String sdo) {
|
||||
super( id, type, wkt);
|
||||
this.sdo = sdo;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,9 +37,8 @@ public class SDOTestDataReader extends TestDataReader {
|
|||
int id = Integer.valueOf( element.selectSingleNode( "id" ).getText() );
|
||||
String type = element.selectSingleNode( "type" ).getText();
|
||||
String wkt = element.selectSingleNode( "wkt" ).getText();
|
||||
int srid = Integer.valueOf( element.selectSingleNode( "srid" ).getText() );
|
||||
String sdo = element.selectSingleNode( "sdo" ).getText();
|
||||
TestDataElement testDataElement = new SDOTestDataElement( id, type, wkt, srid, sdo );
|
||||
TestDataElement testDataElement = new SDOTestDataElement( id, type, wkt, sdo );
|
||||
testDataElements.add( testDataElement );
|
||||
}
|
||||
|
||||
|
|
|
@ -23,9 +23,14 @@ package org.hibernate.spatial.testing.dialects.postgis;
|
|||
|
||||
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.codec.WkbDecoder;
|
||||
import org.geolatte.geom.jts.JTS;
|
||||
import org.postgresql.util.PGobject;
|
||||
|
||||
import org.hibernate.spatial.JTSGeometryJavaTypeDescriptor;
|
||||
import org.hibernate.spatial.dialect.postgis.PGGeometryValueExtractor;
|
||||
import org.hibernate.spatial.Log;
|
||||
import org.hibernate.spatial.LogFactory;
|
||||
import org.hibernate.spatial.testing.AbstractExpectationsFactory;
|
||||
import org.hibernate.spatial.testing.DataSourceUtils;
|
||||
import org.hibernate.spatial.testing.NativeSQLStatement;
|
||||
|
@ -37,7 +42,8 @@ import org.hibernate.spatial.testing.NativeSQLStatement;
|
|||
*/
|
||||
public class PostgisExpectationsFactory extends AbstractExpectationsFactory {
|
||||
|
||||
private final PGGeometryValueExtractor decoder = new PGGeometryValueExtractor( JTSGeometryJavaTypeDescriptor.INSTANCE);
|
||||
private static final Log LOG = LogFactory.make();
|
||||
|
||||
|
||||
public PostgisExpectationsFactory(DataSourceUtils utils) {
|
||||
super( utils );
|
||||
|
@ -245,9 +251,20 @@ public class PostgisExpectationsFactory extends AbstractExpectationsFactory {
|
|||
);
|
||||
}
|
||||
|
||||
//remove redundancy with toGeometry function in PGGeometryTypeDescriptor
|
||||
@Override
|
||||
protected Geometry decode(Object o) {
|
||||
return decoder.toJTS( o );
|
||||
protected Geometry decode(Object object) {
|
||||
ByteBuffer buffer = null;
|
||||
if (object instanceof PGobject ) {
|
||||
buffer = ByteBuffer.from( ( (PGobject) object ).getValue() );
|
||||
} else if ( object instanceof byte[] ) {
|
||||
byte[] bytes = (byte[]) object;
|
||||
ByteBuffer.from( bytes );
|
||||
} else {
|
||||
throw new IllegalStateException( "Received object of type " + object.getClass().getCanonicalName() );
|
||||
}
|
||||
WkbDecoder decoder = Wkb.newDecoder( Wkb.Dialect.POSTGIS_EWKB_1 );
|
||||
return JTS.to(decoder.decode( buffer));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,15 +31,14 @@ import org.hibernate.spatial.testing.TestDataElement;
|
|||
*/
|
||||
public class PostgisExpressionTemplate implements SQLExpressionTemplate {
|
||||
|
||||
final String SQL_TEMPLATE = "insert into geomtest (id, type, geom) values (%d, '%s', GeomFromText('%s', %d))";
|
||||
final String SQL_TEMPLATE = "insert into geomtest (id, type, geom) values (%d, '%s', GeomFromText('%s'))";
|
||||
|
||||
public String toInsertSql(TestDataElement testDataElement) {
|
||||
return String.format(
|
||||
SQL_TEMPLATE,
|
||||
testDataElement.id,
|
||||
testDataElement.type,
|
||||
testDataElement.wkt,
|
||||
testDataElement.srid
|
||||
testDataElement.wkt
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ package org.hibernate.spatial.testing.dialects.sqlserver;
|
|||
|
||||
import org.hibernate.spatial.testing.SQLExpressionTemplate;
|
||||
import org.hibernate.spatial.testing.TestDataElement;
|
||||
import org.hibernate.spatial.testing.WktUtility;
|
||||
|
||||
/**
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
|
@ -32,12 +33,14 @@ public class SQLServerExpressionTemplate implements SQLExpressionTemplate {
|
|||
final String SQL_TEMPLATE = "insert into geomtest (id, type, geom) values (%d, '%s', Geometry::STGeomFromText('%s', %d))";
|
||||
|
||||
public String toInsertSql(TestDataElement testDataElement) {
|
||||
int srid = WktUtility.getSRID( testDataElement.wkt );
|
||||
String wkt = WktUtility.getWkt( testDataElement.wkt );
|
||||
return String.format(
|
||||
SQL_TEMPLATE,
|
||||
testDataElement.id,
|
||||
testDataElement.type,
|
||||
testDataElement.wkt,
|
||||
testDataElement.srid
|
||||
wkt,
|
||||
srid
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,60 +10,51 @@ In MySQL these are stored as null objects.
|
|||
<Element>
|
||||
<id>1</id>
|
||||
<type>POINT</type>
|
||||
<wkt>POINT(10 5)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POINT(10 5)</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>2</id>
|
||||
<type>POINT</type>
|
||||
<wkt>POINT(52.25 2.53)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POINT(52.25 2.53)</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>3</id>
|
||||
<type>POINT</type>
|
||||
<wkt>POINT(51 12)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POINT(51 12)</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>4</id>
|
||||
<type>POINT</type>
|
||||
<wkt>POINT(10.0 2.0)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POINT(10.0 2.0)</wkt>
|
||||
</Element>
|
||||
|
||||
|
||||
<Element>
|
||||
<id>5</id>
|
||||
<type>LINESTRING</type>
|
||||
<wkt>LINESTRING(10.0 5.0, 20.0 15.0)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;LINESTRING(10.0 5.0, 20.0 15.0)</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>6</id>
|
||||
<type>LINESTRING</type>
|
||||
<wkt>LINESTRING(10.0 5.0, 20.0 15.0, 30.3 22.4, 10 30.0)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;LINESTRING(10.0 5.0, 20.0 15.0, 30.3 22.4, 10 30.0)</wkt>
|
||||
</Element>
|
||||
|
||||
|
||||
<Element>
|
||||
<id>16</id>
|
||||
<type>POLYGON</type>
|
||||
<wkt>POLYGON( (0 0, 0 10, 10 10, 10 0, 0 0) )</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POLYGON( (0 0, 0 10, 10 10, 10 0, 0 0) )</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>18</id>
|
||||
<type>POLYGON</type>
|
||||
<wkt>POLYGON( (0 0, 0 10, 10 10, 10 0, 0 0), (2 2, 2 5, 5 5,5 2, 2 2))</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POLYGON( (0 0, 0 10, 10 10, 10 0, 0 0), (2 2, 2 5, 5 5,5 2, 2 2))</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>19</id>
|
||||
<type>POLYGON</type>
|
||||
<wkt>POLYGON( (110 110, 110 120, 120 120, 120 110, 110 110) )</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POLYGON( (110 110, 110 120, 120 120, 120 110, 110 110) )</wkt>
|
||||
</Element>
|
||||
|
||||
</TestData>
|
||||
|
|
|
@ -26,14 +26,14 @@
|
|||
hibernate.test.new_metadata_mappings = true
|
||||
hibernate.connection.pool_size 5
|
||||
|
||||
hibernate.show_sql false
|
||||
hibernate.show_sql true
|
||||
|
||||
hibernate.max_fetch_depth 5
|
||||
|
||||
#hibernate.dialect org.hibernate.dialect.H2Dialect
|
||||
#hibernate.connection.driver_class org.h2.Driver
|
||||
#hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE
|
||||
#hibernate.connection.username sa
|
||||
hibernate.dialect org.hibernate.dialect.H2Dialect
|
||||
hibernate.connection.driver_class org.h2.Driver
|
||||
hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE
|
||||
hibernate.connection.username sa
|
||||
|
||||
#hibernate.cache.region_prefix hibernate.test
|
||||
#hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory
|
||||
|
@ -50,19 +50,29 @@ hibernate.max_fetch_depth 5
|
|||
#hibernate.connection.username hibbrtru
|
||||
#hibernate.connection.password hibbrtru
|
||||
|
||||
#
|
||||
## Oracle 10g
|
||||
#hibernate.dialect org.hibernate.spatial.dialect.oracle.OracleSpatial10gDialect
|
||||
#hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver
|
||||
#hibernate.connection.url jdbc:oracle:thin:@oracle.geovise.com/ORCL
|
||||
#hibernate.connection.username hbs
|
||||
#hibernate.connection.password hbs
|
||||
|
||||
## Oracle 11g
|
||||
##
|
||||
#hibernate.dialect org.hibernate.spatial.dialect.oracle.OracleSpatial10gDialect
|
||||
#hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver
|
||||
#hibernate.connection.url jdbc:oracle:thin:@oracle11g.geovise.com:1521/orcl11g.geovise.com
|
||||
#hibernate.connection.username HBS
|
||||
#hibernate.connection.password HBS
|
||||
|
||||
hibernate.dialect org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect
|
||||
hibernate.connection.driver_class com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
hibernate.connection.url jdbc:sqlserver://sqlserver.geovise.com:1433;databaseName=HBS
|
||||
hibernate.connection.username hbs
|
||||
hibernate.connection.password hbs
|
||||
|
||||
## Sql Server 2008
|
||||
##
|
||||
#hibernate.dialect org.hibernate.spatial.dialect.sqlserver.SqlServer2008SpatialDialect
|
||||
#hibernate.connection.driver_class com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
#hibernate.connection.url jdbc:sqlserver://sqlserver.geovise.com:1433;databaseName=HBS
|
||||
#hibernate.connection.username hbs
|
||||
#hibernate.connection.password hbs
|
||||
|
||||
|
||||
##
|
||||
|
|
|
@ -9,135 +9,116 @@ In MySQL these are stored as null objects.
|
|||
<Element>
|
||||
<id>1</id>
|
||||
<type>POINT</type>
|
||||
<wkt>POINT(10 5)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POINT(10 5)</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>2</id>
|
||||
<type>POINT</type>
|
||||
<wkt>POINT(52.25 2.53)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POINT(52.25 2.53)</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>3</id>
|
||||
<type>POINT</type>
|
||||
<wkt>POINT(51 12)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POINT(51 12)</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>4</id>
|
||||
<type>POINT</type>
|
||||
<wkt>POINT(10.0 2.0)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POINT(10.0 2.0)</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>5</id>
|
||||
<type>LINESTRING</type>
|
||||
<wkt>LINESTRING(10.0 5.0, 20.0 15.0)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;LINESTRING(10.0 5.0, 20.0 15.0)</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>6</id>
|
||||
<type>LINESTRING</type>
|
||||
<wkt>LINESTRING(10.0 5.0, 20.0 15.0, 30.3 22.4, 10 30.0)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;LINESTRING(10.0 5.0, 20.0 15.0, 30.3 22.4, 10 30.0)</wkt>
|
||||
</Element>
|
||||
|
||||
|
||||
<Element>
|
||||
<id>11</id>
|
||||
<type>MULTILINESTRING</type>
|
||||
<wkt>MULTILINESTRING((10.0 5.0, 20.0 15.0),( 25.0 30.0, 30.0 20.0))</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;MULTILINESTRING((10.0 5.0, 20.0 15.0),( 25.0 30.0, 30.0 20.0))</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>12</id>
|
||||
<type>MULTILINESTRING</type>
|
||||
<wkt>MULTILINESTRING((10.0 5.0, 20.0 15.0, 30.3 22.4, 10 30.0), (40.0 20.0, 42.0 18.0, 43.0 16.0, 40 14.0))
|
||||
<wkt>SRID=4326;MULTILINESTRING((10.0 5.0, 20.0 15.0, 30.3 22.4, 10 30.0), (40.0 20.0, 42.0 18.0, 43.0 16.0, 40 14.0))
|
||||
</wkt>
|
||||
<srid>4326</srid>
|
||||
</Element>
|
||||
|
||||
|
||||
<Element>
|
||||
<id>16</id>
|
||||
<type>POLYGON</type>
|
||||
<wkt>POLYGON( (0 0, 0 10, 10 10, 10 0, 0 0) )</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POLYGON( (0 0, 0 10, 10 10, 10 0, 0 0) )</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>18</id>
|
||||
<type>POLYGON</type>
|
||||
<wkt>POLYGON( (0 0, 0 10, 10 10, 10 0, 0 0), (2 2, 2 5, 5 5,5 2, 2 2))</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POLYGON( (0 0, 0 10, 10 10, 10 0, 0 0), (2 2, 2 5, 5 5,5 2, 2 2))</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>19</id>
|
||||
<type>POLYGON</type>
|
||||
<wkt>POLYGON( (110 110, 110 120, 120 120, 120 110, 110 110) )</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POLYGON( (110 110, 110 120, 120 120, 120 110, 110 110) )</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>20</id>
|
||||
<type>MULTIPOLYGON</type>
|
||||
<wkt>MULTIPOLYGON( ((10 20, 30 40, 44 50, 10 20)), ((105 100, 120 140, 130 134, 105 100)) )</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;MULTIPOLYGON( ((10 20, 30 40, 44 50, 10 20)), ((105 100, 120 140, 130 134, 105 100)) )</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>22</id>
|
||||
<type>MULTIPOLYGON</type>
|
||||
<wkt>MULTIPOLYGON(( (0 0, 0 50, 50 50, 50 0, 0 0), (10 10, 10 20, 20 20, 20 10, 10 10) ),((105 100, 120 140, 130
|
||||
<wkt>SRID=4326;MULTIPOLYGON(( (0 0, 0 50, 50 50, 50 0, 0 0), (10 10, 10 20, 20 20, 20 10, 10 10) ),((105 100, 120 140, 130
|
||||
134, 105 100)) )
|
||||
</wkt>
|
||||
<srid>4326</srid>
|
||||
</Element>
|
||||
|
||||
|
||||
<Element>
|
||||
<id>25</id>
|
||||
<type>MULTIPOINT</type>
|
||||
<wkt>MULTIPOINT(21 2, 25 5, 30 3)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;MULTIPOINT(21 2, 25 5, 30 3)</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>26</id>
|
||||
<type>MULTIPOINT</type>
|
||||
<wkt>MULTIPOINT(21 2)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;MULTIPOINT(21 2)</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>30</id>
|
||||
<type>GEOMETRYCOLLECTION</type>
|
||||
<wkt>GEOMETRYCOLLECTION(POINT(4 0), LINESTRING(4 2, 5 3))</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;GEOMETRYCOLLECTION(POINT(4 0), LINESTRING(4 2, 5 3))</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>31</id>
|
||||
<type>GEOMETRYCOLLECTION</type>
|
||||
<wkt>GEOMETRYCOLLECTION(POINT(4 0), LINESTRING(4 2, 5 3), POLYGON((0 0, 3 0, 3 3,0 3, 0 0)))</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;GEOMETRYCOLLECTION(POINT(4 0), LINESTRING(4 2, 5 3), POLYGON((0 0, 3 0, 3 3,0 3, 0 0)))</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>32</id>
|
||||
<type>GEOMETRYCOLLECTION</type>
|
||||
<wkt>GEOMETRYCOLLECTION(POINT(4 0), LINESTRING(4 2, 5 3), POLYGON((0 0, 3 0, 3 3,0 3, 0 0),(1 1, 2 1, 2 2, 1 2,
|
||||
<wkt>SRID=4326;GEOMETRYCOLLECTION(POINT(4 0), LINESTRING(4 2, 5 3), POLYGON((0 0, 3 0, 3 3,0 3, 0 0),(1 1, 2 1, 2 2, 1 2,
|
||||
1 1)))
|
||||
</wkt>
|
||||
<srid>4326</srid>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>33</id>
|
||||
<type>GEOMETRYCOLLECTION</type>
|
||||
<wkt>GEOMETRYCOLLECTION( MULTIPOINT(21 2, 25 5, 30 3), MULTIPOLYGON( ((10 20, 30 40, 44 50, 10 20)), ((105 100,
|
||||
<wkt>SRID=4326;GEOMETRYCOLLECTION( MULTIPOINT(21 2, 25 5, 30 3), MULTIPOLYGON( ((10 20, 30 40, 44 50, 10 20)), ((105 100,
|
||||
120 140, 130 134, 105 100)) ), MULTILINESTRING((10.0 5.0, 20.0 15.0),( 25.0 30.0, 30.0 20.0)))
|
||||
</wkt>
|
||||
<srid>4326</srid>
|
||||
</Element>
|
||||
|
||||
|
||||
|
|
|
@ -35,32 +35,28 @@
|
|||
<id>1</id>
|
||||
<type>POINT</type>
|
||||
<sdo>SDO_GEOMETRY(2001, 4326, NULL, SDO_ELEM_INFO_ARRAY(1,1,1), SDO_ORDINATE_ARRAY(10.0, 5.0))</sdo>
|
||||
<wkt>POINT(10 5)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POINT(10 5)</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>2</id>
|
||||
<type>POINT</type>
|
||||
<sdo>SDO_GEOMETRY(2001, 4326, SDO_POINT_TYPE(52.25, 2.53, NULL), NULL, NULL)</sdo>
|
||||
<wkt>POINT(52.25 2.53)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POINT(52.25 2.53)</wkt>
|
||||
</Element>
|
||||
|
||||
|
||||
<Element>
|
||||
<id>5</id>
|
||||
<type>LINESTRING</type>
|
||||
<wkt>LINESTRING(10.0 5.0, 20.0 15.0)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;LINESTRING(10.0 5.0, 20.0 15.0)</wkt>
|
||||
<sdo>SDO_GEOMETRY(2002, 4326, NULL, SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(10.0, 5.0, 20.0, 15.0))</sdo>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>6</id>
|
||||
<type>LINESTRING</type>
|
||||
<wkt>LINESTRING(10.0 5.0, 20.0 15.0, 30.3 22.4, 10 30.0)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;LINESTRING(10.0 5.0, 20.0 15.0, 30.3 22.4, 10 30.0)</wkt>
|
||||
<sdo>SDO_GEOMETRY(2002, 4326, NULL, SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(10.0, 5.0, 20.0, 15.0, 30.3,
|
||||
22.4, 10.0, 30.0 ))
|
||||
</sdo>
|
||||
|
@ -70,8 +66,7 @@
|
|||
<Element>
|
||||
<id>11</id>
|
||||
<type>MULTILINESTRING</type>
|
||||
<wkt>MULTILINESTRING((10.0 5.0, 20.0 15.0),( 25.0 30.0, 30.0 20.0))</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;MULTILINESTRING((10.0 5.0, 20.0 15.0),( 25.0 30.0, 30.0 20.0))</wkt>
|
||||
<sdo>SDO_GEOMETRY(2006, 4326, NULL, SDO_ELEM_INFO_ARRAY(1,2,1,5,2,1), SDO_ORDINATE_ARRAY(10.0, 5.0, 20.0,
|
||||
15.0,25.0,30.0, 30.0,20.0))
|
||||
</sdo>
|
||||
|
@ -80,9 +75,8 @@
|
|||
<Element>
|
||||
<id>12</id>
|
||||
<type>MULTILINESTRING</type>
|
||||
<wkt>MULTILINESTRING((10.0 5.0, 20.0 15.0, 30.3 22.4, 10 30.0), (40.0 20.0, 42.0 18.0, 43.0 16.0, 40 14.0))
|
||||
<wkt>SRID=4326;MULTILINESTRING((10.0 5.0, 20.0 15.0, 30.3 22.4, 10 30.0), (40.0 20.0, 42.0 18.0, 43.0 16.0, 40 14.0))
|
||||
</wkt>
|
||||
<srid>4326</srid>
|
||||
<sdo>SDO_GEOMETRY(2006, 4326, NULL, SDO_ELEM_INFO_ARRAY(1,2,1,9,2,1),
|
||||
SDO_ORDINATE_ARRAY(10.0,5.0,20.0,15.0,30.3,22.4,10,30.0,40.0,20.0,42.0,18.0,43.0,16.0,40,14.0))
|
||||
</sdo>
|
||||
|
@ -91,8 +85,7 @@
|
|||
<Element>
|
||||
<id>16</id>
|
||||
<type>POLYGON</type>
|
||||
<wkt>POLYGON( (0 0, 0 10, 10 10, 10 0, 0 0) )</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POLYGON( (0 0, 10 0, 10 10, 0 10, 0 0) )</wkt>
|
||||
<sdo>SDO_GEOMETRY(2003, 4326, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1),
|
||||
SDO_ORDINATE_ARRAY(0,0,0,10,10,10,10,0,0,0))
|
||||
</sdo>
|
||||
|
@ -101,18 +94,16 @@
|
|||
<Element>
|
||||
<id>18</id>
|
||||
<type>POLYGON</type>
|
||||
<wkt>POLYGON( (0 0, 0 10, 10 10, 10 0, 0 0), (2 2, 2 5, 5 5,5 2, 2 2))</wkt>
|
||||
<wkt>SRID=4326;POLYGON( (0 0, 10 0, 10 10, 0 10, 0 0), (2 2, 2 5, 5 5,5 2, 2 2))</wkt>
|
||||
<sdo>SDO_GEOMETRY(2003, 4326, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1, 11, 2003, 1), SDO_ORDINATE_ARRAY(0, 0, 0,
|
||||
10, 10, 10, 10, 0, 0, 0, 2, 2, 2, 5, 5, 5, 5, 2, 2, 2))
|
||||
</sdo>
|
||||
<srid>4326</srid>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>19</id>
|
||||
<type>POLYGON</type>
|
||||
<wkt>POLYGON( (110 110, 110 120, 120 120, 120 110, 110 110) )</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POLYGON( (110 110, 120 110, 120 120, 110 120, 110 110) )</wkt>
|
||||
<sdo>SDO_GEOMETRY(2003, 4326, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1),
|
||||
SDO_ORDINATE_ARRAY(110,110,110,120,120,120,120,110,110,110))
|
||||
</sdo>
|
||||
|
@ -121,8 +112,7 @@
|
|||
<Element>
|
||||
<id>20</id>
|
||||
<type>MULTIPOLYGON</type>
|
||||
<wkt>MULTIPOLYGON( ((10 20, 30 40, 44 50, 10 20)), ((105 100, 120 140, 130 134, 105 100)) )</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;MULTIPOLYGON( ((10 20, 44 50, 30 40, 10 20)), ((105 100, 130 134, 120 140, 105 100)) )</wkt>
|
||||
<sdo>SDO_GEOMETRY(2007, 4326, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1, 9, 1003, 1), SDO_ORDINATE_ARRAY(10, 20, 30,
|
||||
40, 44, 50, 10, 20, 105, 100, 120, 140, 130, 134, 105, 100))
|
||||
</sdo>
|
||||
|
|
|
@ -32,45 +32,39 @@
|
|||
<id>1</id>
|
||||
<type>POINT</type>
|
||||
<sdo>SDO_GEOMETRY(2001, 0, SDO_POINT_TYPE(10, 5, NULL), NULL, NULL)</sdo>
|
||||
<wkt>POINT(10 5)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POINT(10 5)</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>2</id>
|
||||
<type>POINT</type>
|
||||
<sdo>SDO_GEOMETRY(2001, 4326, SDO_POINT_TYPE(52.25, 2.53, NULL), NULL, NULL)</sdo>
|
||||
<wkt>POINT(52.25 2.53)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POINT(52.25 2.53)</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>3</id>
|
||||
<type>POINT</type>
|
||||
<sdo>SDO_GEOMETRY(3001, 31370, SDO_POINT_TYPE(150000, 200000, 500), NULL, NULL)</sdo>
|
||||
<wkt>POINT(150000 200000 500)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POINT(150000 200000 500)</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>4</id>
|
||||
<type>POINT</type>
|
||||
<sdo>SDO_GEOMETRY(4401, 4326, NULL, SDO_ELEM_INFO_ARRAY(1,1,1), SDO_ORDINATE_ARRAY(10.0, 2.0, 1.0, 3.0))</sdo>
|
||||
<wkt>POINT(10.0 2.0 1.0 3.0)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POINT(10.0 2.0 1.0 3.0)</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>5</id>
|
||||
<type>LINESTRING</type>
|
||||
<wkt>LINESTRING(10.0 5.0, 20.0 15.0)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;LINESTRING(10.0 5.0, 20.0 15.0)</wkt>
|
||||
<sdo>SDO_GEOMETRY(2002, 4326, NULL, SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(10.0, 5.0, 20.0, 15.0))</sdo>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>6</id>
|
||||
<type>LINESTRING</type>
|
||||
<wkt>LINESTRING(10.0 5.0, 20.0 15.0, 30.3 22.4, 10 30.0)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;LINESTRING(10.0 5.0, 20.0 15.0, 30.3 22.4, 10 30.0)</wkt>
|
||||
<sdo>SDO_GEOMETRY(2002, 4326, NULL, SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(10.0, 5.0, 20.0, 15.0, 30.3,
|
||||
22.4, 10.0, 30.0 ))
|
||||
</sdo>
|
||||
|
@ -79,18 +73,16 @@
|
|||
<Element>
|
||||
<id>7</id>
|
||||
<type>LINESTRING</type>
|
||||
<wkt>LINESTRING(10.0 5.0 0.0, 20.0 15.0 3.0)</wkt>
|
||||
<wkt>SRID=4326;LINESTRING(10.0 5.0 0.0, 20.0 15.0 3.0)</wkt>
|
||||
<sdo>SDO_GEOMETRY(3002, 4326, NULL, SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(10.0, 5.0, 0.0, 20.0, 15, 3.0
|
||||
))
|
||||
</sdo>
|
||||
<srid>4326</srid>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>8</id>
|
||||
<type>LINESTRING</type>
|
||||
<wkt>LINESTRING(10.0 5.0 0.0 0.0, 20.0 15.0 3.0 1.0)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;LINESTRING(10.0 5.0 0.0 0.0, 20.0 15.0 3.0 1.0)</wkt>
|
||||
<sdo>SDO_GEOMETRY(4402, 4326, NULL, SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(10.0, 5.0, 0.0, 0.0, 20.0,
|
||||
15, 3.0, 1.0))
|
||||
</sdo>
|
||||
|
@ -99,8 +91,7 @@
|
|||
<Element>
|
||||
<id>9</id>
|
||||
<type>LINESTRING</type>
|
||||
<wkt>LINESTRING(10.0 5.0 1, 20.0 15.0 2, 30.3 22.4 5, 10 30.0 2)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;LINESTRING(10.0 5.0 1, 20.0 15.0 2, 30.3 22.4 5, 10 30.0 2)</wkt>
|
||||
<sdo>SDO_GEOMETRY(3002, 4326, NULL, SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(10.0, 5.0, 1.0,20.0, 15, 2.0,
|
||||
30.3, 22.4, 5.0, 10.0, 30.0, 2.0))
|
||||
</sdo>
|
||||
|
@ -109,8 +100,7 @@
|
|||
<Element>
|
||||
<id>10</id>
|
||||
<type>LINESTRING</type>
|
||||
<wkt>LINESTRING(10.0 5.0 1 1, 20.0 15.0 2 3, 30.3 22.4 5 10, 10 30.0 2 12)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;LINESTRING(10.0 5.0 1 1, 20.0 15.0 2 3, 30.3 22.4 5 10, 10 30.0 2 12)</wkt>
|
||||
<sdo>SDO_GEOMETRY(4402, 4326, NULL, SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(10.0,5.0,1,1, 20.0, 15.0, 2,
|
||||
3, 30.3, 22.4, 5, 10, 10, 30.0, 2, 12))
|
||||
</sdo>
|
||||
|
@ -119,8 +109,7 @@
|
|||
<Element>
|
||||
<id>11</id>
|
||||
<type>MULTILINESTRING</type>
|
||||
<wkt>MULTILINESTRING((10.0 5.0, 20.0 15.0),( 25.0 30.0, 30.0 20.0))</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;MULTILINESTRING((10.0 5.0, 20.0 15.0),( 25.0 30.0, 30.0 20.0))</wkt>
|
||||
<sdo>SDO_GEOMETRY(2006, 4326, NULL, SDO_ELEM_INFO_ARRAY(1,2,1,5,2,1), SDO_ORDINATE_ARRAY(10.0, 5.0, 20.0,
|
||||
15.0,25.0,30.0, 30.0,20.0))
|
||||
</sdo>
|
||||
|
@ -129,9 +118,8 @@
|
|||
<Element>
|
||||
<id>12</id>
|
||||
<type>MULTILINESTRING</type>
|
||||
<wkt>MULTILINESTRING((10.0 5.0, 20.0 15.0, 30.3 22.4, 10 30.0), (40.0 20.0, 42.0 18.0, 43.0 16.0, 40 14.0))
|
||||
<wkt>SRID=4326;MULTILINESTRING((10.0 5.0, 20.0 15.0, 30.3 22.4, 10 30.0), (40.0 20.0, 42.0 18.0, 43.0 16.0, 40 14.0))
|
||||
</wkt>
|
||||
<srid>4326</srid>
|
||||
<sdo>SDO_GEOMETRY(2006, 4326, NULL, SDO_ELEM_INFO_ARRAY(1,2,1,9,2,1),
|
||||
SDO_ORDINATE_ARRAY(10.0,5.0,20.0,15.0,30.3,22.4,10,30.0,40.0,20.0,42.0,18.0,43.0,16.0,40,14.0))
|
||||
</sdo>
|
||||
|
@ -139,11 +127,10 @@
|
|||
|
||||
<Element>
|
||||
<id>13</id>
|
||||
<type>MULTILINESTRING</type>
|
||||
<type>SRID=4326;MULTILINESTRING</type>
|
||||
<wkt>MULTILINESTRING((10.0 5.0 1.0, 20.0 15.0 2.0, 30.3 22.4 1.0, 10 30.0 1.0),(40.0 20.0 0.0, 42.0 18.0 1.0,
|
||||
43.0 16.0 2.0, 40 14.0 3.0))
|
||||
</wkt>
|
||||
<srid>4326</srid>
|
||||
<sdo>SDO_GEOMETRY(3006, 4326, NULL, SDO_ELEM_INFO_ARRAY(1,2,1,13,2,1),
|
||||
SDO_ORDINATE_ARRAY(10.0,5.0,1.0,20.0,15.0,2.0,30.3,22.4,1.0,10,30.0,1.0,40.0,20.0,0.0,42.0,18.0,1.0,43.0,16.0,2.0,40,14.0,3.0))
|
||||
</sdo>
|
||||
|
@ -152,10 +139,9 @@
|
|||
<Element>
|
||||
<id>14</id>
|
||||
<type>MULTILINESTRING</type>
|
||||
<wkt>MULTILINESTRING((10.0 5.0 1.0 0.0, 20.0 15.0 2.0 0.0, 30.3 22.4 1.0 1.0, 10 30.0 1.0 2.0),(40.0 20.0 0.0
|
||||
<wkt>SRID=4326;MULTILINESTRING((10.0 5.0 1.0 0.0, 20.0 15.0 2.0 0.0, 30.3 22.4 1.0 1.0, 10 30.0 1.0 2.0),(40.0 20.0 0.0
|
||||
3.0, 42.0 18.0 1.0 4.0, 43.0 16.0 2.0 5.0, 40 14.0 3.0 6.0))
|
||||
</wkt>
|
||||
<srid>4326</srid>
|
||||
<sdo>SDO_GEOMETRY(4406, 4326, NULL, SDO_ELEM_INFO_ARRAY(1,2,1,17,2,1),
|
||||
SDO_ORDINATE_ARRAY(10.0,5.0,1.0,0.0,20.0,15.0,2.0,0.0,30.3,22.4,1.0,1.0,10,30.0,1.0,2.0,40.0,20.0,0.0,3.0,42.0,18.0,1.0,4.0,43.0,16.0,2.0,5.0,40,14.0,3.0,6.0))
|
||||
</sdo>
|
||||
|
@ -164,8 +150,7 @@
|
|||
<Element>
|
||||
<id>15</id>
|
||||
<type>MULTILINESTRING</type>
|
||||
<wkt>MULTILINESTRING((10.0 5.0 1.0 0.0, 20.0 15.0 2.0 0.0, 30.3 22.4 1.0 1.0, 10 30.0 1.0 2.0))</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;MULTILINESTRING((10.0 5.0 1.0 0.0, 20.0 15.0 2.0 0.0, 30.3 22.4 1.0 1.0, 10 30.0 1.0 2.0))</wkt>
|
||||
<sdo>SDO_GEOMETRY(4406, 4326, NULL, SDO_ELEM_INFO_ARRAY(1,2,1),
|
||||
SDO_ORDINATE_ARRAY(10.0,5.0,1.0,0.0,20.0,15.0,2.0,0.0,30.3,22.4,1.0,1.0,10,30.0,1.0,2.0))
|
||||
</sdo>
|
||||
|
@ -175,8 +160,7 @@
|
|||
<Element>
|
||||
<id>16</id>
|
||||
<type>POLYGON</type>
|
||||
<wkt>POLYGON( (0 0, 0 10, 10 10, 10 0, 0 0) )</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POLYGON( (0 0, 0 10, 10 10, 10 0, 0 0) )</wkt>
|
||||
<sdo>SDO_GEOMETRY(2003, 4326, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1),
|
||||
SDO_ORDINATE_ARRAY(0,0,0,10,10,10,10,0,0,0))
|
||||
</sdo>
|
||||
|
@ -186,8 +170,7 @@
|
|||
<Element>
|
||||
<id>17</id>
|
||||
<type>POLYGON</type>
|
||||
<wkt>POLYGON( (0 0 0, 0 10 1, 10 10 1, 10 0 1, 0 0 0) )</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POLYGON( (0 0 0, 0 10 1, 10 10 1, 10 0 1, 0 0 0) )</wkt>
|
||||
<sdo>SDO_GEOMETRY(3003, 4326, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1),
|
||||
SDO_ORDINATE_ARRAY(0,0,0,0,10,1,10,10,1,10,0,1,0,0,0))
|
||||
</sdo>
|
||||
|
@ -195,17 +178,15 @@
|
|||
<Element>
|
||||
<id>18</id>
|
||||
<type>POLYGON</type>
|
||||
<wkt>POLYGON( (0 0, 0 10, 10 10, 10 0, 0 0), (2 2, 2 5, 5 5,5 2, 2 2))</wkt>
|
||||
<wkt>SRID=4326;POLYGON( (0 0, 0 10, 10 10, 10 0, 0 0), (2 2, 2 5, 5 5,5 2, 2 2))</wkt>
|
||||
<sdo>SDO_GEOMETRY(2003, 4326, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1, 11, 2003, 1), SDO_ORDINATE_ARRAY(0, 0, 0,
|
||||
10, 10, 10, 10, 0, 0, 0, 2, 2, 2, 5, 5, 5, 5, 2, 2, 2))
|
||||
</sdo>
|
||||
<srid>4326</srid>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>19</id>
|
||||
<type>POLYGON</type>
|
||||
<wkt>POLYGON( (110 110, 110 120, 120 120, 120 110, 110 110) )</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POLYGON( (110 110, 110 120, 120 120, 120 110, 110 110) )</wkt>
|
||||
<sdo>SDO_GEOMETRY(2003, 4326, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1),
|
||||
SDO_ORDINATE_ARRAY(110,110,110,120,120,120,120,110,110,110))
|
||||
</sdo>
|
||||
|
@ -214,8 +195,7 @@
|
|||
<Element>
|
||||
<id>20</id>
|
||||
<type>MULTIPOLYGON</type>
|
||||
<wkt>MULTIPOLYGON( ((10 20, 30 40, 44 50, 10 20)), ((105 100, 120 140, 130 134, 105 100)) )</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;MULTIPOLYGON( ((10 20, 30 40, 44 50, 10 20)), ((105 100, 120 140, 130 134, 105 100)) )</wkt>
|
||||
<sdo>SDO_GEOMETRY(2007, 4326, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1, 9, 1003, 1), SDO_ORDINATE_ARRAY(10, 20, 30,
|
||||
40, 44, 50, 10, 20, 105, 100, 120, 140, 130, 134, 105, 100))
|
||||
</sdo>
|
||||
|
@ -223,9 +203,8 @@
|
|||
<Element>
|
||||
<id>21</id>
|
||||
<type>MULTIPOLYGON</type>
|
||||
<wkt>MULTIPOLYGON( ((10 20 1, 30 40 2, 44 50 2, 10 20 1)), ((105 100 0, 120 140 10, 130 134 20, 105 100 0)) )
|
||||
<wkt>SRID=4326;MULTIPOLYGON( ((10 20 1, 30 40 2, 44 50 2, 10 20 1)), ((105 100 0, 120 140 10, 130 134 20, 105 100 0)) )
|
||||
</wkt>
|
||||
<srid>4326</srid>
|
||||
<sdo>SDO_GEOMETRY(3007, 4326, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1, 13, 1003, 1),
|
||||
SDO_ORDINATE_ARRAY(10,20,1,30,40,2,44,50,2,10,20,1,105,100,0,120,140,10,130,134,20,105,100,0))
|
||||
</sdo>
|
||||
|
@ -233,43 +212,38 @@
|
|||
<Element>
|
||||
<id>22</id>
|
||||
<type>MULTIPOLYGON</type>
|
||||
<wkt>MULTIPOLYGON(( (0 0, 0 50, 50 50, 50 0, 0 0), (10 10, 10 20, 20 20, 20 10, 10 10) ),((105 100, 120 140, 130
|
||||
<wkt>SRID=4326;MULTIPOLYGON(( (0 0, 0 50, 50 50, 50 0, 0 0), (10 10, 10 20, 20 20, 20 10, 10 10) ),((105 100, 120 140, 130
|
||||
134, 105 100)))
|
||||
</wkt>
|
||||
<sdo>SDO_GEOMETRY(2007, 4326, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1, 11, 2003, 1, 21, 1003, 1),
|
||||
SDO_ORDINATE_ARRAY(0, 0, 0, 50, 50, 50, 50, 0, 0, 0, 10, 10, 10, 20, 20, 20, 20, 10, 10, 10, 105, 100, 120,
|
||||
140, 130, 134, 105, 100))
|
||||
</sdo>
|
||||
<srid>4326</srid>
|
||||
</Element>
|
||||
|
||||
|
||||
<Element>
|
||||
<id>25</id>
|
||||
<type>MULTIPOINT</type>
|
||||
<wkt>MULTIPOINT(21 2, 25 5, 30 3)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;MULTIPOINT(21 2, 25 5, 30 3)</wkt>
|
||||
<sdo>SDO_GEOMETRY(2005, 4326, NULL, SDO_ELEM_INFO_ARRAY(1,1,1), SDO_ORDINATE_ARRAY(21,2,25,5,30,3))</sdo>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>26</id>
|
||||
<type>MULTIPOINT</type>
|
||||
<wkt>MULTIPOINT(21 2)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;MULTIPOINT(21 2)</wkt>
|
||||
<sdo>SDO_GEOMETRY(2005, 4326, NULL, SDO_ELEM_INFO_ARRAY(1,1,1), SDO_ORDINATE_ARRAY(21,2))</sdo>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>27</id>
|
||||
<type>MULTIPOINT</type>
|
||||
<wkt>MULTIPOINT(21 2 1, 25 5 2, 30 3 5)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;MULTIPOINT(21 2 1, 25 5 2, 30 3 5)</wkt>
|
||||
<sdo>SDO_GEOMETRY(3005, 4326, NULL, SDO_ELEM_INFO_ARRAY(1,1,1), SDO_ORDINATE_ARRAY(21,2,1,25,5,2,30,3,5))</sdo>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>28</id>
|
||||
<type>MULTIPOINT</type>
|
||||
<wkt>MULTIPOINT(21 2 1 0, 25 5 2 4, 30 3 5 2)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;MULTIPOINT(21 2 1 0, 25 5 2 4, 30 3 5 2)</wkt>
|
||||
<sdo>SDO_GEOMETRY(4405, 4326, NULL, SDO_ELEM_INFO_ARRAY(1,1,1),
|
||||
SDO_ORDINATE_ARRAY(21,2,1,0,25,5,2,4,30,3,5,2))
|
||||
</sdo>
|
||||
|
|
|
@ -3,75 +3,64 @@
|
|||
<Element>
|
||||
<id>1</id>
|
||||
<type>POINT</type>
|
||||
<wkt>POINT(10 5)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POINT(10 5)</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>2</id>
|
||||
<type>POINT</type>
|
||||
<wkt>POINT(79 79)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POINT(79 79)</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>3</id>
|
||||
<type>POINT</type>
|
||||
<wkt>POINT(50 50)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POINT(50 50)</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>4</id>
|
||||
<type>POINT</type>
|
||||
<wkt>POINT(10 20)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POINT(10 20)</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>5</id>
|
||||
<type>POINT</type>
|
||||
<wkt>POINT(-4 -5)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POINT(-4 -5)</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>6</id>
|
||||
<type>LINESTRING</type>
|
||||
<wkt>LINESTRING(10.0 5.0, 20.0 15.0)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;LINESTRING(10.0 5.0, 20.0 15.0)</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>7</id>
|
||||
<type>LINESTRING</type>
|
||||
<wkt>LINESTRING(10.0 5.0 1, 20.0 15.0 2, 30.3 22.4 5, 10 30.0 2)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;LINESTRING(10.0 5.0 1, 20.0 15.0 2, 30.3 22.4 5, 10 30.0 2)</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>8</id>
|
||||
<type>LINESTRING</type>
|
||||
<wkt>LINESTRING(10.0 5.0 1 1, 20.0 15.0 2 3, 30.3 22.4 5 10, 10 30.0 2 12)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;LINESTRING(10.0 5.0 1 1, 20.0 15.0 2 3, 30.3 22.4 5 10, 10 30.0 2 12)</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>9</id>
|
||||
<type>MULTILINESTRING</type>
|
||||
<wkt>MULTILINESTRING((10.0 5.0, 20.0 15.0, 30.3 22.4, 10 30.0), (40.0 20.0, 42.0 18.0, 43.0 16.0, 40 14.0))
|
||||
<wkt>SRID=4326;MULTILINESTRING((10.0 5.0, 20.0 15.0, 30.3 22.4, 10 30.0), (40.0 20.0, 42.0 18.0, 43.0 16.0, 40 14.0))
|
||||
</wkt>
|
||||
<srid>4326</srid>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>10</id>
|
||||
<type>POLYGON</type>
|
||||
<wkt>POLYGON( (0 0, 0 10, 10 10, 10 0, 0 0) )</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POLYGON( (0 0, 0 10, 10 10, 10 0, 0 0) )</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>11</id>
|
||||
<type>MULTIPOLYGON</type>
|
||||
<wkt>MULTIPOLYGON( ((10 20, 30 40, 44 50, 10 20)), ((15 10, 12 14, 13 13, 15 10)) )</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;MULTIPOLYGON( ((10 20, 30 40, 44 50, 10 20)), ((15 10, 12 14, 13 13, 15 10)) )</wkt>
|
||||
</Element>
|
||||
|
||||
</TestData>
|
||||
|
|
|
@ -3,295 +3,251 @@
|
|||
<id>1</id>
|
||||
<type>POINT</type>
|
||||
<wkt>POINT(10 5)</wkt>
|
||||
<srid>0</srid>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>2</id>
|
||||
<type>POINT</type>
|
||||
<wkt>POINT(52.25 2.53)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POINT(52.25 2.53)</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>3</id>
|
||||
<type>POINT</type>
|
||||
<wkt>POINT(150000 200000)</wkt>
|
||||
<srid>31370</srid>
|
||||
<wkt>SRID=31370;POINT(150000 200000)</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>4</id>
|
||||
<type>POINT</type>
|
||||
<wkt>POINT(10.0 2.0 1.0 3.0)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POINT(10.0 2.0 1.0 3.0)</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>5</id>
|
||||
<type>LINESTRING</type>
|
||||
<wkt>LINESTRING(10.0 5.0, 20.0 15.0)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;LINESTRING(10.0 5.0, 20.0 15.0)</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>6</id>
|
||||
<type>LINESTRING</type>
|
||||
<wkt>LINESTRING(10.0 5.0, 20.0 15.0, 30.3 22.4, 10 30.0)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;LINESTRING(10.0 5.0, 20.0 15.0, 30.3 22.4, 10 30.0)</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>7</id>
|
||||
<type>LINESTRING</type>
|
||||
<wkt>LINESTRING(10.0 5.0 0.0, 20.0 15.0 3.0)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;LINESTRING(10.0 5.0 0.0, 20.0 15.0 3.0)</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>8</id>
|
||||
<type>LINESTRING</type>
|
||||
<wkt>LINESTRING(10.0 5.0 0.0 0.0, 20.0 15.0 3.0 1.0)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;LINESTRING(10.0 5.0 0.0 0.0, 20.0 15.0 3.0 1.0)</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>9</id>
|
||||
<type>LINESTRING</type>
|
||||
<wkt>LINESTRING(10.0 5.0 1, 20.0 15.0 2, 30.3 22.4 5, 10 30.0 2)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;LINESTRING(10.0 5.0 1, 20.0 15.0 2, 30.3 22.4 5, 10 30.0 2)</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>10</id>
|
||||
<type>LINESTRING</type>
|
||||
<wkt>LINESTRING(10.0 5.0 1 1, 20.0 15.0 2 3, 30.3 22.4 5 10, 10 30.0 2 12)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;LINESTRING(10.0 5.0 1 1, 20.0 15.0 2 3, 30.3 22.4 5 10, 10 30.0 2 12)</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>11</id>
|
||||
<type>MULTILINESTRING</type>
|
||||
<wkt>MULTILINESTRING((10.0 5.0, 20.0 15.0),( 25.0 30.0, 30.0 20.0))</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;MULTILINESTRING((10.0 5.0, 20.0 15.0),( 25.0 30.0, 30.0 20.0))</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>12</id>
|
||||
<type>MULTILINESTRING</type>
|
||||
<wkt>MULTILINESTRING((10.0 5.0, 20.0 15.0, 30.3 22.4, 10 30.0), (40.0 20.0, 42.0 18.0, 43.0 16.0, 40 14.0))
|
||||
<wkt>SRID=4326;MULTILINESTRING((10.0 5.0, 20.0 15.0, 30.3 22.4, 10 30.0), (40.0 20.0, 42.0 18.0, 43.0 16.0, 40 14.0))
|
||||
</wkt>
|
||||
<srid>4326</srid>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>13</id>
|
||||
<type>MULTILINESTRING</type>
|
||||
<wkt>MULTILINESTRING((10.0 5.0 1.0, 20.0 15.0 2.0, 30.3 22.4 1.0, 10 30.0 1.0),(40.0 20.0 0.0, 42.0 18.0 1.0,
|
||||
<wkt>SRID=4326;MULTILINESTRING((10.0 5.0 1.0, 20.0 15.0 2.0, 30.3 22.4 1.0, 10 30.0 1.0),(40.0 20.0 0.0, 42.0 18.0 1.0,
|
||||
43.0 16.0 2.0, 40 14.0 3.0))
|
||||
</wkt>
|
||||
<srid>4326</srid>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>14</id>
|
||||
<type>MULTILINESTRING</type>
|
||||
<wkt>MULTILINESTRING((10.0 5.0 1.0 0.0, 20.0 15.0 2.0 0.0, 30.3 22.4 1.0 1.0, 10 30.0 1.0 2.0),(40.0 20.0 0.0
|
||||
<wkt>SRID=4326;MULTILINESTRING((10.0 5.0 1.0 0.0, 20.0 15.0 2.0 0.0, 30.3 22.4 1.0 1.0, 10 30.0 1.0 2.0),(40.0 20.0 0.0
|
||||
3.0, 42.0 18.0 1.0 4.0, 43.0 16.0 2.0 5.0, 40 14.0 3.0 6.0))
|
||||
</wkt>
|
||||
<srid>4326</srid>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>15</id>
|
||||
<type>MULTILINESTRING</type>
|
||||
<wkt>MULTILINESTRING((10.0 5.0 1.0 0.0, 20.0 15.0 2.0 0.0, 30.3 22.4 1.0 1.0, 10 30.0 1.0 2.0))</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;MULTILINESTRING((10.0 5.0 1.0 0.0, 20.0 15.0 2.0 0.0, 30.3 22.4 1.0 1.0, 10 30.0 1.0 2.0))</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>16</id>
|
||||
<type>POLYGON</type>
|
||||
<wkt>POLYGON( (0 0, 0 10, 10 10, 10 0, 0 0) )</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POLYGON( (0 0, 0 10, 10 10, 10 0, 0 0) )</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>17</id>
|
||||
<type>POLYGON</type>
|
||||
<wkt>POLYGON( (0 0 0, 0 10 1, 10 10 1, 10 0 1, 0 0 0) )</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POLYGON( (0 0 0, 0 10 1, 10 10 1, 10 0 1, 0 0 0) )</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>18</id>
|
||||
<type>POLYGON</type>
|
||||
<wkt>POLYGON( (0 0, 0 10, 10 10, 10 0, 0 0), (2 2, 2 5, 5 5,5 2, 2 2))</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POLYGON( (0 0, 0 10, 10 10, 10 0, 0 0), (2 2, 2 5, 5 5,5 2, 2 2))</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>19</id>
|
||||
<type>POLYGON</type>
|
||||
<wkt>POLYGON( (110 110, 110 120, 120 120, 120 110, 110 110) )</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;POLYGON( (110 110, 110 120, 120 120, 120 110, 110 110) )</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>20</id>
|
||||
<type>MULTIPOLYGON</type>
|
||||
<wkt>MULTIPOLYGON( ((10 20, 30 40, 44 50, 10 20)), ((105 100, 120 140, 130 134, 105 100)) )</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;MULTIPOLYGON( ((10 20, 30 40, 44 50, 10 20)), ((105 100, 120 140, 130 134, 105 100)) )</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>21</id>
|
||||
<type>MULTIPOLYGON</type>
|
||||
<wkt>MULTIPOLYGON( ((10 20 1, 30 40 2, 44 50 2, 10 20 1)), ((105 100 0, 120 140 10, 130 134 20, 105 100 0)) )
|
||||
<wkt>SRID=4326;MULTIPOLYGON( ((10 20 1, 30 40 2, 44 50 2, 10 20 1)), ((105 100 0, 120 140 10, 130 134 20, 105 100 0)) )
|
||||
</wkt>
|
||||
<srid>4326</srid>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>22</id>
|
||||
<type>MULTIPOLYGON</type>
|
||||
<wkt>MULTIPOLYGON(( (0 0, 0 50, 50 50, 50 0, 0 0), (10 10, 10 20, 20 20, 20 10, 10 10) ),((105 100, 120 140, 130
|
||||
<wkt>SRID=4326;MULTIPOLYGON(( (0 0, 0 50, 50 50, 50 0, 0 0), (10 10, 10 20, 20 20, 20 10, 10 10) ),((105 100, 120 140, 130
|
||||
134, 105 100)) )
|
||||
</wkt>
|
||||
<srid>4326</srid>
|
||||
</Element>
|
||||
|
||||
|
||||
<Element>
|
||||
<id>25</id>
|
||||
<type>MULTIPOINT</type>
|
||||
<wkt>MULTIPOINT(21 2, 25 5, 30 3)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;MULTIPOINT(21 2, 25 5, 30 3)</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>26</id>
|
||||
<type>MULTIPOINT</type>
|
||||
<wkt>MULTIPOINT(21 2)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;MULTIPOINT(21 2)</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>27</id>
|
||||
<type>MULTIPOINT</type>
|
||||
<wkt>MULTIPOINT(21 2 1, 25 5 2, 30 3 5)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;MULTIPOINT(21 2 1, 25 5 2, 30 3 5)</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>28</id>
|
||||
<type>MULTIPOINT</type>
|
||||
<wkt>MULTIPOINT(21 2 1 0, 25 5 2 4, 30 3 5 2)</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;MULTIPOINT(21 2 1 0, 25 5 2 4, 30 3 5 2)</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>30</id>
|
||||
<type>GEOMETRYCOLLECTION</type>
|
||||
<wkt>GEOMETRYCOLLECTION(POINT(4 0), LINESTRING(4 2, 5 3))</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;GEOMETRYCOLLECTION(POINT(4 0), LINESTRING(4 2, 5 3))</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>31</id>
|
||||
<type>GEOMETRYCOLLECTION</type>
|
||||
<wkt>GEOMETRYCOLLECTION(POINT(4 0), LINESTRING(4 2, 5 3), POLYGON((0 0, 3 0, 3 3,0 3, 0 0)))</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;GEOMETRYCOLLECTION(POINT(4 0), LINESTRING(4 2, 5 3), POLYGON((0 0, 3 0, 3 3,0 3, 0 0)))</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>32</id>
|
||||
<type>GEOMETRYCOLLECTION</type>
|
||||
<wkt>GEOMETRYCOLLECTION(POINT(4 0), LINESTRING(4 2, 5 3), POLYGON((0 0, 3 0, 3 3,0 3, 0 0),(1 1, 2 1, 2 2, 1 2,
|
||||
<wkt>SRID=4326;GEOMETRYCOLLECTION(POINT(4 0), LINESTRING(4 2, 5 3), POLYGON((0 0, 3 0, 3 3,0 3, 0 0),(1 1, 2 1, 2 2, 1 2,
|
||||
1 1)))
|
||||
</wkt>
|
||||
<srid>4326</srid>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>33</id>
|
||||
<type>GEOMETRYCOLLECTION</type>
|
||||
<wkt>GEOMETRYCOLLECTION( MULTIPOINT(21 2, 25 5, 30 3), MULTIPOLYGON( ((10 20, 30 40, 44 50, 10 20)), ((105 100,
|
||||
<wkt>SRID=4326;GEOMETRYCOLLECTION( MULTIPOINT(21 2, 25 5, 30 3), MULTIPOLYGON( ((10 20, 30 40, 44 50, 10 20)), ((105 100,
|
||||
120 140, 130 134, 105 100)) ), MULTILINESTRING((10.0 5.0, 20.0 15.0),( 25.0 30.0, 30.0 20.0)))
|
||||
</wkt>
|
||||
<srid>4326</srid>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>34</id>
|
||||
<type>GEOMETRYCOLLECTION</type>
|
||||
<wkt>GEOMETRYCOLLECTION(POINT(4 0), POINT EMPTY, LINESTRING(4 2, 5 3))</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;GEOMETRYCOLLECTION(POINT(4 0), POINT EMPTY, LINESTRING(4 2, 5 3))</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>35</id>
|
||||
<type>GEOMETRYCOLLECTION</type>
|
||||
<wkt>GEOMETRYCOLLECTION(POINT(4 0), LINESTRING EMPTY, LINESTRING(4 2, 5 3))</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;GEOMETRYCOLLECTION(POINT(4 0), LINESTRING EMPTY, LINESTRING(4 2, 5 3))</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>36</id>
|
||||
<type>GEOMETRYCOLLECTION</type>
|
||||
<wkt>GEOMETRYCOLLECTION(POINT(4 0), GEOMETRYCOLLECTION EMPTY, LINESTRING(4 2, 5 3))</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;GEOMETRYCOLLECTION(POINT(4 0), GEOMETRYCOLLECTION EMPTY, LINESTRING(4 2, 5 3))</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>37</id>
|
||||
<type>GEOMETRYCOLLECTION</type>
|
||||
<wkt>GEOMETRYCOLLECTION(POINT(4 0), POLYGON EMPTY, LINESTRING(4 2, 5 3))</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;GEOMETRYCOLLECTION(POINT(4 0), POLYGON EMPTY, LINESTRING(4 2, 5 3))</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>38</id>
|
||||
<type>GEOMETRYCOLLECTION</type>
|
||||
<wkt>GEOMETRYCOLLECTION(POINT(4 0), MULTILINESTRING EMPTY, LINESTRING(4 2, 5 3))</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;GEOMETRYCOLLECTION(POINT(4 0), MULTILINESTRING EMPTY, LINESTRING(4 2, 5 3))</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>39</id>
|
||||
<type>GEOMETRYCOLLECTION</type>
|
||||
<wkt>GEOMETRYCOLLECTION(POINT(4 0), MULTIPOINT EMPTY, LINESTRING(4 2, 5 3))</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;GEOMETRYCOLLECTION(POINT(4 0), MULTIPOINT EMPTY, LINESTRING(4 2, 5 3))</wkt>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>40</id>
|
||||
<type>GEOMETRYCOLLECTION</type>
|
||||
<wkt>GEOMETRYCOLLECTION(POINT(4 0), MULTIPOLYGON EMPTY, LINESTRING(4 2, 5 3))</wkt>
|
||||
<srid>4326</srid>
|
||||
<wkt>SRID=4326;GEOMETRYCOLLECTION(POINT(4 0), MULTIPOLYGON EMPTY, LINESTRING(4 2, 5 3))</wkt>
|
||||
</Element>
|
||||
|
||||
<Element>
|
||||
<id>50</id>
|
||||
<type>POINT</type>
|
||||
<wkt>POINT EMPTY</wkt>
|
||||
<srid>0</srid>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>51</id>
|
||||
<type>LINESTRING</type>
|
||||
<wkt>LINESTRING EMPTY</wkt>
|
||||
<srid>0</srid>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>52</id>
|
||||
<type>POLYGON</type>
|
||||
<wkt>POLYGON EMPTY</wkt>
|
||||
<srid>0</srid>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>53</id>
|
||||
<type>MULTIPOINT</type>
|
||||
<wkt>MULTIPOINT EMPTY</wkt>
|
||||
<srid>0</srid>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>54</id>
|
||||
<type>MULTILINESTRING</type>
|
||||
<wkt>MULTILINESTRING EMPTY</wkt>
|
||||
<srid>0</srid>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>55</id>
|
||||
<type>MULTIPOLYGON</type>
|
||||
<wkt>MULTIPOLYGON EMPTY</wkt>
|
||||
<srid>0</srid>
|
||||
</Element>
|
||||
<Element>
|
||||
<id>56</id>
|
||||
<type>GEOMETRYCOLLECTION</type>
|
||||
<wkt>GEOMETRYCOLLECTION EMPTY</wkt>
|
||||
<srid>0</srid>
|
||||
</Element>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue