Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
DENUE tiles
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Rodrigo Tapia-McClung
DENUE tiles
Commits
91bcf77f
Commit
91bcf77f
authored
Dec 16, 2020
by
Rodrigo Tapia-McClung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add /mbtiles route
parent
866f9324
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
24 deletions
+30
-24
mbtiles.js
mbtiles.js
+29
-0
pgserver.js
pgserver.js
+1
-24
No files found.
mbtiles.js
0 → 100644
View file @
91bcf77f
const
MBTiles
=
require
(
'@mapbox/mbtiles'
);
const
p
=
require
(
"path"
);
// Enable CORS and set correct mime type/content encoding
let
header
=
{
"Access-Control-Allow-Origin"
:
"*"
,
"Access-Control-Allow-Headers"
:
"Origin, X-Requested-With, Content-Type, Accept"
,
"Content-Type"
:
"application/x-protobuf"
,
"Content-Encoding"
:
"gzip"
};
// Route which handles requests like the following: /<mbtiles-name>/0/1/2.pbf
module
.
exports
=
function
(
app
)
{
app
.
get
(
'/data/:source/mbtiles/:z/:x/:y.pbf'
,
function
(
req
,
res
)
{
new
MBTiles
(
p
.
join
(
__dirname
,
`/public/
${
req
.
params
.
source
}
.mbtiles`
),
function
(
err
,
mbtiles
)
{
mbtiles
.
getTile
(
req
.
params
.
z
,
req
.
params
.
x
,
req
.
params
.
y
,
function
(
err
,
tile
,
headers
)
{
if
(
err
)
{
res
.
set
({
"Content-Type"
:
"text/plain"
});
res
.
status
(
404
).
send
(
'Tile rendering error: '
+
err
+
'
\
n'
);
}
else
{
res
.
set
(
header
);
res
.
send
(
tile
);
}
});
if
(
err
)
console
.
log
(
"error opening database"
);
});
});
}
\ No newline at end of file
pgserver.js
View file @
91bcf77f
...
@@ -19,32 +19,8 @@ app.use(logger('combined', {
...
@@ -19,32 +19,8 @@ app.use(logger('combined', {
}));
}));
app
.
use
(
cors
());
app
.
use
(
cors
());
// Enable CORS and set correct mime type/content encoding
let
header
=
{
"Access-Control-Allow-Origin"
:
"*"
,
"Access-Control-Allow-Headers"
:
"Origin, X-Requested-With, Content-Type, Accept"
,
"Content-Type"
:
"application/x-protobuf"
,
"Content-Encoding"
:
"gzip"
};
app
.
use
(
'/'
,
express
.
static
(
__dirname
+
'/public'
));
app
.
use
(
'/'
,
express
.
static
(
__dirname
+
'/public'
));
// Route which handles requests like the following: /<mbtiles-name>/0/1/2.pbf
app
.
get
(
'/denue/:z/:x/:y.pbf'
,
function
(
req
,
res
)
{
new
MBTiles
(
p
.
join
(
__dirname
,
'/public/outC.mbtiles'
),
function
(
err
,
mbtiles
)
{
mbtiles
.
getTile
(
req
.
params
.
z
,
req
.
params
.
x
,
req
.
params
.
y
,
function
(
err
,
tile
,
headers
)
{
if
(
err
)
{
res
.
set
({
"Content-Type"
:
"text/plain"
});
res
.
status
(
404
).
send
(
'Tile rendering error: '
+
err
+
'
\
n'
);
}
else
{
res
.
set
(
header
);
res
.
send
(
tile
);
}
});
if
(
err
)
console
.
log
(
"error opening database"
);
});
});
const
{
Pool
}
=
require
(
'pg'
);
const
{
Pool
}
=
require
(
'pg'
);
const
dbconfig
=
require
(
'./config/dbconfig.json'
);
const
dbconfig
=
require
(
'./config/dbconfig.json'
);
const
readOnlyPool
=
new
Pool
(
dbconfig
);
const
readOnlyPool
=
new
Pool
(
dbconfig
);
...
@@ -59,6 +35,7 @@ const geobuf = require('./geobuf.js')(app, readOnlyPool);
...
@@ -59,6 +35,7 @@ const geobuf = require('./geobuf.js')(app, readOnlyPool);
const
listLayers
=
require
(
'./list_layers.js'
)(
app
,
readOnlyPool
);
const
listLayers
=
require
(
'./list_layers.js'
)(
app
,
readOnlyPool
);
const
query
=
require
(
'./query.js'
)(
app
,
readOnlyPool
);
const
query
=
require
(
'./query.js'
)(
app
,
readOnlyPool
);
const
geojsonmvt
=
require
(
'./geojsonmvt.js'
)(
app
,
readOnlyPool
);
const
geojsonmvt
=
require
(
'./geojsonmvt.js'
)(
app
,
readOnlyPool
);
const
mbtiles
=
require
(
'./mbtiles.js'
)(
app
,
readOnlyPool
);
const
server
=
app
.
listen
(
pgserverconfig
.
port
);
const
server
=
app
.
listen
(
pgserverconfig
.
port
);
server
.
setTimeout
(
600000
);
server
.
setTimeout
(
600000
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment