Code Monkey home page Code Monkey logo

wms-downloader's Introduction

wms-downloader

Installation

01 NodeJS and NPM

Windows: Use the installer from https://nodejs.org/

Ubuntu / Debian:

sudo apt-get install nodejs npm

02 GraphicsMagick

Windows: Use the installer from http://www.graphicsmagick.org/

Ubuntu / Debian:

sudo apt-get install graphicsmagick

03 wms-downloader

Use terminal:

npm install wms-downloader

Get started

Example

Download

var downloader = require('wms-downloader');

var taskOptions = {
	"task" : {
		"id" : "id_of_my_first_download",
		"title" : "My first WMS download.",
		"format" : "image/png",
		"workspace" : "./tiles",
		"area" : {
			"bbox" : {
				"xmin" : 455000,
				"ymin" : 5750000,
				"xmax" : 479000,
				"ymax" : 5774000
			}
		}
	},
	"tiles" : {
		"maxSizePx" : 2500,
		"gutterPx" : 250,
		"resolutions" : [ {
			"id" : "id_of_resolution_25000",
			"scale" : 25000,
			"dpi" : 96
		} ]
	},
	"wms" : [ {
		"id" : "id_of_wms_stadtbezirke",
		"getmap" : {
			"url" : "http://www.bielefeld01.de/geodaten/geo_dienste/wms.php?url=gebietsgliederung_wms_stadtbezirke_641&",
			"kvp" : {
				"SERVICE" : "WMS",
				"REQUEST" : "GetMap",
				"VERSION" : "1.3.0",
				"LAYERS" : "stadtbezirke_wms",
				"STYLES" : "",
				"CRS" : "EPSG:25832",
				"FORMAT" : "image/png",
				"TRANSPARENT" : "TRUE",
				"MAP_RESOLUTION" : 72
			}
		}
	} ]
};

// Init downloader
downloader.init({
	"request" : {
		"userAgent" : "wms-downloader",
		"timeout" : 30000
	}
});

// Print progress
var progressInterval = setInterval(function() {
	var progress = downloader.getProgress(taskOptions.task.id);
	console.log('Progress: ' + progress.percent + '%, Waiting time: ' + progress.waitingTime + ' ms');
}, 1000);

// Start download
downloader.startDownload(taskOptions, function(err) {

	// Stop progress printing
	clearInterval(progressInterval);

	if (err) {
		console.log(err);
	} else {
		console.log('Download was finished.');
	}

});

Download with proxy

var downloader = require('wms-downloader');

var configOptions = {
	"request" : {
		"userAgent" : "wms-downloader",
		"timeout" : 30000,
		"proxy" : {
			"http" : {
				"host" : "10.208.20.71",
				"port" : 4239,
				"user" : "NameOfUser",
				"password" : "PasswordOfUser",
				"exclude" : [ "http://12.101.20.18/", "http://12.208.28.48/" ]
			}
		}
	}
};

var taskOptions = {
	"task" : {
		"id" : "id_of_my_first_download",
		"title" : "My first WMS download.",
		"format" : "image/png",
		"workspace" : "./tiles",
		"area" : {
			"bbox" : {
				"xmin" : 455000,
				"ymin" : 5750000,
				"xmax" : 479000,
				"ymax" : 5774000
			}
		}
	},
	"tiles" : {
		"maxSizePx" : 2500,
		"gutterPx" : 250,
		"resolutions" : [ {
			"id" : "id_of_resolution_25000",
			"scale": 25000,
            "dpi": 96
		} ]
	},
	"wms" : [ {
		"id" : "id_of_wms_stadtbezirke",
		"getmap" : {
			"url" : "http://www.bielefeld01.de/geodaten/geo_dienste/wms.php?url=gebietsgliederung_wms_stadtbezirke_641&",
			"kvp" : {
				"SERVICE" : "WMS",
				"REQUEST" : "GetMap",
				"VERSION" : "1.3.0",
				"LAYERS" : "stadtbezirke_wms",
				"STYLES" : "",
				"CRS" : "EPSG:25832",
				"FORMAT" : "image/png",
				"TRANSPARENT" : "TRUE",
				"MAP_RESOLUTION" : 72
			}
		}
	} ]
};

// Init downloader
downloader.init(configOptions);


// Print progress
var progressInterval = setInterval(function() {
	var progress = downloader.getProgress(taskOptions.task.id);
	console.log('Progress: ' + progress.percent + '%, Waiting time: ' + progress.waitingTime + ' ms');
}, 1000);

// Start download
downloader.startDownload(taskOptions, function(err) {

	// Stop progress printing
	clearInterval(progressInterval);

	if (err) {
		console.log(err);
	} else {
		console.log('Download was finished.');
	}

});

Supported formats

  • image/png
  • image/jpeg
  • image/gif
  • image/tiff

License

MIT

wms-downloader's People

Watchers

James Cloos avatar RandomName 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.