Giter VIP home page Giter VIP logo

node-tileserver's Introduction

node-tileserver

node-tileserver is a lightweight tileserver using NodeJS. It can serve bitmap and vector tiles and is designed as a fast and easy-to-install tileserver for rendering OpenStreetMap data. It works perfectly with an osm2pgsql database and Leaflet and KothicJS on the client side.

See the OpenStreetMap Wiki or the Github repository for more information.

Features

  • Serves tiles bitmap tiles usable in Leaflet or OpenLayers
  • Serves vector tiles rendered on clientside by KothicJS
  • Uses KothicJS both as bitmap renderer on serverside and canvas renderer on clientside
  • Filesystem caching mechanisms
  • Map styling with MapCSS
  • Support for tiles in multiple rendering styles
  • Designed to use a osm2pgsql hstore database containing OpenStreetMap data
  • Refresh tiles manually by GET requests
  • Rerender expired tiles automatically in the background
  • High performance that profits from the non-blocking I/O design of NodeJS
  • Easy to install on several operating systems, distributions and environments due to less dependencies
  • Renders bitmap tiles in "retina" quality (Supersampling)

Authors

Installation

Follow the installation instructions.

References

  • OpenRailwayMap - a map of the global railway network based on OpenStreetMap. Provides a client-rendered canvas and a standard bitmap tile version of the map.

Contribute

Want to contribute to node-tileserver? Patches for new features, bug fixes, documentation, examples and others are welcome. Take also a look at the issues.

You can honor this project also by a donation with Paypal. This project is operated by the developers in their spare time and has no commercial goals. By making a donation you can show that you appreciate the voluntary work of the developers and can motivate them to continue the project in the future.

License

Copyright (C) 2014 Alexander Matheisen

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

The file mapcss_converter.py and the files in the mapcss_parser and kothic directories are published under other licenses. See the header of each file for more information.

node-tileserver's People

Contributors

derdakon avatar mmoll avatar nakaner avatar pbabik avatar philhug avatar rurseekatze avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-tileserver's Issues

init-rendering.js error

hi

i try to install your node-tileserver on a fresh ubuntu 14.04
with nodejs install per nvm
nvm set 0.10.28

i get the tileserver.js running, but have troubles with the init-rendering.js

got this error:

[2014-06-17 18:47:07.556] [INFO] [default] - Initial rendering of 87k tiles in the background. This process can take some time.

/home/osm/projects/osmjs/tileserver/init-rendering.js:142
eventEmitter.on('tileFinished', initTileFinished);
^
ReferenceError: eventEmitter is not defined
    at Object.<anonymous> (/home/osm/projects/osmjs/tileserver/init-rendering.js:142:1)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

is there a package missing?
any ideas? i am no programmer :)

thx
rob

MapCSS regex parsing error

MapCSS converter throws syntax errors when trying to compile MapCSS stylesheets with regular expressions containing square brackets.

It seems that MapCSS parser does not differentiate between square brackets of MapCSS selectors and those inside regular expressions.

See OpenRailwayMap/OpenRailwayMap#200 as an example.

Project structure

Hi,
would it be possible to post the structure of the project, js files and so on thank you :)

900913 vs. 3857

node-tileserver currently works with EPGS:900913 while current osm2pgsql versions use EPSG:3857.

To do:

  • add a config option to set SRID (but only support 900913 and 3857 as a first step)
  • replace 900913 by 3857
  • remove osm2pgsql/900913.sql from setup instructions. This file has been removed a few weeks/months ago from osm2pgsql

"font-weight" not properly working

One can get bold fonts, but only if a bold font-family is requested. "font-weight: bold" has no effect. In fact KothicJS calculates the italic and bold styles from the font-family. See getFontString() in kothic/style/style.js.

Related to #16.

Support for classes is missing

way.test {}

AttributeError: ConditionClass instance has no attribute 'as_js'

way { set .test; }

AttributeError: ClassStatement instance has no attribute 'as_js'

Rendering artefact

Fix a bug that causes rendering artefacts. In every known case a lines goes either from the top left corner parallel to the tile bound or from the top left corner to the bottom right corner of a tile.

The bug can be seen on the map of the OpenRailwayMap project (which uses node-tileserver for rendering):

1

1

All tiles are empty

Greetings,

I have configured a running installation of node-tileserver on my own server but all tiles generated are empty. I'm using this mapcss style and a recently downloaded extract of Berlim from Geofabrik imported via osm2pgsql.

I'm pretty sure I've followed the README correctly and can't seem to find where the problem is.

This is my config.json:

{
    "tileSize" : 256,
    "prefix" : "planet_osm",
    "database" : "avm-node",
    "username" : "avm",
    "password" : "",
    "vtiledir" : "./tiles",
    "tiledir" : "./bitmap-tiles",
    "expiredtilesdir" : "./expired-tiles",
    "styledir" : "./styles",
    "zoomOffset" : 0,
    "minZoom" : 0,
    "maxZoom" : 20,
    "styles" : ["default"],
    "intscalefactor" : 10000,
    "geomcolumn" : "way",
    "pxtolerance" : 1.8,
    "maxPrerender" : 8,
    "maxCached" : 16,
    "minExpiring" : 8,
    "maxsockets" : 100,
    "tileserverPort" : 80,
    "tileBoundTolerance" : 60,
    "filterconditions" :
    {
        "0" : ""
    }
}

Full async code

Rewrite the last remaining synchronous functions to have a full asynchronous program.

Send UTF-8 encoding header

Send an UTF-8 encoding header in vector tiles responses.

Try
res.header("Content-Type", "application/javascript; charset=utf-8");
or
res.setEncoding('utf8');

Finish pending requests before stopping

The tileserver should not be stopped directly after a quit event, but wait until all pending requests are finished. This ensures that users will receive a response for their pending requests and the program exit will be more smoothly.

Add logging and statistics

Add logging and statistics of tile requests to be able to:

  • analyse the number of requested tiles in different periods of time
  • detect abuse (robots, mass downloads, ...)
  • ...

Reduce number of ways in low zoom levels

While solving #74, I discovered that there is a huge problem with too big vector tiles on low zoom levels. There should not be more than 10.000 features necessary for rendering just this single tile. In low zoom levels the single ways are simplified, but not merged. This causes that there are thousands of ways that consist of one or two nodes. Merging these short ways to a few longer would reduce the file size.

This issue can be used for collecting ideas on how to reduce the number of features in low zoom levels.

Proxy js

Hi,
I cannot find this file. Do i have to create it ? and what shall it contains ?
Thanks

Compress vector tiles

It seems that vector rendering is very slow not because of the browser rendering itself, but large vector data tiles.

Another way of reducing tile size is removing tags that are not rendered (such as source=, fixme=, description=, note=) and compressing tags since there are a lot tags that occur at almost every feature (like railway=rail).

And some compression could be achieved by using shorter property names (e.g. 'c' instead of 'coordinates').

Remove unnecessary coordinate transformations

There are some functions for coordinate transformation such as from4326To3857() in tile.js and coordinate transformations in the database query. Check if there is a possibility to remove unnecessary transformations to improve performance.

keys and values including quotes are not correctly supported

The MapCSS spec says that both single and double quotes are supported and can be used to mask the other type. Currently all quotes from the beginning and end of both keys and values are stripped, and at the end always single quotes are used.

This is currently no big issue as those things are quite uncommon, but it should not get lost.

Hi can somoene help me pls

Error: Problem with log4js configuration: ({ appenders:
[ { type: 'console' },
{ type: 'file', filename: 'logs/site_1499517945.log' } ] }) - must have a p roperty "appenders" of type object.
at tests.forEach (/var/www/bot/node_modules/log4js/lib/configuration.js:37:1 5)
at Array.forEach (native)
at Configuration.throwExceptionIf (/var/www/bot/node_modules/log4js/lib/conf iguration.js:35:11)
at new Configuration (/var/www/bot/node_modules/log4js/lib/configuration.js: 190:10)
at Object.configure (/var/www/bot/node_modules/log4js/lib/log4js.js:172:12)
at updateLog (/var/www/bot/cf.js:32:9)
at Object. (/var/www/bot/cf.js:29:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)

MapCSS style example

Hi,
Is it possible to share the example of MapCSS style which you are using and works with map_cssconverter.py ?
I tried some MapCSSs and they raise errors while I try to convert them. Mostly raise Illegal character for ! and +

Do not cache empty bitmap tiles

To save disk space, empty bitmap tiles should not be cached on hard disk. Instead, there should be a hardlink to one transparent tile created.

config error

i got an error pointing to the first parameter of the config file.
i updated all modules and still it gave me the same thing.
i'm using node v0.4.0
/home/yasser/Desktop/nodetileserver/node-tileserver/config.json:2
"tileSize": 256,
^

