Turf playground

by Stefano

HTML

<script src="https://npmcdn.com/@turf/turf/turf.min.js"></script>
<div id="output"></div>

JavaScript

var res = turf.toWgs84(turf.toMercator({
	"type": "Feature",
	"properties": {},
	"geometry": {
		"type": "Polygon",
		"coordinates": [
			[
				[
					180.054931640625,
					-16.480863883114882
				],
				[
					179.6539306640625,
					-16.878146994732155
				],
				[
					179.7967529296875,
					-17.329664329425047
				],
				[
					180.3131103515625,
					-17.14603949574698
				],
				[
					180.42572021484375,
					-16.754577926390958
				],
				[
					180.054931640625,
					-16.480863883114882
				]
			]
		]
	}
}));

display(res);


/* output function */
function display(data, target) {
	target = target || 'output';
  var el = document.getElementById(target);
  // if not available create target element
  if (!el) {
  	el = document.createElement('div');
    el.setAttribute("id", target);
    document.body.appendChild(el);
  }
  // inject text
	var json = JSON.stringify(data, null, '\t');
  document.getElementById(target).innerHTML = json;
}