Skip to content

Commit

Permalink
Release 2.14 - various bug fixes, see metadata for details
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Aug 23, 2017
1 parent 8c16c68 commit 3c96fa5
Show file tree
Hide file tree
Showing 7 changed files with 218 additions and 64 deletions.
99 changes: 99 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
29 changes: 20 additions & 9 deletions ConfigDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,30 @@
* *
***************************************************************************/
"""
import os

# Import the PyQt and QGIS libraries
try:
from qgis.core import Qgis
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5 import uic
QT_VERSION=5
os.environ['QT_API'] = 'pyqt5'
except:
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import uic
QT_VERSION=4

from PyQt4.QtCore import *
from PyQt4.QtGui import *

from Ui_Config import Ui_Config
# create the dialog for Config
class ConfigDialog(QDialog, Ui_Config ):
class ConfigDialog(QDialog ):

def __init__(self, caller):
QDialog.__init__(self)
##Set up the user interface from Designer.
##self.ui = Ui_Config ()
##self.ui.setupUi(self)
self.setupUi(self)
super(ConfigDialog, self ).__init__()
uic.loadUi(os.path.join(os.path.dirname(__file__), 'Ui_Config.ui'), self)

# stupid qvariant return a tuple...
zoom_scale = caller.get_config('ZoomScale', 0)
Expand Down
68 changes: 44 additions & 24 deletions GeoCoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Name : Geocoding
Description : Geocoding and reverse Geocoding using Web Services
Date : 25/Jun/2013
copyright : (C) 2009-2013 by ItOpen
copyright : (C) 2009-2017 by ItOpen
email : [email protected]
***************************************************************************/
Expand All @@ -17,16 +17,26 @@
* *
***************************************************************************/
"""
import sys, os


# Import the PyQt and QGIS libraries
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
try:
from qgis.core import Qgis
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5 import uic
QT_VERSION=5
os.environ['QT_API'] = 'pyqt5'
except:
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import uic
QT_VERSION=4

import sys, os
from urllib2 import URLError

# Initialize Qt resources from file resources.py
import resources
# Import the code for the dialog
from GeoCodingDialog import GeoCodingDialog
from ConfigDialog import ConfigDialog
Expand All @@ -49,34 +59,40 @@ def __init__(self, iface):

def initGui(self):
# Create action that will start plugin
self.action = QAction(QIcon(":/plugins/GeoCoding/geocode_icon.png"), \
"&GeoCode", self.iface.mainWindow())
current_directory = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
self.action = QAction(QIcon(os.path.join(current_directory, "geocode_icon.png")), \
"&GeoCoding", self.iface.mainWindow())
# connect the action to the run method
QObject.connect(self.action, SIGNAL("triggered()"), self.geocode)

# Add toolbar button and menu item

self.reverseAction=QAction(QIcon(":/plugins/GeoCoding/reverse_icon.png"), QCoreApplication.translate('GeoCoding', "&Reverse GeoCode"), self.iface.mainWindow())
self.configAction=QAction(QIcon(":/plugins/GeoCoding/settings_icon.png"), QCoreApplication.translate('GeoCoding', "&Settings"), self.iface.mainWindow())
self.aboutAction=QAction(QIcon(":/plugins/GeoCoding/about_icon.png"), QCoreApplication.translate('GeoCoding', "&About"), self.iface.mainWindow())
self.reverseAction=QAction(QIcon(os.path.join(current_directory, "reverse_icon.png")), QCoreApplication.translate('GeoCoding', "&Reverse GeoCoding"), self.iface.mainWindow())
self.configAction=QAction(QIcon(os.path.join(current_directory, "settings_icon.png")), QCoreApplication.translate('GeoCoding', "&Settings"), self.iface.mainWindow())
self.aboutAction=QAction(QIcon(os.path.join(current_directory, "about_icon.png")), QCoreApplication.translate('GeoCoding', "&About"), self.iface.mainWindow())
QObject.connect(self.configAction, SIGNAL("triggered()"), self.config)
QObject.connect(self.reverseAction, SIGNAL("triggered()"), self.reverse)
QObject.connect(self.aboutAction, SIGNAL("triggered()"), self.about)


self.menu = QMenu(QCoreApplication.translate('GeoCoding', "GeoCoding"))
self.menu.setIcon(QIcon(os.path.join(current_directory, "geocode_icon.png")))
self.menu.addActions([self.action, self.reverseAction, self.configAction, self.aboutAction])
self.iface.pluginMenu().addMenu( self.menu )
self.iface.addToolBarIcon(self.action)
self.iface.addPluginToMenu("GeoCode", self.action)
self.iface.addPluginToMenu("GeoCode", self.reverseAction)
self.iface.addPluginToMenu("GeoCode", self.configAction)
self.iface.addPluginToMenu("GeoCode", self.aboutAction)
# read config
self.config = QSettings('ItOpen', 'GeoCoding');
self.previous_map_tool = self.iface.mapCanvas().mapTool()


