def errors(db, langs): params = Params(max_limit=10000) results = query._gets(db, params) out = [] for res in results: i = { 'lat': float(res["lat"]), 'lon': float(res["lon"]), 'id': res["uuid"], 'item': str(res["item"]), } if params.full: i.update({ 'lat': float(res["lat"]), 'lon': float(res["lon"]), 'id': res["uuid"], 'item': str(res["item"]), 'source': res["source"], 'class': res["class"], 'subtitle': utils.i10n_select(res["subtitle"], langs), 'title': utils.i10n_select(res["title"], langs), 'level': res["level"], 'update': str(res["timestamp"]), 'usernames': list(map(lambda elem: "username" in elem and elem["username"] or "", res['elems'] or [])), 'osm_ids': dict(map(lambda k_g: [ {'N':'nodes', 'W':'ways', 'R':'relations'}[k_g[0]], list(map(lambda g: g['id'], k_g[1])) ], groupby(sorted(res['elems'] or [], key=lambda e: e['type']), lambda e: e['type']))), }) out.append(i) return {'issues': out}
def _fp(version, db, langs, uuid, marker, columns): data_type = {"N": "node", "W": "way", "R": "relation", "I": "infos"} lat = str(marker["lat"]) lon = str(marker["lon"]) title = utils.i10n_select(marker["title"], langs) subtitle = utils.i10n_select(marker["subtitle"], langs) b_date = marker["timestamp"] or "" item = marker["item"] or 0 date = marker["date"].isoformat() or 0 if version == 2: return { "lat": lat, "lon": lon, "minlat": float(lat) - 0.002, "maxlat": float(lat) + 0.002, "minlon": float(lon) - 0.002, "maxlon": float(lon) + 0.002, "error_id": err_id, "title": title['auto'], "subtitle": subtitle['auto'], "b_date": b_date.strftime("%Y-%m-%d"), "item": item, "date": date, "url_help": "" # Keep for retro compatibility } else: return { "lat": lat, "lon": lon, "minlat": float(lat) - 0.002, "maxlat": float(lat) + 0.002, "minlon": float(lon) - 0.002, "maxlon": float(lon) + 0.002, "id": uuid, "title": title, "subtitle": subtitle, "b_date": b_date.strftime("%Y-%m-%d"), "item": item, "date": date, }
def _fp(version, db, langs, uuid, marker, columns): lat = str(marker["lat"]) lon = str(marker["lon"]) title = utils.i10n_select(marker["title"], langs) subtitle = utils.i10n_select(marker["subtitle"], langs) item = marker["item"] or 0 date = marker["date"].isoformat() or 0 if version == 2: return { "lat": lat, "lon": lon, "minlat": float(lat) - 0.002, "maxlat": float(lat) + 0.002, "minlon": float(lon) - 0.002, "maxlon": float(lon) + 0.002, "error_id": err_id, "title": title['auto'], "subtitle": subtitle['auto'], "b_date": None, # Keep for retro compatibility "item": item, "date": date, "url_help": "" # Keep for retro compatibility } else: return { "lat": lat, "lon": lon, "minlat": float(lat) - 0.002, "maxlat": float(lat) + 0.002, "minlon": float(lon) - 0.002, "maxlon": float(lon) + 0.002, "id": uuid, "title": title, "subtitle": subtitle, "b_date": None, # Keep for retro compatibility "item": item, "date": date, }
def errors(db, lang): params = Params() results = query._gets(db, params) out = OrderedDict() if not params.full: out["description"] = ["lat", "lon", "error_id", "item"] else: out["description"] = ["lat", "lon", "error_id", "item", "source", "class", "elems", "subclass", "subtitle", "title", "level", "update", "username"] out["errors"] = [] for res in results: lat = res["lat"] lon = res["lon"] error_id = res["id"] item = res["item"] or 0 if not params.full: out["errors"].append([str(lat), str(lon), str(error_id), str(item)]) else: source = res["source"] classs = res["class"] elems = '_'.join(map(lambda elem: {'N':'node', 'W':'way', 'R':'relation'}[elem['type']] + str(elem['id']), res['elems'] or [])) subclass = 0 subtitle = utils.i10n_select(res['subtitle'], lang) subtitle = subtitle and subtitle['auto'] or '' title = utils.i10n_select(res['title'], lang) title = title and title['auto'] or '' level = res["level"] update = res["timestamp"] username = '******'.join(map(lambda elem: "username" in elem and elem["username"] or "", res['elems'] or [])) out["errors"].append([str(lat), str(lon), str(error_id), str(item), str(source), str(classs), str(elems), str(subclass), subtitle, title, str(level), str(update), username]) return out
def _error(version, db, langs, uuid, marker): if not marker: abort(410, "Id is not present in database.") data_type = {"N": "node", "W": "way", "R": "relation", "I": "infos"} lat = str(marker["lat"]) lon = str(marker["lon"]) title = utils.i10n_select(marker["title"], langs) subtitle = utils.i10n_select(marker["subtitle"], langs) b_date = marker["timestamp"] or "" item = marker["item"] or 0 classs = marker["class"] or 0 elems = [] for elem in marker['elems'] or []: if elem['type']: tags = elem.get("tags", {}) tmp_elem = { data_type[elem['type']]: True, "type": data_type[elem['type']], "id": elem["id"], "tags": _expand_tags(tags, t2l.checkTags(tags)), "fixes": [], } for fix_index, fix_group in enumerate(marker['fixes'] or []): for fix in fix_group: if (fix['type'] and fix['type'] == elem['type'] and fix['id'] == elem["id"]): tmp_elem["fixes"].append({ "num": fix_index, "add": _expand_tags(fix['create'], t2l.checkTags(fix['create'])), "mod": _expand_tags(fix['modify'], t2l.checkTags(fix['modify'])), "del": _expand_tags(fix['delete'], {}, True), }) elems.append(tmp_elem) new_elems = [] for fix_index, fix_group in enumerate(marker['fixes'] or []): for fix in fix_group: if fix['type']: found = False for e in elems: if (e["type"] == data_type[fix['type']] and e["id"] == fix['id']): found = True break if not found: new_elems.append({ "num": fix_index, "add": _expand_tags(fix['create'], t2l.checkTags(fix['create'])), "mod": _expand_tags(fix['modify'], t2l.checkTags(fix['modify'])), "del": _expand_tags(fix['delete'], {}, True), }) if version == 2: return { "lat": lat, "lon": lon, "minlat": float(lat) - 0.002, "maxlat": float(lat) + 0.002, "minlon": float(lon) - 0.002, "maxlon": float(lon) + 0.002, "error_id": marker['id'], "title": title and title['auto'], "subtitle": subtitle and subtitle['auto'], "b_date": b_date.strftime("%Y-%m-%d"), "item": item, "class": classs, "elems": elems, "new_elems": new_elems, "elems_id": ','.join( map(lambda elem: elem['type_long'] + str(elem['id']), marker["elems"])), "url_help": "" # Keep for retro compatibility } else: return { "lat": lat, "lon": lon, "minlat": float(lat) - 0.002, "maxlat": float(lat) + 0.002, "minlon": float(lon) - 0.002, "maxlon": float(lon) + 0.002, "uuid": uuid, "title": title, "subtitle": subtitle, "b_date": b_date.strftime("%Y-%m-%d"), "item": item, "class": classs, "elems": elems, "new_elems": new_elems, }