node.js:116
throw e; // process.nextTick error, or 'error' event on first tick
^
SyntaxError: Unexpected token :
at Module._compile (module.js:368:25)
at Object..js (module.js:379:10)
at Module.load (module.js:305:31)
at Function._load (module.js:271:10)
at require (module.js:317:19)
at Object. (eval at (/home/yasser/Desktop/nodetileserver/node-tileserver/tileserver.js:33:9))
at Object. (/home/yasser/Desktop/nodetileserver/node-tileserver/tileserver.js:33:9)
at Module._compile (module.js:373:26)
at Object..js (module.js:379:10)
at Module.load (module.js:305:31)

any ideas ?
thanks in advance

Installation note for Windows?

Can't install at windows 10 or windows server.
I can't catch from installation note.
Can I get reference installation note/video for Windows environment?
Thanks.

Add request statistics

Add an internal logging and statistics to count the number of tiles which was requested in the last minute, hour, day, etc. Also analyse e.g. referers to detect abuse (robots, mass downloads, ...).

It should be possible to access these stats with an API call which returns this data in JSON format.

query err: error: Operation on mixed SRID geometries

Hello,
I'm getting mixed SRID geometries error in funcion: getDatabaseQuery: function(bbox) in tile.js
Do you have any idea why?

this is the generated query:

SELECT ST_AsGeoJSON(ST_TransScale(ST_ForceRHR(ST_Intersection(way, ST_SetSRID('BOX3D(3889115.9991497695 3769262.7387969648,3890338.9916023314 3770485.731249527)'::box3d, 900913))), 
                        -3889115.9991497695, -3769262.7387969648, 8.176665341681026, 8.176665341677914), 0) AS way,
hstore2json(CAST(hstore(tags) AS hstore)) AS tags,
ST_AsGeoJSON(ST_TransScale(ST_ForceRHR(ST_PointOnSurface(way)), -3889115.9991497695, -3769262.7387969648, 8.176665341681026, 8.176665341677914), 0) AS reprpoint    

FROM (  SELECT (ST_Dump(ST_Multi(ST_SimplifyPreserveTopology(ST_Buffer(way ,-8.59916568208233), 8.59916568208233)))).geom AS way, 
        tags
        FROM  ( SELECT ST_Union(way) AS way, tags                                       
                FROM (  SELECT ST_Buffer(way, 8.59916568208233) AS way, 
                CAST(tags AS text) AS tags  
                FROM planet_osm_polygon 
                WHERE way && ST_SetSRID('BOX3D(3889115.9991497695 3769262.7387969648,3890338.9916023314 3770485.731249527)'::box3d, 900913) AND way_area > 41.08091690439025 AND (tags->'usage'='main') ) p
                GROUP BY CAST(tags AS text) ) p                         
                WHERE ST_Area(way) > 73.94565042790245
                ORDER BY ST_Area(way)) p                        

UNION       

SELECT  ST_AsGeoJSON(ST_TransScale(ST_Intersection(way, ST_SetSRID('BOX3D(3889115.9991497695 3769262.7387969648,3890338.9916023314 3770485.731249527)'::box3d, 900913)), -3889115.9991497695, -3769262.7387969648, 8.176665341681026, 8.176665341677914), 0) AS way,
hstore2json(CAST(hstore(tags) AS hstore)) as tags,
Null AS reprpoint                       
FROM ( SELECT (ST_Dump(ST_Multi(ST_SimplifyPreserveTopology(ST_LineMerge(way), 8.59916568208233)))).geom AS way, 
        tags 
        FROM ( SELECT ST_Union(way) AS way, 
        CAST(tags AS text)  
        FROM planet_osm_line 
        WHERE way && ST_SetSRID('BOX3D(3889115.9991497695 3769262.7387969648,3890338.9916023314 3770485.731249527)'::box3d, 900913) AND 
        (tags->'usage'='main')  GROUP BY CAST(tags AS text) ) p ) p                     


UNION 

SELECT ST_AsGeoJSON(ST_TransScale(way, -3889115.9991497695, -3769262.7387969648, 8.176665341681026, 8.176665341677914), 0) AS way,                      
             hstore2json(tags) AS tags,                 
             Null AS reprpoint                      
             FROM planet_osm_point                      
             WHERE  way && ST_SetSRID('BOX3D(3888829.3602937004 3768976.0999408956,3890625.6304584006 3770772.3701055963)'::box3d, 900913) AND (tags->'usage'='main') LIMIT 10000

