Thursday, 16 December 2010

My XML Application



News Sieve
NewsSieve is my xml product. It pulls in news feeds using Yahoo and displays them at a certain time that the user specifies. For example if they want football scores they select the day and times they want it and then it will appear on their home page once they sign into the website.

Problems it solves
What NewsSieve does save the user time. Instead of them having to click numerous links and search through lots of articles to find what they want. All they have to do is use NewsSieve to filter out all of the unwanted stuff and display links to what they want. Not only does it do this it also allows the user to select what time they want these links to appear so they do not have too many links at one time thus helping the problem of information overload.

How does it work?
It works by using a yahoo key which is needed to access the API. Once you access the API it does a search using the term the user has entered. The search is then displayed in an XML file and then NewsSieve pulls in tags from this XML document and then displays the top 10 in a handy list for the user on their home page. It does all of this and it uses the times the user enters to display them at the exact time the user asks.

And here is the final link NewsSieve

Wednesday, 28 April 2010

Website Rebrand

Well my website has been fully rebranded and finished. It was a long hard task and i'm still not that happy with it but it will do for now until I work on it over the summer.

Take a look: http://www.tomsaundersmpt.co.uk/

Monday, 26 April 2010

The Data

And here is the data we collected and used in our sketch.

Click Here

Sunday, 25 April 2010

The Processing Sketch

Thanks to Jon our sketch is now online to be viewed. It can be seen here. You may have to wait a while for the first balls to appear. The rate the balls appear is determined by when the bluetooth device was first detected.

So thats it we have transformed Stonehouse by importing activity from other areas and puting it into Stonehouse.

The Visual Element is Complete - Part 2

Continuing on from the last post here is some more code from our Processing Sketch and what it all does.

for (int r= 0; r < count; r++){
if((Fdetect[r] < metricTime)&&(metricTime < Fdetect[r]+3000)){
active[r] = "true";
}else{
active[r] = "false";
}

This checks to see if a particular device had been detected yet.

for(int z = 0; z < count;z++){
if(active[z] == "true"){
//BALL - WALL COLLISIONS
if((posX[z] < rad)||(posX[z] > width -rad)){
speedX[z] = -speedX[z] *loss;
}
if((posY[z] < rad)||(posY[z] > height)){
speedY[z] = -speedY[z] *loss;
}
if(posZ[z] < -10000 +rad){
speedZ[z] = -speedZ[z] *loss;
}
//balls that go beyond the camera are deactivated
if(posZ[z] > 1000){
active[z] = "false";
}

//BALL - BALL COLLISIONS
for(int others = 0; others < count;others++){
if(others != z){
if(ballSize > dist(posX[z],posY[z],posZ[z],posX[others],posY[others],posZ[others])){
TspeedX = speedY[z] *loss;
TspeedY = speedX[z] *loss;
TspeedZ = speedZ[z] *loss;
speedY[z] = speedY[others];
speedX[z] = speedX[others];
speedZ[z] = speedZ[others];
speedY[others] = TspeedY *loss;
speedX[others] = TspeedX *loss;
speedZ[others] = TspeedZ *loss;
}
}
}

//BALL - FLOOR COLLISIONS

speedY[z] = speedY[z] - gravity; //gravity

speedZ[z] = speedZ[z] - 0.2;

posX[z] = posX[z] - speedX[z] *drag;
posY[z] = posY[z] - speedY[z] *drag;
posZ[z] = posZ[z] - speedZ[z] *drag;


pushMatrix();
noStroke();
translate(posX[z],posY[z],posZ[z]);
fill(50,50,200);
sphere(ballSize);
sphereDetail(10);
popMatrix();
}
}


And all of this code controls the bouncing balls. It detects if they bounce of the sides, the ground or eachother and then acts accordingly.

PImage a = loadImage("stonehouse.jpg");
beginShape();
texture(a);
translate(500+width/2.0,650+height/2.0, -100);
fill(255);
scale(300);
vertex(-20, -20, -30, 0, 0);
vertex( 20, -20, -30, 1, 0);
vertex( 20, 20, -30, 1, 1);
vertex(-20, 20, -30, 0, 1);
endShape();
}


And finally this code is just to display the image of the street behind it all. Thats all folks the sketch has been complete.

The Visual Element is Complete - Part 1

Its taken a while but we have finally completed the Processing Sketch that visualises the data we have collected. I won't post up every bit of code that features in our sketch but here are a few of the important bits:

import processing.xml.*;

//DATA GATHERING
XMLElement xml;
XMLElement xmlGrandChild;
float FdetectLow = 9999999;
float LdetectHigh = 0;
int timer;
int LastTime;
int playtime = 600;
float metricTime;

String[] active = new String[1];
String[] address = new String[1];
float[] Fdetect = new float[1];
float[] Ldetect = new float[1];
String[] name = new String[1];
int[] times = new int[1];


This bit essentially parses our XML file and puts it into variables to use later on.

//First Detected
xmlGrandChild = xmlChild.getChild(5);
float temp[] = float(splitTokens(xmlGrandChild.getContent(), " :"));
Fdetect[i] = round(((temp[3]/86400)+(temp[2]/1440)+(temp[1]/24))*pow(10,6));
if(Fdetect[i] < FdetectLow){
FdetectLow = Fdetect[i];
}

//Last Detected
xmlGrandChild = xmlChild.getChild(6);
float temp2[] = float(splitTokens(xmlGrandChild.getContent(), " :"));
Ldetect[i] = round(((temp2[3]/86400)+(temp2[2]/1440)+(temp2[1]/24))*pow(10,6));
if(Ldetect[i] > LdetectHigh){
LdetectHigh = Ldetect[i];
}

}
float duration = LdetectHigh - FdetectLow; //duration in metric time


All of this works out when a device was first detected and when it was last detected so we can then work out how long a device has been active.

//initial positions and speeds
for(int x = 0; x < count;x++){
posX[x] = random((width/2)-250,(width/2)+250);
posY[x] = random(20,200);
posZ[x] = random(-10000,-9800);
speedX[x] = random(-10,10);
speedY[x] = random(-10,10);
speedZ[x] = random(10);
}
}


This code works out where each ball starts off in our sketch and how fast it is going. This was done manually using random numbers rather than using the data we collected otherwise they would all be doing something similar!

Thats all for now I will explain more later.

The Street

Here is a photo of the street that we may use in our Processing Sketch.