/// <summary>
        /// Construct Offset
        /// </summary>
        /// <param name="polyline">object polyline</param>
        /// <param name="point">value of offset</param>
        /// <param name="offset">offset point</param>
        /// <returns>point with offset</returns>
        internal static IPoint ConstructOffset(IPolyline polyline, IPoint point, double?offset)
        {
            if (polyline == null || polyline.IsEmpty)
            {
                return(null);
            }

            if (point == null || point.IsEmpty)
            {
                return(null);
            }

            if ((!offset.HasValue) || double.IsNaN(offset.Value) || offset.Value == 0.0)
            {
                return(point);
            }

            double distanceAlongCurve = 0;
            double distanceFromCurve  = 0;
            bool   rightSide          = false;
            IPoint outPoint           = new PointClass();

            polyline.QueryPointAndDistance(esriSegmentExtension.esriNoExtension, point, false, outPoint, ref distanceAlongCurve, ref distanceFromCurve, ref rightSide);
            IConstructPoint constructPoint = outPoint as IConstructPoint;

            constructPoint.ConstructOffset(polyline, esriSegmentExtension.esriNoExtension, distanceAlongCurve, false, offset.Value);
            return(constructPoint as IPoint);
        }
Exemple #2
0
        public static IPoint ConstructPoint_AngleDistance(IPoint point, double angle, double distance)
        {
            IPoint          pPoint          = new PointClass();
            IConstructPoint pConstructPoint = pPoint as IConstructPoint;

            pConstructPoint.ConstructAngleDistance(point, angle, distance);
            return(pPoint);
        }
