Bounding Box point of entry

96 views
Skip to first unread message

elCapitan

unread,
Apr 3, 2018, 4:10:22 PM4/3/18
to MIT App Inventor Forum
Assume you have created a rectangular bounding box at a point on a two way street and you would like to trigger an event/alert when entering from only one direction, not from the
other how would you define it?

Chris Ward

unread,
Apr 4, 2018, 7:56:02 AM4/4/18
to MIT App Inventor Forum
Hello elCapitan

A tricky question! Firstly, since you cannot rotate a map rectangle, it's impossible to align one properly with a road, unless that road happens to be Horizontal/Vertical to the map.

Thinking out loud, the following could be absolute garbage, or it could be of some use:

You only need a point on the road (e.g., a Circle with known location) as the destination location, and a point before it (another circle of known location, a "way point") on the road nearby. Thus, when your sensor has passed the way point and gets to the location, you know the device travelled in that particular direction.

SteveJG

unread,
Apr 4, 2018, 8:56:59 AM4/4/18
to mitappinv...@googlegroups.com
There is no real way to do this with any real reliability.  Here is why.

Your are using a bounding box.  What is called a ring fence or geo-fence? 

If you are using a ring fence, as illustrated in the following tutorial      
                               one option is to compare the  bounding latitude/longitude of the entry point compared to the latitude/longitude with exit point.


In the example case the Northern boundary is 37.78034 and the Southern boundary is

                                                                          37.78016 .   If the device is entering from the North, the initial latitude upon entering will be closer to 37.78034 than it is to 37.78016.  You could compare the actual latitude at the 'point of entry'  with the southern and northern bounds.  If the point of entry is closer to the southern bound, then the entry is from the south.    This takes care of North/South.  Use the longitude to compare West/East.    What about other directions of entry?   Perhaps from the northwest?   Hmmm.  Then you have to do some trigonometry and things get messy.


If the ring fence is relatively small in dimensions, all these calculations are probably useless?   Why?   Read about the LocationSensor Property of Accuracy.

You could use the Orientation Sensor to find the direction of travel.  If the sensor points to magnetic South, the device is moving from North to South.

If you are using a ring fence in conjunction with the MIT Map component, there are some other things that could be done in a different way.  
----------------------
Edit:  Perhaps set a bounding box  using Map

BoundingBox
Sets or gets the current boundary for the map's drawn view. The value is a list of lists containing the northwest and southeast coordinates of the current view in the form ((North West) (South East)).
As stated, the rectangular coordinates probably would be a List of the coordinates.

You could make a comparison in a way similar to what you would do with the first example. 
-------------------
 In my opinion, none of these solutions is satisfactory in ensuring you are going the right way on a one way street (unless of course the street is North-South or East-West and not curving.  :(

Regards,
Steve

Reply all
Reply to author
Forward
0 new messages