Пример #1
0
        private List <IPoint> CreateLinesAtStartPoint(int numberOfLines, ref int lineCounter, ref int juncCounter, ref int spCounter, IPoint startPoint,
                                                      double lineLength, double angleInRadians, IFeatureClass lineFC, IFeatureClass fuseFC, IFeatureClass serveFC, IFeatureClass juncFC)
        {
            List <IPoint> retList = new List <IPoint>();

            System.Random rnd     = new System.Random();
            double        starter = 1.0 / rnd.Next(1, 9);

            //starter = .5;
            for (double index = starter; index < numberOfLines; index++)
            {
                IConstructPoint outPoint = new PointClass();
                outPoint.ConstructAngleDistance(startPoint, angleInRadians * index, lineLength);
                IPoint           outPointpnt = outPoint as IPoint;
                IPointCollection pc          = new PolylineClass();
                pc.AddPoint(startPoint); pc.AddPoint(outPointpnt);
                IFeature lineFe = lineFC.CreateFeature();
                lineFe.Shape = pc as IGeometry;
                lineFe.Store();
                lineCounter++;
                ICurve curve = (ICurve)lineFe.ShapeCopy;
                bool   brs = false; double dfc = 0; double dac = 0;
                IPoint pntToNQ = new PointClass();
                if (lineLength > 200)
                {
                    for (int j = 0; j <= numberOfLines; j++)
                    {
                        dac = j * (1.0 / numberOfLines);
                        if (dac == 0)
                        {
                            IConstructPoint pntCP2 = new PointClass();
                            pntCP2.ConstructAlong(curve, esriSegmentExtension.esriNoExtension, 1, false);
                            IPoint   pntcp2pnt = (IPoint)pntCP2;
                            IFeature fuseFe    = fuseFC.CreateFeature();
                            fuseFe.Shape = pntcp2pnt as IGeometry;
                            fuseFe.Store();
                        }
                        else
                        {
                            IConstructPoint pntCP2 = new PointClass();
                            pntCP2.ConstructAlong(curve, esriSegmentExtension.esriNoExtension, dac, true);
                            IPoint   pntcp2pnt = (IPoint)pntCP2;
                            IFeature juncfe    = juncFC.CreateFeature();
                            juncfe.Shape = pntcp2pnt as IGeometry;
                            juncfe.Store();
                            retList.Add(pntcp2pnt as IPoint);
                            juncCounter++;
                        }
                    }
                }
                else
                {
                    IFeature servFe = serveFC.CreateFeature();
                    servFe.Shape = outPointpnt as IGeometry;
                    servFe.Store();
                    spCounter++;
                }
            }
            return(retList);
        }
Пример #2
0
        private PointClass RectanglePoint2(IPoint point, double angle, double height)
        {
            PointClass p = new PointClass();

            p.SpatialReference = m_hookHelper.FocusMap.SpatialReference;
            p.ConstructAngleDistance(point, angle, height / 2);
            return(p);
        }
Пример #3
0
        private IPoint ConstructPoint(IPoint point, double angle, double width)
        {
            var point3 = new PointClass {
                ZAware = true
            };

            point3.ConstructAngleDistance(point, angle * Deg2Rad, width);
            return(point3);
        }
Пример #4
0
        /// <summary>
        /// Get new point by distance and angel
        /// </summary>
        /// <param name="basePoint">The base point</param>
        /// <param name="angel">dirrection in radians</param>
        /// <param name="length">distance to the new point</param>
        /// <returns>Esri point</returns>
        public static IPoint GetPointFromAngelAndDistance(IPoint basePoint, double angel, double length)
        {
            IConstructPoint outPoint = new PointClass();

            outPoint.ConstructAngleDistance(basePoint, angel, length);
            IPoint resilt = outPoint as IPoint;

            resilt.SpatialReference = basePoint.SpatialReference;
            return(resilt);
        }
Пример #5
0
        private IPoint ConstructPoint(IPoint sourcePoint, double angle, double offsetAngle, double length, double width)
        {
            var p = new PointClass();

            p.ConstructAngleDistance(sourcePoint, angle * Deg2Rad, width / 2);
            var p2 = new PointClass();

            p2.ConstructAngleDistance(p, offsetAngle * Deg2Rad, length);

            return(p2);
        }
Пример #6
0
        static private IPolyline ExtendLineFun(IPoint pt1, double angle)
        {
            IConstructPoint extendPt = new PointClass();

            extendPt.ConstructAngleDistance(pt1, angle, 150);
            IPoint    newPt     = extendPt as IPoint;
            IPolyline extendPly = new PolylineClass();

            extendPly.FromPoint = pt1;
            extendPly.ToPoint   = newPt;
            return(extendPly);
        }
Пример #7
0
        //构造角度距离法
        private void button3_Click(object sender, EventArgs e)
        {
            delFeature("point");
            IPoint point1, point2;

            point1 = new PointClass();
            point1.PutCoords(0, 0);
            double          distance       = 20;
            double          angle          = 60;
            IConstructPoint constructPoint = new PointClass();
            double          angleRad       = angle * 2 * Math.PI / 360;

            constructPoint.ConstructAngleDistance(point1, angleRad, distance);
            point2 = constructPoint as IPoint;
            addFeature("point", point1);
            addFeature("point", point2);
            axMapControl1.Refresh();
        }
Пример #8
0
        public void ContructGeometry(IPoint point, List <KeyValuePair <int, double> > datasources, out List <KeyValuePair <string, IPolygon> > polygons, out List <IPoint> lineStartPoints, out List <IPoint> txtPoints)
        {
            _centerPoint = new PointClass {
                X = point.X, Y = point.Y
            };
            polygons = new List <KeyValuePair <string, IPolygon> >();

            lineStartPoints = new List <IPoint>();
            txtPoints       = new List <IPoint>();

            var polygonBlack = new PolygonClass();
            var polygonWhite = new PolygonClass();

            _linepoints = lineStartPoints;
            _points     = txtPoints;

            var indexLine   = 0;
            var length      = datasources.Sum(s => s.Value) * BL;
            var totalLength = length / 2;

            _halfHeight = length / 2;
            _height3    = _halfHeight + GeometryHeight1;
            _height4    = _halfHeight + GeometryHeight0 + GeometryHeight1;
            IPoint lastFromPoint = null;

            //IPoint lastToPoint = null;

            foreach (var d in datasources)
            {
                double dd     = d.Value * BL;
                var    list30 = new List <IPoint>
                {
                    ConstructPoint(_centerPoint, 180, 90, totalLength),
                    ConstructPoint(_centerPoint, 0, 90, totalLength),
                    ConstructPoint(_centerPoint, 0, 90, totalLength - dd),
                    ConstructPoint(_centerPoint, 180, 90, totalLength - dd),
                    ConstructPoint(_centerPoint, 180, 90, totalLength)
                };

                //  生成面
                var geometry = ConstructRing(list30);

                if (d.Key == 0)
                {
                    polygonWhite.AddGeometry(geometry);
                }
                else
                {
                    polygonBlack.AddGeometry(geometry);
                }

                //int angleLine = indexLine % 2 == 0 ? 0 : 180;

                var fromPoint = list30[indexLine % 2 + 2];
                //var toPoint = ConstructPoint3(fromPoint, angleLine, LineWidth);

                //  生成线
                _linepoints.Add(fromPoint);

                lastFromPoint = list30[3];
                //lastToPoint = ConstructPoint3(lastFromPoint, Angle2, LineWidth * 2);

                var txtPoint = new PointClass();
                txtPoint.ConstructAngleDistance(fromPoint, (TextOffsetAngle + indexLine % 2 * 180) * Deg2Rad, TextOffsetDistance);

                //  生成点
                _points.Add(txtPoint);

                totalLength -= dd;
                indexLine++;
            }

            if (lastFromPoint != null)
            {
                var txtLastPoint = new PointClass();
                txtLastPoint.ConstructAngleDistance(lastFromPoint, 180 * Deg2Rad, LastTextOffsetDistance);

                //  生成点
                _points.Add(txtLastPoint);
                //  生成线
                _linepoints.Add(lastFromPoint);
            }


            polygonWhite.Close();
            polygonBlack.Close();
            var tPolygon = new PolygonClass();

            polygons.Add(new KeyValuePair <string, IPolygon>("top", ContructGeometry(out tPolygon)));
            polygons.Add(new KeyValuePair <string, IPolygon>("top", tPolygon));
            polygons.Add(new KeyValuePair <string, IPolygon>("white", polygonWhite));
            polygons.Add(new KeyValuePair <string, IPolygon>("black", polygonBlack));
        }
        private ICircularArc ConstructCurveFromString(string inString, ISegment ExitTangentFromPreviousCourse,
          esriDirectionType inDirectionType, esriDirectionUnits inDirectionUnits,
          out double outChordLength, out double outChordBearing)
        {
            //
              IConstructCircularArc pConstArc = new CircularArcClass();
              ICircularArc pArc = (ICircularArc)pConstArc;
              IPoint pPt = new PointClass();
              pPt.PutCoords(1000, 1000);
              //initialize the curve params
              bool bHasRadius = false; double dRadius = -1;
              bool bHasChord = false; double dChord = -1;
              bool bHasArc = false; double dArcLength = -1;
              bool bHasDelta = false; double dDelta = -1;
              bool bCCW = false; //assume curve to right unless proven otherwise
              //now initialize bearing types for non-tangent curves
              bool bHasRadialBearing = false; double dRadialBearing = -1;
              bool bHasChordBearing = false; double dChordBearing = -1;
              bool bHasTangentBearing = false; double dTangentBearing = -1;
              ISegment EntryTangentSegment = null;

              int iItemPosition = 0;

              string[] sCourse = inString.Split(' ');
              int UpperBound = sCourse.GetUpperBound(0);
              bool bIsTangentCurve = (((string)sCourse.GetValue(0)).ToLower() == "tc");
              foreach (string item in sCourse)
              {
            if (item == null)
              break;
            if ((item.ToLower() == "r") && (!bHasRadius) && (iItemPosition <= 3))
            {// this r is for radius
              dRadius = Convert.ToDouble(sCourse.GetValue(iItemPosition + 1));
              bHasRadius = true; //found a radius
            }
            if ((item.ToLower()) == "c" && (!bHasChord) && (iItemPosition <= 3))
            {// this c is for chord length
              dChord = Convert.ToDouble(sCourse.GetValue(iItemPosition + 1));
              bHasChord = true; //found a chord length
            }
            if ((item.ToLower()) == "a" && (!bHasArc) && (iItemPosition <= 3))
            {// this a is for arc length
              dArcLength = Convert.ToDouble(sCourse.GetValue(iItemPosition + 1));
              bHasArc = true; //found an arc length
            }
            if ((item.ToLower()) == "d" && (!bHasDelta) && (iItemPosition <= 3))
            {// this d is for delta or central angle
              dDelta = Angle_2_Radians((string)sCourse.GetValue(iItemPosition + 1), inDirectionUnits);
              bHasDelta = true; //found a central angle
            }
            if ((item.ToLower()) == "r" && (!bHasRadialBearing) && (iItemPosition > 3) && (UpperBound > 5))
            {// this r is for radial bearing
              try
              {
            dRadialBearing = DirectionString_2_PolarRadians((string)sCourse.GetValue(iItemPosition + 1), inDirectionType, inDirectionUnits);
            if (!(dRadialBearing == -999)) { bHasRadialBearing = true; } //found a radial bearing
              }
              catch { }//this will catch case of final R meaning a curve right and not radial bearing
            }
            if ((item.ToLower()) == "c" && (!bHasChordBearing) && (iItemPosition > 3))
            {// this c is for chord bearing
              dChordBearing = DirectionString_2_PolarRadians((string)sCourse.GetValue(iItemPosition + 1), inDirectionType, inDirectionUnits);
              bHasChordBearing = true; //found a chord bearing
            }
            if ((item.ToLower()) == "t" && (!bHasTangentBearing) && (iItemPosition > 3))
            {// this t is for tangent bearing
              dTangentBearing = DirectionString_2_PolarRadians((string)sCourse.GetValue(iItemPosition + 1), inDirectionType, inDirectionUnits);
              bHasTangentBearing = true; //found a tangent bearing
              IConstructPoint2 pToPt = new PointClass();
              pToPt.ConstructAngleDistance(pPt, dTangentBearing, 100);
              ILine EntryTangentLine = new LineClass();
              EntryTangentLine.PutCoords(pPt, (IPoint)pToPt);
              EntryTangentSegment = (ISegment)EntryTangentLine;
            }

            if ((item.ToLower()) == "l")
              // this l is for defining a curve to the left
              bCCW = true;
            iItemPosition += 1;
              }

              if (!(bIsTangentCurve)) //non-tangent curve
              {//chord bearing
            if (bHasRadius && bHasChord && bHasChordBearing)
            {
              try
              {
            pConstArc.ConstructBearingRadiusChord(pPt, dChordBearing, bCCW, dRadius, dChord, true);
              }
              catch { };
            }

            if (bHasRadius && bHasArc && bHasChordBearing)
            {
              try
              {
            pConstArc.ConstructBearingRadiusArc(pPt, dChordBearing, bCCW, dRadius, dArcLength);
              }
              catch { };
            }

            if (bHasRadius && bHasDelta && bHasChordBearing)
            {
              try
              {
            pConstArc.ConstructBearingRadiusAngle(pPt, dChordBearing, bCCW, dRadius, dDelta);
              }
              catch { };
            }

            if (bHasChord && bHasDelta && bHasChordBearing)
            {
              try
              {
            pConstArc.ConstructBearingAngleChord(pPt, dChordBearing, bCCW, dDelta, dChord);
              }
              catch { };
            }

            if (bHasChord && bHasArc && bHasChordBearing)
            {
              try
              {
            pConstArc.ConstructBearingChordArc(pPt, dChordBearing, bCCW, dChord, dArcLength);
              }
              catch { };
            }

            //tangent bearing
            if (bHasRadius && bHasChord && bHasTangentBearing)
            {
              try
              {
            pConstArc.ConstructTangentRadiusChord(EntryTangentSegment, false, bCCW, dRadius, dChord);
              }
              catch { };
            }

            if (bHasRadius && bHasArc && bHasTangentBearing)
            {
              try
              {
            pConstArc.ConstructTangentRadiusArc(EntryTangentSegment, false, bCCW, dRadius, dArcLength);
              }
              catch { };
            }
            if (bHasRadius && bHasDelta && bHasTangentBearing)
            {
              try
              {
            pConstArc.ConstructTangentRadiusAngle(EntryTangentSegment, false, bCCW, dRadius, dDelta);
              }
              catch { };
            }

            if (bHasChord && bHasDelta && bHasTangentBearing)
            {
              try
              {
            pConstArc.ConstructTangentAngleChord(EntryTangentSegment, false, bCCW, dDelta, dChord);
              }
              catch { };
            }
            if (bHasChord && bHasArc && bHasTangentBearing)
            {
              try
              {
            pConstArc.ConstructTangentChordArc(EntryTangentSegment, false, bCCW, dChord, dArcLength);
              }
              catch { };
            }

            //radial bearing
            if (bHasRadialBearing)
            {
              //need to convert radial bearing to tangent bearing by adding/subtracting 90 degrees
              double dTanBear = 0;
              if (bCCW)
            dTanBear = dRadialBearing - (Angle_2_Radians("90", esriDirectionUnits.esriDUDecimalDegrees));
              else
            dTanBear = dRadialBearing + (Angle_2_Radians("90", esriDirectionUnits.esriDUDecimalDegrees));
              IConstructPoint2 pToPt = new PointClass();
              pToPt.ConstructAngleDistance(pPt, dTanBear, 100);
              ILine EntryTangentLine = new LineClass();
              EntryTangentLine.PutCoords(pPt, (IPoint)pToPt);
              EntryTangentSegment = (ISegment)EntryTangentLine;
            }

            if (bHasRadius && bHasChord && bHasRadialBearing)
            {
              try
              {
            pConstArc.ConstructTangentRadiusChord(EntryTangentSegment, false, bCCW, dRadius, dChord);
              }
              catch { };
            }
            if (bHasRadius && bHasArc && bHasRadialBearing)
            {
              try
              {
            pConstArc.ConstructTangentRadiusArc(EntryTangentSegment, false, bCCW, dRadius, dArcLength);
              }
              catch { };
            }
            if (bHasRadius && bHasDelta && bHasRadialBearing)
            {
              try
              {
            pConstArc.ConstructTangentRadiusAngle(EntryTangentSegment, false, bCCW, dRadius, dDelta);
              }
              catch { };
            }
            if (bHasChord && bHasDelta && bHasRadialBearing)
            {
              try
              {
            pConstArc.ConstructTangentAngleChord(EntryTangentSegment, false, bCCW, dDelta, dChord);
              }
              catch { };
            }
            if (bHasChord && bHasArc && bHasRadialBearing)
            {
              try
              {
            pConstArc.ConstructTangentChordArc(EntryTangentSegment, false, bCCW, dChord, dArcLength);
              }
              catch { };
            }
              }
              else
              { //tangent curve
            if (bHasRadius && bHasChord)
            {
              try
              {
            pConstArc.ConstructTangentRadiusChord(ExitTangentFromPreviousCourse, false, bCCW, dRadius, dChord);
              }
              catch { };
            }
            if (bHasRadius && bHasArc)
            {
              try
              {
            pConstArc.ConstructTangentRadiusArc(ExitTangentFromPreviousCourse, false, bCCW, dRadius, dArcLength);
              }
              catch { };
            }
            if (bHasRadius && bHasDelta)
            {
              try
              {
            pConstArc.ConstructTangentRadiusAngle(ExitTangentFromPreviousCourse, false, bCCW, dRadius, dDelta);
              }
              catch { };
            }
            if (bHasChord && bHasDelta)
            {
              try
              {
            pConstArc.ConstructTangentAngleChord(ExitTangentFromPreviousCourse, false, bCCW, dDelta, dChord);
              }
              catch { };
            }
            if (bHasChord && bHasArc)
            {
              try
              {
            pConstArc.ConstructTangentChordArc(ExitTangentFromPreviousCourse, false, bCCW, dChord, dArcLength);
              }
              catch { };
            }
              }
              ILine pLine = new LineClass();
              try
              {
            pLine.PutCoords(pArc.FromPoint, pArc.ToPoint);
              }
              catch
              {
            outChordLength = -1; outChordBearing = -1;
            return null;
              }
              outChordLength = pLine.Length;
              outChordBearing = pLine.Angle;
              return pArc;
        }
        private ICircularArc ConstructCurveFromString(string inString, ISegment ExitTangentFromPreviousCourse,
                                                      esriDirectionType inDirectionType, esriDirectionUnits inDirectionUnits,
                                                      out double outChordLength, out double outChordBearing)
        {//
            IConstructCircularArc pConstArc = new CircularArcClass();
            ICircularArc          pArc      = (ICircularArc)pConstArc;
            IPoint pPt = new PointClass();

            pPt.PutCoords(1000, 1000);
            //initialize the curve params
            bool bHasRadius = false; double dRadius = -1;
            bool bHasChord = false; double dChord = -1;
            bool bHasArc = false; double dArcLength = -1;
            bool bHasDelta = false; double dDelta = -1;
            bool bCCW = false; //assume curve to right unless proven otherwise
            //now initialize bearing types for non-tangent curves
            bool     bHasRadialBearing = false; double dRadialBearing = -1;
            bool     bHasChordBearing = false; double dChordBearing = -1;
            bool     bHasTangentBearing = false; double dTangentBearing = -1;
            ISegment EntryTangentSegment = null;

            int iItemPosition = 0;

            string[] sCourse         = inString.Split(' ');
            int      UpperBound      = sCourse.GetUpperBound(0);
            bool     bIsTangentCurve = (((string)sCourse.GetValue(0)).ToLower() == "tc");

            foreach (string item in sCourse)
            {
                if (item == null)
                {
                    break;
                }
                if ((item.ToLower() == "r") && (!bHasRadius) && (iItemPosition <= 3))
                {                      // this r is for radius
                    dRadius    = Convert.ToDouble(sCourse.GetValue(iItemPosition + 1));
                    bHasRadius = true; //found a radius
                }
                if ((item.ToLower()) == "c" && (!bHasChord) && (iItemPosition <= 3))
                {                     // this c is for chord length
                    dChord    = Convert.ToDouble(sCourse.GetValue(iItemPosition + 1));
                    bHasChord = true; //found a chord length
                }
                if ((item.ToLower()) == "a" && (!bHasArc) && (iItemPosition <= 3))
                {                      // this a is for arc length
                    dArcLength = Convert.ToDouble(sCourse.GetValue(iItemPosition + 1));
                    bHasArc    = true; //found an arc length
                }
                if ((item.ToLower()) == "d" && (!bHasDelta) && (iItemPosition <= 3))
                {                     // this d is for delta or central angle
                    dDelta    = Angle_2_Radians((string)sCourse.GetValue(iItemPosition + 1), inDirectionUnits);
                    bHasDelta = true; //found a central angle
                }
                if ((item.ToLower()) == "r" && (!bHasRadialBearing) && (iItemPosition > 3) && (UpperBound > 5))
                {// this r is for radial bearing
                    try
                    {
                        dRadialBearing = DirectionString_2_PolarRadians((string)sCourse.GetValue(iItemPosition + 1), inDirectionType, inDirectionUnits);
                        if (!(dRadialBearing == -999))
                        {
                            bHasRadialBearing = true;
                        }                                                //found a radial bearing
                    }
                    catch { }//this will catch case of final R meaning a curve right and not radial bearing
                }
                if ((item.ToLower()) == "c" && (!bHasChordBearing) && (iItemPosition > 3))
                {                            // this c is for chord bearing
                    dChordBearing    = DirectionString_2_PolarRadians((string)sCourse.GetValue(iItemPosition + 1), inDirectionType, inDirectionUnits);
                    bHasChordBearing = true; //found a chord bearing
                }
                if ((item.ToLower()) == "t" && (!bHasTangentBearing) && (iItemPosition > 3))
                {                              // this t is for tangent bearing
                    dTangentBearing    = DirectionString_2_PolarRadians((string)sCourse.GetValue(iItemPosition + 1), inDirectionType, inDirectionUnits);
                    bHasTangentBearing = true; //found a tangent bearing
                    IConstructPoint2 pToPt = new PointClass();
                    pToPt.ConstructAngleDistance(pPt, dTangentBearing, 100);
                    ILine EntryTangentLine = new LineClass();
                    EntryTangentLine.PutCoords(pPt, (IPoint)pToPt);
                    EntryTangentSegment = (ISegment)EntryTangentLine;
                }

                if ((item.ToLower()) == "l")
                {
                    // this l is for defining a curve to the left
                    bCCW = true;
                }
                iItemPosition += 1;
            }

            if (!(bIsTangentCurve)) //non-tangent curve
            {                       //chord bearing
                if (bHasRadius && bHasChord && bHasChordBearing)
                {
                    try
                    {
                        pConstArc.ConstructBearingRadiusChord(pPt, dChordBearing, bCCW, dRadius, dChord, true);
                    }
                    catch { };
                }

                if (bHasRadius && bHasArc && bHasChordBearing)
                {
                    try
                    {
                        pConstArc.ConstructBearingRadiusArc(pPt, dChordBearing, bCCW, dRadius, dArcLength);
                    }
                    catch { };
                }

                if (bHasRadius && bHasDelta && bHasChordBearing)
                {
                    try
                    {
                        pConstArc.ConstructBearingRadiusAngle(pPt, dChordBearing, bCCW, dRadius, dDelta);
                    }
                    catch { };
                }

                if (bHasChord && bHasDelta && bHasChordBearing)
                {
                    try
                    {
                        pConstArc.ConstructBearingAngleChord(pPt, dChordBearing, bCCW, dDelta, dChord);
                    }
                    catch { };
                }

                if (bHasChord && bHasArc && bHasChordBearing)
                {
                    try
                    {
                        pConstArc.ConstructBearingChordArc(pPt, dChordBearing, bCCW, dChord, dArcLength);
                    }
                    catch { };
                }

                //tangent bearing
                if (bHasRadius && bHasChord && bHasTangentBearing)
                {
                    try
                    {
                        pConstArc.ConstructTangentRadiusChord(EntryTangentSegment, false, bCCW, dRadius, dChord);
                    }
                    catch { };
                }

                if (bHasRadius && bHasArc && bHasTangentBearing)
                {
                    try
                    {
                        pConstArc.ConstructTangentRadiusArc(EntryTangentSegment, false, bCCW, dRadius, dArcLength);
                    }
                    catch { };
                }
                if (bHasRadius && bHasDelta && bHasTangentBearing)
                {
                    try
                    {
                        pConstArc.ConstructTangentRadiusAngle(EntryTangentSegment, false, bCCW, dRadius, dDelta);
                    }
                    catch { };
                }

                if (bHasChord && bHasDelta && bHasTangentBearing)
                {
                    try
                    {
                        pConstArc.ConstructTangentAngleChord(EntryTangentSegment, false, bCCW, dDelta, dChord);
                    }
                    catch { };
                }
                if (bHasChord && bHasArc && bHasTangentBearing)
                {
                    try
                    {
                        pConstArc.ConstructTangentChordArc(EntryTangentSegment, false, bCCW, dChord, dArcLength);
                    }
                    catch { };
                }

                //radial bearing
                if (bHasRadialBearing)
                {
                    //need to convert radial bearing to tangent bearing by adding/subtracting 90 degrees
                    double dTanBear = 0;
                    if (bCCW)
                    {
                        dTanBear = dRadialBearing - (Angle_2_Radians("90", esriDirectionUnits.esriDUDecimalDegrees));
                    }
                    else
                    {
                        dTanBear = dRadialBearing + (Angle_2_Radians("90", esriDirectionUnits.esriDUDecimalDegrees));
                    }
                    IConstructPoint2 pToPt = new PointClass();
                    pToPt.ConstructAngleDistance(pPt, dTanBear, 100);
                    ILine EntryTangentLine = new LineClass();
                    EntryTangentLine.PutCoords(pPt, (IPoint)pToPt);
                    EntryTangentSegment = (ISegment)EntryTangentLine;
                }

                if (bHasRadius && bHasChord && bHasRadialBearing)
                {
                    try
                    {
                        pConstArc.ConstructTangentRadiusChord(EntryTangentSegment, false, bCCW, dRadius, dChord);
                    }
                    catch { };
                }
                if (bHasRadius && bHasArc && bHasRadialBearing)
                {
                    try
                    {
                        pConstArc.ConstructTangentRadiusArc(EntryTangentSegment, false, bCCW, dRadius, dArcLength);
                    }
                    catch { };
                }
                if (bHasRadius && bHasDelta && bHasRadialBearing)
                {
                    try
                    {
                        pConstArc.ConstructTangentRadiusAngle(EntryTangentSegment, false, bCCW, dRadius, dDelta);
                    }
                    catch { };
                }
                if (bHasChord && bHasDelta && bHasRadialBearing)
                {
                    try
                    {
                        pConstArc.ConstructTangentAngleChord(EntryTangentSegment, false, bCCW, dDelta, dChord);
                    }
                    catch { };
                }
                if (bHasChord && bHasArc && bHasRadialBearing)
                {
                    try
                    {
                        pConstArc.ConstructTangentChordArc(EntryTangentSegment, false, bCCW, dChord, dArcLength);
                    }
                    catch { };
                }
            }
            else
            { //tangent curve
                if (bHasRadius && bHasChord)
                {
                    try
                    {
                        pConstArc.ConstructTangentRadiusChord(ExitTangentFromPreviousCourse, false, bCCW, dRadius, dChord);
                    }
                    catch { };
                }
                if (bHasRadius && bHasArc)
                {
                    try
                    {
                        pConstArc.ConstructTangentRadiusArc(ExitTangentFromPreviousCourse, false, bCCW, dRadius, dArcLength);
                    }
                    catch { };
                }
                if (bHasRadius && bHasDelta)
                {
                    try
                    {
                        pConstArc.ConstructTangentRadiusAngle(ExitTangentFromPreviousCourse, false, bCCW, dRadius, dDelta);
                    }
                    catch { };
                }
                if (bHasChord && bHasDelta)
                {
                    try
                    {
                        pConstArc.ConstructTangentAngleChord(ExitTangentFromPreviousCourse, false, bCCW, dDelta, dChord);
                    }
                    catch { };
                }
                if (bHasChord && bHasArc)
                {
                    try
                    {
                        pConstArc.ConstructTangentChordArc(ExitTangentFromPreviousCourse, false, bCCW, dChord, dArcLength);
                    }
                    catch { };
                }
            }
            ILine pLine = new LineClass();

            try
            {
                pLine.PutCoords(pArc.FromPoint, pArc.ToPoint);
            }
            catch
            {
                outChordLength = -1; outChordBearing = -1;
                return(null);
            }
            outChordLength  = pLine.Length;
            outChordBearing = pLine.Angle;
            return(pArc);
        }
        private IGSLine CreateGSLine(String inCourse, esriDirectionUnits inDirectionUnits,
                                     esriDirectionType inDirectionType, ISegment EntryTangent,
                                     out ISegment ExitTangent, out ICircularArc outCircularArc)
        {//
            string[]  sCourse = inCourse.Split(' ');
            Utilities UTILS   = new Utilities();
            double    dToMeterUnitConversion = UTILS.ToMeterUnitConversion();
            // ISegment ExitTangent = null;
            string item = (string)sCourse.GetValue(0);

            if (item.ToLower() == "dd")
            {//Direction distance -- straight line course
                IGSLine pLine = new GSLineClass();
                double  dBear = DirectionString_2_NorthAzimuth((string)sCourse.GetValue(1), inDirectionType, inDirectionUnits);
                pLine.Bearing   = dBear;
                pLine.Distance  = Convert.ToDouble(sCourse.GetValue(2)) * dToMeterUnitConversion;
                pLine.FromPoint = m_count;
                m_count        += 1;
                pLine.ToPoint   = m_count;
                //Now define the tangent exit segment
                //in case it's needed for the next course (TC tangent curve, or Angle deflection)
                double dPolar = DirectionString_2_PolarRadians((string)sCourse.GetValue(1),
                                                               inDirectionType, inDirectionUnits);
                IPoint pFromPt = new PointClass();
                pFromPt.PutCoords(1000, 1000);
                IConstructPoint2 pToPt = new PointClass();
                pToPt.ConstructAngleDistance(pFromPt, dPolar, 100);
                ILine ExitTangentLine = new LineClass();
                ExitTangentLine.PutCoords(pFromPt, (IPoint)pToPt);
                ExitTangent    = (ISegment)ExitTangentLine;
                outCircularArc = null;
                Marshal.ReleaseComObject(pFromPt);
                Marshal.ReleaseComObject(pToPt);
                return(pLine);
            }
            if (item.ToLower() == "ad")
            {//Angle deflection distance
                IGSLine pLine      = new GSLineClass();
                double  dDeflAngle = Angle_2_Radians((string)sCourse.GetValue(1), inDirectionUnits);
                //now need to take the previous tangent segment, reverse its orientation and
                //add +ve clockwise to get the bearing
                ILine  calcLine = (ILine)EntryTangent;
                double dBear    = PolarRAD_2_SouthAzimuthRAD(calcLine.Angle) + dDeflAngle;
                pLine.Bearing   = dBear;
                pLine.Distance  = Convert.ToDouble(sCourse.GetValue(2)) * dToMeterUnitConversion;
                pLine.FromPoint = m_count;
                m_count        += 1;
                pLine.ToPoint   = m_count;
                //Now define the tangent exit segment
                //in case it's needed for the next course (TC tangent curve, or Angle deflection)
                IPoint pFromPt = new PointClass();
                pFromPt.PutCoords(1000, 1000);
                IConstructPoint2 pToPt  = new PointClass();
                double           dPolar = NorthAzimuthRAD_2_PolarRAD(dBear);
                pToPt.ConstructAngleDistance(pFromPt, dPolar, 100);
                ILine ExitTangentLine = new LineClass();
                ExitTangentLine.PutCoords(pFromPt, (IPoint)pToPt);
                ExitTangent    = (ISegment)ExitTangentLine;
                outCircularArc = null;
                Marshal.ReleaseComObject(pFromPt);
                Marshal.ReleaseComObject(pToPt);

                return(pLine);
            }
            else if ((item.ToLower() == "nc") || (item.ToLower() == "tc"))
            {
                double       dChordlength;
                double       dChordBearing;
                ICircularArc pArc = ConstructCurveFromString(inCourse, EntryTangent,
                                                             inDirectionType, inDirectionUnits, out dChordlength, out dChordBearing);
                try
                {
                    IGSLine pLine = new GSLineClass();
                    pLine.Bearing = PolarRAD_2_NorthAzimuthRAD(dChordBearing);
                    pLine.Radius  = pArc.Radius * dToMeterUnitConversion;//convert to meters
                    if (pArc.IsCounterClockwise)
                    {
                        pLine.Radius = pLine.Radius * -1;
                    }
                    pLine.Distance  = dChordlength * dToMeterUnitConversion; //convert to meters
                    pLine.FromPoint = m_count;
                    m_count        += 1;
                    pLine.ToPoint   = m_count;
                    ILine pTangentLine = new LineClass();
                    pArc.QueryTangent(esriSegmentExtension.esriExtendTangentAtTo, 1, true, 100, pTangentLine);
                    //pass the exit tangent back out for use as next entry tangent
                    ExitTangent    = (ISegment)pTangentLine;
                    outCircularArc = pArc;
                    return(pLine);
                }
                catch { }
            }
            outCircularArc = null;
            ExitTangent    = null;
            return(null);
        }
        private IGSLine CreateGSLine(String inCourse, esriDirectionUnits inDirectionUnits,
            esriDirectionType inDirectionType, ISegment EntryTangent,
            out ISegment ExitTangent, out ICircularArc outCircularArc)
        {
            //
              string[] sCourse = inCourse.Split(' ');
              Utilities UTILS = new Utilities();
              double dToMeterUnitConversion = UTILS.ToMeterUnitConversion();
              // ISegment ExitTangent = null;
              string item = (string)sCourse.GetValue(0);
              if (item.ToLower() == "dd")
              {//Direction distance -- straight line course
            IGSLine pLine = new GSLineClass();
            double dBear = DirectionString_2_NorthAzimuth((string)sCourse.GetValue(1), inDirectionType, inDirectionUnits);
            pLine.Bearing = dBear;
            pLine.Distance = Convert.ToDouble(sCourse.GetValue(2)) * dToMeterUnitConversion;
            pLine.FromPoint = m_count;
            m_count += 1;
            pLine.ToPoint = m_count;
            //Now define the tangent exit segment
            //in case it's needed for the next course (TC tangent curve, or Angle deflection)
            double dPolar = DirectionString_2_PolarRadians((string)sCourse.GetValue(1),
                inDirectionType, inDirectionUnits);
            IPoint pFromPt = new PointClass();
            pFromPt.PutCoords(1000, 1000);
            IConstructPoint2 pToPt = new PointClass();
            pToPt.ConstructAngleDistance(pFromPt, dPolar, 100);
            ILine ExitTangentLine = new LineClass();
            ExitTangentLine.PutCoords(pFromPt, (IPoint)pToPt);
            ExitTangent = (ISegment)ExitTangentLine;
            outCircularArc = null;
            Marshal.ReleaseComObject(pFromPt);
            Marshal.ReleaseComObject(pToPt);
            return pLine;
              }
              if (item.ToLower() == "ad")
              {//Angle deflection distance
            IGSLine pLine = new GSLineClass();
            double dDeflAngle = Angle_2_Radians((string)sCourse.GetValue(1), inDirectionUnits);
            //now need to take the previous tangent segment, reverse its orientation and
            //add +ve clockwise to get the bearing
            ILine calcLine = (ILine)EntryTangent;
            double dBear = PolarRAD_2_SouthAzimuthRAD(calcLine.Angle) + dDeflAngle;
            pLine.Bearing = dBear;
            pLine.Distance = Convert.ToDouble(sCourse.GetValue(2)) * dToMeterUnitConversion;
            pLine.FromPoint = m_count;
            m_count += 1;
            pLine.ToPoint = m_count;
            //Now define the tangent exit segment
            //in case it's needed for the next course (TC tangent curve, or Angle deflection)
            IPoint pFromPt = new PointClass();
            pFromPt.PutCoords(1000, 1000);
            IConstructPoint2 pToPt = new PointClass();
            double dPolar = NorthAzimuthRAD_2_PolarRAD(dBear);
            pToPt.ConstructAngleDistance(pFromPt, dPolar, 100);
            ILine ExitTangentLine = new LineClass();
            ExitTangentLine.PutCoords(pFromPt, (IPoint)pToPt);
            ExitTangent = (ISegment)ExitTangentLine;
            outCircularArc = null;
            Marshal.ReleaseComObject(pFromPt);
            Marshal.ReleaseComObject(pToPt);

            return pLine;
              }
              else if ((item.ToLower() == "nc") || (item.ToLower() == "tc"))
              {
            double dChordlength;
            double dChordBearing;
            ICircularArc pArc = ConstructCurveFromString(inCourse, EntryTangent,
                inDirectionType, inDirectionUnits, out dChordlength, out dChordBearing);
            try
            {
              IGSLine pLine = new GSLineClass();
              pLine.Bearing = PolarRAD_2_NorthAzimuthRAD(dChordBearing);
              pLine.Radius = pArc.Radius * dToMeterUnitConversion;//convert to meters
              if (pArc.IsCounterClockwise) { pLine.Radius = pLine.Radius * -1; }
              pLine.Distance = dChordlength * dToMeterUnitConversion; //convert to meters
              pLine.FromPoint = m_count;
              m_count += 1;
              pLine.ToPoint = m_count;
              ILine pTangentLine = new LineClass();
              pArc.QueryTangent(esriSegmentExtension.esriExtendTangentAtTo, 1, true, 100, pTangentLine);
              //pass the exit tangent back out for use as next entry tangent
              ExitTangent = (ISegment)pTangentLine;
              outCircularArc = pArc;
              return pLine;
            }
            catch { }
              }
              outCircularArc = null;
              ExitTangent = null;
              return null;
        }
Пример #13
0
 private PointClass RectanglePoint2(IPoint point, double angle,double height)
 {
     PointClass p = new PointClass();
     p.SpatialReference = m_hookHelper.FocusMap.SpatialReference;
     p.ConstructAngleDistance(point, angle, height/2);
     return p;
 }
Пример #14
0
        static public IPolyline intelligentSearchMethod(IFeatureLayer terlkFyr, FeaPtInform fptInfo, IPolyline leftPly, IPolyline rightPly, IGeometry geometry, bool isValOrRidge)
        {
            #region  xx
            isZearo = 0;
            ptList  = new List <IPoint>();
            FeaPtInform newFptClass = new FeaPtInform();
            fristPt = fptInfo.PtCoord;
            ptList.Add(fptInfo.PtCoord);

            IPointCollection leftPtCol  = leftPly as IPointCollection;
            IPointCollection rightPtCol = rightPly as IPointCollection;
            IPoint           angPt      = PublicFunctionClass.CreateAngleBisectorPt(fptInfo, terlkFyr, isValOrRidge);
            ptList.Add(angPt);
            secondPt          = angPt;
            newLine.FromPoint = fristPt;
            newLine.ToPoint   = secondPt;

            double l = 100; double r = 100;
            Dictionary <IPoint, double> leftDic  = ReturnMinDistancePt(leftPly, secondPt);
            Dictionary <IPoint, double> rightDic = ReturnMinDistancePt(rightPly, secondPt);
            l = leftDic.Values.ElementAt(0);
            r = rightDic.Values.ElementAt(0);
            double          h                    = (l + r) / 2;
            IConstructPoint extendPt             = new PointClass();
            extendPt.ConstructAngleDistance(secondPt, newLine.Angle, h);
            IPoint nePt = new PointClass();
            nePt = extendPt as IPoint;
            newLine.FromPoint = secondPt;
            newLine.ToPoint   = nePt;
            Dictionary <IPoint, double> dic = new Dictionary <IPoint, double>();
            while (true)
            {
                if (isZearo == 0)
                {
                    fristPt  = secondPt;
                    secondPt = nePt;
                }
                else
                {
                    fristPt  = newLine.FromPoint;
                    secondPt = newLine.ToPoint;
                }
                if (isZearo != 0)
                {
                    if (geometry.GeometryType == esriGeometryType.esriGeometryPoint)
                    {
                        ITopologicalOperator pTopoOper   = newLine.ToPoint as ITopologicalOperator;
                        IPolygon             pBufferPoly = pTopoOper.Buffer(50) as IPolygon;
                        IRelationalOperator  relatOper   = pBufferPoly as IRelationalOperator;
                        if (relatOper.Contains(geometry) == true)
                        {
                            FeaPtInform fpt = new FeaPtInform();
                            fpt.PtCoord   = newLine.ToPoint;
                            fpt.PtCoord.Z = 10;
                            ptList.Add(fpt.PtCoord);
                            feapt = ChooseOptimalFeaPt.GetOptiumPt(terlkFyr, fptList, fpt, newLine, isValOrRidge);
                            ptList.Add(feapt.PtCoord);
                            IPolyline ply = CreatePly(ptList);
                            return(ply);
                        }
                    }
                    else if (geometry.GeometryType == esriGeometryType.esriGeometryPolyline)
                    {
                        IPolyline ppy = new PolylineClass();
                        ppy.FromPoint = newLine.FromPoint;
                        ppy.ToPoint   = newLine.ToPoint;
                        ITopologicalOperator topo = ppy as ITopologicalOperator;
                        IGeometry            pgeo = topo.Intersect(geometry, esriGeometryDimension.esriGeometry0Dimension);
                        if (pgeo.IsEmpty == false)
                        {
                            IPointCollection ptcol = pgeo as IPointCollection;
                            IPoint           pt    = ptcol.get_Point(0);
                            pt.Z = 10;
                            ptList.Add(pt);
                            IPolyline ply = CreatePly(ptList);
                            return(ply);
                        }
                    }
                }
                K        = newLine.Angle;
                l        = 100; r = 100;
                leftDic  = ReturnMinDistancePt(leftPly, secondPt);
                rightDic = ReturnMinDistancePt(rightPly, secondPt);
                l        = leftDic.Values.ElementAt(0);
                r        = rightDic.Values.ElementAt(0);
                double diff = Math.Abs(l - r);
                leNew = diff;
                if (dic.ContainsKey(secondPt) == false)
                {
                    dic.Add(secondPt, diff);
                }
                if (diff < 0.03 || isZearo > 15)
                {
                    if (isZearo > 15)
                    {
                        var dicSd = from objDic in dic orderby objDic.Value ascending select objDic;

                        foreach (KeyValuePair <IPoint, double> keyv in dicSd)
                        {
                            secondPt = keyv.Key; break;
                        }
                    }

                    h          = (l + r) / 2;
                    secondPt.Z = 10;
                    ptList.Add(secondPt);
                    newFptClass         = new FeaPtInform();
                    newFptClass.PtCoord = secondPt;

                    extendPt = new PointClass();
                    extendPt.ConstructAngleDistance(secondPt, newLine.Angle, h);
                    IPoint newPt = extendPt as IPoint;
                    newLine.FromPoint = secondPt;;
                    newLine.ToPoint   = newPt;
                    fptInfo           = newFptClass;
                    K              = newLine.Angle;
                    leOld          = 0;
                    leNew          = 0;
                    startStep      = 0;
                    adjustiveAngle = 5;
                    dic            = new Dictionary <IPoint, double>();
                    isZearo        = 1;
                }
                else
                {
                    if (startStep == 0)
                    {
                        if (l > r)
                        {
                            adjustiveAngle = -adjustiveAngle;
                            direction      = 0;
                        }
                        else
                        {
                            adjustiveAngle = 5;
                            direction      = 1;
                        }
                        IPoint adjustivePt = new PointClass();
                        adjustivePt.X       = newLine.FromPoint.X + h * Math.Cos(newLine.Angle + (Math.PI / 180) * adjustiveAngle);
                        adjustivePt.Y       = newLine.FromPoint.Y + h * Math.Sin(newLine.Angle + (Math.PI / 180) * adjustiveAngle);
                        leOld               = leNew;
                        newLine.FromPoint   = fristPt;;
                        newLine.ToPoint     = adjustivePt;
                        newFptClass         = new FeaPtInform();
                        newFptClass.PtCoord = fristPt;
                        newFptClass.Elev    = fptInfo.Elev;
                        fptInfo             = newFptClass;
                        startStep           = 1;
                        isZearo++;
                    }
                    else if (startStep == 1)
                    {
                        if (leNew < leOld)
                        {
                            if (direction == 0)
                            {
                                if (adjustiveAngle > 0)
                                {
                                    adjustiveAngle = -adjustiveAngle;
                                }
                                double a = adjustiveAngle;
                                adjustiveAngle = a; direction = 0;
                            }
                            else if (direction == 1)
                            {
                                if (adjustiveAngle < 0)
                                {
                                    adjustiveAngle = -adjustiveAngle;
                                }
                                double a = adjustiveAngle;
                                adjustiveAngle = a; direction = 1;
                            }
                            IPoint adjustivePt = new PointClass();
                            adjustivePt.X       = newLine.FromPoint.X + h * Math.Cos(newLine.Angle + (Math.PI / 180) * adjustiveAngle);
                            adjustivePt.Y       = newLine.FromPoint.Y + h * Math.Sin(newLine.Angle + (Math.PI / 180) * adjustiveAngle);
                            leOld               = leNew;
                            newLine.FromPoint   = fristPt;;
                            newLine.ToPoint     = adjustivePt;
                            newFptClass         = new FeaPtInform();
                            newFptClass.PtCoord = fristPt;
                            newFptClass.Elev    = fptInfo.Elev;
                            fptInfo             = newFptClass;
                            startStep           = 1;
                        }
                        else if (leNew > leOld)
                        {
                            if (direction == 0)
                            {
                                if (adjustiveAngle < 0)
                                {
                                    adjustiveAngle = -adjustiveAngle;
                                }
                                adjustiveAngle = adjustiveAngle / 2;
                                direction      = 1;
                            }
                            else if (direction == 1)
                            {
                                if (adjustiveAngle > 0)
                                {
                                    adjustiveAngle = -adjustiveAngle;
                                }
                                adjustiveAngle = adjustiveAngle / 2;
                                direction      = 0;
                            }
                            IPoint adjustivePt = new PointClass();
                            adjustivePt.X       = newLine.FromPoint.X + h * Math.Cos(newLine.Angle + (Math.PI / 180) * adjustiveAngle);
                            adjustivePt.Y       = newLine.FromPoint.Y + h * Math.Sin(newLine.Angle + (Math.PI / 180) * adjustiveAngle);
                            leOld               = leNew;
                            newLine.FromPoint   = fristPt;;
                            newLine.ToPoint     = adjustivePt;
                            newFptClass         = new FeaPtInform();
                            newFptClass.PtCoord = fristPt;
                            newFptClass.Elev    = fptInfo.Elev;
                            fptInfo             = newFptClass;
                            startStep           = 1;
                        }
                        else if (leNew == leOld)
                        {
                            extendPt = new PointClass();
                            extendPt.ConstructAngleDistance(secondPt, newLine.Angle, h);
                            IPoint newPt = extendPt as IPoint;
                            newLine.FromPoint   = secondPt;;
                            newLine.ToPoint     = newPt;
                            newFptClass         = new FeaPtInform();
                            newFptClass.PtCoord = secondPt;
                            newFptClass.Elev    = fptInfo.Elev;
                            fptInfo             = newFptClass;
                            K              = newLine.Angle;
                            leOld          = 0;
                            leNew          = 0;
                            startStep      = 0;
                            adjustiveAngle = 5;
                        }
                        isZearo++;
                    }
                }
            }
            #endregion
        }
