3

MapServerQuerySublayer (Version 10) does not seem to support setting a definition query, although according to documentation it should using ImapServerSublayer2.LayerDescription as IMapserverSublayer. Nor does it support selections, i.e. rendering objects matching a query or selection differently.

What are our options when making an Engine application which contains a MapControl consuming only arcgisserver layers? In the application we would like to change an individual layer's definition query to only show object that matches the user's interest. We would also like to render some objects as "selected" to reflect user selections.

It would also be nice to be able to get the selected objects to the client as features, which also does not seem to be supported out of the box in ArcGisServer.

Any ideas on how to accomplish this?

Edit:

I don't think that we can wait for ESRI to fix this bug, so I'm looking for an alternate solution, which may include fetching the selection as features and use a local layer. Engine seems to lack support for fetching features from a map service without having to connect to the context itself (not using the Layer's connection) or fetching them one by one using identify. Using the Feature service seems like a good idea, but Engine has no built in functionality to from a Layer fetch IFeatures from the FeatureService. I think that there would be a more graceful way than having to involve extra connections to the server, which implies more configuration in the application.

7
  • 3
    See gis.stackexchange.com/questions/3827/…. It looks like it is either not supported, or it's a bug.
    – Petr Krebs
    Commented Feb 10, 2011 at 14:10
  • 2
    Have you considered using the Silverlight/WPF sdk instead of arcengine? I think the FeatureLayer.where works. Besides, it's free and certainly much easier to deploy than arcengine. Commented Feb 10, 2011 at 14:45
  • @petr-k I recieved NIM063392 resources.arcgis.com/content/nimbus-bug?bugID=TklNMDYzMzky in that case. Commented Feb 11, 2011 at 7:41
  • petr: I missed that Mattias had posted a similar question, we're actually working on the same project.
    – Stefan
    Commented Feb 11, 2011 at 9:41
  • @Kirk We dismissed Silverlight a long time ago. The application is actually doing a lot more that is hard to accomplish in silverlight. For this question its only the AGSserver layers that are interesting.
    – Stefan
    Commented Feb 11, 2011 at 10:06

3 Answers 3

2

I've never tried this, but it seems like you could write a custom layer that uses webclient to access the mapservice via a REST API query, with returngeometry=true.

The returned json string could then be converted into a list of geometries using Json.NET. ILayer.Draw would loop through this list and draw the geometries.

If you need a legend, you could implement ILegendInfo so that it returns symbols that have been fetched via SOAP.

1
  • 1
    When implementing the custom layer, it's also possible to stay in the ArcObjects world by using IMapServer. IMapServer.ExportMapImage takes an IMapDescription, where definition expressions for individual layers can be specified. This approach would actually mean reimplementing the existing layer objects, but working around the bugs it has.
    – Petr Krebs
    Commented Feb 11, 2011 at 17:16
1

The NIM063392 has been logged for the issue that IMapServerSubLayer doesn't honor ILayerDescription property DefinitionExpression. I have looked into the status of this NIM and it had been exported to the development team for a possible fix, but hasn't been fixed yet.

I found the issue root is actually caused by [NIM036788 Make IMapServeSubLayer::LayerDescription Read/Write. It is currently Read only.] Our developer replied in NIM036788 that

"IMapServeSubLayer::LayerDescription is read only. You will not be able to apply a new definition expression through a MapServerSubLayer. You would have to access the MapServer through the context requiring a DCOM connection. There is no workaround for an internet connection."

The only option is to use aDCOM connection to access the IMapServer object. For example:

 //DCOM connection
 ESRI.ArcGIS.ADF.Identity identity = new ESRI.ArcGIS.ADF.Identity("username", "passworld", "domain");
 ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection agsconnection;
 agsconnection = new ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection("servername", identity);
 agsconnection.Connect();
 ESRI.ArcGIS.Server.IServerObjectManager pSOM = agsconnection.ServerObjectManager;
 ESRI.ArcGIS.Server.IServerContext pServerContext = pSOM.CreateServerContext("map service name", "MapServer");

 //Access the IMapServer object
 ESRI.ArcGIS.Carto.IMapServer pMapServer = pServerContext.ServerObject as ESRI.ArcGIS.Carto.IMapServer;

 //Get the ILayerDescription of sublayer and apply a defintion expression
 ESRI.ArcGIS.Carto.IMapServerInfo pMapServerInfo = pMapServer.GetServerInfo(pMapServer.DefaultMapName);
 ESRI.ArcGIS.Carto.IMapDescription pMD = pMapServerInfo.DefaultMapDescription;
 ESRI.ArcGIS.Carto.ILayerDescription pLD = pMD.LayerDescriptions.get_Element(5); //5 is the id of sublayer
 pLD.DefinitionExpression = "Name = 'California'";
0
0

This isn't a bug, the functionality is just not implemented for the layer. Specifically IMapServerSublayer2.get_LayerDescription hands out a copy of the description, not an updatable reference. In almost all cases the ArcObjects help will list an object as get/put_ref if the accessor hands out a reference. The are occasionally usages of get/put for objects, but these are rare. This particular member has no put equivalent.

If you are just using service layers for an engine application, I'd recommend using the Silverlight/WPF API instead. It has everything you are looking for and excellent query support.

5
  • 2
    Then this behaviour should be clearly documented. I can think of many, many examples when the "rule" you describe does not apply. Anyway, from my point of view, my definition of a bug, by which I myself develop software, is that when the user or consumer of my API perceives something as a bug, then it IS a bug.
    – Petr Krebs
    Commented Feb 13, 2011 at 10:33
  • It is clearly documented here: help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/… Commented Feb 14, 2011 at 5:00
  • @craig-williams well that it works in other ESRI APIs and doesn't work in ArcObjects is the reason I consider this to be a bug. Commented Feb 14, 2011 at 8:37
  • ok, good resource to clarify the behavior. Still, I have always found it largery inconsistent. Anyway, the point is, for this particular property, there should be a means to change it, otherwise it is a quite an important feature missing in AO.
    – Petr Krebs
    Commented Feb 14, 2011 at 9:17
  • Understood. The AO MapServerLayer does not expose the full functionality of the MapService and that is the primary complaint. Commented Feb 14, 2011 at 19:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.