Exemplo n.º 1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            CultureInfo         ci       = CultureInfo.InvariantCulture;
            ApiMeasurementPoint apiPoint = value as ApiMeasurementPoint;

            string stdx = apiPoint == null || double.IsNaN(apiPoint.Std_x) ? "---" : apiPoint.Std_x.ToString("#0.00", ci);
            string stdy = apiPoint == null || double.IsNaN(apiPoint.Std_y) ? "---" : apiPoint.Std_y.ToString("#0.00", ci);
            string stdz = apiPoint == null || double.IsNaN(apiPoint.Std_z) ? "---" : apiPoint.Std_z.ToString("#0.00", ci);

            return(string.Format(ci, "{0}, {1}, {2}", stdx, stdy, stdz));
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            ApiMeasurementPoint point = value as ApiMeasurementPoint;
            bool reliableEstimate     = point?.reliableEstimate ?? false;
            bool stdef = point != null && !double.IsNaN(point.Std_x) && !double.IsNaN(point.Std_y) &&
                         !double.IsNaN(point.Std_z);
            var circle = new Bitmap(18, 18);

            using (var ga = Graphics.FromImage(circle))
            {
                ga.Clear(Color.Transparent);
                Brush color = reliableEstimate ? Brushes.Green : (stdef ? Brushes.Red : Brushes.Gray);
                ga.DrawEllipse(new Pen(color, 1), 2, 2, 14, 14);
                ga.FillEllipse(color, 2, 2, 14, 14);
            }

            return(circle.ToBitmapSource());
        }
        public async Task UpdatePointAsync(ApiMeasurementPoint measurementPoint, int index)
        {
            if (!_updatePoint)
            {
                _updatePoint = true;
                Index        = index;

                ApiPoint = measurementPoint;
                double x = measurementPoint.x;
                double y = measurementPoint.y;
                double z = measurementPoint.z;
                Point = await CoordSystemUtils.CycloramaToMapPointAsync(x, y, z);

                LastPoint = LastPoint ?? Point;

                MapView  thisView = MapView.Active;
                Geometry geometry = await thisView.GetCurrentSketchAsync();

                if (geometry != null)
                {
                    var ptColl = await Measurement.ToPointCollectionAsync(geometry);

                    int nrPoints = Measurement.PointNr;

                    if ((ptColl != null) && Measurement.IsSketch)
                    {
                        if (_intId <= nrPoints)
                        {
                            MapPoint pointC = ptColl[_intId - 1];

                            if (!IsSame(pointC))
                            {
                                await QueuedTask.Run(() =>
                                {
                                    MapPoint point = MapPointBuilder.CreateMapPoint(Point.X, Point.Y, Point.Z, Point.M,
                                                                                    geometry.SpatialReference);

                                    if (Measurement.IsPointMeasurement)
                                    {
                                        thisView.SetCurrentSketchAsync(point);
                                    }
                                    else
                                    {
                                        ptColl[_intId - 1] = point;

                                        if ((_intId == 1) && ((nrPoints + 1) == ptColl.Count))
                                        {
                                            ptColl[ptColl.Count - 1] = point;
                                        }

                                        if (Measurement.IsGeometryType(GeometryType.Polygon))
                                        {
                                            geometry = PolygonBuilder.CreatePolygon(ptColl, geometry.SpatialReference);
                                        }
                                        else if (Measurement.IsGeometryType(GeometryType.Polyline))
                                        {
                                            if (ptColl.Count == 1)
                                            {
                                                ptColl.Add(ptColl[0]);
                                            }

                                            geometry = PolylineBuilder.CreatePolyline(ptColl, geometry.SpatialReference);
                                        }

                                        thisView.SetCurrentSketchAsync(geometry);
                                    }
                                });
                            }
                        }
                        else
                        {
                            await QueuedTask.Run(() =>
                            {
                                MapPoint point = MapPointBuilder.CreateMapPoint(Point.X, Point.Y, Point.Z, Point.M,
                                                                                geometry.SpatialReference);
                                int nrPoints2 = ptColl.Count;

                                switch (nrPoints2)
                                {
                                case 0:
                                    ptColl.Add(point);

                                    if (geometry is Polygon)
                                    {
                                        ptColl.Add(point);
                                    }

                                    break;

                                case 1:
                                    ptColl.Add(point);
                                    break;

                                default:
                                    if (_intId <= (nrPoints + 1))
                                    {
                                        if ((_intId - 1) != nrPoints2)
                                        {
                                            ptColl.Insert((_intId - 1), point);
                                        }
                                        else
                                        {
                                            ptColl.Add(point);
                                        }
                                    }

                                    break;
                                }

                                if (Measurement.IsGeometryType(GeometryType.Polygon))
                                {
                                    geometry = PolygonBuilder.CreatePolygon(ptColl, geometry.SpatialReference);
                                }
                                else if (Measurement.IsGeometryType(GeometryType.Polyline))
                                {
                                    if (ptColl.Count == 1)
                                    {
                                        ptColl.Add(ptColl[0]);
                                    }

                                    geometry = PolylineBuilder.CreatePolyline(ptColl, geometry.SpatialReference);
                                }
                                else if ((Measurement.IsPointMeasurement) && (ptColl.Count == 1))
                                {
                                    geometry = ptColl[0];
                                }

                                thisView.SetCurrentSketchAsync(geometry);
                            });
                        }
                    }
                    else
                    {
                        if (geometry is MapPoint)
                        {
                            await QueuedTask.Run(() =>
                            {
                                if (geometry.IsEmpty)
                                {
                                    if ((!double.IsNaN(Point.X)) && (!double.IsNaN(Point.Y)))
                                    {
                                        if (!_added)
                                        {
                                            _added         = true;
                                            MapPoint point = MapPointBuilder.CreateMapPoint(Point.X, Point.Y, Point.Z, Index);
                                            thisView.SetCurrentSketchAsync(point);
                                            _added = false;
                                        }
                                    }
                                }
                                else
                                {
                                    var pointC = geometry as MapPoint;

                                    if (!IsSame(pointC))
                                    {
                                        if ((!double.IsNaN(Point.X)) && (!double.IsNaN(Point.Y)))
                                        {
                                            MapPoint point = MapPointBuilder.CreateMapPoint(Point.X, Point.Y, Point.Z, Index);
                                            thisView.SetCurrentSketchAsync(point);
                                        }
                                    }
                                }
                            });
                        }
                    }
                }

                _updatePoint = false;
            }

            await RedrawPointAsync();
        }