예제 #1
0
        protected override Geometry GetGeometry(string valueString)
        {
            Geometry geometry = null;

            try
            {
                switch (Geometry.GetGeometryType(valueString))
                {
                case egtype.point:
                    geometry = Point.Parse(valueString);
                    break;

                case egtype.multipoint:
                    geometry = Multipoint.Parse(valueString, ' ', ',');
                    break;

                case egtype.linestring:
                    geometry = LineString.Parse(valueString, ' ', ',');
                    break;

                case egtype.polygon:
                    geometry = Polygon.Parse(valueString, ' ', ',');
                    break;

                case egtype.none:
                default:
                    break;
                }
            }
            catch (GeometryException ex)
            {
                LogManager.Instance.Error(ex);
            }
            return(geometry);
        }
예제 #2
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            JObject        jsonObject = JObject.Load(reader);
            EsriJsonObject geometry   = default(EsriJsonObject);

            IEnumerable <String> keys = GetKeys(jsonObject);

            if (keys.Contains("points"))
            {
                geometry = new Multipoint();
            }
            else if (keys.Contains("rings"))
            {
                geometry = new Polygon();
            }
            else if (keys.Contains("paths"))
            {
                geometry = new Polyline();
            }
            else if (keys.Contains("x") && keys.Contains("y"))
            {
                geometry = new Point();
            }
            //else
            //{
            //    throw new NotSupportedException("Conversion of this type is not supported");
            //}

            serializer.Populate(jsonObject.CreateReader(), geometry);

            return(geometry);
        }
예제 #3
0
        /// <summary>
        /// Force the sketch to complete after we've clicked twice
        /// </summary>
        /// <returns></returns>
        protected override async Task <bool> OnSketchModifiedAsync()
        {
            bool finish = await QueuedTask.Run(async() =>
            {
                // get the current sketch
                var sketchGeometry = await this.GetCurrentSketchAsync();
                // cast to multiPoint (our sketchType)
                Multipoint goo = sketchGeometry as Multipoint;
                // check the point count... if we have two points, return true
                if (goo.PointCount >= 2)
                {
                    return(true);
                }

                return(false);
            });

            // call FinishSketchAsync if we have 2 points
            if (finish)
            {
                finish = await base.FinishSketchAsync();
            }

            return(finish);
        }
예제 #4
0
        public void CanDetermineEqualMultipointXyChangedOrderWithDuplicates()
        {
            Multipoint <IPnt> mp1 = new Multipoint <IPnt>(
                new[]
            {
                new Pnt3D(1234.5678, 9876.54321, 345.6),
                new Pnt3D(234.5678, 987.54321, 355.6),
                new Pnt3D(34.5678, 98.54321, 365.6),
                new Pnt3D(4.5678, 9.54321, 375.6)
            });

            Multipoint <IPnt> mp2 = new Multipoint <IPnt>(mp1.GetPoints(0, null, true).Reverse());

            mp2.AddPoint(new Pnt3D(34.5678, 98.54321, 365.6));

            Assert.IsTrue(GeomRelationUtils.AreMultipointsEqualXY(mp1, mp2, 0.00001));

            mp2 = new Multipoint <IPnt>(mp2.GetPoints(0, null, true).Reverse());

            Assert.IsTrue(GeomRelationUtils.AreMultipointsEqualXY(mp1, mp2, 0.00001));

            mp2.AddPoint(new Pnt3D(34.4678, 98.64321, 365.6));

            Assert.IsFalse(GeomRelationUtils.AreMultipointsEqualXY(mp1, mp2, 0.00001));
            Assert.IsTrue(GeomRelationUtils.AreBoundsEqual(mp1, mp2, 0.000001));
        }
