コード例 #1
0
        private void UpdateFlash(System.Windows.Point?point)
        {
            var flashVM = OverlayEmbeddableControl as FlashEmbeddedControlViewModel;

            if (flashVM != null)
            {
                flashVM.ClientPoint = point.Value;
            }

            var temp = QueuedTask.Run(() =>
            {
                if (flashVM != null && MapView.Active != null)
                {
                    flashVM.ScreenPoint = MapView.Active.ClientToScreen(point.Value);
                    var p1            = MapView.Active.MapToScreen(MapPointBuilder.CreateMapPoint(MapView.Active.Extent.XMin, MapView.Active.Extent.YMin));
                    var p3            = MapView.Active.MapToScreen(MapPointBuilder.CreateMapPoint(MapView.Active.Extent.XMax, MapView.Active.Extent.YMax));
                    var width         = (p3.X - p1.X) + 1;
                    var height        = (p1.Y - p3.Y) + 1;
                    flashVM.MapWidth  = width;
                    flashVM.MapHeight = height;
                    flashVM.RunFlashAnimation();
                }
                return(true);
            }).Result;
        }
コード例 #2
0
        public async Task <MapPoint> AddHeightToMapPointAsync(MapPoint srcPoint)
        {
            return(await QueuedTask.Run(async() =>
            {
                MapView mapView = MapView.Active;
                Map map = mapView.Map;
                SpatialReference srcSpatialReference = map.SpatialReference;
                SpatialReference dstSpatialReference = await CoordSystemUtils.CycloramaSpatialReferenceAsync();

                ProjectionTransformation dstProjection = ProjectionTransformation.Create(srcSpatialReference,
                                                                                         dstSpatialReference);
                MapPoint dstPoint = GeometryEngine.Instance.ProjectEx(srcPoint, dstProjection) as MapPoint;

                if (dstPoint != null)
                {
                    double?height = await _cycloMediaGroupLayer.GetHeightAsync(dstPoint.X, dstPoint.Y);

                    if (height != null)
                    {
                        dstPoint = MapPointBuilder.CreateMapPoint(dstPoint.X, dstPoint.Y, ((double)height), dstSpatialReference);
                        ProjectionTransformation srcProjection = ProjectionTransformation.Create(dstSpatialReference,
                                                                                                 srcSpatialReference);
                        srcPoint = GeometryEngine.Instance.ProjectEx(dstPoint, srcProjection) as MapPoint;
                    }
                }

                return srcPoint;
            }));
        }
コード例 #3
0
        private Task <bool> CreateLocations(FeatureLayer pointFeatureLayer, IReadOnlyList <Location> locations)
        {
            return(QueuedTask.Run(() =>
            {
                var createOperation = new EditOperation()
                {
                    Name = "Generate points",
                    SelectNewFeatures = false
                };

                foreach (var location in locations)
                {
                    var firstfeature = location.Feature;
                    var jfeature = firstfeature as JObject;
                    var token = jfeature.GetValue("type").ToString();

                    if (token == "Point")
                    {
                        var p = jfeature.ToObject <GeoJSON.Net.Geometry.Point>();
                        var mapView = MapView.Active;

                        var newMapPoint = MapPointBuilder.CreateMapPoint(p.Coordinates.Longitude, p.Coordinates.Latitude, SpatialReferences.WGS84);
                        var atts = new Dictionary <string, object>();
                        atts.Add("id", location.Id);
                        atts.Add("Shape", newMapPoint);
                        atts.Add("description", location.Description);
                        createOperation.Create(pointFeatureLayer, atts);
                    }
                }
                return createOperation.ExecuteAsync();
            }));
        }
コード例 #4
0
        protected void UpdateAttrib()
        {
            QueuedTask.Run(() =>
            {
                //get the geometry of the selected feature.
                var selectedFeatures = MapView.Active.Map.GetSelection();
                var insp             = new Inspector();
                insp.Load(selectedFeatures.Keys.First(), selectedFeatures.Values.First());
                var selGeom = insp.Shape;

                //var extPolyline = some geometry operation.
                var extPolyline = new MapPointBuilder(1.0, 1.0).ToGeometry();

                //set the new geometry back on the feature
                insp.Shape = extPolyline;

                //update an attribute value
                insp["RouteNumber"] = 42;

                //create and execute the edit operation
                var op = new EditOperation()
                {
                    Name = "Extend"
                };
                op.Modify(insp);
                op.Execute();
            });
        }
        private static async Task <MapPoint> CreatePointAlongArc(MapPoint startPt, MapPoint endPt, MapPoint centerPt, double angle, double radius, SpatialReference spatRef, bool arcIsMinor, bool arcIsCounterClockwise)
        {
            System.Windows.Media.Media3D.Vector3D start = new System.Windows.Media.Media3D.Vector3D(startPt.X - centerPt.X, startPt.Y - centerPt.Y, startPt.Z - centerPt.Z);
            System.Windows.Media.Media3D.Vector3D end   = new System.Windows.Media.Media3D.Vector3D(endPt.X - centerPt.X, endPt.Y - centerPt.Y, endPt.Z - centerPt.Z);

            System.Windows.Media.Media3D.Vector3D normalOfPlane = new System.Windows.Media.Media3D.Vector3D();
            normalOfPlane = System.Windows.Media.Media3D.Vector3D.CrossProduct(start, end);

            //Two ortho vectors: orthoVec and start
            System.Windows.Media.Media3D.Vector3D orthoVec = new System.Windows.Media.Media3D.Vector3D();
            orthoVec = System.Windows.Media.Media3D.Vector3D.CrossProduct(normalOfPlane, start);

            //If this is not done then half of the keyframes for S-shaped curve are not on the curve
            if (arcIsMinor && !arcIsCounterClockwise)
            {
                orthoVec.Negate();
            }

            //Normalize
            start.Normalize();
            orthoVec.Normalize();

            System.Windows.Media.Media3D.Vector3D ptAlong = new System.Windows.Media.Media3D.Vector3D();
            ptAlong = radius * Math.Cos(angle) * start + radius * Math.Sin(angle) * orthoVec;

            MapPoint intermediateKeyframePoint = await QueuedTask.Run(() => MapPointBuilder.CreateMapPoint(ptAlong.X + centerPt.X, ptAlong.Y + centerPt.Y, ptAlong.Z + centerPt.Z, spatRef));

            return(intermediateKeyframePoint);
        }
        private void Watcher_PositionChanged(object sender, GeoPositionChangedEventArgs <GeoCoordinate> e)
        {
            GeoCoordinate coord   = e.Position.Location;
            var           mapView = MapView.Active;

            if (mapView == null)
            {
                return;
            }
            if (coord.IsUnknown != true)
            {
                System.Diagnostics.Debug.WriteLine("Lat: {0}, Long: {1}",
                                                   coord.Latitude,
                                                   coord.Longitude);
                ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
                {
                    MapPoint zoomToPnt = MapPointBuilder.CreateMapPoint(coord.Longitude, coord.Latitude, SpatialReferences.WGS84);
                    var geoProject     = GeometryEngine.Instance.Project(zoomToPnt, SpatialReferences.WebMercator) as MapPoint;
                    var expandSize     = 200.0;
                    var minPoint       = MapPointBuilder.CreateMapPoint(geoProject.X - expandSize, geoProject.Y - expandSize, SpatialReferences.WebMercator);
                    var maxPoint       = MapPointBuilder.CreateMapPoint(geoProject.X + expandSize, geoProject.Y + expandSize, SpatialReferences.WebMercator);
                    Envelope env       = EnvelopeBuilder.CreateEnvelope(minPoint, maxPoint);
                    mapView.ZoomTo(env, new TimeSpan(0, 0, 3));
                    _graphic = MapView.Active.AddOverlay(zoomToPnt, _pointSymbol.MakeSymbolReference());
                });
            }
            else
            {
                MessageBox.Show("Unknown latitude and longitude.  Check your control panel for Location Privacy settings.");
            }
        }
コード例 #7
0
        /// <summary>
        /// Create a CIMPointGaphic which can be added to the MapView overlay.
        /// </summary>
        /// <param name="point">The location for the point (as a CIM point)</param>
        /// <returns></returns>
        public CIMPointGraphic MakeCIMPointGraphic(PointN point)
        {
            CIMMarker marker = SymbolFactory.Instance.ConstructMarker(Red, 10, SimpleMarkerStyle.Star);

            CIMSymbolLayer[] layers = new CIMSymbolLayer[1];
            layers[0] = marker;

            CIMPointSymbol pointSymbol = new CIMPointSymbol()
            {
                SymbolLayers = layers,
                ScaleX       = 1
            };
            CIMSymbolReference symbolRef = new CIMSymbolReference()
            {
                Symbol = pointSymbol
            };
            CIMPointGraphic pointGraphic = new CIMPointGraphic();

            ArcGIS.Core.Geometry.SpatialReference spatialRef = SpatialReferenceBuilder.CreateSpatialReference(point.SpatialReference.WKID);
            MapPoint mapPoint = MapPointBuilder.CreateMapPoint(point.X, point.Y, spatialRef);

            pointGraphic.Location = mapPoint;
            pointGraphic.Symbol   = symbolRef;

            return(pointGraphic);
        }
        private static Geometry GetGeometryFromBuffer(byte[] geomBuffer, SpatialReference sr)
        {
            var geomType = GetGeometryType(geomBuffer);

            switch (geomType)
            {
            case GeometryType.Point:
            {
                int    offset = 4;
                double x      = DoubleWithNaN(BitConverter.ToDouble(geomBuffer, offset));
                offset += 8;
                double y = DoubleWithNaN(BitConverter.ToDouble(geomBuffer, offset));

                var mp = MapPointBuilder.FromEsriShape(geomBuffer, sr);
                //System.Diagnostics.Debug.WriteLine($@"x: {x} = {mp.X} y: {y} = {mp.Y}");
                return(mp);
            }

            case GeometryType.Polyline:
            {
                var line = PolylineBuilder.FromEsriShape(geomBuffer, sr);
                return(line);
            }

            case GeometryType.Polygon:
            {
                var poly = PolygonBuilder.FromEsriShape(geomBuffer, sr);
                return(poly);
            }
            }
            return(null);
        }
コード例 #9
0
        public static ArcGIS.Core.Geometry.Geometry ToScreenGeometry(
            MapView mapView, Polygon mapGeometry)
        {
            // TODO: ensure single-part, linear segments

            var screenPoints = new List <Coordinate2D>();

            if (mapGeometry.Extent.Width > 0 || mapGeometry.Extent.Height > 0)
            {
                foreach (var mapPoint in mapGeometry.Points)
                {
                    var screenVertex = mapView.MapToScreen(mapPoint);

                    screenPoints.Add(new Coordinate2D(screenVertex.X, screenVertex.Y));
                }

                return(PolygonBuilder.CreatePolygon(screenPoints, mapView.Camera.SpatialReference));
            }

            // The screen is probably the entire screen
            var screenPoint = mapView.MapToScreen(mapGeometry.Extent.Center);

            // The client is probably the relevant map canvas, these coords seem to correspond
            // with the tool's mouse coordinates in SketchOutputMode.Screen!?!
            var clientPoint = mapView.ScreenToClient(screenPoint);

            return(MapPointBuilder.CreateMapPoint(new Coordinate2D(clientPoint.X, clientPoint.Y)));
        }
コード例 #10
0
        /// <summary>
        /// Get the current row, convert the data to a plugin row
        /// Project the data in the right projection.
        /// </summary>
        /// <returns></returns>
        public override PluginRow GetCurrentRow()
        {
            if (StationMeasurements != null && StationMeasurements.Current != null)
            {
                // Create a point
                MapPointBuilder location = new MapPointBuilder(StationMeasurements.Current.Lon, StationMeasurements.Current.Lat, new SpatialReferenceBuilder(4326).ToSpatialReference());

                // Convert point to rd point.
                Geometry locationRD = GeometryEngine.Instance.Project(location.ToGeometry(), SpatialReferenceBuilder.CreateSpatialReference(28992));

                // Convert attribute data
                var listOfRowValues = new List <object>();
                listOfRowValues.Add(StationMeasurements.Current.Stationid);
                listOfRowValues.Add(StationMeasurements.Current.Stationname);
                listOfRowValues.Add(StationMeasurements.Current.Temperature);
                listOfRowValues.Add(StationMeasurements.Current.Timestamp);
                listOfRowValues.Add(StationMeasurements.Current.Weatherdescription);
                listOfRowValues.Add(StationMeasurements.Current.Iconurl);
                listOfRowValues.Add(StationMeasurements.Current.Humidity);
                listOfRowValues.Add(StationMeasurements.Current.Sunpower);
                listOfRowValues.Add(StationMeasurements.Current.Airpressure);
                listOfRowValues.Add(StationMeasurements.Current.Visibility);

                // Add the geometry
                listOfRowValues.Add(locationRD);

                return(new PluginRow(listOfRowValues));
            }

            return(new PluginRow());
        }
コード例 #11
0
        public async Task <bool> ApplyResults(MapView mapView, SearchResults results, IPointSymbology symbology, CancellationToken ctsToken)
        {
            Clear();

            if (ctsToken.IsCancellationRequested)
            {
                return(false);
            }

            await QueuedTask.Run(() =>
            {
                InitSymbology(symbology);
                var spatialRef = SpatialReferences.WGS84; // TODO: this should be coming from response
                foreach (var point in results.GetValuePoints(ValueName))
                {
                    if (ctsToken.IsCancellationRequested)
                    {
                        return;
                    }

                    var location = MapPointBuilder.CreateMapPoint(point.Longitude, point.Latitude, spatialRef);
                    var overlay  = mapView.AddOverlay(location, _symbolRef);
                    _elements.Add(new Element()
                    {
                        Value = point, Location = location, Overlay = overlay, Hitbox = CreateHitBox(mapView, location, symbology.Size / 2, spatialRef)
                    });
                }
            });

            return(_elements.Count > 0);
        }
コード例 #12
0
ファイル: ProCoreTest.cs プロジェクト: sungaoyong/ProSuite
        public void CanMapPointBuilderStatic()
        {
            MapPoint pt1 = MapPointBuilder.CreateMapPoint(1.0, 2.0);

            Assert.False(pt1.HasZ);
            Assert.False(pt1.HasM);
            Assert.False(pt1.HasID);
            Assert.False(pt1.IsEmpty);

            MapPoint pt2 = MapPointBuilder.CreateMapPoint(1.0, 2.0, 3.0);

            Assert.True(pt2.HasZ);
            Assert.False(pt2.HasM);
            Assert.False(pt2.HasID);
            Assert.False(pt2.IsEmpty);

            MapPoint pt3 = MapPointBuilder.CreateMapPoint(1.0, 2.0, 3.0, 4.0);

            Assert.True(pt3.HasZ);
            Assert.True(pt3.HasM);
            Assert.False(pt3.HasID);
            Assert.False(pt3.IsEmpty);

            MapPoint pt3Copy = MapPointBuilder.CreateMapPoint(pt3);

            Assert.True(pt3Copy.IsEqual(pt3));
            Assert.False(ReferenceEquals(pt3, pt3Copy));             // Note: since geoms are immutable, returning *same* would be ok, but here test for behavior
        }
コード例 #13
0
        private void SetThumbnail(Mosaic item)
        {
            TilePointConvert tilePointConvert = new TilePointConvert();
            var      extent = MapView.Active.Extent;
            int      z      = 7;
            MapPoint sw     = MapPointBuilder.CreateMapPoint(extent.XMin, extent.YMin, extent.SpatialReference);

            sw = GeometryEngine.Instance.Project(sw, SpatialReferences.WGS84) as MapPoint;
            MapPoint ne = MapPointBuilder.CreateMapPoint(extent.XMax, extent.YMax, SpatialReferences.WGS84);

            ne = GeometryEngine.Instance.Project(ne, SpatialReferences.WGS84) as MapPoint;
            IList <MapPoint> mapPoints = new List <MapPoint>();

            mapPoints.Add(sw);
            mapPoints.Add(ne);
            double zz = TilePointConvert.BestMapView(mapPoints, 100, 56, 2);

            z = (int)Math.Floor(zz);
            if (z < 0)
            {
                z = z * -1;
            }
            var    centerProjected = GeometryEngine.Instance.Project(extent.Center, SpatialReferences.WGS84) as MapPoint;
            double centerlong      = centerProjected.X;
            double centerlat       = centerProjected.Y;
            PointF point           = tilePointConvert.WorldToTilePos(centerlong, centerlat, z);

            item.Thumbnail = item._links.tiles.Replace("{x}", Math.Floor(point.X).ToString()).Replace("{y}", Math.Floor(point.Y).ToString()).Replace("{z}", z.ToString());
        }
コード例 #14
0
        protected async Task InitializeAsync(RecordingLocation location, double angle, double hFov, Color color)
        {
            _angle         = angle;
            _hFov          = hFov;
            Color          = color;
            _isInitialized = true;

            double             x        = location.X;
            double             y        = location.Y;
            Settings           settings = Settings.Instance;
            MySpatialReference spatRel  = settings.CycloramaViewerCoordinateSystem;

            await QueuedTask.Run(() =>
            {
                Map map = MapView.Active?.Map;
                SpatialReference mapSpatialReference = map?.SpatialReference;
                SpatialReference spatialReference    = spatRel?.ArcGisSpatialReference ?? mapSpatialReference;
                MapPoint point = MapPointBuilder.CreateMapPoint(x, y, spatialReference);

                if ((mapSpatialReference != null) && (spatialReference.Wkid != mapSpatialReference.Wkid))
                {
                    ProjectionTransformation projection = ProjectionTransformation.Create(spatialReference, mapSpatialReference);
                    _mapPoint = GeometryEngine.Instance.ProjectEx(point, projection) as MapPoint;
                }
                else
                {
                    _mapPoint = (MapPoint)point.Clone();
                }
            });

            MapViewCameraChangedEvent.Subscribe(OnMapViewCameraChanged);
            await RedrawConeAsync();
        }
コード例 #15
0
        public static async Task <MapPoint> CycloramaToMapPointAsync(double x, double y, double z)
        {
            MapView          mapView             = MapView.Active;
            Map              map                 = mapView?.Map;
            SpatialReference mapSpatialReference = map?.SpatialReference;
            SpatialReference gsSpatialReference  = await CycloramaSpatialReferenceAsync();

            MapPoint point = null;

            await QueuedTask.Run(() =>
            {
                MapPoint mapPoint = MapPointBuilder.CreateMapPoint(x, y, z, gsSpatialReference);

                if ((mapSpatialReference != null) && (gsSpatialReference != null) &&
                    (gsSpatialReference.Wkid != mapSpatialReference.Wkid))
                {
                    ProjectionTransformation projection = ProjectionTransformation.Create(gsSpatialReference, mapSpatialReference);
                    point = GeometryEngine.Instance.ProjectEx(mapPoint, projection) as MapPoint;
                }
                else
                {
                    point = (MapPoint)mapPoint.Clone();
                }
            });

            return(point);
        }
コード例 #16
0
        /// <summary>
        /// Called when the OnToolMouseDown event is handled. Allows the opportunity to perform asynchronous operations corresponding to the event.
        /// </summary>
        protected override Task HandleMouseDownAsync(MapViewMouseButtonEventArgs e)
        {
            //Get the instance of the ViewModel
            var symbolDockPaneViewModel = FrameworkApplication.DockPaneManager.Find("ProSymbolEditor_MilitarySymbolDockpane") as MilitarySymbolDockpaneViewModel;

            if (symbolDockPaneViewModel == null)
            {
                return(Task.FromResult(0));
            }

            //Get the map coordinates from the click point and set the property on the ViewModel.
            return(QueuedTask.Run(() =>
            {
                var tempMapPoint = MapView.Active.ClientToMap(e.ClientPoint);
                try
                {
                    // for now we will always project to WGS84
                    MapPoint projectedMapPoint = GeometryEngine.Project(tempMapPoint, SpatialReferences.WGS84) as MapPoint;

                    //Create a point with a z value, since the mil spec feature classes have z enabled (TODO: other way to do this?)
                    symbolDockPaneViewModel.MapGeometry = MapPointBuilder.CreateMapPoint(projectedMapPoint.X, projectedMapPoint.Y, 0, projectedMapPoint.SpatialReference);
                    symbolDockPaneViewModel.MapPointCoordinatesString = string.Format("{0:0.0####} {1:0.0####}", tempMapPoint.Y, tempMapPoint.X);
                }
                catch (Exception exception)
                {
                    System.Console.WriteLine(exception.Message);
                }
            }));
        }
コード例 #17
0
        public async Task <bool> ApplyResults(MapView mapView, SearchResults results, IPointSymbology symbology, CancellationToken ctsToken)
        {
            Clear();

            if (ctsToken.IsCancellationRequested)
            {
                return(false);
            }

            await QueuedTask.Run(() =>
            {
                InitSymbology(symbology);
                var spatialRef = SpatialReferences.WGS84; // TODO: this should be coming from response
                foreach (var pointCluster in results.GetValuePointClusters(ValueName))
                {
                    if (ctsToken.IsCancellationRequested)
                    {
                        return;
                    }

                    var location = MapPointBuilder.CreateMapPoint(pointCluster.Longitude, pointCluster.Latitude, spatialRef);
                    var addItems = AddOverlay(mapView, location, pointCluster, spatialRef);
                    _elements.Add(new Element()
                    {
                        Location = location, Value = pointCluster, PointOverlay = addItems.Item1, TextOverlay = addItems.Item2, Hitbox = addItems.Item3
                    });
                }
            });

            return(_elements.Count > 0);
        }
コード例 #18
0
        /// <summary>
        /// Update the CIMPointGraphic location
        /// </summary>
        /// <param name="point"></param>
        public void UpdateLocation(PointN point)
        {
            ArcGIS.Core.Geometry.SpatialReference sptlRef = SpatialReferenceBuilder.CreateSpatialReference(point.SpatialReference.WKID);
            MapPoint mapPoint = MapPointBuilder.CreateMapPoint(point.X, point.Y, sptlRef);

            _graphic.Location = mapPoint;
        }
コード例 #19
0
        private async void UpdateManualFeedback()
        {
            if (LineFromType == LineFromTypes.BearingAndDistance && Azimuth.HasValue && HasPoint1 && Point1 != null)
            {
                GeodeticCurveType curveType = DeriveCurveType(LineType);
                LinearUnit        lu        = DeriveUnit(LineDistanceType);
                // update feedback
                var segment = QueuedTask.Run(() =>
                {
                    var mpList = new List <MapPoint>()
                    {
                        Point1
                    };
                    // get point 2
                    // SDK Bug, GeometryEngine.GeodesicMove seems to not honor the LinearUnit passed in, always does Meters
                    var tempDistance = ConvertFromTo(LineDistanceType, DistanceTypes.Meters, Distance);
                    var results      = GeometryEngine.Instance.GeodeticMove(mpList, MapView.Active.Map.SpatialReference, tempDistance, LinearUnit.Meters /*GetLinearUnit(LineDistanceType)*/, GetAzimuthAsRadians().Value, GetCurveType());
                    foreach (var mp in results)
                    {
                        // WORKAROUND: For some odd reason GeodeticMove is removing the Z attribute of the point
                        // so need to put it back so all points will have a consistent Z.
                        // This is important when storing to feature class with Z
                        if (mp == null)
                        {
                            continue;
                        }

                        if (Double.IsNaN(mp.Z))
                        {
                            MapPointBuilder mb = new MapPointBuilder(mp.X, mp.Y, 0.0, mp.SpatialReference);
                            Point2             = mb.ToGeometry();
                        }
                        else
                        {
                            Point2 = mp;
                        }
                    }

                    if (Point2 != null)
                    {
                        var point2Proj = GeometryEngine.Instance.Project(Point2, Point1.SpatialReference);
                        return(LineBuilder.CreateLineSegment(Point1, (MapPoint)point2Proj));
                    }
                    else
                    {
                        return(null);
                    }
                }).Result;

                if (segment != null)
                {
                    await UpdateFeedbackWithGeoLine(segment, curveType, lu);
                }
            }
            else
            {
                ClearTempGraphics(); // if not, or no longer, valid clear
            }
        }
コード例 #20
0
 private async Task <MapPoint> AddZOffsetAsync(MapPoint mapPoint)
 {
     return(await QueuedTask.Run(async() => mapPoint.HasZ
                                 ?MapPointBuilder.CreateMapPoint(mapPoint.X, mapPoint.Y,
                                                                 mapPoint.Z + ((VectorLayer != null) ? await VectorLayer.GetOffsetZAsync() : 0),
                                                                 mapPoint.SpatialReference)
                                 : MapPointBuilder.CreateMapPoint(mapPoint.X, mapPoint.Y, mapPoint.SpatialReference)));
 }
コード例 #21
0
        public static MapPoint MidPoint(MapPoint p1, MapPoint p2)
        {
            MapPointBuilder p = new MapPointBuilder(p1.SpatialReference);

            p.X = (p1.X + p2.X) / 2.0;
            p.Y = (p1.Y + p2.Y) / 2.0;
            return(p.ToGeometry());
        }
コード例 #22
0
        private static Dictionary <MapMember, List <long> > GetSelectedItems(MapViewMouseButtonEventArgs e)
        {
            var point = MapPointBuilder.CreateMapPoint(e.ClientPoint.X, e.ClientPoint.Y);
            var selectedLayerFeatures = MapView.Active.GetFeatures(point, true);
            var selectedItems         = selectedLayerFeatures.ToDictionary(x => x.Key as MapMember, x => x.Value);

            return(selectedItems);
        }
コード例 #23
0
        public void CanUseCoreDirectly()
        {
            SpatialReference ch1903 = SpatialReferenceBuilder.CreateSpatialReference(21781);
            MapPoint         point  = MapPointBuilder.CreateMapPoint(600000, 200000, ch1903);

            Assert.AreEqual(600000.0, point.X);
            Assert.AreEqual(200000.0, point.Y);
        }
