This project is read-only.

MsSqlSpatial 0.1.0 Released

Topics: User Forum
Jan 31, 2007 at 5:17 PM
In case you haven't noticed, there's a new release of MsSqlSpatial. Download, deploy and enjoy 0.1.0 Production.

The latest improvements include some fine tunings on spatial indexes, so you could see a performance improvement in some cases. On the other hand, upgrading will be slower if you have big tables, so you are warned.

If you are a SharpMap user, there's also an upgrade of the MsSqlSpatial data provider. See SharpMap's changeset 17461.

Best regards,
Ricardo Stuven.
Jan 31, 2007 at 6:33 PM
Hi Ricardo!

Great work and congrats to the new release.

The MsSqlSpatial provider for SharpMap is failing for me.

An exception is thrown in the GetExtent method.

I changed the sql string into this:
string strSQL = string.Format("SELECT ST.AsBinary(ST.EnvelopeQueryWhere('{0}', '{1}', '{2}'))", this.Table, this.GeometryColumn, this.DefinitionQuery);

Jan 31, 2007 at 7:00 PM
Edited Jan 31, 2007 at 7:07 PM
Oops. Fixed in changeset 17470. Thank you.

Best regards,
Ricardo Stuven.
Feb 1, 2007 at 11:37 AM
Just upgraded to the above version, downloaded an recompiled SharpMap for the latest provider. I'm getting an error when using this code:

// Get the area needed
SharpMap.Layers.VectorLayer area = new SharpMap.Layers.VectorLayer("area");
SharpMap.Data.Providers.MsSqlSpatial areaData = new SharpMap.Data.Providers.MsSqlSpatial("Server=localhost;Database=***;Uid=***;Pwd=***", "meridian_district_boundaries", "the_geom", "oid");
areaData.DefinitionQuery = "ons = '" + Request["ons"] + "'";
area.DataSource = areaData;
// Zoom to area

What the code basically does is to get a specific polygon from the database based on the value of the column ons and then zoom to that polygon on the map, showing the entire polygon. This is within the context of some other datasets that I haven't shown in the above code, so using ZoomToExtents() isn't suitable as it would zoom to a map of the entire UK, not just the district I am interested in.

The error I am getting is:


Incorrect syntax near '00'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near '00'.

The stack trace shows:

[SqlException (0x80131904): Incorrect syntax near '00'.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +857242
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734854
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838
   System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +31
   System.Data.SqlClient.SqlDataReader.get_MetaData() +62
   System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +297
   System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +886
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +32
   System.Data.SqlClient.SqlCommand.ExecuteScalar() +137
   SharpMap.Data.Providers.MsSqlSpatial.GetExtents() +186
   SharpMap.Layers.VectorLayer.get_Envelope() +43
   SharpMapTest.Test.Page_Load(Object sender, EventArgs e) +2360
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061

As an example, the URL that I used for the above was "http://testing/SharpMap/sharpmap.aspx?ons=00NA" which should cause the map to centre on the Isle of Anglesey in the UK. If I change the code so that it simply zooms to the extents of the map (ie. the full UK) and apply a style to the selected area (eg. a red outline), then it all runs fine and Anglesey would appear on the map as a red-outlined polygon.

It would appear, to me at least, that the problem lies in getting the extents of the returned dataset. I also get the same error if I attempt to access "map.GetExtents()"

As a comparison, this exact code worked fine yesterday before downloading and updating to the latest versions, so it's certainly a recently introduced bug.
Feb 1, 2007 at 1:51 PM
Fixed in changeset 17565.

Best regards,
Ricardo Stuven.
Feb 1, 2007 at 3:16 PM
Thank you, that solved the problem perfectly, and the new version does indeed appear to work slightly faster!