Li,
If you are looking to return the distance between geometries then have a look at the IProximityOperator Interface.
PointClass p1 = new PointClass();
PointClass p2 = new PointClass();
// Add data to points for test
p1.PutCoords(34.481560, 41.515391);
p2.PutCoords(34.702832, 41.795668);
IMeasurementTool measurementTool = new MeasurementToolClass();
measurementTool.ConstructByPoints(p1, p2);
// Here we calculate distance between two points: (p1, p2)
double distance = measurementTool.Distance;
ILine lineForAngle = new Line();
GeometryEnvironment geoEnv = new GeometryEnvironment();
IConstructAngle angleCalculator = (IConstructAngle)geoEnv;
lineForAngle.PutCoords(p1, p2);
// Here we calculate angle of line between (p1, p2) and the positive x-axis
double angle = angleCalculator.ConstructLine(lineForAngle);
// Convert radian to degree
angle *= 180 / Math.PI;
Code for calculating distance and angle between two points in C#:
PointClass p1 = new PointClass();
PointClass p2 = new PointClass();
// Add data to points for test
p1.PutCoords(34.481560, 41.515391);
p2.PutCoords(34.702832, 41.795668);
IMeasurementTool measurementTool = new MeasurementToolClass();
measurementTool.ConstructByPoints(p1, p2);
// Here we calculate distance between two points: (p1, p2)
double distance = measurementTool.Distance;
ILine lineForAngle = new Line();
GeometryEnvironment geoEnv = new GeometryEnvironment();
IConstructAngle angleCalculator = (IConstructAngle)geoEnv;
lineForAngle.PutCoords(p1, p2);
// Here we calculate angle of line between (p1, p2) and the positive x-axis
double angle = angleCalculator.ConstructLine(lineForAngle);
// Convert radian to degree
angle *= 180 / Math.PI;
Sinrecely
PointClass p1 = new PointClass();
Dim p1 as PointClass
Set p1 = new PointClass
p1.PutCoords(34.481560, 41.515391);should be:
p1.PutCoords 34.481560, 41.515391
I am a beginner of arcobjects.
My question is to write code for Calculation of Distance Matrix between different locations (different spots) and save it automatically in a table or a *csv file. The basic data is vetor map data with points, polygons and line.
Thank you very very very much for help.