Search code examples
processingtwitter4j

twitter4j how to get only statuses with location data from a twitter stream


I'm getting high numbers of "onTrackLimitationNotice". I'd like to narrow my predicate by only searching for statuses with geo location, but all geo locations? Can this be done? Im coding in Processing, using twitter4j-2.2.6.

EDIT: it was an answer... moved.


Solution

  • i found that querying the stream for a global bounding box, returns only status withs geo location. So this worked:

    // cb is an instace of ConfigurationBuilder
    TwitterStream twitter = new TwitterStreamFactory(cb.build()).getInstance();
    FilterQuery filtro = new FilterQuery();    
    double[][] bb= {{-180, -90}, {180, 90}};
    filtro.locations(bb);
    twitter.addListener(listener);
    twitter.filter(filtro);
    

    returning only tweets with location info.