mapbox / abaculus Goto Github PK
View Code? Open in Web Editor NEWLibrary for creating static maps from tiles based on center or corner lng,lat coordinates. Uses node-blend.
License: ISC License
Library for creating static maps from tiles based on center or corner lng,lat coordinates. Uses node-blend.
License: ISC License
Could you please push a new version to npm so that there's a published version out there that works with node-0.12 and iojs? Thanks!!
/cc @camilleanne
Hi, is it possible to create a functionality to place markers on the rendered map, based on lat,lng?
@camilleanne - Can you see if my changes look good and if so want to roll a new tag?
I see a function named zoomTo
. But this function is not implemented anywhere. I checked the history of this file, and found out this function was introduced in the initial commit.
https://github.com/mapbox/abaculus/blob/master/index.js#L99
It would be nice if there was a license file, or at least one listed in package.json to make it clear if abaculus can be redistributed or modified in an way.
Wording in readme makes the definition of the limit
parameter ambiguous.
Looks like it's a max width or height here: https://github.com/mapbox/abaculus/blob/master/index.js#L53
But here it looks like a measure of perimeter (4752 x 4 = 19008
): https://github.com/mapbox/abaculus/blob/master/test/test.js#L50-L51
I'm not totally sure if I'm interpreting this right, cc: @camilleanne
These three functions currently take callbacks but are actually synchronous:
https://github.com/mapbox/abaculus/blob/master/index.js#L46-L153
Should be fine to have them just return
the results of their work. If they need to pass an error to the caller use the node convention of having synchronous functions throw, e.g.
function mySyncFunc() {
throw new Error("Gah this is a sync error");
return "Great data";
}
You'll see this pattern around any node core sync calls, e.g.
// Sync version
try {
var data = fs.readFileSync('./filedoesntexist');
} catch(err) {
if (err && err.code === 'ENOENT') console.log('No file, ignore');
}
// Async version
fs.readFile('./filedoesntexist', function(err) {
if (err && err.code === 'ENOENT') console.log('No file, ignore');
});
The width calculated by coordsFromBbox() is base_width * scale *scale, which should be base_width * scale. Let check out:
console.log(abaculus.coordsFromBbox(0, 2, [-180, -85.0511, 180, 85.0511], 19000, 256))
console.log(abaculus.coordsFromCenter(0, 2, {x: 0, y: 0, w: 256, h: 256}, 19000, 256))
What I got is :
{ w: 1024, h: 1024, x: 256, y: 256 }
{ w: 512, h: 512, x: 256, y: 256 }
We have already get the right size from here: https://github.com/mapbox/abaculus/blob/master/index.js#L42-L43
But we enlarged the size again at here: https://github.com/mapbox/abaculus/blob/master/index.js#L50-L51
And x: 256, y: 256
is definitely not the center of w: 1024, h: 1024
, which proves the results calculated by coordsFromBbox is wrong.
If this problem is confirmed. I will send a PR.
Every time I use scale = 1, everything is fine. However when I use scale > 1, I get rendering errors, see:
https://gist.github.com/Maarius/a5969257ff46a9dbf38509386237b9e0
I use abacus 1.3.0 on a ubuntu machine.
Hello,
I have just been looking at this api and tested out the example code from issue #11 which works great. The issue arrises when I change the scale. If I change it to 2 it produces this:
If I change the scale to 4 which is closer to what I am looking for it does not seem to really do anything.
Any ideas?
$ npm i @mapbox/abaculus
npm WARN deprecated [email protected]: This module is now under the @mapbox namespace: install @mapbox/sphericalmercator instead
Tried to move my project to Node v10 and abaculus barks:
$ npm i @mapbox/abaculus
> [email protected] install /tmp/mapnik/node_modules/@mapbox/abaculus/node_modules/mapnik
> node-pre-gyp install --fallback-to-build
node-pre-gyp ERR! Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/mapnik/v3.7.2/node-v64-linux-x64-Release.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v64 ABI, glibc) (falling back to source compile with node-gyp)
node-pre-gyp ERR! Tried to download(undefined): https://mapbox-node-binary.s3.amazonaws.com/mapnik/v3.7.2/node-v64-linux-x64-Release.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v64 ABI, glibc) (falling back to source compile with node-gyp)
make: Entering directory '/tmp/mapnik/node_modules/@mapbox/abaculus/node_modules/mapnik/build'
[...snip building...]
../../nan/nan_object_wrap.h:66:61: required from here
/home/flc/.node-gyp/10.14.1/include/node/v8.h:9502:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfo<Nan::ObjectWrap>::Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<Nan::ObjectWrap>&)’} to ‘Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<void>&)’} [-Wcast-function-type]
CXX(target) Release/obj.target/mapnik/src/node_mapnik.o
sed: can't read ./Release/.deps/Release/obj.target/mapnik/src/mapnik_logger.o.d.raw: No such file or directory
make: *** [mapnik.target.mk:237: Release/obj.target/mapnik/src/mapnik_logger.o] Error 2
make: Leaving directory '/tmp/mapnik/node_modules/@mapbox/abaculus/node_modules/mapnik/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/flc/.nvm/versions/node/v10.14.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Linux 4.19.4-arch1-1-ARCH
gyp ERR! command "/home/flc/.nvm/versions/node/v10.14.1/bin/node" "/home/flc/.nvm/versions/node/v10.14.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/tmp/mapnik/node_modules/@mapbox/abaculus/node_modules/mapnik/lib/binding/mapnik.node" "--module_name=mapnik" "--module_path=/tmp/mapnik/node_modules/@mapbox/abaculus/node_modules/mapnik/lib/binding"
gyp ERR! cwd /tmp/mapnik/node_modules/@mapbox/abaculus/node_modules/mapnik
gyp ERR! node -v v10.14.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/home/flc/.nvm/versions/node/v10.14.1/bin/node /home/flc/.nvm/versions/node/v10.14.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/tmp/mapnik/node_modules/@mapbox/abaculus/node_modules/mapnik/lib/binding/mapnik.node --module_name=mapnik --module_path=/tmp/mapnik/node_modules/@mapbox/abaculus/node_modules/mapnik/lib/binding' (1)
I see the README.md has the build failing
icon, so maybe you were already aware.
Also I tried installing mapnik under Node v10 and went without problems.
Any ideas on how to fix this?
Looks like a base tilesize of 256 is hardcoded: https://github.com/mapbox/abaculus/blob/master/index.js#L76
User should be able to pass a custom base tilesize in.
Hi,
I'm trying to use Abaculus to generate a hi-res image. However, I haven't got the hang of the getTile function.
Could you give a simple example that, say, uses tiles from examples.map-zr0njcqy (from the developer docs: http://api.tiles.mapbox.com/v4/examples.map-zr0njcqy/0/0/0.png?access_token=pk.eyJ1Ijoid3JpZ2dsZXIiLCJhIjoiOXBUMjFERSJ9.jo2f0W7fTzbX-7lj_8pk7g) and saves an image to the local disk?
This is as far as I got, and the getTile function (at least) is clearly incorrect.
// Calculate image bounds from center lng,lat coordinates and
// pixel dimensions of final image (will be multipled by scale).
var params = {
zoom: 4,
scale: 4,
center: {
x: 20,
y: -10,
w: 100,
h: 100
},
//format: {format},
//quality: {quality},
getTile: function(z,x,y, callback){
// do something
return 'http://api.tiles.mapbox.com/v4/examples.map-zr0njcqy/' + z + '/' + x + '/' + y + '.png?access_token=pk.eyJ1Ijoid3JpZ2dsZXIiLCJhIjoiOXBUMjFERSJ9.jo2f0W7fTzbX-7lj_8pk7g';
//return callback(null, buffer, headers);
},
//limit: {limit}
};
abaculus(params, function(err, image){
if (err) return err;
console.log('File saved.');
// do something with image
});
I know that the Static Maps API exists, but this does not allow images large enough for my purposes.
Many thanks,
I suggest changing the API for passing bounds from
corners: {
topLeft: {
x: {x},
y: {y}
},
bottomRight: {
x: {x},
y: {x}
}
}
to:
bbox: [w, s, e, n]
API lat/lon orders are all over the map (har har), but [w, s, e, n]
is the convention used by sphericalmercator and GeoJSON. Whereas passing spherical coordinates as x
and y
values feels odd, as does topLeft
and bottomRight
keys -- APIs that accept two coordinate pairs usually opt for bottomLeft and topRight.
There are a couple of .DS_Store files checked in to the repo: test/.DS_Store
and test/fixtures/.DS_Store
.
.DS_Store
is a good thing to have in ~/.gitignore
because it should never be checked in.
I found vector.pbf here. Actually, mapnik.blend does not support vector tile blending. So those lines of code should be deleted to avoid confusion
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.