Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ tools/*.py
images/
Ui*.py
xplanung.zip
schema/*
__pycache__/*
.settings
.pydevproject
.project
.gitignore
135 changes: 135 additions & 0 deletions Ui_Hoehenmanager.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Hoehenmananger</class>
<widget class="QDialog" name="Hoehenmananger">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>397</width>
<height>462</height>
</rect>
</property>
<property name="windowTitle">
<string>Hoehenmanager</string>
</property>
<property name="sizeGripEnabled">
<bool>true</bool>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="txlFilter">
<property name="toolTip">
<string>Filterbegriff eingeben</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnFilter">
<property name="toolTip">
<string>Nur dem Filter entsprechende Einträge anzeigen</string>
</property>
<property name="text">
<string>Filtern</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Bitte wählen Sie ein Flächenobjekt aus, um die dazugehörige Höhe zu bearbeiten bzw. ein neues Höhenobjekt anzulegen.</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QgsMapCanvas" name="canvas" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>250</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="hoehen">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="toolTip">
<string>Rechtsklick zum Bearbeiten</string>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close|QDialogButtonBox::Reset</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsMapCanvas</class>
<extends>QWidget</extends>
<header>qgis.gui</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Hoehenmananger</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Hoehenmananger</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
2 changes: 1 addition & 1 deletion XPImport.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def importGml(self):
commands = ['ogr2ogr'] + arguments

fused_command = ' '.join([str(c) for c in commands])

self.tools.showWarning(fused_command)
try:
proc = subprocess.check_output(
fused_command,
Expand Down
62 changes: 44 additions & 18 deletions XPTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
from .XPlanDialog import BereichsauswahlDialog
from .XPlanDialog import StilauswahlDialog

from traceback import format_stack
import inspect
from pprint import pformat

class XPTools():
def __init__(self, iface, standardName, simpleStyleName):
self.iface = iface
Expand Down Expand Up @@ -267,8 +271,8 @@ def getBereicheFuerFeatures(self, db, gids):

def getMaxGid(self, db, schemaName, tableName, pkFieldName = "gid"):
retValue = -9999
sel = "SELECT " + pkFieldName + " FROM \"" + schemaName + "\".\"" + tableName + \
"\" ORDER BY 1 DESC LIMIT 1;"
sel = 'SELECT "' + pkFieldName + '" FROM \"' + schemaName + '"."' + tableName + \
'" ORDER BY 1 DESC LIMIT 1;'

query = QtSql.QSqlQuery(db)
query.prepare(sel)
Expand Down Expand Up @@ -565,14 +569,26 @@ def createFeature(self, layer, fid = None):
newFeature = QgsVectorLayerUtils.createFeature(layer)

if fid:
newFeaturesetId(fid)
newFeaturesetId(fid) #is this defined?

provider = layer.dataProvider()
fields = layer.fields()
newFeature.initAttributes(fields.count())

for i in range(fields.count()):
newFeature.setAttribute(i,provider.defaultValue(i))
## bad fix for bug in Default retrieval from postgres
## (defaultValue won't give 9999 integer for e.g. XP_ExterneReferenz default value,
## but defaultValueClause does. Though defaultValueClause will return ''
## where None/NULL is correct)
## REALLY DON'T KNOW IF THERE IS SOMEWHERE A CORRECT DEFAULT EMPTY STRING, WHICH
## SHOULDN'T BE FIXED...
if provider.defaultValueClause(i)=='':
newFeature.setAttribute(i,provider.defaultValue(i))
else:
newFeature.setAttribute(i,provider.defaultValueClause(i))
## end fix
## old:
## newFeature.setAttribute(i,provider.defaultValue(i))

return newFeature
else:
Expand Down Expand Up @@ -619,6 +635,27 @@ def setEditable(self, layer, showErrorMsg = False, iface = None):
def noActiveLayerWarning(self):
self.showWarning(u"Kein aktiver Layer")

def debug(self, msg, stacksize=0):
t_ = [
x[0].f_locals for x in inspect.trace()
]
if stacksize==0:
self.log("Debug" + "\n" + msg)
elif len(t_) >=stacksize:
t_ = ['...'] + t_[-1*stacksize:]
self.log("Debug" + "\n" + msg + ' | ' + pformat( t_ ))
else:
self.log("Debug" + "\n" + msg + ' | ' + pformat( t_ ))

def log(self, msg, type = 'info'):
if type == 'info':
msgType = Qgis.Info
if type == 'warn':
msgType = Qgis.Warning
if type == 'error':
msgType = Qgis.Critical
QgsMessageLog.logMessage(msg, "XPlanung", msgType)

def showQueryError(self, query):
self.showError(
"%(error)s" % {"error": query.lastError().text()}, "DB-Fehler")
Expand All @@ -638,24 +675,13 @@ def showWarning(self, msg, title = "XPlanung"):

def showError(self, msg, title = "XPlanung"):
self.iface.messageBar().pushMessage(title,
msg, level=Qgis.Critical, duration = 10)
self.log(msg, "error")
msg + " (more in log)", level=Qgis.Critical, duration = 10)
self.log(msg +'\n' + str(format_stack()), "error")
self.debug(msg, 2)

def noStyleWarning(self, layer):
self.showWarning(u"Für den Layer " + layer.name() + u" sind keine Stile gespeichert")

def debug(self, msg):
self.log("Debug" + "\n" + msg)

def log(self, msg, type = 'info'):
if type == 'info':
msgType = Qgis.Info
if type == 'warn':
msgType = Qgis.Warning
if type == 'error':
msgType = Qgis.Critical
QgsMessageLog.logMessage(msg, "XPlanung", msgType)

def getAuthUserNamePassword(self, authcfg):
username = None
password = None
Expand Down
Loading