Ejemplo n.º 1
0
        // est: since going from 6 to 10 took 1 minute, we might expect doing all 256 would take 256 minutes
        // if we break it up into quadrants using the same library, maybe it'll only take (4+1+1/16...) roughly 5.33 minutes?
        // actually took 8.673 mins (went from 450MB to 455MB)
        // estimated time to segment the whole 43.1 GB planet? 12/28/2018 = 8.673 * 43.1 / 8.05 * 47.7833 = 36.98 hours
        public static void BreakupFile(string filePath, ISector sector, int targetZoom)
        {
            if (sector.Zoom == targetZoom)
            {
                return;
            }
            List <ISector> quadrants = sector.GetChildrenAtLevel(sector.Zoom + 1);

            if (READ_BREAKUP_STEP <= CURRENT_BREAKUP_STEP)
            {
                foreach (var quadrant in quadrants)
                {
                    String quadrantPath = OSMPaths.GetSectorPath(quadrant);
                    if (File.Exists(quadrantPath))
                    {
                        File.Delete(quadrantPath);                            // we're assuming it's corrupted
                    }
                    if (!Directory.Exists(Path.GetDirectoryName(quadrantPath)))
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(quadrantPath));
                    }
                    var fInfo = new FileInfo(filePath);
                    using (var fileInfoStream = fInfo.OpenRead())
                    {
                        using (var source = new PBFOsmStreamSource(fileInfoStream))
                        {
                            var filtered = source.FilterNodes(x => x.Longitude.HasValue && x.Latitude.HasValue && quadrant.ContainsLongLat(new LongLat(x.Longitude.Value * Math.PI / 180, x.Latitude.Value * Math.PI / 180)), true);
                            using (var stream = new FileInfo(quadrantPath).Open(FileMode.Create, FileAccess.ReadWrite))
                            {
                                var target = new PBFOsmStreamTarget(stream, true);
                                target.RegisterSource(filtered);
                                target.Pull();
                                target.Close();
                            }
                        }
                    }
                }
                if (Path.GetFileName(filePath).ToLower() != Path.GetFileName(OSMPaths.GetPlanetPath()).ToLower())
                {
                    File.Delete(filePath);
                }
            }
            BreakupStepDone();
            foreach (var quadrant in quadrants)
            {
                String quadrantPath = OSMPaths.GetSectorPath(quadrant);
                BreakupFile(quadrantPath, quadrant, targetZoom);
            }
        }
Ejemplo n.º 2
0
 public static string GetSectorImagePath(ISector sector, string root = null)
 {
     if (root == null)
     {
         root = GetRenderRoot();
     }
     if (sector is MercatorSector)
     {
         var parent  = sector.GetChildrenAtLevel(sector.Zoom + 1)[0].GetAllParents().Where(x => x.Zoom == 10);
         var parent5 = sector.GetChildrenAtLevel(sector.Zoom + 1)[0].GetAllParents().Where(x => x.Zoom == 5);
         if (parent.Count() != 0)
         {
             return(Path.Combine(root, parent5.Single().ToString(), parent.Single().ToString() + ".PNG"));
         }
         if (parent5.Count() != 0)
         {
             return(Path.Combine(root, parent5.Single().ToString(), sector.ToString() + ".PNG"));
         }
         return(Path.Combine(root, sector.ToString() + ".PNG"));
     }
     if (sector is CubeSector)
     {
         var parent  = sector.GetChildrenAtLevel(sector.Zoom + 1)[0].GetAllParents().Where(x => x.Zoom == 8);
         var parent4 = sector.GetChildrenAtLevel(sector.Zoom + 1)[0].GetAllParents().Where(x => x.Zoom == 4);
         if (parent.Count() != 0)
         {
             return(Path.Combine(root, ((CubeSector)sector).sectorFace.GetFaceAcronym() + "Face", parent4.Single().ToString(), parent.Single().ToString() + ".PNG"));
         }
         if (parent4.Count() != 0)
         {
             return(Path.Combine(root, ((CubeSector)sector).sectorFace.GetFaceAcronym() + "Face", parent4.Single().ToString(), sector.ToString() + ".PNG"));
         }
         return(Path.Combine(root, ((CubeSector)sector).sectorFace.GetFaceAcronym() + "Face", sector.ToString() + ".PNG"));
     }
     throw new NotImplementedException();
 }
Ejemplo n.º 3
0
        static int wait = 0; // wait to initialize whatever
        protected override void Update(GameTime gameTime)
        {
            if (RENDER_SECTOR != null && wait > 10)
            {
                Stopwatch sw = new Stopwatch();
                sw.Start();
                foreach (var child in RENDER_SECTOR.GetChildrenAtLevel(8))
                {
                    var sectorLoader = new OSMSectorLoader();
                    var buffer       = sectorLoader.GetGraphicsBuffer(GraphicsDevice, child);
                    buffer.Dispose();
                }
                double secs = sw.Elapsed.TotalSeconds;
                Exit();
            }
            wait++;

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape) || Constants.TERMINATE)
            {
                Exit();
            }
            if (Keyboard.GetState().WasKeyPressed(Keys.R))
            {
                RECORDING = !RECORDING;
            }
            if (Keyboard.GetState().WasKeyPressed(Keys.T))
            {
                DEBUGGING = !DEBUGGING;
            }
            if (Keyboard.GetState().WasKeyPressed(Keys.C))
            {
                CameraMatrixManager.MODE = (CameraMatrixManager.MODE + 1) % CameraMatrixManager.MODE_COUNT;
            }

            foreach (var component in zComponents)
            {
                component.Update(GraphicsDevice, gameTime);
            }
        }