Exemplo n.º 1
0
        public void PhotosSearchPhotoSearchBoundaryBox()
        {
            BoundaryBox        b = new BoundaryBox(103.675997, 1.339811, 103.689456, 1.357764, GeoAccuracy.World);
            PhotoSearchOptions o = new PhotoSearchOptions();

            o.HasGeo        = true;
            o.BoundaryBox   = b;
            o.Accuracy      = b.Accuracy;
            o.MinUploadDate = DateTime.Now.AddYears(-1);
            o.MaxUploadDate = DateTime.Now;
            o.Extras        = PhotoSearchExtras.Geo;

            PhotoCollection ps = f.PhotosSearch(o);

            foreach (Photo p in ps)
            {
                // Annoying, but sometimes Flickr doesn't return the geo properties for a photo even for this type of search.
                if (p.Latitude == 0 && p.Longitude == 0)
                {
                    continue;
                }

                Assert.IsTrue(p.Latitude > b.MinimumLatitude && b.MaximumLatitude > p.Latitude, "Latitude is not within the boundary box.");
                Assert.IsTrue(p.Longitude > b.MinimumLongitude && b.MaximumLongitude > p.Longitude, "Longitude is not within the boundary box.");
            }
        }
Exemplo n.º 2
0
        public void PhotosSearchPhotoSearchBoundaryBox()
        {
            var b = new BoundaryBox(103.675997, 1.339811, 103.689456, 1.357764, GeoAccuracy.World);
            var o = new PhotoSearchOptions
            {
                HasGeo        = true,
                BoundaryBox   = b,
                Accuracy      = b.Accuracy,
                MinUploadDate = DateTime.Now.AddYears(-1),
                MaxUploadDate = DateTime.Now,
                Extras        = PhotoSearchExtras.Geo | PhotoSearchExtras.PathAlias,
                Tags          = "colorful"
            };

            var ps = Instance.PhotosSearch(o);

            foreach (var p in ps)
            {
                // Annoying, but sometimes Flickr doesn't return the geo properties for a photo even for this type of search.
                if (Math.Abs(p.Latitude - 0) < 1e-8 && Math.Abs(p.Longitude - 0) < 1e-8)
                {
                    continue;
                }

                Assert.IsTrue(p.Latitude > b.MinimumLatitude && b.MaximumLatitude > p.Latitude,
                              "Latitude is not within the boundary box. {0} outside {1} and {2} for photo {3}", p.Latitude, b.MinimumLatitude, b.MaximumLatitude, p.WebUrl);
                Assert.IsTrue(p.Longitude > b.MinimumLongitude && b.MaximumLongitude > p.Longitude,
                              "Longitude is not within the boundary box. {0} outside {1} and {2} for photo {3}", p.Longitude, b.MinimumLongitude, b.MaximumLongitude, p.WebUrl);
            }
        }
Exemplo n.º 3
0
        private Vector2 _GetCombinedDivPosition()
        {
            int divWidth  = Divs.Sum(x => x.Padding.Left + x.Width + x.Padding.Right);
            int divHeight = Divs.Max(x => x.Height);

            return(BoundaryBox.PositionOn(divWidth, divHeight, Alignment));
        }
Exemplo n.º 4
0
        private Vector2 _GetCombinedElementPosition()
        {
            int elementWidth  = Elements.Sum(x => x.Padding.Left + x.Width + x.Padding.Right);
            int elementHeight = Elements.Max(x => x.Height);

            return(BoundaryBox.PositionOn(elementWidth, elementHeight, Alignment));
        }
Exemplo n.º 5
0
        private Vector2 _GetCombinedRowPosition()
        {
            int rowWidth  = Rows.Max(x => x.Width);
            int rowHeight = Rows.Sum(x => x.Padding.Top + x.Height + x.Padding.Bottom);

            return(BoundaryBox.PositionOn(rowWidth, rowHeight, Alignment));
        }
Exemplo n.º 6
0
        public void BoundaryBoxCalculateSizesFrankfurtToBerlin()
        {
            var b = new BoundaryBox(8.68194, 50.11222, 13.29750, 52.52222);

            var e = b.DiagonalDistanceInMiles();

            Assert.IsTrue(259.9 < e && e < 260.0);
        }
Exemplo n.º 7
0
        public void BoundaryBoxWithValidPointStringSetCorrectly()
        {
            var b = new BoundaryBox("1,2,3,4");

            Assert.That(b.MinimumLongitude, Is.EqualTo(1M));
            Assert.That(b.MinimumLatitude, Is.EqualTo(2M));
            Assert.That(b.MaximumLongitude, Is.EqualTo(3M));
            Assert.That(b.MaximumLatitude, Is.EqualTo(4M));
        }
Exemplo n.º 8
0
    protected virtual void Awake()
    {
        BoxCollider2D collider = GetComponent <BoxCollider2D>();

        collider.offset = local_center;
        collider.size   = new Vector2(size.x * Section.width - 1, size.y * Section.height - 1);

        enemy_bound_box = GetComponentInChildren <BoundaryBox>();
        if (enemy_bound_box != null)
        {
            enemy_bound_box.Set(this);
            enemy_bound_box.Disable();
        }
    }
Exemplo n.º 9
0
 private void Awake()
 {
     if (_template != null)
     {
         _template.Ini();
         foreach (Block b in template.GetBlocks())
         {
             b.SetRoom(this);
         }
     }
     boundary_box = GetComponentInChildren <BoundaryBox>();
     if (boundary_box != null)
     {
         boundary_box.Set(this);
         boundary_box.Disable();
     }
     enemies = new Dictionary <Enemy, Vector3>();
 }
Exemplo n.º 10
0
        internal static object GetValueFromTypeAndArray(byte type, byte[] array)
        {
            byte[] take;
            int    length, count;
            var    sb = new StringBuilder();

            switch (type)
            {
            case 0x07:
                return(array[0]);

            case 0x08:
                return(BitConverter.ToChar(array, 0));

            case 0x09:
                take = array.Take(4).Reverse().ToArray();
                return(BitConverter.ToInt32(take, 0));

            case 0x0A:
                take = array.Take(4).Reverse().ToArray();
                return(BitConverter.ToSingle(take, 0));

            case 0x0B:
                take = array.Take(8).Reverse().ToArray();
                return(BitConverter.ToDouble(take, 0));

            case 0x0C:
                sb     = new StringBuilder();
                take   = array.Take(4).Reverse().ToArray();
                length = BitConverter.ToInt32(take, 0);
                for (var i = 0; i < length; ++i)
                {
                    sb.Append((char)array[i + 4]);
                }
                return(sb.ToString());

            case 0x0E:
                sb    = new StringBuilder();
                take  = array.Take(4).Reverse().ToArray();
                count = BitConverter.ToInt32(take, 0);
                var list = new List <string>();
                var k1   = 4;
                for (var i1 = 0; i1 < count; ++i1)
                {
                    sb.Clear();
                    take   = array.Skip(k1).Take(4).Reverse().ToArray();
                    k1    += 4;
                    length = BitConverter.ToInt32(take, 0);
                    for (var j = 0; j < length; ++j)
                    {
                        sb.Append((char)array[k1]);
                        ++k1;
                    }
                    list.Add(sb.ToString());
                }
                return(list);

            case 0x0F:
                take  = array.Take(4).Reverse().ToArray();
                count = BitConverter.ToInt32(take, 0);
                var ctlist = new List <ComposedTypeBase>();
                var k2     = 4;
                for (var i = 0; i < count; ++i)
                {
                    var ctype = array[k2];
                    ++k2;
                    switch (ctype)
                    {
                    case 0x00:
                        var lonlat = new LonLatPosition();
                        take             = array.Skip(k2).Take(8).Reverse().ToArray();
                        k2              += 8;
                        lonlat.Longitude = BitConverter.ToDouble(take, 0);
                        take             = array.Skip(k2).Take(8).Reverse().ToArray();
                        k2              += 8;
                        lonlat.Latitude  = BitConverter.ToDouble(take, 0);
                        ctlist.Add(lonlat);
                        break;

                    case 0x01:
                        var pos2d = new Position2D();
                        take    = array.Skip(k2).Take(8).Reverse().ToArray();
                        k2     += 8;
                        pos2d.X = BitConverter.ToDouble(take, 0);
                        take    = array.Skip(k2).Take(8).Reverse().ToArray();
                        k2     += 8;
                        pos2d.Y = BitConverter.ToDouble(take, 0);
                        ctlist.Add(pos2d);
                        break;

                    case 0x02:
                        var lonlatalt = new LonLatAltPosition();
                        take = array.Skip(k2).Take(8).Reverse().ToArray();
                        k2  += 8;
                        lonlatalt.Longitude = BitConverter.ToDouble(take, 0);
                        take = array.Skip(k2).Take(8).Reverse().ToArray();
                        k2  += 8;
                        lonlatalt.Latitude = BitConverter.ToDouble(take, 0);
                        take = array.Skip(k2).Take(8).Reverse().ToArray();
                        k2  += 8;
                        lonlatalt.Altitude = BitConverter.ToDouble(take, 0);
                        ctlist.Add(lonlatalt);
                        break;

                    case 0x03:
                        var pos3d = new Position3D();
                        take    = array.Skip(k2).Take(8).Reverse().ToArray();
                        k2     += 8;
                        pos3d.X = BitConverter.ToDouble(take, 0);
                        take    = array.Skip(k2).Take(8).Reverse().ToArray();
                        k2     += 8;
                        pos3d.Y = BitConverter.ToDouble(take, 0);
                        take    = array.Skip(k2).Take(8).Reverse().ToArray();
                        k2     += 8;
                        pos3d.Z = BitConverter.ToDouble(take, 0);
                        ctlist.Add(pos3d);
                        break;

                    case 0x04:
                        var rmp = new RoadMapPosition();
                        sb     = new StringBuilder();
                        take   = array.Skip(k2).Take(4).Reverse().ToArray();
                        k2    += 4;
                        length = BitConverter.ToInt32(take, 0);
                        for (var j = 0; j < length; ++j)
                        {
                            sb.Append((char)array[j + 4]);
                            ++k2;
                        }
                        rmp.RoadId = sb.ToString();
                        take       = array.Skip(k2).Take(8).Reverse().ToArray();
                        k2        += 8;
                        rmp.Pos    = BitConverter.ToDouble(take, 0);
                        rmp.LaneId = array[k2];
                        ctlist.Add(rmp);
                        break;

                    case 0x05:
                        var bb = new BoundaryBox();
                        take           = array.Skip(k2).Take(8).Reverse().ToArray();
                        k2            += 8;
                        bb.LowerLeftX  = BitConverter.ToDouble(take, 0);
                        take           = array.Skip(k2).Take(8).Reverse().ToArray();
                        k2            += 8;
                        bb.LowerLeftY  = BitConverter.ToDouble(take, 0);
                        take           = array.Skip(k2).Take(8).Reverse().ToArray();
                        k2            += 8;
                        bb.UpperRightX = BitConverter.ToDouble(take, 0);
                        take           = array.Skip(k2).Take(8).Reverse().ToArray();
                        k2            += 8;
                        bb.UpperRightY = BitConverter.ToDouble(take, 0);
                        ctlist.Add(bb);
                        break;

                    case 0x06:
                        var pol  = new Polygon();
                        var plen = array[k2];
                        ++k2;
                        for (var j = 0; j < plen; j++)
                        {
                            var p = new Position2D();
                            take = array.Skip(k2).Take(8).Reverse().ToArray();
                            k2  += 8;
                            p.X  = BitConverter.ToDouble(take, 0);
                            take = array.Skip(k2).Take(8).Reverse().ToArray();
                            k2  += 8;
                            p.Y  = BitConverter.ToDouble(take, 0);
                            pol.Points.Add(p);
                        }
                        ctlist.Add(pol);
                        break;

                    case 0x0D:
                        break;

                    case 0x11:
                        var c = new Color();
                        c.R = array[k2++];
                        c.G = array[k2++];
                        c.B = array[k2++];
                        c.A = array[k2++];
                        ctlist.Add(c);
                        break;
                    }
                }
                return(ctlist);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 11
0
        public void BoundaryBoxCalculateSizesUKNewcastle()
        {
            BoundaryBox b = BoundaryBox.UKNewcastle;

            double e = b.DiagonalDistanceInMiles();
        }