Skip to content

Commit

Permalink
feat(registration): Support for individual dynamic layers
Browse files Browse the repository at this point in the history
Permits users to specify a feature layer endpoint as esriMapServer, for dynamic layer support in RAMP.

Closes #66
  • Loading branch information
dan-bowerman authored and james-rae committed Feb 27, 2018
1 parent a0761db commit 3942702
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
14 changes: 12 additions & 2 deletions services/regparse/universal.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,19 @@ def make_node(key, json_request, config):
n['id'] = make_id(key, lang)
ltype = svc_types[lang]
n['layerType'] = remapped_types.get(ltype, ltype)
if 'service_type' in json_request[lang] and json_request[lang]['service_type'] != svc_types[lang]:
if 'service_type' in json_request[lang] and json_request[lang]['service_type'] != svc_types[lang] \
and json_request[lang]['service_type'] != "esriMapServer":
msg = 'Mismatched service type in {0} object, endpoint identified as {1} but provided as {2}' \
.format(lang, svc_types[lang], json_request[lang]['service_type'])
raise ServiceEndpointException(msg)
n['url'] = json_request[lang]['service_url']
if json_request[lang]['service_type'] == 'esriMapServer' and \
re.match('.*?(\/[0-9]*)$', json_request[lang]['service_url']):
n['layerType'] = 'esriDynamic'
layerid = re.sub('.*?(\/[0-9]*)$', r'\1', json_request[lang]['service_url']).replace('/', '')
n['url'] = json_request[lang]['service_url']
n['layerEntries'] = [{'index': int(layerid)}]
else:
n['url'] = json_request[lang]['service_url']
m_url, c_url = metadata.get_url(json_request[lang], config)
if n['url'].endswith("FeatureServer"):
msg = 'FeatureServer registration must specify a feature layer'
Expand All @@ -137,4 +145,6 @@ def make_node(key, json_request, config):
v1[lang] = ogc.make_v1_wms_node(json_request[lang], n)
elif ltype == ServiceTypes.FEATURE:
v1[lang] = esri.make_v1_feature_node(json_request[lang], n)
if n['layerType'] == 'esriDynamic':
n['url'] = n['url'].rstrip('/0123456789')
return node, v1
18 changes: 16 additions & 2 deletions static/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,11 @@
<input type="button" class="btn btn-default samplejson" value="esriFeature" data-obj="sampleFeature" />
<input type="button" class="btn btn-default samplejson" value="esriFeature (Zoom Scale)" data-obj="sampleZoomScale" />
<input type="button" class="btn btn-default samplejson" value="esriFeature (Class Breaks)" data-obj="sampleFeature2" />
<input type="button" class="btn btn-default samplejson" value="esriFeature (Specific Sublayers)" data-obj="sampleScrapeOnly" />
<input type="button" class="btn btn-default samplejson" value="esriDynamic (Specific Sublayers)" data-obj="sampleScrapeOnly" />
<input type="button" class="btn btn-default samplejson" value="esriFeature (w/ Metadata)" data-obj="sampleCatalogue" />
<input type="button" class="btn btn-default samplejson" value="esriFeature (Display Field)" data-obj="sampleDisplayField" />
<input type="button" class="btn btn-default samplejson" value="esriFeature (Update)" data-obj="sampleUpdateFeature" /><br/><br/>
<input type="button" class="btn btn-default samplejson" value="esriDynamic (Single FeatureLayer)" data-obj="sampleDynamic" />
<input type="button" class="btn btn-default samplejson" value="esriImage" data-obj="sampleImage" />
<input type="button" class="btn btn-default samplejson" value="esriTile" data-obj="sampleTile" />
<input type="button" class="btn btn-default samplejson" value="esri Group Layer (recursive)" data-obj="sampleRecursive" />
Expand Down Expand Up @@ -356,6 +357,19 @@
"service_name": "Railways"
},
"version": "2.0"
},
sampleDynamic = {
"fr": {
"service_url": "http://section917.cloudapp.net/arcgis/rest/services/JOSM/Oilsands_fr/MapServer/20",
"service_type": "esriMapServer",
"service_name": "Surveillance de la situation et des tendances d'oiseaux terrestres inscrits rares et difficiles à surveiller"
},
"en": {
"service_url": "http://section917.cloudapp.net/arcgis/rest/services/JOSM/Oilsands_en/MapServer/20",
"service_type": "esriMapServer",
"service_name": "Status and Trend Monitoring of Listed, Rare, and Difficult-to-Monitor Landbirds"
},
"version": "2.0"
};

function get_versioned_url() {
Expand Down Expand Up @@ -558,7 +572,7 @@

$('#upgradetest').click( function() {
var s = get_sig_params("upgrade"),
sig = sign( s.key, s.path, s.id, s.isodate ),
sig = sign( s.key, s.path, s.id, s.isodate, '' ),
h = make_headers(s,sig);
console.log(h);
$.ajax({
Expand Down

0 comments on commit 3942702

Please sign in to comment.