Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
georgecoltart opened this issue Oct 25, 2013 · 12 comments
Open

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

georgecoltart opened this issue Oct 25, 2013 · 12 comments

Comments

@georgecoltart
Copy link

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
Copy link
Author

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
Copy link
Contributor

mojodna commented Oct 25, 2013

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
Copy link
Author

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

@mojodna
Copy link
Contributor

mojodna commented Oct 26, 2013

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
Copy link
Author

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:
Automattic/node-canvas#348
Don't suppose you know where the jpeglib is supposed to live in relation to the canvas install?

@mojodna
Copy link
Contributor

mojodna commented Oct 26, 2013

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
Copy link
Author

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
Copy link
Contributor

mojodna commented Oct 26, 2013

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
Copy link
Author

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
Copy link
Contributor

mojodna commented Oct 28, 2013

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

@almccon
Copy link
Member

almccon commented Jul 30, 2015

@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.

almccon added a commit that referenced this issue Jul 30, 2015
@mojodna
Copy link
Contributor

mojodna commented Jul 30, 2015

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants