Skip to content

Using MSSQL Spatial with AutoCAD Map 3D and Mapguide Enterprise

by troy.miller on December 19th, 2011

Spatial databases allow for instant database connectivity just like normal databases but now hold the spatial components. There is no longer a need to organize directories of shape files and keep track of which one is the most current. The database handles this and allows many connections to the same data. Microsoft SQL 2008 is the first version to allow for the storage of spatial data. MSSQL 2008 is a good alternative to Oracle Spatial because its ease of setup especially for those not used to the complexities of Oracle.

The FDO is the final link between the spatial database, AutoCAD Map 3D, and Mapguide Enterprise. The Feature Data Object is a layer of software that allows for standard operations between feature sources like SQL Spatial and client software like AutoCAD Map 3D. The FDO is used to generate the feature stores which include all the tables needed to handle the FDO schema.

Creating the Feature Store

While you could create a schema from scratch, we are going to import a schema and data from an existing SHP file.

Open a new DWG, set the coordinate system, and set the units.

Open the Task Pane > Data > Connect To Data

Select “Add SHP Connection” pick the SHP file to load into SQL Spatial, and click Connect.

The coordinate systems should match. Make sure the SHP feature source is checked and click Add to Map.

AutoCAD will add the SHP file as layer to the map.

Now we are going to add our SQL Spatial connection. With the Data Connection panel still open, click “Add SQL Server Spatial Connection”. Enter the Server name and log in.

Click the Data Store drop down box and select Add New Data Store.

Enter a Data Store Name which will be the Database name in SQL Server.

Select the coordinate system for the spatial data.

Check the box that says “Use FDO enabled schema”. This will allow for optimistic concurrency support in the database.

Click OK to create the data store.

A pop up will ask to edit the schema. Select Edit Later.

Close the Data Connect Panel

In the Task Pane, click the Map Explorer tab.

Click Tools > Bulk Copy…

The Bulk Copy Dialog will appear.

In the From section, select Source > Feature Sources > SHP_1 (Or the name of your SHP connection)

In the To section, select Source > Feature Sources > SqlServeSpatial_1 (Or the name of your SQLS connection)

In the Select items to copy section check the Default box.

This will automatically setup the schema to transfer from the SHP file to the SQL Spatial table.

Set the schema how you would like in the SQL table by unchecking any fields you do not want transferred.

Click Copy Now to start the transfer.

Once it completes you can close out of the dialogs.

Now that it is loaded into SQL Spatial, we need to add it as a layer in AutoCAD.

In the Task Pane click Data > Connect to Data

Click on your SQL Spatial connection (SqlServerSpatial_1)

Make sure the feature type you added to SQL Spatial is checked and click Add to Map.

While in this screen, right click on your SHP connection and disconnect it. The SHP layer is no longer needed.

You now have the SQL Spatial data loaded into AutoCAD

To view attributes, highlight the new layer and click the Table icon

Connecting SQL Spatial to Mapguide Enterprise

This tutorial assumes some knowledge on how to setup a Mapguide Enterprise site with Mapguide Studio. We will be using the OSGeo Fdo provider for SQL Server Spatial.

Create a new Data Connection.

Enter the Server name, login credentials, click Test Connection, and select newly created Data Store.

Save your Data Connection in the Data connections directory

Create a new layer and select your Data Connection as the Data Resource.

Make sure you have the correct Feature Class and theme the layer as desired.

Add the Mapguide layer to a map and view the new layer coming from SQL Server Spatial

Here is the beauty of this setup.

Switch back to AutoCAD Map and move a line.

Right click on the layer and select Check in.

Switch back to Mapguide and pan the screen.

The data is updated instantly.

This tutorial covered how to use SQL Server Spatial to store your spatial data. The FDO tools are used to import an existing SHP file into a SQL Spatial data store. This data can be edited in AutoCAD Map and is instantly available in Mapguide Enterprise.

From → MapGuide

No comments yet

Leave a Reply

You must be logged in to post a comment.