Place a constraint on the db.

************************************************************
USE [YOUR_DB]
GO

ALTER TABLE [dbo].[parcels]  WITH CHECK ADD  CONSTRAINT 
[enforce_srid_geometry_parcels] CHECK  (([geom].[STSrid]=(2925)))
GO

ALTER TABLE [dbo].[parcels] CHECK CONSTRAINT [enforce_srid_geometry_parcels]
GO


************************************************************

I do not know whether or not this will still be read if the geom is null.  You 
should use your workaround and test that though.

Martin Morrison
Application Engineer
Engineering Design Systems, Inc.
3780 Peters Creek Rd Ext SW
Roanoke, VA  24018
540.345.1410
gis.edsi.com

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Gunter Becker
Sent: Wednesday, July 17, 2013 6:12 AM
To: [email protected]
Subject: [mapguide-users] SQL Server Spatial and SRS for geometry data type

Hi,

I'm struggling with inserting geometries into SQL Server. After a coordinate 
system transformation all my geometries now have the appropriate SRS 
(SRID=25832). Before SRID was just 0.

Now when inserting new geometries via MapGuide/FDO into the tables I realized 
that sometimes they are written in the correct SRS (SRID=25832) and sometimes 
not (SRID=0). So I debugged the SQL that was send from MapGuide/FDO to the SQL 
Server and found out that the provider determine the SRID from the first row of 
the table where the geometry should be insert in:

SELECT TOP 1 [geom].STSrid as srid from [tablename]

BUT, when the first row has no geometry (geom=NULL) then this query returns 
NULL and the new geometry is written into the table with SRID=0 instead of the 
correct SRID=25832. (As a side note: that wouldn't have happen if there is a 
where-clause in this query like " WHERE geom IS NOT NULL")

MapGuide doesn't show up the new geometry since it has the wrong SRS. 
Is there a way to insert the geometry with the correct SRS? Can I use fdo 
schema tables? 
If yes, then which tables do I have to use to achieve my goal? Any other ideas?

Thanks, Gunter



--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/SQL-Server-Spatial-and-SRS-for-geometry-data-type-tp5067010.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
_______________________________________________
mapguide-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapguide-users

_______________________________________________
mapguide-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapguide-users

Reply via email to