0
我遇到問題。我使用下面的代碼找到一個十字路口:獲取交叉索引
Envelope[][] extents = new Envelope[tilesCountX][tilesCountY];
// some code here to set "extents" values
var intersectedTiles =
extents
.SelectMany(es => es)
.Where(e => EnvIntersects(e, bounds))
.ToList();
private static bool EnvIntersects(Envelope e1, Envelope e2)
{
return e1.MinX >= e2.MinX && e1.MaxX <= e2.MaxX && e1.MinY >= e2.MinY && e1.MaxY <= e2.MaxY;
}
它的工作原理,但我想獲得相交的擴展的索引。
例如
如果extents[2][7]
是一個相交元素,我想獲得2
和7
。
可以通過修改我的代碼嗎?
[編輯]
bounds
是Envelope
具有內部MinX
,MinY
,MaxX
和MaxY
性質。
Envelope bounds = new Envelope();
bounds.MinX = some_value_1;
bounds.MaxX = some_value_2;
bounds.MinY = some_value_3;
bounds.MaxY = some_value_4;
'邊界'從哪裏來? SelectMany似乎不合適。 –
您使用的是什麼版本的C#? 'Envelope [] [] extents = new Envelope [tilesCountX] [tilesCountY];'在我的.NET 4.0中不能編譯 – GolfWolf
你的'EnvIntersects'需要比我稱之爲'intersection'更嚴格的條件,順便說一句。 – AakashM