// store in mapBeacons the beacons on the map private void getMapBeacons(ref BeaconOnMap[] mapBeacons) { mapBeacons[0] = new BeaconOnMap(23896, 25923, 614, 345); mapBeacons[1] = new BeaconOnMap(7354, 47683, 158, 230); mapBeacons[2] = new BeaconOnMap(58610, 36050, 324, 257); mapBeacons[3] = new BeaconOnMap(18155, 58632, 446, 162); mapBeacons[4] = new BeaconOnMap(61265, 34052, 333, 116); mapBeacons[5] = new BeaconOnMap(36242, 5515, 306, 493); mapBeacons[6] = new BeaconOnMap(31499, 2016, 416, 369); mapBeacons[7] = new BeaconOnMap(30745, 50948, 66, 98); }
protected virtual void HandleRanging(object sender, BeaconManager.RangingEventArgs e) { // major, minor, xpos, ypos BeaconOnMap[] mapBeacons = new BeaconOnMap[8]; getMapBeacons(ref mapBeacons); // distanceInMeters * ratio = distanceInPixels const int ratio = 43; Log.Debug(TAG, "Found {0} beacons.", e.Beacons.Count); foreach (Beacon b in e.Beacons) { Log.Debug(TAG, "major: {0}, minor: {1}, distance: {2}", b.Major, b.Minor, Utils.ComputeAccuracy(b)); } BeaconsFound(this, new BeaconsFoundEventArgs(e.Beacons)); if (e.Beacons.Count < 3) { return; } BeaconOnMap[] b3 = new BeaconOnMap[3]; int[] dist = new int[3]; getClosest3BeaconsOnMap(ref b3, ref dist, e.Beacons, mapBeacons, ratio); Position pos = intersectThreeCircles(b3[0].getPosition(), dist[0], b3[1].getPosition(), dist[1], b3[2].getPosition(), dist[2]); //Log.Debug(TAG, "{0}", canvas.ActualHeight); if (pos.getX() != 0 && pos.getY() != 0) { Map.drawPointOnMap(pos.getX(), pos.getY()); } Log.Debug(TAG, pos.ToString()); // IEnumerable<Beacon> beacons = from item in e.Beacons // let uuid = item.ProximityUUID // where uuid.Equals(EstimoteBeacons.EstimoteProximityUuid, StringComparison.OrdinalIgnoreCase) || // uuid.Equals(EstimoteBeacons.EstimoteIosProximityUuid, StringComparison.OrdinalIgnoreCase) // select item; }