예제 #5
0
        private Graphic GraphicFromAttributes(List <XElement> graphicAttributes)
        {
            // Get the geometry and the spatial reference from the message elements.
            XElement geometryAttribute    = graphicAttributes.First(attr => attr.Name == "_control_points");
            XElement spatialReferenceAttr = graphicAttributes.First(attr => attr.Name == "_wkid");

            // Split the geometry field into a list of points.
            Array pointStrings = geometryAttribute.Value.Split(';');

            // Create a point collection in the correct spatial reference.
            int wkid = Convert.ToInt32(spatialReferenceAttr.Value);
            SpatialReference pointSR       = SpatialReference.Create(wkid);
            PointCollection  graphicPoints = new PointCollection(pointSR);

            // Add a point for each point in the list.
            foreach (string pointString in pointStrings)
            {
                var coords = pointString.Split(',');
                graphicPoints.Add(Convert.ToDouble(coords[0]), Convert.ToDouble(coords[1]));
            }

            // Create a multipoint from the point collection.
            Multipoint graphicMultipoint = new Multipoint(graphicPoints);

            // Create the graphic from the multipoint.
            Graphic messageGraphic = new Graphic(graphicMultipoint);

            // Add all of the message's attributes to the graphic (some of these are used for rendering).
            foreach (XElement attr in graphicAttributes)
            {
                messageGraphic.Attributes[attr.Name.ToString()] = attr.Value;
            }

            return(messageGraphic);
        }
예제 #6
0
        private void UpdateSdo(long g3efid, System.Drawing.Point ScreenPt)
        {
            var WorldPt = dddMap.screen2geo(ScreenPt.X, ScreenPt.Y);
            var shbsdo  =
                DBManager.Instance.GetEntities <Gg_jx_jlb_pt_sdogeom>(
                    o => o.G3E_FID == g3efid && o.EntityState != EntityState.Delete).FirstOrDefault();
            var mpValue = new Multipoint();

            mpValue.Points.Add(new ElectronTransferModel.Geo.Point(new[] { WorldPt[1], WorldPt[0], 0 }));
            mpValue.Points.Add(new ElectronTransferModel.Geo.Point(new[] { Math.Cos(0.0), Math.Sin(0.0), 0 }));
            if (shbsdo != null)
            {
                shbsdo.G3E_GEOMETRY = mpValue;
                if (shbsdo.EntityState != EntityState.Insert)
                {
                    shbsdo.EntityState = EntityState.Update;
                }
                DBManager.Instance.Update(shbsdo);
                var pb = pbs.FirstOrDefault(o => o.JlbPBFid == g3efid);
                if (pb != null)
                {
                    pb.JlbPBPosition = new Point3d(WorldPt[1], WorldPt[0], 0);
                }
            }
        }
        //For "poly" type geometries, this function returns an array of the multipoint parts of a record.
        //This multipoint part array is used in the construction of the "poly" type geometry.
        private static Multipoint[] GetMultipointParts(byte[] recordContents)
        {
            //Get the number of parts and number of points and stored inside the PolyRecordFields struct.
            PolyRecordFields recordNums = new PolyRecordFields(recordContents);

            //Get all the points in the record.
            Point[] points = GetPolyPoints(recordNums.NumPoints, recordNums.NumParts, recordContents);

            //The points will be divided up into parts and assigned an index here.
            Multipoint[] multiparts = new Multipoint[recordNums.NumParts];

            //Get the index of each part.
            int[] partIndex = GetRecordPartOffsets(recordNums.NumParts, recordContents);

            //Loop through all the parts indicies and copy the points of that part to the multipart array.
            for (int n = 0; n < partIndex.Length; n++)
            {
                //Find the number of points between the current index and the next index.
                //If this is the last index then find the number of points between it and the length of the point array.
                int numPointsInPart = n < partIndex.Length - 1 ? partIndex[n + 1] - partIndex[n] : recordNums.NumPoints - partIndex[n];

                //Copy points to new point array sized for that part.
                Point[] partPoints = new Point[numPointsInPart];
                partPoints = points.Skip(partIndex[n]).Take(numPointsInPart).ToArray <Point>();

                //Create a new multipoint object from the new point array and store it at the current part index.
                multiparts[n] = new Multipoint(partPoints);
            }
            return(multiparts);
        }
