use of com.microsoft.sqlserver.jdbc.Geometry in project mssql-jdbc by Microsoft.
the class SQLServerSpatialDatatypeTest method testSTAsText.
@Test
public void testSTAsText() throws SQLException {
beforeEachSetup();
String geoWKT = "GEOMETRYCOLLECTION(POINT(300 20 1), GEOMETRYCOLLECTION EMPTY, GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION EMPTY)), POLYGON((0 0 2, 1 10 3, 1 0 4, 0 0 2)))";
String geoWKTSS = "GEOMETRYCOLLECTION(POINT(300 20), GEOMETRYCOLLECTION EMPTY, GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION EMPTY)), POLYGON((0 0, 1 10, 1 0, 0 0)))";
Geometry geomWKT = Geometry.STGeomFromText(geoWKT, 0);
Geography geogWKT = Geography.STGeomFromText(geoWKT, 4326);
pstmt = (SQLServerPreparedStatement) con.prepareStatement("insert into " + geomTableName + " values (?)");
pstmt.setGeometry(1, geomWKT);
pstmt.execute();
rs = (SQLServerResultSet) stmt.executeQuery("select c1 from " + geomTableName);
rs.next();
assertEquals(rs.getGeometry(1).STAsText(), geoWKTSS);
pstmt = (SQLServerPreparedStatement) con.prepareStatement("insert into " + geogTableName + " values (?)");
pstmt.setGeography(1, geogWKT);
pstmt.execute();
rs = (SQLServerResultSet) stmt.executeQuery("select c1 from " + geogTableName);
rs.next();
assertEquals(rs.getGeography(1).STAsText(), geoWKTSS);
}
use of com.microsoft.sqlserver.jdbc.Geometry in project mssql-jdbc by Microsoft.
the class SQLServerSpatialDatatypeTest method testMultiPolygonWkb.
@Test
public void testMultiPolygonWkb() throws DecoderException {
String geoWKT = "MULTIPOLYGON(((1 1, 1 2, 2 1, 1 1), (0 0, 0 3, 3 3, 3 0, 0 0 7)), ((9 9, 9 10, 10 9, 9 9)))";
byte[] geomWKB = Hex.decodeHex("0000000001010D000000000000000000F03F000000000000F03F000000000000F03F00000000000000400000000000000040000000000000F03F000000000000F03F000000000000F03F000000000000000000000000000000000000000000000000000000000000084000000000000008400000000000000840000000000000084000000000000000000000000000000000000000000000000000000000000022400000000000002240000000000000224000000000000024400000000000002440000000000000224000000000000022400000000000002240000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF0000000000001C40000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF0300000002000000000004000000020900000003000000FFFFFFFF0000000006000000000000000003000000000200000003".toCharArray());
byte[] geogWKB = Hex.decodeHex("E610000002010D000000000000000000F03F000000000000F03F0000000000000040000000000000F03F000000000000F03F0000000000000040000000000000F03F000000000000F03F000000000000000000000000000000000000000000000840000000000000000000000000000008400000000000000840000000000000000000000000000008400000000000000000000000000000000000000000000022400000000000002240000000000000244000000000000022400000000000002240000000000000244000000000000022400000000000002240000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF0000000000001C40000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF0300000001000000000104000000010900000003000000FFFFFFFF0000000006000000000000000003000000000200000003".toCharArray());
Geometry geomWKT = Geometry.deserialize(geomWKB);
Geography geogWKT = Geography.deserialize(geogWKB);
assertEquals(geomWKT.asTextZM(), geoWKT);
assertEquals(geogWKT.asTextZM(), geoWKT);
}
use of com.microsoft.sqlserver.jdbc.Geometry in project mssql-jdbc by Microsoft.
the class SQLServerSpatialDatatypeTest method testLineStringWkb.
@Test
public void testLineStringWkb() throws DecoderException {
String geoWKT = "LINESTRING(1 0, 0 1, -1 0)";
byte[] geomWKB = Hex.decodeHex("00000000010403000000000000000000F03F00000000000000000000000000000000000000000000F03F000000000000F0BF000000000000000001000000010000000001000000FFFFFFFF0000000002".toCharArray());
byte[] geogWKB = Hex.decodeHex("E61000000104030000000000000000000000000000000000F03F000000000000F03F00000000000000000000000000000000000000000000F0BF01000000010000000001000000FFFFFFFF0000000002".toCharArray());
Geometry geomWKT = Geometry.deserialize(geomWKB);
Geography geogWKT = Geography.deserialize(geogWKB);
assertEquals(geomWKT.asTextZM(), geoWKT);
assertEquals(geogWKT.asTextZM(), geoWKT);
}
Aggregations