Beispiel #1
0
        private void SpreadObjects()
        {
            if (Matrix != null)
            {
                return;
            }

            var width  = Tile.Width / 2;
            var height = Tile.Height / 2;

            Matrix = new Node[2, 2];
            for (var x = 0; x < 2; x++)
            {
                for (var y = 0; y < 2; y++)
                {
                    var geoTile = new GeoTile(new GeoPoint(Tile.Point.Latitude - y * height, Tile.Point.Longitude + x * width), width, height);
                    Matrix[x, y] = new Node(geoTile);
                }
            }

            foreach (var geoObject in GeoObjects)
            {
                var x = (Int32)((geoObject.Location.Longitude - Tile.Point.Longitude) / width);
                var y = (Int32)((Tile.Point.Latitude - geoObject.Location.Latitude) / height);
                Matrix[x, y].AddObject(geoObject);
            }
            GeoObjects.Clear();
        }
        internal ITile CreateTile(IEnumerable <IGeometryItem> features, int zoomSquared, int x, int y, double tileTolerance, bool shouldSimplify)
        {
            var tile = new GeoTile
            {
                ZoomSquared              = zoomSquared,
                NumberOfPoints           = 0,
                NumberOfSimplifiedPoints = 0,
                NumberOfFeatures         = 0,
                X        = x,
                Y        = y,
                Features = new List <IGeometryItem>(),
                Source   = new List <IGeometryItem>()
            };

            if (features != null)
            {
                foreach (var feature in features)
                {
                    tile.NumberOfFeatures++;
                    AddFeature(tile, feature, tileTolerance, shouldSimplify);

                    var min = feature.MinGeometry;
                    var max = feature.MaxGeometry;

                    (double X, double Y)tileMinimum = (X : tile.Min.X, Y : tile.Min.Y);
                    (double X, double Y)tileMaximum = (X : tile.Max.X, Y : tile.Max.Y);

                    if (min.X < tile.Min.X || tile.Min.X == 0)
                    {
                        tileMinimum.X = min.X;
                    }
                    if (min.Y < tile.Min.Y || tile.Min.Y == 0)
                    {
                        tileMinimum.Y = min.Y;
                    }

                    if (max.X > tile.Max.X || tile.Max.X == 0)
                    {
                        tileMaximum.X = max.X;
                    }
                    if (max.Y > tile.Max.Y || tile.Max.Y == 0)
                    {
                        tileMaximum.Y = max.Y;
                    }

                    tile.Min = tileMinimum;
                    tile.Max = tileMaximum;
                }
            }
            return(tile);
        }
Beispiel #3
0
 public Node(GeoTile tile)
 {
     GeoObjects = new List <GeoObject>();
     Tile       = tile;
 }