Last active
April 13, 2016 19:55
-
-
Save trillerpfeife/fe3e750de38ae3d0beb14e699e158e09 to your computer and use it in GitHub Desktop.
Convert crap to GeoJSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//map for objects | |
Object.defineProperty(Object.prototype, 'map', { | |
value: function(f, ctx) { | |
ctx = ctx || this; | |
var self = this, result = {}; | |
Object.keys(self).forEach(function(k) { | |
result[k] = f.call(ctx, self[k], k, self); | |
}); | |
return result; | |
} | |
}); | |
var newGeo = { | |
"type": "FeatureCollection", | |
"features": | |
[] | |
} | |
var oldGeo = { | |
"cTVnehLvJ1bt9lkjSd8YjWwSzeY=":{ | |
"id":"cTVnehLvJ1bt9lkjSd8YjWwSzeY=", | |
"name":"Aachener Land Nord", | |
"type":"type1", | |
"xCoordinate":"50.818", | |
"yCoordinate":"6.215", | |
"county":"10", | |
"bab":"A4", | |
"operator":"tankrast", | |
"has":{ | |
"bar":true, | |
"bat":true | |
} | |
} | |
} | |
} | |
function feature(y,x,name) { | |
var element = { | |
"type": "Feature", | |
"geometry": { | |
"type": "Point", | |
"coordinates":[Number(x),Number(y)] | |
}, | |
"properties": { | |
"name": name | |
} | |
}; | |
return element; | |
} | |
oldGeo.map(function(value,index,obj){ | |
newGeo.features.push(new feature(value.xCoordinate,value.yCoordinate,value.name)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment