示例#1
0
        public void Clone()
        {
            Pose poseA = new Pose(new Vector3F(1, 2, 3));
              PointShape pointA = new PointShape(3, 4, 5);
              GeometricObject geometryA = new GeometricObject(pointA, poseA);

              Pose poseB = new Pose(new Vector3F(1, 2, 3));
              PointShape pointB = new PointShape(3, 4, 5);
              GeometricObject geometryB = new GeometricObject(pointB, poseB);

              MinkowskiSumShape minkowskiSumShape = new MinkowskiSumShape(geometryA, geometryB);
              MinkowskiSumShape clone = minkowskiSumShape.Clone() as MinkowskiSumShape;
              Assert.IsNotNull(clone);
              Assert.IsNotNull(clone.ObjectA);
              Assert.IsNotNull(clone.ObjectB);
              Assert.AreNotSame(geometryA, clone.ObjectA);
              Assert.AreNotSame(geometryB, clone.ObjectB);
              Assert.IsTrue(clone.ObjectA is GeometricObject);
              Assert.IsTrue(clone.ObjectB is GeometricObject);
              Assert.AreEqual(poseA, clone.ObjectA.Pose);
              Assert.AreEqual(poseB, clone.ObjectB.Pose);
              Assert.IsNotNull(clone.ObjectA.Shape);
              Assert.IsNotNull(clone.ObjectB.Shape);
              Assert.AreNotSame(pointA, clone.ObjectA.Shape);
              Assert.AreNotSame(pointB, clone.ObjectB.Shape);
              Assert.IsTrue(clone.ObjectA.Shape is PointShape);
              Assert.IsTrue(clone.ObjectB.Shape is PointShape);
              Assert.AreEqual(pointA.Position, ((PointShape)clone.ObjectA.Shape).Position);
              Assert.AreEqual(pointB.Position, ((PointShape)clone.ObjectB.Shape).Position);
              Assert.AreEqual(minkowskiSumShape.GetAabb(Pose.Identity).Minimum, clone.GetAabb(Pose.Identity).Minimum);
              Assert.AreEqual(minkowskiSumShape.GetAabb(Pose.Identity).Maximum, clone.GetAabb(Pose.Identity).Maximum);
        }
示例#2
0
 /// <summary>
 /// Creates a SimpleSymbol with the specified color, shape and size.  The size is used for
 /// both the horizontal and vertical directions.
 /// </summary>
 /// <param name="color">The color of the symbol.</param>
 /// <param name="shape">The shape of the symbol.</param>
 /// <param name="size">The size of the symbol.</param>
 public SimpleSymbol(Color color, PointShape shape, double size)
 {
     Configure();
     _color = color;
     _pointShape = shape;
     Size = new Size2D(size, size);
 }
示例#3
0
        public void Clone()
        {
            CompositeShape compositeShape = new CompositeShape();
              for (int i = 0; i < 10; i++)
              {
            Pose pose = new Pose(new Vector3F(i, i, i));
            PointShape point = new PointShape(i, i, i);
            GeometricObject geometry = new GeometricObject(point, pose);
            compositeShape.Children.Add(geometry);
              }

              CompositeShape clone = compositeShape.Clone() as CompositeShape;
              Assert.IsNotNull(clone);
              Assert.AreEqual(10, clone.Children.Count);
              for (int i = 0; i < 10; i++)
              {
            Assert.IsNotNull(clone.Children[i]);
            Assert.AreNotSame(compositeShape.Children[i], clone.Children[i]);
            Assert.IsTrue(clone.Children[i] is GeometricObject);
            Assert.AreEqual(compositeShape.Children[i].Pose, clone.Children[i].Pose);
            Assert.IsNotNull(clone.Children[i].Shape);
            Assert.AreNotSame(compositeShape.Children[i].Shape, clone.Children[i].Shape);
            Assert.IsTrue(clone.Children[i].Shape is PointShape);
            Assert.AreEqual(((PointShape)compositeShape.Children[i].Shape).Position, ((PointShape)clone.Children[i].Shape).Position);
              }

              Assert.AreEqual(compositeShape.GetAabb(Pose.Identity).Minimum, clone.GetAabb(Pose.Identity).Minimum);
              Assert.AreEqual(compositeShape.GetAabb(Pose.Identity).Maximum, clone.GetAabb(Pose.Identity).Maximum);
        }
示例#4
0
 public void Clone()
 {
     PointShape point = new PointShape(new Vector3F(1, 2, 3));
       PointShape clone = point.Clone() as PointShape;
       Assert.IsNotNull(clone);
       Assert.AreEqual(point.Position, clone.Position);
       Assert.AreEqual(point.GetAabb(Pose.Identity).Minimum, clone.GetAabb(Pose.Identity).Minimum);
       Assert.AreEqual(point.GetAabb(Pose.Identity).Maximum, clone.GetAabb(Pose.Identity).Maximum);
 }
示例#5
0
        public void GetMesh()
        {
            var p = new PointShape(1, 2, 3);

              var m = p.GetMesh(0, 1);
              Assert.AreEqual(1, m.NumberOfTriangles);

              Triangle t = m.GetTriangle(0);

              Assert.AreEqual(p.Position, t.Vertex0);
              Assert.AreEqual(p.Position, t.Vertex1);
              Assert.AreEqual(p.Position, t.Vertex2);
        }
 private static int GetFixedPointIndex(PolygonShape sourcePolygonShape, PointShape sourceControlPointShape)
 {
     var index = 0;
     for (var i = 0; i < sourcePolygonShape.OuterRing.Vertices.Count; i++)
     {
         var vertex = sourcePolygonShape.OuterRing.Vertices[i];
         if (Math.Abs(vertex.X - sourceControlPointShape.X) > 10E-6 || Math.Abs(vertex.Y - sourceControlPointShape.Y) > 10E-6) continue;
         index = i;
         break;
     }
     int fixedPointIndex;
     if (index <= 2) fixedPointIndex = index + 2;
     else fixedPointIndex = index - 2;
     return fixedPointIndex;
 }
示例#7
0
        public void CloneWithPartition()
        {
            CompositeShape compositeShape = new CompositeShape();
              for (int i = 0; i < 10; i++)
              {
            Pose pose = new Pose(new Vector3F(i, i, i));
            PointShape point = new PointShape(i, i, i);
            GeometricObject geometry = new GeometricObject(point, pose);
            compositeShape.Children.Add(geometry);
              }

              CloneWithPartition(compositeShape, new AabbTree<int>());
              CloneWithPartition(compositeShape, new AdaptiveAabbTree<int>());
              CloneWithPartition(compositeShape, new CompressedAabbTree());
              CloneWithPartition(compositeShape, new DynamicAabbTree<int>());
              CloneWithPartition(compositeShape, new SweepAndPruneSpace<int>());
        }
 protected override Feature ResizeFeatureCore(Feature sourceFeature, PointShape sourceControlPoint, PointShape targetControlPoint)
 {
     // Override the base method and modify the logic for resizing if the shape is the "custom"
     var polygonShape = sourceFeature.GetShape() as PolygonShape;
     if (polygonShape != null)
     {
         // If the rectangle is horizontal or vertical, it will use the custom method.
         if (string.Equals(polygonShape.GetBoundingBox().GetWellKnownText(), polygonShape.GetWellKnownText()))
         {
             var fixedPointIndex = GetFixedPointIndex(polygonShape, sourceControlPoint);
             var fixedPointShape = new PointShape(polygonShape.OuterRing.Vertices[fixedPointIndex]);
             var newRectangleShape = new LineShape(new[] { new Vertex(fixedPointShape), new Vertex(targetControlPoint) }).GetBoundingBox();
             return base.ResizeFeatureCore(new Feature(newRectangleShape.GetWellKnownBinary(), sourceFeature.Id, sourceFeature.ColumnValues),
                                           targetControlPoint,
                                           targetControlPoint);
         }
     }
     return base.ResizeFeatureCore(sourceFeature, sourceControlPoint, targetControlPoint);
 }
示例#9
0
        public void Clone()
        {
            Pose pose = new Pose(new Vector3F(1, 2, 3));
              PointShape pointShape = new PointShape(3, 4, 5);
              GeometricObject geometry = new GeometricObject(pointShape, pose);

              TransformedShape transformedShape = new TransformedShape(geometry);
              TransformedShape clone = transformedShape.Clone() as TransformedShape;
              Assert.IsNotNull(clone);
              Assert.IsNotNull(clone.Child);
              Assert.AreNotSame(geometry, clone.Child);
              Assert.IsTrue(clone.Child is GeometricObject);
              Assert.AreEqual(pose, clone.Child.Pose);
              Assert.IsNotNull(clone.Child.Shape);
              Assert.AreNotSame(pointShape, clone.Child.Shape);
              Assert.IsTrue(clone.Child.Shape is PointShape);
              Assert.AreEqual(pointShape.Position, ((PointShape)clone.Child.Shape).Position);
              Assert.AreEqual(transformedShape.GetAabb(Pose.Identity).Minimum, clone.GetAabb(Pose.Identity).Minimum);
              Assert.AreEqual(transformedShape.GetAabb(Pose.Identity).Maximum, clone.GetAabb(Pose.Identity).Maximum);
        }
 private void wpfMap1_MapClick(object sender, MapClickWpfMapEventArgs e)
 {
     pointShape = e.WorldLocation;
     FindWithinDistanceFeatures();
 }
示例#11
0
 internal static bool IsSamePoint(PointShape point1, Vertex point2, double tolerance)
 {
     return isSamePoint(point1.X, point1.Y, point2.X, point2.Y, tolerance);
 }
示例#12
0
        internal static bool IsIntermediatePoint(Vertex startVertex, Vertex endVertex, PointShape intermeidatePoint)
        {
            bool isIntermediatePoint = false;

            if ((startVertex.X == intermeidatePoint.X && startVertex.Y == intermeidatePoint.Y)
                || (endVertex.X == intermeidatePoint.X && endVertex.Y == intermeidatePoint.Y))
            {
                isIntermediatePoint = true;
            }
            else
            {
                if (endVertex.X == startVertex.X)
                {
                    if (intermeidatePoint.X == startVertex.X)
                    {
                        if ((intermeidatePoint.Y >= startVertex.Y && intermeidatePoint.Y <= endVertex.Y)
                            || (intermeidatePoint.Y >= endVertex.Y && intermeidatePoint.Y <= startVertex.Y))
                        {
                            isIntermediatePoint = true;
                        }
                    }
                }
                else
                {
                    double segmentRatio = (endVertex.Y - startVertex.Y) / (endVertex.X - startVertex.X);
                    double intermeidateRatio = (intermeidatePoint.Y - startVertex.Y) / (intermeidatePoint.X - startVertex.X);

                    if (segmentRatio == intermeidateRatio)
                    {
                        if ((intermeidatePoint.X >= startVertex.X && intermeidatePoint.X <= endVertex.X)
                            || (intermeidatePoint.X >= endVertex.X && intermeidatePoint.Y <= startVertex.X))
                        {
                            isIntermediatePoint = true;
                        }
                    }
                }
            }
            return isIntermediatePoint;
        }
示例#13
0
 internal static double GetEvaluatedDistance(Vertex point1, PointShape point2)
 {
     return DecimalDegreesHelper.GetDistanceFromDecimalDegrees(new PointShape(point1), point2, DistanceUnit.Meter);
 }
示例#14
0
 protected Feature DragFeature(Feature sourceFeature, PointShape sourceControlPoint, PointShape targetControlPoint)
 {
     return(DragFeatureCore(sourceFeature, sourceControlPoint, targetControlPoint));
 }
示例#15
0
        public void SerializationBinary()
        {
            Pose poseA = new Pose(new Vector3F(1, 2, 3));
              PointShape pointA = new PointShape(3, 4, 5);
              GeometricObject geometryA = new GeometricObject(pointA, poseA);

              Pose poseB = new Pose(new Vector3F(11, 22, 33));
              PointShape pointB = new PointShape(33, 44, 55);
              GeometricObject geometryB = new GeometricObject(pointB, poseB);

              var a = new MinkowskiSumShape(geometryA, geometryB);

              // Serialize object.
              var stream = new MemoryStream();
              var formatter = new BinaryFormatter();
              formatter.Serialize(stream, a);

              // Deserialize object.
              stream.Position = 0;
              var deserializer = new BinaryFormatter();
              var b = (MinkowskiSumShape)deserializer.Deserialize(stream);

              Assert.AreEqual(a.ObjectA.Pose, b.ObjectA.Pose);
              Assert.AreEqual(a.ObjectB.Pose, b.ObjectB.Pose);
              Assert.AreEqual(((PointShape)a.ObjectA.Shape).Position, ((PointShape)b.ObjectA.Shape).Position);
              Assert.AreEqual(((PointShape)a.ObjectB.Shape).Position, ((PointShape)b.ObjectB.Shape).Position);
        }
示例#16
0
        public void SerializationBinary()
        {
            Pose pose = new Pose(new Vector3F(1, 2, 3));
              PointShape pointShape = new PointShape(3, 4, 5);
              var a = new TransformedShape(new GeometricObject(pointShape, pose));

              // Serialize object.
              var stream = new MemoryStream();
              var formatter = new BinaryFormatter();
              formatter.Serialize(stream, a);

              // Deserialize object.
              stream.Position = 0;
              var deserializer = new BinaryFormatter();
              var b = (TransformedShape)deserializer.Deserialize(stream);

              Assert.AreEqual(a.Child.Pose, b.Child.Pose);
              Assert.AreEqual(((PointShape)a.Child.Shape).Position, ((PointShape)b.Child.Shape).Position);
        }
示例#17
0
 public static RectangleShape GetUpperRightQuater(RectangleShape boundingBox)
 {
     PointShape uppperLeft = new PointShape((boundingBox.UpperLeftPoint.X + boundingBox.UpperRightPoint.X) / 2, boundingBox.UpperLeftPoint.Y);
     PointShape lowerRight = new PointShape(boundingBox.UpperRightPoint.X, (boundingBox.UpperRightPoint.Y + boundingBox.LowerRightPoint.Y) / 2);
     return new RectangleShape(uppperLeft, lowerRight);
 }
示例#18
0
        public static double GetCellWidthByLevel(RectangleShape extent, GeographyUnit extentMapUnit, int level, DistanceUnit returnDistanceUnit)
        {
            PointShape centerPoint = extent.GetCenterPoint();

            PointShape centerLeft = new PointShape(extent.LowerLeftPoint.X, centerPoint.Y);
            PointShape centerRight = new PointShape(extent.UpperRightPoint.X, centerPoint.Y);
            PointShape centerUpper = new PointShape(centerPoint.X, extent.UpperLeftPoint.Y);
            PointShape centerLower = new PointShape(centerPoint.X, extent.LowerLeftPoint.Y);

            double centerWidth = centerLeft.GetDistanceTo(centerRight, extentMapUnit, returnDistanceUnit);
            double centerHeight = centerUpper.GetDistanceTo(centerLower, extentMapUnit, returnDistanceUnit);
            double longestEdge = Math.Max(centerWidth, centerHeight);

            double cellWidth = longestEdge / Math.Sqrt(Math.Pow(4, level - 1));
            return cellWidth;
        }
 protected override Feature AddVertexCore(Feature targetFeature, PointShape targetPointShape, double searchingTolerance)
 {
     // Override the base method and disable the function of AddVertex if the shape is the "custom"
     return new Feature();
 }
 public static RectangleShape GetBufferedRectangle(PointShape pointShape, double resolution, double tolerance = 8)
 {
     PointShape clickedPoint = pointShape;
     double offset = resolution * 8;
     return new RectangleShape(clickedPoint.X - offset, clickedPoint.Y + offset, clickedPoint.X + offset, clickedPoint.Y - offset);
 }
        void MouseHover()
        {
            // Here create an event stream called mouseGeosWithMouseWheelNulls, which consists of the MouseGeo event stream, 
            // merged with another stream that produces a null every time the mouse wheel is moved
            // Here create an event stream called MouseHoverGeo, which consists of mouseGeosWithMouseWheelNulls events 
            // filtered to only give us an event after 300 ms of inactivity with duplicate events and null events removed
            MouseHoverGeo = MouseGeo.Throttle(TimeSpan.FromMilliseconds(300))
                .Merge(Observable.FromEventPattern<MouseWheelEventArgs>(_wpfMap, "MouseWheel").Select(e => (Geo)null))
                .Merge(MouseGeo.Select(e => (Geo)null))
                .DistinctUntilChanged();
            //MouseHoverGeo.ObserveOn(TaskPoolScheduler.Default).Subscribe(g => Debug.WriteLine(string.Format("{0:HH:mm:ss:fff} MouseHoverGeo is now {1}", DateTime.Now, g)));

#if false
    // Observe the MouseHoveGeo event stream on the TaskPool
            _mouseHover = MouseHoverGeo.ObserveOn(TaskPoolScheduler.Default)
                .Subscribe(g =>
                {
                    var pointShape = new PointShape(g.Longitude, g.Latitude);
                    foreach (var activeLayerOverlay in _wpfMap.Overlays.OfType<ActiveLayerOverlay>().ToList())
                    {
                        foreach (var featureLayer in activeLayerOverlay.Layers.OfType<FeatureLayer>().ToList())
                        {
                            try
                            {
                                featureLayer.Open();
                                var featureCollection = featureLayer.QueryTools.GetFeaturesContaining(pointShape, ReturningColumnsType.NoColumns);
                                if (featureCollection.Count == 0) continue;
                                activeLayerOverlay.MouseIsHovering.OnNext(true);
                                _hoveringOverlays.Add(activeLayerOverlay);
                            }
                            finally
                            {
                                if (featureLayer.IsOpen) featureLayer.Close();
                            }
                        }
                    }
                });
            mouseGeoWithMouseWheelNull.ObserveOn(TaskPoolScheduler.Default)
                .Subscribe(g =>
                {
                    while (!_hoveringOverlays.IsEmpty)
                    {
                        ActiveLayerOverlay overlay;
                        if (_hoveringOverlays.TryTake(out overlay)) overlay.MouseIsHovering.OnNext(false);
                    }
                });
#endif
        }
示例#22
0
 public LineShape(object owner, string name, PointShape start, PointShape end) : base(owner, name)
 {
     _start = start;
     _end   = end;
 }
示例#23
0
        public override void OnFrameworkInitializationCompleted()
        {
            if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktopLifetime)
            {
                var disposable = new CompositeDisposable();

                // Model

                object owner = new object();

                var layer1 = new Layer(owner, "layer1");

                var start11 = new PointShape(owner, "start11", 100, 100);
                var end11   = new PointShape(owner, "end11", 200, 100);
                var line1   = new LineShape(layer1, "line1", start11, end11);
                start11.Owner = line1;
                end11.Owner   = line1;
                layer1.Shapes.Add(line1);

                var start21 = new PointShape(owner, "start21", 100, 200);
                var end21   = new PointShape(owner, "end21", 200, 200);
                var line2   = new LineShape(layer1, "line2", start21, end21);
                start21.Owner = line2;
                line2.Owner   = line2;
                layer1.Shapes.Add(line2);

                // ViewModel

                var history        = new StackHistory().AddTo(disposable);
                var layerViewModel = new LayerViewModel(layer1, history).AddTo(disposable);

                // Window

                var mainWindow = new MainWindow()
                {
                    DataContext = layerViewModel
                };

                var layerCanvas = mainWindow.FindControl <LayerCanvas>("layerCanvas");

                LineShape?line = null;

                layerCanvas.PointerPressed += (sender, e) =>
                {
                    if (e.GetPointerPoint(layerCanvas).Properties.IsLeftButtonPressed)
                    {
                        var point = e.GetPosition(layerCanvas);
                        if (line == null)
                        {
                            var start = new PointShape(layer1.Owner, "start", point.X, point.Y);
                            var end   = new PointShape(layer1.Owner, "end", point.X, point.Y);
                            line             = new LineShape(layer1, "line", start, end);
                            line.Start.Owner = line;
                            line.End.Owner   = line;
                            //layer1.Shapes.AddWithHistory(line, history);
                            layer1.Shapes.Add(line);
                            //history.IsPaused = true;
                            layerCanvas.InvalidateVisual();
                        }
                        else
                        {
                            line.End.X = point.X;
                            line.End.Y = point.Y;
                            layer1.Shapes.Remove(line);
                            layer1.Shapes.AddWithHistory(line, history);
                            //history.IsPaused = false;
                            line = null;
                            layerCanvas.InvalidateVisual();
                        }
                    }
                    else if (e.GetPointerPoint(layerCanvas).Properties.IsRightButtonPressed)
                    {
                        if (line != null)
                        {
                            layer1.Shapes.Remove(line);
                            line = null;
                            layerCanvas.InvalidateVisual();
                        }
                    }
                };

                layerCanvas.PointerMoved += (sender, args) =>
                {
                    var point = args.GetPosition(layerCanvas);
                    if (line != null)
                    {
                        line.End.X = point.X;
                        line.End.Y = point.Y;
                        layerCanvas.InvalidateVisual();
                    }
                };

                history.CanClear.Subscribe(_ => layerCanvas.InvalidateVisual()).AddTo(disposable);

                desktopLifetime.MainWindow = mainWindow;

                desktopLifetime.Exit += (sennder, e) =>
                {
                    disposable.Dispose();
                };
            }
            else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewLifetime)
            {
                //singleViewLifetime.MainView = new MainView();
            }
            base.OnFrameworkInitializationCompleted();
        }
示例#24
0
        protected virtual Feature DragFeatureCore(Feature sourceFeature, PointShape sourceControlPoint, PointShape targetControlPoint)
        {
            FeatureDraggingEditInteractiveOverlayEventArgs featureDraggingEditInteractiveOverlayEventArgs = new FeatureDraggingEditInteractiveOverlayEventArgs(sourceFeature, false, sourceControlPoint, targetControlPoint);

            OnFeatureDragging(featureDraggingEditInteractiveOverlayEventArgs);

            if (featureDraggingEditInteractiveOverlayEventArgs.Cancel)
            {
                return(sourceFeature);
            }

            double offsetDistanceX = targetControlPoint.X - sourceControlPoint.X;
            double offsetDistanceY = targetControlPoint.Y - sourceControlPoint.Y;

            BaseShape baseShape = BaseShape.TranslateByOffset(sourceFeature.GetShape(), offsetDistanceX, offsetDistanceY, GeographyUnit.Meter, DistanceUnit.Meter);

            baseShape.Id = sourceFeature.Id;

            Feature returnFeature = new Feature(baseShape, sourceFeature.ColumnValues);

            OnFeatureDragged(new FeatureDraggedEditInteractiveOverlayEventArgs(returnFeature));

            return(returnFeature);
        }
示例#25
0
        /// <summary>
        /// Occurs during the randomizing process
        /// </summary>
        /// <param name="generator"></param>
        protected override void OnRandomize(Random generator)
        {
            _color = generator.NextColor();
            Opacity = generator.NextFloat();
            _pointShape = generator.NextEnum<PointShape>();

            base.OnRandomize(generator);
        }
示例#26
0
        protected override void DrawCore(IEnumerable <Feature> features, GeoCanvas canvas, Collection <SimpleCandidate> labelsInThisLayer, Collection <SimpleCandidate> labelsInAllLayers)
        {
            double resolution = Math.Max(canvas.CurrentWorldExtent.Width / canvas.Width, canvas.CurrentWorldExtent.Height / canvas.Height);

            foreach (var feature in features)
            {
                PointShape pointShape = feature.GetShape() as PointShape;
                if (pointShape != null)
                {
                    float  screenOffsetX = (float)((pointShape.X - canvas.CurrentWorldExtent.UpperLeftPoint.X) / resolution);
                    float  screenOffsetY = (float)((canvas.CurrentWorldExtent.UpperLeftPoint.Y - pointShape.Y) / resolution);
                    string angle         = feature.ColumnValues[angleColumn];
                    string level         = feature.ColumnValues[windLevelColumn];
                    int    windLevel     = int.Parse(level);

                    ScreenPointF[] directionLine = null;
                    ScreenPointF[] levelLine1    = null;
                    ScreenPointF[] levelLine2    = null;

                    if (!string.IsNullOrEmpty(angle))
                    {
                        double radian1 = double.Parse(angle) * Math.PI / 180;
                        float  x1      = (float)(directionLineLength1 * Math.Cos(radian1));
                        float  y1      = (float)(directionLineLength1 * Math.Sin(radian1));

                        double radian2 = (double.Parse(angle) - 90) * Math.PI / 180;
                        float  x2      = (float)(directionLineLength2 * Math.Cos(radian2));
                        float  y2      = (float)(directionLineLength2 * Math.Sin(radian2));

                        float x3 = (float)((directionLineLength1 - 8) * Math.Cos(radian1));
                        float y3 = (float)((directionLineLength1 - 8) * Math.Sin(radian1));

                        float x4 = (float)(directionLineLength2 * Math.Cos(radian2));
                        float y4 = (float)(directionLineLength2 * Math.Sin(radian2));

                        if (windLevel >= 1)
                        {
                            directionLine    = new ScreenPointF[2];
                            directionLine[0] = new ScreenPointF(screenOffsetX, screenOffsetY);
                            directionLine[1] = new ScreenPointF(screenOffsetX + x1, screenOffsetY + y1);
                        }

                        if (windLevel >= 2)
                        {
                            levelLine1    = new ScreenPointF[2];
                            levelLine1[0] = new ScreenPointF(screenOffsetX + x1, screenOffsetY + y1);
                            levelLine1[1] = new ScreenPointF(screenOffsetX + x1 + x2, screenOffsetY + y1 + y2);
                        }

                        if (windLevel >= 3)
                        {
                            levelLine2    = new ScreenPointF[2];
                            levelLine2[0] = new ScreenPointF(screenOffsetX + x3, screenOffsetY + y3);
                            levelLine2[1] = new ScreenPointF(screenOffsetX + x3 + x4, screenOffsetY + y3 + y4);
                        }
                    }

                    // draw back
                    canvas.DrawEllipse(feature, 26, 26, blackBrush, DrawingLevel.LevelOne);
                    if (directionLine != null)
                    {
                        canvas.DrawLine(directionLine, outlinePen, DrawingLevel.LevelOne, 0, 0);
                    }
                    if (levelLine1 != null)
                    {
                        canvas.DrawLine(levelLine1, outlinePen, DrawingLevel.LevelOne, 0, 0);
                    }
                    if (levelLine2 != null)
                    {
                        canvas.DrawLine(levelLine2, outlinePen, DrawingLevel.LevelOne, 0, 0);
                    }

                    //draw fore
                    canvas.DrawEllipse(feature, 24, 24, fillBrush, DrawingLevel.LevelTwo);
                    if (directionLine != null)
                    {
                        canvas.DrawLine(directionLine, innerlinePen, DrawingLevel.LevelTwo, 0, 0);
                    }
                    if (levelLine1 != null)
                    {
                        canvas.DrawLine(levelLine1, innerlinePen, DrawingLevel.LevelTwo, 0, 0);
                    }
                    if (levelLine2 != null)
                    {
                        canvas.DrawLine(levelLine2, innerlinePen, DrawingLevel.LevelTwo, 0, 0);
                    }

                    string text = feature.ColumnValues[textColumn];
                    if (!string.IsNullOrEmpty(text))
                    {
                        canvas.DrawTextWithScreenCoordinate(text, font, textBrush, screenOffsetX, screenOffsetY, DrawingLevel.LabelLevel);
                    }
                }
            }
        }
        private void InitGridDefinition()
        {
            var entity = content.DataContext as GridWizardShareObject;

            RectangleShape gridExtent = new RectangleShape();
            List <Feature> features   = new List <Feature>();

            entity.SelectedFeatureLayer.SafeProcess(() =>
            {
                if (entity.HasSelectedFeatures && entity.OnlyUseSelectedFeatures)
                {
                    features   = GisEditor.SelectionManager.GetSelectedFeatures().Where(f => f.Tag != null && f.Tag == entity.SelectedFeatureLayer).ToList();
                    gridExtent = ExtentHelper.GetBoundingBoxOfItems(features);
                    gridExtent.ScaleUp(0.05);
                }
                else
                {
                    features   = entity.SelectedFeatureLayer.FeatureSource.GetAllFeatures(entity.SelectedFeatureLayer.FeatureSource.GetDistinctColumnNames()).ToList();
                    gridExtent = ExtentHelper.GetBoundingBoxOfItems(features);
                }
            });

            Dictionary <PointShape, double> dataPoints = new Dictionary <PointShape, double>();

            foreach (var item in features)
            {
                double columnValue = double.NaN;
                if (double.TryParse(item.ColumnValues[entity.SelectedDataColumn.ColumnName], out columnValue))
                {
                    var shape = item.GetShape();
                    if (shape.GetType().Equals(typeof(MultipointShape)))
                    {
                        foreach (var point in ((MultipointShape)shape).Points)
                        {
                            point.Tag = null;
                            dataPoints.Add(point, columnValue);
                        }
                    }
                    else
                    {
                        PointShape pointShape = (PointShape)shape;
                        pointShape.Tag = null;
                        dataPoints.Add(pointShape, columnValue);
                    }
                }
            }

            double tmpCellSize = 0.0;

            switch (GisEditor.ActiveMap.MapUnit)
            {
            case GeographyUnit.DecimalDegree:
                tmpCellSize = DecimalDegreesHelper.GetLongitudeDifferenceFromDistance(entity.CellSize, entity.SelectedCellSizeDistanceUnit, gridExtent.GetCenterPoint().Y);
                break;

            case GeographyUnit.Feet:
                tmpCellSize = Conversion.ConvertMeasureUnits(entity.CellSize, entity.SelectedCellSizeDistanceUnit, DistanceUnit.Feet);
                break;

            case GeographyUnit.Meter:
                tmpCellSize = Conversion.ConvertMeasureUnits(entity.CellSize, entity.SelectedCellSizeDistanceUnit, DistanceUnit.Meter);
                break;

            default:
                break;
            }

            entity.GridDefinition = new GridDefinition(gridExtent, tmpCellSize, -9999, dataPoints);
        }
示例#28
0
 /// <summary>
 /// Creates a simple point category where the symbolizer is based on the simple characteristics.
 /// The selection symbolizer has the same shape and size, but will be colored cyan.
 /// </summary>
 /// <param name="color">The color of the regular symbolizer</param>
 /// <param name="shape">The shape of the regular symbolizer</param>
 /// <param name="size">the size of the regular symbolizer</param>
 public PointCategory(Color color, PointShape shape, double size)
 {
     Symbolizer = new PointSymbolizer(color, shape, size);
     SelectionSymbolizer = new PointSymbolizer(Color.Cyan, shape, size);
 }
        private object ReverseDirection(PointShape shape, PanDirection direction)
        {
            PanDirection newDirection = PanDirection.Down;

            switch (direction)
            {
                case PanDirection.Up:
                    newDirection = PanDirection.Down;
                    break;
                case PanDirection.UpperRight:
                    newDirection = PanDirection.LowerLeft;
                    break;
                case PanDirection.Right:
                    newDirection = PanDirection.Left;
                    break;
                case PanDirection.LowerRight:
                    newDirection = PanDirection.UpperLeft;
                    break;
                case PanDirection.Down:
                    newDirection = PanDirection.Up;
                    break;
                case PanDirection.LowerLeft:
                    newDirection = PanDirection.UpperRight;
                    break;
                case PanDirection.Left:
                    newDirection = PanDirection.Right;
                    break;
                case PanDirection.UpperLeft:
                    newDirection = PanDirection.LowerRight;
                    break;
                default:
                    break;
            }

            UpdatePointShape(shape, newDirection);

            return newDirection;
        }
示例#30
0
        public static int GetLevelByCellWidth(RectangleShape extent, GeographyUnit extentMapUnit, double cellWidth, DistanceUnit widthDistanceUnit)
        {
            PointShape centerPoint = extent.GetCenterPoint();

            PointShape centerLeft = new PointShape(extent.LowerLeftPoint.X, centerPoint.Y);
            PointShape centerRight = new PointShape(extent.UpperRightPoint.X, centerPoint.Y);
            PointShape centerUpper = new PointShape(centerPoint.X, extent.UpperLeftPoint.Y);
            PointShape centerLower = new PointShape(centerPoint.X, extent.LowerLeftPoint.Y);

            double centerWidth = centerLeft.GetDistanceTo(centerRight, extentMapUnit, widthDistanceUnit);
            double centerHeight = centerUpper.GetDistanceTo(centerLower, extentMapUnit, widthDistanceUnit);

            double longestEdge = Math.Max(centerWidth, centerHeight);

            double level = Math.Round(2 * Math.Log((longestEdge / cellWidth), 4) + 1);

            return (int)level;
        }
 private void UpdatePointShape(PointShape shape, PanDirection direction)
 {
     switch (direction)
     {
         case PanDirection.Up:
             shape.Y++;
             break;
         case PanDirection.UpperRight:
             shape.X++;
             shape.Y++;
             break;
         case PanDirection.Right:
             shape.X++;
             break;
         case PanDirection.LowerRight:
             shape.X++;
             shape.Y--;
             break;
         case PanDirection.Down:
             shape.Y--;
             break;
         case PanDirection.LowerLeft:
             shape.X--;
             shape.Y--;
             break;
         case PanDirection.Left:
             shape.X--;
             break;
         case PanDirection.UpperLeft:
             shape.X--;
             shape.Y++;
             break;
         default:
             break;
     }
 }
示例#32
0
        private static RectangleShape SquaredExtent(RectangleShape extent)
        {
            PointShape center = extent.GetCenterPoint();

            double extentWidth = extent.LowerRightPoint.X - extent.LowerLeftPoint.X;
            double extentHeight = extent.UpperLeftPoint.Y - extent.LowerLeftPoint.Y;

            double halfEdgeLength = (extentWidth > extentHeight) ? extentWidth / 2 : extentHeight / 2;

            PointShape upperLeft = new PointShape(center.X - halfEdgeLength, center.Y + halfEdgeLength);
            PointShape lowerRight = new PointShape(center.X + halfEdgeLength, center.Y - halfEdgeLength);

            return new RectangleShape(upperLeft, lowerRight);
        }
        private PointShape GetRandomPoint(RectangleShape currentExtent)
        {
            double x = random.Next((int)currentExtent.UpperLeftPoint.X, (int)currentExtent.LowerRightPoint.X);
            double y = random.Next((int)currentExtent.LowerRightPoint.Y, (int)currentExtent.UpperLeftPoint.Y);

            PointShape pointShape = new PointShape(x, y);

            return pointShape;
        }
示例#34
0
 /// <summary>
 /// Creates a point symbol with the specified color and shape.
 /// </summary>
 /// <param name="color">The color of the symbol.</param>
 /// <param name="shape">The shape of the symbol.</param>
 public SimpleSymbol(Color color, PointShape shape)
 {
     Configure();
     _color = color;
     _pointShape = shape;
 }
        private void FilterEarthquake()
        {
            FilteredQueryResults.Clear();

            ManagedProj4Projection mercatorToWgs84Projection = new ManagedProj4Projection();
            mercatorToWgs84Projection.InternalProjectionParametersString = ManagedProj4Projection.GetSphericalMercatorParametersString();
            mercatorToWgs84Projection.ExternalProjectionParametersString = ManagedProj4Projection.GetDecimalDegreesParametersString();
            mercatorToWgs84Projection.Open();

            for (int i = queryResults.Count - 1; i >= 0; i--)
            {
                EarthquakeViewModel resultItem = queryResults[i];

                double latitude, longitude;
                if (double.TryParse(resultItem.Latitude, out latitude) && double.TryParse(resultItem.Longitude, out longitude))
                {
                    PointShape point = new PointShape(longitude, latitude);
                    point = (PointShape)mercatorToWgs84Projection.ConvertToExternalProjection(point);

                    EarthquakeViewModel newResultItem = new EarthquakeViewModel(resultItem.EpicenterFeature);
                    newResultItem.Latitude = point.Y.ToString("f3", CultureInfo.InvariantCulture);
                    newResultItem.Longitude = point.X.ToString("f3", CultureInfo.InvariantCulture);

                    double year, depth, magnitude;
                    double.TryParse(newResultItem.Magnitude, out magnitude);
                    double.TryParse(newResultItem.DepthInKilometer, out depth);
                    double.TryParse(newResultItem.Year, out year);

                    if ((magnitude >= queryFilter.StartMagnitudeRange && magnitude <= queryFilter.EndMagnitudeRange || newResultItem.Magnitude == Resources.UnknownString)
                        && (depth <= queryFilter.EndDepthRange && depth >= queryFilter.StartDepthRange || newResultItem.DepthInKilometer == Resources.UnknownString)
                        && (year >= queryFilter.StartYearRange && year <= queryFilter.EndYearRange) || newResultItem.Year == Resources.UnknownString)
                    {
                        FilteredQueryResults.Add(newResultItem);
                    }
                }
            }

            mercatorToWgs84Projection.Close();
            mapModel.RefreshMarkersByFeatures(FilteredQueryResults.Select(f => f.EpicenterFeature));
        }
示例#36
0
 private void Configure()
 {
     base.SymbolType = SymbolType.Simple;
     _color = SymbologyGlobal.RandomColor();
     _pointShape = PointShape.Rectangle;
 }
示例#37
0
        private void RefreshQueryResultData()
        {
            if (queryResultView.Hidden)
            {
                queryResultView.AnimatedShow();
            }
            DataTableSource earthquakeSource;

            if (tbvQueryResult.Source == null)
            {
                earthquakeSource          = new DataTableSource();
                earthquakeSource.RowClick = EarthquakeRowClicked;
            }
            else
            {
                earthquakeSource = (DataTableSource)tbvQueryResult.Source;
            }
            earthquakeSource.Sections.Clear();

            Proj4Projection mercatorToWgs84Projection = Global.GetWgs84ToMercatorProjection();

            mercatorToWgs84Projection.Open();

            try
            {
                Global.FilterSelectedEarthquakeFeatures();

                InMemoryFeatureLayer selectMarkerLayer = (InMemoryFeatureLayer)Global.HighLightOverlay.Layers["SelectMarkerLayer"];

                GeoCollection <Feature> selectFeatures = selectMarkerLayer.InternalFeatures;

                SectionModel detailSection = new SectionModel("Queried Count: " + selectFeatures.Count);
                detailSection.HeaderHeight = 50;
                foreach (var feature in selectFeatures)
                {
                    double longitude, latitude = 0;

                    if (double.TryParse(feature.ColumnValues["LONGITUDE"], out longitude) && double.TryParse(feature.ColumnValues["LATITIUDE"], out latitude))
                    {
                        PointShape point = new PointShape(longitude, latitude);
                        point     = (PointShape)mercatorToWgs84Projection.ConvertToInternalProjection(point);
                        longitude = point.X;
                        latitude  = point.Y;
                    }

                    double year, depth, magnitude;
                    double.TryParse(feature.ColumnValues["MAGNITUDE"], out magnitude);
                    double.TryParse(feature.ColumnValues["DEPTH_KM"], out depth);
                    double.TryParse(feature.ColumnValues["YEAR"], out year);

                    EarthquakeRow result = new EarthquakeRow();

                    result.YearValue      = year != -9999 ? year.ToString(CultureInfo.InvariantCulture) : "Unknown";
                    result.LocationValue  = longitude.ToString("f2", CultureInfo.InvariantCulture);
                    result.LatitudeValue  = latitude.ToString("f2", CultureInfo.InvariantCulture);
                    result.DepthValue     = depth != -9999 ? depth.ToString(CultureInfo.InvariantCulture) : "Unknown";
                    result.MagnitudeValue = magnitude != -9999 ? magnitude.ToString(CultureInfo.InvariantCulture) : "Unknown";
                    result.LocationValue  = feature.ColumnValues["LOCATION"];

                    detailSection.Rows.Add(new RowModel(result.ToString(), new UIImageView(UIImage.FromBundle("location"))));
                }
                earthquakeSource.Sections.Add(detailSection);

                tbvQueryResult.Source = earthquakeSource;
                tbvQueryResult.ReloadData();
            }
            finally
            {
                mercatorToWgs84Projection.Close();
            }
        }