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);
        }
        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);
        }
Пример #3
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)));
        }
Пример #4
0
        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
        }
Пример #5
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);
        }
Пример #6
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;
        }
        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());
        }
        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();
        }
        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);
        }
        /// <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);
                }
            }));
        }
        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.");
            }
        }
Пример #12
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;
        }
Пример #13
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);
        }
        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;
            }));
        }
Пример #15
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();
            }));
        }
 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)));
 }
        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);
        }
Пример #18
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);
        }
Пример #19
0
        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);
        }
Пример #20
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));
        }
Пример #21
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);
        }
Пример #22
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);
        }
        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
        }
        private async Task OpenImageAsync(bool replace)
        {
            if (_api != null)
            {
                string location = ((dynamic)DataContext).Location;
                bool   nearest  = ((dynamic)DataContext).Nearest;
                _api.SetActiveViewerReplaceMode(replace);

                if (nearest)
                {
                    MySpatialReference spatialReference     = _settings.CycloramaViewerCoordinateSystem;
                    SpatialReference   thisSpatialReference = spatialReference.ArcGisSpatialReference ??
                                                              await spatialReference.CreateArcGisSpatialReferenceAsync();

                    if ((_lastSpatialReference != null) && (thisSpatialReference.Wkid != _lastSpatialReference.Wkid))
                    {
                        string[]    splitLoc = location.Split(',');
                        CultureInfo ci       = CultureInfo.InvariantCulture;
                        double      x        = double.Parse(splitLoc.Length >= 1 ? splitLoc[0] : "0.0", ci);
                        double      y        = double.Parse(splitLoc.Length >= 2 ? splitLoc[1] : "0.0", ci);
                        MapPoint    point    = null;

                        await QueuedTask.Run(() =>
                        {
                            point = MapPointBuilder.CreateMapPoint(x, y, _lastSpatialReference);
                            ProjectionTransformation projection = ProjectionTransformation.Create(_lastSpatialReference,
                                                                                                  thisSpatialReference);
                            point = GeometryEngine.Instance.ProjectEx(point, projection) as MapPoint;
                        });

                        if (point != null)
                        {
                            location = string.Format(ci, "{0},{1}", point.X, point.Y);
                            DockPaneGlobeSpotter globeSpotter = ((dynamic)DataContext);
                            globeSpotter.PropertyChanged   -= OnGlobeSpotterPropertyChanged;
                            ((dynamic)DataContext).Location = location;
                            globeSpotter.PropertyChanged   += OnGlobeSpotterPropertyChanged;
                        }
                    }

                    _startOpenNearest = true;
                    _api.OpenNearestImage(location, _settings.CtrlClickHashTag * _settings.CtrlClickDelta);
                }
                else
                {
                    _api.OpenImage(location);
                }

                MySpatialReference cycloSpatialReference = _settings.CycloramaViewerCoordinateSystem;
                _lastSpatialReference = cycloSpatialReference.ArcGisSpatialReference ??
                                        await cycloSpatialReference.CreateArcGisSpatialReferenceAsync();
            }
        }
        //Use this method if you want keyframes ONLY at line vertices. This is good if the line is highly densified.
        //However, you will get sharp turns at corners because there is no attempt to smooth the animation
        public static async Task CreateKeyframes_AtVertices(MapView mapView, SpatialReference layerSpatRef, ProjectionTransformation transformation,
                                                            CameraTrack cameraTrack, Polyline lineGeom, IEnumerator <ReadOnlySegmentCollection> segments,
                                                            int segmentCount, double pathLength)
        {
            double segmentLength  = 0;
            int    num_iterations = 0;

            segments.Reset();

            //process each segment depending upon its type - straight line or arc
            while (segments.MoveNext())
            {
                ReadOnlySegmentCollection seg = segments.Current;
                double accumulatedDuration    = mapView.Map.Animation.Duration.TotalSeconds + ((mapView.Map.Animation.Duration.TotalSeconds > 0) ? ANIMATION_APPEND_TIME : 0); // 0;

                foreach (Segment s in seg)
                {
                    segmentLength = Math.Sqrt((s.EndPoint.X - s.StartPoint.X) * (s.EndPoint.X - s.StartPoint.X) +
                                              (s.EndPoint.Y - s.StartPoint.Y) * (s.EndPoint.Y - s.StartPoint.Y) +
                                              (s.EndPoint.Z - s.StartPoint.Z) * (s.EndPoint.Z - s.StartPoint.Z));

                    double segmentDuration = (TotalDuration / pathLength) * segmentLength;

                    MapPoint startPt = await QueuedTask.Run(() => MapPointBuilder.CreateMapPoint(s.StartPoint.X, s.StartPoint.Y, s.StartPoint.Z, layerSpatRef));

                    MapPoint endPt = await QueuedTask.Run(() => MapPointBuilder.CreateMapPoint(s.EndPoint.X, s.EndPoint.Y, s.EndPoint.Z, layerSpatRef));

                    //create keyframe at start vertex of path in map space
                    double   timeSpanValue    = accumulatedDuration;
                    TimeSpan keyframeTimespan = TimeSpan.FromSeconds(timeSpanValue);
                    SetPitchAndHeadingForLine(startPt, endPt);
                    await CreateCameraKeyframe(mapView, startPt, transformation, cameraTrack, keyframeTimespan, _keyframePitch, _keyframeHeading);

                    //Create a keyframe at end point of segment only for the end point of last segment
                    //Otherwise we will get duplicate keyframes at end of one segment and start of the next one
                    if (num_iterations == segmentCount - 1)
                    {
                        timeSpanValue    = accumulatedDuration + segmentDuration;
                        keyframeTimespan = TimeSpan.FromSeconds(timeSpanValue);

                        if (SelectedCameraView == "Face target")
                        {
                            SetPitchAndHeadingForLine(endPt, TargetPoint);
                        }

                        await CreateCameraKeyframe(mapView, endPt, transformation, cameraTrack, keyframeTimespan, _keyframePitch, _keyframeHeading);
                    }

                    accumulatedDuration += segmentDuration;
                    num_iterations++;
                }
            }
        }
Пример #26
0
        /// <summary>
        /// Create random sample points in the extent of the spatial reference
        /// </summary>
        /// <param name="pointFeatureLayer">Point geometry feature layer used to the generate the points.</param>
        /// <returns>Task of bool</returns>
        private Task <bool> constructSamplePoints(FeatureLayer pointFeatureLayer)
        {
            // create a random number generator
            var randomGenerator = new Random();

            // the database and geometry interactions are considered fine-grained and must be executed on
            // the main CIM thread
            return(QueuedTask.Run(() =>
            {
                // get the feature class associated with the layer
                var featureClass = pointFeatureLayer.GetTable() as FeatureClass;

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



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

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

                // start an edit operation to create new (random) point features
                var createOperation = new EditOperation();
                createOperation.Name = "Generate points";
                createOperation.SelectNewFeatures = false;

                // create 20 new point geometries and queue them for creation
                for (int i = 0; i < 20; i++)
                {
                    MapPoint newMapPoint = null;

                    // generate either 2D or 3D geometries
                    if (classDefinition.HasZ())
                    {
                        newMapPoint = MapPointBuilder.CreateMapPoint(randomGenerator.NextCoordinate(areaOfInterest, true), spatialReference);
                    }
                    else
                    {
                        newMapPoint = MapPointBuilder.CreateMapPoint(randomGenerator.NextCoordinate(areaOfInterest, false), spatialReference);
                    }

                    // queue feature creation
                    createOperation.Create(pointFeatureLayer, newMapPoint);
                }

                // execute the edit (feature creation) operation
                return createOperation.ExecuteAsync();
            }));
        }
 internal Task <Polyline> CreatePolylineFromPointAsync(MapPoint pt, double tolerance)
 {
     return(QueuedTask.Run(() =>
     {
         // create a polyline from a starting point
         //use a tolerance to construct the second point
         MapPoint pt2 = MapPointBuilder.CreateMapPoint(pt.X + tolerance, pt.Y, pt.SpatialReference);
         return PolylineBuilder.CreatePolyline(new List <MapPoint>()
         {
             pt, pt2
         });
     }));
 }
        public async Task <MapPoint> ToMapPoint()
        {
            if (_mapPoint == null)
            {
                await QueuedTask.Run(() =>
                {
                    ArcGIS.Core.Geometry.SpatialReference sr = SpatialReferenceBuilder.CreateSpatialReference(WKID);
                    _mapPoint = MapPointBuilder.CreateMapPoint(Feature.Location.X, Feature.Location.Y, sr);
                });
            }

            return(_mapPoint);
        }
Пример #29
0
        public async Task RedrawObservationAsync()
        {
            await QueuedTask.Run(() =>
            {
                _disposeInnerLine?.Dispose();
                _disposeOuterLine?.Dispose();

                if (_measurementPoint?.IsObservationVisible() ?? false)
                {
                    MapView thisView   = MapView.Active;
                    MapPoint measPoint = _measurementPoint?.Point;
                    MapPoint mapPointObsLine;

                    if ((measPoint != null) && (!double.IsNaN(measPoint.X)) && (!double.IsNaN(measPoint.Y)))
                    {
                        Point winMeasPoint = thisView.MapToScreen(measPoint);
                        Point winObsPoint  = thisView.MapToScreen(Point);

                        double xdir           = ((winMeasPoint.X - winObsPoint.X) * 3) / 2;
                        double ydir           = ((winMeasPoint.Y - winObsPoint.Y) * 3) / 2;
                        Point winPointObsLine = new Point(winObsPoint.X + xdir, winObsPoint.Y + ydir);
                        mapPointObsLine       = thisView.ScreenToMap(winPointObsLine);
                    }
                    else
                    {
                        mapPointObsLine = MapPointBuilder.CreateMapPoint((Point.X + (XDir * DistLine)), (Point.Y + (YDir * DistLine)));
                    }

                    IList <MapPoint> linePointList = new List <MapPoint>();
                    linePointList.Add(mapPointObsLine);
                    linePointList.Add(Point);
                    Polyline polyline = PolylineBuilder.CreatePolyline(linePointList);

                    Color outerColorLine             = Viewer?.Color ?? Color.DarkGray;
                    CIMColor cimOuterColorLine       = ColorFactory.Instance.CreateColor(Color.FromArgb(255, outerColorLine));
                    CIMLineSymbol cimOuterLineSymbol = SymbolFactory.Instance.DefaultLineSymbol;
                    cimOuterLineSymbol.SetColor(cimOuterColorLine);
                    cimOuterLineSymbol.SetSize(OuterLineSize);
                    CIMSymbolReference cimOuterLineSymbolRef = cimOuterLineSymbol.MakeSymbolReference();
                    _disposeOuterLine = thisView.AddOverlay(polyline, cimOuterLineSymbolRef);

                    Color innerColorLine             = Color.LightGray;
                    CIMColor cimInnerColorLine       = ColorFactory.Instance.CreateColor(innerColorLine);
                    CIMLineSymbol cimInnerLineSymbol = SymbolFactory.Instance.DefaultLineSymbol;
                    cimInnerLineSymbol.SetColor(cimInnerColorLine);
                    cimInnerLineSymbol.SetSize(InnerLineSize);
                    CIMSymbolReference cimInnerLineSymbolRef = cimInnerLineSymbol.MakeSymbolReference();
                    _disposeInnerLine = thisView.AddOverlay(polyline, cimInnerLineSymbolRef);
                }
            });
        }
Пример #30
0
        public void ProCreateAddInPointTest()
        {
            MapPoint point = MapPointBuilder.CreateMapPoint(1300757, 554219);

            Assert.IsNotNull(point);

            AddInPoint addinPoint = new AddInPoint();

            addinPoint.Point = point;

            string output = addinPoint.Text;

            Assert.IsFalse(output.Equals("NA"));
        }