예제 #8
0
        private void CreateBlockElements()
        {
            IGeometryCollection geometryCollection = new Multipoint() as IGeometryCollection;

            for (int i = 0; i < this._networkInfo.arrayList_0.Count; i++)
            {
                object   missing = Type.Missing;
                IFeature feature = (IFeature)this._networkInfo.arrayList_0[i];
                geometryCollection.AddGeometry(feature.ShapeCopy, ref missing, ref missing);
            }
            if (this._networkInfo.arrayList_0.Count > 0)
            {
                IGraphicsContainer graphicsContainer = (IGraphicsContainer)m_iApp.ActiveView;
                IMarkerSymbol      markerSymbol      = this.GetMarkerSymbol();
                markerSymbol.Size = (26.0);
                for (int j = 0; j < geometryCollection.GeometryCount; j++)
                {
                    IMarkerElement markerElement = new MarkerElement() as IMarkerElement;
                    IElement       element       = (IElement)markerElement;
                    element.Geometry     = (geometryCollection.get_Geometry(j));
                    markerElement.Symbol = (markerSymbol);
                    graphicsContainer.AddElement(element, 0);
                }
                m_iApp.ActiveView.PartialRefresh((esriViewDrawPhase)8, null, null);
            }
        }
예제 #9
0
        private void method_3(object sender, ValueChangedEventArgs e)
        {
            IPoint inPoint = RasterAdjustHelper.RasterAdjust.DestPointCollection.get_Point(e.Row);

            try
            {
                if (e.Column == 3)
                {
                    inPoint.X = Convert.ToDouble(e.NewValue);
                }
                else if (e.Column == 4)
                {
                    inPoint.Y = Convert.ToDouble(e.NewValue);
                }
            }
            catch
            {
                return;
            }
            object           before    = Missing.Value;
            IPointCollection newPoints = new Multipoint();

            newPoints.AddPoint(inPoint, ref before, ref before);
            RasterAdjustHelper.RasterAdjust.DestPointCollection.ReplacePointCollection(e.Row, 1, newPoints);
        }
예제 #10
0
        private IGeometry method_0(esriGeometryType esriGeometryType_0)
        {
            IGeometry pointClass = null;

            switch (esriGeometryType_0)
            {
            case esriGeometryType.esriGeometryPoint:
            {
                pointClass = new ESRI.ArcGIS.Geometry.Point();
                break;
            }

            case esriGeometryType.esriGeometryMultipoint:
            {
                pointClass = new Multipoint() as IGeometry;
                break;
            }

            case esriGeometryType.esriGeometryPolyline:
            {
                pointClass = new Polyline() as IGeometry;
                break;
            }

            case esriGeometryType.esriGeometryPolygon:
            {
                pointClass = new Polygon() as IGeometry;
                break;
            }
            }
            return(pointClass);
        }
예제 #11
0
        /// <summary>
        /// 创建标注
        /// </summary>
        /// <param name="ise"></param>
        /// <param name="multipoint"></param>
        /// <param name="className"></param>
        /// <param name="G3E_CNO"></param>
        /// <param name="G3E_FNO"></param>
        private static ElectronSymbol CreateLabel(InsertSymbolEventArgs ise, Multipoint multipoint, string className, int G3E_CNO, int G3E_FNO)
        {
            long?          g3e_cid = 1;
            ElectronSymbol pt      = null;

            try
            {
                var type = TypeCache.Instance.GetTypeFromCache(typeof(DBEntity), className);
                pt = ReflectionUtils.CreateObject(
                    new
                {
                    G3E_CID      = g3e_cid,
                    G3E_ID       = ise.g3e_id,
                    G3E_FID      = ise.g3e_fid,
                    G3E_FNO      = ise.g3e_fno,
                    G3E_CNO      = G3E_CNO,
                    G3E_GEOMETRY = multipoint,
                    LTT_ID       = Convert.ToDecimal(MapConfig.Instance.LTTID),
                    EntityState  = EntityState.Insert
                }, type) as ElectronSymbol;

                DBManager.Instance.Insert(pt);
                pt.EntityType       = EntityType.Label;
                pt.FinderFuncNumber = G3E_FNO;
                //新增标注LB表数据
                AddBortherDBEntity(className, pt, G3E_CNO);
            }
            catch (Exception ex)
            {
                LogManager.Instance.Error(ex);
            }
            return(pt);
        }
예제 #12
0
        public override bool DeCompose(out IArray iarray_0)
        {
            bool flag;

            iarray_0 = null;
            if (this.m_pGeometry.GeometryType != esriGeometryType.esriGeometryMultipoint)
            {
                flag = false;
            }
            else
            {
                object value = Missing.Value;
                iarray_0 = new Array();
                IPointCollection mPGeometry = this.m_pGeometry as IPointCollection;
                IPoint           point      = null;
                for (int i = 0; i < mPGeometry.PointCount; i++)
                {
                    point = mPGeometry.Point[i];
                    IPointCollection multipointClass = new Multipoint();
                    multipointClass.AddPoint(point, ref value, ref value);
                    iarray_0.Add(multipointClass);
                }
                flag = true;
            }
            return(flag);
        }
예제 #13
0
        public override IGeometry HorizontalMirror(IPoint ipoint_0)
        {
            IPoint    pointClass;
            IGeometry geometry;

            if (this.m_pGeometry.GeometryType != esriGeometryType.esriGeometryPoint)
            {
                object           value           = Missing.Value;
                IPointCollection mPGeometry      = this.m_pGeometry as IPointCollection;
                IPointCollection multipointClass = new Multipoint();
                for (int i = 0; i < mPGeometry.PointCount; i++)
                {
                    IPoint point = mPGeometry.Point[i];
                    pointClass = new ESRI.ArcGIS.Geometry.Point();
                    pointClass.PutCoords(2 * ipoint_0.X - pointClass.X, pointClass.Y);
                    multipointClass.AddPoint(pointClass, ref value, ref value);
                }
                geometry = multipointClass as IGeometry;
            }
            else
            {
                pointClass = new ESRI.ArcGIS.Geometry.Point();
                pointClass.PutCoords(2 * ipoint_0.X - (this.m_pGeometry as IPoint).X, (this.m_pGeometry as IPoint).Y);
                geometry = pointClass;
            }
            return(geometry);
        }
예제 #14
0
        private void btnFinish_Click(object sender, EventArgs e)
        {
            try
            {
                Multipoint pointList = _map.FinishDraw() as Multipoint;
                if (pointList != null)
                {
                    if (_lineInfo.PolylineId == 0)
                    {
                        object temp = _hmCon.SQLExecutor.ExecuteScalar("select max(PolylineId) from Geo_Polyline", _hmCon.TRConnection);
                        _lineInfo.PolylineId = (DBNull.Value.Equals(temp)) ? 1 : (int)temp + 1;

                        string sql = $"insert into Geo_Link(LinkTableName, LinkCode, Feature, LinkType, LinkId)" +
                                     $" values('{_layer.LinkTable}','{_lineInfo.KeyCode}', '{_layer.LayerName}', {(int)GeoType.Polyline}, {_lineInfo.PolylineId})";
                        _hmCon.SQLExecutor.ExecuteNonQuery(sql, _hmCon.TRConnection);
                    }

                    int lineId = _lineInfo.Polylines.Keys.Max(); // already added
                    foreach (MapPoint point in pointList.Points)
                    {
                        string sql = $"insert into Geo_Polyline(PolylineId, Latitude, Longitude, LineId) values({_lineInfo.PolylineId}, {point.Y}, {point.X}, {lineId})";
                        _hmCon.SQLExecutor.ExecuteNonQuery(sql, _hmCon.TRConnection);
                    }

                    cboPolyline.Properties.Items.Add(lineId);
                    cboPolyline.SelectedIndex = cboPolyline.Properties.Items.Count - 1;
                    InDrawingStatus(false);
                }
            }
            catch (Exception ex)
            {
                _pop.ShowPopup("Sql exception: " + ex.Message);
            }
        }
예제 #15
0
 public static Esri.ArcGISRuntime.Geometry.Geometry ChangeSpatailReference(
     Esri.ArcGISRuntime.Geometry.Geometry geom, SpatialReference sr)
 {
     if (geom.GeometryType == Esri.ArcGISRuntime.Geometry.GeometryType.Point)
     {
         MapPoint p = geom as MapPoint;
         return(ChangeSpatailReference(p, sr));
     }
     else if (geom.GeometryType == Esri.ArcGISRuntime.Geometry.GeometryType.Multipoint)
     {
         Multipoint             mp    = geom as Multipoint;
         IEnumerable <MapPoint> newMP = ChangeSpatialReference(mp.Points, sr);
         return(new Multipoint(newMP, sr));
     }
     else if (geom.GeometryType == Esri.ArcGISRuntime.Geometry.GeometryType.Polyline)
     {
         Esri.ArcGISRuntime.Geometry.Polyline pl = geom as Esri.ArcGISRuntime.Geometry.Polyline;
         PartCollection newPart = ChangeSpatialReference(pl.Parts, sr);
         return(new Esri.ArcGISRuntime.Geometry.Polyline(newPart, sr));
     }
     else if (geom.GeometryType == Esri.ArcGISRuntime.Geometry.GeometryType.Polygon)
     {
         Esri.ArcGISRuntime.Geometry.Polygon pg = geom as Esri.ArcGISRuntime.Geometry.Polygon;
         PartCollection newPart = ChangeSpatialReference(pg.Parts, sr);
         return(new Esri.ArcGISRuntime.Geometry.Polygon(newPart, sr));
     }
     else if (geom.GeometryType == Esri.ArcGISRuntime.Geometry.GeometryType.Envelope)
     {
         Envelope ev = geom as Envelope;
         return(new Envelope(ev.XMin, ev.YMin, ev.XMax, ev.YMax, sr));
     }
     return(null);
 }
