Friday, October 30, 2015

tilestream


============================================================================
Therein, Tom MacWright of the Mapbox project suggested a work-around of basically clicked over a tile to determine what the correct URL is. It appears the server reformulates the URL, possibly depending upon how many mbtiles are in the directly. I don't think this URL change is documented, so the work-around is to look at the generic instances, e.g. : http://192.168.1.25:8888/map/John_test2 to see what the URL root path is for a sample PNG. In my case, I had two mbtiles in the directory, and the URL for a PNG was, for example: http://themis:8888/v2/John_test2/17/21010/50421.png. Consequently, there are two issues here: 1) one must use the addLayers mechanism to import maps not served by mapbox.com, 2) the URLs are programmatically changed and for now (I could not find any documentation on the matter), the work-around is to access the mbtiles file directly and determine what the URL construct is by right clicking an image and viewing its particular URL.
Here's my HTML that used to successfully render within a mapbox.map object:


var map = L.mapbox.map('map');
    //map.addLayer(L.tileLayer('http://{s}.tile.stamen.com/toner/{z}/{x}/{y}.png'));  // original
    //
    //map.addLayer(L.tileLayer('http://192.168.1.25:8888/map/John_test2/{z}/{x}/{y}.png'));   // fails

    // per suggestion
    // http://support.mapbox.com/discussions/mapboxjs/1875-deploying-sqlite-database-via-tilestream
    map.addLayer(L.tileLayer('http://themis:8888/v2/John_test2/{z}/{x}/{y}.png'));

    //map.setView([0, 0], 5);  //original
    map.setView([38.297619, -122.296316 ], 17);



    
    
    <!--[if lte IE 8]>
    
    <![endif]
    
    
-->
Note: I changed my server host name from an IP to "themis", hence the difference there is a result of my changing the initialization of the tilestream server.

========================================
start tilestream on windows. open cmd, into directory.

node index.js

C:\jh\tilestream>node index.js
Creating tiles dir C:\Users\hu_j\Documents\MapBox\tiles
Started [Server Tile].
Started [Server Core:8888].


=======================================================

0) install node js,  must be 0.10.x or 0.8.x( 4.2.1 will fail the build)
    Must read install doc, follow exactly what version to use.

1)before install tilestream, you must install python(2.7,   3.5 is not support by node-gyp)
    currently node-gyp support python 2.5 - 3.0  

2)add python to system path environment variable, system variable -> path, add c:\python27\
    the user variable PATH only for current user, so should use system variable for all users.
    Restart needed to have system path take effect.

3) uninstall any pieces of visual studio 2005 2008 redistribution x86 x64, uninstall other python version. only left 2.7.



 4) open cmd, You can use npm to install TileStream:
git clone https://github.com/mapbox/tilestream.git
cd tilestream
npm install

5) try to run the command npm install , the error:
c:\tilestream>npm install

Error: ENOENT, stat 'C:\Users\hoogw\AppData\Roaming\npm'
Error: ENOENT, stat 'C:\Users\RT\AppData\Roaming\npm
Solution: Manually creating a folder named 'npm' in the displayed path fixed the problem.

Error: ENOENT, stat 'C:\Users\\AppData\Roaming\npm' on Windows 7

This is a consequence of joyent/node#8141, and is an issue with the Node installer for Windows. The workaround is to ensure that C:\Users\\AppData\Roaming\npm exists and is writable with your normal user account.
 AppData is hidden folder, so
  1. Open Folder Options by clicking the Start button Picture of the Start button, clicking Control Panel, clicking Appearance and Personalization, and then clicking Folder Options.
  2. Click the View tab.
  3. Under Advanced settings, click Show hidden files, folders, and drives, and then click OK.

6) Start TileStream: under tilestream folder
c:\tilestream>node index.js
7) error missing model
c:\tilestream\node_modules\connect\node_modules\qs\lib\index.js:5
const Stringify = require('./stringify');

window 7 and windows server 2012,
install tilestream without any error message.
But when I run it, it error out.
To verify this is bug, I did both windows 7 and server 2012, both give the exact same error.
c:\tilestream>node index.js
error:
c:\tilestream\node_modules\connect\node_modules\qs\lib\index.js:5
const Stringify = require('./stringify');
^^^^^
SyntaxError: Use of const in strict mode.
at Module._compile (module.js:439:25)
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 Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (c:\tilestream\node_modules\connect\lib\middleware\bod
yParser.js:13:10)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)

I found the problem is in connect folder, C:\tilestream\node_modules\connect, if I replace connect folder with the previously working copy's connect folder, it will works. If I use "npm install" then node index.js, will always get error message above




I just ran into this as well using node 0.10.36 (CentOS 6 EPEL packages). Using the --harmony option fixes it in my case:
$ node --harmony index.js




Done.

===================================================================
Must install vs c++,  not the regular visual studio for web. otherwise will get "gyp build error"
    Microsoft Visual Studio C++ 2012 Express version, visual studio 2012 express for desktop
    • Python (v2.7.3 recommended, v3.x.x is not supported)
      • Make sure that you have a PYTHON environment variable, and it is set to drive:\path\to\python.exe not to a folder
    • Windows XP/Vista/7:
      • Microsoft Visual Studio C++ 2013 (Express version works well)
        • If the install fails, try uninstalling any C++ 2010 x64&x86 Redistributable that you have installed first
        • If you get errors that the 64-bit compilers are not installed you may also need the compiler update for the Windows SDK 7.1
    • Windows 7/8:
      • Microsoft Visual Studio C++ 2013 for Windows Desktop (Express version works well)
    • All Windows Versions
      • For 64-bit builds of node and native modules you will also need the Windows 7 64-bit SDK
      • You may need to run one of the following commands if your build complains about WindowsSDKDir not being set, and you are sure you have already installed the SDK:
call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x86
call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x64
If you have multiple Python versions installed, you can identify which Python version node-gyp uses by setting the '--python' variable:
$ node-gyp --python /path/to/python2.7
If node-gyp is called by way of npm and you have multiple versions of Python installed, then you can set npm's 'python' config key to the appropriate value:
$ npm config set python /path/to/executable/python2.7
Note that OS X is just a flavour of Unix and so needs pythonmake, and C/C++. An easy way to obtain these is to install XCode from Apple, and then use it to install the command line tools (under Preferences -> Downloads).


4) specify "--msvs_version=2012" 
  for example:   npm install --msvs_version=2012 
5)


when install tilestream, run node.js command windows as adminstrator.


if error, look the error message, if you missing some model.






-------------------------------------------------
if the error is can't find python,
because missing node-gyp, you need to install it by:

  • Install node-gypnpm install -g node-gyp
..........................................
Some npm plugins need node-gyp to be installed.
However, node-gyp has it's own dependencies (from the github page):
enter image description here

So to install it on windows you must first :

If you use linux (debian):

  • python / make are pre-installed!
  • just install gccsudo apt-get install g++
  • and then install node-gypsudo npm install -g node-gyp


---------------------------------------------------------------------

if the error is missing sqlite3,  need install sqlite3

C:\jh\tilestream>npm install sqlite3

other model might missing

npm install sqlite3
npm install mbtiles
npm install jsdom
npm install uglify-js
npm install connect
npm install qs
npm install mime

No comments: