Skip to content
Permalink
Browse files
Merge pull request #4327 from tomkralidis/issue-16320
[FEATURE] [needs-docs] MetaSearch: add support for ESRI MapServer/FeatureServer layer integration (fixes #16320)
  • Loading branch information
tomkralidis committed Apr 3, 2017
2 parents 9ac70a0 + c403994 commit baced7b7708d450cd5a0dede377e4747f7525133
Showing with 70 additions and 5 deletions.
  1. +40 −5 python/plugins/MetaSearch/dialogs/maindialog.py
  2. +10 −0 python/plugins/MetaSearch/link_types.py
  3. +20 −0 python/plugins/MetaSearch/ui/maindialog.ui
@@ -37,7 +37,9 @@
from urllib.request import build_opener, install_opener, ProxyHandler

from qgis.PyQt.QtCore import Qt
from qgis.PyQt.QtWidgets import QApplication, QDialog, QDialogButtonBox, QMessageBox, QTreeWidgetItem, QWidget
from qgis.PyQt.QtWidgets import (QApplication, QDialog, QComboBox,
QDialogButtonBox, QMessageBox,
QTreeWidgetItem, QWidget)
from qgis.PyQt.QtGui import QColor, QCursor

from qgis.core import (QgsApplication, QgsCoordinateReferenceSystem,
@@ -131,6 +133,8 @@ def __init__(self, iface):
self.mActionAddWms.triggered.connect(self.add_to_ows)
self.mActionAddWfs.triggered.connect(self.add_to_ows)
self.mActionAddWcs.triggered.connect(self.add_to_ows)
self.mActionAddAms.triggered.connect(self.add_to_ows)
self.mActionAddAfs.triggered.connect(self.add_to_ows)
self.btnShowXml.clicked.connect(self.show_xml)

# settings
@@ -609,12 +613,14 @@ def find_services(self, record, item):
wmswmst_link_types = list(map(str.upper, link_types.WMSWMST_LINK_TYPES))
wfs_link_types = list(map(str.upper, link_types.WFS_LINK_TYPES))
wcs_link_types = list(map(str.upper, link_types.WCS_LINK_TYPES))
ams_link_types = list(map(str.upper, link_types.AMS_LINK_TYPES))
afs_link_types = list(map(str.upper, link_types.AFS_LINK_TYPES))

# if the link type exists, and it is one of the acceptable
# interactive link types, then set
if all([link_type is not None,
link_type in wmswmst_link_types + wfs_link_types +
wcs_link_types]):
wcs_link_types + ams_link_types + afs_link_types]):
if link_type in wmswmst_link_types:
services['wms'] = link['url']
self.mActionAddWms.setEnabled(True)
@@ -624,6 +630,12 @@ def find_services(self, record, item):
if link_type in wcs_link_types:
services['wcs'] = link['url']
self.mActionAddWcs.setEnabled(True)
if link_type in ams_link_types:
services['ams'] = link['url']
self.mActionAddAms.setEnabled(True)
if link_type in afs_link_types:
services['afs'] = link['url']
self.mActionAddAfs.setEnabled(True)
self.tbAddData.setEnabled(True)

set_item_data(item, 'link', json.dumps(services))
@@ -708,14 +720,23 @@ def add_to_ows(self):
elif caller == 'mActionAddWcs':
stype = ['OGC:WCS', 'wcs', 'wcs']
data_url = item_data['wcs']
elif caller == 'mActionAddAms':
stype = ['ESRI:ArcGIS:MapServer', 'ams', 'arcgismapserver']
data_url = item_data['ams'].split('MapServer')[0] + 'MapServer'
elif caller == 'mActionAddAfs':
stype = ['ESRI:ArcGIS:FeatureServer', 'afs', 'arcgisfeatureserver']
data_url = item_data['afs'].split('FeatureServer')[0] + 'FeatureServer'

QApplication.restoreOverrideCursor()

sname = '%s from MetaSearch' % stype[1]

