We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi all,
I've got a map view which displays a number of ellipses representing natural disasters. I would like to be able to make them appear in the chronological order based on the year the natural disaster happened.
Could you guide me what would be the best approach to make it happen?
I've attached a screenshot of the current view.
This might be a very basic thing to do, however, I'm very new to processing and would appreciate your support.
Thank you Sim
Answers
what does the data look like?
Basically show your code.
Remark
When you work with
background(0);
indraw ()
or when you draw the map anew every loop ofdraw()
: good.add a variable
currentYearForDisplay
or so to your code - set it to the first year you have data of (or 10 years before the first disaster)Now increase the year every frame or every 10th frame or every 2 seconds
currentYearForDisplay++;
or sonow compare
currentYearForDisplay
to all disasters (assuming they have a date) and display only those disasters that matchcurrentYearForDisplay
Chrisir ;-)
Thanks guys. I think I managed to make it work, not sure if this is the most optimal way though.
(just ctrl-t in the processing editor to indent the code nicely, cut it and paste it here, highlight it and press ctrl-o. don't 'copy as html'. i have fixed the above)
but without these files, or a sample of their contents, that code is useless...
first remark: you use < year
I see a
why not
say abs(tsunami.....-year) < 8
or so to make the disasters disappear after the year has passed?(remark: you increase year by 5 --- why not by 1? Then you could say
if (int(tsunamiData[i][0]) == year) {
- then the disasters would disappear instantly)Second remark
you use a 2D array for the data. But since all data are similar why not make only one 2D array "disasterArray" with one more column
typeOfDisaster
? The column typeOfDisaster could hold an int where 0 signifies volcano, 1 earthquake and so on.Third remark: OOP
When you look into objects (see tutorials) you could beautify your code by using a class btw...