Exemplo n.º 1
0
    private double calcDistanceMeters(ESRI.ArcGIS.ADF.Web.Geometry.Point toPoint, ESRI.ArcGIS.ADF.Web.Geometry.Point fromPoint)
    {
        ILine2 line;
        double distance = 0;
        ESRI.ArcGIS.Geometry.Point p1, p2;
        p1 = new PointClass();
        p2 = new PointClass();

        p1.PutCoords(toPoint.X, toPoint.Y);
        p2.PutCoords(fromPoint.X, fromPoint.Y);

        ISpatialReferenceFactory3 spatialReferenceFactory = new SpatialReferenceEnvironmentClass();
        ISpatialReference spatialReference = spatialReferenceFactory.CreateSpatialReference((int)
            esriSRProjCSType.esriSRProjCS_World_Mercator);
        ISpatialReference spatialReferenceOrig = spatialReferenceFactory.CreateSpatialReference((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);
        line = new LineClass();
        line.SpatialReference = spatialReferenceOrig;
        line.PutCoords(p1, p2);
        line.Project(spatialReference);
        distance = line.Length;
        return distance;
    }
Exemplo n.º 2
0
 private ILine ConstructLine(double x1, double y1, double x2, double y2)
 {
     IPoint p1 = new PointClass();
     p1.PutCoords(x1, y1);
     p1.Project(SpatialReferenceHelper.BCAlbersSpatialReference);
     IPoint p2 = new PointClass();
     p2.PutCoords(x2, y2);
     p2.Project(SpatialReferenceHelper.BCAlbersSpatialReference);
     ILine theReturn = new LineClass();
     theReturn.PutCoords(p1, p2);
     theReturn.Project(SpatialReferenceHelper.BCAlbersSpatialReference);
     return theReturn;
 }