I'm trying to make a gps and google maps based appthat notifies you when you are near specific places. You can set the places from the start (banks,coffee shops,hotels...) and when you are some meters away a pop up message pops and tells you, for example "You are near sunshine hotel"!!
I tested with some coordinates and it notifies me correctly but I would like to make a list of coordinates and pass them to the ai2 so I can have many places set up and their pop up messages.
Can you help me? I'll post the block Imade to notify you when you are at some coordinates for you to see.
I would like to make a geofence like that but don't know how... If you can help me with that also please.
--
Here are some suggestions. Also google using search for messages in the forum with List as the search to learn how to use Lists.
You have a good start. Sorry, there are already issues with your proposal.
The tutorial Exploring with LocationSensor in AI2 https://docs.google.com/document/d/1V1Zm5cYoa12KVb_cTlfelSfyUkW7IH2WPHUoTa02XaY/pub
Here are some suggestions. Also google using search for messages in the forum with List as the search to learn how to use Lists.
You have a good start. Sorry, there are already issues with your proposal.
The tutorial Exploring with LocationSensor in AI2 https://docs.google.com/document/d/1V1Zm5cYoa12KVb_cTlfelSfyUkW7IH2WPHUoTa02XaY/pub
explains that a difference of 0.00001 of a degree of latitude converts to 0.9144 meters. You probably read that but are you aware:
40.93563
40.93565
_________
0.0002 at 0.00001 x 20 = 18.29 meters approximately
24.4002
24.4004
_______
0.0002 at 0.00001 x 20 = 18.29 meters approximately (longitude varies South to North) but the latitude approximation might be good enough.
Your example ring fence is 18 x 18 meters. Your GPS seldom has an Accuracy (see the above tutorial) that good . Some times when you get a satellite fix Accuracy will be 12 m, sometimes 2, sometimes 50. So what happens if you use a ring fence as small as you show in your example? Can the GPS always resolve an 18 m diameter circle?
To know whether the device is within 150 meters of the location using this technique, shouldn't your difference in Latitude/Longitude be 0.00001 X 0.9144 (approx 1 meter) x 150 meters ; that is should the sizes of the ring fence be at least 0.015 degrees on a side? Perhaps you want a larger ring fence box?
If you want the algorithm to be generic; consider using variables in the ring fence equation. The boundaries for the ring fence can be created using your List of places ('Sunshine hotel' , 40.9xxxx , 24.4xxx) or however you create your List or List of Lists to handle geocoordinates and venue ). Create VenueLatitude and VenuLongitude variables and populate them with lat and from your List of places. Do the same for the venue longitudes (east/west).
Call the Northern latitude perhaps NLatitude also create SLatitude and Elongitude and Wlongitude perhaps get NLatitude > (Vemieatitude + 0.0075) and get Slatitude < (Venuelatitude - 0.0075) and the same for the longitudes? 0.0075 degree is one half of a ring fence side. If you use a generic solution you can use the same information to populate a polygon as mentioned below.
I know of now way to populate a static map with a circle as shown in your image. You can use pipes and draw the sizes of your ring fence using the Google API as a box or use a polygonal area . Perhaps use a square based on your ring fence dimensions instead of a circle. https://developers.google.com/maps/documentation/static-maps/intro. Keep in mind Google restricts the characters in a url used to capture a static map to 2,048 characters.
Creating an app like this is getting very complicated. You can create something similar to what can be done with the Java compilers if you take one step at a time. The key word is similar ..AI2 does not have all the tools necessary to use all the Google API features. Experiment with small pieces as you have already started to do; keep it up. Make a small test example using two or three venues. If you still have issues, show your progress and ask again.
Another solution might be to use a Fusion Table with all your venues loaded and use the FT mapping capabilities.. If you do it this way, you are however restricted in how you can annotate the Fusion Table map. See the post here to get an idea as to what that is all about https://groups.google.com/forum/#!category-topic/mitappinventortest/oKFMCEt1kRs
thank you very much you helped me a lot!! :D
I made some lists and they kinda work but I need somemore help with them.
It appears you have the beginnings of a good test Project. You now have a generic ringed fence algorithm that works.
--
There are still issues you certainly can fix get your app to work they way you want. Ask yourself why does the notification appear every two seconds in your test app?
Your notifier block located is in your LocationChanged block. That meansvthe ringed fence if statement tests every time your LocationChanged event is triggered/
If the ringed fence if statement is true, your vibrate starts and you get a notification message probably. ...and it happens about every two seconds? That frequency tells you something. To get a repeat message, the LocationChanged event must fire (execute) again. Think about what can cause the event to fire every two seconds? What is your LocationSensor TimeInterval set to?
This image shows one place TimeInterval can be set circled in red. The example shows 60000 which polls the LS once a minute (6,0000 ms). Polling every two seconds does not seem reasonable to me.
The other place a developer can set the TimeInterval is using the blocks above. You did not show one of these blocks in your code so it appears you set the interval in the Control. I expect you are polling the LS to get a satellite fix every 2000 ms (every two seconds?) or your DistanceInterval is NOT 0. Is that true?
However, there is another reason the LocationSensor might fire. Did you set the DistanceInterval to a NOT 0 value. Is that true? If it is, read the MIT LocationSensor tutorial to find out why setting this to a different value (in meters) can cause the LS to fire? Both options can be set but doing so can lead to confusion. I would keep DistanceInterval at 0.
Did you set the LocationSensor DistanceInterval to something other than zero ( 0 ms )? An interval of not 0 could cause frequent tripping of the LocationSensor.
Your code to determine if the device's current location is within the ringed fence is now within the ChangedEvent block. This does work but is not the best programming practice. AI2 blocks execute asynchronously. Better to place your ringed fence blocks into a procedure outside the ChangedEvent block and call the Procedure within the ChangedEvent block instead. The less code a developer places in LocationChanged the better. Using a procedure allows you to avoid 'timing' collisions in code execution. However, a potentially better solution is described below (the ringed event Procedure in a Clock).
You said " I want to make a loop that for everytime it finds a right location (everytime if statement is right), it stops the loop." OK. A loop might not be your best solution. A loop could work depending on your code. Using a Clock might be a better solution (perhaps place your ringed fence Procedure into the clock, after you call the ringed fence procedure, use a block to turn off the Clock (Clock.TimerEnabled is set to false) ). If you do that you have many options to turn off the notifier after if 'finds' a venue. There are other ways of disabling the notifier...this suggestion is simple.
Use Boolean switches (check for a state of true or false). Create a variable called VenueFound and initially set to false. If VenueFound is false then call Notifier1 else if VenueFound is true then do nothing.
Try some code.
Ask yourself why you send an address to your TinyDB everytime the LocationSensor fires. Why do you do that? You are collecting a lot of CurrentAddress events, but why?
Well as I was searching and trying tutorials I did that and forgot it (see the block).
The buttons are : 1)Museums, 2)Hotels, 3)Petrol Stations, 4)Cashpoints, 5)Coffee, 6)Fast Food, 7)Pubs and Bars, 8)Restaurants.
I'll show you my new loop now. It goes on and on and on....that is something I don't like and I'll try to make a procedure like you told me/
The interface of my app is that.
The buttons are : 1)Museums, 2)Hotels, 3)Petrol Stations, 4)Cashpoints, 5)Coffee, 6)Fast Food, 7)Pubs and Bars, 8)Restaurants.
If you press one button then the black X goes away and that means that when I walk near a location that this button describes then it notifies me. For example if the buttons Museums and Coffee does not have the black X that means that the app notifies meonly if I walk near (150 m) a Museum or a Hotel.
I have made lists for every button (not finished yet) with latitude, lontitude and place name. If the button is enabled (that means it does not have the black X), then the programm gets in the loop and searches for e.x. Museums and Coffee Shops only and notifies me when I walk near them. Here is my lists for Hotel button.
I'll show you my new loop now. It goes on and on and on....that is something I don't like and I'll try to make a procedure like you told me/
The reason I put the address in a database is because I will need it later cause I want to save them but that's another thing I don't need help right now.
:D Thank you again my friend
--
--
댓글 없음:
댓글 쓰기