question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Geometry class cannot handle 3D WKT

See original GitHub issue

Driver version

SQL Server version

Microsoft SQL Server 2019 (RTM) - 15.0.2000.5 (X64) Sep 24 2019 13:48:23 Copyright © 2019 Microsoft Corporation Developer Edition (64-bit) on Linux (Ubuntu 16.04.6 LTS) <X64>

Client Operating System

Linux Mint 19.2 (SQLServer is running in the official docker images)

JAVA/JVM version

OpenJDK 1.8.0_232

Table schema

No table needed.

Problem description

The JDBC driver (and the routines inside the database too) cannot handle geometries with Z as specified in the OGC Simple Feature Specitication, see “7.2.3 BNF Productions for Three-Dimension Geometry WKT”

  1. Expected behaviour: the code (and the database should parse a valid 3D WKT expression
  2. Actual behaviour: it does not, claims Z is invalid
  3. Error message/stack trace:
Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: Carattere non valido in Well-Known text alla posizione 12.
	at com.microsoft.sqlserver.jdbc.SQLServerSpatialDatatype.throwIllegalWKTPosition(SQLServerSpatialDatatype.java:1835)
	at com.microsoft.sqlserver.jdbc.SQLServerSpatialDatatype.checkEmptyKeyword(SQLServerSpatialDatatype.java:1489)
	at com.microsoft.sqlserver.jdbc.SQLServerSpatialDatatype.parseWKTForSerialization(SQLServerSpatialDatatype.java:380)
	at com.microsoft.sqlserver.jdbc.Geometry.<init>(Geometry.java:39)
	at com.microsoft.sqlserver.jdbc.Geometry.parse(Geometry.java:128)
	at org.geotools.data.sqlserver.GeometryZTest.main(GeometryZTest.java:9)
  1. Any other details that can be helpful: Code to reproduce:
import com.microsoft.sqlserver.jdbc.Geometry;
import com.microsoft.sqlserver.jdbc.SQLServerException;

public class GeometryZTest {

    public static void main(String[] args) throws SQLServerException {
        Geometry geometry = Geometry.parse("LINESTRING Z(0 0 0, 1 1 1)");
    }
}

As an addition, the same problem seems to happen with WKB, the code (and the database routines) cannot parse a valid 3D geometry encoding. To generate such encodings I’d suggest to use the Java Topology Suite WKTWriter and WKBWriter classes.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

0reactions
peterbaecommented, Jan 28, 2020

Closing the issue as it’s not a driver issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Oracle 3D WKT? — oracle-tech
I have tried your stated trick of using WKT as a medium between MDSYS. SDO_GEOMETRY and SDE. ST_GEOMETRY using supported "simple" 2D geometries ......
Read more >
Float point problems using Shapely using WKT
1 Answer 1 ... Knowing that Shapely and GEOS cannot reduce precision (floating-point precision problem, How to deal with rounding errors in ...
Read more >
Circle, Arcs and user defined Geometries and WKT conversion
Circle geometry exists in OpenLayers but because GeometryEncoder in ... WKT conversion that excludes Circle geometry type to be handles ...
Read more >
Convert java.lang.String geometry to jts Geometry
I assume that your geometry has the WKT (Well Known Text) format. If not, you can get it in the WKT format by...
Read more >
Geometry — pygeos documentation - Read the Docs
Geometry class is the central datatype in PyGEOS. An instance of Geometry is a container of the actual GEOSGeometry object. The Geometry object...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found