def unload(self):
# Remove the plugin menu item and icon
self.iface.removePluginMenu("GeoCode", self.action)
self.iface.removePluginMenu("GeoCoding", self.action)
self.iface.removePluginMenu("GeoCoding", self.reverseAction)
self.iface.removePluginMenu("GeoCoding", self.configAction)
self.iface.removePluginMenu("GeoCoding", self.aboutAction)
self.iface.removeToolBarIcon(self.action)
self.iface.pluginMenu().removeMenu( self.menu )
if self.previous_map_tool:
self.iface.mapCanvas().setMapTool(self.previous_map_tool)

def config(self):
# create and show the dialog
Expand Down Expand Up @@ -140,6 +156,7 @@ def reverse(self):
sb = self.iface.mainWindow().statusBar()
sb.showMessage(QCoreApplication.translate('GeoCoding', "Click on the map to obtain the address"))
ct = ClickTool(self.iface, self.reverse_action);
self.previous_map_tool = self.iface.mapCanvas().mapTool()
self.iface.mapCanvas().setMapTool(ct)


Expand Down Expand Up @@ -186,6 +203,8 @@ def reverse_action(self, point):

def geocode(self):
# run geocoding
if self.previous_map_tool:
self.iface.mapCanvas().setMapTool(self.previous_map_tool)
chk = self.check_settings()
if len(chk) :
QMessageBox.information(self.iface.mainWindow(),QCoreApplication.translate('GeoCoding', "GeoCoding plugin error"), chk)
Expand Down Expand Up @@ -324,18 +343,19 @@ def save_point(self, point, address):
self.layer.updateFields()

# Labels on
label = self.layer.label()
label.setLabelField(QgsLabel.Text, 0)
self.layer.enableLabels(True)

self.layer.setCustomProperty("labeling", "pal")
self.layer.setCustomProperty("labeling/enabled", "true")
#self.layer.setCustomProperty("labeling/fontFamily", "Arial")
#self.layer.setCustomProperty("labeling/fontSize", "10")
self.layer.setCustomProperty("labeling/fieldName", "address")
self.layer.setCustomProperty("labeling/placement", "2")
# add layer if not already
QgsMapLayerRegistry.instance().addMapLayer(self.layer)

# store layer id
self.layerid = self.layer.id()



# add a feature
fields=self.layer.pendingFields()
fet = QgsFeature(fields)
Expand Down
30 changes: 22 additions & 8 deletions GeoCodingDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,27 @@
* *
***************************************************************************/
"""
from PyQt4 import QtCore, QtGui
from Ui_GeoCoding import Ui_GeoCoding

import os

# Import the PyQt and QGIS libraries
try:
from qgis.core import Qgis
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5 import uic
QT_VERSION=5
os.environ['QT_API'] = 'pyqt5'
except:
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import uic
QT_VERSION=4


# create the dialog for GeoCoding
class GeoCodingDialog(QtGui.QDialog, Ui_GeoCoding ):
class GeoCodingDialog(QDialog):
def __init__(self):
QtGui.QDialog.__init__(self)
# Set up the user interface from Designer.
# #self.ui = Ui_GeoCoding ()
# #self.ui.setupUi(self)
self.setupUi(self)
super(GeoCodingDialog, self).__init__()
uic.loadUi(os.path.join(os.path.dirname(__file__), 'Ui_GeoCoding.ui'), self)
13 changes: 0 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,11 @@ install: copy2qgis
PY_FILES = ConfigDialog.py GeoCodingDialog.py GeoCoding.py PlaceSelectionDialog.py

EXTRAS = about_icon.png geocode_icon.png reverse_icon.png settings_icon.png
UI_FILES = Ui_Config.py Ui_GeoCoding.py Ui_PlaceSelection.py

RESOURCE_FILES = resources.py


compile: $(UI_FILES) $(RESOURCE_FILES)

%.py : %.qrc
pyrcc4 -o $@ $<
%.py : %.ui
pyuic4 -o $@ $<



clean:
find ./ -name "*.pyc" -exec rm -rf \{\} \;
rm -f ../GeoCoding.zip
rm -f Ui_GeoCoding.py Ui_Config.py Ui_GeoCoding.py Ui_PlaceSelection.py Ui_GeoCoding.py resources.py

package:
cd .. && find GeoCoding/ -print|grep -v Make | grep -v zip | grep -v .git | grep -v .pyc| zip GeoCoding.zip -@
Expand Down
31 changes: 23 additions & 8 deletions PlaceSelectionDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,28 @@
* *
***************************************************************************/
"""
from PyQt4 import QtCore, QtGui
from Ui_PlaceSelection import Ui_PlaceSelectionDialog


import os

# Import the PyQt and QGIS libraries
try:
from qgis.core import Qgis
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5 import uic
QT_VERSION=5
os.environ['QT_API'] = 'pyqt5'
except:
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import uic
QT_VERSION=4

# create the dialog for GeoCoding
class PlaceSelectionDialog(QtGui.QDialog, Ui_PlaceSelectionDialog):
class PlaceSelectionDialog(QDialog):

def __init__(self):
QtGui.QDialog.__init__(self)
# Set up the user interface from Designer.
# #self.ui = Ui_GeoCoding ()
# #self.ui.setupUi(self)
self.setupUi(self)
super(PlaceSelectionDialog, self).__init__()
uic.loadUi(os.path.join(os.path.dirname(__file__), 'Ui_PlaceSelection.ui'), self)
Loading

0 comments on commit 3c96fa5

Please sign in to comment.