Beispiel #1
0
        public static IEnumerable<DPoint> getRoutePoints(string route_guid)
        {
            List<DPoint> pntsList = new System.Collections.Generic.List<DPoint>();
            string sql = "select * from routes_points where route_guid='" + route_guid + "' order by point_num";

            using (NpgsqlConnection connection = new NpgsqlConnection(strPostGISConnection))
            using (NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, connection))
            {
                DataSet ds = new DataSet();
                DataTable dt = new DataTable();
                ds.Reset();
                da.Fill(ds);
                dt = ds.Tables[0];

                if (dt == null || dt.Rows == null || dt.Rows.Count == 0)
                {
                    return null;
                }

                foreach (DataRow row in dt.Rows)
                {

                    DPoint mp = new DPoint();
                    mp.x = System.Convert.ToDouble(row["pointx"]);
                    mp.y = System.Convert.ToDouble(row["pointy"]);
                    pntsList.Add(mp);
                }
            }


            return pntsList;
        }
Beispiel #2
0
        public override void MouseClick(object sender, MouseEventArgs e)
        {
            if (map.InsertionLayer == null) return;

            CoordSys layerCoordsys = map.InsertionLayer.LayerCoordSys;

            CoordConverter oCC = new CoordConverter();
            oCC.Init(layerCoordsys, map.DisplayCoordSys);

            // this atPan converts DisplayCoordSys into Screen CoordSys[px]
            // DisplayCoordSys has Y axis up (unless its AT does not change it)
            // Screen Y axis is down
            AffineTransform atPan = new AffineTransform();
            atPan.OffsetInPlace((double)map.MapOffsetX, (double)map.MapOffsetY);
            atPan.MultiplyInPlace(map.MapScale, -map.MapScale);

            // add screen scale and offset transformation
            oCC.atMaster = oCC.atMaster.Compose(atPan);

            oCC.ConvertInverse(e.X, e.Y);

            DPoint pt = new DPoint(oCC.X, oCC.Y);
            // szukaj w tym miejscu feature
            List<Feature> ftrs = map.InsertionLayer.Search(pt);

            if (ftrs.Count == 0)
            {
                Feature oF = FeatureFactory.CreateSymbol(oCC.X, oCC.Y);
                map.InsertionLayer.FeaturesAdd(oF);
            }

            MapControl.Globals.Instance.MapControl.InvalidateMap();
        }
Beispiel #3
0
        public void recordMovePoint(DPoint point, DPoint newPoint)
        {
            undoElementCurrent.movePoint(point, new DPoint(point));

            point.X = newPoint.X;
            point.Y = newPoint.Y;
        }
Beispiel #4
0
        // create a straight line route from source to dest
        public static Route createRoute(DPoint source, DPoint dest)
        {
            List<DPoint> points = new List<DPoint>();
            points.Add(source);
            points.Add(dest);

            return createRoute(points);
        }
Beispiel #5
0
        public EmfGraphics(DRect bounds, DPoint screenMM, DPoint deviceRes)
        {
            this.screenMM = screenMM;
            this.deviceRes = deviceRes;

            // create memory stream
            ms = new MemoryStream();
            // write header
            Emf.MetafileHeaderExtension2 h = new Emf.MetafileHeaderExtension2();
            h.EmfHeader.Type = 1;
            h.EmfHeader.Size = (uint)Marshal.SizeOf(typeof(Emf.MetafileHeaderExtension2));
            h.EmfHeader.Bounds = new Emf.RectL((int)bounds.X, (int)bounds.Y, (int)bounds.Right, (int)bounds.Bottom);
            double pixelWidth = screenMM.X / deviceRes.X;
            double pixelHeight = screenMM.Y / deviceRes.Y;
            h.EmfHeader.Frame = new Emf.RectL((int)(bounds.X * 100 * pixelWidth),
                (int)(bounds.Y * 100 * pixelHeight),
                (int)(bounds.Right * 100 * pixelWidth),
                (int)(bounds.Bottom * 100 * pixelHeight));
            h.EmfHeader.Signature = (uint)Emf.FormatSignature.ENHMETA_SIGNATURE;
            h.EmfHeader.Version = 0x00010000;
            h.EmfHeader.Bytes = 0; // size of metafile (set later on)
            h.EmfHeader.Records = 0; // num of records in metafile (set later on)
            h.EmfHeader.Handles = 0; // max number of gdi objects used at one time (set later on)
            h.EmfHeader.Reserved = 0;
            h.EmfHeader.nDescription = 0;
            h.EmfHeader.offDescription = 0;
            h.EmfHeader.nPalEntries = 0; // set later on
            h.EmfHeader.Device = new Wmf.SizeL((uint)deviceRes.X, (uint)deviceRes.Y);
            h.EmfHeader.Millimeters = new Wmf.SizeL((uint)screenMM.X, (uint)screenMM.Y);
            h.EmfHeaderExtension1.cbPixelFormat = 0;
            h.EmfHeaderExtension1.offPixelFormat = 0;
            h.EmfHeaderExtension1.bOpenGL = 0;
            h.EmfHeaderExtension2.MicrometersX = (uint)(screenMM.X * 1000);
            h.EmfHeaderExtension2.MicrometersY = (uint)(screenMM.Y * 1000);
            byte[] data = RawSerialize(h);
            ms.Write(data, 0, data.Length);

            WriteRecordHeader(Emf.RecordType.EMR_SETMAPMODE, 12);
            WriteUInt(0x08); // MM_ANISOTROPIC

            WriteRecordHeader(Emf.RecordType.EMR_SETWINDOWORGEX, 16);
            WritePointL(new Wmf.PointL(h.EmfHeader.Bounds.Left, h.EmfHeader.Bounds.Top));
            WriteRecordHeader(Emf.RecordType.EMR_SETWINDOWEXTEX, 16);
            WriteSizeL(new Wmf.SizeL((uint)(h.EmfHeader.Bounds.Right - h.EmfHeader.Bounds.Left),
                (uint)(h.EmfHeader.Bounds.Bottom - h.EmfHeader.Bounds.Top)));
            WriteRecordHeader(Emf.RecordType.EMR_SETVIEWPORTORGEX, 16);
            WritePointL(new Wmf.PointL(h.EmfHeader.Bounds.Left, h.EmfHeader.Bounds.Top));
            WriteRecordHeader(Emf.RecordType.EMR_SETVIEWPORTEXTEX, 16);
            WriteSizeL(new Wmf.SizeL((uint)(h.EmfHeader.Bounds.Right - h.EmfHeader.Bounds.Left),
                (uint)(h.EmfHeader.Bounds.Bottom - h.EmfHeader.Bounds.Top)));

            WriteRecordHeader(Emf.RecordType.EMR_SETBKMODE, 12);
            WriteUInt(0x01); // TRANSPARENT
            WriteRecordHeader(Emf.RecordType.EMR_SETTEXTALIGN, 12);
            WriteUInt(Wmf.TA_LEFT | Wmf.TA_TOP);
        }
Beispiel #6
0
 protected override DHitTest BodyHitTest(DPoint pt, List<Figure> children)
 {
     DPoints pts = DrawPoints();
     if (Fill.IsEmpty)
     {
         if (DGeom.PointInPolyline(pt, pts, SwHalf + noFillThresh))
             return DHitTest.Body;
     }
     else if (DGeom.PointInPolygon(pt, pts) || DGeom.PointInPolyline(pt, pts, SwHalf))
         return DHitTest.Body;
     return DHitTest.None;
 }
Beispiel #7
0
 public static DRect BoundingBoxOfRotatedRect(DRect rect, double angle, DPoint origin)
 {
     if (angle == 0)
         return rect;
     DPoint p1 = RotatePoint(rect.TopLeft, origin, angle);
     DPoint p2 = RotatePoint(rect.TopRight, origin, angle);
     DPoint p3 = RotatePoint(rect.BottomLeft, origin, angle);
     DPoint p4 = RotatePoint(rect.BottomRight, origin, angle);
     double x = Math.Min(Math.Min(p1.X, p2.X), Math.Min(p3.X, p4.X));
     double y = Math.Min(Math.Min(p1.Y, p2.Y), Math.Min(p3.Y, p4.Y));
     double right = Math.Max(Math.Max(p1.X, p2.X), Math.Max(p3.X, p4.X));
     double bottom = Math.Max(Math.Max(p1.Y, p2.Y), Math.Max(p3.Y, p4.Y));
     return new DRect(x, y, right - x, bottom - y);
 }
Beispiel #8
0
        public static typRoute planStraightLineRoute(DPoint source, DPoint dest, String routeName)
        {
            typRoute route = new typRoute();
            route.RouteName = routeName;
            route.arr_legs = new List<typLegSector>();

            typLegSector legSector = new typLegSector();
            legSector.FromLongn = source.x;
            legSector.FromLatn = source.y;
            legSector.ToLongn = dest.x;
            legSector.ToLatn = dest.y;
            legSector.LegDistance = (float)TerrainService.MathEngine.CalcDistance(legSector.FromLongn, legSector.FromLatn, legSector.ToLongn, legSector.ToLatn) / 1000f;
            route.arr_legs.Add(legSector);

            return route;
        }
Beispiel #9
0
        // find the index of the closest point in a route to a specific point
        public static int findClosestPointIndexInRoute(DPoint point, Route route)
        {
            double minDistance      = Double.MaxValue;
            int    minDistanceIndex = 0;

            for (int i = 0; i < route.Points.Count(); i++)
            {
                double distance = TerrainService.MathEngine.CalcDistance(point.x, point.y, route.Points.ElementAt(i).x, route.Points.ElementAt(i).y);

                if (distance < minDistance)
                {
                    minDistance      = distance;
                    minDistanceIndex = i;
                }
            }

            return(minDistanceIndex);
        }
Beispiel #10
0
        static SMapWorkRequest CreateWorkRequest(int jobId)
        {
            CanvasSize canvasSize = new CanvasSize(300, 200);
            DPoint     leftBot    = new DPoint(-2, -1);
            DPoint     rightTop   = new DPoint(1, 1);
            SCoords    coords     = new SCoords(new SPoint(leftBot), new SPoint(rightTop));
            MapSection area       = new MapSection(new Point(0, 0), canvasSize.GetWholeUnits(Engine.BLOCK_SIZE));

            int    maxIterations = 100;
            string connectionId  = "dummy";

            SMapWorkRequest mapWorkRequest = new SMapWorkRequest("FEngRunner", coords, canvasSize, area, maxIterations, connectionId)
            {
                JobId = jobId
            };

            return(mapWorkRequest);
        }
Beispiel #11
0
 public void PointTransformAffineM()
 {
     for (var x = -10d; x <= 10d; x += 0.5)
     {
         for (var y = -10d; y <= 10d; y += 0.5)
         {
             var matrix    = new Matrix <double>(2, 2);
             var vector    = new DPoint(x, y);
             var transform = new PointTransformAffine(matrix, vector);
             var m         = transform.M;
             Assert.Equal(m.MatrixElementType, MatrixElementTypes.Double);
             Assert.Equal(m.Rows, 2);
             Assert.Equal(m.Columns, 2);
             this.DisposeAndCheckDisposedState(m);
             this.DisposeAndCheckDisposedState(transform);
             this.DisposeAndCheckDisposedState(matrix);
         }
     }
 }
        //
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        /// <summary>
        /// Data from F200 / SMP40 temperature measurements
        /// Exel gives the following formula:
        /// y = -2E-05x2 + 1.0171x - 0.1298
        /// </summary>
        /// <returns></returns>
        DPoint[] realData()
        {
            DPoint[] points = new DPoint[] {
                new DPoint(49.98, 50.527d),
                new DPoint(59.98, 60.734d),
                new DPoint(69.98, 70.938d),
                new DPoint(79.99, 81.12d),
                new DPoint(89.99, 91.288d),
                new DPoint(99.99, 101.451d),
                new DPoint(110, 111.609d),
                new DPoint(119.98, 121.752d),
                new DPoint(129.99, 131.88d),
                new DPoint(139.98, 142.008d),
                new DPoint(149.99, 152.14d),
                new DPoint(159.99, 162.253d),
                new DPoint(169.99, 172.361d),
                new DPoint(179.99, 182.474d),
                new DPoint(190, 192.591d),
                new DPoint(199.99, 202.686d),
                new DPoint(209.99, 212.796d),
                new DPoint(219.99, 222.898d),
                new DPoint(229.99, 233.01d),
                new DPoint(239.99, 243.097d),
                new DPoint(249.99, 253.199d),
                new DPoint(259.99, 263.276d),
                new DPoint(270, 273.357d),
                new DPoint(279.99, 283.424d),
                new DPoint(289.98, 293.484d),
                new DPoint(300, 303.556d),
                new DPoint(310, 313.63d),
                new DPoint(319.99, 323.689d),
                new DPoint(330, 333.758d),
                new DPoint(340, 343.827d),
                new DPoint(349.98, 353.888d),
                new DPoint(359.99, 363.98d),
                new DPoint(370, 374.092d),
                new DPoint(379.98, 384.186d),
                new DPoint(390, 394.349d),
                new DPoint(399.99, 404.49d)
            };

            return(points);
        }
Beispiel #13
0
        private int getClosestExitPoint(clsGroundAtom refGroundAtom, clsPolygon Structure)
        {
            DPoint[] coordinates = refGroundAtom.m_GameObject.getRegularMovementCoordinates();
            DPoint   minPoint    = null;
            int      minIndex    = 0;

            for (int i = 0; i < coordinates.Count(); i++)
            {
                DPoint coordinate = coordinates[i];
                if (minPoint == null || TerrainService.MathEngine.CalcDistance(refGroundAtom.curr_X, refGroundAtom.curr_Y, coordinate.x, coordinate.y) <
                    TerrainService.MathEngine.CalcDistance(refGroundAtom.curr_X, refGroundAtom.curr_Y, minPoint.x, minPoint.y))
                {
                    minPoint = coordinate;
                    minIndex = i;
                }
            }

            return(minIndex);
        }
Beispiel #14
0
        public void OperatorEqual()
        {
            var x = (double)this.NextRandom(0, 100);
            var y = (double)this.NextRandom(0, 100);

            var r  = new DPoint(x, y);
            var l  = new DPoint(x, y);
            var l1 = new DPoint(x * 2, y);
            var l2 = new DPoint(x, y * 2);

            Assert.IsTrue(r == l, $"1 - RX: {r.X}, RY: {r.Y}\nLX: {l.X}, LY: {l.Y}");
            Assert.IsTrue(r != l1, $"2 - RX: {r.X}, RY: {r.Y}\nLX: {l1.X}, LY: {l1.Y}");
            Assert.IsTrue(r != l2, $"3 - RX: {r.X}, RY: {r.Y}\nLX: {l2.X}, LY: {l2.Y}");

            this.DisposeAndCheckDisposedState(l);
            this.DisposeAndCheckDisposedState(r);
            this.DisposeAndCheckDisposedState(l1);
            this.DisposeAndCheckDisposedState(l2);
        }
Beispiel #15
0
        public void CopyTo()
        {
            const int size   = 10;
            var       source = Enumerable.Range(0, size).Select(i => new DPoint(i, i));
            var       vector = new StdVector <DPoint>(source);

            Assert.Equal(vector.Size, size);
            var ret = new DPoint[15];

            vector.CopyTo(ret, 5);

            for (var i = 0; i < size; i++)
            {
                Assert.Equal(ret[i + 5].X, i);
                Assert.Equal(ret[i + 5].Y, i);
            }

            this.DisposeAndCheckDisposedState(vector);
        }
Beispiel #16
0
 public void PointTransformAffineB()
 {
     for (var x = -10d; x <= 10d; x += 0.5)
     {
         for (var y = -10d; y <= 10d; y += 0.5)
         {
             var matrix    = new Matrix <double>(2, 2);
             var vector    = new DPoint(x, y);
             var transform = new PointTransformAffine(matrix, vector);
             var b         = transform.B;
             Assert.AreEqual(b.X, x);
             Assert.AreEqual(b.Y, y);
             this.DisposeAndCheckDisposedState(b);
             this.DisposeAndCheckDisposedState(transform);
             this.DisposeAndCheckDisposedState(vector);
             this.DisposeAndCheckDisposedState(matrix);
         }
     }
 }
Beispiel #17
0
        public void doBuild(double range_max, double range_min)
        {
            _LJV7Frame.buffer         = _BufferList.ToArray();
            _LJV7Frame.size_per_frame = Convert.ToUInt32(_PointList.Count * _EACHSIZE);
            //_LJV7Frame.size_per_frame = Convert.ToUInt32(700);
            _LJV7Frame.count = _LJV7Frame.size_per_frame;
            _LJV7Frame.SetComputeBuffer();
            _LJV7Frame.DoWritePreByteFile("C:\\Users\\user\\Desktop\\3DModel.boltun", _LJV7Frame.buffer);

            _ShowPoints = null;
            GC.Collect();
            _ShowPoints = new DPoint[_LJV7Frame.buffer_compute.Length];
            for (int i = 0; i < _LJV7Frame.buffer_compute.Length; i++)
            {
                _ShowPoints[i] = new DPoint();
            }

            reBuild();
        }
Beispiel #18
0
    /// <summary>
    /// Возвращает индекс самого близкоого к точке игрока
    /// </summary>
    /// <param name="to">Точка</param>
    /// <param name="all">Игроки</param>
    /// <returns>Индекс в посланном массиве</returns>
    private static int closest(DPoint to, params DPoint[] all)
    {
        double[] dist = new double[all.Length];
        for (int i = 0; i < all.Length; i++)
        {
            dist[i] = Math.Sqrt(Math.Pow(all[i].X - to.X, 2) + Math.Pow(all[i].Y - to.Y, 2));
        }

        double min_dist = 200; int min_index = -1;

        for (int i = 0; i < all.Length; i++)
        {
            if (dist[i] < min_dist)
            {
                min_dist = dist[i]; min_index = i;
            }
        }
        return(min_index);
    }
Beispiel #19
0
 public void PointTransformAffineOperator()
 {
     for (var x = -10d; x <= 10d; x += 0.5)
     {
         for (var y = -10d; y <= 10d; y += 0.5)
         {
             var matrix    = new Matrix <double>(2, 2);
             var vector    = new DPoint(x, y);
             var transform = new PointTransformAffine(matrix, vector);
             var vector2   = new DPoint(x * 2, y * 2);
             var ret       = transform.Operator(vector2);
             this.DisposeAndCheckDisposedState(ret);
             this.DisposeAndCheckDisposedState(vector2);
             this.DisposeAndCheckDisposedState(transform);
             this.DisposeAndCheckDisposedState(vector);
             this.DisposeAndCheckDisposedState(matrix);
         }
     }
 }
Beispiel #20
0
        /// <summary>
        /// ABOD algorithm implement
        /// </summary>
        /// <param name="topK">topK points are outlier</param>
        public static void ABOD(int topK, String fpath, DateTime timeStart)
        {
            List <DPoint>  ABOFList = new List <DPoint>(LENGTH);
            List <DStatus> D        = new List <DStatus>(LENGTH);
            DStatusPacket  tmpPacket;
            DPoint         tmpPoint = new DPoint();
            DStatusPacket  A;
            double         ABOF_A;

            for (int i = 0; i < LENGTH; i++)
            {
                tmpPacket = data.getDataByID(i);
                D.Add(addIndexToPacket(i, tmpPacket));
            }
            for (int j = 0; j < D.Count(); j++)
            {
                A      = D[j];
                ABOF_A = ABOF(D, A, j);

                tmpPoint = new DPoint(A.ID, ABOF_A);
                ABOFList.Add(tmpPoint);
            }
            ABOFList.Sort();       // Sort ABOF list by ABOF value

            DateTime timeEnd = DateTime.Now;

            saveDPoint(ABOFList, fpath);
            saveOutlier(ABOFList, topK, fpath);

            string runTime = calcRunTime(timeStart, timeEnd);
            string str     = "======================================"
                             + "\r\nN\t" + LENGTH
                             + "\r\nK\t" + DIMENSION
                             + "\r\ntopK\t" + topK
                             + "\r\nStart Time\t" + timeStart.ToString("yyyy-MM-dd HH:mm:ss")
                             + "\r\nEnd Time\t" + timeEnd.ToString("yyyy-MM-dd HH:mm:ss")
                             + "\r\nRun Time\t" + runTime;

            strfprintf(str, fpath);

            Console.WriteLine("ABOD Accomplished!");
        }
        DPoint[] createPoints()
        {
            DPoint[] points = new DPoint[1000];
            int      index  = 0;

            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 100; j++)
                {
                    points[index] = new DPoint(index, j);
                    index++;
                }
                for (int j = 0; j < 100; j++)
                {
                    points[index] = new DPoint(index, 100 - j);
                    index++;
                }
            }
            return(points);
        }
        private MapSectionWorkResult BuildInitialWorkingValues(MapSectionWorkRequest mswr)
        {
            int width  = mswr.MapSection.CanvasSize.Width;
            int height = mswr.MapSection.CanvasSize.Height;

            int len = width * height;

            int[]    counts    = new int[len];
            bool[]   doneFlags = new bool[len];
            DPoint[] zValues   = new DPoint[len];

            for (int ptr = 0; ptr < len; ptr++)
            {
                zValues[ptr] = new DPoint(0, 0);
            }

            MapSectionWorkResult result = new MapSectionWorkResult(counts, mswr.MaxIterations, zValues, doneFlags);

            return(result);
        }
Beispiel #23
0
 public void PointTransformB()
 {
     for (var angle = -360d; angle <= 360d; angle += 2.5)
     {
         for (var x = -10d; x <= 10d; x += 0.5)
         {
             for (var y = -10d; y <= 10d; y += 0.5)
             {
                 var vector    = new DPoint(x, y);
                 var transform = new PointTransform(angle, vector);
                 var b         = transform.B;
                 Assert.AreEqual(b.X, x);
                 Assert.AreEqual(b.Y, y);
                 this.DisposeAndCheckDisposedState(b);
                 this.DisposeAndCheckDisposedState(transform);
                 this.DisposeAndCheckDisposedState(vector);
             }
         }
     }
 }
Beispiel #24
0
 public void PointTransformM()
 {
     for (var angle = -360d; angle <= 360d; angle += 2.5)
     {
         for (var x = -10d; x <= 10d; x += 0.5)
         {
             for (var y = -10d; y <= 10d; y += 0.5)
             {
                 var vector    = new DPoint(x, y);
                 var transform = new PointTransform(angle, vector);
                 var m         = transform.M;
                 Assert.Equal(m.MatrixElementType, MatrixElementTypes.Double);
                 Assert.Equal(m.Rows, 2);
                 Assert.Equal(m.Columns, 2);
                 this.DisposeAndCheckDisposedState(m);
                 this.DisposeAndCheckDisposedState(transform);
             }
         }
     }
 }
Beispiel #25
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="oMap"></param>
        /// <param name="strLayer"></param>
        /// <param name="strUID"></param>
        /// <param name="strName"></param>
        /// <param name="dPoint"></param>
        /// <param name="nCode"></param>
        /// <param name="dbCodeSize"></param>
        /// <param name="color"></param>
        /// <returns></returns>
        public static bool AddMarker(Map oMap,
                                     string strLayer,
                                     string strUID,
                                     string strText,
                                     DPoint dPoint,
                                     int nCode,
                                     double dbCodeSize,
                                     System.Drawing.Color color)
        {
            if (oMap == null)
            {
                return(false);
            }
            FeatureLayer layer = oMap.Layers[strLayer] as FeatureLayer;

            if (layer == null)
            {
                return(false);
            }

            //创建点图元及其样式
            FeatureGeometry fg = new Point(oMap.GetDisplayCoordSys(), dPoint);
            CompositeStyle  cs = new MapInfo.Styles.CompositeStyle(new SimpleVectorPointStyle((short)nCode, color, dbCodeSize));


            Feature feature = new Feature(layer.Table.TableInfo.Columns);

            feature.Geometry = fg;
            feature.Style    = cs;
            feature["uid"]   = strUID;
            feature["name"]  = strText;

            //fg.GetGeometryEditor().Rotate(dPoint, 90);
            //fg.EditingComplete();
            //MapInfo.Geometry.IGeometryEdit edit = feature.Geometry.GetGeometryEditor();
            //edit.OffsetByAngle(90, 500, MapInfo.Geometry.DistanceUnit.Meter, MapInfo.Geometry.DistanceType.Spherical);
            //edit.Geometry.EditingComplete();

            layer.Table.InsertFeature(feature);
            return(true);
        }
Beispiel #26
0
        public static DPoint GetPoint(FloatRect rect, VerticalPostion verticalPostion = VerticalPostion.Center, HorizontalPosition horizontalPosition = HorizontalPosition.Center)
        {
            double x = 0;
            double y = 0;

            switch (verticalPostion)
            {
            case VerticalPostion.Top:
                y = rect.Y;
                break;

            case VerticalPostion.Center:
            case VerticalPostion.Unspecified:
                y = rect.Y + rect.Height / 2.0;
                break;

            case VerticalPostion.Bottom:
                y = rect.Y + rect.Height;
                break;
            }

            switch (horizontalPosition)
            {
            case HorizontalPosition.Left:
                x = rect.X;
                break;

            case HorizontalPosition.Center:
            case HorizontalPosition.Unspecified:
                x = rect.X + rect.Width / 2.0;
                break;

            case HorizontalPosition.Right:
                x = rect.X + rect.Width;
                break;
            }

            var point = new DPoint(x, y);

            return(point);
        }
Beispiel #27
0
        // Plan a straight line route
        public static typRoute planStraightLineRoute(DPoint source, DPoint dest, String routeName)
        {
            typRoute route = new typRoute();

            route.RouteName = routeName;
            route.arr_legs  = new List <typLegSector>();

            // only one leg exists in a straight line
            typLegSector legSector = new typLegSector();

            legSector.FromLongn   = source.x;
            legSector.FromLatn    = source.y;
            legSector.ToLongn     = dest.x;
            legSector.ToLatn      = dest.y;
            legSector.LegDistance = (float)TerrainService.MathEngine.CalcDistance(legSector.FromLongn, legSector.FromLatn, legSector.ToLongn, legSector.ToLatn) / 1000f;

            // add the leg to the route
            route.arr_legs.Add(legSector);

            return(route);
        }
Beispiel #28
0
        private ApCell GetCell(int x, int y, double[] XValues, double[] YValues)
        {
            DPoint refC = new DPoint(XValues[x], YValues[y]);

            ApDetail[] details = new ApDetail[8];

            details[0] = new ApDetail(refC - new DPoint(XValues[x - 1], YValues[y - 1]));
            details[1] = new ApDetail(refC - new DPoint(XValues[x], YValues[y - 1]));
            details[2] = new ApDetail(refC - new DPoint(XValues[x + 1], YValues[y - 1]));

            details[3] = new ApDetail(refC - new DPoint(XValues[x - 1], YValues[y]));
            details[4] = new ApDetail(refC - new DPoint(XValues[x + 1], YValues[y]));

            details[5] = new ApDetail(refC - new DPoint(XValues[x - 1], YValues[y + 1]));
            details[6] = new ApDetail(refC - new DPoint(XValues[x], YValues[y + 1]));
            details[7] = new ApDetail(refC - new DPoint(XValues[x + 1], YValues[y + 1]));

            ApCell result = new ApCell(refC, details);

            return(result);
        }
Beispiel #29
0
        private double GetEscapeVelocity(DPoint z, DPoint c, double xSquared, double ySquared)
        {
            _z2.X = z.X;
            _z2.Y = z.Y;

            for (_cntr2 = 0; _cntr2 < 25; _cntr2++)
            {
                _z2.Y = 2 * _z2.X * _z2.Y + c.Y;
                _z2.X = xSquared - ySquared + c.X;

                xSquared = _z2.X * _z2.X;
                ySquared = _z2.Y * _z2.Y;

                if ((xSquared + ySquared) > THRESHOLD)
                {
                    return(GetEscapeVelocity(xSquared + ySquared));
                }
            }

            return(0);
        }
Beispiel #30
0
        static void Seventh()
        {
            Console.WriteLine("Введите координаты первой точки");
            string[] input = Console.ReadLine().Split(' ');
            DPoint   p1    = new DPoint(int.Parse(input[0]), int.Parse(input[1]));

            Console.WriteLine("Введите координаты второй точки");
            input = Console.ReadLine().Split(' ');
            DPoint p2 = new DPoint(int.Parse(input[0]), int.Parse(input[1]));

            Console.WriteLine("Введите координаты третьей точки");
            input = Console.ReadLine().Split(' ');
            DPoint p3 = new DPoint(int.Parse(input[0]), int.Parse(input[1]));
            double ma = (p2.y + -p1.y) / (p2.x - p1.x);
            double mb = (p3.y - p2.y) / (p3.x - p2.x);
            double x  = (ma * mb * (p1.y - p3.y) + mb * (p1.x + p2.x) - ma * (p2.x + p3.x)) / (2 * mb - 2 * ma);
            double y  = (-1 / ma) * (x - (p1.x + p2.x) / 2) + (p1.y + p2.y) / 2;
            double r  = Range(p1.x, p1.y, x, y);

            Console.WriteLine("(x-{0})^2+(y-{1})^2={2}^2", x, y, r);
        }
Beispiel #31
0
        public IList <string> SaveAllFacesImages(string folderName)
        {
            List <string> imagesPathes = new List <string>();

            string folderPath = Path.Combine(PathSystem.OutputsPath, folderName);

            if (File.Exists(folderPath) == true)
            {
                File.Delete(folderPath);                                  // Check for exist file with same name and delet him
            }
            if (Directory.Exists(folderPath) == false)
            {
                Directory.CreateDirectory(folderPath);                                        // Check for exist directory with same name and create her
            }
            using (var faceDetector = Dlib.GetFrontalFaceDetector())
            {
                var faces = faceDetector.Operator(Image); // Detect all faces
                for (int i = 0; i < faces.Length; i++)
                {
                    string imageName = $"face[{i}].jpg";;                   // Create image name
                    string imagePath = Path.Combine(folderPath, imageName); // Create image path

                    DPoint[] dPoints = new DPoint[4]                        // Create box points
                    {
                        new DPoint(faces[i].TopLeft.X, faces[i].TopLeft.Y),
                        new DPoint(faces[i].TopRight.X, faces[i].TopRight.Y),
                        new DPoint(faces[i].BottomRight.X, faces[i].BottomRight.Y),
                        new DPoint(faces[i].BottomLeft.X, faces[i].BottomLeft.Y),
                    };

                    //Extract face box
                    var face = Dlib.ExtractImage4Points(Image, dPoints, (int)faces[i].Width, (int)faces[i].Height);

                    imagesPathes.Add(imagePath);
                    Dlib.SaveJpeg(face, imagePath); // Save face image to image path
                }
            }

            return(imagesPathes); // Return faces images pathes list
        }
Beispiel #32
0
        public override void MouseMove(object sender, MouseEventArgs e)
        {
            base.MouseMove(sender, e);

            // highlight polilines and points

            if (map.InsertionLayer == null) return;

            CoordSys layerCoordsys = map.InsertionLayer.LayerCoordSys;

            CoordConverter oCC = new CoordConverter();
            oCC.Init(layerCoordsys, map.DisplayCoordSys);

            // this atPan converts DisplayCoordSys into Screen CoordSys[px]
            // DisplayCoordSys has Y axis up (unless its AT does not change it)
            // Screen Y axis is down
            AffineTransform atPan = new AffineTransform();
            atPan.OffsetInPlace((double)map.MapOffsetX, (double)map.MapOffsetY);
            atPan.MultiplyInPlace(map.MapScale, -map.MapScale);

            // add screen scale and offset transformation
            oCC.atMaster = oCC.atMaster.Compose(atPan);

            int margin = 5;

            oCC.ConvertInverse(e.X, e.Y);
            DPoint pt_center = new DPoint(oCC.X, oCC.Y);
            oCC.ConvertInverse(e.X - margin, e.Y - margin);
            DPoint pt1 = new DPoint(oCC.X, oCC.Y);
            oCC.ConvertInverse(e.X + margin, e.Y + margin);
            DPoint pt2 = new DPoint(oCC.X, oCC.Y);
            // szukaj w tym miejscu feature
            //List<Feature> ftrs = map.InsertionLayer.Search(pt);

            // construct search rectangle (10px wide)
            DRect rect = new DRect(pt1.X, pt2.Y, pt2.X, pt1.Y);

            //map.InsertionLayer.SelectWithinRectangle(rect);
        }
        /// <summary>
        /// Возвращает массив углов (shoulder, elbow, wrist),
        /// необходимых для приведения эффектора манипулятора в точку x и y
        /// с углом между последним суставом и горизонталью, равному angle (в радианах)
        /// См. чертеж manipulator.png!
        /// </summary>
        public static double[] MoveManipulatorTo(double x, double y, double angle)
        {
            // Используйте поля Forearm, UpperArm, Palm класса Manipulator
            DPoint wristPoint = new DPoint
            {
                X = y + Math.Sin(angle) * Manipulator.Palm,
                Y = x - Math.Sin((Math.PI / 2) - angle) * Manipulator.Palm
            };
            double elbowAngle = TriangleTask.GetABAngle(
                Manipulator.UpperArm,
                Manipulator.Forearm,
                wristPoint.GetLengthLine()
                );
            double shoulderAngle = TriangleTask.GetABAngle(
                wristPoint.GetLengthLine(),
                Manipulator.UpperArm,
                Manipulator.Forearm
                ) + Math.Atan2(wristPoint.X, wristPoint.Y);
            double wristAngle = -angle - shoulderAngle - elbowAngle;

            return(new[] { shoulderAngle, elbowAngle, wristAngle });
        }
Beispiel #34
0
        public void TranslateStaticD()
        {
            const int left   = 0;
            const int top    = 0;
            const int right  = 100;
            const int bottom = 100;
            const int x      = 10;
            const int y      = 20;
            var       rect   = new DRectangle(left, top, right, bottom);
            var       point  = new DPoint(x, y);

            var ret = DRectangle.Translate(rect, point);

            Assert.AreEqual(ret.Left, left + x);
            Assert.AreEqual(ret.Top, top + y);
            Assert.AreEqual(ret.Right, right + x);
            Assert.AreEqual(ret.Bottom, bottom + y);

            this.DisposeAndCheckDisposedState(ret);
            this.DisposeAndCheckDisposedState(point);
            this.DisposeAndCheckDisposedState(rect);
        }
Beispiel #35
0
        [NotNull] private InkDrawingAttributes GetPenAttributes(double zoom, DPoint[] pts)
        {
            if (pts == null)
            {
                throw new Exception("Invalid pen points");
            }

            var detail = new DPoint {
                StylusId = 0
            };

            if (pts.Length > 0)
            {
                detail = pts[0];
            }


            // get size and color from dictionary, or set default
            if (!_penColors.TryGetValue(detail.StylusId, out var color))
            {
                color = detail.IsErase ? Colors.White : Colors.BlueViolet;
            }

            if (!_penSizes.TryGetValue(detail.StylusId, out var size))
            {
                size = detail.IsErase ? 6.5 : 2.5;
            }

            var attr = new InkDrawingAttributes
            {
                Size       = new Size(size * zoom, size * zoom),
                Color      = color,
                PenTip     = PenTipShape.Circle,
                FitToCurve = false
            };

            return(attr);
        }
Beispiel #36
0
        public void Rotate2()
        {
            const int away  = 90;
            var       x     = 10;
            var       y     = 20;
            var       point = new DPoint(x, y);
            var       move  = new DPoint(-away, 0);
            var       p     = point + move;

            for (var i = 1; i <= 3; i++)
            {
                var rotated = DPoint.Rotate(point, p, 90 * i);

                switch (i)
                {
                case 1:
                    Assert.AreEqual(Math.Round(rotated.X), x, $"Check X and Rotate: {90 * i}");
                    Assert.AreEqual(Math.Round(rotated.Y), y - away, $"Check Y Rotate: {90 * i}");
                    break;

                case 2:
                    Assert.AreEqual(Math.Round(rotated.X), x + away, $"Check X and Rotate: {90 * i}");
                    Assert.AreEqual(Math.Round(rotated.Y), y, $"Check Y Rotate: {90 * i}");
                    break;

                case 3:
                    Assert.AreEqual(Math.Round(rotated.X), x, $"Check X and Rotate: {90 * i}");
                    Assert.AreEqual(Math.Round(rotated.Y), y + away, $"Check Y and Rotate: {90 * i}");
                    break;
                }

                this.DisposeAndCheckDisposedState(rotated);
            }

            this.DisposeAndCheckDisposedState(point);
            this.DisposeAndCheckDisposedState(move);
            this.DisposeAndCheckDisposedState(p);
        }
Beispiel #37
0
        public void CenteredRect()
        {
            const int x      = 50;
            const int y      = 60;
            var       p      = new DPoint(x, y);
            double    width  = 20;
            double    height = 30;

            var result = DRectangle.CenteredRect(p, width, height);

            width--;
            height--;

            var eLeft   = x - width / 2;
            var eTop    = y - height / 2;
            var eRight  = eLeft + width - 1;
            var eBottom = eTop + height - 1;

            Assert.AreEqual(result.Left, eLeft);
            Assert.AreEqual(result.Top, eTop);
            Assert.AreEqual(result.Right, eRight + 1);
            Assert.AreEqual(result.Bottom, eBottom + 1);
        }
Beispiel #38
0
        static void Sixth()
        {
            Console.WriteLine("Введите координаты вершины угла");
            string[] input = Console.ReadLine().Split(' ');
            DPoint   p     = new DPoint(int.Parse(input[0]), int.Parse(input[1]));

            Console.WriteLine("Введите координаты первой точки");
            input = Console.ReadLine().Split(' ');
            DPoint p1 = new DPoint(int.Parse(input[0]), int.Parse(input[1]));

            Console.WriteLine("Введите координаты второй точки");
            input = Console.ReadLine().Split(' ');
            DPoint p2    = new DPoint(int.Parse(input[0]), int.Parse(input[1]));
            double r     = Range(p.x, p.y, p1.x, p1.y) / Range(p.x, p.y, p2.x, p2.y);
            DPoint point = new DPoint((p1.x + r * p2.x) / (1 + r), (p1.y + r * p2.y) / (1 + r));

            Console.WriteLine(point.x + " " + point.y);
            double a = point.y - p.y;
            double b = p.x - point.x;
            double c = (p.y * point.x - p.x * point.y);

            Console.WriteLine("{0}x + {1}y + {2} = 0", a, b, c);
        }
Beispiel #39
0
        public static IViewerNode addNodeWithStyles(GraphViewer gv, string id, DPoint pos, ICollection <Style> styles)
        {
            var graph = gv.Graph;
            var node  = graph.AddNode(id);

            if (styles != null)
            {
                foreach (var s in styles)
                {
                    node.Attr.AddStyle(s);
                }
            }

            var lnode     = GeometryGraphCreator.CreateGeometryNode(graph, graph.GeometryGraph, node, ConnectionToGraph.Disconnected);
            var labelSize = Common.MeasureLabel(node.Label);
            var mar       = node.Attr.LabelMargin;

            lnode.BoundaryCurve = NodeBoundaryCurves.GetNodeBoundaryCurve(node, labelSize.Width + mar * 2, labelSize.Height + mar * 2);
            node.GeometryNode   = lnode;
            var vnode = gv.CreateIViewerNode(node, pos, null);

            return(vnode);
        }
Beispiel #40
0
        public static double DistBetweenPtAndLine(DPoint pt, DPoint linep1, DPoint linep2, out DPoint linept)
        {
            /* Calculate the distance between a point and a line */

            // below is based from http://www.allegro.cc/forums/thread/589720/644831#target

            double A = pt.X - linep1.X;
            double B = pt.Y - linep1.Y;
            double C = linep2.X - linep1.X;
            double D = linep2.Y - linep1.Y;

            double dot = A * C + B * D;
            double len_sq = C * C + D * D;
            double param = dot / len_sq;

            if (param < 0)
                linept = new DPoint(linep1.X, linep1.Y);
            else if (param > 1)
                linept = new DPoint(linep2.X, linep2.Y);
            else
                linept = new DPoint(linep1.X + param * C, linep1.Y + param * D);

            return DistBetweenTwoPts(linept, pt);
        }
Beispiel #41
0
 void hsm_ContextClick(DEngine de, Figure clickedFigure, DPoint pt)
 {
     if (ContextClick != null)
         ContextClick(this, clickedFigure, pt);
 }
Beispiel #42
0
 void hsm_DragFigureEnd(DEngine de, Figure dragFigure, DPoint pt)
 {
     if (DragFigureEnd != null)
         DragFigureEnd(this, dragFigure, pt);
 }
Beispiel #43
0
 void hsm_DragFigureStart(DEngine de, Figure dragFigure, DPoint pt)
 {
     if (DragFigureStart != null)
         DragFigureStart(this, dragFigure, pt);
 }
Beispiel #44
0
 void hsm_FigureLockClick(DEngine de, Figure clickedFigure, DPoint pt)
 {
     if (FigureLockClick != null)
         FigureLockClick(this, clickedFigure, pt);
 }
Beispiel #45
0
 public DPoint ClientToEngine(DPoint pt)
 {
     double x = pt.X + HortScroll - OffsetX;
     double y = pt.Y + VertScroll - OffsetY;
     return new DPoint(x / scale, y / scale);
 }
Beispiel #46
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="actualPointMoved">points to actual point in contianer (attached)</param>
 /// <param name="originalPointLocation">clone of point (detached)</param>
 public void movePoint(DPoint actualPointMoved, DPoint originalPointLocation)
 {
     UndoElementPrimitive elem = new UndoElementPrimitive();
     elem.pointMoved(actualPointMoved, originalPointLocation);
     undoPrimitives.Add(elem);
 }
Beispiel #47
0
 void viewerHandler_MouseUp(DTkViewer dv, DMouseButton btn, DPoint pt)
 {
     if (MouseUp != null)
         MouseUp(dv, btn, pt);
 }
Beispiel #48
0
 protected void DoMouseMove(DPoint pt)
 {
     if (MouseMove != null)
         MouseMove(this, pt);
 }
Beispiel #49
0
 public void CallClicked(Figure f, DPoint pt)
 {
     if (Clicked != null)
         Clicked(this, f, pt);
 }
Beispiel #50
0
 protected void DoMouseDown(DMouseButton btn, DPoint pt)
 {
     if (MouseDown != null)
         MouseDown(this, btn, pt);
 }
Beispiel #51
0
 protected void DoDoubleClick(DPoint pt)
 {
     if (DoubleClick != null)
         DoubleClick(this, pt);
 }
Beispiel #52
0
 public DPoint EngineToClient(DPoint pt)
 {
     pt = new DPoint(pt.X * scale, pt.Y * scale);
     return pt.Offset(-HortScroll + OffsetX, -VertScroll + OffsetY);
 }
Beispiel #53
0
 void de_ContextClick(DEngine de, Figure clickedFigure, DPoint pt)
 {
     // create popup
     Menu pop = new Menu();
     MenuItem mi;
     if (clickedFigure == null)
     {
         // page zoom menu items
         mi = new MenuItem("Fit to Page");
         mi.ButtonPressEvent += new ButtonPressEventHandler(miFitToPage_ButtonPressEvent);
         pop.Append(mi);
         mi = new MenuItem("Fit to Width");
         mi.ButtonPressEvent += new ButtonPressEventHandler(miFitToWidth_ButtonPressEvent);
         pop.Append(mi);
         mi = new MenuItem("50%");
         mi.ButtonPressEvent += new ButtonPressEventHandler(mi050pc_ButtonPressEvent);
         pop.Append(mi);
         mi = new MenuItem("100%");
         mi.ButtonPressEvent += new ButtonPressEventHandler(mi100pc_ButtonPressEvent);
         pop.Append(mi);
         mi = new MenuItem("150%");
         mi.ButtonPressEvent += new ButtonPressEventHandler(mi150pc_ButtonPressEvent);
         pop.Append(mi);
         mi = new MenuItem("Print");
         mi.ButtonPressEvent += new ButtonPressEventHandler(miPrint_ButtonPressEvent);
         pop.Append(mi);
     }
     else
     {
         // group menu items
         List<Figure> figs = de.SelectedFigures;
         if (de.CanGroupFigures(figs))
         {
             mi = new MenuItem("Group");
             mi.ButtonPressEvent += new ButtonPressEventHandler(miGroup_ButtonPressEvent);
             pop.Append(mi);
         }
         else if (de.CanUngroupFigures(figs))
         {
             mi = new MenuItem("Ungroup");
             mi.ButtonPressEvent += new ButtonPressEventHandler(miUngroup_ButtonPressEvent);
             pop.Append(mi);
         }
     }
     // show popup
     if (pop.Children.Length > 0)
     {
         pop.Popup();
         pop.ShowAll();
     }
 }
Beispiel #54
0
 void viewerHandler_MouseMove(DTkViewer dv, DPoint pt)
 {
     if (MouseMove != null)
         MouseMove(dv, pt);
 }
Beispiel #55
0
        // find the index of the closest point in a route to a specific point
        public static int findClosestPointIndexInRoute(DPoint point, Route route)
        {
            double minDistance = Double.MaxValue;
            int minDistanceIndex = 0;

            for (int i = 0; i < route.Points.Count(); i++)
            {
                double distance = TerrainService.MathEngine.CalcDistance(point.x, point.y, route.Points.ElementAt(i).x, route.Points.ElementAt(i).y);

                if (distance < minDistance)
                {
                    minDistance = distance;
                    minDistanceIndex = i;
                }
            }

            return minDistanceIndex;
        }
Beispiel #56
0
        public static typRoute planRouteByShortestPath(DPoint source, DPoint dest, String routeName)
        {
            typRoute route = new typRoute();

            return route;
        }
Beispiel #57
0
 protected void DoMouseUp(DMouseButton btn, DPoint pt)
 {
     if (MouseUp != null)
         MouseUp(this, btn, pt);
 }
Beispiel #58
0
 public override void SetPageSize(DPoint pageSize)
 {
     this.pageSize = pageSize;
 }
Beispiel #59
0
 public DHitTest HitTest(DPoint pt, Figure f, double scale)
 {
     if (IsVisible(f.Selected))
     {
         if (DGeom.PointInRect(pt, GetRect(pos, f.GetSelectRect(), scale)))
             return DHitTest.Glyph;
     }
     return DHitTest.None;
 }
Beispiel #60
0
 public abstract void SetPageSize(DPoint pageSize);