QGis : strange tiedpoints after makeGraph

المشرف العام

Administrator
طاقم الإدارة
I try to use the Disjkstra shortest length path calculation.

On the following program, when I use the Network.shp file (found here : https://geospatialpython.googlecode.com/svn/network.zip) with pStart = QgsPoint(-0.8095638694, -0.1578175511) and pStop = QgsPoint(0.8907435677, 0.4430834924), the value of tiedPoints is [(-0.814696,-0.121406), (0.880931,0.394498)], so OK. (CRS = WGS 84)

When I just change the SHP file to "routeToulouse.shp" and the pStart and pStop coordinates to pStart = QgsPoint(572777,6277751) and pStop = QgsPoint(571644,6279403) (CRS = RGF93 / Lambert-93), I got this for tiedPoints : [(9999,-7.23497e-310), (9999,-7.23497e-310)]

Why do I have this strange values?

I use QGis Desktop to draw the "routeToulouse.shp" file and the 2 points and you can see that the 2 points are on the extent of the map, not outside.



Here's the source code :

# -*- coding: utf-8 -*-from PyQt4.QtCore import *from PyQt4.QtGui import *from qgis.core import *from qgis.gui import *from qgis.networkanalysis import *import os,sysclass MapViewer(QMainWindow): def __init__(self): QMainWindow.__init__(self) canvas = QgsMapCanvas() canvas.useImageToRender(False) canvas.setCanvasColor(Qt.white) layer = QgsVectorLayer("routeToulouse.shp", "layer1", "ogr") #layer = QgsVectorLayer("Network.shp", "layer1", "ogr") if not layer.isValid(): raise IOError("Invalid shapefile") director = QgsLineVectorLayerDirector(layer, -1, '', '', '', 3) properter = QgsDistanceArcProperter() director.addProperter(properter) crs = layer.crs() print crs.description() builder = QgsGraphBuilder(crs) pStart = QgsPoint(572777,6277751) #1.42510,43.58740,572777.082,6277751.358 pStop = QgsPoint(571644,6279403) #1.41067,43.60206,571644.110,6279403.609 #pStart = QgsPoint(-0.8095638694, -0.1578175511) #pStop = QgsPoint(0.8907435677, 0.4430834924) tiedPoints = director.makeGraph(builder, [pStart, pStop]) print tiedPoints QgsMapLayerRegistry.instance().addMapLayer(layer) layerExtend = layer.extent() canvas.setExtent(layerExtend) canvas.setLayerSet([QgsMapCanvasLayer(layer)]) layout = QVBoxLayout() layout.addWidget(canvas) contents = QWidget() contents.setLayout(layout) self.setCentralWidget(contents) canvas.show()if __name__ == '__main__': QgsApplication.setPrefixPath(os.environ['QGIS_PREFIX'], True) QgsApplication.initQgis() app = QApplication(sys.argv) app.processEvents() frame = MapViewer() frame.show() app.exec_()Thank you for any help,

Philippe



أكثر...
 
أعلى