private void SetLocation(IEnumerable <Entity> entities, StringBuilder collisionInfo, Boolean overrideData) { if (entities == null) { throw new ArgumentNullException("entities"); } ClearRunInfo(); foreach (var entity in entities) { Boolean hasValue = false; var office = entity.office.FirstOrDefault(); if (office != null) { hasValue = office.Point != null; } if (hasValue) { var item = _helper.GetWikiDataItemForEntity(entity); if (item == null) { _runInfo[WikiDataState.ItemNotFound]++; collisionInfo.AppendFormat("{0}: {1} was deleted!", entity.wiki.wikidata, entity.english); } else { var state = _helper.LocationCorrect(item, entity); _runInfo[state]++; if (state == WikiDataState.WrongValue) { var expected = new GeoCoordinate(Convert.ToDouble(office.Point.lat), Convert.ToDouble(office.Point.@long)); var actual = _helper.GetCoordinateValue(item, WikiBase.PropertyIdCoordinate); var distance = expected.GetDistanceTo(actual); collisionInfo.AppendFormat("{0}: {1} has wrong location, off by {2:0.###}km", item.id, entity.english, distance / 1000.0); collisionInfo.AppendLine(); } if (state != WikiDataState.Valid) { var statement = _helper.SetLocation(item, entity, overrideData); if (statement != null) { statement.save(_helper.GetClaimSaveEditSummary(statement)); } } } } } }