Select to view content in your preferred language

Help with C# code

591
0
03-04-2013 06:38 AM
OscarCalderon
Deactivated User
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...
0 Kudos
0 Replies