Skip to main content
Question

Bug in JDBC SQL Server Spatial Writer - when geometry is empty


nordpil
Supporter
Forum|alt.badge.img+10

Hi,

I have a very basic workbench in FME 2022.2.8

Reading features from a MSSQL table and writing to another, it is a FeatureReader/FeatureWriter combon in a dynamic workflow using the schema from the FeatureReader. This is using JDBC MSSQL Spatial.

If the geometry column is set to EMPTY the writing fails with the message:

MS SQL Server Spatial (JDBC) Writer: Error writing feature. Error: IFMEFeature.exportGeometryToOGCWKB: Unable to export geometry to OGC WKB

Examining the feature in the database one can find it using SHAPE.STIsEmpty() = 1 and  SHAPE.STAsText() returns “GEOMETRYCOLLECTION EMPTY”

3 replies

hkingsbury
Celebrity
Forum|alt.badge.img+53
  • Celebrity
  • March 9, 2025

Can you share that problematic feature with us to look at? Saving it as .FFS would be perfect


nordpil
Supporter
Forum|alt.badge.img+10
  • Author
  • Supporter
  • March 11, 2025

@hkingsbury simplest is just to create a new table with a geometry column:

CREATE TABLE test_jdbc_shape (     SHAPE geometry NULL );

INSERT INTO test_jdbc_shape (SHAPE) VALUES      ('GEOMETRYCOLLECTION EMPTY'),      ('POLYGON ((421088.4296000004 6880213.433899999, 421088.49170000013 6880208.436799999, 421098.4857999999 6880208.561099999, 421088.4296000004 6880213.433899999))');

Created a row with a polygon there too just for testing/comparison…

To reproduce:

  • FeatureReader → FeatureWriter MSSQL/JDBC Spatial
    • the empty geometry will faill with the error in the first message - it won’t fail the workspace, it will just skip writing this feature
  • FeatureReader → FeatureWriter MSSQL Spatial (non-JDBC)
    • works fine

hkingsbury
Celebrity
Forum|alt.badge.img+53
  • Celebrity
  • March 13, 2025

I can replicate it in version up to 2024.2 (don’t have anything newer)

Looking at the way FME reads that first geometry it treats it as an aggregate with no parts (aligns with it being an empty geometry collection).

If you map it to a null geometry it writes fine


I don't necessarily disagree with it not being written as you could argue it is an invalid geometry, BUT SQL lets you create it (as shown in the INSERT statement).

Might be worth raising a bug. Also tagging ​@ctredinnick as he knows much more about SQL than I do


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings