add render() to LocationAnalyzer

simu_flags
clemens 2017-07-26 18:18:30 +02:00
parent 3c5e6c3ce3
commit e59e1647ac
2 changed files with 10 additions and 1 deletions

View File

@ -1,3 +1,4 @@
import json
from collections import defaultdict
from log_analyzer import LogSettings
@ -23,6 +24,11 @@ class LocationAnalyzer(Analyzer):
def result(self) -> object:
return self.entries
def render(self, format="geojson"):
if format is "geojson":
return json.dumps([entry['location']['coordinates'] for entry in self.entries])
raise NotImplementedError()
def process(self, entry: dict) -> bool:
if entry[self.settings.entry_type] in self.settings.spatials:
self.entries.append(entry)

View File

@ -52,4 +52,7 @@ if __name__ == '__main__':
break
for analyzer in analyzers:
print("* Result for " + str(type(analyzer)))
print(analyzer.result())
print(analyzer.result())
coords = analyzers[0].render()
with open("test.js", "w") as out:
out.write("coords = "+coords)