예제 #16
0
 private void method_1(IDisplay idisplay_0)
 {
     if (CmdSelectTopology.m_TopologyGraph != null)
     {
         IEnumTopologyEdge edgeSelection = CmdSelectTopology.m_TopologyGraph.EdgeSelection;
         edgeSelection.Reset();
         ITopologyEdge topologyEdge = edgeSelection.Next();
         if (topologyEdge != null)
         {
             IPolyline polylineClass = new Polyline() as IPolyline;
             idisplay_0.SetSymbol((ISymbol)this.ilineSymbol_0);
             while (topologyEdge != null)
             {
                 idisplay_0.DrawPolyline(topologyEdge.Geometry);
                 topologyEdge = edgeSelection.Next();
             }
         }
         IEnumTopologyNode nodeSelection = CmdSelectTopology.m_TopologyGraph.NodeSelection;
         nodeSelection.Reset();
         ITopologyNode topologyNode = nodeSelection.Next();
         if (topologyNode != null)
         {
             IMultipoint multipointClass = new Multipoint() as IMultipoint;
             idisplay_0.SetSymbol((ISymbol)this.imarkerSymbol_0);
             while (topologyNode != null)
             {
                 idisplay_0.DrawPoint(topologyNode.Geometry);
                 topologyNode = nodeSelection.Next();
             }
         }
     }
 }
예제 #17
0
 private void method_3(IDisplay idisplay_0, esriViewDrawPhase esriViewDrawPhase_0)
 {
     if ((CmdSelectTopology.m_TopologyGraph == null ? false : this.Enabled))
     {
         IEnumTopologyEdge edgeSelection = CmdSelectTopology.m_TopologyGraph.EdgeSelection;
         edgeSelection.Reset();
         ITopologyEdge topologyEdge = edgeSelection.Next();
         object        value        = Missing.Value;
         if (topologyEdge != null)
         {
             IGeometryCollection polylineClass = new Polyline() as IGeometryCollection;
             while (topologyEdge != null)
             {
                 polylineClass.AddGeometryCollection((IGeometryCollection)topologyEdge.Geometry);
                 topologyEdge = edgeSelection.Next();
             }
             idisplay_0.SetSymbol((ISymbol)this.ilineSymbol_0);
             idisplay_0.DrawPolyline((IGeometry)polylineClass);
         }
         IEnumTopologyNode nodeSelection = CmdSelectTopology.m_TopologyGraph.NodeSelection;
         nodeSelection.Reset();
         ITopologyNode topologyNode = nodeSelection.Next();
         if (topologyNode != null)
         {
             IPointCollection multipointClass = new Multipoint();
             while (topologyNode != null)
             {
                 multipointClass.AddPoint((IPoint)topologyNode.Geometry, ref value, ref value);
                 topologyNode = nodeSelection.Next();
             }
             idisplay_0.SetSymbol((ISymbol)this.imarkerSymbol_0);
             idisplay_0.DrawMultipoint((IGeometry)multipointClass);
         }
     }
 }
예제 #18
0
 /// <summary>
 /// 更新户表的坐标
 /// </summary>
 /// <param name="g3efid">户表fid</param>
 /// <param name="WorldPt">户表地理坐标</param>
 private bool UpdateSdo(long g3efid, double[] WorldPt)
 {
     try
     {
         var shbsdo =
             DBManager.Instance.GetEntities <Gg_jx_jlb_pt_sdogeom>(
                 o => o.G3E_FID == g3efid && o.EntityState != EntityState.Delete).FirstOrDefault();
         var mpValue = new Multipoint();
         mpValue.Points.Add(new ElectronTransferModel.Geo.Point(new[] { WorldPt[1], WorldPt[0], 0 }));
         mpValue.Points.Add(new ElectronTransferModel.Geo.Point(new[] { Math.Cos(0.0), Math.Sin(0.0), 0 }));
         if (shbsdo == null)
         {
             return(false);
         }
         shbsdo.G3E_GEOMETRY = mpValue;
         if (shbsdo.EntityState != EntityState.Insert)
         {
             shbsdo.EntityState = EntityState.Update;
         }
         DBManager.Instance.Update(shbsdo);
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
예제 #19
0
 private static XElement ToKmlMultipoint(this Multipoint geometry, double?z, XElement[] extraElements)
 {
     return(new XElement(ns + "MultiGeometry",
                         geometry.points !.Select(p => new Point {
         x = p[0], y = p[1], z = p.Length > 2 ? p[2] : (double?)null
     }.ToKmlPoint(z, extraElements))));
 }
예제 #20
0
        public void CanReadWriteMultipointXy()
        {
            var points = new WKSPointZ[4];

            points[0] = new WKSPointZ {
                X = 2600000, Y = 1200000, Z = double.NaN
            };
            points[1] = new WKSPointZ {
                X = 2600030, Y = 1200020, Z = double.NaN
            };
            points[2] = new WKSPointZ {
                X = 2600020, Y = 1200030, Z = double.NaN
            };
            points[3] = new WKSPointZ {
                X = 2600040, Y = 1200040, Z = double.NaN
            };

            ISpatialReference sr =
                SpatialReferenceUtils.CreateSpatialReference(WellKnownHorizontalCS.LV95);

            IMultipoint multipoint = GeometryFactory.CreateMultipoint(points, sr);

            GeometryUtils.MakeNonZAware(multipoint);

            WkbGeometryWriter writer = new WkbGeometryWriter();

            byte[] wkb = writer.WriteMultipoint(multipoint);

            // ArcObjects
            byte[] arcObjectsWkb = GeometryUtils.ToWkb(multipoint);
            Assert.AreEqual(wkb, arcObjectsWkb);

            // Wkx
            byte[] wkx = ToChristianSchwarzWkb(ToWkxMultipoint(points, Ordinates.Xy));
            Assert.AreEqual(wkx, wkb);

            // Bonus test: Geom
            WkbGeomWriter     geomWriter = new WkbGeomWriter();
            Multipoint <IPnt> multipnt   = GeometryConversionUtils.CreateMultipoint(multipoint);

            byte[] wkbGeom = geomWriter.WriteMultipoint(multipnt, Ordinates.Xy);
            Assert.AreEqual(wkb, wkbGeom);

            WkbGeometryReader reader = new WkbGeometryReader();

            IMultipoint restored = reader.ReadMultipoint(new MemoryStream(wkb));

            Assert.IsTrue(GeometryUtils.AreEqual(multipoint, restored));

            // Geom
            WkbGeomReader geomReader = new WkbGeomReader();

            Multipoint <IPnt> deserializedPnts =
                geomReader.ReadMultiPoint(new MemoryStream(wkbGeom));

            Assert.IsTrue(
                GeomRelationUtils.AreMultipointsEqualXY(multipnt, deserializedPnts,
                                                        double.Epsilon));
        }
예제 #21
0
        /// <summary>
        /// Create a single multi-point feature that is comprised of 20 points.
        /// </summary>
        /// <param name="multiPointLayer">Multi-point geometry feature layer used to add the multi-point feature.</param>
        /// <returns></returns>
        private Task ConstructSampleMultiPoints(FeatureLayer multiPointLayer)
        {
            // create a random number generator
            var randomGenerator = new Random();

            // the database and geometry interactions are considered fine-grained and need to be executed on
            // a separate thread
            return(QueuedTask.Run(() =>
            {
                // get the feature class associated with the layer
                var featureClass = multiPointLayer.GetTable() as FeatureClass;
                var featureClassDefinition = featureClass.GetDefinition() as FeatureClassDefinition;

                // store the spatial reference as its own variable
                var spatialReference = featureClassDefinition.GetSpatialReference();

                // define an area of interest. Random points are generated in the allowed
                // confines of the allow extent range
                var areaOfInterest = MapView.Active.Extent;

                // start an edit operation to create new (random) multi-point feature
                var createOperation = new EditOperation()
                {
                    Name = "Generate multipoints"
                };

                // retrieve the class definition of the point feature class
                var classDefinition = featureClass.GetDefinition() as FeatureClassDefinition;

                Multipoint newPoints = null;
                // generate either 2D or 3D geometries
                if (classDefinition.HasZ())
                {
                    // 3D
                    // create a list to hold the 20 coordinates of the multi-point feature
                    IList <Coordinate3D> coordinateList = new List <Coordinate3D>(20);
                    for (int i = 0; i < 20; i++)
                    {
                        coordinateList.Add(randomGenerator.NextCoordinate3D(areaOfInterest));
                    }
                    newPoints = MultipointBuilder.CreateMultipoint(coordinateList, classDefinition.GetSpatialReference());
                }
                else
                {
                    // 2D
                    // create a list to hold the 20 coordinates of the multi-point feature
                    IList <Coordinate2D> coordinateList = new List <Coordinate2D>(20);
                    for (int i = 0; i < 20; i++)
                    {
                        coordinateList.Add(randomGenerator.NextCoordinate2D(areaOfInterest));
                    }
                    newPoints = MultipointBuilder.CreateMultipoint(coordinateList, classDefinition.GetSpatialReference());
                }
                // create and execute the feature creation operation
                createOperation.Create(multiPointLayer, newPoints);

                return createOperation.ExecuteAsync();
            }));
        }
예제 #22
0
        public Multipoint GetMultipoint(double x, double y, double rotation)
        {
            var mpValue = new Multipoint();

            mpValue.Points.Add(new Point(new[] { x, y, 0 }));
            mpValue.Points.Add(new Point(new[] { Math.Cos(rotation), Math.Sin(rotation), 0 }));
            return(mpValue);
        }
예제 #23
0
    public static double?Distance(this Polygon polygon, Multipoint multipoint)
    {
        if (Null(polygon, multipoint))
        {
            return(null);
        }

        return(multipoint.Distance(polygon));
    }
예제 #24
0
    public static bool WithinDistance(this Multipoint multipoint, Polygon polygon, double distance)
    {
        if (Null(multipoint, polygon))
        {
            return(false);
        }

        return(multipoint.Extent().Buffer(distance).Intersects(polygon.Extent()) && multipoint.Distance(polygon) < distance);
    }
예제 #25
0
    public static bool WithinDistance(this Multipoint multipoint, Point point, double distance)
    {
        if (Null(multipoint, point))
        {
            return(false);
        }

        return(point.Distance(multipoint) < distance);
    }
예제 #26
0
    public static bool WithinDistance(this Polygon polygon, Multipoint multipoint, double distance)
    {
        if (Null(polygon, multipoint))
        {
            return(false);
        }

        return(multipoint.Distance(polygon) < distance);
    }
예제 #27
0
    public static bool Within(this Multipoint multipoint, Polygon polygon)
    {
        if (Null(multipoint, polygon))
        {
            return(false);
        }

        return(polygon.Contains(multipoint));
    }
예제 #28
0
    public static bool WithinDistance(this Multipoint multipoint1, Multipoint multipoint2, double distance)
    {
        if (Null(multipoint1, multipoint2))
        {
            return(false);
        }

        return(multipoint1.Extent().Buffer(distance).Intersects(multipoint2.Extent()) && multipoint1.Distance(multipoint2) < distance);
    }
예제 #29
0
    public static bool Contains(this Polygon polygon, Multipoint multipoint)
    {
        if (Null(polygon, multipoint, multipoint.points))
        {
            return(false);
        }

        return(polygon.Contains(multipoint.points !));
    }
예제 #30
0
    public static bool WithinDistance(this Point point, Multipoint multipoint, double distance)
    {
        if (Null(point, multipoint))
        {
            return(false);
        }

        return(point.Extent().Buffer(distance).Intersects(multipoint.Extent()) && point.Distance(multipoint) < distance);
    }