Giter Site home page Giter Site logo

mapshaper-proxy's Introduction

mapshaper-proxy

This is an HTTP proxy for MapShaper. It allows tiled JSON sources to be processed on the fly by providing MapShaper commands in the URL.

Starting

SOURCE=http://localhost:8000/{z}/{x}/{y}{scale}.json npm start

Requesting Tiles

This is a URL template (suitable for handing to Tangram or other tools that consume tiled GeoJSON) that will filter out small features, clean up gaps, and simplify. It will also pass ?sieve=12 to the underlying tile source.

http://localhost:8080/{z}/{x}/{y}.json?cmds=-filter%20%22this.originalArea%20%3E%20%7B%7Bmath%20resolution%20%22*%22%201000%7D%7D%22%20-clean%20min-gap-area%3D%7B%7Bmath%20resolution%20%22*%22%2065000%7D%7D%20-simplify%20interval%3D%7B%7Bmath%20resolution%20%22*%22%202%7D%7D&sieve=12

To break this down, there are 2 query parameters included: cmds and sieve. cmds is the only parameter that mapshaper-proxy cares about; all others will be passed to the underlying tile source.

cmds is a set of URL-encoded MapShaper commands. In this case, it's:

-filter "this.originalArea > {{math resolution "*" 1000}}"
-clean min-gap-area={{math resolution "*" 65000}}
-simplify interval={{math resolution "*" 2}}

(Decoded using decodeURIComponent() in a JavaScript console. Newlines were added by hand.)

Commands may include handlebars expressions to facilitate dynamic functionality. At present, resolution and zoom are made available as variables to the template. Because handlebars does not natively support math expressions, a custom math handler is included, explaining the funky syntax.

To create your own cmds query parameter, run encodeURIComponent("-simplify 20%") (or similar) in a JavaScript console to encode it.

mapshaper-proxy's People

Contributors

mojodna avatar

Stargazers

Saiful Azfar Ramlee avatar Thomas Gratier avatar Brett Camper avatar

Watchers

 avatar James Cloos avatar  avatar

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.