Giter Club home page Giter Club logo

d3-quadtiles's Introduction

QuadTiles

Inspired and guided by the Automatic Projection Tiles tech demo from Jason Davies and the source code by the same name 'd3.quadTiles.js'. https://www.jasondavies.com/maps/tile/

This utility takes a d3 geo projection and using the projection's clipping rectangles returns an array of visible tiles. A maximum tile budget and max zoom level controls the quadtree descent. A full hierarchy of visible tiles at zoom levels starting from 0 until the zoom level reached is also returned.

Use this algorithm to efficiently calculate visible map tiles on any d3 geo map projection! Performs well even at high zoom levels.

var d3 = require('d3');
var projection = d3.geo.orthographic()
  .precision(0.1)
  .clipAngle(90)
  .rotate([-150, 25])
  .scale(150)
  .translate([300, 240])
  .clipExtent([[0, 0], [600, 480]]);
var quadtiles = require('d3-quadtiles');
var quad = quadtiles(projection, { maxtiles: 32, maxzoom: 18 });
console.log(quad.zoom); // e.g. 6
console.log(quad.tiles); // e.g. [zoom6tile1, zoom6tile2, zoom6tile3..]
// quad.all is indexed by zoom level
console.log(quad.all); // e.g. [[zoom0tile1], [zoom1tile1, zoom1tile2], ...]
// tile = {
//   type: "Polygon",
//   key: [x, y, z], // tilespace coordinates
//   // points created as 10 points along each side of the tile starting top left and going right
//   // 40 points total
//   points: [[[lng, lat], [lng, lat], [lng, lat], ...]],
//   centroid: [lng, lat] // coordinates of centroid
// }

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.