Hi, I’m very beginner. I really need your help.
(Eventhough I used a library, the question is not about the library itself. The main question is a code regarding how to read files (column by column)and display it in sequence.)
My project is…‘animation of hourly activities on map’.
-
To display amount of hourly activities on map. (On the same day, and the amount of activities will be described as circle size)
-
When I finish displaying activities(points) for time 0(T1), then now need to display points for time1(T1)…and so on(for time 2(T2), time 3(T3), time 4…) It should be an ‘animation’
-
the result needs to be “animation” which shows the changes of activities on the same points on the map over time(hourly)
The structure of CSV(which includes the information of location, amount of activities, time and date) file is as follow
I’ve tried to display for the first day of first time(T0) by using this code below.
// we should load all things in setup, and call each one and draw in draw() in order.
import com.reades.mapthing.*;
import net.divbyzero.gpx.*;
import net.divbyzero.gpx.parser.*;
import de.fhpotsdam.unfolding.*;
import de.fhpotsdam.unfolding.geo.*;
import de.fhpotsdam.unfolding.utils.*;
import de.fhpotsdam.unfolding.providers.*;
UnfoldingMap map;
ArrayList<Position> Bcontainer = new ArrayList(); //declare and create array "Big container"
int maxSize = 0;
int upTo = 0;
int time;
void setup()
{
size(800, 600, P2D);
smooth();
// Create interactive map centered around Jeju
map = new UnfoldingMap(this, new OpenStreetMap.OpenStreetMapProvider());
map.zoomAndPanTo(10, new Location(33.35, 126.52));
MapUtils.createDefaultEventDispatcher(this, map);
map.setTweening(true);
// Load CSV data
Table DataCSV = loadTable("oneday.csv", "header");
for (int i=0; i<24 ;i++)
{
for (TableRow Row : DataCSV.rows())
{
// Create new empty object to store data
Position Scontainer = new Position();
// Read data from CSV
Scontainer.k = Row.getInt("T"+i);
float lat = Row.getFloat("Y_COORD");
float lng = Row.getFloat("X_COORD");
Scontainer.location = new Location(lat, lng);
// Add to list of all location
Bcontainer.add(Scontainer);
maxSize = max(maxSize, Scontainer.k);
}
}
newTime();
}
// OK we put all (FROM 1~31 DAY) POINTS INTO BCONTAINER
void draw()
{
// Draw map and darken it a bit
map.draw();
fill(0, 150);
rect(0, 0, width, height);
noStroke();
for( int i = 0; i < upTo; i++)
{
for (Position Scontainer : Bcontainer)
{
// Convert geo locations to screen positions
ScreenPosition pos = map.getScreenPosition(Scontainer.location);
float s = map(Scontainer.k, 0, maxSize, 1, 50);
//the brightness of the circle
fill(200, 30, 200, 50);
ellipse(pos.x, pos.y, s, s);
}
}
if( millis() > time )
{
newTime();
if( ???? )
{
upTo++;
}
}
}
void newTime()
{
time = millis() + 100;
}
public class Position {
Location location;
int k ;
}
My questions are
I used processing 2.X since only in that case
- in setup() I red all columns and added them in Bcontainer(arrylist)
- I want to read and draw column by column from Bcontainer. But I do not know how to do this.
Do I have to use ‘2-D array?’ - what is the code that enables me to read and display data one column by one column?(Column : each T, so that I can display them on the screen in sequence
plz help me ㅜㅜ