Пример #15
0
        private IPoint ConstructPoint(IPoint sourcePoint, double angle, double offsetAngle, double length, double width)
        {
            var p = new PointClass();
            p.ConstructAngleDistance(sourcePoint, angle * Deg2Rad, width / 2);
            var p2 = new PointClass();
            p2.ConstructAngleDistance(p, offsetAngle * Deg2Rad, length);

            return p2;
        }
Пример #16
0
        static public IPolyline intelligentSearchMethod(IFeatureLayer terlkFyr, FeaPtInform fptInfo, IPolyline leftPly, IPolyline rightPly, IGeometry geometry, int isSaddOrGeneral)
        {
            ptList = new List <IPoint>();
            FeaPtInform newFptClass = new FeaPtInform();

            fristPt = fptInfo.PtCoord;
            if (isSaddOrGeneral == 0)
            {
                ptList.Add(fptInfo.PtCoord);
                IPointCollection terlkPtc    = terlkFyr.FeatureClass.GetFeature(fptInfo.PtAtPlyOid).Shape as IPointCollection;
                IConstructPoint  constructPt = new PointClass();
                constructPt.ConstructAngleBisector(terlkPtc.get_Point(fptInfo.PtAtNumber - 1), fptInfo.PtCoord, terlkPtc.get_Point(fptInfo.PtAtNumber + 1), 6.45, false);
                IPoint newPt = new PointClass();
                newPt    = constructPt as IPoint;
                secondPt = newPt;
                newPt.Z  = 10;
                ptList.Add(newPt);
                newFptClass.PtCoord = newPt;
                newFptClass.Elev    = fptInfo.Elev;
                fptInfo             = newFptClass;
            }
            else
            {
                ptList.Add(fptInfo.PtCoord);

                IPointCollection leftPtCol  = leftPly as IPointCollection;
                IPointCollection rightPtCol = rightPly as IPointCollection;
                for (int i = 0; i < leftPtCol.PointCount - 3; i++)
                {
                    int                  p    = 0;
                    IPolyline            ply1 = CreateAngleBisector(leftPtCol.get_Point(i), leftPtCol.get_Point(i + 1), leftPtCol.get_Point(i + 2));
                    ITopologicalOperator topo = ply1 as ITopologicalOperator;
                    for (int j = i; j < rightPtCol.PointCount - 3; j++)
                    {
                        IPolyline ply2 = CreateAngleBisector(rightPtCol.get_Point(j), rightPtCol.get_Point(j + 1), rightPtCol.get_Point(j + 2));
                        IGeometry pGeo = topo.Intersect(ply2, esriGeometryDimension.esriGeometry0Dimension);
                        if (pGeo.IsEmpty == false)
                        {
                            IPointCollection ptc      = pGeo as IPointCollection;
                            IPoint           pt       = ptc.get_Point(0);
                            double           midLen   = Length(pt, fptInfo.PtCoord);
                            double           leftLen  = Length(pt, leftPtCol.get_Point(i + 1));
                            double           rightLen = Length(pt, rightPtCol.get_Point(j + 1));
                            if (Math.Abs(midLen - leftLen) < 1 && Math.Abs(midLen - rightLen) < 1)
                            {
                                pt.Z = 10;
                                ptList.Add(pt);
                                secondPt            = pt;
                                newFptClass.PtCoord = pt;
                                newFptClass.Elev    = fptInfo.Elev;
                                fptInfo             = newFptClass;
                                p = 1;
                                break;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    if (p == 1)
                    {
                        break;
                    }
                }
            }
            newLine.FromPoint = fristPt;
            newLine.ToPoint   = secondPt;

            double l = 100; double r = 100;
            Dictionary <IPoint, double> leftDic  = ReturnMinDistancePt(leftPly, secondPt);
            Dictionary <IPoint, double> rightDic = ReturnMinDistancePt(rightPly, secondPt);

            l = leftDic.Values.ElementAt(0);
            r = rightDic.Values.ElementAt(0);
            double          h                    = (l + r) / 6.0;
            IConstructPoint extendPt             = new PointClass();

            extendPt.ConstructAngleDistance(secondPt, newLine.Angle, h);
            IPoint nePt = new PointClass();

            nePt = extendPt as IPoint;
            int m = 0;

            newLine.FromPoint = secondPt;
            newLine.ToPoint   = nePt;
            Dictionary <IPoint, double> dic = new Dictionary <IPoint, double>();

            while (true)
            {
                if (m == 0)
                {
                    fristPt  = secondPt;
                    secondPt = nePt;
                }
                else
                {
                    fristPt  = newLine.FromPoint;
                    secondPt = newLine.ToPoint;
                }
                if (m != 0)
                {
                    if (isSaddOrGeneral == 0 && geometry.GeometryType == esriGeometryType.esriGeometryPolyline)
                    {
                        IPolyline ppy = new PolylineClass();
                        ppy.FromPoint = newLine.FromPoint;
                        ppy.ToPoint   = newLine.ToPoint;
                        ITopologicalOperator topo = ppy as ITopologicalOperator;
                        IGeometry            pgeo = topo.Intersect(geometry, esriGeometryDimension.esriGeometry0Dimension);
                        if (pgeo.IsEmpty == false)
                        {
                            IPointCollection ptcol = pgeo as IPointCollection;
                            IPoint           pt    = ptcol.get_Point(0);
                            pt.Z = 10;
                            ptList.Add(pt);
                            IPolyline ply = CreatePly(ptList);
                            return(ply);
                        }
                    }
                    else if (isSaddOrGeneral == 0 && geometry.GeometryType == esriGeometryType.esriGeometryPoint)
                    {
                        ITopologicalOperator pTopoOper   = newLine.ToPoint as ITopologicalOperator;
                        IPolygon             pBufferPoly = pTopoOper.Buffer(30) as IPolygon;
                        IRelationalOperator  relatOper   = pBufferPoly as IRelationalOperator;
                        if (relatOper.Contains(geometry) == true)
                        {
                            IPoint ppt = geometry as IPoint;
                            ptList.Add(ppt);
                            IPolyline ply = CreatePly(ptList);
                            return(ply);
                        }
                    }
                    else if (isSaddOrGeneral == 1 && geometry.GeometryType == esriGeometryType.esriGeometryPolyline)
                    {
                        IPolyline ppy = new PolylineClass();
                        ppy.FromPoint = newLine.FromPoint;
                        ppy.ToPoint   = newLine.ToPoint;
                        ITopologicalOperator topo = ppy as ITopologicalOperator;
                        IGeometry            pgeo = topo.Intersect(geometry, esriGeometryDimension.esriGeometry0Dimension);
                        if (pgeo.IsEmpty == false)
                        {
                            IPointCollection ptcol = pgeo as IPointCollection;
                            IPoint           pt    = ptcol.get_Point(0);
                            pt.Z = 10;
                            ptList.Add(pt);
                            IPolyline ply = CreatePly(ptList);
                            return(ply);
                        }
                    }
                }
                K        = newLine.Angle;
                l        = 100; r = 100;
                leftDic  = ReturnMinDistancePt(leftPly, secondPt);
                rightDic = ReturnMinDistancePt(rightPly, secondPt);
                l        = leftDic.Values.ElementAt(0);
                r        = rightDic.Values.ElementAt(0);
                double diff = Math.Abs(l - r);
                leNew = diff;
                if (dic.ContainsKey(secondPt) == false)
                {
                    dic.Add(secondPt, diff);
                }

                if (diff < 0.03 || m > 15)
                {
                    if (m > 15)
                    {
                        var dicSd = from objDic in dic orderby objDic.Value ascending select objDic;

                        foreach (KeyValuePair <IPoint, double> keyv in dicSd)
                        {
                            secondPt = keyv.Key; break;
                        }
                    }
                    h          = (l + r) / 6.0;
                    secondPt.Z = 10;
                    ptList.Add(secondPt);
                    newFptClass         = new FeaPtInform();
                    newFptClass.PtCoord = secondPt;

                    extendPt = new PointClass();
                    extendPt.ConstructAngleDistance(secondPt, newLine.Angle, h);
                    IPoint newPt = extendPt as IPoint;
                    newLine.FromPoint = secondPt;;
                    newLine.ToPoint   = newPt;
                    fptInfo           = newFptClass;
                    K              = newLine.Angle;
                    leOld          = 0;
                    leNew          = 0;
                    startStep      = 0;
                    adjustiveAngle = 5;
                    dic            = new Dictionary <IPoint, double>();
                    m              = 1;
                }
                else
                {
                    if (startStep == 0)
                    {
                        if (l > r)
                        {
                            adjustiveAngle = -adjustiveAngle;
                            direction      = 0;
                        }
                        else
                        {
                            adjustiveAngle = 5;
                            direction      = 1;
                        }
                        IPoint adjustivePt = new PointClass();
                        adjustivePt.X       = newLine.FromPoint.X + h * Math.Cos(newLine.Angle + (Math.PI / 180) * adjustiveAngle);
                        adjustivePt.Y       = newLine.FromPoint.Y + h * Math.Sin(newLine.Angle + (Math.PI / 180) * adjustiveAngle);
                        leOld               = leNew;
                        newLine.FromPoint   = fristPt;;
                        newLine.ToPoint     = adjustivePt;
                        newFptClass         = new FeaPtInform();
                        newFptClass.PtCoord = fristPt;
                        newFptClass.Elev    = fptInfo.Elev;
                        fptInfo             = newFptClass;
                        startStep           = 1;
                        m++;
                    }
                    else if (startStep == 1)
                    {
                        if (leNew < leOld)
                        {
                            if (direction == 0)
                            {
                                if (adjustiveAngle > 0)
                                {
                                    adjustiveAngle = -adjustiveAngle;
                                }
                                double a = adjustiveAngle;
                                adjustiveAngle = a; direction = 0;
                            }
                            else if (direction == 1)
                            {
                                if (adjustiveAngle < 0)
                                {
                                    adjustiveAngle = -adjustiveAngle;
                                }
                                double a = adjustiveAngle;
                                adjustiveAngle = a; direction = 1;
                            }
                            IPoint adjustivePt = new PointClass();
                            adjustivePt.X       = newLine.FromPoint.X + h * Math.Cos(newLine.Angle + (Math.PI / 180) * adjustiveAngle);
                            adjustivePt.Y       = newLine.FromPoint.Y + h * Math.Sin(newLine.Angle + (Math.PI / 180) * adjustiveAngle);
                            leOld               = leNew;
                            newLine.FromPoint   = fristPt;;
                            newLine.ToPoint     = adjustivePt;
                            newFptClass         = new FeaPtInform();
                            newFptClass.PtCoord = fristPt;
                            newFptClass.Elev    = fptInfo.Elev;
                            fptInfo             = newFptClass;
                            startStep           = 1;
                        }
                        else if (leNew > leOld)
                        {
                            if (direction == 0)
                            {
                                if (adjustiveAngle < 0)
                                {
                                    adjustiveAngle = -adjustiveAngle;
                                }
                                adjustiveAngle = adjustiveAngle / 2;
                                direction      = 1;
                            }
                            else if (direction == 1)
                            {
                                if (adjustiveAngle > 0)
                                {
                                    adjustiveAngle = -adjustiveAngle;
                                }
                                adjustiveAngle = adjustiveAngle / 2;
                                direction      = 0;
                            }
                            IPoint adjustivePt = new PointClass();
                            adjustivePt.X       = newLine.FromPoint.X + h * Math.Cos(newLine.Angle + (Math.PI / 180) * adjustiveAngle);
                            adjustivePt.Y       = newLine.FromPoint.Y + h * Math.Sin(newLine.Angle + (Math.PI / 180) * adjustiveAngle);
                            leOld               = leNew;
                            newLine.FromPoint   = fristPt;;
                            newLine.ToPoint     = adjustivePt;
                            newFptClass         = new FeaPtInform();
                            newFptClass.PtCoord = fristPt;
                            newFptClass.Elev    = fptInfo.Elev;
                            fptInfo             = newFptClass;
                            startStep           = 1;
                        }
                        else if (leNew == leOld)
                        {
                            extendPt = new PointClass();
                            extendPt.ConstructAngleDistance(secondPt, newLine.Angle, h);
                            IPoint newPt = extendPt as IPoint;
                            newLine.FromPoint   = secondPt;;
                            newLine.ToPoint     = newPt;
                            newFptClass         = new FeaPtInform();
                            newFptClass.PtCoord = secondPt;
                            newFptClass.Elev    = fptInfo.Elev;
                            fptInfo             = newFptClass;
                            K              = newLine.Angle;
                            leOld          = 0;
                            leNew          = 0;
                            startStep      = 0;
                            adjustiveAngle = 5;
                        }
                    }
                    m++;
                }
            }
        }
Пример #17
0
        void distanceAngle_Disposed(object sender, EventArgs e)
        {
            if (_isDistAngleFormDisposed) return;

            double x = 0, y = 0;
            IPoint anchor = new PointClass();
            if (_segmentCollection.SegmentCount > 0)
            {
                try
                {
                    ISegment seg = _segmentCollection.get_Segment(_segmentCollection.SegmentCount - 1);
                    x = seg.ToPoint.X;
                    y = seg.ToPoint.Y;
                }
                catch
                {
                }
            }
            else
            {
                x = _initialAnchorPoint.X;
                y = _initialAnchorPoint.Y;
            }

            if (x > 0 && y > 0 && _distance > 10)
            {
                anchor.X = x;
                anchor.Y = y;
                IAngularConverter converter = new AngularConverterClass();
                esriDirectionType dt = ((IEditProperties2)ExtensionInfo.Editor).DirectionType;// GISApplication.EditorDirectionType();
                esriDirectionUnits ut = ((IEditProperties2)ExtensionInfo.Editor).DirectionUnits;// GISApplication.EditorDirectionUnit();
                converter.SetAngle(_angle, esriDirectionType.esriDTPolar, ut);
                _angle = converter.GetAngle(dt, ut);
                IConstructPoint newPoint = new PointClass();
                double radians = DisplayMap.DegreesToRadians(_angle);
                newPoint.ConstructAngleDistance(anchor, radians, _distance);
                ProcessSegment((IPoint)newPoint);
            }

            _isDistAngleFormDisposed = true;
        }
Пример #18
0
        public static IPath MakeTextPath(IPath pPath, double length)
        {
            try
            {
                double angle = GetAngle(pPath);
                IPoint pPt = pPath.ToPoint;
                IConstructPoint pCP = new PointClass();
                double PI = 3.1415926535897;
                double rad = angle * PI / 180;
                pCP.ConstructAngleDistance(pPt, rad, 1);
                IPoint pNew = pCP as IPoint;

                IPath pNewPath = new PathClass();
                pNewPath.FromPoint = pPt;
                pNewPath.ToPoint = pNew;
                if (ShouldFlip(angle))
                {
                    pNewPath.ReverseOrientation();
                }
                return pNewPath;
            }
            catch (Exception eX)
            {
                MessageBox.Show(eX.Message);
                return null;
            }
        }
Пример #19
0
        public void ContructGeometry(IPoint point, List<KeyValuePair<int, double>> datasources, out List<KeyValuePair<string, IPolygon>> polygons, out List<IPoint> lineStartPoints, out List<IPoint> txtPoints)
        {
            _centerPoint = new PointClass { X = point.X, Y = point.Y };
            polygons = new List<KeyValuePair<string, IPolygon>>();

            lineStartPoints = new List<IPoint>();
            txtPoints = new List<IPoint>();

            var polygonBlack = new PolygonClass();
            var polygonWhite = new PolygonClass();
            _linepoints = lineStartPoints;
            _points = txtPoints;

            var indexLine = 0;
            var length = datasources.Sum(s => s.Value) * BL;
            var totalLength = length / 2;
            _halfHeight = length / 2;
            _height3 = _halfHeight + GeometryHeight1;
            _height4 = _halfHeight + GeometryHeight0 + GeometryHeight1;
            IPoint lastFromPoint = null;
            //IPoint lastToPoint = null;

            foreach (var d in datasources)
            {
                double dd = d.Value * BL;
                var list30 = new List<IPoint>
                {
                    ConstructPoint(_centerPoint, 180, 90, totalLength),
                    ConstructPoint(_centerPoint, 0, 90, totalLength),
                    ConstructPoint(_centerPoint, 0, 90, totalLength - dd),
                    ConstructPoint(_centerPoint, 180, 90, totalLength - dd),
                    ConstructPoint(_centerPoint, 180, 90, totalLength)
                };

                //  生成面
                var geometry = ConstructRing(list30);

                if (d.Key == 0)
                {
                    polygonWhite.AddGeometry(geometry);
                }
                else
                {
                    polygonBlack.AddGeometry(geometry);
                }

                //int angleLine = indexLine % 2 == 0 ? 0 : 180;

                var fromPoint = list30[indexLine % 2 + 2];
                //var toPoint = ConstructPoint3(fromPoint, angleLine, LineWidth);

                //  生成线
                _linepoints.Add(fromPoint);

                lastFromPoint = list30[3];
                //lastToPoint = ConstructPoint3(lastFromPoint, Angle2, LineWidth * 2);

                var txtPoint = new PointClass();
                txtPoint.ConstructAngleDistance(fromPoint, (TextOffsetAngle + indexLine % 2 * 180) * Deg2Rad, TextOffsetDistance);

                //  生成点
                _points.Add(txtPoint);

                totalLength -= dd;
                indexLine++;
            }

            if (lastFromPoint != null)
            {
                var txtLastPoint = new PointClass();
                txtLastPoint.ConstructAngleDistance(lastFromPoint, 180 * Deg2Rad, LastTextOffsetDistance);

                //  生成点
                _points.Add(txtLastPoint);
                //  生成线
                _linepoints.Add(lastFromPoint);
            }

            polygonWhite.Close();
            polygonBlack.Close();
            var tPolygon = new PolygonClass();
            polygons.Add(new KeyValuePair<string, IPolygon>("top", ContructGeometry(out tPolygon)));
            polygons.Add(new KeyValuePair<string, IPolygon>("top", tPolygon));
            polygons.Add(new KeyValuePair<string, IPolygon>("white", polygonWhite));
            polygons.Add(new KeyValuePair<string, IPolygon>("black", polygonBlack));
        }