Skip to content

Commit

Permalink
Bumped version to 0.4.0. Browser not required any more. Fixes sdteffen#1
Browse files Browse the repository at this point in the history
.
  • Loading branch information
Steffen Macke committed Jan 12, 2014
1 parent 87bc068 commit be301ff
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 14 deletions.
32 changes: 21 additions & 11 deletions Elevation.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#! /usr/bin/env python
#
# This file is part of the QGIS Elevation Plugin
#
# Elevation.py - load Elevation class from file Elevation.py
#
# Copyright 2010, 2013 Steffen Macke <[email protected]>
# Copyright 2010, 2013, 2014 Steffen Macke <[email protected]>
#
# The QGIS Elevation plugin is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
Expand All @@ -28,13 +27,14 @@
from PyQt4.QtGui import *
from qgis.core import *

import sys, os, httplib, json, webbrowser, urllib
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
import sys, os, httplib, json, tempfile, urllib

# GeoCoding Utils
from Utils import *
# Elevation imports
import resources, numericmarkers
from resources import *
from numericmarkers import *
from ImageDialog import *

class Elevation:

Expand Down Expand Up @@ -62,7 +62,7 @@ def unload(self):
self.iface.removeToolBarIcon(self.obtainAction)

def about(self):
infoString = QCoreApplication.translate('Elevation', "QGIS Elevation Plugin 0.3.0<br />This plugin allows to mark point elevations in Google Maps.<br />Copyright (c) 2010, 2013 Steffen Macke<br /><a href=\"http://polylinie.de/elevation\">polylinie.de/elevation</a><br/>You have to accept the<br/><a href=\"http://code.google.com/intl/en/apis/maps/terms.html\">Google Maps APIs Terms of Service</a>\n")
infoString = QCoreApplication.translate('Elevation', "QGIS Elevation Plugin 0.4.0<br />This plugin allows to mark point elevations in Google Maps.<br />Copyright (c) 2010, 2013 Steffen Macke<br /><a href=\"http://polylinie.de/elevation\">polylinie.de/elevation</a><br/>You have to accept the<br/><a href=\"http://code.google.com/intl/en/apis/maps/terms.html\">Google Maps APIs Terms of Service</a>\n")
QMessageBox.information(self.iface.mainWindow(), "About Elevation", infoString)

# Obtain elevation
Expand Down Expand Up @@ -94,14 +94,23 @@ def obtain_action(self, point) :
#find marker
marker = 'http://bit.ly/aUwrKs'
for x in range(0, 1000):
if numericmarkers.numericmarkers.has_key(elevation+x) :
marker = numericmarkers.numericmarkers.get(elevation+x)
if numericmarkers.has_key(elevation+x) :
marker = numericmarkers.get(elevation+x)
break
if numericmarkers.numericmarkers.has_key(elevation-x):
marker = numericmarkers.numericmarkers.get(elevation-x)
if numericmarkers.has_key(elevation-x):
marker = numericmarkers.get(elevation-x)
break
# create map
webbrowser.open('http://maps.google.com/maps/api/staticmap?size=512x512&maptype=terrain\&markers=icon:'+marker+'|'+str(pt[1])+','+str(pt[0])+'&mobile=true&sensor=false')
image = tempfile.mkstemp(suffix='png')
os.close(image[0])
urllib.urlretrieve('http://maps.google.com/maps/api/staticmap?size=640x480&maptype=terrain\&markers=icon:'+marker+'|'+str(pt[1])+','+str(pt[0])+'&mobile=true&sensor=false', image[1])
QgsMessageLog.instance().logMessage('http://maps.google.com/maps/api/staticmap?size=640x4802&maptype=terrain\&markers=icon:'+marker+'|'+str(pt[1])+','+str(pt[0])+'&mobile=true&sensor=false')
dlg = ImageDialog()
dlg.image.setPixmap(QPixmap(image[1]))
dlg.show()
dlg.exec_()
if os.path.exists(image[1]):
os.unlink(image[1])
else:
QMessageBox.warning(self.iface.mainWindow(), 'Elevation', 'HTTP GET Request failed.', QMessageBox.Ok, QMessageBox.Ok)
except ValueError, e:
Expand All @@ -117,6 +126,7 @@ def save_point(self, point, elevation):

# add fields
self.provider.addAttributes( [QgsField("elevation", QVariant.Double)] )
self.layer.updateFields()

# Labels on
label = self.layer.label()
Expand Down
36 changes: 36 additions & 0 deletions ImageDialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#
# This file is part of the QGIS Elevation Plugin
#
# ImageDialog.py - Display a simple dialog with an image
#
# Copyright 2014 Steffen Macke <[email protected]>
#
# The QGIS Elevation plugin 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, or (at your option) any later version.
#
# The QGIS Elevation plugin 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.
#
# You should have received a copy of the GNU General Public
# License along with program; see the file COPYING. If not,
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#

from PyQt4 import QtCore, QtGui

class ImageDialog(QtGui.QDialog):
def setupUi(self):
self.setObjectName('Elevation')
self.resize(640,480)
self.image = QtGui.QLabel(self)
self.image.setGeometry(0,0,640,480)

def __init__(self):
QtGui.QDialog.__init__(self)
self.setupUi()

4 changes: 2 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# __init__.py - load Elevation class from file Elevation.py
#
# Copyright 2010, 2013 Steffen Macke <[email protected]>
# Copyright 2010, 2013, 2014 Steffen Macke <[email protected]>
#
# The QGIS Elevation plugin is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
Expand All @@ -28,7 +28,7 @@ def name():
def description():
return "Obtain and display point elevation data using Google Maps"
def version():
return "Version 0.3.0"
return "Version 0.4.0"
def qgisMinimumVersion():
return "2.0"
def classFactory(iface):
Expand Down
4 changes: 3 additions & 1 deletion metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ [email protected]
; end of mandatory metadata

; start of optional metadata
changelog=2013-12-11 Elevation 0.3.0:
changelog=2014-01-12 Elevation 0.4.0:
Web browser is no longer required
2013-12-11 Elevation 0.3.0:
QGIS 2.0 updates
2013-08-20 Elevation 0.2.0:
Several updates and bug fixes
Expand Down

0 comments on commit be301ff

Please sign in to comment.