Thank you very much for your help,
Adi Barda

Reload stylesheets on the fly

Currently it is necessary to restart node-tileserver to apply stylesheet changes. This behaviour is not very smooth as it e.g. aborts pending tile requests.

It would be nice if the stylesheets could be reloaded with a command without the need to restart node-tileserver.

Problem reading log4js config

hi,
i'm working on ubuntu 14.04 LTS.
when i start the server i get this this error:

node.js:116
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Problem reading log4js config { appenders:
[ { type: 'logLevelFilter',
level: 'ERROR',
appender: [Object],
makers: [Object] },
{ type: 'logLevelFilter',
level: 'INFO',
appender: [Object] } ] }. Error was "log4js configuration problem for { type: 'logLevelFilter',
level: 'ERROR',
appender:
{ type: 'file',
filename: 'tileserver.log',
maxLogSize: 20480,
backups: 0 },
makers: { console: [Function], logLevelFilter: [Function] } }" (Error: log4js configuration problem for { type: 'logLevelFilter',
level: 'ERROR',
appender:
{ type: 'file',
filename: 'tileserver.log',
maxLogSize: 20480,
backups: 0 },
makers: { console: [Function], logLevelFilter: [Function] } }
at /home/yasser/Desktop/nodetileserver/node-tileserver/node_modules/log4js/lib/log4js.js:167:15
at Array.forEach (native)
at configureAppenders (/home/yasser/Desktop/nodetileserver/node-tileserver/node_modules/log4js/lib/log4js.js:159:18)
at configureOnceOff (/home/yasser/Desktop/nodetileserver/node-tileserver/node_modules/log4js/lib/log4js.js:208:32)
at Object.configure (/home/yasser/Desktop/nodetileserver/node-tileserver/node_modules/log4js/lib/log4js.js:272:3)
at Object. (/home/yasser/Desktop/nodetileserver/node-tileserver/tileserver.js:11:8)
at Module._compile (module.js:373:26)
at Object..js (module.js:379:10)
at Module.load (module.js:305:31)
at Function._load (module.js:271:10))
at configureOnceOff (/home/yasser/Desktop/nodetileserver/node-tileserver/node_modules/log4js/lib/log4js.js:217:13)
at Object.configure (/home/yasser/Desktop/nodetileserver/node-tileserver/node_modules/log4js/lib/log4js.js:272:3)
at Object. (/home/yasser/Desktop/nodetileserver/node-tileserver/tileserver.js:11:8)
at Module._compile (module.js:373:26)
at Object..js (module.js:379:10)
at Module.load (module.js:305:31)
at Function._load (module.js:271:10)
at Array. (module.js:392:10)
at EventEmitter._tickCallback (node.js:108:26)

any help ?
thanks in advance.

Ordering of features with z-index not working

Ordering features with z-index to determine their rendering order does not work correctly in some cases.

I guess that the problem occurs when using splitted MapCSS rules where multiple rules match on one feature (like in the example). It is also thinkable that z-indexes dynamically created with eval() are not supported by parts of the code. Therefore analyse what is happening here:

styleFeatures: function (features, zoom, styleNames) {

Example:
Speed signals and the used MapCSS stylesheet.

yum repositories

Hi,
first of all, i have to thank you for this awsome solution.
i just want to know which repositories you used in yum to install all dependencies.
thank you in advance.

it cannot find module pg

it's installed under node_module, and it cannot recognize it !!

node.js:116
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'pg'
at Function._resolveFilename (module.js:289:11)
at Function._load (module.js:241:25)
at require (module.js:317:19)
at Object. (/home/yasser/Desktop/nodetileserver/node-tileserver/tileserver.js:17:6)
at Module._compile (module.js:373:26)
at Object..js (module.js:379:10)
at Module.load (module.js:305:31)
at Function._load (module.js:271:10)
at Array. (module.js:392:10)
at EventEmitter._tickCallback (node.js:108:26)

Make SRID configurable

Add a config option to set the SRID of the osm2pgsql database (but only support 900913 and 3857 as a first step).

This task was taken from #122.

Do not transfer empty bitmap tiles

To speed up loading and reduce the traffic, empty bitmap tiles should no be transferred. Instead an error code should be sended to inform the client to use a transparent standard tile (errorTileUrl in Leaflet), which was loaded just one time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.