"Resample" or "Clip" expression for WMS connection

keith_sowinski
Advocate
Advocate

"Resample" or "Clip" expression for WMS connection

keith_sowinski
Advocate
Advocate

I need to create a custom command to clip or resample a raster image provided by a WMS connection. Whenever I ask this question, I usually just get the response "use the provided Resample Raster" command. However, that does not meet my requirements. I need to create a custom command so the user can pick the clip extents (instead of using the view extents), and so I can re-load the clip for subsequent sessions. 

 

I see the appropriate expression capabilities listed here, but I cannot find any examples for applying these expressions to the WMS connection.

Here is the snippet if from the "OSGeo FDO Provider for WMS" section:

keithsowinski_0-1686682571720.png

 

Here is the code that I have so far, but I'm not even sure if I'm on the right track.

using Autodesk.Gis.Map.Platform;
using OSGeo.FDO.Commands;
using OSGeo.FDO.Connections;
using OSGeo.FDO.Connections.Capabilities;
using OSGeo.FDO.Expression;
using OSGeo.MapGuide;

namespace MapServices
{
    public class WmsLayer
    {
        public static void ClipMapLayer(string layerName, double minX, double minY, double maxX, double maxY)
        {
            AcMapFeatureService fs = AcMapServiceFactory.GetService(MgServiceType.FeatureService) as AcMapFeatureService;

            //Get the current Map.
            AcMapMap currentMap = AcMapMap.GetCurrentMap();

            //Get the collecton of Map 3D layers
            MgLayerCollection layers = currentMap.GetLayers();
            if (layers.Contains(layerName)) //Make sure the specified Map 3D layer exists
            {
                //Get the specified Map 3D layer with the Raster image.
                MgLayerBase lyr = layers.GetItem(layerName);                
                
                //Get the resource identifier
                MgResourceIdentifier identifier = new MgResourceIdentifier(lyr.FeatureSourceId); 

                //Get the FDO connection from the resource
                IConnection con = fs.GetFdoConnection(identifier);  

                //I can get the Expression capabilities from the connection, but what do I do with that??
                IExpressionCapabilities expCaps = con.ExpressionCapabilities;
                ExpressionType[] types = expCaps.ExpressionTypes;
                FunctionDefinitionCollection funcs = expCaps.Functions;

                //Is this how to create the expresion?
                //How do I pass the inputs into the expression?
                //How a BLOB created from the raster?
                Expression exp = Expression.Parse("CLIP(raster, minX, minY, maxX, maxY)");                

                //Do I somehow pass the expression into an ICommand???  No idea what command type is correct.
                ICommand cmd = con.CreateCommand(CommandType.CommandType_Select); 
            }
        }
    }
}

 

0 Likes
Reply
127 Views
0 Replies
Replies (0)