forked from MapComplete/MapComplete
		
	Add capability to load tiled geojsons, eventually as overpass-cache
This commit is contained in:
		
							parent
							
								
									475cdae19f
								
							
						
					
					
						commit
						2da52501a3
					
				
					 16 changed files with 520 additions and 76 deletions
				
			
		| 
						 | 
				
			
			@ -1,4 +1,5 @@
 | 
			
		|||
import {lstatSync, readdirSync} from "fs";
 | 
			
		||||
import * as https from "https";
 | 
			
		||||
 | 
			
		||||
export default class ScriptUtils {
 | 
			
		||||
    public static readDirRecSync(path): string[] {
 | 
			
		||||
| 
						 | 
				
			
			@ -16,5 +17,30 @@ export default class ScriptUtils {
 | 
			
		|||
        }
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static DownloadJSON(url, continuation : (parts : string []) => void){
 | 
			
		||||
        https.get(url, (res) => {
 | 
			
		||||
            console.log("Got response!")
 | 
			
		||||
            const parts : string[] = []
 | 
			
		||||
            res.setEncoding('utf8');
 | 
			
		||||
            res.on('data', function (chunk) {
 | 
			
		||||
                // @ts-ignore
 | 
			
		||||
                parts.push(chunk)
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            res.addListener('end', function () {
 | 
			
		||||
                continuation(parts)
 | 
			
		||||
            });
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static sleep(ms) {
 | 
			
		||||
        return new Promise((resolve) => {
 | 
			
		||||
            console.debug("Sleeping for", ms)
 | 
			
		||||
            setTimeout(resolve, ms);
 | 
			
		||||
           
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue