Can't create correct location manually - it always shows wrong position. Can someone tell how to do it right and show where I have wrong values in my code? Thanks.
ESTLocationBuilder *locationBuilder = [ESTLocationBuilder new];
[locationBuilder setLocationBoundaryPoints:@[
[ESTPoint pointWithX:0 y:0],
[ESTPoint pointWithX:0 y:7.46],
[ESTPoint pointWithX:7.6 y:7.46],
[ESTPoint pointWithX:7.6 y:0]
]];
[locationBuilder setLocationOrientation:275];
[locationBuilder addBeaconIdentifiedByMac:kBeaconMac1
atBoundarySegmentIndex:0
inDistance:0
fromSide:ESTLocationBuilderLeftSide];
[locationBuilder addBeaconIdentifiedByMac:kBeaconMac2
atBoundarySegmentIndex:1
inDistance:0
fromSide:ESTLocationBuilderLeftSide];
[locationBuilder addBeaconIdentifiedByMac:kBeaconMac3
atBoundarySegmentIndex:2
inDistance:0
fromSide:ESTLocationBuilderRightSide];
[locationBuilder addBeaconIdentifiedByMac:kBeaconMac4
atBoundarySegmentIndex:3
inDistance:0
fromSide:ESTLocationBuilderRightSide];
self.location = [locationBuilder build];
The way you're setting up points and orientation looks fine.
The only thing that needs changing:
[locationBuilder addBeaconIdentifiedByMac:kBeaconMac1
atBoundarySegmentIndex:0
inDistance:0
fromSide:ESTLocationBuilderLeftSide];
This code reads:
I have a beacon with MAC addreses
kBeaconMac1
placed on the first wall (atBoundarySegmentIndex:0
), 0 meters (inDistance:0
) from the left side of the wall (fromSide:ESTLocationBuilderLeftSide
).
"Left" or "Right" is understood as "I'm in the middle of the room, facing directly towards the wall; the left side is to my left and the right side is to my right".
"First wall" is understood as the wall between the first two points you defined in setLocationBoundaryPoints
. "Second wall" would be between the second and the third point, "Third wall" between the third and the fourth, and the final "Fourth wall"—the fourth and the first.
Looking at the picture, you actually have your beacon in the middle of the wall, so you want the inDistance
parameters set to theWidthOfTheWall / 2
, i.e. in case of the "First wall", 7.46 / 2 = 3.73
. In this particular scenario, "left" or "right" doesn't matter.
Here's the code matching the picture:
[locationBuilder addBeaconIdentifiedByMac:kBeaconMac1
atBoundarySegmentIndex:0
inDistance:3.73
fromSide:ESTLocationBuilderLeftSide];
[locationBuilder addBeaconIdentifiedByMac:kBeaconMac2
atBoundarySegmentIndex:1
inDistance:3.8
fromSide:ESTLocationBuilderLeftSide];
[locationBuilder addBeaconIdentifiedByMac:kBeaconMac3
atBoundarySegmentIndex:2
inDistance:3.73
fromSide:ESTLocationBuilderRightSide];
[locationBuilder addBeaconIdentifiedByMac:kBeaconMac4
atBoundarySegmentIndex:3
inDistance:3.8
fromSide:ESTLocationBuilderRightSide];