GeoNode / geonode

GeoNode is an open source platform that facilitates the creation, sharing, and collaborative use of geospatial data.
https://geonode.org/
Other
1.47k stars 1.13k forks source link

ArcGIS REST MapServer #6353

Closed Adriana-Martinez closed 4 years ago

Adriana-Martinez commented 4 years ago

Expected Behavior

Add layers using remote service from ArcGIS REST Map Server

Actual Behavior

Error: Could not connect to the service at https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer

Steps to Reproduce the Problem

  1. Add url of remote service: https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer
  2. Select ArcGIS REST MapServer
  3. Click in Create button
  4. Error: Could not connect to the service at https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer

Specifications

afabiani commented 4 years ago

Fixed through https://github.com/GeoNode/geonode/pull/6355

mahdin75 commented 4 years ago

I had the same issue, and I installed gn-arcrest==10.5.1 instead of gn-arcrest==10.5. after restarting Django and Nginx docker containers nothing changed. Does this change solve this issue?

malnajdi commented 4 years ago

as some discussion between me and @afabiani i noticed the rest:

trying to import resources from an ArcGIS Web Map Service I got the error code below:

Traceback (most recent call last):
  File "/usr/src/geonode/geonode/services/serviceprocessors/arcgis.py", line 140, in get_resources
    return self._parse_layers(self.parsed_service.layers)
  File "/usr/src/geonode/geonode/services/serviceprocessors/arcgis.py", line 149, in _parse_layers
    map_layers.extend(self._parse_layers(lyr.subLayers))
  File "/usr/local/lib/python3.8/site-packages/arcrest/server.py", line 769, in subLayers
    return [self._get_subfolder("../%s/" %
  File "/usr/local/lib/python3.8/site-packages/arcrest/server.py", line 770, in <listcomp>
    layer['parentLayer']['id'],
KeyError: 'parentLayer'

This is a sample structure of the received data.

"layers": [
  {
   "id": 0,
   "name": "Street_Naming",
   "parentLayerId": -1,
   "defaultVisibility": true,
   "subLayerIds": [
    1
   ],
   "minScale": 0,
   "maxScale": 0
  },

Also it seems that the demo url is giving the same issue https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer?f=pjson

Changing the code to

@property
def parentLayer(self):
    if self._json_struct.get('parentLayer'):
        return self._get_subfolder("../%s/" %
                               self._json_struct['parentLayer']['id'],
                               MapLayer)
    if self._json_struct.get('parentLayerId'):
        return self._get_subfolder("../%s/" %
                               self._json_struct['parentLayerId'],
                               MapLayer)
@property
def subLayers(self):
    sub_layers = []
    for layer in self._json_struct['subLayers']:
        if layer.get('parentLayer'):
            value = self._get_subfolder("../%s/" % layer['parentLayer']['id'], MapLayer)
            sub_layers.append(value)

        if layer.get('parentLayerId'):
            value = self._get_subfolder("../%s/" % layer['parentLayerId'], MapLayer)
            sub_layers.append(value)

    return sub_layers

seems to fix the issue

afabiani commented 4 years ago

@malnajdi thanks, I'll send a patch ASAP for this

afabiani commented 4 years ago

@malnajdi @mahdin75 @Adriana-Martinez please try out

pip install gn-arcrest==10.5.3

malnajdi commented 4 years ago

@afabiani I think this issue can be closed