GithubHelp home page GithubHelp logo

mapbox / abaculus Goto Github PK

View Code? Open in Web Editor NEW
127.0 127.0 38.0 1.14 MB

Library for creating static maps from tiles based on center or corner lng,lat coordinates. Uses node-blend.

License: ISC License

JavaScript 100.00%

abaculus's People

Contributors

calvinmetcalf avatar camilleanne avatar flippmoke avatar mojodna avatar samanpwbb avatar samwillis avatar thibaudlopez avatar tmcw avatar wilhelmberg avatar yhahn 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  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

abaculus's Issues

npm release please!

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

Place markers

Hi, is it possible to create a functionality to place markers on the rendered map, based on lat,lng?

There is no LICENSE for abaculus

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.

Util functions that are faux async

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');
});

coordsFromBbox enlarge width and height twice

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.

Issue with scale - changing it produces a grid effect

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:
ab-image-x2

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?

Fails to build for Node v10.14.1

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?

Basic example?

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,

Accept bounds in array format

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.

Remove .DS_Store files

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.

vector.pbf blending

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

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.