How to obtain geographic location (data) via a Twitter Streams api query? - twitter

I am using the twitter streaming api and have created a stream about #javascript but I want to pitch my tweets on a map.
Every response I get in any of the geo or locations field is null. So I need some form of elevated privilege or is the tweets location something I'm not allowed to query?

There is no extra privilege for this. You have a few options, all of which yield a very low percentage of geo-located tweets.
The geo field used to be filled with coordinates for about 1% of all tweets. Twitter this year began returning even fewer tweets with geo coordinates.
These days, you will get a small percentage of tweets with place, which contains the coordinates for a bounding box. This may not be useful for you if you want to map a point, although you could calculate the center of the box and map that. Also, place is manually selected when tweeting, so it's meaning is questionable.
Your last option is the location field which users fill in about half the time. It's a fixed location that the user identifies with. Often it's some sarcastic comment. Still, location is usable if you send it to a geolocation service which will return its latitude and longitude. Like place, location has questionable significance.

Related

How to show multiple users location in iOS project live?

I am trying to develop an app that would show the location of multiple users near you on a map in real time. Me and my friend were thinking of getting the users location every 1 min, then upload their current location to a database, then update that on the map, and show it on other people's map. Now we realize that this would consume so much data and time from the user, also that would create so much calling to the database which we are trying to limit. So my question is, how would I show multiple users location on the map in real time? Think of uber or lyft and how they display the driver's location and also many other driver's location to the user. How did they accomplish that or if there is away of creating a similar thing without the strain on the user's data.
Steps to be followed -
Get location of the user not after every 1 minute or specific time but get location as per user moves. Get their location by using Significant-Change Location.
To get multiple users data - you must be storing data of other users, so get those data in background thread. Don't use main thread to get data but use main thread to display the data.
If you want store data into local database, so that if user is offline he does not looses any data.
PS: Start small scale then go for large scale. Don't think of handling data into large scale like uber at first. So start with 5 users and updating data into application every specific time( this is not for fetching user location but to showing data of users)

Foursquare API: Consider close proximity as check-in

I've been looking into the Foursquare API on iOS (through das-quadrat). I'd like to figure out if a user is at a specific location. I know how to find it and I can actually get it. That works.
How can I now tell if the user is actually close enough to the location to consider his close proximity as a check-in (I'm not interested in actually checking him in the Foursquare way)? It's just that I want to know that a user is at a venue of a category I'm monitoring. I know that I can just calculate the distance between the user's location and the venue's location and consider every distance less than, say, 15 meters a check-in but I was wondering if there's is a more elegant solution, maybe even an API endpoint that I'm just missing.
I would guess that the real time API is best suited: https://developer.foursquare.com/overview/realtime
Allows you to register for notifications, thus Foursquare does the heavy lifting for you.

iOS NearBy devices

Hi I am creating two apps where each app needs to know the location of the other app. I am using corelocation for that. However I am not sure whats the best/efficient way of getting the nearby devices. I can create a database with co-ordinates using parsi api. However I think that would be a lot of work to calculate the shortest distance every few minutes. Any ideas? I have a map for each app and i want to display the shortest distance between the two users on the map.I am using google maps api for ios
The API to calculate distance is pretty lightweight. Internally you use the Haversine formula to calculate distance including the curvature of the Earth. From the iOS perspective though you simply do this:
CLLocation* previousPoint = [self.allLocations objectAtIndex:i-1];
CLLocation* currentPoint = [self.allLocations objectAtIndex:i];
CLLocationDistance distanceFromPrevPoint = [previousPoint distanceFromLocation:currentPoint];
You can easily iterate over the other devices in the zone. If you want to reduce the number of calculations, you could only calculate distances to devices in the same base latitude longitude (ignore minutes and seconds).
Since you're using Parse, you should be able to do a PFQuery for all place objects within a given range. See the documentation here: https://www.parse.com/docs/ios_guide#geo/iOS (Geo Queries)
If they're close enough (~30 meters) you can use iBeacons.
What would work the best depends on your particular app's needs.
Edit: Since you said your distance is too far, iBeacons won't work.
The brute-force way to do this is to run through all connected devices and calculate the (Pythagorean) distance to each one, and select the ones that are within your distance threshold. That's very time-consuming however.
Instead you might want to have each device report some sort of region code for each location (State? County? Zip code?) as the location changes. You'd use geocoding to generate the region information. You could have the reporting devices do the geocoding themselves, so they are only responsible for updating location information for a single device and you don't bog down doing geocoding. You'd report lat/long and region information to the server as it changes, with a "choke" to only report changes on significant changes, or once per minute, whichever is LESS frequent. (I remember reading in the docs that you are only supposed to submit a small number of geocoding calls or you get locked out and/or your app gets rejected.)
You'd collect the data in a central server.
Then you could start by requesting other users that match your current region (and possibly nearby regions) and then do distance calculations only on that small subset of your data that matches the region code.

Getting which contacts are close to my current location?

I'm experimenting with an app for my own use, and trying to find an energy efficient way to get the Contacts whose addresses are close to my current location.
There are about 100 people in my Contacts list each located in another town, maybe 5-60 km apart. Essentially after I've visited about 5-6 of them I'm running out of time and I just want the next two or three to be really close to my location.
What I'm doing now, requesting directions by selecting a Contact manually and seeing how much time it would take to get there, which is fine... But as the client list grows I have trouble remembering which ones are close and I keep selecting them and never get it right.
I tried storing them in an NSDictionary and grouping them by locality but it would be great to have a simple radar like report where the program would "see" which points are close just as one is able to figure out immediately by looking at a map whith 20 placemarks.
Any suggestions?
How does -distanceToLocation: (iOS Developer Library) sound to you?
From the comments I understand that you have the locations of all contacts. So you just need to loop through the contacts, get the distance to your current location and compare them...
You could possibly make an array or dictionary of CLLocation and CLLocationDistance objects and sort them by the distance.

Finding current region with lat long in offline mode

I am currently working on an app which requires the current region in which the user is in.The worst part is app is completely off line.
My logic :
1.Take a screen shot of the city draw squares on that.
Store square 4 points (lat long values taken with respect to map) in DB.
With the lat long values got from gps i can easily find out lat lont belongs to what reason.
I am just wondering if anybody can suggest me better idea to work my app offline.
Thank you in advance ..
You will probably find you have problems getting a location if you have no network access. iOS uses assisted-GPS, which allows the device to both lock onto GPS satellites much faster than it might otherwise take, and also pull in other data from the network to quickly determine location.
Without network access you may not get a location reported back at all, especially if the app was being used indoors (vanilla GPS reception is typically very bad without line of sight). If you do get a location it may take several minutes for an accurate enough reading to be provided.
you can use the RouteMe library which is based on OpenStreetMap. this allows to download map data in advance.
If you want to work with screenshots (from a legal source) then you use the Helmert transformation to transform between gps and picture-pixel coordinazes.
you need at least 3 points in the picture-map for which you now the lat,lon coordinates.

Resources