public void GetMiddleCoordinateEmptyTest() { var coordinates = new PointF[] {}; var middle = MapUtil.GetMiddleCoordinate(coordinates); Assert.AreEqual(PointF.Empty, middle); }
private static PointF CalcCenter(IEnumerable <AddressVm> addresses) { var points = addresses .Select(address => new PointF((float)address.Latitude, (float)address.Longitude)) .ToArray(); return(MapUtil.GetMiddleCoordinate(points)); }
public void GetMiddleCoordinateSimpleTest() { var coordinates = new[] { new PointF(5, 5), new PointF(10, 10), new PointF(20, 20) }; var middle = MapUtil.GetMiddleCoordinate(coordinates); Assert.AreEqual(new PointF(12.5f, 12.5f), middle); }
public void GetMiddleCoordinateRealTest() { var coordinates = new[] { new PointF(37.754237f, -122.412065f), new PointF(37.754113f, -122.414268f), new PointF(37.75256f, -122.412923f), new PointF(37.760708f, -122.410678f), new PointF(37.755351f, -122.419876f) }; var middle = MapUtil.GetMiddleCoordinate(coordinates); Assert.AreEqual(new PointF(37.7566338f, -122.415276f), middle); }
private static void SetEventMetadataCoordinate( EventMetadataRecord eventMetadata, IEnumerable <Venue> venues) { var coordinates = venues.SelectMany( v => v.Addresses != null ? v.Addresses.Select( a => new PointF((float)a.Latitude, (float)a.Longitude)) : Enumerable.Empty <PointF>()).ToArray(); var middle = MapUtil.GetMiddleCoordinate(coordinates); eventMetadata.Latitude = middle.X; eventMetadata.Longitude = middle.Y; }
private static void RecalcEventCoordinates(EventMetadataRecord eventMeta) { var coords = eventMeta .ShowRecords .Where(s => !s.IsDeleted) .Select(s => s.EntityRecord) .SelectMany(v => v.AddressRecords) .Select(address => new PointF((float)address.Latitude, (float)address.Longitude)) .ToArray(); if (coords.Length != 0) { var eventCoord = MapUtil.GetMiddleCoordinate(coords); eventMeta.Latitude = eventCoord.X; eventMeta.Longitude = eventCoord.Y; } else { eventMeta.Latitude = 0; eventMeta.Longitude = 0; } }