Quantcast
Channel: Forums - ArcObjects SDKs
Viewing all articles
Browse latest Browse all 1374

Help with C# code

$
0
0
May be this is not a new post, but I did not find any solution for this, so... I have to layers one of points (cities) and another of lines (roads), I need to find the shortest distance between two selected cities, using the road layer. I have try using this code:

IFeatureLayer Temp_Line = (IFeatureLayer)Glb.Mapa.get_Layer(0);
IFeatureLayer Temp_Point = (IFeatureLayer)Glb.Mapa.get_Layer(0);

int x = Glb.Mapa.LayerCount;
for (int i = 0; (i < x); i++)
{
if (Glb.Mapa.get_Layer(i).Name == "Caminos" + "_Z" + Glb.Zona)
{
Temp_Line = (IFeatureLayer)Glb.Mapa.get_Layer(i);
}
else if(Glb.Mapa.get_Layer(i).Name == "Fallas" + "_Z" + Glb.Zona)
{
Temp_Point = (IFeatureLayer)Glb.Mapa.get_Layer(i);
}
}

IFeature pLine = Temp_Line.FeatureClass.GetFeature(1);
IFeature pPoint = Temp_Point.FeatureClass.GetFeature(1);

IProximityOperator pProximity = pPoint.Shape as IProximityOperator;
double distance = pProximity.ReturnDistance(pLine.Shape);

textBox1.Text = distance.ToString();

But is not working...
Thanks in advance...

Viewing all articles
Browse latest Browse all 1374

Trending Articles