Example #1
0
        //构造垂直线上点法
        private void button9_Click(object sender, EventArgs e)
        {
            delFeature("point");
            IPoint[] points = new IPoint[2];
            for (int i = 0; i < 2; i++)
            {
                points[i] = new PointClass();
            }
            points[0].PutCoords(0, 0);
            points[1].PutCoords(20, 0);


            ISegment segment;
            ILine    line = new LineClass();

            line.FromPoint = points[0];
            line.ToPoint   = points[1];

            segment = line as ISegment;
            IPoint fromPoint = new PointClass();

            fromPoint.X = points[0].X + 10;
            fromPoint.Y = points[0].Y + 10;
            IConstructPoint constructPoint = new PointClass();

            constructPoint.ConstructPerpendicular(segment, esriSegmentExtension.esriNoExtension, fromPoint, 3, false);
            addFeature("point", points[0]);
            addFeature("point", points[1]);
            addFeature("point", constructPoint as IPoint);
            axMapControl1.Refresh();
        }
        static public List <IPolyline> CreatePerpendicularLine(FeaPtInform fptClass, IFeatureLayer plyFeatureLyr, bool isValOrRige)
        {
            IPoint pt1 = CreateAngleBisectorPt(fptClass, plyFeatureLyr, isValOrRige);
            ILine  AngleBisectorLine = new LineClass();

            AngleBisectorLine.FromPoint = fptClass.PtCoord;
            AngleBisectorLine.ToPoint   = pt1;

            IConstructPoint constructPt = new PointClass();
            double          m           = 100;

            if (isValOrRige == true)
            {
                m = 150;
            }
            constructPt.ConstructPerpendicular(AngleBisectorLine as ISegment, esriSegmentExtension.esriNoExtension, AngleBisectorLine.FromPoint, m, false);
            IPoint newpt      = constructPt as IPoint;
            ILine  beforeLine = new LineClass();

            beforeLine.FromPoint = fptClass.PtCoord;
            beforeLine.ToPoint   = newpt;
            IPolyline leftPly = new PolylineClass();

            leftPly.FromPoint = fptClass.PtCoord;
            leftPly.ToPoint   = newpt;

            IPolyline temperply = new PolylineClass();

            temperply = ExtendLineFun(beforeLine.FromPoint, beforeLine.Angle - Math.PI);

            IPolyline rightPly = new PolylineClass();

            rightPly.FromPoint = fptClass.PtCoord;
            rightPly.ToPoint   = temperply.ToPoint;
            List <IPolyline> buildPerpendicularLine = new List <IPolyline>();

            buildPerpendicularLine.Add(leftPly);
            buildPerpendicularLine.Add(rightPly);
            return(buildPerpendicularLine);
        }