chore: use new filter classes

This commit is contained in:
Paul Bienkowski 2021-10-10 10:16:45 +02:00
parent 4742a6df13
commit ddeb5f9195
2 changed files with 18 additions and 16 deletions

@ -1 +1 @@
Subproject commit 44488dfdc8a15f4723824ce2f8f12a1ebdd0d23d Subproject commit 657a63975325f42bd932108d7d73ddfbd04487a7

View file

@ -6,10 +6,8 @@ import json
from obs.face.importer import ImportMeasurementsCsv from obs.face.importer import ImportMeasurementsCsv
from obs.face.annotate import AnnotateMeasurements from obs.face.annotate import AnnotateMeasurements
from obs.face.filter import MeasurementFilter from obs.face.filter import PrivacyFilter, ChainFilter, AnonymizationMode, RequiredFieldsFilter, ConfirmedFilter
from obs.face.geojson import ExportMeasurements, ExportRoadAnnotation
from obs.face.osm import DataSource as OSMDataSource from obs.face.osm import DataSource as OSMDataSource
from obs.face.filter import PrivacyFilter
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -55,19 +53,23 @@ def process(args):
os.makedirs(args.output, exist_ok=True) os.makedirs(args.output, exist_ok=True)
filename_log = os.path.join(args.output, f"{dataset_id}.log")
log.info("Annotating and filtering CSV file") log.info("Annotating and filtering CSV file")
with open(filename_log, "w") as logfile: measurements, statistics = ImportMeasurementsCsv().read(
measurements, statistics = ImportMeasurementsCsv().read( filename_input,
filename_input, user_id="dummy",
user_id="dummy", dataset_id=dataset_id,
dataset_id=dataset_id, )
log=logfile,
) measurements = AnnotateMeasurements(osm, cache_dir=args.cache_dir).annotate(measurements)
measurements = AnnotateMeasurements(osm, cache_dir=args.cache_dir).annotate(measurements)
confirmed_measurements = MeasurementFilter().filter(measurements, log=logfile) valid_measurements = ChainFilter(
valid_measurements = MeasurementFilter(remove_unconfirmed=False).filter(measurements, log=logfile) RequiredFieldsFilter(),
PrivacyFilter(
user_id_mode=AnonymizationMode.REMOVE,
measurement_id_mode=AnonymizationMode.REMOVE,
),
).filter(measurements, log=log)
confirmed_measurements = ConfirmedFilter().filter(valid_measurements, log=log)
# write out # write out
confirmed_measurements_json = { confirmed_measurements_json = {