Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add drop down functionality #124

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
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
Empty file modified CODE_OF_CONDUCT.md
100644 → 100755
Empty file.
Empty file modified CONTRIBUTING.md
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified functions/AstarBase.py
100644 → 100755
Empty file.
Empty file modified functions/CostBase.py
100644 → 100755
Empty file.
Empty file modified functions/DijkstraBase.py
100644 → 100755
Empty file.
Empty file modified functions/pgr_KSP.py
100644 → 100755
Empty file.
Empty file modified functions/pgr_aStar.py
100644 → 100755
Empty file.
Empty file modified functions/pgr_aStarCost.py
100644 → 100755
Empty file.
Empty file modified functions/pgr_bdAstar.py
100644 → 100755
Empty file.
Empty file modified functions/pgr_bdAstarCost.py
100644 → 100755
Empty file.
Empty file modified functions/pgr_bdDijkstra.py
100644 → 100755
Empty file.
Empty file modified functions/pgr_bdDijkstraCost.py
100644 → 100755
Empty file.
Empty file modified functions/pgr_dijkstra.py
100644 → 100755
Empty file.
Empty file modified functions/pgr_dijkstraCost.py
100644 → 100755
Empty file.
Empty file modified help/Makefile
100644 → 100755
Empty file.
Empty file modified help/make.bat
100644 → 100755
Empty file.
Empty file modified help/source/conf.py
100644 → 100755
Empty file.
Empty file modified help/source/index.rst
100644 → 100755
Empty file.
Empty file modified icons/pgr_fn.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified mkdocs.yml
100644 → 100755
Empty file.
Empty file modified pb_tool.cfg
100644 → 100755
Empty file.
61 changes: 55 additions & 6 deletions pgRoutingLayer.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ def initGui(self):
self.action.triggered.connect(self.show)
self.dock.buttonReloadConnections.clicked.connect(self.reloadConnections)
self.dock.comboConnections.currentIndexChanged.connect(self.updateConnectionEnabled)
self.dock.SchemacomboBox.currentIndexChanged.connect(self.updateEdgeTable)
self.dock.comboBoxFunction.currentIndexChanged.connect(self.updateFunctionEnabled)

self.dock.buttonSelectIds.clicked.connect(self.selectIds)
Expand Down Expand Up @@ -234,13 +235,18 @@ def initGui(self):
self.dock.lineEditDistance.setValidator(QDoubleValidator())
self.dock.lineEditAlpha.setValidator(QDoubleValidator())
self.dock.lineEditPaths.setValidator(QIntValidator())


# populate the combo with connections
self.reloadMessage = False
self.reloadConnections()
self.loadSettings()
Utils.logMessage("startup version " + str(self.version))
self.reloadMessage = True
#experiment
layers=QgsProject.instance().layerTreeRoot().children()
self.dock.EdgeTablecomboBox.clear()
self.dock.EdgeTablecomboBox.addItems([layer.name() for layer in layers])

def show(self):
self.iface.addDockWidget(Qt.LeftDockWidgetArea, self.dock)
Expand Down Expand Up @@ -291,6 +297,48 @@ def reloadConnections(self):
self.reloadMessage = oldReloadMessage
self.updateConnectionEnabled()


def updateSchemaTable(self,con):
self.dock.SchemacomboBox.clear()
cursor=con.cursor()
cursor.execute("""select schema_name
from information_schema.schemata""")
for schema in cursor.fetchall():
self.dock.SchemacomboBox.addItems(schema)


def updateEdgeTable(self):

dbname = str(self.dock.comboConnections.currentText())
if dbname == '':
return

db = self.actionsDb[dbname].connect()
con = db.con
cursor = con.cursor()
curSchema =str(self.dock.SchemacomboBox.currentText())
tab={}
tab['temp']= curSchema

query=sql.SQL("""SELECT table_name FROM information_schema.tables
WHERE table_schema='public' """)

cursor.execute(query.as_string(con))
for table in cursor.fetchall():
self.dock.EdgeTablecomboBox.addItems(table)
self.updateGeometryTable(con)

def updateGeometryTable(self,con):
curTable =str(self.dock.EdgeTablecomboBox.currentText())
self.dock.GeometrycomboBox.clear()
cursor=con.cursor()
cursor.execute("""SELECT geometry_columns.f_geometry_column FROM geometry_columns""")
for geom in cursor.fetchall():
self.dock.GeometrycomboBox.addItems(geom)




def updateConnectionEnabled(self):
''' Updates the database connection name and function '''
dbname = str(self.dock.comboConnections.currentText())
Expand All @@ -309,6 +357,7 @@ def updateConnectionEnabled(self):
return

self.loadFunctionsForVersion()
self.updateSchemaTable(con)
self.updateFunctionEnabled(currentFunction)

def loadFunctionsForVersion(self):
Expand Down Expand Up @@ -941,9 +990,9 @@ def toggleSelectButton(self, button):
def get_innerQueryArguments(self, controls):
args = {}

args['edge_schema'] = sql.Identifier(str(self.dock.lineEditSchema.text()))
args['edge_table'] = sql.Identifier(str(self.dock.lineEditTable.text()))
args['geometry'] = sql.Identifier(str(self.dock.lineEditGeometry.text()))
args['edge_schema'] = sql.Identifier(str(self.dock.SchemacomboBox.currentText()))
args['edge_table'] = sql.Identifier(str(self.dock.EdgeTablecomboBox.currentText()))
args['geometry'] = sql.Identifier(str(self.dock.GeometrycomboBox.currentText()))
args['id'] = sql.Identifier(str(self.dock.lineEditId.text()))
args['source'] = sql.Identifier(str(self.dock.lineEditSource.text()))
args['target'] = sql.Identifier(str(self.dock.lineEditTarget.text()))
Expand Down Expand Up @@ -1161,9 +1210,9 @@ def loadSettings(self):
if idx >= 0:
self.dock.comboBoxFunction.setCurrentIndex(idx)

self.dock.lineEditSchema.setText(Utils.getStringValue(settings, '/pgRoutingLayer/sql/edge_schema', 'public'))
self.dock.lineEditTable.setText(Utils.getStringValue(settings, '/pgRoutingLayer/sql/edge_table', 'edge_table'))
self.dock.lineEditGeometry.setText(Utils.getStringValue(settings, '/pgRoutingLayer/sql/geometry', 'the_geom'))
self.dock.SchemacomboBox.findText(Utils.getStringValue(settings, '/pgRoutingLayer/sql/edge_schema', 'public'))
self.dock.EdgeTablecomboBox.findText(Utils.getStringValue(settings, '/pgRoutingLayer/sql/edge_table', 'edge_table'))
self.dock.GeometrycomboBox.findText(Utils.getStringValue(settings, '/pgRoutingLayer/sql/geometry', 'the_geom'))

self.dock.lineEditId.setText(Utils.getStringValue(settings, '/pgRoutingLayer/sql/id', 'id'))
self.dock.lineEditSource.setText(Utils.getStringValue(settings, '/pgRoutingLayer/sql/source', 'source'))
Expand Down
Empty file modified requirements.txt
100644 → 100755
Empty file.
Empty file modified resources.qrc
100644 → 100755
Empty file.
52 changes: 15 additions & 37 deletions ui_pgRoutingLayer.ui
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>333</width>
<width>339</width>
<height>640</height>
</rect>
</property>
Expand Down Expand Up @@ -258,7 +258,7 @@
<x>0</x>
<y>0</y>
<width>241</width>
<height>355</height>
<height>362</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_5">
Expand Down Expand Up @@ -515,17 +515,7 @@
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>Edge table</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEditTable">
<property name="toolTip">
<string>Name of the table containing the routable network</string>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
<string>Schema</string>
</property>
</widget>
</item>
Expand All @@ -535,17 +525,7 @@
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>Schema</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEditSchema">
<property name="toolTip">
<string>Name of the table containing the routable network</string>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
<string>Edge Table</string>
</property>
</widget>
</item>
Expand All @@ -559,20 +539,22 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEditGeometry">
<property name="toolTip">
<string>Name of the geometry column in network table</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="checkBoxUseBBOX">
<property name="text">
<string>BBOX</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="SchemacomboBox"/>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="EdgeTablecomboBox"/>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="GeometrycomboBox"/>
</item>
</layout>
</widget>
</widget>
Expand Down Expand Up @@ -642,8 +624,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>235</width>
<height>599</height>
<width>213</width>
<height>450</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
Expand Down Expand Up @@ -1272,10 +1254,6 @@ _sql</string>
</layout>
</widget>
</widget>
<tabstops>
<tabstop>lineEditTable</tabstop>
<tabstop>lineEditGeometry</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
Empty file modified utilities/pgr_queries.py
100644 → 100755
Empty file.