text overlapping and quiry speed
in
Programming Questions
•
2 years ago
having trouble with 2 differnet things:
first in my script i have twitter streaming longitude and latitude locations it then makes a dot on the screen at the same long and lat.
i made a "for loop" so that is saves each dot, but unfortunatly it keeps overlapping the txt that i am printing.
also this isnt realy a processing question more of a general ask it and hope for the best the quiry i am doing is producing results very slowly is it to do with my code or just the quiry i am doing.
any help or sugestions would be very welcome (i am very new to processing)
THE SCRIPT
import com.twitter.processing.*;
//
//
// Library by twitter4j
//
//
//
//
//
// Library by twitter4j
//
//
//
// test tweet counting (not sure if it will work)
int tweetCount;
// this stores how many tweets we've gotten
int tweets = 0;
// and this stores the text of the last tweet
String tweetText = "";
Geo tweetGeo;
int tweetCount;
// this stores how many tweets we've gotten
int tweets = 0;
// and this stores the text of the last tweet
String tweetText = "";
Geo tweetGeo;
double lati, longi;
float latiFl, longiFl,latiMap, longiMap;
float latiFl, longiFl,latiMap, longiMap;
int textsize;
void setup() {
size(1000,600);
background(0);
size(1000,600);
background(0);
// set up twitter stream object
TweetStream s = new TweetStream(this, "stream.twitter.com", 80,
"1/statuses/filter.json?locations=-122.75,36.8,-121.75,37.8",
"USSER", "PASSWORD");
s.go();
smooth();
}
TweetStream s = new TweetStream(this, "stream.twitter.com", 80,
"1/statuses/filter.json?locations=-122.75,36.8,-121.75,37.8",
"USSER", "PASSWORD");
s.go();
smooth();
}
void draw() {
textsize = 12;
// set up fonts
PFont font;
font = createFont("ArialMT-48.vlw", textsize);
textFont(font);
textSize(textsize);
fill(255);
//converts double to float
latiFl = (float)lati;
longiFl = (float)longi;
//map value to screen
latiMap = map(latiFl, -90, 90, 0, width);
longiMap = map(longiFl, -180, 180, 0, height);
// and draw the text of the last tweet
text(tweetText, 20, 520);
// adn its lat and long
text("lat = " + lati + " long = " + longi,20,560);
text("number of tweets:" +tweetCount, 880, 580);
for( int i = 0; i < 7000; i++){
fill(255);
ellipse(latiMap, longiMap, 5,5);
/* fill(0);
rect(0,500,1000,100);
*/
}
textsize = 12;
// set up fonts
PFont font;
font = createFont("ArialMT-48.vlw", textsize);
textFont(font);
textSize(textsize);
fill(255);
//converts double to float
latiFl = (float)lati;
longiFl = (float)longi;
//map value to screen
latiMap = map(latiFl, -90, 90, 0, width);
longiMap = map(longiFl, -180, 180, 0, height);
// and draw the text of the last tweet
text(tweetText, 20, 520);
// adn its lat and long
text("lat = " + lati + " long = " + longi,20,560);
text("number of tweets:" +tweetCount, 880, 580);
for( int i = 0; i < 7000; i++){
fill(255);
ellipse(latiMap, longiMap, 5,5);
/* fill(0);
rect(0,500,1000,100);
*/
}
}
// called by twitter stream whenever a new tweet comes in
void tweet(Status tweet) {
// print a message to the console just for giggles if you like
// println("got tweet " + tweet.id());
void tweet(Status tweet) {
// print a message to the console just for giggles if you like
// println("got tweet " + tweet.id());
// store the latest tweet text
tweetText = tweet.text();
tweetGeo = tweet.geo();
lati = tweetGeo.latitude();
longi = tweetGeo.longitude();
println("lat = " + lati + " long = " + longi);
// bump our tweet count by one
tweets += 1;
println("number of tweets:" +tweetCount);
tweetCount++;
}
tweetText = tweet.text();
tweetGeo = tweet.geo();
lati = tweetGeo.latitude();
longi = tweetGeo.longitude();
println("lat = " + lati + " long = " + longi);
// bump our tweet count by one
tweets += 1;
println("number of tweets:" +tweetCount);
tweetCount++;
}
1