Skip to content

Commit 5bf5d8d

Browse files
committed
Making the pgr_KSP and DijkstraBase as similar as possible
1 parent 3e26c0f commit 5bf5d8d

File tree

4 files changed

+14
-19
lines changed

4 files changed

+14
-19
lines changed

functions/DijkstraBase.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,12 @@ def prepare(self, canvasItemList):
5151
@classmethod
5252
def getQuery(self, args):
5353
''' returns the sql query in required signature format of pgr_dijkstra '''
54-
return sql.SQL("""
55-
SELECT seq, '(' || start_vid || ',' || end_vid || ')' AS path_name,
54+
return sql.SQL("""SELECT seq,
55+
'(' || start_vid || ',' || end_vid || ')' AS path_name,
5656
path_seq AS _path_seq, start_vid AS _start_vid, end_vid AS _end_vid,
57-
node AS _node, edge AS _edge, cost AS _cost, lead(agg_cost) over() AS _agg_cost
58-
FROM {function}('
59-
{innerQuery}
60-
',
57+
node AS _node, edge AS _edge,
58+
cost AS _cost, agg_cost AS _agg_cost
59+
FROM {function}('{innerQuery}',
6160
{source_ids}, {target_ids}, {directed})
6261
""").format(**args)
6362

functions/FunctionBase.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ def drawCostPaths(self, rows, con, args, geomType, canvasItemList, mapCanvas):
264264
rubberBand = QgsRubberBand(mapCanvas, Utils.getRubberBandType(False))
265265
rubberBand.setColor(QColor(255, 0, 0, 128))
266266
rubberBand.setWidth(4)
267-
268267
if args['result_cost'] != -1:
269268
costLine = PgrQ.getCostLine(args, sql.Literal(row[1]), sql.Literal(row[2]))
270269
# Utils.logMessage(costLine.as_string(cursor))

functions/pgr_KSP.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,13 @@ def getControlNames(self, version):
5656

5757
def getQuery(self, args):
5858
''' returns the sql query in required signature format of pgr_KSP '''
59-
return sql.SQL("""
60-
SELECT seq,
61-
'(' || start_vid || ',' || end_vid || ')-' || path_id AS path_name,
62-
path_seq AS _path_seq,
63-
start_vid AS _start_vid, end_vid AS _end_vid,
64-
path_id AS _path_id,
65-
node AS _node,
66-
edge AS _edge,
67-
cost AS _cost
68-
FROM pgr_KSP(' {innerQuery} ',
59+
return sql.SQL("""SELECT seq,
60+
'(' || start_vid || ',' || end_vid || ')-' || path_id AS path_name,
61+
path_seq AS _path_seq, start_vid AS _start_vid, end_vid AS _end_vid,
62+
node AS _node, edge AS _edge,
63+
path_id AS _path_id,
64+
cost AS _cost, agg_cost AS _agg_cost
65+
FROM pgr_KSP('{innerQuery}',
6966
{source_ids}, {target_ids}, {Kpaths}, {directed}, {heap_paths})
7067
""").format(**args)
7168

@@ -77,5 +74,5 @@ def getExportMergeQuery(self, args):
7774

7875
def draw(self, rows, con, args, geomType, canvasItemList, mapCanvas):
7976
''' draw the result '''
80-
columns = [2, 4, 5]
77+
columns = [2, 5, 6]
8178
self.drawManyPaths(rows, columns, con, args, geomType, canvasItemList, mapCanvas)

tests/qgis_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import logging
3030
import sys
3131

32-
from PyQt4.QtCore import QObject, pyqtSlot, pyqtSignal, QCoreApplication
32+
from PyQt5.QtCore import QObject, pyqtSlot, pyqtSignal, QCoreApplication
3333
from qgis.core import QgsMapLayerRegistry, QgsApplication, QgsVectorLayer
3434
from qgis.gui import QgsMapCanvasLayer
3535
import config

0 commit comments

Comments
 (0)