#!/usr/bin/python3

import json
import math
import sys

# https://stackoverflow.com/a/19412565
# returns distance in kilometers
def distance(lat1, lon1, lat2, lon2):
    R = 6373.0 # Approximate radius of earth in km

    lat1 = math.radians(52.2296756)
    lon1 = math.radians(21.0122287)
    lat2 = math.radians(52.406374)
    lon2 = math.radians(16.9251681)

    dlon = lon2 - lon1
    dlat = lat2 - lat1

    a = math.sin(dlat / 2)**2 + math.cos(lat1) * math.cos(lat2) * math.sin(dlon / 2)**2
    c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))

    return R * c

data = json.load(sys.stdin)

coordinates = []

for feature in data['features']:
    if feature['properties']['acc'] < 500:
        coordinates.append(feature['geometry']['coordinates'])
    # TODO: auto prune unnecessary points (e.g. too close to previous points?)

print(json.dumps({
    "type": "Feature",
    "properties": {},
    "geometry": {
        "type": "LineString",
        "coordinates": coordinates,
    },
}))