Skip to content

Commit

Permalink
Merge pull request #52 from linz/order_srs
Browse files Browse the repository at this point in the history
order and filter srs as per #47
  • Loading branch information
Simon Planzer committed Mar 12, 2019
2 parents 807b4dc + cdd7058 commit 144bede
Show file tree
Hide file tree
Showing 33 changed files with 173 additions and 150 deletions.
11 changes: 2 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,16 @@ env:
matrix:
- QGIS_VERSION_TAG=master
language: python
cache:
directories:
- "$HOME/.cache/pip"

python:
- '3.6'
branches:
only:
- master_qgis3
addons:
apt:
packages:
- git
- python-software-properties

before_install:
- docker pull ${IMAGE}:${QGIS_VERSION_TAG}
install:
- pip install --upgrade pip
- docker run -d --name qgis-testing-environment -v ${TRAVIS_BUILD_DIR}:/tests_directory
-e LDI_LINZ_KEY -e LDI_MFE_KEY -e LDI_NZDF_KEY -e DISPLAY=:99 ${IMAGE}:${QGIS_VERSION_TAG}
- sleep 10
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ the plugin is started.
The left hand panel allows users to filter by service / protocol types (either, All, WFS, WMS, WMTS).
All column headers can be toggled to allow ascending or descending ordering of their data.
Text can be entered in the "Filter Data Sets" search bar to filter the datasets by keyword.
## Source Code, Further Documentation and Feedback
## Source Code and Feedback
Please see the [LINZ-Data-Importer](https://github.com/linz/linz-data-importer/) repository on GitHub.

## Dev Notes
Expand Down
107 changes: 0 additions & 107 deletions linz-data-importer/plugin_upload.py

This file was deleted.

Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


import os

#from .ExtendedCombobox import ExtendedCombobox
from PyQt5 import QtGui, QtWidgets, uic

FORM_CLASS, _ = uic.loadUiType(os.path.join(
Expand Down Expand Up @@ -44,4 +44,4 @@ def __init__(self, parent=None):
# }
# """
# )


Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QComboBox" name="uCRSCombo">
<widget class="ExtendedCombobox" name="uCRSCombo">
<property name="maximumSize">
<size>
<width>160</width>
Expand Down Expand Up @@ -819,9 +819,15 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ExtendedCombobox</class>
<extends>QComboBox</extends>
<header>linz_data_importer.tablemodel.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>uTextFilter</tabstop>
<tabstop>uCRSCombo</tabstop>
<tabstop>uBtnImport</tabstop>
<tabstop>uListOptions</tabstop>
<tabstop>uTableView</tabstop>
Expand Down
4 changes: 4 additions & 0 deletions linz_data_importer/gui/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import sys
from os.path import dirname, abspath
sys.path.append(dirname(dirname(dirname(abspath(__file__)))))

File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* see the LICENSE file for more information *
***************************************************************************/
"""
from __future__ import absolute_import

# This program is released under the terms of the 3 clause BSD license. See the
# LICENSE file for more information.
Expand All @@ -24,7 +23,7 @@
from qgis.PyQt.QtCore import QSettings, QTranslator, qVersion, QCoreApplication, Qt, QRegExp, QSize, Qt

from qgis.PyQt.QtWidgets import QAction, QListWidgetItem, QHeaderView, QMenu, QToolButton
from qgis.PyQt.QtGui import QIcon, QPixmap, QImage
from qgis.PyQt.QtGui import QIcon, QPixmap, QImage, QStandardItemModel, QStandardItem
from qgis.PyQt.QtCore import QSortFilterProxyModel
from qgis.core import (QgsRasterLayer, QgsVectorLayer, QgsProject,
QgsCoordinateReferenceSystem, Qgis)
Expand Down Expand Up @@ -238,7 +237,9 @@ def initGui(self):
self.dlg.uListOptions.itemClicked.connect(self.showSelectedOption)
self.dlg.uListOptions.itemClicked.emit(self.dlg.uListOptions.item(0))
self.curr_list_wid_index=0


model = QStandardItemModel()
self.dlg.uCRSCombo.setModel(model)
self.dlg.uCRSCombo.currentIndexChanged.connect(self.layerCrsSelected)

self.dlg.uLabelWarning.setStyleSheet('color:red')
Expand Down Expand Up @@ -541,9 +542,17 @@ def showSelectedOption(self, item):
self.dlg.uStackedWidget.setCurrentIndex(2)

def layerCrsSelected(self):
self.selected_crs = str(self.dlg.uCRSCombo.currentText())
if self.selected_crs:
self.selected_crs_int = int(self.selected_crs.strip('EPSG:'))
"""
Track the user selected crs. Check validity to
ensure only well formed crs are provided.
"""

valid = re.compile('^EPSG\:\d+')
crs_text = self.dlg.uCRSCombo.currentText()
if valid.match(crs_text):
self.selected_crs = str(self.dlg.uCRSCombo.currentText())
if self.selected_crs:
self.selected_crs_int = int(self.selected_crs.strip('EPSG:'))

def getPreview(self, res, res_timeout):
"""
Expand Down Expand Up @@ -706,7 +715,7 @@ def importDataset(self):
Import the selected dataset to QGIS
"""

if not self.layers_loaded:
if not self.layers_loaded and not self.data_type == 'table':
self.setProjectSRID()

if self.service == "WFS":
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from owslib.wmts import WebMapTileService
from owslib.util import ServiceException
from qgis.core import QgsMessageLog, QgsApplication
from qgis.core import QgsApplication

import os.path

Expand All @@ -40,6 +40,12 @@

from qgis.PyQt.QtCore import QSettings


#temp
from qgis.core import QgsMessageLog



class ApiKey(object):
"""
Store API Keys for each domain. Required to
Expand Down Expand Up @@ -166,8 +172,6 @@ def delAllLocalServiceXML(self, services=['wms','wfs','wmts']):
file = os.path.join(dir, f)
self.delLocalSeviceXML(file)



def purgeCache(self):
"""
Delete all cached documents but the
Expand Down Expand Up @@ -281,7 +285,7 @@ def isEnabled(self):

def getServiceData(self):
"""
Select method to obtain capbilties doc.
Select method to obtain capabilities doc.
Either via localstore or internet
"""

Expand Down Expand Up @@ -381,30 +385,45 @@ def getServiceXml(self):

elif hasattr(e, 'code'):
self.err = 'Error: ({0}) {1}'.format(self.domain, e.reason)


def sortCrs(self):
# wms returns some no valid crs values
valid = re.compile('^EPSG\:\d+')
self.crs = [s for s in self.crs if valid.match(s)]
# sort
self.crs.sort(key = lambda x: int(x.split(':')[1]))

def formatForUI(self):
"""
Format the service data to display in the UI
"""


wms_crs = []
service_data = []
cont = self.obj.contents

for dataset_id, dataset_obj in cont.items():
crs=[]
self.crs=[]
full_id = re.search(r'([aA-zZ]+\\.[aA-zZ]+\\.[aA-zZ]+\\.[aA-zZ]+\\:)?(?P<type>[aA-zZ]+)-(?P<id>[0-9]+)', dataset_obj.id)
type = full_id.group('type')
id = full_id.group('id')
# Get and standarise espg codes
if self.service == 'wmts':
crs = dataset_obj.tilematrixsets
self.crs = dataset_obj.tilematrixsets
self.sortCrs()
elif self.service in ('wfs'):
crs = dataset_obj.crsOptions
crs = ['EPSG:{0}'.format(item.code) for item in crs]
self.crs = dataset_obj.crsOptions
self.crs = ['EPSG:{0}'.format(item.code) for item in self.crs]
self.sortCrs()
elif self.service in ('wms'):
crs = dataset_obj.crsOptions
crs = ['EPSG:{0}'.format(item.strip('urn:ogc:def:crs:EPSG::')) for item in crs]
if wms_crs:
self.crs = wms_crs
else:
self.crs = dataset_obj.crsOptions
self.sortCrs()
wms_crs = self.crs

service_data.append([self.domain, type, self.service.upper(), id,
dataset_obj.title, dataset_obj.abstract, crs])
dataset_obj.title, dataset_obj.abstract, self.crs])

self.info = service_data

0 comments on commit 144bede

Please sign in to comment.