jshirota / PreStorm

A Parallel REST Client for ArcGIS Server
17 stars 2 forks source link

Parent\Sublayer support (group layers) #2

Closed gertgeringer closed 7 years ago

gertgeringer commented 7 years ago

Hi Jiro,

Thanks for this useful client.

I went through the documentation and did not see any functionality relating to parent and sub-layer feature of AGS. Am I missing something?

For example, counties is the parent layer and Coarse Counties and Detailed Counties the sub layers.

{
      "id" : 2, 
      "name" : "Counties", 
      "parentLayerId" : -1, 
      "defaultVisibility" : true, 
      "subLayerIds" : [3, 4], 
      "minScale" : 0, 
      "maxScale" : 0
    }, 
    {
      "id" : 3, 
      "name" : "Coarse Counties", 
      "parentLayerId" : 2, 
      "defaultVisibility" : true, 
      "subLayerIds" : null, 
      "minScale" : 0, 
      "maxScale" : 1000001
    }, 
    {
      "id" : 4, 
      "name" : "Detailed Counties", 
      "parentLayerId" : 2, 
      "defaultVisibility" : true, 
      "subLayerIds" : null, 
      "minScale" : 1000000, 
      "maxScale" : 0
    }

Thanks

jshirota commented 7 years ago

You can just treat each sub layer as its own collection of features. In the following example, CoarseCounty and DetailedCounty seem to have the same attributes. In this case, you can make them into one County class.

        var service = new Service(
            "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer");

        foreach (var coarseCounty in service.Download<CoarseCounty>("Coarse Counties"))
        {
            Console.WriteLine(coarseCounty.OID);
        }

        foreach (var detailedCounty in service.Download<DetailedCounty>("Detailed Counties"))
        {
            Console.WriteLine(detailedCounty.OID);
        }
gertgeringer commented 7 years ago

Thanks for your reply Jiro,

That would work if the service you are working with is constan., In my case the service is dynamic (the user enters a service url). So I have decided just to parse the json using a normal http request, and extract the layer hierarchy from there.

Regards