Exemple #1
0
        public override void OnMouseDown(int int_0, int int_1, int int_2, int int_3)
        {
            IPoint point = Utils3D.XYToPoint(this._plugin.SceneGraph, int_2, int_3);

            if (point != null)
            {
                point.Z = this.isurface_0.GetElevation(point);
                FlyByUtils.AddFlyByGraphic(this._plugin.SceneGraph, point, FlyByUtils.FlyByElementType.FLYBY_ANCHORS, System.Drawing.Color.Red, System.Drawing.Color.Red, System.Drawing.Color.Red, System.Drawing.Color.Red, false);
                Utils3D.FlashLocation3D(this._plugin.SceneGraph, point);
                if (this.ipointCollection_0 == null)
                {
                    this.ipointCollection_0 = new Polyline();
                }
                object value = Missing.Value;
                this.ipointCollection_0.AddPoint(point, ref value, ref value);
                if (this.ipointCollection_0.PointCount > 1)
                {
                    IPolyline polyline = (this.ipointCollection_0 as IClone).Clone() as IPolyline;
                    Utils3D.MakeZMAware(polyline, true);
                    double maxSegmentLength = polyline.Length / 50.0;
                    if (this.ipointCollection_0.PointCount > 2)
                    {
                        polyline.Smooth(0.0);
                        polyline.Densify(maxSegmentLength, 0.0);
                    }
                    FlyByUtils.AddFlyByGraphic(this._plugin.SceneGraph, polyline, FlyByUtils.FlyByElementType.FLYBY_PATH, System.Drawing.Color.Red, System.Drawing.Color.Red, System.Drawing.Color.Red, System.Drawing.Color.Red, true);
                }
            }
        }
Exemple #2
0
        public static IGeometry GetExample9()
        {
            const int    DensificationDivisions = 20;
            const double MaxDeviation           = 0.1;
            const double BaseZ   = 0;
            const double OffsetZ = -7;

            //Extrusion: 3D Polyline Having Vertices With Varying Z Values, Extruded Relative To Existing
            //           Vertex Z Values Via ConstructExtrude()

            IPointCollection polylinePointCollection = new PolylineClass();

            polylinePointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-10, -10), ref _missing, ref _missing);
            polylinePointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(0, -5), ref _missing, ref _missing);
            polylinePointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(0, 5), ref _missing, ref _missing);
            polylinePointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(10, 10), ref _missing, ref _missing);

            IPolyline polyline = polylinePointCollection as IPolyline;

            polyline.Densify(polyline.Length / DensificationDivisions, MaxDeviation);

            IGeometry polylineGeometry = polyline as IGeometry;

            GeometryUtilities.MakeZAware(polylineGeometry);

            Random random = new Random();

            for (int i = 0; i < polylinePointCollection.PointCount; i++)
            {
                IPoint polylinePoint = polylinePointCollection.get_Point(i);

                polylinePointCollection.UpdatePoint(i, GeometryUtilities.ConstructPoint3D(polylinePoint.X, polylinePoint.Y, BaseZ - 2 * Math.Sin(random.NextDouble())));
            }

            ITopologicalOperator topologicalOperator = polylineGeometry as ITopologicalOperator;

            topologicalOperator.Simplify();

            IConstructMultiPatch constructMultiPatch = new MultiPatchClass();

            constructMultiPatch.ConstructExtrude(OffsetZ, polylineGeometry);

            return(constructMultiPatch as IGeometry);
        }
Exemple #3
0
        /// <summary>
        /// Create a geojson string from the geometry
        /// </summary>
        /// <param name="geometry"></param>
        /// <returns></returns>
        public static GeoJSONGeometry CreateFromIGeometry(IGeometry geometry)
        {
            GeoJSONGeometry jsonGeom = new GeoJSONGeometry();

            jsonGeom.Type = geometry.GeometryType.ToString();
            StringBuilder sb = new StringBuilder();

            if (geometry.GeometryType != esriGeometryType.esriGeometryPoint)
            {
                sb.Append("[");
            }
            //Need to work out how to easily rip the coords out of the IGeometry

            switch (geometry.GeometryType)
            {
            case esriGeometryType.esriGeometryPoint:
                IPoint pt = (IPoint)geometry;
                sb.Append(string.Format("[{0}, {1}]", Math.Round(pt.X, 5), Math.Round(pt.Y, 5)));
                jsonGeom.Type = "Point";
                break;

            case esriGeometryType.esriGeometryLine:
                IPolyline line = geometry as IPolyline;
                if (line == null)
                {
                    return(null);
                }

                line.Densify(-1, -1);   //make sure it's all straight line segments
                line.Weed(20);          //weed out some vertices
                line.SimplifyNetwork(); //make sure it is simple


                IPointCollection points = line as IPointCollection;
                for (int i = 0; i < points.PointCount; i++)
                {
                    IPoint point = points.get_Point(i);
                    if (sb.Length > 1)
                    {
                        sb.Append(",");
                    }
                    sb.Append(string.Format("[{0}, {1}]", Math.Round(point.X, 4), Math.Round(point.Y, 4)));
                }

                jsonGeom.Type = "LineString";
                break;

            case esriGeometryType.esriGeometryPolygon:
                IPolygon4 poly = geometry as IPolygon4;
                if (poly == null)
                {
                    return(null);
                }

                poly.Densify(-1, -1);          //make sure it is all straight line segments
                poly.Weed(20);                 //weed out some vertices
                poly.SimplifyPreserveFromTo(); //make sure it's simple

                //We aren't gonna deal with interior rings right now (ie - no holes in polygons)
                IGeometryBag  multiRing         = poly.ExteriorRingBag;
                IEnumGeometry exteriorRingsEnum = multiRing as IEnumGeometry;
                exteriorRingsEnum.Reset();
                IRing currentExteriorRing = exteriorRingsEnum.Next() as IRing;
                while (currentExteriorRing != null)
                {
                    if (!currentExteriorRing.IsClosed)
                    {
                        currentExteriorRing.Close();
                    }

                    IPointCollection multiRingPoints = currentExteriorRing as IPointCollection;
                    for (int pointIdx = 0; pointIdx < multiRingPoints.PointCount; pointIdx++)
                    {
                        IPoint multiRingPoint = multiRingPoints.get_Point(pointIdx);
                        //coords.Add(new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(Math.Round(multiRingPoint.X, 5), Math.Round(multiRingPoint.Y, 5)));
                        if (sb.Length > 1)
                        {
                            sb.Append(",");
                        }
                        sb.Append(string.Format("[{0}, {1}]", Math.Round(multiRingPoint.X, 4), Math.Round(multiRingPoint.Y, 4)));
                    }

                    currentExteriorRing = exteriorRingsEnum.Next() as IRing;
                }
                jsonGeom.Type = "Polygon";
                break;
            }


            if (geometry.GeometryType != esriGeometryType.esriGeometryPoint)
            {
                sb.Append("]");
            }
            jsonGeom.coordinates = sb.ToString();
            return(jsonGeom);
        }