# store connection
# check if there is a connection with same name
self.settings.beginGroup('/Qgis/connections-%s' % stype[1])
if caller in ['mActionAddAms', 'mActionAddAfs']:
self.settings.beginGroup('/Qgis/connections-%s' % stype[2])
else:
self.settings.beginGroup('/Qgis/connections-%s' % stype[1])
keys = self.settings.childGroups()
self.settings.endGroup()

@@ -739,14 +760,16 @@ def add_to_ows(self):
sname = serialize_string(sname)

# no dups detected or overwrite is allowed
self.settings.beginGroup('/Qgis/connections-%s' % stype[1])
if caller in ['mActionAddAms', 'mActionAddAfs']:
self.settings.beginGroup('/Qgis/connections-%s' % stype[2])
else:
self.settings.beginGroup('/Qgis/connections-%s' % stype[1])
self.settings.setValue('/%s/url' % sname, clean_ows_url(data_url))
self.settings.endGroup()

# open provider window
ows_provider = QgsProviderRegistry.instance().selectWidget(stype[2],
self)

service_type = stype[0]

# connect dialog signals to iface slots
@@ -762,6 +785,14 @@ def add_to_ows(self):
ows_provider.addRasterLayer.connect(self.iface.addRasterLayer)
conn_cmb = ows_provider.findChild(QWidget, 'mConnectionsComboBox')
connect = 'on_mConnectButton_clicked'
elif service_type == 'ESRI:ArcGIS:MapServer':
ows_provider.addAction(self.iface.actionAddAmsLayer())
conn_cmb = ows_provider.findChild(QComboBox)
connect = 'connectToServer'
elif service_type == 'ESRI:ArcGIS:FeatureServer':
ows_provider.addAction(self.iface.actionAddAfsLayer())
conn_cmb = ows_provider.findChild(QComboBox)
connect = 'connectToServer'
ows_provider.setModal(False)
ows_provider.show()

@@ -772,6 +803,8 @@ def add_to_ows(self):
# only for wfs
if service_type == 'OGC:WFS':
ows_provider.on_cmbConnections_activated(index)
elif service_type in ['ESRI:ArcGIS:MapServer', 'ESRI:ArcGIS:FeatureServer']:
ows_provider.on_cmbConnections_activated(index)
getattr(ows_provider, connect)()

def show_metadata(self):
@@ -842,6 +875,8 @@ def reset_buttons(self, services=True, xml=True, navigation=True):
self.mActionAddWms.setEnabled(False)
self.mActionAddWfs.setEnabled(False)
self.mActionAddWcs.setEnabled(False)
self.mActionAddAms.setEnabled(False)
self.mActionAddAfs.setEnabled(False)

if xml:
self.btnShowXml.setEnabled(False)
@@ -46,3 +46,13 @@
'urn:x-esri:specification:ServiceType:wcs:url',
'urn:x-esri:specification:ServiceType:Gmd:URL.wcs'
]

AMS_LINK_TYPES = [
'ESRI:ArcGIS:MapServer',
'Esri REST: Map Service'
]

AFS_LINK_TYPES = [
'ESRI:ArcGIS:FeatureServer',
'Esri REST: Feature Service'
]
@@ -359,9 +359,29 @@
<string>Add WCS</string>
</property>
</action>
<action name="mActionAddAms">
<property name="icon">
<iconset>
<normaloff>:/images/themes/default/mActionAddAmsLayer.svg</normaloff>:/images/themes/default/mActionAddAmsLayer.svg</iconset>
</property>
<property name="text">
<string>Add ArcGIS MapServer</string>
</property>
</action>
<action name="mActionAddAfs">
<property name="icon">
<iconset>
<normaloff>:/images/themes/default/mActionAddAfsLayer.svg</normaloff>:/images/themes/default/mActionAddAfsLayer.svg</iconset>
</property>
<property name="text">
<string>Add ArcGIS FeatureServer</string>
</property>
</action>
<addaction name="mActionAddWms"/>
<addaction name="mActionAddWfs"/>
<addaction name="mActionAddWcs"/>
<addaction name="mActionAddAms"/>
<addaction name="mActionAddAfs"/>
</widget>
</item>
</layout>

0 comments on commit baced7b

Please sign in to comment.