Select to view content in your preferred language

Adding/Editing Definition Query on ImageServiceLayer silently fails

200
3
3 weeks ago
FanisDeligiannis
New Contributor II

Hello. I am loading an ImageServiceLayer from a URL. Through the UI, I can add a Definition Query to it.

Through the SDK, I can see the previously created Definition Query. But I cannot add, edit or remove it in any way.

 

ImageServiceLayer ISL = null;

List<Layer> layers = map.GetLayersAsFlattenedList().ToList();
foreach (var layer in layers)
{
    if (layer is ImageServiceLayer)
    {
        if (layer.Name == "ImageLayer")
            ISL = layer as ImageServiceLayer;
    }
}

if (ISL == null)
{
    Uri uri = new Uri("...");
    ISL = LayerFactory.Instance.CreateLayer(uri, map, 0) as ImageServiceLayer;
}

// If I have set a Definition Query through ArcGIS Pro UI, I can read it using ISL.DefinitionQuery

DefinitionQuery dq = new DefinitionQuery("QueryName", "OBJECTID = 5");
ISL.InsertDefinitionQuery(dq, true); // This does nothing.

 

I have tried a bunch of stuff but nothing seems to work. I can't edit an existing Definition Query, I can't remove it, I can't add a new one. Am I doing something wrong, or is it bugged?

0 Kudos
3 Replies
UmaHarano
Esri Regular Contributor

Hi

I see the same issue. Thanks for reporting this one. I have submitted an issue to the development team that owns this functionality.

Thanks!

Uma

FanisDeligiannis
New Contributor II

Will this be fixed in the next version?

0 Kudos
UmaHarano
Esri Regular Contributor

@FanisDeligiannis 

I can post back to this thread if I have an update on this issue. But here is a workaround to access and set queries. You can access the CIM Definition of the ImageService Layer - this will give you access to the definition queries. Here is a code snippet that shows you how to do this.

 

        var definition  = imageServiceLayer.GetDefinition() as CIMImageServiceLayer;
        var featureTable = definition.FeatureTable;
        //This is a list of all the definition queries
        var defnFilterChoices = featureTable.DefinitionFilterChoices; 
        //Iterate through the definition queries
        foreach (var defnFilterChoice in defnFilterChoices)
        {
         //access the definition queries here
         var cimDefinitionFilter = defnFilterChoice as CIMDefinitionFilter;
          var queryName = cimDefinitionFilter.Name;
          var expression = cimDefinitionFilter.DefinitionExpression;
        }
        //To activate a definition query
        featureTable.DefinitionExpression = "Name = '76264301'"; //example
        featureTable.DefinitionExpressionName = "Query 1"; //example

        //Set defintion
        imageServiceLayer.SetDefinition(definition);