瀏覽代碼

dglib: fix sp cache initialization

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@63161 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 10 年之前
父節點
當前提交
4d66e95f0f
共有 1 個文件被更改,包括 12 次插入2 次删除
  1. 12 2
      lib/vector/dglib/sp-template.c

+ 12 - 2
lib/vector/dglib/sp-template.c

@@ -256,8 +256,18 @@ static dglSPReport_s *DGL_SP_CACHE_REPORT_FUNC(dglGraph_s * pgraph,
 			clipInput.nFromDistance = 0; \
 			if ( fnClip( pgraph , & clipInput , & clipOutput , pvClipArg ) ) continue; \
 		} \
-		pPredistItem = dglTreePredistAdd( pCache->pvPredist, DGL_NODE_ID(pDestination) ); \
-		if ( pPredistItem == NULL ) goto sp_error; \
+		findPredist.nKey = DGL_NODE_ID(pDestination); \
+		if ( (pPredistItem = avl_find( pCache->pvPredist, &findPredist)) == NULL ) { \
+			if ( (pPredistItem = dglTreePredistAdd( pCache->pvPredist, DGL_NODE_ID(pDestination) )) == NULL ) { \
+				pgraph->iErrno = DGL_ERR_MemoryExhausted; \
+				goto sp_error; \
+			} \
+		} \
+		else { \
+			if ( pPredistItem->nDistance <= clipOutput.nEdgeCost ) { \
+				continue; \
+			} \
+		} \
 		pPredistItem->nFrom      = nStart; \
 		pPredistItem->pnEdge     = pEdge; \
 		pPredistItem->nCost      = clipOutput.nEdgeCost; \