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
6fa91cf3
Commit
6fa91cf3
authored
Dec 15, 2020
by
Rodrigo Tapia-McClung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Serve gzipped tiles from PostGIS
parent
9ea9f68e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
3 deletions
+24
-3
mvt.js
mvt.js
+17
-2
package-lock.json
package-lock.json
+5
-0
package.json
package.json
+2
-1
No files found.
mvt.js
View file @
6fa91cf3
...
...
@@ -6,6 +6,8 @@ const merc = new sm({
size
:
256
})
const
zlib
=
require
(
'zlib'
);
function
toBoolean
(
value
)
{
if
(
!
value
)
{
return
false
;
...
...
@@ -74,6 +76,13 @@ const sql = (params, query) => {
`
}
// TODO, use sql place holders $1, $2 etc. instead of inserting user-parameters into query
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"
};
module
.
exports
=
function
(
app
,
pool
,
cache
)
{
let
cacheMiddleWare
=
async
(
req
,
res
,
next
)
=>
{
...
...
@@ -91,7 +100,9 @@ module.exports = function(app, pool, cache) {
if
(
mvt
.
length
===
0
)
{
res
.
status
(
204
)
}
res
.
header
(
'Content-Type'
,
'application/x-protobuf'
).
send
(
mvt
);
//res.header('Content-Type', 'application/x-protobuf').send(mvt);
// send cached gzipped tiles with appropriate header
res
.
header
(
header
).
send
(
mvt
);
return
;
}
else
{
res
.
sendResponse
=
res
.
send
;
...
...
@@ -170,7 +181,11 @@ module.exports = function(app, pool, cache) {
if
(
mvt
.
length
===
0
)
{
res
.
status
(
204
)
}
res
.
header
(
'Content-Type'
,
'application/x-protobuf'
).
send
(
mvt
);
//res.header('Content-Type', 'application/x-protobuf').send(mvt);
// gzip and send tiles
zlib
.
gzip
(
mvt
,
function
(
err
,
pbf
)
{
res
.
header
(
header
).
send
(
pbf
);
});
}
catch
(
err
)
{
console
.
log
(
err
);
let
status
=
500
;
...
...
package-lock.json
View file @
6fa91cf3
...
...
@@ -6044,6 +6044,11 @@
"version"
:
"2.1.2"
,
"resolved"
:
"https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz"
,
"integrity"
:
"sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI="
},
"zlib"
:
{
"version"
:
"1.0.5"
,
"resolved"
:
"https://registry.npmjs.org/zlib/-/zlib-1.0.5.tgz"
,
"integrity"
:
"sha1-bnyXL8NxxkWmr7A6sUdp3vEU/MA="
}
}
}
package.json
View file @
6fa91cf3
...
...
@@ -28,6 +28,7 @@
"
morgan
"
:
"^1.9.1"
,
"
nodemon
"
:
"^1.19.2"
,
"
path
"
:
"^0.12.7"
,
"
pg
"
:
"^7.12.1"
"
pg
"
:
"^7.12.1"
,
"
zlib
"
:
"^1.0.5"
}
}
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