Skip to content

Instantly share code, notes, and snippets.

@zeroasterisk
Created Nov 2, 2016
Embed
What would you like to do?
import poly data from taradel
var Buffer = require('buffer').Buffer;
var wkx = require('wkx');
function convertHex(hexInput) {
var wkbBuffer = new Buffer(hexInput.slice(2), 'hex');
var geometry = wkx.Geometry.parse(wkbBuffer);
return geometry.toGeoJSON();
}
function convertTwkb(hexInput) {
var wkbBuffer = new Buffer(hexInput.slice(2), 'hex');
var geometry = wkx.Geometry.parseTwkb(wkbBuffer);
return geometry.toGeoJSON();
}
var example = '0xE6100000010429000000E6EB32FCA75D53C0E4326E6AA0D14240C784984BAA5D53C005DB8827BBD14240B70A62A06B5D53C06534F279C5D142402F89B3226A5D53C0A3C85A43A9D1424037FFAF3A725D53C0B6679604A8D14240C32CB4739A5D53C03659A31EA2D14240E6EB32FCA75D53C0E4326E6AA0D14240D3872EA86F5D53C0B665C0594AD442407B30293E3E5D53C004E621533ED4424037548CF3375D53C01F4C8A8F4FD44240CAFCA36FD25C53C0E413B2F336D44240FC6D4F90D85C53C0B742588D25D442408BFD65F7E45C53C0B6B9313D61D342402368CC24EA5C53C001A5A14621D34240BFF38B12F45C53C053758F6CAED242407B4E7ADFF85C53C06E68CA4E3FD2424093C49272F75C53C03C1570CFF3D14240AFEC82C1355D53C04F57772CB6D14240AC1C5A643B5D53C028603B18B1D14240FB2477D8445D53C005C4245CC8D14240187B2FBE685D53C0CAF962EFC5D1424064963D096C5D53C0C8B4368DEDD14240D2393FC5715D53C0060E68E90AD2424039D55A98855D53C005FD851E31D242400266BE839F5D53C015A8C5E061D242407D3CF4DDAD5D53C025B1A4DC7DD24240AE7FD767CE5D53C0817A336ABED242407F4C6BD3D85D53C0A35698BED7D24240BD00FBE8D45D53C0795BE9B5D9D24240E61F7D93A65D53C0744012F6EDD2424037C478CDAB5D53C0BE13B35E0CD34240AEB6627FD95D53C0450DA661F8D24240A1866F61DD5D53C0185FB4C70BD342409EEA909BE15D53C0C0232A5437D3424043A9BD88B65D53C0BC3C9D2B4AD3424040A20914B15D53C05B41D3122BD3424045BA9F53905D53C0F530B43A39D34240EF8FF7AA955D53C03813D38558D34240E083D72E6D5D53C029B2D6506AD34240E1EB6B5D6A5D53C0E2395B4068D34240D3872EA86F5D53C0B665C0594AD44240020000000200000000020700000003000000FFFFFFFF0000000006000000000000000003000000000100000003';
// console.log(convertHex(example));
// ^ not working at all
console.log(convertTwkb(example));
// output: { type: 'MultiPolygon', coordinates: [] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment