Compare commits
114 Commits
v0.0.1-pre
...
v0.9.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ffc72789ae | ||
|
|
4fc76251c3 | ||
|
|
b048990e14 | ||
|
|
b257855e38 | ||
|
|
fb758be730 | ||
|
|
7accdfa7da | ||
|
|
7efe22cf7f | ||
|
|
5a20bf4fac | ||
|
|
a0fbf7fb79 | ||
|
|
ed0af943da | ||
|
|
e4ce4877b6 | ||
|
|
a0a086e95a | ||
|
|
dbaca66b2c | ||
|
|
d465142275 | ||
|
|
7f06f09696 | ||
|
|
f5c5570fca | ||
|
|
cb10936a1d | ||
|
|
a43c96f6cc | ||
|
|
a310c130f3 | ||
|
|
14f406cc34 | ||
|
|
3c29cb0f65 | ||
|
|
d993c805fe | ||
|
|
6443ade489 | ||
|
|
eeb27ed481 | ||
|
|
15bc393aa8 | ||
|
|
d6e2baef67 | ||
|
|
6100013718 | ||
|
|
4eea8a91b8 | ||
|
|
d57f9f7a60 | ||
|
|
1307b29ff9 | ||
|
|
a9443edfc6 | ||
|
|
e6a1bf407c | ||
|
|
0ba2dcce53 | ||
|
|
ebd6662ebb | ||
|
|
6898be5bea | ||
|
|
a55b5ad69c | ||
|
|
1104bf8a57 | ||
|
|
1d4503b507 | ||
|
|
2d5dccc1e0 | ||
|
|
fc32cc24e5 | ||
|
|
575c1df524 | ||
|
|
d8f35bb70a | ||
|
|
4af6fb686f | ||
|
|
391c21a966 | ||
|
|
2d2c43aeb5 | ||
|
|
900ca4ed3e | ||
|
|
9d63634078 | ||
|
|
0b98651b48 | ||
|
|
d3aeab5d89 | ||
|
|
01bff86c6d | ||
|
|
9a21382984 | ||
|
|
9e391562ab | ||
|
|
646b65d695 | ||
|
|
c9e21b676c | ||
|
|
c50da54e64 | ||
|
|
b8b56846f2 | ||
|
|
8bb625652d | ||
|
|
801c523c73 | ||
|
|
8e289684d5 | ||
|
|
59cc66095f | ||
|
|
187da7bb58 | ||
|
|
daa94dc806 | ||
|
|
5d940066d9 | ||
|
|
10caaa1e8b | ||
|
|
9edf7c0cae | ||
|
|
f979e25fd7 | ||
|
|
d3a9b6cfbf | ||
|
|
2a55517a2d | ||
|
|
927a3eda87 | ||
|
|
54073cecce | ||
|
|
287a632295 | ||
|
|
a25ce62662 | ||
|
|
c0fb4fd400 | ||
|
|
d486a8595b | ||
|
|
3b92c6109b | ||
|
|
b6ad565e31 | ||
|
|
f794f6b8ba | ||
|
|
640a18ca49 | ||
|
|
75f64924b5 | ||
|
|
ec5d282d87 | ||
|
|
bdea327437 | ||
|
|
6cf006ec50 | ||
|
|
34befd43c9 | ||
|
|
c132d7fba8 | ||
|
|
62a6917778 | ||
|
|
403bc949a5 | ||
|
|
837cb7d1fb | ||
|
|
d0c0430dca | ||
|
|
1ade82bf05 | ||
|
|
5a94689385 | ||
|
|
074c873826 | ||
|
|
72ad669502 | ||
|
|
2210ea2f35 | ||
|
|
a39aa0bd8a | ||
|
|
1c73c14d84 | ||
|
|
8a46bd8b88 | ||
|
|
d1e33d04cb | ||
|
|
06b88bbbe7 | ||
|
|
946cb2ca5f | ||
|
|
d742672238 | ||
|
|
b98b7244f6 | ||
|
|
d4fa224d04 | ||
|
|
4c40700bac | ||
|
|
6f644a4c03 | ||
|
|
9efa22b52b | ||
|
|
a0007b42f9 | ||
|
|
a495993e68 | ||
|
|
ad867f305b | ||
|
|
d6e17c1a3a | ||
|
|
9736649244 | ||
|
|
832b2d22be | ||
|
|
47f6c90a98 | ||
|
|
77755b548b | ||
|
|
7ca7fc721f |
@@ -1,3 +1,4 @@
|
|||||||
.git
|
.git
|
||||||
node_modules
|
node_modules
|
||||||
test_data
|
test_data
|
||||||
|
test
|
||||||
|
|||||||
23
.travis.yml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
language: node_js
|
||||||
|
node_js:
|
||||||
|
- "4"
|
||||||
|
env:
|
||||||
|
- CXX=g++-4.8
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
packages:
|
||||||
|
- g++-4.8
|
||||||
|
before_install:
|
||||||
|
- sudo apt-get update -qq
|
||||||
|
- sudo apt-get install -qq libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++
|
||||||
|
- sudo apt-get install -qq xvfb
|
||||||
|
install:
|
||||||
|
- npm install
|
||||||
|
- wget -O test_data.zip https://github.com/klokantech/tileserver-gl-data/archive/v0.8.zip
|
||||||
|
- unzip -q test_data.zip -d tmp_test_data
|
||||||
|
- mkdir test_data
|
||||||
|
- mv tmp_test_data/tileserver-gl-data-*/* -t test_data
|
||||||
|
script:
|
||||||
|
- xvfb-run --server-args="-screen 0 1024x768x24" npm test
|
||||||
13
Dockerfile
@@ -3,17 +3,24 @@ MAINTAINER Petr Sloup <petr.sloup@klokantech.com>
|
|||||||
|
|
||||||
RUN apt-get -qq update \
|
RUN apt-get -qq update \
|
||||||
&& DEBIAN_FRONTEND=noninteractive apt-get -y install \
|
&& DEBIAN_FRONTEND=noninteractive apt-get -y install \
|
||||||
|
apt-transport-https \
|
||||||
curl \
|
curl \
|
||||||
|
unzip \
|
||||||
build-essential \
|
build-essential \
|
||||||
python \
|
python \
|
||||||
|
libcairo2-dev \
|
||||||
xvfb \
|
xvfb \
|
||||||
&& curl -sL https://deb.nodesource.com/setup_5.x | bash - \
|
&& echo "deb https://deb.nodesource.com/node_4.x jessie main" >> /etc/apt/sources.list.d/nodejs.list \
|
||||||
&& apt-get -y install nodejs \
|
&& echo "deb-src https://deb.nodesource.com/node_4.x jessie main" >> /etc/apt/sources.list.d/nodejs.list \
|
||||||
|
&& apt-get -qq update \
|
||||||
|
&& DEBIAN_FRONTEND=noninteractive apt-get -y --allow-unauthenticated install \
|
||||||
|
nodejs \
|
||||||
|
&& rm /etc/apt/sources.list.d/nodejs.list \
|
||||||
&& apt-get clean
|
&& apt-get clean
|
||||||
|
|
||||||
RUN mkdir -p /usr/src/app
|
RUN mkdir -p /usr/src/app
|
||||||
COPY / /usr/src/app
|
COPY / /usr/src/app
|
||||||
RUN cd /usr/src/app && npm install
|
RUN cd /usr/src/app && npm install --production
|
||||||
|
|
||||||
VOLUME /data
|
VOLUME /data
|
||||||
WORKDIR /data
|
WORKDIR /data
|
||||||
|
|||||||
976
LICENSE.md
Normal file
@@ -0,0 +1,976 @@
|
|||||||
|
TileServer GL
|
||||||
|
=============
|
||||||
|
|
||||||
|
Copyright (c) 2016, Klokan Technologies GmbH
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in
|
||||||
|
the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
mapbox-gl-native copyright (c) 2014-2016 Mapbox.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in
|
||||||
|
the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Mapbox GL uses portions of Android Gesture Detectors Framework.
|
||||||
|
|
||||||
|
Copyright (c) 2012, Almer Thie
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Mapbox GL uses portions of Android Support Library.
|
||||||
|
|
||||||
|
Copyright (c) 2005-2013, The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Mapbox GL uses portions of Boost.
|
||||||
|
|
||||||
|
Distributed under the Boost Software License, Version 1.0.
|
||||||
|
|
||||||
|
http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Mapbox GL uses portions of Clipper.
|
||||||
|
|
||||||
|
Author : Angus Johnson
|
||||||
|
Version : 6.1.3a
|
||||||
|
Date : 22 January 2014
|
||||||
|
Website : http://www.angusj.com
|
||||||
|
Copyright : Angus Johnson 2010-2014
|
||||||
|
|
||||||
|
License:
|
||||||
|
Use, modification & distribution is subject to Boost Software License Ver 1.
|
||||||
|
http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
Attributions:
|
||||||
|
The code in this library is an extension of Bala Vatti's clipping algorithm:
|
||||||
|
"A generic solution to polygon clipping"
|
||||||
|
Communications of the ACM, Vol 35, Issue 7 (July 1992) pp 56-63.
|
||||||
|
http://portal.acm.org/citation.cfm?id=129906
|
||||||
|
|
||||||
|
Computer graphics and geometric modeling: implementation and algorithms
|
||||||
|
By Max K. Agoston
|
||||||
|
Springer; 1 edition (January 4, 2005)
|
||||||
|
http://books.google.com/books?q=vatti+clipping+agoston
|
||||||
|
|
||||||
|
See also:
|
||||||
|
"Polygon Offsetting by Computing Winding Numbers"
|
||||||
|
Paper no. DETC2005-85513 pp. 565-575
|
||||||
|
ASME 2005 International Design Engineering Technical Conferences
|
||||||
|
and Computers and Information in Engineering Conference (IDETC/CIE2005)
|
||||||
|
September 24-28, 2005 , Long Beach, California, USA
|
||||||
|
http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Mapbox GL uses portions of BugshotKit.
|
||||||
|
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014 marcoarment
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Mapbox GL uses portions of CSS Color Parser.
|
||||||
|
|
||||||
|
(c) Dean McNamee <dean@gmail.com>, 2012.
|
||||||
|
C++ port by Konstantin Käfer <mail@kkaefer.com>, 2014.
|
||||||
|
|
||||||
|
https://github.com/deanm/css-color-parser-js
|
||||||
|
https://github.com/kkaefer/css-color-parser-cpp
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to
|
||||||
|
deal in the Software without restriction, including without limitation the
|
||||||
|
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
IN THE SOFTWARE.
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Mapbox GL uses portions of GLFW.
|
||||||
|
|
||||||
|
Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
|
Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would
|
||||||
|
be appreciated but is not required.
|
||||||
|
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not
|
||||||
|
be misrepresented as being the original software.
|
||||||
|
|
||||||
|
3. This notice may not be removed or altered from any source
|
||||||
|
distribution.
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Mapbox GL uses portions of libc++.
|
||||||
|
|
||||||
|
The libc++ library is dual licensed under both the University of Illinois
|
||||||
|
"BSD-Like" license and the MIT license. As a user of this code you may choose
|
||||||
|
to use it under either license. As a contributor, you agree to allow your code
|
||||||
|
to be used under both.
|
||||||
|
|
||||||
|
Full text of the relevant licenses is included below.
|
||||||
|
|
||||||
|
====
|
||||||
|
|
||||||
|
University of Illinois/NCSA
|
||||||
|
Open Source License
|
||||||
|
|
||||||
|
Copyright (c) 2009-2015 by the contributors listed in CREDITS.TXT
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Developed by:
|
||||||
|
|
||||||
|
LLVM Team
|
||||||
|
|
||||||
|
University of Illinois at Urbana-Champaign
|
||||||
|
|
||||||
|
http://llvm.org
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal with
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
|
so, subject to the following conditions:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimers.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimers in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the names of the LLVM Team, University of Illinois at
|
||||||
|
Urbana-Champaign, nor the names of its contributors may be used to
|
||||||
|
endorse or promote products derived from this Software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
|
====
|
||||||
|
|
||||||
|
Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Mapbox GL uses portions of libcurl.
|
||||||
|
|
||||||
|
COPYRIGHT AND PERMISSION NOTICE
|
||||||
|
|
||||||
|
Copyright (c) 1996 - 2015, Daniel Stenberg, <daniel@haxx.se>.
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and distribute this software for any purpose
|
||||||
|
with or without fee is hereby granted, provided that the above copyright
|
||||||
|
notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN
|
||||||
|
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
||||||
|
OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
Except as contained in this notice, the name of a copyright holder shall not
|
||||||
|
be used in advertising or otherwise to promote the sale, use or other dealings
|
||||||
|
in this Software without prior written authorization of the copyright holder.
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Mapbox GL uses portions of libjpeg-turbo.
|
||||||
|
|
||||||
|
This software is based in part on the work of the Independent JPEG Group.
|
||||||
|
|
||||||
|
Copyright (C)2009-2015 D. R. Commander. All Rights Reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
- Redistributions of source code must retain the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer.
|
||||||
|
- Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
- Neither the name of the libjpeg-turbo Project nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from this
|
||||||
|
software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
||||||
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
TurboJPEG/LJT: this implements the TurboJPEG API using libjpeg or libjpeg-turbo
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Mapbox GL uses portions of libpng.
|
||||||
|
|
||||||
|
This copy of the libpng notices is provided for your convenience. In case of
|
||||||
|
any discrepancy between this copy and the notices in the file png.h that is
|
||||||
|
included in the libpng distribution, the latter shall prevail.
|
||||||
|
|
||||||
|
COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
|
||||||
|
|
||||||
|
If you modify libpng you may insert additional notices immediately following
|
||||||
|
this sentence.
|
||||||
|
|
||||||
|
This code is released under the libpng license.
|
||||||
|
|
||||||
|
libpng versions 1.0.7, July 1, 2000, through 1.6.18, July 23, 2015, are
|
||||||
|
Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, and are
|
||||||
|
distributed according to the same disclaimer and license as libpng-1.0.6
|
||||||
|
with the following individuals added to the list of Contributing Authors:
|
||||||
|
|
||||||
|
Simon-Pierre Cadieux
|
||||||
|
Eric S. Raymond
|
||||||
|
Mans Rullgard
|
||||||
|
Cosmin Truta
|
||||||
|
Gilles Vollant
|
||||||
|
James Yu
|
||||||
|
|
||||||
|
and with the following additions to the disclaimer:
|
||||||
|
|
||||||
|
There is no warranty against interference with your enjoyment of the
|
||||||
|
library or against infringement. There is no warranty that our
|
||||||
|
efforts or the library will fulfill any of your particular purposes
|
||||||
|
or needs. This library is provided with all faults, and the entire
|
||||||
|
risk of satisfactory quality, performance, accuracy, and effort is with
|
||||||
|
the user.
|
||||||
|
|
||||||
|
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
||||||
|
Copyright (c) 1998-2000 Glenn Randers-Pehrson, and are distributed according
|
||||||
|
to the same disclaimer and license as libpng-0.96, with the following
|
||||||
|
individuals added to the list of Contributing Authors:
|
||||||
|
|
||||||
|
Tom Lane
|
||||||
|
Glenn Randers-Pehrson
|
||||||
|
Willem van Schaik
|
||||||
|
|
||||||
|
libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
||||||
|
Copyright (c) 1996-1997 Andreas Dilger, and are
|
||||||
|
distributed according to the same disclaimer and license as libpng-0.88,
|
||||||
|
with the following individuals added to the list of Contributing Authors:
|
||||||
|
|
||||||
|
John Bowler
|
||||||
|
Kevin Bracey
|
||||||
|
Sam Bushell
|
||||||
|
Magnus Holmgren
|
||||||
|
Greg Roelofs
|
||||||
|
Tom Tanner
|
||||||
|
|
||||||
|
libpng versions 0.5, May 1995, through 0.88, January 1996, are
|
||||||
|
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
|
|
||||||
|
For the purposes of this copyright and license, "Contributing Authors"
|
||||||
|
is defined as the following set of individuals:
|
||||||
|
|
||||||
|
Andreas Dilger
|
||||||
|
Dave Martindale
|
||||||
|
Guy Eric Schalnat
|
||||||
|
Paul Schmidt
|
||||||
|
Tim Wegner
|
||||||
|
|
||||||
|
The PNG Reference Library is supplied "AS IS". The Contributing Authors
|
||||||
|
and Group 42, Inc. disclaim all warranties, expressed or implied,
|
||||||
|
including, without limitation, the warranties of merchantability and of
|
||||||
|
fitness for any purpose. The Contributing Authors and Group 42, Inc.
|
||||||
|
assume no liability for direct, indirect, incidental, special, exemplary,
|
||||||
|
or consequential damages, which may result from the use of the PNG
|
||||||
|
Reference Library, even if advised of the possibility of such damage.
|
||||||
|
|
||||||
|
Permission is hereby granted to use, copy, modify, and distribute this
|
||||||
|
source code, or portions hereof, for any purpose, without fee, subject
|
||||||
|
to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this source code must not be misrepresented.
|
||||||
|
|
||||||
|
2. Altered versions must be plainly marked as such and must not
|
||||||
|
be misrepresented as being the original source.
|
||||||
|
|
||||||
|
3. This Copyright notice may not be removed or altered from any
|
||||||
|
source or altered source distribution.
|
||||||
|
|
||||||
|
The Contributing Authors and Group 42, Inc. specifically permit, without
|
||||||
|
fee, and encourage the use of this source code as a component to
|
||||||
|
supporting the PNG file format in commercial products. If you use this
|
||||||
|
source code in a product, acknowledgment is not required but would be
|
||||||
|
appreciated.
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Mapbox GL uses portions of libuv.
|
||||||
|
|
||||||
|
libuv is part of the Node project: http://nodejs.org/
|
||||||
|
libuv may be distributed alone under Node's license:
|
||||||
|
|
||||||
|
====
|
||||||
|
|
||||||
|
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to
|
||||||
|
deal in the Software without restriction, including without limitation the
|
||||||
|
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
IN THE SOFTWARE.
|
||||||
|
|
||||||
|
====
|
||||||
|
|
||||||
|
This license applies to all parts of libuv that are not externally
|
||||||
|
maintained libraries.
|
||||||
|
|
||||||
|
The externally maintained libraries used by libuv are:
|
||||||
|
|
||||||
|
- tree.h (from FreeBSD), copyright Niels Provos. Two clause BSD license.
|
||||||
|
|
||||||
|
- inet_pton and inet_ntop implementations, contained in src/inet.c, are
|
||||||
|
copyright the Internet Systems Consortium, Inc., and licensed under the ISC
|
||||||
|
license.
|
||||||
|
|
||||||
|
- stdint-msvc2008.h (from msinttypes), copyright Alexander Chemeris. Three
|
||||||
|
clause BSD license.
|
||||||
|
|
||||||
|
- pthread-fixes.h, pthread-fixes.c, copyright Google Inc. and Sony Mobile
|
||||||
|
Communications AB. Three clause BSD license.
|
||||||
|
|
||||||
|
- android-ifaddrs.h, android-ifaddrs.c, copyright Berkeley Software Design
|
||||||
|
Inc, Kenneth MacKay and Emergya (Cloud4all, FP7/2007-2013, grant agreement
|
||||||
|
n° 289016). Three clause BSD license.
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Mapbox GL uses portions of libzip.
|
||||||
|
|
||||||
|
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
|
||||||
|
|
||||||
|
The authors can be contacted at <libzip@nih.at>
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in
|
||||||
|
the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
|
||||||
|
3. The names of the authors may not be used to endorse or promote
|
||||||
|
products derived from this software without specific prior
|
||||||
|
written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||||
|
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||||
|
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||||
|
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Mapbox GL uses portions of LOST.
|
||||||
|
|
||||||
|
Copyright (c) 2014 Mapzen
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Mapbox GL uses portions of the Mapbox iOS SDK, which was derived from the
|
||||||
|
Route-Me open source project, including the Alpstein fork of it.
|
||||||
|
|
||||||
|
The Route-Me license appears below.
|
||||||
|
|
||||||
|
Copyright (c) 2008-2013, Route-Me Contributors
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Mapbox GL uses portions of nunicode.
|
||||||
|
|
||||||
|
Copyright (c) 2013 Aleksey Tulinov <aleksey.tulinov@gmail.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Mapbox GL uses portions of OkHTTP.
|
||||||
|
|
||||||
|
Copyright 2014 Square, Inc.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Mapbox GL uses portions of OpenSSL.
|
||||||
|
|
||||||
|
LICENSE ISSUES
|
||||||
|
==============
|
||||||
|
|
||||||
|
The OpenSSL toolkit stays under a dual license, i.e. both the conditions of
|
||||||
|
the OpenSSL License and the original SSLeay license apply to the toolkit.
|
||||||
|
See below for the actual license texts. Actually both licenses are BSD-style
|
||||||
|
Open Source licenses. In case of any license issues related to OpenSSL
|
||||||
|
please contact openssl-core@openssl.org.
|
||||||
|
|
||||||
|
OpenSSL License
|
||||||
|
---------------
|
||||||
|
|
||||||
|
Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in
|
||||||
|
the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
|
||||||
|
3. All advertising materials mentioning features or use of this
|
||||||
|
software must display the following acknowledgment:
|
||||||
|
"This product includes software developed by the OpenSSL Project
|
||||||
|
for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||||
|
|
||||||
|
4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||||
|
endorse or promote products derived from this software without
|
||||||
|
prior written permission. For written permission, please contact
|
||||||
|
openssl-core@openssl.org.
|
||||||
|
|
||||||
|
5. Products derived from this software may not be called "OpenSSL"
|
||||||
|
nor may "OpenSSL" appear in their names without prior written
|
||||||
|
permission of the OpenSSL Project.
|
||||||
|
|
||||||
|
6. Redistributions of any form whatsoever must retain the following
|
||||||
|
acknowledgment:
|
||||||
|
"This product includes software developed by the OpenSSL Project
|
||||||
|
for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||||
|
EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||||
|
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
This product includes cryptographic software written by Eric Young
|
||||||
|
(eay@cryptsoft.com). This product includes software written by Tim
|
||||||
|
Hudson (tjh@cryptsoft.com).
|
||||||
|
|
||||||
|
Original SSLeay License
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
This package is an SSL implementation written
|
||||||
|
by Eric Young (eay@cryptsoft.com).
|
||||||
|
The implementation was written so as to conform with Netscapes SSL.
|
||||||
|
|
||||||
|
This library is free for commercial and non-commercial use as long as
|
||||||
|
The following conditions are aheared to. The following conditions
|
||||||
|
apply to all code found in this distribution, be it the RC4, RSA,
|
||||||
|
lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||||
|
included with this distribution is covered by the same copyright terms
|
||||||
|
except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||||
|
|
||||||
|
Copyright remains Eric Young's, and as such any Copyright notices in
|
||||||
|
the code are not to be removed.
|
||||||
|
If this package is used in a product, Eric Young should be given attribution
|
||||||
|
as the author of the parts of the library used.
|
||||||
|
This can be in the form of a textual message at program startup or
|
||||||
|
in documentation (online or textual) provided with the package.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
1. Redistributions of source code must retain the copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
3. All advertising materials mentioning features or use of this software
|
||||||
|
must display the following acknowledgement:
|
||||||
|
"This product includes cryptographic software written by
|
||||||
|
Eric Young (eay@cryptsoft.com)"
|
||||||
|
The word 'cryptographic' can be left out if the rouines from the library
|
||||||
|
being used are not cryptographic related :-).
|
||||||
|
4. If you include any Windows specific code (or a derivative thereof) from
|
||||||
|
the apps directory (application code) you must include an acknowledgement:
|
||||||
|
"This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGE.
|
||||||
|
|
||||||
|
The licence and distribution terms for any publically available version or
|
||||||
|
derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||||
|
copied and put under another distribution licence
|
||||||
|
[including the GNU Public Licence.]
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Mapbox GL uses portions of RapidJSON.
|
||||||
|
|
||||||
|
Tencent is pleased to support the open source community by making RapidJSON
|
||||||
|
available.
|
||||||
|
|
||||||
|
Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights
|
||||||
|
reserved.
|
||||||
|
|
||||||
|
If you have downloaded a copy of the RapidJSON binary from Tencent, please note
|
||||||
|
that the RapidJSON binary is licensed under the MIT License. If you have
|
||||||
|
downloaded a copy of the RapidJSON source code from Tencent, please note that
|
||||||
|
RapidJSON source code is licensed under the MIT License, except for the third-
|
||||||
|
party components listed below which are subject to different license terms.
|
||||||
|
Your integration of RapidJSON into your own projects may require compliance with
|
||||||
|
the MIT License, as well as the other licenses applicable to the third-party
|
||||||
|
components included within RapidJSON. To avoid the problematic JSON license in
|
||||||
|
your own projects, it's sufficient to exclude the bin/jsonchecker/ directory, as
|
||||||
|
it's the only code under the JSON license. A copy of the MIT License is included
|
||||||
|
in this file.
|
||||||
|
|
||||||
|
Other dependencies and licenses:
|
||||||
|
|
||||||
|
Open Source Software Licensed Under the BSD License:
|
||||||
|
--------------------------------------------------------------------
|
||||||
|
|
||||||
|
The msinttypes r29
|
||||||
|
Copyright (c) 2006-2013 Alexander Chemeris
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of copyright holder nor the names of its contributors may be
|
||||||
|
used to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||||
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
Open Source Software Licensed Under the JSON License:
|
||||||
|
--------------------------------------------------------------------
|
||||||
|
|
||||||
|
json.org
|
||||||
|
Copyright (c) 2002 JSON.org
|
||||||
|
All Rights Reserved.
|
||||||
|
|
||||||
|
JSON_checker
|
||||||
|
Copyright (c) 2002 JSON.org
|
||||||
|
All Rights Reserved.
|
||||||
|
|
||||||
|
Terms of the JSON License:
|
||||||
|
---------------------------------------------------
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
The Software shall be used for Good, not Evil.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
Terms of the MIT License:
|
||||||
|
--------------------------------------------------------------------
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Mapbox GL uses portions of Reachability.
|
||||||
|
|
||||||
|
Copyright (c) 2011, Tony Million.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Mapbox GL uses portions of SQLite.
|
||||||
|
|
||||||
|
2001 September 15
|
||||||
|
|
||||||
|
The author disclaims copyright to this source code. In place of
|
||||||
|
a legal notice, here is a blessing:
|
||||||
|
|
||||||
|
May you do good and not evil.
|
||||||
|
May you find forgiveness for yourself and forgive others.
|
||||||
|
May you share freely, never taking more than you give.
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Mapbox GL uses portions of SVPulsingAnnotationView.
|
||||||
|
|
||||||
|
Copyright (c) 2013, Sam Vermette <hello@samvermette.com>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any purpose
|
||||||
|
with or without fee is hereby granted, provided that the above copyright notice
|
||||||
|
and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||||
|
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||||
|
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||||
|
THIS SOFTWARE.
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Mapbox GL uses portions of zlib.
|
||||||
|
|
||||||
|
Acknowledgments:
|
||||||
|
|
||||||
|
The deflate format used by zlib was defined by Phil Katz. The deflate and
|
||||||
|
zlib specifications were written by L. Peter Deutsch. Thanks to all the
|
||||||
|
people who reported problems and suggested various improvements in zlib; they
|
||||||
|
are too numerous to cite here.
|
||||||
|
|
||||||
|
Copyright notice:
|
||||||
|
|
||||||
|
(C) 1995-2013 Jean-loup Gailly and Mark Adler
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
||||||
|
Jean-loup Gailly Mark Adler
|
||||||
|
jloup@gzip.org madler@alumni.caltech.edu
|
||||||
|
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Mapbox GL uses portions of Realm Objective-C.
|
||||||
|
|
||||||
|
Copyright 2015 Realm Inc.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
86
README.md
@@ -1,4 +1,7 @@
|
|||||||
# tileserver-gl
|
# TileServer GL
|
||||||
|
[](https://travis-ci.org/klokantech/tileserver-gl)
|
||||||
|
[](https://hub.docker.com/r/klokantech/tileserver-gl/)
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -10,64 +13,47 @@
|
|||||||
- `npm install`
|
- `npm install`
|
||||||
- `node src/main.js`
|
- `node src/main.js`
|
||||||
|
|
||||||
|
## Sample data
|
||||||
|
Sample data can be downloaded at https://github.com/klokantech/tileserver-gl-data/archive/master.zip
|
||||||
|
|
||||||
|
#### Usage
|
||||||
|
- unpack somewhere and `cd` to the directory
|
||||||
|
- `docker run -it -v $(pwd):/data -p 8080:80 klokantech/tileserver-gl`
|
||||||
|
- (or `node path/to/repo/src/main.js`)
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
Create `config.json` file in the root directory.
|
Create `config.json` file in the root directory.
|
||||||
The config file can contain definition of several paths where the tiles will be served.
|
The config file can contain definition of several paths where the tiles will be served.
|
||||||
|
|
||||||
Every path needs to have `root` specified. All other paths (in the config (`style`) **and** in the style (`sprites`, `glyphs`, `sources`, ...)) are relative to this root.
|
|
||||||
|
|
||||||
For raster endpoints specify `style`, for serving raw `pbf` vector tiles specify `mbtiles` property.
|
|
||||||
|
|
||||||
Alternative `domains` can be specified (array or comma-separated string). These will be used to generate tile urls for `index.json`.
|
|
||||||
|
|
||||||
Every path can also have `options` object and its content is directly copied into served `index.json`.
|
|
||||||
The `options.format` can be used to modify the extension in tile urls inside `index.json`, but the server will still serve all the supported formats.
|
|
||||||
|
|
||||||
### Example configuration file
|
### Example configuration file
|
||||||
|
See https://github.com/klokantech/tileserver-gl-data/blob/master/config.json
|
||||||
|
|
||||||
Example styles can be downloaded from https://github.com/klokantech/osm2vectortiles-gl-styles.
|
**Note**: To specify local mbtiles as source of the vector tiles inside the style, use urls with `mbtiles` protocol with path relative to the `cwd + options.paths.root + options.paths.mbtiles`. (For example `mbtiles://switzerland.mbtiles`)
|
||||||
Rendered vector tiles can be found at http://osm2vectortiles.org/downloads/.
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"/basic": {
|
|
||||||
"root": "test_data",
|
|
||||||
"style": "styles/basic-v8.json",
|
|
||||||
"domains": [
|
|
||||||
"localhost:8080",
|
|
||||||
"127.0.0.1:8080"
|
|
||||||
],
|
|
||||||
"options": {
|
|
||||||
"type": "overlay",
|
|
||||||
"bounds": [5.8559113, 45.717995, 10.5922941, 47.9084648]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/hybrid": {
|
|
||||||
"root": "test_data",
|
|
||||||
"style": "styles/satellite-hybrid-v8.json",
|
|
||||||
"options": {
|
|
||||||
"format": "webp"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/switzerland-vector": {
|
|
||||||
"root": "test_data",
|
|
||||||
"mbtiles": "switzerland.mbtiles"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
**Note**: To specify local mbtiles as source of the vector tiles inside the style, use urls with `mbtiles` protocol with path relative to the `root`. (For example `mbtiles://switzerland.mbtiles`)
|
|
||||||
|
|
||||||
## Available URLs
|
## Available URLs
|
||||||
|
|
||||||
- If you visit the server on the configured port (default 8080) you should see your maps appearing in the browser.
|
- If you visit the server on the configured port (default 8080) you should see your maps appearing in the browser.
|
||||||
- The tiles itself are served at `/{basename}/{z}/{x}/{y}[@2x].{format}`
|
- Style is served at `/styles/{id}.json` (+ array at `/styles.json`)
|
||||||
|
- Sprites at `/styles/{id}/sprite[@2x].{format}`
|
||||||
|
- Fonts at `/fonts/{fontstack}/{start}-{end}.pbf`
|
||||||
|
- Rendered tiles are at `/styles/{id}/rendered/{z}/{x}/{y}[@2x].{format}`
|
||||||
- The optional `@2x` (or `@3x`) part can be used to render HiDPI (retina) tiles
|
- The optional `@2x` (or `@3x`) part can be used to render HiDPI (retina) tiles
|
||||||
- Static images (only for raster tiles) are rendered at:
|
- Available formats: `png`, `jpg` (`jpeg`), `webp`
|
||||||
- `/{basename}/static/{lon},{lat},{zoom}/{width}x{height}[@2x].{format}` (center-based)
|
- TileJSON at `/styles/{id}/rendered.json`
|
||||||
- `/{basename}/static/{minx},{miny},{maxx},{maxy}/{zoom}[@2x].{format}` (area-based)
|
- Static images are rendered at:
|
||||||
- TileJSON at `/{basename}/index.json`
|
- `/styles/{id}/static/{lon},{lat},{zoom}[@{bearing}[,{pitch}]]/{width}x{height}[@2x].{format}` (center-based)
|
||||||
- Array of all TileJSONs at `/index.json`
|
- `/styles/{id}/static/{minx},{miny},{maxx},{maxy}/{width}x{height}[@2x].{format}` (area-based)
|
||||||
- Available formats:
|
- `/styles/{id}/static/auto/{width}x{height}[@2x].{format}` (autofit path -- see below)
|
||||||
- raster: `png`, `jpg` (`jpeg`), `webp`
|
- The static image endpoints additionally support following query parameters:
|
||||||
- vector: `pbf`
|
- `path` - comma-separated `lng,lat`, pipe-separated pairs
|
||||||
|
- e.g. `5.9,45.8|5.9,47.8|10.5,47.8|10.5,45.8|5.9,45.8`
|
||||||
|
- `latlng` - indicates the `path` coordinates are in `lat,lng` order rather than the usual `lng,lat`
|
||||||
|
- `fill` - color to use as the fill (e.g. `red`, `rgba(255,255,255,0.5)`, `#0000ff`)
|
||||||
|
- `stroke` - color of the path stroke
|
||||||
|
- `width` - width of the stroke
|
||||||
|
- `padding` - "percetange" padding for fitted endpoints (area-based and path autofit)
|
||||||
|
- value of `0.1` means "add 10% size to each side to make sure the area of interest is nicely visible"
|
||||||
|
- Source data at `/data/{mbtiles}/{z}/{x}/{y}.{format}`
|
||||||
|
- TileJSON at `/data/{mbtiles}.json`
|
||||||
|
- Array of all TileJSONs at `/index.json` (`/rendered.json`; `/data.json`)
|
||||||
|
|||||||
33
package.json
@@ -1,8 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "tileserver-gl",
|
"name": "tileserver-gl",
|
||||||
"version": "0.0.1",
|
"version": "0.9.0",
|
||||||
"description": "Map tile server for JSON GL styles - serverside generated raster tiles",
|
"description": "Map tile server for JSON GL styles - serverside generated raster tiles",
|
||||||
"main": "src/main.js",
|
"main": "src/main.js",
|
||||||
|
"bin": "src/main.js",
|
||||||
"authors": [
|
"authors": [
|
||||||
"Petr Sloup <petr.sloup@klokantech.com>"
|
"Petr Sloup <petr.sloup@klokantech.com>"
|
||||||
],
|
],
|
||||||
@@ -10,18 +11,32 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/klokantech/tileserver-gl.git"
|
"url": "https://github.com/klokantech/tileserver-gl.git"
|
||||||
},
|
},
|
||||||
|
"license": "BSD-2-Clause",
|
||||||
|
"scripts": {
|
||||||
|
"test": "mocha test/**.js"
|
||||||
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async": "1.5.2",
|
"async": "2.0.1",
|
||||||
"advanced-pool": "0.3.1",
|
"advanced-pool": "0.3.2",
|
||||||
|
"base64url": "2.0.0",
|
||||||
|
"canvas": "1.4.0",
|
||||||
"clone": "1.0.2",
|
"clone": "1.0.2",
|
||||||
|
"color": "0.11.3",
|
||||||
"cors": "2.7.1",
|
"cors": "2.7.1",
|
||||||
"express": "4.13.4",
|
"express": "4.14.0",
|
||||||
"mapbox-gl-native": "3.0.2-earcut",
|
"glyph-pbf-composite": "0.0.2",
|
||||||
"mbtiles": "0.8.2",
|
"handlebars": "4.0.5",
|
||||||
|
"mapbox-gl-native": "3.2.1",
|
||||||
|
"mbtiles": "0.9.0",
|
||||||
"morgan": "1.7.0",
|
"morgan": "1.7.0",
|
||||||
"nomnom": "1.8.1",
|
"nomnom": "1.8.1",
|
||||||
"request": "2.69.0",
|
"request": "2.74.0",
|
||||||
"sharp": "0.13.1",
|
"sharp": "0.15.1",
|
||||||
"sphericalmercator": "1.0.4"
|
"sphericalmercator": "1.0.5"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"should": "^10.0.0",
|
||||||
|
"mocha": "^2.5.0",
|
||||||
|
"supertest": "^1.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
public/resources/favicon.ico
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
public/resources/fonts/OpenSans-Bold.ttf
Normal file
BIN
public/resources/fonts/OpenSans-Italic.ttf
Normal file
BIN
public/resources/fonts/OpenSans-Regular.ttf
Normal file
BIN
public/resources/images/header-map-1280px.png
Normal file
|
After Width: | Height: | Size: 171 KiB |
BIN
public/resources/images/header-map-1600px.png
Normal file
|
After Width: | Height: | Size: 250 KiB |
BIN
public/resources/images/header-map-2560px.png
Normal file
|
After Width: | Height: | Size: 530 KiB |
BIN
public/resources/images/header-map-640px.png
Normal file
|
After Width: | Height: | Size: 48 KiB |
BIN
public/resources/images/icons-000000@2x.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
public/resources/images/klokantech.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
public/resources/images/logo.png
Normal file
|
After Width: | Height: | Size: 6.3 KiB |
BIN
public/resources/images/placeholder.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
200
public/resources/index.css
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
@font-face {
|
||||||
|
font-family: 'OpenSans';
|
||||||
|
src: url('/fonts/OpenSans-Regular.ttf');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
@font-face {
|
||||||
|
font-family: 'OpenSans';
|
||||||
|
src: url('/fonts/OpenSans-Italic.ttf');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
@font-face {
|
||||||
|
font-family: 'OpenSans';
|
||||||
|
src: url('/fonts/OpenSans-Bold.ttf');
|
||||||
|
font-weight: bold;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
body{
|
||||||
|
background-color: #fff;
|
||||||
|
color: #212121;
|
||||||
|
font-family:'OpenSans', sans-serif, Arial;
|
||||||
|
font-size: 14px;
|
||||||
|
margin:0;
|
||||||
|
}
|
||||||
|
a{
|
||||||
|
color: #499DCE;
|
||||||
|
transition: color .2s;
|
||||||
|
}
|
||||||
|
a:hover{
|
||||||
|
color: #395D73;
|
||||||
|
}
|
||||||
|
.title {
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 32px;
|
||||||
|
text-align:center;
|
||||||
|
margin:90px 0 0 0;
|
||||||
|
}
|
||||||
|
section{
|
||||||
|
margin: 15px auto;
|
||||||
|
width: 930px;
|
||||||
|
padding: 30px 0;
|
||||||
|
}
|
||||||
|
.title img {
|
||||||
|
width: 320px;
|
||||||
|
}
|
||||||
|
.subtitle {
|
||||||
|
font-size: 26px;
|
||||||
|
font-weight:normal;
|
||||||
|
text-align:center;
|
||||||
|
margin:10px 0 95px 0;
|
||||||
|
}
|
||||||
|
.box-header {
|
||||||
|
text-align:left;
|
||||||
|
text-transform:uppercase;
|
||||||
|
border:1px solid #ededed;
|
||||||
|
margin:25px 0 0 0;
|
||||||
|
padding:12px 30px;
|
||||||
|
font-size:20px;
|
||||||
|
background:#fff;
|
||||||
|
}
|
||||||
|
.item{
|
||||||
|
background:#fff;
|
||||||
|
height: 191px;
|
||||||
|
border: 1px solid #ededed;
|
||||||
|
border-top:none;
|
||||||
|
}
|
||||||
|
.item:nth-child(odd) {
|
||||||
|
background-color:#fbfbfb;
|
||||||
|
}
|
||||||
|
.item img{
|
||||||
|
position: absolute;
|
||||||
|
margin: 30px;
|
||||||
|
width: 128px;
|
||||||
|
height: 128px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
}
|
||||||
|
.details {
|
||||||
|
float:left;
|
||||||
|
width:180px;
|
||||||
|
height: 128px;
|
||||||
|
padding: 20px 30px 20px 188px;
|
||||||
|
}
|
||||||
|
.details h3 {
|
||||||
|
font-size:18px;
|
||||||
|
margin-top: 25px;
|
||||||
|
}
|
||||||
|
.details p {
|
||||||
|
padding:0;
|
||||||
|
margin:18px 0;
|
||||||
|
}
|
||||||
|
.viewers {
|
||||||
|
float:right;
|
||||||
|
text-align:center;
|
||||||
|
width: 120px;
|
||||||
|
margin-top: 25px;
|
||||||
|
padding-right: 30px;
|
||||||
|
}
|
||||||
|
.btn {
|
||||||
|
display:block;
|
||||||
|
margin: 0;
|
||||||
|
line-height: 36px;
|
||||||
|
}
|
||||||
|
.btn:first-child {
|
||||||
|
position: relative;
|
||||||
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius:4px;
|
||||||
|
background-color: #499DCE;
|
||||||
|
background: linear-gradient(90deg, #5aaad8, #4a9ecf);
|
||||||
|
color: #fff;
|
||||||
|
text-decoration: none;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.btn:first-child:hover{
|
||||||
|
background: #395D73;
|
||||||
|
}
|
||||||
|
footer{
|
||||||
|
width:100%;
|
||||||
|
border-top:1px solid #ededed;
|
||||||
|
text-align:center;
|
||||||
|
color:#d3d3d3;
|
||||||
|
padding-top:10px;
|
||||||
|
font-size:12px;
|
||||||
|
}
|
||||||
|
footer img{
|
||||||
|
width: 118px;
|
||||||
|
height: 32px;
|
||||||
|
}
|
||||||
|
footer p {
|
||||||
|
margin-top:0;
|
||||||
|
}
|
||||||
|
footer a {
|
||||||
|
color: #787878;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* body background image */
|
||||||
|
body {
|
||||||
|
background-repeat:no-repeat !important;
|
||||||
|
background-size: contain !important;
|
||||||
|
background-image: url(/images/header-map-640px.png);
|
||||||
|
}
|
||||||
|
@media only screen and (min-width: 641px) {
|
||||||
|
body {
|
||||||
|
background-image: url(/images/header-map-1280px.png);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media only screen and (min-width: 1281px) {
|
||||||
|
body {
|
||||||
|
background-image: url(/images/header-map-1600px.png);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media only screen and (min-width: 1601px) {
|
||||||
|
body {
|
||||||
|
background-image: url(/images/header-map-2560px.png);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Responsive */
|
||||||
|
@media (max-width: 950px) {
|
||||||
|
section{
|
||||||
|
margin: 0;
|
||||||
|
width: 96%;
|
||||||
|
padding: 2%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media (max-width: 600px) {
|
||||||
|
.title{
|
||||||
|
margin: 25px 0 0 0;
|
||||||
|
}
|
||||||
|
.title img{
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
|
.subtitle{
|
||||||
|
font-size: 20px;
|
||||||
|
margin: 0 0 35px 0;
|
||||||
|
}
|
||||||
|
.item{
|
||||||
|
height: 245px;
|
||||||
|
}
|
||||||
|
.viewers{
|
||||||
|
float: left;
|
||||||
|
text-align: left;
|
||||||
|
width: 100%;
|
||||||
|
margin-left: 30px;
|
||||||
|
margin-top: 15px;
|
||||||
|
}
|
||||||
|
.viewers a{
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
.btn{
|
||||||
|
margin: 0 20px 0 0;
|
||||||
|
}
|
||||||
|
.btn:first-child{
|
||||||
|
padding: 0 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
162
public/resources/leaflet-hash.js
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
(function(window) {
|
||||||
|
var HAS_HASHCHANGE = (function() {
|
||||||
|
var doc_mode = window.documentMode;
|
||||||
|
return ('onhashchange' in window) &&
|
||||||
|
(doc_mode === undefined || doc_mode > 7);
|
||||||
|
})();
|
||||||
|
|
||||||
|
L.Hash = function(map) {
|
||||||
|
this.onHashChange = L.Util.bind(this.onHashChange, this);
|
||||||
|
|
||||||
|
if (map) {
|
||||||
|
this.init(map);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
L.Hash.parseHash = function(hash) {
|
||||||
|
if(hash.indexOf('#') === 0) {
|
||||||
|
hash = hash.substr(1);
|
||||||
|
}
|
||||||
|
var args = hash.split("/");
|
||||||
|
if (args.length == 3) {
|
||||||
|
var zoom = parseInt(args[0], 10),
|
||||||
|
lat = parseFloat(args[1]),
|
||||||
|
lon = parseFloat(args[2]);
|
||||||
|
if (isNaN(zoom) || isNaN(lat) || isNaN(lon)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
center: new L.LatLng(lat, lon),
|
||||||
|
zoom: zoom
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
L.Hash.formatHash = function(map) {
|
||||||
|
var center = map.getCenter(),
|
||||||
|
zoom = map.getZoom(),
|
||||||
|
precision = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
|
||||||
|
|
||||||
|
return "#" + [zoom,
|
||||||
|
center.lat.toFixed(precision),
|
||||||
|
center.lng.toFixed(precision)
|
||||||
|
].join("/");
|
||||||
|
},
|
||||||
|
|
||||||
|
L.Hash.prototype = {
|
||||||
|
map: null,
|
||||||
|
lastHash: null,
|
||||||
|
|
||||||
|
parseHash: L.Hash.parseHash,
|
||||||
|
formatHash: L.Hash.formatHash,
|
||||||
|
|
||||||
|
init: function(map) {
|
||||||
|
this.map = map;
|
||||||
|
|
||||||
|
// reset the hash
|
||||||
|
this.lastHash = null;
|
||||||
|
this.onHashChange();
|
||||||
|
|
||||||
|
if (!this.isListening) {
|
||||||
|
this.startListening();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
removeFrom: function(map) {
|
||||||
|
if (this.changeTimeout) {
|
||||||
|
clearTimeout(this.changeTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isListening) {
|
||||||
|
this.stopListening();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.map = null;
|
||||||
|
},
|
||||||
|
|
||||||
|
onMapMove: function() {
|
||||||
|
// bail if we're moving the map (updating from a hash),
|
||||||
|
// or if the map is not yet loaded
|
||||||
|
|
||||||
|
if (this.movingMap || !this.map._loaded) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var hash = this.formatHash(this.map);
|
||||||
|
if (this.lastHash != hash) {
|
||||||
|
location.replace(hash);
|
||||||
|
this.lastHash = hash;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
movingMap: false,
|
||||||
|
update: function() {
|
||||||
|
var hash = location.hash;
|
||||||
|
if (hash === this.lastHash) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var parsed = this.parseHash(hash);
|
||||||
|
if (parsed) {
|
||||||
|
this.movingMap = true;
|
||||||
|
|
||||||
|
this.map.setView(parsed.center, parsed.zoom);
|
||||||
|
|
||||||
|
this.movingMap = false;
|
||||||
|
} else {
|
||||||
|
this.onMapMove(this.map);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// defer hash change updates every 100ms
|
||||||
|
changeDefer: 100,
|
||||||
|
changeTimeout: null,
|
||||||
|
onHashChange: function() {
|
||||||
|
// throttle calls to update() so that they only happen every
|
||||||
|
// `changeDefer` ms
|
||||||
|
if (!this.changeTimeout) {
|
||||||
|
var that = this;
|
||||||
|
this.changeTimeout = setTimeout(function() {
|
||||||
|
that.update();
|
||||||
|
that.changeTimeout = null;
|
||||||
|
}, this.changeDefer);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
isListening: false,
|
||||||
|
hashChangeInterval: null,
|
||||||
|
startListening: function() {
|
||||||
|
this.map.on("moveend", this.onMapMove, this);
|
||||||
|
|
||||||
|
if (HAS_HASHCHANGE) {
|
||||||
|
L.DomEvent.addListener(window, "hashchange", this.onHashChange);
|
||||||
|
} else {
|
||||||
|
clearInterval(this.hashChangeInterval);
|
||||||
|
this.hashChangeInterval = setInterval(this.onHashChange, 50);
|
||||||
|
}
|
||||||
|
this.isListening = true;
|
||||||
|
},
|
||||||
|
|
||||||
|
stopListening: function() {
|
||||||
|
this.map.off("moveend", this.onMapMove, this);
|
||||||
|
|
||||||
|
if (HAS_HASHCHANGE) {
|
||||||
|
L.DomEvent.removeListener(window, "hashchange", this.onHashChange);
|
||||||
|
} else {
|
||||||
|
clearInterval(this.hashChangeInterval);
|
||||||
|
}
|
||||||
|
this.isListening = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
L.hash = function(map) {
|
||||||
|
return new L.Hash(map);
|
||||||
|
};
|
||||||
|
L.Map.prototype.addHash = function() {
|
||||||
|
this._hash = L.hash(this);
|
||||||
|
};
|
||||||
|
L.Map.prototype.removeHash = function() {
|
||||||
|
this._hash.removeFrom();
|
||||||
|
};
|
||||||
|
})(window);
|
||||||
251
public/resources/mapbox-gl.css
Normal file
@@ -0,0 +1,251 @@
|
|||||||
|
.mapboxgl-map {
|
||||||
|
font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;
|
||||||
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
|
-webkit-tap-highlight-color: rgba(0,0,0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.mapboxgl-canvas-container.mapboxgl-interactive,
|
||||||
|
.mapboxgl-ctrl-nav-compass {
|
||||||
|
cursor: -webkit-grab;
|
||||||
|
cursor: -moz-grab;
|
||||||
|
cursor: grab;
|
||||||
|
}
|
||||||
|
.mapboxgl-canvas-container.mapboxgl-interactive:active,
|
||||||
|
.mapboxgl-ctrl-nav-compass:active {
|
||||||
|
cursor: -webkit-grabbing;
|
||||||
|
cursor: -moz-grabbing;
|
||||||
|
cursor: grabbing;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mapboxgl-ctrl-top-left,
|
||||||
|
.mapboxgl-ctrl-top-right,
|
||||||
|
.mapboxgl-ctrl-bottom-left,
|
||||||
|
.mapboxgl-ctrl-bottom-right { position:absolute; }
|
||||||
|
.mapboxgl-ctrl-top-left { top:0; left:0; }
|
||||||
|
.mapboxgl-ctrl-top-right { top:0; right:0; }
|
||||||
|
.mapboxgl-ctrl-bottom-left { bottom:0; left:0; }
|
||||||
|
.mapboxgl-ctrl-bottom-right { right:0; bottom:0; }
|
||||||
|
|
||||||
|
.mapboxgl-ctrl { clear:both; }
|
||||||
|
.mapboxgl-ctrl-top-left .mapboxgl-ctrl { margin:10px 0 0 10px; float:left; }
|
||||||
|
.mapboxgl-ctrl-top-right .mapboxgl-ctrl{ margin:10px 10px 0 0; float:right; }
|
||||||
|
.mapboxgl-ctrl-bottom-left .mapboxgl-ctrl { margin:0 0 10px 10px; float:left; }
|
||||||
|
.mapboxgl-ctrl-bottom-right .mapboxgl-ctrl { margin:0 10px 10px 0; float:right; }
|
||||||
|
|
||||||
|
.mapboxgl-ctrl-group {
|
||||||
|
border-radius: 4px;
|
||||||
|
-moz-box-shadow: 0px 0px 2px rgba(0,0,0,0.1);
|
||||||
|
-webkit-box-shadow: 0px 0px 2px rgba(0,0,0,0.1);
|
||||||
|
box-shadow: 0px 0px 0px 2px rgba(0,0,0,0.1);
|
||||||
|
overflow: hidden;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
.mapboxgl-ctrl-group > button {
|
||||||
|
width: 30px;
|
||||||
|
height: 30px;
|
||||||
|
display: block;
|
||||||
|
padding: 0;
|
||||||
|
outline: none;
|
||||||
|
border: none;
|
||||||
|
border-bottom: 1px solid #ddd;
|
||||||
|
box-sizing: border-box;
|
||||||
|
background-color: rgba(0,0,0,0);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
/* https://bugzilla.mozilla.org/show_bug.cgi?id=140562 */
|
||||||
|
.mapboxgl-ctrl > button::-moz-focus-inner {
|
||||||
|
border: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.mapboxgl-ctrl > button:last-child {
|
||||||
|
border-bottom: 0;
|
||||||
|
}
|
||||||
|
.mapboxgl-ctrl > button:hover {
|
||||||
|
background-color: rgba(0,0,0,0.05);
|
||||||
|
}
|
||||||
|
.mapboxgl-ctrl-icon,
|
||||||
|
.mapboxgl-ctrl-icon > div.arrow {
|
||||||
|
speak: none;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
}
|
||||||
|
.mapboxgl-ctrl-icon.mapboxgl-ctrl-zoom-out {
|
||||||
|
padding: 5px;
|
||||||
|
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20viewBox%3D%270%200%2020%2020%27%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%3E%0A%20%20%3Cpath%20style%3D%27fill%3A%23333333%3B%27%20d%3D%27m%207%2C9%20c%20-0.554%2C0%20-1%2C0.446%20-1%2C1%200%2C0.554%200.446%2C1%201%2C1%20l%206%2C0%20c%200.554%2C0%201%2C-0.446%201%2C-1%200%2C-0.554%20-0.446%2C-1%20-1%2C-1%20z%27%20%2F%3E%0A%3C%2Fsvg%3E%0A");
|
||||||
|
}
|
||||||
|
.mapboxgl-ctrl-icon.mapboxgl-ctrl-zoom-in {
|
||||||
|
padding: 5px;
|
||||||
|
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20viewBox%3D%270%200%2020%2020%27%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%3E%0A%20%20%3Cpath%20style%3D%27fill%3A%23333333%3B%27%20d%3D%27M%2010%206%20C%209.446%206%209%206.4459904%209%207%20L%209%209%20L%207%209%20C%206.446%209%206%209.446%206%2010%20C%206%2010.554%206.446%2011%207%2011%20L%209%2011%20L%209%2013%20C%209%2013.55401%209.446%2014%2010%2014%20C%2010.554%2014%2011%2013.55401%2011%2013%20L%2011%2011%20L%2013%2011%20C%2013.554%2011%2014%2010.554%2014%2010%20C%2014%209.446%2013.554%209%2013%209%20L%2011%209%20L%2011%207%20C%2011%206.4459904%2010.554%206%2010%206%20z%27%20%2F%3E%0A%3C%2Fsvg%3E%0A");
|
||||||
|
}
|
||||||
|
.mapboxgl-ctrl-icon.mapboxgl-ctrl-geolocate {
|
||||||
|
padding: 5px;
|
||||||
|
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20viewBox%3D%270%200%2020%2020%27%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%3E%3Cpath%20style%3D%27fill%3A%23333333%3B%27%20d%3D%27M13%2C7%20L10.5%2C11.75%20L10.25%2C10%20z%20M13.888%2C6.112%20C13.615%2C5.84%2013.382%2C6.076%2012.5%2C6.5%20C10.14%2C7.634%206%2C10%206%2C10%20L9.5%2C10.5%20L10%2C14%20C10%2C14%2012.366%2C9.86%2013.5%2C7.5%20C13.924%2C6.617%2014.16%2C6.385%2013.888%2C6.112%27%2F%3E%3C%2Fsvg%3E");
|
||||||
|
}
|
||||||
|
|
||||||
|
.mapboxgl-ctrl-icon.mapboxgl-ctrl-compass > div.arrow {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
margin: 5px;
|
||||||
|
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%0A%09%3Cpolygon%20fill%3D%27%23333333%27%20points%3D%276%2C9%2010%2C1%2014%2C9%27%2F%3E%0A%09%3Cpolygon%20fill%3D%27%23CCCCCC%27%20points%3D%276%2C11%2010%2C19%2014%2C11%20%27%2F%3E%0A%3C%2Fsvg%3E");
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mapboxgl-ctrl.mapboxgl-ctrl-attrib {
|
||||||
|
padding: 0 5px;
|
||||||
|
background-color: rgba(255,255,255,0.5);
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
.mapboxgl-ctrl-attrib a {
|
||||||
|
color: rgba(0,0,0,0.75);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
.mapboxgl-ctrl-attrib a:hover {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
.mapboxgl-ctrl-attrib .mapbox-improve-map {
|
||||||
|
font-weight: bold;
|
||||||
|
margin-left: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mapboxgl-popup {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
display: -webkit-flex;
|
||||||
|
display: flex;
|
||||||
|
will-change: transform;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
.mapboxgl-popup-anchor-top,
|
||||||
|
.mapboxgl-popup-anchor-top-left,
|
||||||
|
.mapboxgl-popup-anchor-top-right {
|
||||||
|
-webkit-flex-direction: column;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
.mapboxgl-popup-anchor-bottom,
|
||||||
|
.mapboxgl-popup-anchor-bottom-left,
|
||||||
|
.mapboxgl-popup-anchor-bottom-right {
|
||||||
|
-webkit-flex-direction: column-reverse;
|
||||||
|
flex-direction: column-reverse;
|
||||||
|
}
|
||||||
|
.mapboxgl-popup-anchor-left {
|
||||||
|
-webkit-flex-direction: row;
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
.mapboxgl-popup-anchor-right {
|
||||||
|
-webkit-flex-direction: row-reverse;
|
||||||
|
flex-direction: row-reverse;
|
||||||
|
}
|
||||||
|
.mapboxgl-popup-tip {
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
border: 10px solid transparent;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
.mapboxgl-popup-anchor-top .mapboxgl-popup-tip {
|
||||||
|
-webkit-align-self: center;
|
||||||
|
align-self: center;
|
||||||
|
border-top: none;
|
||||||
|
border-bottom-color: #fff;
|
||||||
|
}
|
||||||
|
.mapboxgl-popup-anchor-top-left .mapboxgl-popup-tip {
|
||||||
|
-webkit-align-self: flex-start;
|
||||||
|
align-self: flex-start;
|
||||||
|
border-top: none;
|
||||||
|
border-left: none;
|
||||||
|
border-bottom-color: #fff;
|
||||||
|
}
|
||||||
|
.mapboxgl-popup-anchor-top-right .mapboxgl-popup-tip {
|
||||||
|
-webkit-align-self: flex-end;
|
||||||
|
align-self: flex-end;
|
||||||
|
border-top: none;
|
||||||
|
border-right: none;
|
||||||
|
border-bottom-color: #fff;
|
||||||
|
}
|
||||||
|
.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip {
|
||||||
|
-webkit-align-self: center;
|
||||||
|
align-self: center;
|
||||||
|
border-bottom: none;
|
||||||
|
border-top-color: #fff;
|
||||||
|
}
|
||||||
|
.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-tip {
|
||||||
|
-webkit-align-self: flex-start;
|
||||||
|
align-self: flex-start;
|
||||||
|
border-bottom: none;
|
||||||
|
border-left: none;
|
||||||
|
border-top-color: #fff;
|
||||||
|
}
|
||||||
|
.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-tip {
|
||||||
|
-webkit-align-self: flex-end;
|
||||||
|
align-self: flex-end;
|
||||||
|
border-bottom: none;
|
||||||
|
border-right: none;
|
||||||
|
border-top-color: #fff;
|
||||||
|
}
|
||||||
|
.mapboxgl-popup-anchor-left .mapboxgl-popup-tip {
|
||||||
|
-webkit-align-self: center;
|
||||||
|
align-self: center;
|
||||||
|
border-left: none;
|
||||||
|
border-right-color: #fff;
|
||||||
|
}
|
||||||
|
.mapboxgl-popup-anchor-right .mapboxgl-popup-tip {
|
||||||
|
-webkit-align-self: center;
|
||||||
|
align-self: center;
|
||||||
|
border-right: none;
|
||||||
|
border-left-color: #fff;
|
||||||
|
}
|
||||||
|
.mapboxgl-popup-close-button {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
border: none;
|
||||||
|
border-radius: 0 3px 0 0;
|
||||||
|
cursor: pointer;
|
||||||
|
background-color: rgba(0,0,0,0);
|
||||||
|
}
|
||||||
|
.mapboxgl-popup-close-button:hover {
|
||||||
|
background-color: rgba(0,0,0,0.05);
|
||||||
|
}
|
||||||
|
.mapboxgl-popup-content {
|
||||||
|
position: relative;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 3px;
|
||||||
|
box-shadow: 0 1px 2px rgba(0,0,0,0.10);
|
||||||
|
padding: 10px 10px 15px;
|
||||||
|
pointer-events: auto;
|
||||||
|
}
|
||||||
|
.mapboxgl-popup-anchor-top-left .mapboxgl-popup-content {
|
||||||
|
border-top-left-radius: 0;
|
||||||
|
}
|
||||||
|
.mapboxgl-popup-anchor-top-right .mapboxgl-popup-content {
|
||||||
|
border-top-right-radius: 0;
|
||||||
|
}
|
||||||
|
.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-content {
|
||||||
|
border-bottom-left-radius: 0;
|
||||||
|
}
|
||||||
|
.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-content {
|
||||||
|
border-bottom-right-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mapboxgl-crosshair,
|
||||||
|
.mapboxgl-crosshair .mapboxgl-interactive,
|
||||||
|
.mapboxgl-crosshair .mapboxgl-interactive:active {
|
||||||
|
cursor: crosshair;
|
||||||
|
}
|
||||||
|
.mapboxgl-boxzoom {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
background: #fff;
|
||||||
|
border: 2px dotted #202020;
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
@media print {
|
||||||
|
.mapbox-improve-map {
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
}
|
||||||
364
public/resources/mapbox-gl.js
Normal file
1
public/resources/mapbox.css
Normal file
67
public/resources/mapbox.js
Normal file
134
public/templates/data.tmpl
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>{{name}} - TileServer GL</title>
|
||||||
|
{{#is_vector}}
|
||||||
|
<link rel="stylesheet" type="text/css" href="/mapbox-gl.css{{&key_query}}" />
|
||||||
|
<script src="/mapbox-gl.js{{&key_query}}"></script>
|
||||||
|
<style>
|
||||||
|
body {background:#000;color:#ccc;}
|
||||||
|
#map {position:absolute;top:0;left:0;right:250px;bottom:0;}
|
||||||
|
h1 {position:absolute;top:5px;right:0;width:240px;margin:0;line-height:20px;font-size:20px;}
|
||||||
|
#layerList {position:absolute;top:35px;right:0;bottom:60%;width:240px;overflow:auto;}
|
||||||
|
#layerList div div {width:15px;height:15px;display:inline-block;}
|
||||||
|
#propertyList {position:absolute;top:40%;bottom:0;right:0;width:240px;overflow:auto;color:#fff;}
|
||||||
|
</style>
|
||||||
|
{{/is_vector}}
|
||||||
|
{{^is_vector}}
|
||||||
|
<link rel="stylesheet" type="text/css" href="/mapbox.css{{&key_query}}" />
|
||||||
|
<script src="/mapbox.js{{&key_query}}"></script>
|
||||||
|
<script src="/leaflet-hash.js{{&key_query}}"></script>
|
||||||
|
<style>
|
||||||
|
body { margin:0; padding:0; }
|
||||||
|
#map { position:absolute; top:0; bottom:0; width:100%; }
|
||||||
|
</style>
|
||||||
|
{{/is_vector}}
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{{#is_vector}}
|
||||||
|
<h1>{{name}}</h1>
|
||||||
|
<div id="map"></div>
|
||||||
|
<div id="layerList"></div>
|
||||||
|
<pre id="propertyList"></pre>
|
||||||
|
<script>
|
||||||
|
var map = new mapboxgl.Map({
|
||||||
|
container: 'map',
|
||||||
|
hash: true
|
||||||
|
});
|
||||||
|
map.addControl(new mapboxgl.Navigation());
|
||||||
|
|
||||||
|
function generateColor(str) {
|
||||||
|
var rgb = [0, 0, 0];
|
||||||
|
for (var i = 0; i < str.length; i++) {
|
||||||
|
var v = str.charCodeAt(i);
|
||||||
|
rgb[v % 3] = (rgb[i % 3] + (13*(v%13))) % 12;
|
||||||
|
}
|
||||||
|
var r = 4 + rgb[0];
|
||||||
|
var g = 4 + rgb[1];
|
||||||
|
var b = 4 + rgb[2];
|
||||||
|
r = (r * 16) + r;
|
||||||
|
g = (g * 16) + g;
|
||||||
|
b = (b * 16) + b;
|
||||||
|
return [r, g, b, 1];
|
||||||
|
};
|
||||||
|
|
||||||
|
function initLayer(data) {
|
||||||
|
var layer;
|
||||||
|
var layerList = document.getElementById('layerList');
|
||||||
|
var layers_ = [];
|
||||||
|
data['vector_layers'].forEach(function(el) {
|
||||||
|
var color = generateColor(el['id']);
|
||||||
|
var colorText = 'rgba(' + color[0] + ',' + color[1] + ',' + color[2] + ',' + color[3] + ')';
|
||||||
|
layers_.push({
|
||||||
|
id: el['id'] + Math.random(),
|
||||||
|
source: 'vector_layer_',
|
||||||
|
'source-layer': el['id'],
|
||||||
|
interactive: true,
|
||||||
|
type: 'line',
|
||||||
|
paint: {'line-color': colorText}
|
||||||
|
});
|
||||||
|
var item = document.createElement('div');
|
||||||
|
item.innerHTML = '<div style="' +
|
||||||
|
'background:rgba(' + color[0] + ',' + color[1] + ',' + color[2] + ',1);' +
|
||||||
|
'"></div> ' + el['id'];
|
||||||
|
layerList.appendChild(item);
|
||||||
|
});
|
||||||
|
map.setStyle({
|
||||||
|
version: 8,
|
||||||
|
sources: {
|
||||||
|
'vector_layer_': {
|
||||||
|
type: 'vector',
|
||||||
|
tiles: data['tiles'],
|
||||||
|
minzoom: data['minzoom'],
|
||||||
|
maxzoom: data['maxzoom']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
layers: layers_
|
||||||
|
});
|
||||||
|
|
||||||
|
return layer;
|
||||||
|
}
|
||||||
|
|
||||||
|
var xhttp = new XMLHttpRequest();
|
||||||
|
xhttp.onreadystatechange = function() {
|
||||||
|
if (xhttp.readyState == 4 && xhttp.status == 200) {
|
||||||
|
initLayer(xhttp.response);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhttp.responseType = 'json';
|
||||||
|
xhttp.open('GET', '/data/{{id}}.json{{&key_query}}', true);
|
||||||
|
xhttp.send();
|
||||||
|
|
||||||
|
var propertyList = document.getElementById('propertyList');
|
||||||
|
map.on('mousemove', function(e) {
|
||||||
|
propertyList.innerHTML = '';
|
||||||
|
var width = 3, height = 3;
|
||||||
|
var features = map.queryRenderedFeatures([
|
||||||
|
[e.point.x - width / 2, e.point.y - height / 2],
|
||||||
|
[e.point.x + width / 2, e.point.y + height / 2]
|
||||||
|
]);
|
||||||
|
if (features) {
|
||||||
|
var html = '';
|
||||||
|
features.forEach(function(feature) {
|
||||||
|
html += JSON.stringify(feature.properties, null, 2) + '\n';
|
||||||
|
});
|
||||||
|
propertyList.innerHTML = html;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{{/is_vector}}
|
||||||
|
{{^is_vector}}
|
||||||
|
<h1 style="display:none;">{{name}}</h1>
|
||||||
|
<div id='map'></div>
|
||||||
|
<script>
|
||||||
|
var map = L.mapbox.map('map', '/data/{{id}}.json{{&key_query}}', { zoomControl: false });
|
||||||
|
new L.Control.Zoom({ position: 'topright' }).addTo(map);
|
||||||
|
setTimeout(function() {
|
||||||
|
new L.Hash(map);
|
||||||
|
}, 0);
|
||||||
|
</script>
|
||||||
|
{{/is_vector}}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
88
public/templates/index.tmpl
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>TileServerGL</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/index.css{{&key_query}}" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<section>
|
||||||
|
<h1 class="title"><img src="/images/logo.png" alt="TileServerGL" /></h1>
|
||||||
|
<h2 class="subtitle">Map Layers for web and mobile applications.</h2>
|
||||||
|
<h2 class="box-header">Styles</h2>
|
||||||
|
<div class="box">
|
||||||
|
{{#each styles}}
|
||||||
|
<div class="item">
|
||||||
|
{{#if thumbnail}}
|
||||||
|
<img src="/styles/{{@key}}/rendered/{{thumbnail}}{{&../key_query}}" alt="{{name}} preview" />
|
||||||
|
{{else}}
|
||||||
|
<img src="/images/placeholder.png" alt="{{name}} preview" />
|
||||||
|
{{/if}}
|
||||||
|
<div class="details">
|
||||||
|
<h3>{{name}}</h3>
|
||||||
|
<p class="identifier">identifier: {{@key}}</p>
|
||||||
|
<p class="services">
|
||||||
|
{{#if serving_rendered}}
|
||||||
|
services: <a href="/styles/{{@key}}/rendered.json{{&../key_query}}">TileJSON</a>
|
||||||
|
{{#if wmts_link}}
|
||||||
|
| <a href="{{&wmts_link}}">WMTS</a>
|
||||||
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="viewers">
|
||||||
|
{{#if serving_data}}
|
||||||
|
{{#if serving_rendered}}
|
||||||
|
<a class="btn" href="/styles/{{@key}}/{{&../key_query}}{{viewer_hash}}">Viewer</a>
|
||||||
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
|
{{#if serving_rendered}}
|
||||||
|
<a class="btn" href="/styles/{{@key}}/?{{&../key_query_part}}raster{{viewer_hash}}">Raster</a>
|
||||||
|
{{/if}}
|
||||||
|
{{#if serving_data}}
|
||||||
|
<a class="btn" href="/styles/{{@key}}/?{{&../key_query_part}}vector{{viewer_hash}}">Vector</a>
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{/each}}
|
||||||
|
</div>
|
||||||
|
<h2 class="box-header">Data</h2>
|
||||||
|
<div class="box">
|
||||||
|
{{#each data}}
|
||||||
|
<div class="item">
|
||||||
|
{{#if thumbnail}}
|
||||||
|
<img src="/data/{{@key}}/{{thumbnail}}{{&../key_query}}" alt="{{name}} preview" />
|
||||||
|
{{else}}
|
||||||
|
<img src="/images/placeholder.png" alt="{{name}} preview" />
|
||||||
|
{{/if}}
|
||||||
|
<div class="details">
|
||||||
|
<h3>{{name}}</h3>
|
||||||
|
<p class="identifier">identifier: {{@key}}{{#if formatted_filesize}} | size: {{formatted_filesize}}{{/if}} | type: {{#is_vector}}vector{{/is_vector}}{{^is_vector}}raster{{/is_vector}} data</p>
|
||||||
|
<p class="services">
|
||||||
|
services: <a href="/data/{{@key}}.json{{&../key_query}}">TileJSON</a>
|
||||||
|
{{#if wmts_link}}
|
||||||
|
| <a href="{{&wmts_link}}">WMTS</a>
|
||||||
|
{{/if}}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="viewers">
|
||||||
|
{{#is_vector}}
|
||||||
|
<a class="btn" href="/data/{{@key}}/{{&../key_query}}{{viewer_hash}}">X-Ray view</a>
|
||||||
|
{{/is_vector}}
|
||||||
|
{{^is_vector}}
|
||||||
|
<a class="btn" href="/data/{{@key}}/{{&../key_query}}{{viewer_hash}}">Raster view</a>
|
||||||
|
{{/is_vector}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{/each}}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<footer>
|
||||||
|
<a href="https://www.klokantech.com/" target="_blank"><img src="/images/klokantech.png" /></a>
|
||||||
|
<p>
|
||||||
|
<a href="https://github.com/klokantech/tileserver-gl" target="_blank">Powered by TileServer-GL v{{server_version}}</a> – <a href="https://www.klokantech.com/" target="_blank">open-source project from Klokan Technologies GmbH.</a>
|
||||||
|
</p>
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
42
public/templates/viewer.tmpl
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>{{name}} - TileServer GL</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/mapbox-gl.css{{&key_query}}" />
|
||||||
|
<script src="/mapbox-gl.js{{&key_query}}"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/mapbox.css{{&key_query}}" />
|
||||||
|
<script src="/mapbox.js{{&key_query}}"></script>
|
||||||
|
<script src="/leaflet-hash.js{{&key_query}}"></script>
|
||||||
|
<style>
|
||||||
|
body { margin:0; padding:0; }
|
||||||
|
#map { position:absolute; top:0; bottom:0; width:100%; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1 style="display:none;">{{name}}</h1>
|
||||||
|
<div id='map'></div>
|
||||||
|
<script>
|
||||||
|
var q = (location.search || '').substr(1).split('&');
|
||||||
|
var preference =
|
||||||
|
q.indexOf('vector') >= 0 ? 'vector' :
|
||||||
|
(q.indexOf('raster') >= 0 ? 'raster' :
|
||||||
|
(mapboxgl.supported() ? 'vector' : 'raster'));
|
||||||
|
if (preference == 'vector') {
|
||||||
|
var map = new mapboxgl.Map({
|
||||||
|
container: 'map',
|
||||||
|
style: '/styles/{{id}}.json{{&key_query}}',
|
||||||
|
hash: true
|
||||||
|
});
|
||||||
|
map.addControl(new mapboxgl.Navigation());
|
||||||
|
} else {
|
||||||
|
var map = L.mapbox.map('map', '/styles/{{id}}/rendered.json{{&key_query}}', { zoomControl: false });
|
||||||
|
new L.Control.Zoom({ position: 'topright' }).addTo(map);
|
||||||
|
setTimeout(function() {
|
||||||
|
new L.Hash(map);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
11
run.sh
@@ -1,2 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
xvfb-run --server-args="-screen 0 1024x768x24" node /usr/src/app/src/main.js -p 80 -c /data/config.json
|
if [ ! -f /data/config.json ]; then
|
||||||
|
echo "INFO: No config.json found! Downloading sample data..."
|
||||||
|
echo "--------------------------------------------------------------------------------"
|
||||||
|
curl -L -o sample_data.zip https://github.com/klokantech/tileserver-gl-data/archive/v0.8.0.zip
|
||||||
|
unzip -q sample_data.zip -d sample_data
|
||||||
|
mv sample_data/tileserver-gl-data-*/* -t /data
|
||||||
|
rm sample_data.zip
|
||||||
|
rm -r sample_data
|
||||||
|
fi
|
||||||
|
xvfb-run -a -e /dev/stdout --server-args="-screen 0 1024x768x24" node /usr/src/app/src/main.js -p 80 -c /data/config.json
|
||||||
|
|||||||
85
src/serve_data.js
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var fs = require('fs'),
|
||||||
|
path = require('path');
|
||||||
|
|
||||||
|
var clone = require('clone'),
|
||||||
|
express = require('express'),
|
||||||
|
mbtiles = require('mbtiles');
|
||||||
|
|
||||||
|
var utils = require('./utils');
|
||||||
|
|
||||||
|
module.exports = function(options, repo, params, id) {
|
||||||
|
var app = express().disable('x-powered-by');
|
||||||
|
|
||||||
|
var mbtilesFile = path.join(options.paths.mbtiles, params.mbtiles);
|
||||||
|
var tileJSON = {
|
||||||
|
'tiles': params.domains || options.domains
|
||||||
|
};
|
||||||
|
|
||||||
|
repo[id] = tileJSON;
|
||||||
|
|
||||||
|
var source = new mbtiles(mbtilesFile, function(err) {
|
||||||
|
source.getInfo(function(err, info) {
|
||||||
|
tileJSON['name'] = id;
|
||||||
|
tileJSON['format'] = 'pbf';
|
||||||
|
|
||||||
|
Object.assign(tileJSON, info);
|
||||||
|
|
||||||
|
tileJSON['tilejson'] = '2.0.0';
|
||||||
|
tileJSON['basename'] = id;
|
||||||
|
tileJSON['filesize'] = fs.statSync(mbtilesFile)['size'];
|
||||||
|
delete tileJSON['scheme'];
|
||||||
|
|
||||||
|
Object.assign(tileJSON, params.tilejson || {});
|
||||||
|
utils.fixTileJSONCenter(tileJSON);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
var tilePattern = '/' + id + '/:z(\\d+)/:x(\\d+)/:y(\\d+).:format([\\w]+)';
|
||||||
|
|
||||||
|
app.get(tilePattern, function(req, res, next) {
|
||||||
|
var z = req.params.z | 0,
|
||||||
|
x = req.params.x | 0,
|
||||||
|
y = req.params.y | 0;
|
||||||
|
if (req.params.format != tileJSON.format) {
|
||||||
|
return res.status(404).send('Invalid format');
|
||||||
|
}
|
||||||
|
if (z < tileJSON.minzoom || 0 || x < 0 || y < 0 ||
|
||||||
|
z > tileJSON.maxzoom ||
|
||||||
|
x >= Math.pow(2, z) || y >= Math.pow(2, z)) {
|
||||||
|
return res.status(404).send('Out of bounds');
|
||||||
|
}
|
||||||
|
source.getTile(z, x, y, function(err, data, headers) {
|
||||||
|
if (err) {
|
||||||
|
if (/does not exist/.test(err.message)) {
|
||||||
|
return res.status(404).send(err.message);
|
||||||
|
} else {
|
||||||
|
return res.status(500).send(err.message);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (tileJSON['format'] == 'pbf') {
|
||||||
|
headers['Content-Type'] = 'application/x-protobuf';
|
||||||
|
headers['Content-Encoding'] = 'gzip';
|
||||||
|
}
|
||||||
|
delete headers['ETag']; // do not trust the tile ETag -- regenerate
|
||||||
|
res.set(headers);
|
||||||
|
|
||||||
|
if (data == null) {
|
||||||
|
return res.status(404).send('Not found');
|
||||||
|
} else {
|
||||||
|
return res.status(200).send(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
app.get('/' + id + '.json', function(req, res, next) {
|
||||||
|
var info = clone(tileJSON);
|
||||||
|
info.tiles = utils.getTileUrls(req, info.tiles,
|
||||||
|
'data/' + id, info.format);
|
||||||
|
return res.send(info);
|
||||||
|
});
|
||||||
|
|
||||||
|
return app;
|
||||||
|
};
|
||||||
33
src/serve_font.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var clone = require('clone'),
|
||||||
|
express = require('express');
|
||||||
|
|
||||||
|
var utils = require('./utils');
|
||||||
|
|
||||||
|
module.exports = function(options, allowedFonts) {
|
||||||
|
var app = express().disable('x-powered-by');
|
||||||
|
|
||||||
|
var lastModified = new Date().toUTCString();
|
||||||
|
|
||||||
|
var fontPath = options.paths.fonts;
|
||||||
|
|
||||||
|
app.get('/:fontstack/:range([\\d]+-[\\d]+).pbf',
|
||||||
|
function(req, res, next) {
|
||||||
|
var fontstack = decodeURI(req.params.fontstack);
|
||||||
|
var range = req.params.range;
|
||||||
|
|
||||||
|
return utils.getFontsPbf(allowedFonts, fontPath, fontstack, range,
|
||||||
|
function(err, concated) {
|
||||||
|
if (err || concated.length === 0) {
|
||||||
|
return res.status(400).send('');
|
||||||
|
} else {
|
||||||
|
res.header('Content-type', 'application/x-protobuf');
|
||||||
|
res.header('Last-Modified', lastModified);
|
||||||
|
return res.send(concated);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return app;
|
||||||
|
};
|
||||||
@@ -1,302 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
var async = require('async'),
|
|
||||||
advancedPool = require('advanced-pool'),
|
|
||||||
crypto = require('crypto'),
|
|
||||||
fs = require('fs'),
|
|
||||||
path = require('path'),
|
|
||||||
util = require('util'),
|
|
||||||
zlib = require('zlib');
|
|
||||||
|
|
||||||
var clone = require('clone'),
|
|
||||||
express = require('express'),
|
|
||||||
mercator = new (require('sphericalmercator'))(),
|
|
||||||
mbgl = require('mapbox-gl-native'),
|
|
||||||
mbtiles = require('mbtiles'),
|
|
||||||
request = require('request'),
|
|
||||||
sharp = require('sharp');
|
|
||||||
|
|
||||||
var utils = require('./utils');
|
|
||||||
|
|
||||||
var FLOAT_PATTERN = '[+-]?(?:\\d+|\\d+\.?\\d+)';
|
|
||||||
var SCALE_PATTERN = '@[23]x';
|
|
||||||
|
|
||||||
var getScale = function(scale) {
|
|
||||||
return (scale || '@1x').slice(1, 2) | 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
mbgl.on('message', function(e) {
|
|
||||||
if (e.severity == 'WARNING' || e.severity == 'ERROR') {
|
|
||||||
console.log('mbgl:', e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = function(maps, options, prefix) {
|
|
||||||
var app = express().disable('x-powered-by'),
|
|
||||||
domains = options.domains,
|
|
||||||
tilePath = '/{z}/{x}/{y}.{format}';
|
|
||||||
|
|
||||||
var rootPath = path.join(process.cwd(), options.root || '');
|
|
||||||
|
|
||||||
var styleUrl = options.style;
|
|
||||||
var map = {
|
|
||||||
renderers: [],
|
|
||||||
sources: {},
|
|
||||||
tileJSON: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
var styleJSON;
|
|
||||||
var createPool = function(ratio, min, max) {
|
|
||||||
var createRenderer = function(ratio, createCallback) {
|
|
||||||
var renderer = new mbgl.Map({
|
|
||||||
ratio: ratio,
|
|
||||||
request: function(req, callback) {
|
|
||||||
var protocol = req.url.split(':')[0];
|
|
||||||
//console.log('Handling request:', req);
|
|
||||||
if (protocol == req.url) {
|
|
||||||
fs.readFile(path.join(rootPath, unescape(req.url)), function(err, data) {
|
|
||||||
callback(err, { data: data });
|
|
||||||
});
|
|
||||||
} else if (protocol == 'mbtiles') {
|
|
||||||
var parts = req.url.split('/');
|
|
||||||
var source = map.sources[parts[2]];
|
|
||||||
var z = parts[3] | 0,
|
|
||||||
x = parts[4] | 0,
|
|
||||||
y = parts[5].split('.')[0] | 0;
|
|
||||||
source.getTile(z, x, y, function(err, data, headers) {
|
|
||||||
if (err) {
|
|
||||||
//console.log('MBTiles error, serving empty', err);
|
|
||||||
callback(null, { data: new Buffer(0) });
|
|
||||||
} else {
|
|
||||||
var response = {};
|
|
||||||
|
|
||||||
if (headers['Last-Modified']) {
|
|
||||||
response.modified = new Date(headers['Last-Modified']);
|
|
||||||
}
|
|
||||||
if (headers['ETag']) {
|
|
||||||
response.etag = headers['ETag'];
|
|
||||||
}
|
|
||||||
|
|
||||||
response.data = zlib.unzipSync(data);
|
|
||||||
|
|
||||||
callback(null, response);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (protocol == 'http' || protocol == 'https') {
|
|
||||||
request({
|
|
||||||
url: req.url,
|
|
||||||
encoding: null,
|
|
||||||
gzip: true
|
|
||||||
}, function(err, res, body) {
|
|
||||||
if (err) {
|
|
||||||
//console.log('HTTP tile error', err);
|
|
||||||
callback(null, { data: new Buffer(0) });
|
|
||||||
} else if (res.statusCode == 200) {
|
|
||||||
var response = {};
|
|
||||||
|
|
||||||
if (res.headers.modified) {
|
|
||||||
response.modified = new Date(res.headers.modified);
|
|
||||||
}
|
|
||||||
if (res.headers.expires) {
|
|
||||||
response.expires = new Date(res.headers.expires);
|
|
||||||
}
|
|
||||||
if (res.headers.etag) {
|
|
||||||
response.etag = res.headers.etag;
|
|
||||||
}
|
|
||||||
|
|
||||||
response.data = body;
|
|
||||||
|
|
||||||
callback(null, response);
|
|
||||||
} else {
|
|
||||||
//console.log('HTTP error', JSON.parse(body).message);
|
|
||||||
callback(null, { data: new Buffer(0) });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
renderer.load(styleJSON);
|
|
||||||
createCallback(null, renderer);
|
|
||||||
};
|
|
||||||
return new advancedPool.Pool({
|
|
||||||
min: min,
|
|
||||||
max: max,
|
|
||||||
create: createRenderer.bind(null, ratio),
|
|
||||||
destroy: function(renderer) {
|
|
||||||
renderer.release();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
styleJSON = require(path.join(rootPath, styleUrl));
|
|
||||||
|
|
||||||
map.tileJSON = {
|
|
||||||
'tilejson': '2.0.0',
|
|
||||||
'name': styleJSON.name,
|
|
||||||
'basename': prefix.substr(1),
|
|
||||||
'minzoom': 0,
|
|
||||||
'maxzoom': 20,
|
|
||||||
'bounds': [-180, -85.0511, 180, 85.0511],
|
|
||||||
'format': 'png',
|
|
||||||
'type': 'baselayer'
|
|
||||||
};
|
|
||||||
Object.assign(map.tileJSON, options.options || {});
|
|
||||||
|
|
||||||
var queue = [];
|
|
||||||
Object.keys(styleJSON.sources).forEach(function(name) {
|
|
||||||
var source = styleJSON.sources[name];
|
|
||||||
var url = source.url;
|
|
||||||
if (url.lastIndexOf('mbtiles:', 0) === 0) {
|
|
||||||
// found mbtiles source, replace with info from local file
|
|
||||||
delete source.url;
|
|
||||||
|
|
||||||
queue.push(function(callback) {
|
|
||||||
var mbtilesUrl = url.substring('mbtiles://'.length);
|
|
||||||
map.sources[name] = new mbtiles(path.join(rootPath, mbtilesUrl), function(err) {
|
|
||||||
map.sources[name].getInfo(function(err, info) {
|
|
||||||
Object.assign(source, info);
|
|
||||||
source.basename = name;
|
|
||||||
source.tiles = [
|
|
||||||
// meta url which will be detected when requested
|
|
||||||
'mbtiles://' + name + tilePath.replace('{format}', 'pbf')
|
|
||||||
];
|
|
||||||
callback(null);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
async.parallel(queue, function(err, results) {
|
|
||||||
// TODO: make pool sizes configurable
|
|
||||||
map.renderers[1] = createPool(1, 4, 16);
|
|
||||||
map.renderers[2] = createPool(2, 2, 8);
|
|
||||||
map.renderers[3] = createPool(3, 2, 4);
|
|
||||||
});
|
|
||||||
|
|
||||||
maps[prefix] = map;
|
|
||||||
|
|
||||||
var tilePattern = tilePath
|
|
||||||
.replace(/\.(?!.*\.)/, ':scale(' + SCALE_PATTERN + ')?.')
|
|
||||||
.replace(/\./g, '\.')
|
|
||||||
.replace('{z}', ':z(\\d+)')
|
|
||||||
.replace('{x}', ':x(\\d+)')
|
|
||||||
.replace('{y}', ':y(\\d+)')
|
|
||||||
.replace('{format}', ':format([\\w\\.]+)');
|
|
||||||
|
|
||||||
var respondImage = function(z, lon, lat, width, height, scale, format, res, next) {
|
|
||||||
if (format == 'png' || format == 'webp') {
|
|
||||||
} else if (format == 'jpg' || format == 'jpeg') {
|
|
||||||
format = 'jpeg';
|
|
||||||
} else {
|
|
||||||
return res.status(404).send('Invalid format');
|
|
||||||
}
|
|
||||||
|
|
||||||
var pool = map.renderers[scale];
|
|
||||||
pool.acquire(function(err, renderer) {
|
|
||||||
var mbglZ = Math.max(0, z - 1);
|
|
||||||
var params = {
|
|
||||||
zoom: mbglZ,
|
|
||||||
center: [lon, lat],
|
|
||||||
width: width,
|
|
||||||
height: height
|
|
||||||
};
|
|
||||||
if (z == 0) {
|
|
||||||
params.width *= 2;
|
|
||||||
params.height *= 2;
|
|
||||||
}
|
|
||||||
renderer.render(params, function(err, data) {
|
|
||||||
pool.release(renderer);
|
|
||||||
if (err) console.log(err);
|
|
||||||
|
|
||||||
var image = sharp(data, {
|
|
||||||
raw: {
|
|
||||||
width: params.width * scale,
|
|
||||||
height: params.height * scale,
|
|
||||||
channels: 4
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (z == 0) {
|
|
||||||
// HACK: when serving zoom 0, resize the 0 tile from 512 to 256
|
|
||||||
image.resize(width * scale, height * scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
image.toFormat(format)
|
|
||||||
.compressionLevel(9)
|
|
||||||
.toBuffer(function(err, buffer, info) {
|
|
||||||
if (!buffer) {
|
|
||||||
return res.status(404).send('Not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
var md5 = crypto.createHash('md5').update(buffer).digest('base64');
|
|
||||||
res.set({
|
|
||||||
'content-md5': md5,
|
|
||||||
'content-type': 'image/' + format
|
|
||||||
});
|
|
||||||
return res.status(200).send(buffer);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
app.get(tilePattern, function(req, res, next) {
|
|
||||||
var z = req.params.z | 0,
|
|
||||||
x = req.params.x | 0,
|
|
||||||
y = req.params.y | 0,
|
|
||||||
scale = getScale(req.params.scale),
|
|
||||||
format = req.params.format;
|
|
||||||
var tileSize = 256;
|
|
||||||
var tileCenter = mercator.ll([
|
|
||||||
((x + 0.5) / (1 << z)) * (256 << z),
|
|
||||||
((y + 0.5) / (1 << z)) * (256 << z)
|
|
||||||
], z);
|
|
||||||
return respondImage(z, tileCenter[0], tileCenter[1], tileSize, tileSize,
|
|
||||||
scale, format, res, next);
|
|
||||||
});
|
|
||||||
|
|
||||||
var staticPattern =
|
|
||||||
'/static/%s:scale(' + SCALE_PATTERN + ')?\.:format([\\w\\.]+)';
|
|
||||||
|
|
||||||
var centerPattern =
|
|
||||||
util.format(':lon(%s),:lat(%s),:z(\\d+)/:width(\\d+)x:height(\\d+)',
|
|
||||||
FLOAT_PATTERN, FLOAT_PATTERN);
|
|
||||||
|
|
||||||
app.get(util.format(staticPattern, centerPattern), function(req, res, next) {
|
|
||||||
var z = req.params.z | 0,
|
|
||||||
x = +req.params.lon,
|
|
||||||
y = +req.params.lat,
|
|
||||||
w = req.params.width | 0,
|
|
||||||
h = req.params.height | 0,
|
|
||||||
scale = getScale(req.params.scale),
|
|
||||||
format = req.params.format;
|
|
||||||
return respondImage(z, x, y, w, h, scale, format, res, next);
|
|
||||||
});
|
|
||||||
|
|
||||||
var boundsPattern =
|
|
||||||
util.format(':minx(%s),:miny(%s),:maxx(%s),:maxy(%s)/:z(\\d+)',
|
|
||||||
FLOAT_PATTERN, FLOAT_PATTERN, FLOAT_PATTERN, FLOAT_PATTERN);
|
|
||||||
|
|
||||||
app.get(util.format(staticPattern, boundsPattern), function(req, res, next) {
|
|
||||||
var z = req.params.z | 0,
|
|
||||||
x = ((+req.params.minx) + (+req.params.maxx)) / 2,
|
|
||||||
y = ((+req.params.miny) + (+req.params.maxy)) / 2,
|
|
||||||
w = req.params.width | 0,
|
|
||||||
h = req.params.height | 0,
|
|
||||||
scale = getScale(req.params.scale),
|
|
||||||
format = req.params.format;
|
|
||||||
return respondImage(z, x, y, w, h, scale, format, res, next);
|
|
||||||
});
|
|
||||||
|
|
||||||
app.get('/index.json', function(req, res, next) {
|
|
||||||
var info = clone(map.tileJSON);
|
|
||||||
|
|
||||||
info.tiles = utils.getTileUrls(req.protocol, domains, req.headers.host,
|
|
||||||
prefix, tilePath, info.format,
|
|
||||||
req.query.key);
|
|
||||||
|
|
||||||
return res.send(info);
|
|
||||||
});
|
|
||||||
|
|
||||||
return app;
|
|
||||||
};
|
|
||||||
512
src/serve_rendered.js
Normal file
@@ -0,0 +1,512 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var async = require('async'),
|
||||||
|
advancedPool = require('advanced-pool'),
|
||||||
|
fs = require('fs'),
|
||||||
|
path = require('path'),
|
||||||
|
util = require('util'),
|
||||||
|
zlib = require('zlib');
|
||||||
|
|
||||||
|
// sharp has to be required before node-canvas
|
||||||
|
// see https://github.com/lovell/sharp/issues/371
|
||||||
|
var sharp = require('sharp');
|
||||||
|
|
||||||
|
var Canvas = require('canvas'),
|
||||||
|
clone = require('clone'),
|
||||||
|
Color = require('color'),
|
||||||
|
express = require('express'),
|
||||||
|
mercator = new (require('sphericalmercator'))(),
|
||||||
|
mbgl = require('mapbox-gl-native'),
|
||||||
|
mbtiles = require('mbtiles'),
|
||||||
|
request = require('request');
|
||||||
|
|
||||||
|
var utils = require('./utils');
|
||||||
|
|
||||||
|
var FLOAT_PATTERN = '[+-]?(?:\\d+|\\d+\.?\\d+)';
|
||||||
|
var SCALE_PATTERN = '@[23]x';
|
||||||
|
|
||||||
|
var getScale = function(scale) {
|
||||||
|
return (scale || '@1x').slice(1, 2) | 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
mbgl.on('message', function(e) {
|
||||||
|
if (e.severity == 'WARNING' || e.severity == 'ERROR') {
|
||||||
|
console.log('mbgl:', e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = function(options, repo, params, id) {
|
||||||
|
var app = express().disable('x-powered-by');
|
||||||
|
|
||||||
|
var lastModified = new Date().toUTCString();
|
||||||
|
|
||||||
|
var rootPath = options.paths.root;
|
||||||
|
|
||||||
|
var styleFile = params.style;
|
||||||
|
var map = {
|
||||||
|
renderers: [],
|
||||||
|
sources: {}
|
||||||
|
};
|
||||||
|
|
||||||
|
var styleJSON;
|
||||||
|
var createPool = function(ratio, min, max) {
|
||||||
|
var createRenderer = function(ratio, createCallback) {
|
||||||
|
var renderer = new mbgl.Map({
|
||||||
|
ratio: ratio,
|
||||||
|
request: function(req, callback) {
|
||||||
|
var protocol = req.url.split(':')[0];
|
||||||
|
//console.log('Handling request:', req);
|
||||||
|
if (protocol == 'sprites') {
|
||||||
|
var dir = options.paths[protocol];
|
||||||
|
var file = unescape(req.url).substring(protocol.length + 3);
|
||||||
|
fs.readFile(path.join(dir, file), function(err, data) {
|
||||||
|
callback(err, { data: data });
|
||||||
|
});
|
||||||
|
} else if (protocol == 'fonts') {
|
||||||
|
var parts = req.url.split('/');
|
||||||
|
var fontstack = unescape(parts[2]);
|
||||||
|
var range = parts[3].split('.')[0];
|
||||||
|
utils.getFontsPbf(null, options.paths[protocol], fontstack, range,
|
||||||
|
function(err, concated) {
|
||||||
|
callback(err, {data: concated});
|
||||||
|
});
|
||||||
|
} else if (protocol == 'mbtiles') {
|
||||||
|
var parts = req.url.split('/');
|
||||||
|
var source = map.sources[parts[2]];
|
||||||
|
var z = parts[3] | 0,
|
||||||
|
x = parts[4] | 0,
|
||||||
|
y = parts[5].split('.')[0] | 0,
|
||||||
|
format = parts[5].split('.')[1];
|
||||||
|
source.getTile(z, x, y, function(err, data, headers) {
|
||||||
|
if (err) {
|
||||||
|
//console.log('MBTiles error, serving empty', err);
|
||||||
|
callback(null, { data: source.emptyTile });
|
||||||
|
} else {
|
||||||
|
var response = {};
|
||||||
|
|
||||||
|
if (headers['Last-Modified']) {
|
||||||
|
response.modified = new Date(headers['Last-Modified']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (format == 'pbf') {
|
||||||
|
response.data = zlib.unzipSync(data);
|
||||||
|
} else {
|
||||||
|
response.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(null, response);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (protocol == 'http' || protocol == 'https') {
|
||||||
|
request({
|
||||||
|
url: req.url,
|
||||||
|
encoding: null,
|
||||||
|
gzip: true
|
||||||
|
}, function(err, res, body) {
|
||||||
|
if (err) {
|
||||||
|
//console.log('HTTP tile error', err);
|
||||||
|
callback(null, { data: new Buffer(0) });
|
||||||
|
} else if (res.statusCode == 200) {
|
||||||
|
var response = {};
|
||||||
|
|
||||||
|
if (res.headers.modified) {
|
||||||
|
response.modified = new Date(res.headers.modified);
|
||||||
|
}
|
||||||
|
if (res.headers.expires) {
|
||||||
|
response.expires = new Date(res.headers.expires);
|
||||||
|
}
|
||||||
|
if (res.headers.etag) {
|
||||||
|
response.etag = res.headers.etag;
|
||||||
|
}
|
||||||
|
|
||||||
|
response.data = body;
|
||||||
|
|
||||||
|
callback(null, response);
|
||||||
|
} else {
|
||||||
|
//console.log('HTTP error', JSON.parse(body).message);
|
||||||
|
callback(null, { data: new Buffer(0) });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
renderer.load(styleJSON);
|
||||||
|
createCallback(null, renderer);
|
||||||
|
};
|
||||||
|
return new advancedPool.Pool({
|
||||||
|
min: min,
|
||||||
|
max: max,
|
||||||
|
create: createRenderer.bind(null, ratio),
|
||||||
|
destroy: function(renderer) {
|
||||||
|
renderer.release();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
styleJSON = clone(require(path.join(options.paths.styles, styleFile)));
|
||||||
|
styleJSON.sprite = 'sprites://' + path.basename(styleFile, '.json');
|
||||||
|
styleJSON.glyphs = 'fonts://{fontstack}/{range}.pbf';
|
||||||
|
|
||||||
|
var tileJSON = {
|
||||||
|
'tilejson': '2.0.0',
|
||||||
|
'name': styleJSON.name,
|
||||||
|
'attribution': '',
|
||||||
|
'basename': id,
|
||||||
|
'minzoom': 0,
|
||||||
|
'maxzoom': 20,
|
||||||
|
'bounds': [-180, -85.0511, 180, 85.0511],
|
||||||
|
'format': 'png',
|
||||||
|
'type': 'baselayer'
|
||||||
|
};
|
||||||
|
var attributionOverride = params.tilejson && params.tilejson.attribution;
|
||||||
|
Object.assign(tileJSON, params.tilejson || {});
|
||||||
|
tileJSON.tiles = params.domains || options.domains;
|
||||||
|
utils.fixTileJSONCenter(tileJSON);
|
||||||
|
|
||||||
|
var queue = [];
|
||||||
|
Object.keys(styleJSON.sources).forEach(function(name) {
|
||||||
|
var source = styleJSON.sources[name];
|
||||||
|
var url = source.url;
|
||||||
|
if (url.lastIndexOf('mbtiles:', 0) === 0) {
|
||||||
|
// found mbtiles source, replace with info from local file
|
||||||
|
delete source.url;
|
||||||
|
|
||||||
|
queue.push(function(callback) {
|
||||||
|
var mbtilesFile = url.substring('mbtiles://'.length);
|
||||||
|
map.sources[name] = new mbtiles(
|
||||||
|
path.join(options.paths.mbtiles, mbtilesFile), function(err) {
|
||||||
|
map.sources[name].getInfo(function(err, info) {
|
||||||
|
var type = source.type;
|
||||||
|
Object.assign(source, info);
|
||||||
|
source.type = type;
|
||||||
|
source.basename = name;
|
||||||
|
source.tiles = [
|
||||||
|
// meta url which will be detected when requested
|
||||||
|
'mbtiles://' + name + '/{z}/{x}/{y}.' + (info.format || 'pbf')
|
||||||
|
];
|
||||||
|
if (source.format == 'pbf') {
|
||||||
|
map.sources[name].emptyTile = new Buffer(0);
|
||||||
|
} else {
|
||||||
|
var color = new Color(source.color || '#fff');
|
||||||
|
var format = source.format;
|
||||||
|
if (format == 'jpg') {
|
||||||
|
format = 'jpeg';
|
||||||
|
}
|
||||||
|
sharp(new Buffer(color.rgbArray()), {
|
||||||
|
raw: {
|
||||||
|
width: 1,
|
||||||
|
height: 1,
|
||||||
|
channels: 3
|
||||||
|
}
|
||||||
|
}).toFormat(format).toBuffer(function(err, buffer, info) {
|
||||||
|
map.sources[name].emptyTile = buffer;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!attributionOverride &&
|
||||||
|
source.attribution && source.attribution.length > 0) {
|
||||||
|
if (tileJSON.attribution.length > 0) {
|
||||||
|
tileJSON.attribution += '; ';
|
||||||
|
}
|
||||||
|
tileJSON.attribution += source.attribution;
|
||||||
|
}
|
||||||
|
callback(null);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
async.parallel(queue, function(err, results) {
|
||||||
|
// TODO: make pool sizes configurable
|
||||||
|
map.renderers[1] = createPool(1, 4, 16);
|
||||||
|
map.renderers[2] = createPool(2, 2, 8);
|
||||||
|
map.renderers[3] = createPool(3, 2, 4);
|
||||||
|
});
|
||||||
|
|
||||||
|
repo[id] = tileJSON;
|
||||||
|
|
||||||
|
var tilePattern = '/rendered/:z(\\d+)/:x(\\d+)/:y(\\d+)' +
|
||||||
|
':scale(' + SCALE_PATTERN + ')?\.:format([\\w]+)';
|
||||||
|
|
||||||
|
var respondImage = function(z, lon, lat, bearing, pitch,
|
||||||
|
width, height, scale, format, res, next,
|
||||||
|
opt_overlay) {
|
||||||
|
if (Math.abs(lon) > 180 || Math.abs(lat) > 85.06) {
|
||||||
|
return res.status(400).send('Invalid center');
|
||||||
|
}
|
||||||
|
if (Math.min(width, height) <= 0 ||
|
||||||
|
Math.max(width, height) * scale > 2048) {
|
||||||
|
return res.status(400).send('Invalid size');
|
||||||
|
}
|
||||||
|
if (format == 'png' || format == 'webp') {
|
||||||
|
} else if (format == 'jpg' || format == 'jpeg') {
|
||||||
|
format = 'jpeg';
|
||||||
|
} else {
|
||||||
|
return res.status(400).send('Invalid format');
|
||||||
|
}
|
||||||
|
|
||||||
|
var pool = map.renderers[scale];
|
||||||
|
pool.acquire(function(err, renderer) {
|
||||||
|
var mbglZ = Math.max(0, z - 1);
|
||||||
|
var params = {
|
||||||
|
zoom: mbglZ,
|
||||||
|
center: [lon, lat],
|
||||||
|
bearing: bearing,
|
||||||
|
pitch: pitch,
|
||||||
|
width: width,
|
||||||
|
height: height
|
||||||
|
};
|
||||||
|
if (z == 0) {
|
||||||
|
params.width *= 2;
|
||||||
|
params.height *= 2;
|
||||||
|
}
|
||||||
|
renderer.render(params, function(err, data) {
|
||||||
|
pool.release(renderer);
|
||||||
|
if (err) console.log(err);
|
||||||
|
|
||||||
|
var image = sharp(data, {
|
||||||
|
raw: {
|
||||||
|
width: params.width * scale,
|
||||||
|
height: params.height * scale,
|
||||||
|
channels: 4
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (z == 0) {
|
||||||
|
// HACK: when serving zoom 0, resize the 0 tile from 512 to 256
|
||||||
|
image.resize(width * scale, height * scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opt_overlay) {
|
||||||
|
image.overlayWith(opt_overlay);
|
||||||
|
}
|
||||||
|
|
||||||
|
image.toFormat(format);
|
||||||
|
|
||||||
|
var formatEncoding = (params.formatEncoding || {})[format] ||
|
||||||
|
(options.formatEncoding || {})[format];
|
||||||
|
if (format == 'png') {
|
||||||
|
image.compressionLevel(formatEncoding || 6)
|
||||||
|
.withoutAdaptiveFiltering();
|
||||||
|
} else if (format == 'jpeg') {
|
||||||
|
image.quality(formatEncoding || 80);
|
||||||
|
} else if (format == 'webp') {
|
||||||
|
image.quality(formatEncoding || 90);
|
||||||
|
}
|
||||||
|
image.toBuffer(function(err, buffer, info) {
|
||||||
|
if (!buffer) {
|
||||||
|
return res.status(404).send('Not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
res.set({
|
||||||
|
'Last-Modified': lastModified,
|
||||||
|
'Content-Type': 'image/' + format
|
||||||
|
});
|
||||||
|
return res.status(200).send(buffer);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
app.get(tilePattern, function(req, res, next) {
|
||||||
|
var modifiedSince = req.get('if-modified-since'), cc = req.get('cache-control');
|
||||||
|
if (modifiedSince && (!cc || cc.indexOf('no-cache') == -1)) {
|
||||||
|
if (new Date(lastModified) <= new Date(modifiedSince)) {
|
||||||
|
return res.sendStatus(304);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var z = req.params.z | 0,
|
||||||
|
x = req.params.x | 0,
|
||||||
|
y = req.params.y | 0,
|
||||||
|
scale = getScale(req.params.scale),
|
||||||
|
format = req.params.format;
|
||||||
|
if (z < 0 || x < 0 || y < 0 ||
|
||||||
|
z > 20 || x >= Math.pow(2, z) || y >= Math.pow(2, z)) {
|
||||||
|
return res.status(404).send('Out of bounds');
|
||||||
|
}
|
||||||
|
var tileSize = 256;
|
||||||
|
var tileCenter = mercator.ll([
|
||||||
|
((x + 0.5) / (1 << z)) * (256 << z),
|
||||||
|
((y + 0.5) / (1 << z)) * (256 << z)
|
||||||
|
], z);
|
||||||
|
return respondImage(z, tileCenter[0], tileCenter[1], 0, 0,
|
||||||
|
tileSize, tileSize, scale, format, res, next);
|
||||||
|
});
|
||||||
|
|
||||||
|
var extractPathFromQuery = function(query) {
|
||||||
|
var pathParts = (query.path || '').split('|');
|
||||||
|
var path = [];
|
||||||
|
pathParts.forEach(function(pair) {
|
||||||
|
var pairParts = pair.split(',');
|
||||||
|
if (pairParts.length == 2) {
|
||||||
|
if (query.latlng == '1' || query.latlng == 'true') {
|
||||||
|
path.push([+(pairParts[1]), +(pairParts[0])]);
|
||||||
|
} else {
|
||||||
|
path.push([+(pairParts[0]), +(pairParts[1])]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return path;
|
||||||
|
};
|
||||||
|
|
||||||
|
var renderOverlay = function(z, x, y, bearing, pitch, w, h, scale,
|
||||||
|
path, query) {
|
||||||
|
if (!path || path.length < 2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var precisePx = function(ll, zoom) {
|
||||||
|
var px = mercator.px(ll, 20);
|
||||||
|
var scale = Math.pow(2, zoom - 20);
|
||||||
|
return [px[0] * scale, px[1] * scale];
|
||||||
|
};
|
||||||
|
|
||||||
|
var canvas = new Canvas(scale * w, scale * h);
|
||||||
|
var ctx = canvas.getContext('2d');
|
||||||
|
var center = precisePx([x, y], z);
|
||||||
|
ctx.scale(scale, scale);
|
||||||
|
if (bearing) {
|
||||||
|
ctx.translate(w / 2, h / 2);
|
||||||
|
ctx.rotate(-bearing / 180 * Math.PI);
|
||||||
|
ctx.translate(-center[0], -center[1]);
|
||||||
|
} else {
|
||||||
|
// optimized path
|
||||||
|
ctx.translate(-center[0] + w / 2, -center[1] + h / 2);
|
||||||
|
}
|
||||||
|
var lineWidth = query.width !== undefined ?
|
||||||
|
parseFloat(query.width) : 1;
|
||||||
|
ctx.lineWidth = lineWidth;
|
||||||
|
ctx.strokeStyle = query.stroke || 'rgba(0,64,255,0.7)';
|
||||||
|
ctx.fillStyle = query.fill || 'rgba(255,255,255,0.4)';
|
||||||
|
ctx.beginPath();
|
||||||
|
path.forEach(function(pair) {
|
||||||
|
var px = precisePx(pair, z);
|
||||||
|
ctx.lineTo(px[0], px[1]);
|
||||||
|
});
|
||||||
|
if (path[0][0] == path[path.length - 1][0] &&
|
||||||
|
path[0][1] == path[path.length - 1][1]) {
|
||||||
|
ctx.closePath();
|
||||||
|
}
|
||||||
|
ctx.fill();
|
||||||
|
if (lineWidth > 0) {
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
return canvas.toBuffer();
|
||||||
|
};
|
||||||
|
|
||||||
|
var calcZForBBox = function(bbox, w, h, query) {
|
||||||
|
var z = 25;
|
||||||
|
|
||||||
|
var padding = query.padding !== undefined ?
|
||||||
|
parseFloat(query.padding) : 0.1;
|
||||||
|
|
||||||
|
var minCorner = mercator.px([bbox[0], bbox[3]], z),
|
||||||
|
maxCorner = mercator.px([bbox[2], bbox[1]], z);
|
||||||
|
while ((((maxCorner[0] - minCorner[0]) * (1 + 2 * padding) > w) ||
|
||||||
|
((maxCorner[1] - minCorner[1]) * (1 + 2 * padding) > h)) && z > 0) {
|
||||||
|
z--;
|
||||||
|
minCorner[0] /= 2;
|
||||||
|
minCorner[1] /= 2;
|
||||||
|
maxCorner[0] /= 2;
|
||||||
|
maxCorner[1] /= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return z;
|
||||||
|
};
|
||||||
|
|
||||||
|
var staticPattern =
|
||||||
|
'/static/%s/:width(\\d+)x:height(\\d+)' +
|
||||||
|
':scale(' + SCALE_PATTERN + ')?\.:format([\\w]+)';
|
||||||
|
|
||||||
|
var centerPattern =
|
||||||
|
util.format(':lon(%s),:lat(%s),:z(\\d+)(@:bearing(%s)(,:pitch(%s))?)?',
|
||||||
|
FLOAT_PATTERN, FLOAT_PATTERN, FLOAT_PATTERN, FLOAT_PATTERN);
|
||||||
|
|
||||||
|
app.get(util.format(staticPattern, centerPattern), function(req, res, next) {
|
||||||
|
var z = req.params.z | 0,
|
||||||
|
x = +req.params.lon,
|
||||||
|
y = +req.params.lat,
|
||||||
|
bearing = +(req.params.bearing || '0'),
|
||||||
|
pitch = +(req.params.pitch || '0'),
|
||||||
|
w = req.params.width | 0,
|
||||||
|
h = req.params.height | 0,
|
||||||
|
scale = getScale(req.params.scale),
|
||||||
|
format = req.params.format;
|
||||||
|
|
||||||
|
var path = extractPathFromQuery(req.query);
|
||||||
|
var overlay = renderOverlay(z, x, y, bearing, pitch, w, h, scale,
|
||||||
|
path, req.query);
|
||||||
|
|
||||||
|
return respondImage(z, x, y, bearing, pitch, w, h, scale, format,
|
||||||
|
res, next, overlay);
|
||||||
|
});
|
||||||
|
|
||||||
|
var boundsPattern =
|
||||||
|
util.format(':minx(%s),:miny(%s),:maxx(%s),:maxy(%s)',
|
||||||
|
FLOAT_PATTERN, FLOAT_PATTERN, FLOAT_PATTERN, FLOAT_PATTERN);
|
||||||
|
|
||||||
|
app.get(util.format(staticPattern, boundsPattern), function(req, res, next) {
|
||||||
|
var bbox = [+req.params.minx, +req.params.miny,
|
||||||
|
+req.params.maxx, +req.params.maxy];
|
||||||
|
var w = req.params.width | 0,
|
||||||
|
h = req.params.height | 0,
|
||||||
|
scale = getScale(req.params.scale),
|
||||||
|
format = req.params.format;
|
||||||
|
|
||||||
|
var z = calcZForBBox(bbox, w, h, req.query),
|
||||||
|
x = (bbox[0] + bbox[2]) / 2,
|
||||||
|
y = (bbox[1] + bbox[3]) / 2,
|
||||||
|
bearing = 0,
|
||||||
|
pitch = 0;
|
||||||
|
|
||||||
|
var path = extractPathFromQuery(req.query);
|
||||||
|
var overlay = renderOverlay(z, x, y, bearing, pitch, w, h, scale,
|
||||||
|
path, req.query);
|
||||||
|
return respondImage(z, x, y, bearing, pitch, w, h, scale, format,
|
||||||
|
res, next, overlay);
|
||||||
|
});
|
||||||
|
|
||||||
|
var autoPattern = 'auto';
|
||||||
|
|
||||||
|
app.get(util.format(staticPattern, autoPattern), function(req, res, next) {
|
||||||
|
var path = extractPathFromQuery(req.query);
|
||||||
|
if (path.length < 2) {
|
||||||
|
return res.status(400).send('Invalid path');
|
||||||
|
}
|
||||||
|
|
||||||
|
var w = req.params.width | 0,
|
||||||
|
h = req.params.height | 0,
|
||||||
|
bearing = 0,
|
||||||
|
pitch = 0,
|
||||||
|
scale = getScale(req.params.scale),
|
||||||
|
format = req.params.format;
|
||||||
|
|
||||||
|
var bbox = [Infinity, Infinity, -Infinity, -Infinity];
|
||||||
|
path.forEach(function(pair) {
|
||||||
|
bbox[0] = Math.min(bbox[0], pair[0]);
|
||||||
|
bbox[1] = Math.min(bbox[1], pair[1]);
|
||||||
|
bbox[2] = Math.max(bbox[2], pair[0]);
|
||||||
|
bbox[3] = Math.max(bbox[3], pair[1]);
|
||||||
|
});
|
||||||
|
|
||||||
|
var z = calcZForBBox(bbox, w, h, req.query),
|
||||||
|
x = (bbox[0] + bbox[2]) / 2,
|
||||||
|
y = (bbox[1] + bbox[3]) / 2;
|
||||||
|
|
||||||
|
var overlay = renderOverlay(z, x, y, bearing, pitch, w, h, scale,
|
||||||
|
path, req.query);
|
||||||
|
|
||||||
|
return respondImage(z, x, y, bearing, pitch, w, h, scale, format,
|
||||||
|
res, next, overlay);
|
||||||
|
});
|
||||||
|
|
||||||
|
app.get('/rendered.json', function(req, res, next) {
|
||||||
|
var info = clone(tileJSON);
|
||||||
|
info.tiles = utils.getTileUrls(req, info.tiles,
|
||||||
|
'styles/' + id + '/rendered', info.format);
|
||||||
|
return res.send(info);
|
||||||
|
});
|
||||||
|
|
||||||
|
return app;
|
||||||
|
};
|
||||||
87
src/serve_style.js
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var path = require('path'),
|
||||||
|
fs = require('fs');
|
||||||
|
|
||||||
|
var clone = require('clone'),
|
||||||
|
express = require('express');
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = function(options, repo, params, id, reportTiles, reportFont) {
|
||||||
|
var app = express().disable('x-powered-by');
|
||||||
|
|
||||||
|
var styleFile = path.join(options.paths.styles, params.style);
|
||||||
|
|
||||||
|
var styleJSON = clone(require(styleFile));
|
||||||
|
Object.keys(styleJSON.sources).forEach(function(name) {
|
||||||
|
var source = styleJSON.sources[name];
|
||||||
|
var url = source.url;
|
||||||
|
if (url.lastIndexOf('mbtiles:', 0) === 0) {
|
||||||
|
var mbtiles = url.substring('mbtiles://'.length);
|
||||||
|
var identifier = reportTiles(mbtiles);
|
||||||
|
source.url = 'local://data/' + identifier + '.json';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var findFontReferences = function(obj) {
|
||||||
|
Object.keys(obj).forEach(function(key) {
|
||||||
|
var value = obj[key];
|
||||||
|
if (key == 'text-font') {
|
||||||
|
if (value && value.length > 0) {
|
||||||
|
value.forEach(reportFont);
|
||||||
|
}
|
||||||
|
} else if (value && typeof value == 'object') {
|
||||||
|
findFontReferences(value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
styleJSON.layers.forEach(findFontReferences);
|
||||||
|
|
||||||
|
var spritePath = path.join(options.paths.sprites,
|
||||||
|
path.basename(styleFile, '.json'));
|
||||||
|
|
||||||
|
styleJSON.sprite = 'local://styles/' + id + '/sprite';
|
||||||
|
styleJSON.glyphs = 'local://fonts/{fontstack}/{range}.pbf';
|
||||||
|
|
||||||
|
repo[id] = styleJSON;
|
||||||
|
|
||||||
|
app.get('/' + id + '.json', function(req, res, next) {
|
||||||
|
var fixUrl = function(url, opt_nokey) {
|
||||||
|
var query = '';
|
||||||
|
if (!opt_nokey && req.query.key) {
|
||||||
|
query = '?key=' + req.query.key;
|
||||||
|
}
|
||||||
|
return url.replace(
|
||||||
|
'local://', req.protocol + '://' + req.headers.host + '/') + query;
|
||||||
|
};
|
||||||
|
|
||||||
|
var styleJSON_ = clone(styleJSON);
|
||||||
|
Object.keys(styleJSON_.sources).forEach(function(name) {
|
||||||
|
var source = styleJSON_.sources[name];
|
||||||
|
source.url = fixUrl(source.url);
|
||||||
|
});
|
||||||
|
// mapbox-gl-js viewer cannot handle sprite urls with query
|
||||||
|
styleJSON_.sprite = fixUrl(styleJSON_.sprite, true);
|
||||||
|
styleJSON_.glyphs = fixUrl(styleJSON_.glyphs);
|
||||||
|
return res.send(styleJSON_);
|
||||||
|
});
|
||||||
|
|
||||||
|
app.get('/' + id + '/sprite:scale(@[23]x)?\.:format([\\w]+)',
|
||||||
|
function(req, res, next) {
|
||||||
|
var scale = req.params.scale,
|
||||||
|
format = req.params.format;
|
||||||
|
var filename = spritePath + (scale || '') + '.' + format;
|
||||||
|
return fs.readFile(filename, function(err, data) {
|
||||||
|
if (err) {
|
||||||
|
console.log('Sprite load error:', filename);
|
||||||
|
return res.status(404).send('File not found');
|
||||||
|
} else {
|
||||||
|
if (format == 'json') res.header('Content-type', 'application/json');
|
||||||
|
if (format == 'png') res.header('Content-type', 'image/png');
|
||||||
|
return res.send(data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return app;
|
||||||
|
};
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
var crypto = require('crypto'),
|
|
||||||
path = require('path');
|
|
||||||
|
|
||||||
var clone = require('clone'),
|
|
||||||
express = require('express'),
|
|
||||||
mbtiles = require('mbtiles');
|
|
||||||
|
|
||||||
var utils = require('./utils');
|
|
||||||
|
|
||||||
module.exports = function(maps, options, prefix) {
|
|
||||||
var app = express().disable('x-powered-by'),
|
|
||||||
domains = options.domains,
|
|
||||||
tilePath = '/{z}/{x}/{y}.pbf';
|
|
||||||
|
|
||||||
var rootPath = path.join(process.cwd(), options.root || '');
|
|
||||||
|
|
||||||
var mbtilesPath = options.mbtiles;
|
|
||||||
var map = {
|
|
||||||
tileJSON: {}
|
|
||||||
};
|
|
||||||
maps[prefix] = map;
|
|
||||||
|
|
||||||
var source = new mbtiles(path.join(rootPath, mbtilesPath), function(err) {
|
|
||||||
source.getInfo(function(err, info) {
|
|
||||||
map.tileJSON['name'] = prefix.substr(1);
|
|
||||||
|
|
||||||
Object.assign(map.tileJSON, info);
|
|
||||||
|
|
||||||
map.tileJSON['tilejson'] = '2.0.0';
|
|
||||||
map.tileJSON['basename'] = prefix.substr(1);
|
|
||||||
map.tileJSON['format'] = 'pbf';
|
|
||||||
|
|
||||||
Object.assign(map.tileJSON, options.options || {});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
var tilePattern = tilePath
|
|
||||||
.replace('{z}', ':z(\\d+)')
|
|
||||||
.replace('{x}', ':x(\\d+)')
|
|
||||||
.replace('{y}', ':y(\\d+)');
|
|
||||||
|
|
||||||
var getTile = function(z, x, y, callback) {
|
|
||||||
source.getTile(z, x, y, function(err, data, headers) {
|
|
||||||
if (err) {
|
|
||||||
callback(err);
|
|
||||||
} else {
|
|
||||||
var md5 = crypto.createHash('md5').update(data).digest('base64');
|
|
||||||
headers['content-md5'] = md5;
|
|
||||||
headers['content-type'] = 'application/x-protobuf';
|
|
||||||
headers['content-encoding'] = 'gzip';
|
|
||||||
|
|
||||||
callback(null, data, headers);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
app.get(tilePattern, function(req, res, next) {
|
|
||||||
var z = req.params.z | 0,
|
|
||||||
x = req.params.x | 0,
|
|
||||||
y = req.params.y | 0;
|
|
||||||
return getTile(z, x, y, function(err, data, headers) {
|
|
||||||
if (err) {
|
|
||||||
return next(err);
|
|
||||||
}
|
|
||||||
if (headers) {
|
|
||||||
res.set(headers);
|
|
||||||
}
|
|
||||||
if (data == null) {
|
|
||||||
return res.status(404).send('Not found');
|
|
||||||
} else {
|
|
||||||
return res.status(200).send(data);
|
|
||||||
}
|
|
||||||
}, res, next);
|
|
||||||
});
|
|
||||||
|
|
||||||
app.get('/index.json', function(req, res, next) {
|
|
||||||
var info = clone(map.tileJSON);
|
|
||||||
|
|
||||||
info.tiles = utils.getTileUrls(req.protocol, domains, req.headers.host,
|
|
||||||
prefix, tilePath, info.format,
|
|
||||||
req.query.key);
|
|
||||||
|
|
||||||
return res.send(info);
|
|
||||||
});
|
|
||||||
|
|
||||||
return app;
|
|
||||||
};
|
|
||||||
289
src/server.js
@@ -7,70 +7,293 @@ process.env.UV_THREADPOOL_SIZE =
|
|||||||
var fs = require('fs'),
|
var fs = require('fs'),
|
||||||
path = require('path');
|
path = require('path');
|
||||||
|
|
||||||
var async = require('async'),
|
var base64url = require('base64url'),
|
||||||
clone = require('clone'),
|
clone = require('clone'),
|
||||||
cors = require('cors'),
|
cors = require('cors'),
|
||||||
express = require('express'),
|
express = require('express'),
|
||||||
|
handlebars = require('handlebars'),
|
||||||
|
mercator = new (require('sphericalmercator'))(),
|
||||||
morgan = require('morgan');
|
morgan = require('morgan');
|
||||||
|
|
||||||
var serve_raster = require('./serve_raster'),
|
var packageJson = require('../package'),
|
||||||
serve_vector = require('./serve_vector'),
|
serve_font = require('./serve_font'),
|
||||||
|
serve_rendered = require('./serve_rendered'),
|
||||||
|
serve_style = require('./serve_style'),
|
||||||
|
serve_data = require('./serve_data'),
|
||||||
utils = require('./utils');
|
utils = require('./utils');
|
||||||
|
|
||||||
module.exports = function(opts, callback) {
|
module.exports = function(opts, callback) {
|
||||||
|
console.log('Starting TileServer-GL v' + packageJson.version);
|
||||||
|
|
||||||
var app = express().disable('x-powered-by'),
|
var app = express().disable('x-powered-by'),
|
||||||
maps = {};
|
serving = {
|
||||||
|
styles: {},
|
||||||
|
rendered: {},
|
||||||
|
data: {},
|
||||||
|
fonts: { // default fonts, always expose these (if they exist)
|
||||||
|
'Open Sans Regular': true,
|
||||||
|
'Arial Unicode MS Regular': true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
app.enable('trust proxy');
|
app.enable('trust proxy');
|
||||||
|
|
||||||
callback = callback || function() {};
|
callback = callback || function() {};
|
||||||
|
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== 'production' &&
|
||||||
|
process.env.NODE_ENV !== 'test') {
|
||||||
app.use(morgan('dev'));
|
app.use(morgan('dev'));
|
||||||
}
|
}
|
||||||
|
|
||||||
var configPath = path.resolve(opts.config),
|
var configPath = path.resolve(opts.config);
|
||||||
config = require(configPath);
|
|
||||||
|
|
||||||
Object.keys(config).forEach(function(prefix) {
|
var config;
|
||||||
if (config[prefix].cors !== false) {
|
try {
|
||||||
app.use(prefix, cors());
|
config = clone(require(configPath));
|
||||||
|
} catch (e) {
|
||||||
|
console.log('ERROR: Config file not found or invalid!');
|
||||||
|
console.log(' See README.md for instructions and sample data.');
|
||||||
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config[prefix].style) {
|
var options = config.options || {};
|
||||||
app.use(prefix, serve_raster(maps, config[prefix], prefix));
|
var paths = options.paths || {};
|
||||||
|
options.paths = paths;
|
||||||
|
paths.root = path.resolve(process.cwd(), paths.root || '');
|
||||||
|
paths.styles = path.resolve(paths.root, paths.styles || '');
|
||||||
|
paths.fonts = path.resolve(paths.root, paths.fonts || '');
|
||||||
|
paths.sprites = path.resolve(paths.root, paths.sprites || '');
|
||||||
|
paths.mbtiles = path.resolve(paths.root, paths.mbtiles || '');
|
||||||
|
|
||||||
|
var data = clone(config.data || {});
|
||||||
|
|
||||||
|
app.use(cors());
|
||||||
|
|
||||||
|
Object.keys(config.styles || {}).forEach(function(id) {
|
||||||
|
var item = config.styles[id];
|
||||||
|
if (!item.style || item.style.length == 0) {
|
||||||
|
console.log('Missing "style" property for ' + id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.serve_data !== false) {
|
||||||
|
app.use('/styles/', serve_style(options, serving.styles, item, id,
|
||||||
|
function(mbtiles) {
|
||||||
|
var dataItemId;
|
||||||
|
Object.keys(data).forEach(function(id) {
|
||||||
|
if (data[id].mbtiles == mbtiles) {
|
||||||
|
dataItemId = id;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (dataItemId) { // mbtiles exist in the data config
|
||||||
|
return dataItemId;
|
||||||
} else {
|
} else {
|
||||||
app.use(prefix, serve_vector(maps, config[prefix], prefix));
|
var id = mbtiles.substr(0, mbtiles.lastIndexOf('.')) || mbtiles;
|
||||||
|
while (data[id]) id += '_';
|
||||||
|
data[id] = {
|
||||||
|
'mbtiles': mbtiles
|
||||||
|
};
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}, function(font) {
|
||||||
|
serving.fonts[font] = true;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (item.serve_rendered !== false) {
|
||||||
|
app.use('/styles/' + id + '/',
|
||||||
|
serve_rendered(options, serving.rendered, item, id));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// serve index.html on the root
|
if (Object.keys(serving.styles).length > 0) {
|
||||||
app.use('/', express.static(path.join(__dirname, '../public')));
|
// serve fonts only if serving some styles
|
||||||
|
app.use('/fonts/', serve_font(options, serving.fonts));
|
||||||
|
}
|
||||||
|
|
||||||
// aggregate index.json on root for multiple sources
|
Object.keys(data).forEach(function(id) {
|
||||||
|
var item = data[id];
|
||||||
|
if (!item.mbtiles || item.mbtiles.length == 0) {
|
||||||
|
console.log('Missing "mbtiles" property for ' + id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
app.use('/data/', serve_data(options, serving.data, item, id));
|
||||||
|
});
|
||||||
|
|
||||||
|
app.get('/styles.json', function(req, res, next) {
|
||||||
|
var result = [];
|
||||||
|
var query = req.query.key ? ('?key=' + req.query.key) : '';
|
||||||
|
Object.keys(serving.styles).forEach(function(id) {
|
||||||
|
var styleJSON = serving.styles[id];
|
||||||
|
result.push({
|
||||||
|
version: styleJSON.version,
|
||||||
|
name: styleJSON.name,
|
||||||
|
id: id,
|
||||||
|
url: req.protocol + '://' + req.headers.host +
|
||||||
|
'/styles/' + id + '.json' + query
|
||||||
|
});
|
||||||
|
});
|
||||||
|
res.send(result);
|
||||||
|
});
|
||||||
|
|
||||||
|
var addTileJSONs = function(arr, req, type) {
|
||||||
|
Object.keys(serving[type]).forEach(function(id) {
|
||||||
|
var info = clone(serving[type][id]);
|
||||||
|
info.tiles = utils.getTileUrls(req, info.tiles,
|
||||||
|
type + '/' + id, info.format);
|
||||||
|
arr.push(info);
|
||||||
|
});
|
||||||
|
return arr;
|
||||||
|
};
|
||||||
|
|
||||||
|
app.get('/rendered.json', function(req, res, next) {
|
||||||
|
res.send(addTileJSONs([], req, 'rendered'));
|
||||||
|
});
|
||||||
|
app.get('/data.json', function(req, res, next) {
|
||||||
|
res.send(addTileJSONs([], req, 'data'));
|
||||||
|
});
|
||||||
app.get('/index.json', function(req, res, next) {
|
app.get('/index.json', function(req, res, next) {
|
||||||
var queue = [];
|
res.send(addTileJSONs(addTileJSONs([], req, 'rendered'), req, 'data'));
|
||||||
Object.keys(config).forEach(function(prefix) {
|
|
||||||
var map = maps[prefix];
|
|
||||||
queue.push(function(callback) {
|
|
||||||
var info = clone(map.tileJSON);
|
|
||||||
|
|
||||||
info.tiles = utils.getTileUrls(
|
|
||||||
req.protocol, config[prefix].domains, req.headers.host,
|
|
||||||
prefix, '/{z}/{x}/{y}.{format}', info.format, req.query.key);
|
|
||||||
|
|
||||||
callback(null, info);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return async.parallel(queue, function(err, results) {
|
|
||||||
return res.send(results);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.listen(process.env.PORT || opts.port, function() {
|
//------------------------------------
|
||||||
|
// serve web presentations
|
||||||
|
app.use('/', express.static(path.join(__dirname, '../public/resources')));
|
||||||
|
|
||||||
|
var templates = path.join(__dirname, '../public/templates');
|
||||||
|
var serveTemplate = function(path, template, dataGetter) {
|
||||||
|
fs.readFile(templates + '/' + template + '.tmpl', function(err, content) {
|
||||||
|
if (err) {
|
||||||
|
console.log('Template not found:', err);
|
||||||
|
}
|
||||||
|
var compiled = handlebars.compile(content.toString());
|
||||||
|
|
||||||
|
app.use(path, function(req, res, next) {
|
||||||
|
var data = {};
|
||||||
|
if (dataGetter) {
|
||||||
|
data = dataGetter(req);
|
||||||
|
if (!data) {
|
||||||
|
return res.status(404).send('Not found');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data['server_version'] = packageJson.version;
|
||||||
|
data['key_query_part'] =
|
||||||
|
req.query.key ? 'key=' + req.query.key + '&' : '';
|
||||||
|
data['key_query'] = req.query.key ? '?key=' + req.query.key : '';
|
||||||
|
return res.status(200).send(compiled(data));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
serveTemplate('/$', 'index', function(req) {
|
||||||
|
var styles = clone(config.styles || {});
|
||||||
|
Object.keys(styles).forEach(function(id) {
|
||||||
|
var style = styles[id];
|
||||||
|
style.name = (serving.styles[id] || serving.rendered[id] || {}).name;
|
||||||
|
style.serving_data = serving.styles[id];
|
||||||
|
style.serving_rendered = serving.rendered[id];
|
||||||
|
if (style.serving_rendered) {
|
||||||
|
var center = style.serving_rendered.center;
|
||||||
|
if (center) {
|
||||||
|
style.viewer_hash = '#' + center[2] + '/' +
|
||||||
|
center[1].toFixed(5) + '/' +
|
||||||
|
center[0].toFixed(5);
|
||||||
|
|
||||||
|
var centerPx = mercator.px([center[0], center[1]], center[2]);
|
||||||
|
style.thumbnail = center[2] + '/' +
|
||||||
|
Math.floor(centerPx[0] / 256) + '/' +
|
||||||
|
Math.floor(centerPx[1] / 256) + '.png';
|
||||||
|
}
|
||||||
|
|
||||||
|
var query = req.query.key ? ('?key=' + req.query.key) : '';
|
||||||
|
style.wmts_link = 'http://wmts.maptiler.com/' +
|
||||||
|
base64url('http://' + req.headers.host +
|
||||||
|
'/styles/' + id + '/rendered.json' + query) + '/wmts';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var data = clone(serving.data || {});
|
||||||
|
Object.keys(data).forEach(function(id) {
|
||||||
|
var data_ = data[id];
|
||||||
|
var center = data_.center;
|
||||||
|
if (center) {
|
||||||
|
data_.viewer_hash = '#' + center[2] + '/' +
|
||||||
|
center[1].toFixed(5) + '/' +
|
||||||
|
center[0].toFixed(5);
|
||||||
|
}
|
||||||
|
data_.is_vector = data_.format == 'pbf';
|
||||||
|
if (!data_.is_vector) {
|
||||||
|
if (center) {
|
||||||
|
var centerPx = mercator.px([center[0], center[1]], center[2]);
|
||||||
|
data_.thumbnail = center[2] + '/' +
|
||||||
|
Math.floor(centerPx[0] / 256) + '/' +
|
||||||
|
Math.floor(centerPx[1] / 256) + '.' + data_.format;
|
||||||
|
}
|
||||||
|
|
||||||
|
var query = req.query.key ? ('?key=' + req.query.key) : '';
|
||||||
|
data_.wmts_link = 'http://wmts.maptiler.com/' +
|
||||||
|
base64url('http://' + req.headers.host +
|
||||||
|
'/data/' + id + '.json' + query) + '/wmts';
|
||||||
|
}
|
||||||
|
if (data_.filesize) {
|
||||||
|
var suffix = 'kB';
|
||||||
|
var size = parseInt(data_.filesize, 10) / 1024;
|
||||||
|
if (size > 1024) {
|
||||||
|
suffix = 'MB';
|
||||||
|
size /= 1024;
|
||||||
|
}
|
||||||
|
if (size > 1024) {
|
||||||
|
suffix = 'GB';
|
||||||
|
size /= 1024;
|
||||||
|
}
|
||||||
|
data_.formatted_filesize = size.toFixed(2) + ' ' + suffix;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
styles: styles,
|
||||||
|
data: data
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
serveTemplate('/styles/:id/$', 'viewer', function(req) {
|
||||||
|
var id = req.params.id;
|
||||||
|
var style = clone((config.styles || {})[id]);
|
||||||
|
if (!style) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
style.id = id;
|
||||||
|
style.name = (serving.styles[id] || serving.rendered[id]).name;
|
||||||
|
style.serving_data = serving.styles[id];
|
||||||
|
style.serving_rendered = serving.rendered[id];
|
||||||
|
return style;
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
app.use('/rendered/:id/$', function(req, res, next) {
|
||||||
|
return res.redirect(301, '/styles/' + req.params.id + '/');
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
serveTemplate('/data/:id/$', 'data', function(req) {
|
||||||
|
var id = req.params.id;
|
||||||
|
var data = clone(serving.data[id]);
|
||||||
|
if (!data) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
data.id = id;
|
||||||
|
data.is_vector = data.format == 'pbf';
|
||||||
|
return data;
|
||||||
|
});
|
||||||
|
|
||||||
|
var server = app.listen(process.env.PORT || opts.port, function() {
|
||||||
console.log('Listening at http://%s:%d/',
|
console.log('Listening at http://%s:%d/',
|
||||||
this.address().address, this.address().port);
|
this.address().address, this.address().port);
|
||||||
|
|
||||||
return callback();
|
return callback();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setTimeout(callback, 1000);
|
||||||
|
return {
|
||||||
|
app: app,
|
||||||
|
server: server
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
68
src/utils.js
@@ -1,7 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
module.exports.getTileUrls = function(
|
var async = require('async'),
|
||||||
protocol, domains, host, path, tilePath, format, key) {
|
path = require('path'),
|
||||||
|
fs = require('fs');
|
||||||
|
|
||||||
|
var glyphCompose = require('glyph-pbf-composite');
|
||||||
|
|
||||||
|
module.exports.getTileUrls = function(req, domains, path, format) {
|
||||||
|
|
||||||
if (domains) {
|
if (domains) {
|
||||||
if (domains.constructor === String && domains.length > 0) {
|
if (domains.constructor === String && domains.length > 0) {
|
||||||
@@ -9,20 +14,65 @@ module.exports.getTileUrls = function(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!domains || domains.length == 0) {
|
if (!domains || domains.length == 0) {
|
||||||
domains = [host];
|
domains = [req.headers.host];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var key = req.query.key;
|
||||||
var query = (key && key.length > 0) ? ('?key=' + key) : '';
|
var query = (key && key.length > 0) ? ('?key=' + key) : '';
|
||||||
if (path == '/') {
|
|
||||||
path = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
var uris = [];
|
var uris = [];
|
||||||
domains.forEach(function(domain) {
|
domains.forEach(function(domain) {
|
||||||
uris.push(protocol + '://' + domain + path +
|
uris.push(req.protocol + '://' + domain + '/' + path +
|
||||||
tilePath.replace('{format}', format).replace(/\/+/g, '/') +
|
'/{z}/{x}/{y}.' + format + query);
|
||||||
query);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return uris;
|
return uris;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module.exports.fixTileJSONCenter = function(tileJSON) {
|
||||||
|
if (tileJSON.bounds && !tileJSON.center) {
|
||||||
|
var fitWidth = 1024;
|
||||||
|
var tiles = fitWidth / 256;
|
||||||
|
tileJSON.center = [
|
||||||
|
(tileJSON.bounds[0] + tileJSON.bounds[2]) / 2,
|
||||||
|
(tileJSON.bounds[1] + tileJSON.bounds[3]) / 2,
|
||||||
|
Math.round(
|
||||||
|
-Math.log((tileJSON.bounds[2] - tileJSON.bounds[0]) / 360 / tiles) /
|
||||||
|
Math.LN2
|
||||||
|
)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.getFontsPbf = function(allowedFonts, fontPath, names, range, callback) {
|
||||||
|
var getFontPbf = function(name, range, callback) {
|
||||||
|
if (!allowedFonts || allowedFonts[name]) {
|
||||||
|
var filename = path.join(fontPath, name, range + '.pbf');
|
||||||
|
return fs.readFile(filename, function(err, data) {
|
||||||
|
if (err) {
|
||||||
|
return callback(new Error('Font load error: ' + name));
|
||||||
|
} else {
|
||||||
|
return callback(null, data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return callback(new Error('Font not allowed: ' + name));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var fonts = names.split(',');
|
||||||
|
var queue = [];
|
||||||
|
fonts.forEach(function(font) {
|
||||||
|
queue.push(function(callback) {
|
||||||
|
getFontPbf(font, range, callback);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return async.parallel(queue, function(err, results) {
|
||||||
|
if (err) {
|
||||||
|
callback(err, new Buffer([]));
|
||||||
|
} else {
|
||||||
|
callback(err, glyphCompose.combine(results));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
69
test/metadata.js
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
var testTileJSONArray = function(url) {
|
||||||
|
describe(url + ' is array of TileJSONs', function() {
|
||||||
|
it('is json', function(done) {
|
||||||
|
supertest(app)
|
||||||
|
.get(url)
|
||||||
|
.expect(200)
|
||||||
|
.expect('Content-Type', /application\/json/, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('is non-empty array', function(done) {
|
||||||
|
supertest(app)
|
||||||
|
.get(url)
|
||||||
|
.expect(function(res) {
|
||||||
|
res.body.should.be.Array();
|
||||||
|
res.body.length.should.be.greaterThan(0);
|
||||||
|
}).end(done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var testTileJSON = function(url, basename) {
|
||||||
|
describe(url + ' is TileJSON', function() {
|
||||||
|
it('is json', function(done) {
|
||||||
|
supertest(app)
|
||||||
|
.get(url)
|
||||||
|
.expect(200)
|
||||||
|
.expect('Content-Type', /application\/json/, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('has valid basename and tiles', function(done) {
|
||||||
|
supertest(app)
|
||||||
|
.get(url)
|
||||||
|
.expect(function(res) {
|
||||||
|
res.body.basename.should.equal(basename);
|
||||||
|
res.body.tiles.length.should.be.greaterThan(0);
|
||||||
|
}).end(done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('Metadata', function() {
|
||||||
|
testTileJSONArray('/index.json');
|
||||||
|
testTileJSONArray('/rendered.json');
|
||||||
|
testTileJSONArray('/data.json');
|
||||||
|
|
||||||
|
describe('/styles.json is valid array', function() {
|
||||||
|
it('is json', function(done) {
|
||||||
|
supertest(app)
|
||||||
|
.get('/styles.json')
|
||||||
|
.expect(200)
|
||||||
|
.expect('Content-Type', /application\/json/, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('contains valid item', function(done) {
|
||||||
|
supertest(app)
|
||||||
|
.get('/styles.json')
|
||||||
|
.expect(function(res) {
|
||||||
|
res.body.should.be.Array();
|
||||||
|
res.body.length.should.be.greaterThan(0);
|
||||||
|
res.body[0].version.should.equal(8);
|
||||||
|
res.body[0].id.should.be.String();
|
||||||
|
res.body[0].name.should.be.String();
|
||||||
|
}).end(done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
testTileJSON('/styles/bright/rendered.json', 'bright');
|
||||||
|
testTileJSON('/data/zurich-vector.json', 'zurich-vector');
|
||||||
|
});
|
||||||
20
test/setup.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
process.env.NODE_ENV = 'test';
|
||||||
|
|
||||||
|
global.should = require('should');
|
||||||
|
global.supertest = require('supertest');
|
||||||
|
|
||||||
|
before(function() {
|
||||||
|
console.log('global setup');
|
||||||
|
process.chdir('test_data');
|
||||||
|
var running = require('../src/server')({
|
||||||
|
config: 'config.json',
|
||||||
|
port: 8888
|
||||||
|
});
|
||||||
|
global.app = running.app;
|
||||||
|
global.server = running.server;
|
||||||
|
});
|
||||||
|
|
||||||
|
after(function() {
|
||||||
|
console.log('global teardown');
|
||||||
|
global.server.close(function() { console.log('Done'); });
|
||||||
|
});
|
||||||
101
test/static.js
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
var testStatic = function(prefix, q, format, status, scale, type, query) {
|
||||||
|
if (scale) q += '@' + scale + 'x';
|
||||||
|
var path = '/styles/' + prefix + '/static/' + q + '.' + format;
|
||||||
|
if (query) {
|
||||||
|
path += query;
|
||||||
|
}
|
||||||
|
it(path + ' returns ' + status, function(done) {
|
||||||
|
var test = supertest(app).get(path);
|
||||||
|
if (status) test.expect(status);
|
||||||
|
if (type) test.expect('Content-Type', type);
|
||||||
|
test.end(done);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var prefix = 'bright';
|
||||||
|
|
||||||
|
describe('Static endpoints', function() {
|
||||||
|
describe('center-based', function() {
|
||||||
|
describe('valid requests', function() {
|
||||||
|
describe('various formats', function() {
|
||||||
|
testStatic(prefix, '0,0,0/256x256', 'png', 200, undefined, /image\/png/);
|
||||||
|
testStatic(prefix, '0,0,0/256x256', 'jpg', 200, undefined, /image\/jpeg/);
|
||||||
|
testStatic(prefix, '0,0,0/256x256', 'jpeg', 200, undefined, /image\/jpeg/);
|
||||||
|
testStatic(prefix, '0,0,0/256x256', 'webp', 200, undefined, /image\/webp/);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('different parameters', function() {
|
||||||
|
testStatic(prefix, '0,0,0/300x300', 'png', 200, 2);
|
||||||
|
testStatic(prefix, '0,0,0/300x300', 'png', 200, 3);
|
||||||
|
|
||||||
|
testStatic(prefix, '80,40,20/600x300', 'png', 200, 3);
|
||||||
|
testStatic(prefix, '8.5,40.5,20/300x150', 'png', 200, 3);
|
||||||
|
testStatic(prefix, '-8.5,-40.5,20/300x150', 'png', 200, 3);
|
||||||
|
|
||||||
|
testStatic(prefix, '8,40,2@0,0/300x150', 'png', 200);
|
||||||
|
testStatic(prefix, '8,40,2@180,45/300x150', 'png', 200, 2);
|
||||||
|
testStatic(prefix, '8,40,2@10/300x150', 'png', 200, 3);
|
||||||
|
testStatic(prefix, '8,40,2@10.3,20.4/300x300', 'png', 200);
|
||||||
|
testStatic(prefix, '0,0,2@390,120/300x300', 'png', 200);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('invalid requests return 4xx', function() {
|
||||||
|
testStatic(prefix, '190,0,0/256x256', 'png', 400);
|
||||||
|
testStatic(prefix, '0,86,0/256x256', 'png', 400);
|
||||||
|
testStatic(prefix, '80,40,20/0x0', 'png', 400);
|
||||||
|
testStatic(prefix, '0,0,0/256x256', 'gif', 400);
|
||||||
|
testStatic(prefix, '0,0,0/256x256', 'png', 404, 1);
|
||||||
|
|
||||||
|
testStatic(prefix, '0,0,-1/256x256', 'png', 404);
|
||||||
|
testStatic(prefix, '0,0,1.5/256x256', 'png', 404);
|
||||||
|
testStatic(prefix, '0,0,0/256.5x256.5', 'png', 404);
|
||||||
|
|
||||||
|
testStatic(prefix, '0,0,0,/256x256', 'png', 404);
|
||||||
|
testStatic(prefix, '0,0,0,0,/256x256', 'png', 404);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('area-based', function() {
|
||||||
|
describe('valid requests', function() {
|
||||||
|
describe('various formats', function() {
|
||||||
|
testStatic(prefix, '-180,-80,180,80/10x10', 'png', 200, undefined, /image\/png/);
|
||||||
|
testStatic(prefix, '-180,-80,180,80/10x10', 'jpg', 200, undefined, /image\/jpeg/);
|
||||||
|
testStatic(prefix, '-180,-80,180,80/10x10', 'jpeg', 200, undefined, /image\/jpeg/);
|
||||||
|
testStatic(prefix, '-180,-80,180,80/10x10', 'webp', 200, undefined, /image\/webp/);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('different parameters', function() {
|
||||||
|
testStatic(prefix, '-180,-90,180,90/20x20', 'png', 200, 2);
|
||||||
|
testStatic(prefix, '0,0,1,1/200x200', 'png', 200, 3);
|
||||||
|
|
||||||
|
testStatic(prefix, '-280,-80,0,80/280x160', 'png', 200);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('invalid requests return 4xx', function() {
|
||||||
|
testStatic(prefix, '0,87,1,88/5x2', 'png', 400);
|
||||||
|
|
||||||
|
testStatic(prefix, '0,0,1,1/1x1', 'gif', 400);
|
||||||
|
|
||||||
|
testStatic(prefix, '-180,-80,180,80/0.5x2.6', 'png', 404);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('autofit path', function() {
|
||||||
|
describe('valid requests', function() {
|
||||||
|
testStatic(prefix, 'auto/256x256', 'png', 200, undefined, /image\/png/, '?path=10,10|20,20');
|
||||||
|
|
||||||
|
describe('different parameters', function() {
|
||||||
|
testStatic(prefix, 'auto/20x20', 'png', 200, 2, /image\/png/, '?path=10,10|20,20');
|
||||||
|
testStatic(prefix, 'auto/200x200', 'png', 200, 3, /image\/png/, '?path=-10,-10|-20,-20');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('invalid requests return 4xx', function() {
|
||||||
|
testStatic(prefix, 'auto/256x256', 'png', 400);
|
||||||
|
testStatic(prefix, 'auto/256x256', 'png', 400, undefined, undefined, '?path=10,10');
|
||||||
|
testStatic(prefix, 'auto/2560x2560', 'png', 400, undefined, undefined, '?path=10,10|20,20');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
51
test/style.js
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
var testIs = function(url, type, status) {
|
||||||
|
it(url + ' return ' + (status || 200) + ' and is ' + type.toString(),
|
||||||
|
function(done) {
|
||||||
|
supertest(app)
|
||||||
|
.get(url)
|
||||||
|
.expect(status || 200)
|
||||||
|
.expect('Content-Type', type, done);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var prefix = 'bright';
|
||||||
|
|
||||||
|
describe('Styles', function() {
|
||||||
|
describe('/styles/' + prefix + '.json is valid style', function() {
|
||||||
|
testIs('/styles/' + prefix + '.json', /application\/json/);
|
||||||
|
|
||||||
|
it('contains expected properties', function(done) {
|
||||||
|
supertest(app)
|
||||||
|
.get('/styles/' + prefix + '.json')
|
||||||
|
.expect(function(res) {
|
||||||
|
res.body.version.should.equal(8);
|
||||||
|
res.body.name.should.be.String();
|
||||||
|
res.body.sources.should.be.Object();
|
||||||
|
res.body.glyphs.should.be.String();
|
||||||
|
res.body.sprite.should.be.String();
|
||||||
|
res.body.layers.should.be.Array();
|
||||||
|
}).end(done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('/styles/streets.json is not served', function() {
|
||||||
|
testIs('/styles/streets.json', /./, 404);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('/styles/' + prefix + '/sprite[@2x].{format}', function() {
|
||||||
|
testIs('/styles/' + prefix + '/sprite.json', /application\/json/);
|
||||||
|
testIs('/styles/' + prefix + '/sprite@2x.json', /application\/json/);
|
||||||
|
testIs('/styles/' + prefix + '/sprite.png', /image\/png/);
|
||||||
|
testIs('/styles/' + prefix + '/sprite@2x.png', /image\/png/);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Fonts', function() {
|
||||||
|
testIs('/fonts/Open Sans Bold/0-255.pbf', /application\/x-protobuf/);
|
||||||
|
testIs('/fonts/Open Sans Regular/65280-65535.pbf', /application\/x-protobuf/);
|
||||||
|
testIs('/fonts/Open Sans Bold,Open Sans Regular/0-255.pbf',
|
||||||
|
/application\/x-protobuf/);
|
||||||
|
testIs('/fonts/Nonsense,Open Sans Bold/0-255.pbf', /./, 400);
|
||||||
|
|
||||||
|
testIs('/fonts/Nonsense/0-255.pbf', /./, 400);
|
||||||
|
testIs('/fonts/Nonsense1,Nonsense2/0-255.pbf', /./, 400);
|
||||||
|
});
|
||||||
28
test/tiles_data.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
var testTile = function(prefix, z, x, y, status) {
|
||||||
|
var path = '/data/' + prefix + '/' + z + '/' + x + '/' + y + '.pbf';
|
||||||
|
it(path + ' returns ' + status, function(done) {
|
||||||
|
var test = supertest(app).get(path);
|
||||||
|
if (status) test.expect(status);
|
||||||
|
if (status == 200) test.expect('Content-Type', /application\/x-protobuf/);
|
||||||
|
test.end(done);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var prefix = 'zurich-vector';
|
||||||
|
|
||||||
|
describe('Vector tiles', function() {
|
||||||
|
describe('existing tiles', function() {
|
||||||
|
testTile(prefix, 0, 0, 0, 200);
|
||||||
|
testTile(prefix, 14, 8581, 5738, 200);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('non-existent requests return 4xx', function() {
|
||||||
|
testTile('non_existent', 0, 0, 0, 404);
|
||||||
|
testTile(prefix, -1, 0, 0, 404); // err zoom
|
||||||
|
testTile(prefix, 20, 0, 0, 404); // zoom out of bounds
|
||||||
|
testTile(prefix, 0, 1, 0, 404);
|
||||||
|
testTile(prefix, 0, 0, 1, 404);
|
||||||
|
|
||||||
|
testTile(prefix, 14, 0, 0, 404); // non existent tile
|
||||||
|
});
|
||||||
|
});
|
||||||
46
test/tiles_rendered.js
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
var testTile = function(prefix, z, x, y, format, status, scale, type) {
|
||||||
|
if (scale) y += '@' + scale + 'x';
|
||||||
|
var path = '/styles/' + prefix + '/rendered/' + z + '/' + x + '/' + y + '.' + format;
|
||||||
|
it(path + ' returns ' + status, function(done) {
|
||||||
|
var test = supertest(app).get(path);
|
||||||
|
test.expect(status);
|
||||||
|
if (type) test.expect('Content-Type', type);
|
||||||
|
test.end(done);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var prefix = 'bright';
|
||||||
|
|
||||||
|
describe('Raster tiles', function() {
|
||||||
|
describe('valid requests', function() {
|
||||||
|
describe('various formats', function() {
|
||||||
|
testTile(prefix, 0, 0, 0, 'png', 200, undefined, /image\/png/);
|
||||||
|
testTile(prefix, 0, 0, 0, 'jpg', 200, undefined, /image\/jpeg/);
|
||||||
|
testTile(prefix, 0, 0, 0, 'jpeg', 200, undefined, /image\/jpeg/);
|
||||||
|
testTile(prefix, 0, 0, 0, 'webp', 200, undefined, /image\/webp/);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('different coordinates and scales', function() {
|
||||||
|
testTile(prefix, 1, 1, 1, 'png', 200);
|
||||||
|
|
||||||
|
testTile(prefix, 0, 0, 0, 'png', 200, 2);
|
||||||
|
testTile(prefix, 0, 0, 0, 'png', 200, 3);
|
||||||
|
testTile(prefix, 2, 1, 1, 'png', 200, 3);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('invalid requests return 4xx', function() {
|
||||||
|
testTile('non_existent', 0, 0, 0, 'png', 404);
|
||||||
|
testTile(prefix, -1, 0, 0, 'png', 404);
|
||||||
|
testTile(prefix, 25, 0, 0, 'png', 404);
|
||||||
|
testTile(prefix, 0, 1, 0, 'png', 404);
|
||||||
|
testTile(prefix, 0, 0, 1, 'png', 404);
|
||||||
|
testTile(prefix, 0, 0, 0, 'gif', 400);
|
||||||
|
testTile(prefix, 0, 0, 0, 'pbf', 400);
|
||||||
|
|
||||||
|
testTile(prefix, 0, 0, 0, 'png', 404, 1);
|
||||||
|
testTile(prefix, 0, 0, 0, 'png', 404, 4);
|
||||||
|
|
||||||
|
//testTile('hybrid', 0, 0, 0, 'png', 404); //TODO: test this
|
||||||
|
});
|
||||||
|
});
|
||||||