Skip to content

Instantly share code, notes, and snippets.

@gormo-osm
Created April 5, 2018 20:46
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save gormo-osm/0fc8904edad6b58a6fa0178ad6b10c92 to your computer and use it in GitHub Desktop.
Properties aus GeoJSON löschen
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
#inputJSON { display: block; float: left; }
#mittelblock { display: block; float: left; margin-left: 2em;}
#outputJSON { display: block; float: left; margin-left: 2em;}
</style>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script language="JavaScript">
var jsonIn;
$(document).ready(function() {
$("#createOutput").on('click', function() {
jsonIn = JSON.parse($("#inputJSON").val());
for(i=0;i<jsonIn.features.length;i++) {
$("#deleteProps").val().split(",").forEach(function(delete_this_prop) {
delete jsonIn.features[i].properties[delete_this_prop];
});
}
$("#outputJSON").text( JSON.stringify(jsonIn, null, 2));
});
});
</script>
</head>
<body>
<textarea id="inputJSON" rows="30" cols="50">{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"öffentlicheDaten": "jaja",
"geheimeDaten": "neinnein",
"mehrDaten": "x",
"nochMehrDaten": "hhh"
},
"geometry": {
"type": "Point",
"coordinates": [
11.7,
51.6
]
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-178.84414403223613,
37.52107708186298
]
},
"properties": {
"öffentlicheDaten": "bla",
"geheimeDaten": "blibb",
"mehrDaten": "y",
"nochMehrDaten": "ggg"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-49.36635320666326,
-5.5984152570650565
]
},
"properties": {
"öffentlicheDaten": "was",
"geheimeDaten": "nix",
"mehrDaten": "z",
"nochMehrDaten": "tttt"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
11.498082375907721,
10.242744864248012
]
},
"properties": {
"öffentlicheDaten": "also wirklich ",
"geheimeDaten": "neeeeee",
"mehrDaten": "ccc",
"nochMehrDaten": "vvvvv"
}
}
]
}
</textarea>
<div id="mittelblock">
diese Properties löschen (mehrere mit Komma trennen):<br/>
<input type="text" id="deleteProps" size="50"/><br/>
<input type="button" id="createOutput" value="Ausgabe-JSON erzeugen"/>
</div>
<textarea id="outputJSON" rows="30" cols="50">
(noch keine Ausgabe erzeugt)
</textarea>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment