Skip to content

Commit

Permalink
refactor link types (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Mar 23, 2014
1 parent 3cb1c11 commit 48a7c51
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 18 deletions.
24 changes: 6 additions & 18 deletions plugin/MetaSearch/dialogs/maindialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
49 changes: 49 additions & 0 deletions plugin/MetaSearch/link_types.py
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/copyleft/gpl.html>. 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'
]

0 comments on commit 48a7c51

Please sign in to comment.