TheSwamp

Code Red => .NET => Topic started by: sigster on December 03, 2021, 06:42:10 PM

Title: Add WMS connection and add it to map
Post by: sigster on December 03, 2021, 06:42:10 PM


Hi



I was testing this code how to add WMS to Autocad
I can add the connection but I am wonder how can I add it to Layer in Display Manager and add to the map



https://forums.autodesk.com/t5/net/using-wms-fdo-for-map-laoding-in-aud-modal-space/td-p/4423709




Code: [Select]

        Dim manager As IConnectionManager = FeatureAccessManager.GetConnectionManager()

            Using connection As IConnection = manager.CreateConnection("OSGeo.WMS.4.2")
                Dim IConnectionPropertyDictionaryprops = connection.ConnectionInfo.ConnectionProperties

                IConnectionPropertyDictionaryprops.SetProperty("FeatureServer", "https://SERVER")
                IConnectionPropertyDictionaryprops.SetProperty("Username", "USERNAME")
                IConnectionPropertyDictionaryprops.SetProperty("Password", "PASSWORD")

                Try
                    connection.Open()
                Catch ex As Autodesk.AutoCAD.Runtime.Exception
                    ed.WriteMessage(ex.Message.ToString())
                End Try
            End Using


Regards
Sigster
Title: Re: Add WMS connection and add it to map
Post by: n.yuan on December 05, 2021, 01:20:53 PM
Well, if you use FDO directly to connect a FDO source (WMS, in your case), you can have access to FDO data (attributes and geometries), then it is up to you do decide what to do with the data.

You can write your own code to drawing native AutoCAD entities with the FDO geometries. Since you are talking about "layers" and "Display Manager", I assume you use AutoCAD Map or AutoCAD Civil. If so, you do not use FDO directly, you should use AutoCAD Map's Geospatial API (previously called Map Platform API) to connect to FDO source, which will create map layers (and map entities) in the drawing, the Geospatial API wrapped FDO API and allows you to present FDO data in AutoCAD Map as map layer/map entities.

You can search the net for AutoCAD Map programming document, such as this:

http://docs.autodesk.com/MAP/2014/ENU/Developer_Guides/index.html?url=filesMAP_GEO/GUID-295BB5A9-DA33-42C9-9C92-48764FBE96CD.htm,topicNumber=MAP_GEOd30e218 (http://docs.autodesk.com/MAP/2014/ENU/Developer_Guides/index.html?url=filesMAP_GEO/GUID-295BB5A9-DA33-42C9-9C92-48764FBE96CD.htm,topicNumber=MAP_GEOd30e218)

while it is for Acad Map 2014, it basically applied to all later versions, because there is no major update for the Geospatial API for years.

You should also download AUtoCAD Map ObjectARX SDK (not the AutoCAD ObjectARX SDK), not because it is required for writing code against Geospatial API, but because it comes with GeoSpatial API code samples that you can learn and get start with.

Hope this helps a bit.
Title: Re: Add WMS connection and add it to map
Post by: sigster on December 07, 2021, 06:32:11 AM
Thanks n.yuan