-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
executable file
·71 lines (49 loc) · 2.07 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const express = require('express');
const axios = require('axios');
const path = require('path')
const sqlite3 = require('sqlite3').verbose();
const utills = require('./utills/utills');
const cacheRouter = require('./routes/v1/cache')
const tileRouter = require('./routes/v1/tile')
const app = express();
app.use(express.urlencoded({extended:false}));
const PORT = 3000;
//const style = 'clde6x6d3000101s0p3av4cud'
const db_name = 'tiles.sqlite'
let styles = new Set();
const db = new sqlite3.Database(db_name, function(err)
{
if (err) throw err;
console.log('[LOG] Connected to the tiles database.');
db.run(`CREATE TABLE IF NOT EXISTS tiles (
zoom_level INTEGER,
tile_column INTEGER,
tile_row INTEGER,
tile_style_name STRING,
tile_style STRING,
tile_file_path STRING)`, function(err)
{
if (err) throw err;
console.log("[LOG] Created the tiles table if it didn't exist.")
});
db.all(`SELECT DISTINCT tile_style_name FROM tiles`, (err, rows) =>
{
if(!err)
rows.forEach((row)=>
{
styles.add(row.tile_style_name);
});
});
});
global.GLOBALS = {db: db, ROOT_DIR: path.resolve(__dirname), STYLES: styles};
app.use('/api/v1/cache/', cacheRouter);
app.use('/api/v1/tile/', tileRouter);
app.listen(PORT, function()
{
console.log(`[LOG] Server listening on port ${PORT} ...`);
});
/*
Sattelite : https://api.mapbox.com/styles/v1/dgo20/clde6pi23004401lfgsaokmil/tiles/256/{z}/{x}/{y}@2x?access_token=pk.eyJ1IjoiZGdvMjAiLCJhIjoiY2xjMXRidm9nMTlpNDNwbW5qczlsNDh1diJ9.WbbBmKc-y5XplzCCyIAtBQ
Monochrome blue : https://api.mapbox.com/styles/v1/dgo20/clde6x6d3000101s0p3av4cud/tiles/256/{z}/{x}/{y}@2x?access_token=pk.eyJ1IjoiZGdvMjAiLCJhIjoiY2xjMXRidm9nMTlpNDNwbW5qczlsNDh1diJ9.WbbBmKc-y5XplzCCyIAtBQ
Monochrome dark : https://api.mapbox.com/styles/v1/dgo20/clde6swxi000801mvm9pww2wg/tiles/256/{z}/{x}/{y}@2x?access_token=pk.eyJ1IjoiZGdvMjAiLCJhIjoiY2xjMXRidm9nMTlpNDNwbW5qczlsNDh1diJ9.WbbBmKc-y5XplzCCyIAtBQ
*/