コード例 #24
0
        private static async Task CreateFeatures(List <MapPoint> mapPointList)
        {
            RowBuffer rowBuffer = null;

            try
            {
                await QueuedTask.Run(() =>
                {
                    var layer = MapView.Active.GetSelectedLayers()[0];
                    if (layer is FeatureLayer)
                    {
                        var featureLayer = layer as FeatureLayer;

                        using (var table = featureLayer.GetTable())
                        {
                            TableDefinition definition = table.GetDefinition();
                            int shapeIndex             = definition.FindField("Shape");

                            foreach (var point in mapPointList)
                            {
                                rowBuffer = table.CreateRowBuffer();

                                rowBuffer[shapeIndex] = new MapPointBuilder(point).ToGeometry();

                                Row row = table.CreateRow(rowBuffer);
                            }
                        }

                        //Get simple renderer from feature layer
                        CIMSimpleRenderer currentRenderer = featureLayer.GetRenderer() as CIMSimpleRenderer;
                        CIMSymbolReference sybmol         = currentRenderer.Symbol;

                        //var outline = SymbolFactory.ConstructStroke(ColorFactory.RedRGB, 1.0, SimpleLineStyle.Solid);
                        //var s = SymbolFactory.ConstructPolygonSymbol(ColorFactory.RedRGB, SimpleFillStyle.Null, outline);
                        var s = SymbolFactory.ConstructPointSymbol(ColorFactory.RedRGB, 3.0);
                        CIMSymbolReference symbolRef = new CIMSymbolReference()
                        {
                            Symbol = s
                        };
                        currentRenderer.Symbol = symbolRef;

                        featureLayer.SetRenderer(currentRenderer);
                    }
                });
            }
            catch (GeodatabaseException exObj)
            {
                Console.WriteLine(exObj);
                throw;
            }
            finally
            {
                if (rowBuffer != null)
                {
                    rowBuffer.Dispose();
                }
            }
        }
コード例 #25
0
ファイル: CommonMethod.cs プロジェクト: Yu-Wenb/GPProgram
        public static Polygon SetShipRotate(double angle)
        {
            Polygon  init_p  = GetShipPolygon();
            MapPoint center  = MapPointBuilder.CreateMapPoint(0, 0);
            double   radians = AngularUnit.Degrees.ConvertToRadians(angle);
            Polygon  p       = GeometryEngine.Instance.Rotate(init_p, center, -radians) as Polygon;

            return(p);
        }
コード例 #26
0
        private MapPoint GetAveragePoint(MapPoint leftPoint, MapPoint rightPoint)
        {
            var avgX       = (leftPoint.X + rightPoint.X) / 2;
            var avgY       = (leftPoint.Y + rightPoint.Y) / 2;
            var avgZ       = (leftPoint.Z + rightPoint.Z) / 2;
            var spatialRef = leftPoint.SpatialReference;

            return(MapPointBuilder.CreateMapPoint(avgX, avgY, avgZ, spatialRef));
        }
コード例 #27
0
        private MapPoint CreateTargetShipPoint(MapPoint own_ship, double movedX, double movedY)
        {
            double   lon       = own_ship.X;
            double   lat       = own_ship.Y;
            double   m_movedX  = movedX * 1852;
            double   m_movedY  = movedY * 1852;
            MapPoint newTarget = MapPointBuilder.CreateMapPoint(lon + m_movedX, lat + m_movedY, own_ship.SpatialReference);

            return(newTarget);
        }
コード例 #28
0
        public static MapPoint InterpolatePointOnLine(MapPoint p1, MapPoint p2, double scale)
        {
            MapPointBuilder p = new MapPointBuilder(p1.SpatialReference);
            double          x = 0.0, y = 0.0;

            GeometryAlgorithms.InterpolatePointOnLine(p1.X, p1.Y, p2.X, p2.Y, scale, ref x, ref y);
            p.X = x;
            p.Y = y;
            return(p.ToGeometry());
        }
コード例 #29
0
        private static MapPoint CreatePointFromSketchPolygon(Geometry sketchGeometry)
        {
            var clickCoord =
                new Coordinate2D(sketchGeometry.Extent.XMin, sketchGeometry.Extent.YMin);

            MapPoint sketchPoint =
                MapPointBuilder.CreateMapPoint(clickCoord, sketchGeometry.SpatialReference);

            return(sketchPoint);
        }
コード例 #30
0
        private static void CreateField(Report report)
        {
            #region Create a new field in the report
            //This is the gap between two fields.
            double fieldIncrement = 0.9388875113593206276389;
            //On the QueuedTask
            //New field to add.
            var newReportField = new CIMReportField
            {
                Name       = "POP1990",
                FieldOrder = 2,
            };
            //Get the "ReportSection element"
            var mainReportSection = report.Elements.OfType <ReportSection>().FirstOrDefault();
            if (mainReportSection == null)
            {
                return;
            }

            //Get the "ReportDetails" within the ReportSectionElement. ReportDetails is where "fields" are.
            var reportDetailsSection = mainReportSection?.Elements.OfType <ReportDetails>().FirstOrDefault();
            if (reportDetailsSection == null)
            {
                return;
            }

            //Within ReportDetails find the envelope that encloses a field.
            //We get the first CIMParagraphTextGraphic in the collection so that we can add the new field next to it.
            var lastFieldGraphic = reportDetailsSection.Elements.FirstOrDefault((r) =>
            {
                var gr = r as GraphicElement;
                if (gr == null)
                {
                    return(false);
                }
                return(gr.GetGraphic() is CIMParagraphTextGraphic ? true : false);
            });
            //Get the Envelope of the last field
            var graphicBounds = lastFieldGraphic.GetBounds();

            //Min and Max values of the envelope
            var xMinOfFieldEnvelope = graphicBounds.XMin;
            var yMinOfFieldEnvelope = graphicBounds.YMin;

            var xMaxOfFieldEnvelope = graphicBounds.XMax;
            var YMaxOfFieldEnvelope = graphicBounds.YMax;
            //create the new Envelope to be offset from the existing field
            MapPoint newMinPoint      = MapPointBuilder.CreateMapPoint(xMinOfFieldEnvelope + fieldIncrement, yMinOfFieldEnvelope);
            MapPoint newMaxPoint      = MapPointBuilder.CreateMapPoint(xMaxOfFieldEnvelope + fieldIncrement, YMaxOfFieldEnvelope);
            Envelope newFieldEnvelope = EnvelopeBuilder.CreateEnvelope(newMinPoint, newMaxPoint);

            //Create field
            GraphicElement fieldGraphic = ReportElementFactory.Instance.CreateFieldValueTextElement(reportDetailsSection, newFieldEnvelope, newReportField);
            #endregion
        }
コード例 #31
0
		// Helper method
		private static PointCollection FromArray(params double[] parameters)
		{
			PointCollection coll = new PointCollection(SpatialReferences.Wgs84);
			var mapPointBuilder = new MapPointBuilder(SpatialReferences.Wgs84);
			for (int i = 0; i < parameters.Length - 1; i+=2)
			{
				mapPointBuilder.SetValues(parameters[i], parameters[i + 1]);
				coll.Add(mapPointBuilder.ToGeometry());
			}
			return coll;
		}
コード例 #32
0
 public static MapPoint MidPoint(MapPoint p1, MapPoint p2)
 {
     MapPointBuilder p = new MapPointBuilder(p1.SpatialReference);
     p.X = (p1.X + p2.X) / 2.0;
     p.Y = (p1.Y + p2.Y) / 2.0;
     return p.ToGeometry();
 }
コード例 #33
0
 public static MapPoint InterpolatePointOnLine(MapPoint p1, MapPoint p2, double scale)
 {
     MapPointBuilder p = new MapPointBuilder(p1.SpatialReference);
     double x = 0.0, y = 0.0;
     GeometryAlgorithms.InterpolatePointOnLine(p1.X, p1.Y, p2.X, p2.Y, scale, ref x, ref y);
     p.X = x;
     p.Y = y;
     return p.ToGeometry();
 }
コード例 #34
0
            VectorArrowPoints(double beginPntX, double beginPntY, MapPoint endPnt)
        {
            double x = beginPntX - endPnt.X;
            double y = beginPntY - endPnt.Y;
            double angle = Math.Atan2(y, x);

            double alpha = Math.PI / 6;                         // arrow is 30 degree by each side of original line
            double length = Math.Sqrt(x * x + y * y) * 0.25;      // arrow is a quarter of original length 

            MapPointBuilder p1 = new MapPointBuilder(endPnt);
            MapPointBuilder p2 = new MapPointBuilder(endPnt);
            p1.X += length * Math.Cos(angle + alpha);
            p1.Y += length * Math.Sin(angle + alpha);
            p2.X += length * Math.Cos(angle - alpha);
            p2.Y += length * Math.Sin(angle - alpha);

            Esri.ArcGISRuntime.Geometry.PointCollection pc = new Esri.ArcGISRuntime.Geometry.PointCollection();
            pc.Add(p1.ToGeometry());
            pc.Add(endPnt);
            pc.Add(p2.ToGeometry());

            return pc;
        }