Exemple #3
0
        public void ConstructPointParallelToLine(IPolyline Path)
        {
            IWorkspaceEdit WorkspaceEdit = null;

            try
            {
                if (Path != null)
                {
                    if (Path.GeometryType == esriGeometryType.esriGeometryPolyline)
                    {
                        firstLine       = false;
                        widthPointsMain = new List <IPoint>();
                        heigthPoints    = new List <IPoint>();
                        widthPoints     = new List <IPoint>();

                        IFeatureClass rectsFeatureClass = ((IFeatureLayer)lstLayers[cboLayers.SelectedIndex]).FeatureClass;
                        IWorkspace    workspace         = ((IDataset)rectsFeatureClass).Workspace;
                        WorkspaceEdit = (IWorkspaceEdit)workspace;

                        if (!WorkspaceEdit.IsBeingEdited())
                        {
                            WorkspaceEdit.StartEditing(true);
                        }
                        WorkspaceEdit.StartEditOperation();

                        IConstructPoint constructionPoint = (IConstructPoint) new ESRI.ArcGIS.Geometry.Point();

                        IGeometryCollection geometryCollection = Path as IGeometryCollection;
                        ISegmentCollection  segmentCollection  = geometryCollection.get_Geometry(0) as ISegmentCollection;
                        widthSegment  = segmentCollection.get_Segment(0);
                        heightSegment = segmentCollection.get_Segment(1);

                        IPoint fromPoint = new ESRI.ArcGIS.Geometry.Point();
                        heightSegment.QueryFromPoint(fromPoint);
                        widthPointsMain.Add(fromPoint);

                        IRgbColor rgbColor = GetColor(255, 0, 0);
                        //AddGraphicToMap((IMap)GetActiveView, fromPoint, rgbColor, rgbColor);
                        //GetActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

                        widthSegment.ReverseOrientation();


                        double distanceAlongWidthBunderiesPoints  = 0;
                        double distanceAlongHeightBunderiesPoints = 0;

                        for (int i = 0; i < NumberOfRectsinWidth; i++)
                        {
                            IPoint qpWidthSegment = GetQPWidthSegment(distanceAlongWidthBunderiesPoints + Widthofrects);
                            if (qpWidthSegment == null)
                            {
                                return;
                            }
                            widthPointsMain.Add(qpWidthSegment);

                            //AddGraphicToMap((IMap)GetActiveView, qpWidthSegment, rgbColor, rgbColor);

                            if (i != NumberOfRectsinWidth - 1)
                            {
                                IPoint qpWidthSegmentWithDistance = GetQPWidthSegment(distanceAlongWidthBunderiesPoints + Widthofrects + distanceAlongWidth);
                                //AddGraphicToMap((IMap)GetActiveView, qpWidthSegmentWithDistance, rgbColor, rgbColor);
                                widthPointsMain.Add(qpWidthSegmentWithDistance);
                            }
                            distanceAlongWidthBunderiesPoints = (Widthofrects + distanceAlongWidth) * (i + 1);
                        }

                        for (int i = 0; i < NumberOfRectsinHeigth; i++)
                        {
                            IPoint qpHeightSegment = GetQPHeightSegment(distanceAlongHeightBunderiesPoints + Heigthofrects);
                            if (qpHeightSegment == null)
                            {
                                return;
                            }
                            heigthPoints.Add(qpHeightSegment);

                            //AddGraphicToMap((IMap)GetActiveView, qpHeightSegment, rgbColor, rgbColor);

                            if (i != NumberOfRectsinHeigth - 1)
                            {
                                IPoint qpHeightSegmentWithDistance = GetQPHeightSegment(distanceAlongHeightBunderiesPoints + Heigthofrects + distanceAlongHeigth);
                                //AddGraphicToMap((IMap)GetActiveView, qpHeightSegmentWithDistance, rgbColor, rgbColor);
                                heigthPoints.Add(qpHeightSegmentWithDistance);
                            }
                            distanceAlongHeightBunderiesPoints = (Heigthofrects + distanceAlongHeigth) * (i + 1);
                        }

                        for (int j = 0; j < heigthPoints.Count; j++)
                        {
                            constructionPoint.ConstructParallel(widthSegment, esriSegmentExtension.esriExtendAtTo, heigthPoints[j], Widthofrects);
                            IPoint outPutPoint = constructionPoint as IPoint;

                            IPath newPath = (IPath) new ESRI.ArcGIS.Geometry.Path();
                            newPath.FromPoint = heigthPoints[j];
                            newPath.ToPoint   = outPutPoint;

                            if (!firstLine)
                            {
                                widthPoints.Add(heigthPoints[j]);
                            }
                            else
                            {
                                widthPointsMain.Add(heigthPoints[j]);
                            }

                            distanceAlongWidthBunderiesPoints = 0;

                            for (int i = 0; i < NumberOfRectsinWidth; i++)
                            {
                                IPoint qpWidthSegment = GetQPWidthNewSegment(newPath, distanceAlongWidthBunderiesPoints + Widthofrects);
                                if (qpWidthSegment == null)
                                {
                                    return;
                                }

                                if (!firstLine)
                                {
                                    widthPoints.Add(qpWidthSegment);
                                }
                                else
                                {
                                    widthPointsMain.Add(qpWidthSegment);
                                }

                                //AddGraphicToMap((IMap)GetActiveView, qpWidthSegment, rgbColor, rgbColor);

                                if (i != NumberOfRectsinWidth - 1)
                                {
                                    IPoint qpWidthSegmentWithDistance = GetQPWidthNewSegment(newPath, distanceAlongWidthBunderiesPoints + Widthofrects + distanceAlongWidth);
                                    //AddGraphicToMap((IMap)GetActiveView, qpWidthSegmentWithDistance, rgbColor, rgbColor);
                                    if (!firstLine)
                                    {
                                        widthPoints.Add(qpWidthSegmentWithDistance);
                                    }
                                    else
                                    {
                                        widthPointsMain.Add(qpWidthSegmentWithDistance);
                                    }
                                }

                                //widthPoints.Add(qpWidthSegment);
                                //widthPoints.Add(qpWidthSegmentWithDistance);
                                distanceAlongWidthBunderiesPoints = (Widthofrects + distanceAlongWidth) * (i + 1);
                            }

                            //IRgbColor rgbColor1 = GetColor(0, 255, 0);

                            if (widthPoints.Count > 0 && widthPointsMain.Count > 0)
                            {
                                //IFeatureClass rectsFeatureClass = getFeatureClass.GetFeatureClassFromShapefileOnDisk(shapefileLocation, out workspace);
                                if (rectsFeatureClass == null)
                                {
                                    return;
                                }

                                createRects.FeatureClass     = rectsFeatureClass;
                                createRects.SpatialReference = ((IGeoDataset)rectsFeatureClass).SpatialReference;
                                createRects.WidthPoints      = widthPoints;
                                createRects.WidthPointsMain  = widthPointsMain;
                                createRects.CreateFeatures();
                                widthPoints.Clear();
                                widthPointsMain.Clear();
                                //if(!ShapefileIsAdded()) AddShapefile(GetActiveView, shapefileLocation);
                            }
                            firstLine = !firstLine;

                            //AddGraphicToMap((IMap)GetActiveView, outPutPoint, rgbColor1, rgbColor1);
                        }

                        labelStatus.Text = "It's done.";

                        WorkspaceEdit.StopEditOperation();
                        WorkspaceEdit.StopEditing(true);

                        GetActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                        GetActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                    }
                }
            }
            catch (Exception ex)
            {
                Path = null;
                graphicsContainer.DeleteAllElements();
                labelStatus.Text = ex.Message;
                if (WorkspaceEdit != null)
                {
                    if (WorkspaceEdit.IsBeingEdited())
                    {
                        WorkspaceEdit.AbortEditOperation();
                        WorkspaceEdit.StopEditing(false);
                    }
                }
                GetActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            }
        }