public override bool Remove(GridVector location, int zoomlevel)
        {
            bool removed = m_MaptileService.Remove(location, zoomlevel);

            while (++zoomlevel < MaxZoomLevel)
            {
                location = location.AlignToZoomlevel(zoomlevel);
                m_MaptileService.Remove(location, zoomlevel);
            }
            return(removed);
        }
        public override void Store(MaptileData data)
        {
            m_MaptileService.Store(data);
            int        zoomlevel = data.ZoomLevel;
            GridVector location  = data.Location;

            while (++zoomlevel < MaxZoomLevel)
            {
                location = location.AlignToZoomlevel(zoomlevel);
                m_MaptileService.Remove(location, zoomlevel);
            }
        }
        public override bool TryGetValue(GridVector rawlocation, int zoomlevel, out MaptileData data)
        {
            data = null;
            if (zoomlevel < 1)
            {
                return(false);
            }
            GridVector location = rawlocation.AlignToZoomlevel(zoomlevel);

            if (m_MaptileService.TryGetValue(location, zoomlevel, out data))
            {
                return(true);
            }
            else if (zoomlevel > MaxZoomLevel || zoomlevel < 2)
            {
                return(false);
            }
            var zoomsize = (uint)(256 << (zoomlevel - 1));

            MaptileData map00;
            MaptileData map01;
            MaptileData map10;
            MaptileData map11;
            MaptileData outmap;

            if (!TryGetValue(location, zoomlevel - 1, out map00))
            {
                map00 = null;
            }
            GridVector v  = location;
            GridVector v2 = location;

            v2.X += zoomsize / 2;
            v2.Y += zoomsize / 2;

            if (m_MaptileService.TryGetValue(v, zoomlevel, out outmap))
            {
                List <MaptileInfo> upperInfo = m_MaptileService.GetUpdateTimes(v, v2, zoomlevel - 1);
                Date ownUpdate = outmap.LastUpdate;
                bool haveNewer = false;
                foreach (MaptileInfo up in upperInfo)
                {
                    if (up.LastUpdate.AsULong > ownUpdate.AsULong)
                    {
                        haveNewer = true;
                    }
                }
                if (!haveNewer)
                {
                    return(true);
                }
            }
            else
            {
                outmap = new MaptileData
                {
                    Location  = location,
                    ZoomLevel = zoomlevel,
                };
            }
            outmap.LastUpdate  = Date.Now;
            outmap.ContentType = "image/jpeg";

            v.Y += zoomsize / 2;
            if (!TryGetValue(v, zoomlevel - 1, out map01))
            {
                map01 = null;
            }
            v    = location;
            v.X += zoomsize / 2;
            if (!TryGetValue(location, zoomlevel - 1, out map10))
            {
                map10 = null;
            }
            v    = location;
            v.X += zoomsize / 2;
            v.Y += zoomsize / 2;
            if (!TryGetValue(location, zoomlevel - 1, out map11))
            {
                map11 = null;
            }

            using (var bmp = new Bitmap(256, 256, PixelFormat.Format24bppRgb))
            {
                using (Graphics gfx = Graphics.FromImage(bmp))
                {
                    gfx.FillRectangle(Brushes.Blue, new Rectangle(0, 0, 256, 256));
                    if (map00 != null)
                    {
                        using (Image img = FromMaptileData(map00))
                        {
                            gfx.DrawImage(img, 0, 128, 128, 128);
                        }
                    }
                    if (map01 != null)
                    {
                        using (Image img = FromMaptileData(map01))
                        {
                            gfx.DrawImage(img, 0, 0, 128, 128);
                        }
                    }
                    if (map10 != null)
                    {
                        using (Image img = FromMaptileData(map10))
                        {
                            gfx.DrawImage(img, 128, 128, 128, 128);
                        }
                    }
                    if (map11 != null)
                    {
                        using (Image img = FromMaptileData(map11))
                        {
                            gfx.DrawImage(img, 128, 0, 128, 128);
                        }
                    }
                }
                using (var ms = new MemoryStream())
                {
                    bmp.Save(ms, ImageFormat.Jpeg);
                    outmap.Data = ms.ToArray();
                }
            }

            m_MaptileService.Store(outmap);
            data = outmap;
            return(true);
        }