stamen / mapstitch

Stitches map tiles together
MIT License
14 stars 1 forks source link

A little more info as to how this package works? #6

Open georgecoltart opened 10 years ago

georgecoltart commented 10 years ago

I'm trying to digest what the inputs are for this. It looks like just what I need...

It looks like the required instantiation vars are a 'provider template' and a 'view'

Is the provider template something like http://[abc].tile.openstreetmap.org/zoom/x/y.png ?

And the view is what kind of data?

Sorry Im a rookie Im not sure if this is obvious.

georgecoltart commented 10 years ago

OK so having found this: Usage: $0 --zoom [zoom] --provider [provider] minX minY maxX maxY

So the (minX minY maxX maxY) variables the tile numbers in the /x/y.png tile URL?

mojodna commented 10 years ago

It's not obvious ;-)

A provider template is what you're thinking: http://a.tile.openstreetmap.org/{z}/{x}/{y}.png (it's the same format as Leaflet, FWIW)

A view looks like this and can be generated using getView, given a center point and desired target image dimensions:

{
  extents: [[-122.737, 37.955, -122.011, 37.449]], // this is an array of extents to support stitching around 180º east/west (the antimeridian).
  zoom: zoom // e.g. 12
};

minX minY maxX maxY in the command line tool are geographic coordinates. San Francisco looks like: -122.737 37.955 -122.011 37.449

georgecoltart commented 10 years ago

Great, thanks for clarifying. I'm having a nightmare getting Canvas installed but looking forward to giving this a go.

mojodna commented 10 years ago

What platform? It's definitely painful, but I've had success on OS X with brew install cairo followed by PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/opt/X11/lib/pkgconfig npm install.

georgecoltart commented 10 years ago

Im on a mac, I've got Cairo installed OK. I think it's a broken link to jpeglib.h that's causing me problems, I've posted it here: https://github.com/LearnBoost/node-canvas/issues/348 Don't suppose you know where the jpeglib is supposed to live in relation to the canvas install?

mojodna commented 10 years ago

Weird. Which OS X version? I've had more problems with Cairo on 10.7 than 10.8, but did get it to install (mainly by adding more stuff to PKG_CONFIG_PATH, which doesn't look like your problem here).

If you installed jpeg with homebrew, I would expect to see the header in /usr/local/include.

georgecoltart commented 10 years ago

Thanks for your help with that one.. I now have the server up and running, do I need to construct a URL @ http://0.0.0.0:8080/ with the provider and extent params you mentioned above?

Sorry I'm not a Node dev, I'm not sure if this is obvious stuff or not...

mojodna commented 10 years ago

Sure, no problem.

What are you trying to achieve?

If you're running the server, you can skip the bit about provider URLs and use one of the ones present in providers.json (and/or add your own provider to that).

Here's an example:

http://localhost:8080/mapimg?w=1500&h=1500&extent=37.955:-122.737:37.449:-122.011&p=trees-cabs-crime

That will produce a 1500x1500 image of trees, cabs, and crime for San Francisco (that particular style only covers SF). Note that the coordinates in the extent in the URL are latitude/longitude (where they're x/y when using it programmatically).

There's a second endpoint that accepts an extent and a zoom and will produce an image of whatever dimensions are correct:

http://localhost:8080/?zoom=12&extent=37.955:-122.737:37.449:-122.011&p=trees-cabs-crime

georgecoltart commented 10 years ago

Superb, I'm up and running now. My end goal is print-focussed, so this is ideal for generating my base layer. I was trying this with Mapbox but they have a tight restriction on their static map API (640x640), hence me looking for a self managed solution...

One thing I noticed on the JPEG maps is that I get a

Wrong JPEG library version: library is 90, caller expects 80

GMBP:mapstitch georgecoltart$ brew list jpeg
/usr/local/Cellar/jpeg/8d/bin/wrjpgcom
/usr/local/Cellar/jpeg/8d/bin/rdjpgcom
/usr/local/Cellar/jpeg/8d/bin/jpegtran
/usr/local/Cellar/jpeg/8d/bin/djpeg
/usr/local/Cellar/jpeg/8d/bin/cjpeg
/usr/local/Cellar/jpeg/8d/include/ (4 files)
/usr/local/Cellar/jpeg/8d/lib/libjpeg.8.dylib
/usr/local/Cellar/jpeg/8d/lib/ (2 other files)
/usr/local/Cellar/jpeg/8d/share/man/ (5 files)

Will I have to downgrade my version of JPEG? It looks like I have 8 installed, are you getting this your end after your recent updates?

mojodna commented 10 years ago

Hmm.. I'd reinstall jpeg if you haven't already. (And possibly reinstall cairo after, to make sure that it's linked properly.)

almccon commented 9 years ago

@mojodna The second endpoint you mention doesn't work right for me. If I run http://localhost:8080/mapimg?z=12&extent=37.955:-122.737:37.449:-122.011&p=toner I get a squashed image using the default 1500x1000 dimensions. It doesn't return an image of appropriate size using the native pixel size of the tiles at that zoom.

mapimg

If I change the zoom parameter, I still get the same map.

mojodna commented 9 years ago

tl render is another option here. (There are probably more, but that's the version I've worked on most recently; when wrapping around the antimeridian, use values outside [-180, 180], as it doesn't contain logic to do that yet.)