Thursday 15 June 2017

geoserver - SQL Server spatial data geometry type


I'm trying to link a GeoServer application to a SQL Server Spatial Database. The spatial data has been saved as Geography, but GeoServer can read only Geometry type.


So I'm using the following script to create an additional field of Geometry type:


UPDATE [dbo].[GeoBoundaries]

SET [GeoCoords] = geometry::STGeomFromWKB([SimplifiedCoords].STAsBinary(),[SimplifiedCoords].STSrid).MakeValid()
GO

The issue is with Russian Federation that has polygons crossing the 180 meridian.


The Geography data type is correctly shown:


enter image description here


instead, the Geometry data type has issues displaying the crossing meridian polygons: enter image description here


Obviously Geoserver is not able to read the GeoCoords field even if it is a geometry field and raise an error:


java.lang.RuntimeException: java.io.IOException: Error occured calculating bounds for GeoBoundaries
...

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: A .NET Framework error occurred during execution of user-defined routine or aggregate "geometry":

How can I correctly convert geography to geometry to be used by Geoserver?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...