From 48a7c51b7cd481e909c760c34a153ef8fbc957ca Mon Sep 17 00:00:00 2001 From: Tom Kralidis Date: Sun, 23 Mar 2014 16:31:40 -0400 Subject: [PATCH] refactor link types (#43) --- plugin/MetaSearch/dialogs/maindialog.py | 24 +++--------- plugin/MetaSearch/link_types.py | 49 +++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 18 deletions(-) create mode 100644 plugin/MetaSearch/link_types.py diff --git a/plugin/MetaSearch/dialogs/maindialog.py b/plugin/MetaSearch/dialogs/maindialog.py index 8e739a4..8f1a07a 100644 --- a/plugin/MetaSearch/dialogs/maindialog.py +++ b/plugin/MetaSearch/dialogs/maindialog.py @@ -54,6 +54,7 @@ from MetaSearch.dialogs.newconnectiondialog import NewConnectionDialog from MetaSearch.dialogs.recorddialog import RecordDialog from MetaSearch.dialogs.xmldialog import XMLDialog +from MetaSearch import link_types from MetaSearch.util import (get_connections_from_file, highlight_xml, open_url, render_template, StaticContext) from MetaSearch.ui.maindialog import Ui_MetaSearchDialog @@ -570,28 +571,15 @@ def find_services(self, record, item): if link_type is not None: link_type = link_type.upper() - # acceptable interactive link types - wmswmst_link_types = ['OGC:WMS', 'OGC:WMTS', - 'OGC:WMS-1.1.1-HTTP-GET-MAP', - 'OGC:WMS-1.1.1-HTTP-GET-CAPABILITIES', - 'OGC:WMS-1.3.0-HTTP-GET-MAP', - 'OGC:WMS-1.3.0-HTTP-GET-CAPABILITIES', - 'urn:x-esri:specification:ServiceType:wms:url', - 'urn:x-esri:specification:ServiceType:Gmd:URL.wms'] - wfs_link_types = ['OGC:WFS', - 'OGC:WFS-1.0.0-HTTP-GET-CAPABILITIES', - 'OGC:WFS-1.1.0-HTTP-GET-CAPABILITIES', - 'urn:x-esri:specification:ServiceType:wfs:url', - 'urn:x-esri:specification:ServiceType:Gmd:URL.wfs'] - wcs_link_types = ['OGC:WCS', - 'OGC:WCS-1.1.0-HTTP-GET-CAPABILITIES', - 'urn:x-esri:specification:ServiceType:wcs:url', - 'urn:x-esri:specification:ServiceType:Gmd:URL.wcs'] + wmswmst_link_types = map(str.upper, link_types.WMSWMST_LINK_TYPES) + wfs_link_types = map(str.upper, link_types.WFS_LINK_TYPES) + wcs_link_types = map(str.upper, link_types.WCS_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]): + link_type in wmswmst_link_types + wfs_link_types + + wcs_link_types]): if link_type in wmswmst_link_types: services['wms'] = link['url'] self.btnAddToWms.setEnabled(True) diff --git a/plugin/MetaSearch/link_types.py b/plugin/MetaSearch/link_types.py new file mode 100644 index 0000000..e36339c --- /dev/null +++ b/plugin/MetaSearch/link_types.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# MetaSearch Catalogue Client +# +# Copyright (C) 2014 Tom Kralidis (tomkralidis@gmail.com) +# +# This source is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation; either version 2 of the License, or (at your option) +# any later version. +# +# This code is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# A copy of the GNU General Public License is available on the World Wide Web +# at . You can also obtain it by writing +# to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA. +# +############################################################################### + +WMSWMST_LINK_TYPES = [ + 'OGC:WMS', + 'OGC:WMTS', + 'OGC:WMS-1.1.1-http-get-map', + 'OGC:WMS-1.1.1-http-get-capabilities', + 'OGC:WMS-1.3.0-http-get-map', + 'OGC:WMS-1.3.0-http-get-capabilities', + 'urn:x-esri:specification:ServiceType:wms:url', + 'urn:x-esri:specification:ServiceType:Gmd:URL.wms' +] + +WFS_LINK_TYPES = [ + 'OGC:WFS', + 'OGC:WFS-1.0.0-http-get-capabilities', + 'OGC:WFS-1.1.0-http-get-capabilities', + 'urn:x-esri:specification:ServiceType:wfs:url', + 'urn:x-esri:specification:ServiceType:Gmd:URL.wfs' +] + +WCS_LINK_TYPES = [ + 'OGC:WCS', + 'OGC:WCS-1.1.0-http-get-capabilities', + 'urn:x-esri:specification:ServiceType:wcs:url', + 'urn:x-esri:specification:ServiceType:Gmd:URL.wcs' +]