drandrewthomas_codesnippets/processingjs/pjsgpsgrafpde.txt
/**********************************/
/* Drawing GPS data by converting */
/* it to GML data in arrays.      */
/* Andrew Thomas, October 2010.   */
/**********************************/

/*************************************************/
/* This program is free software: you can        */
/* redistribute it and/or modify it under the    */
/* terms of the GNU General Public License       */
/* as published by the Free Software Foundation, */
/* either version 3 of the License, or (at your  */
/* option) any later version.                    */
/*                                               */
/* This program is distributed in the hope that  */
/* it will be useful, but WITHOUT ANY            */
/* WARRANTY; without even the implied            */
/* warranty of MERCHANTABILITY or FITNESS        */
/* FOR A PARTICULAR PURPOSE.  See the            */
/* GNU General Public License for more details.  */
/*                                               */
/* See http://www.gnu.org/licenses/ for full     */
/* details of licenses.                          */
/*************************************************/

/* @pjs preload="http://www.geocomputing.co.uk/images/edgres.gif"; */

float x[]={0.6798935,0.67772216,0.67150515,0.66350603,0.6542983,0.6451418,0.63689685,0.62907183,0.62088835,0.61056423,0.6013872,0.59123725,0.5816813,0.5713265,0.56101257,0.55092406,0.54154223,0.5325086,0.52451974,0.51528126,0.50633985,0.4964562,0.48628575,0.47930056,0.4704411,0.4619401,0.4497519,0.44021645,0.43423504,0.4296363,0.42186248,0.41233724,0.40084556,0.3882989,0.3772988,0.3651106,0.35457143,0.34502572,0.33515227,0.32419315,0.31515956,0.30592114,0.29666218,0.28785393,0.28271234,0.27571696,0.26801485,0.25733227,0.248821,0.23629484,0.22523329,0.21505257,0.20792402,0.19961762,0.19397418,0.1875216,0.18097687,0.17077567,0.15828022,0.14699335,0.13631077,0.12709281,0.11845866,0.10686453,0.09729834,0.088315964,0.078841954,0.07107839,0.06232133,0.055827796,0.050757922,0.05,0.053666696,0.057005644,0.060969364,0.06474873,0.07451975,0.08137177,0.08536621,0.091716364,0.097789966,0.10155909,0.10546135,0.11101261,0.11330685,0.11797729,0.12226875,0.12675482,0.13314594,0.13858452,0.14573357,0.15240122,0.15900742,0.16766205,0.17462674,0.18308675,0.19018458,0.19759992,0.20754507,0.21361867,0.22077794,0.22752753,0.23347823,0.23939821,0.24438614,0.25320467,0.25931925,0.26344684,0.26828113,0.27417037,0.28459692,0.2912031,0.29881305,0.30583918,0.3097107,0.3150264,0.31998363,0.32424438,0.3285768,0.3311783,0.3324586,0.33332917,0.3340154,0.33310384,999999.0,0.32851535,0.33185428,0.33143434,0.33118856,0.3280442,0.32412145,0.31966612,0.3150264,0.30941367,0.30155796,0.2929033,0.28322446,0.27411917,0.26955116,0.265526,0.26131645,0.25580618,0.24767388,0.23981814,0.23167561,0.22485432,0.21913919,0.21433562,0.21197993,0.21270712,0.2155442,0.22074722,0.22781432,0.23280224,0.24082187,0.2511562,0.26211536,0.27201954,0.28163692,0.291664,0.30109707,0.31193328,0.32142776,0.33174163,0.34085718,0.35115054,0.36125955,0.37065163,0.38074017,0.39229336,0.4040923,0.41028884,0.41865668,0.42880666,0.44012427,0.45034596,0.45932835,0.47021577,0.47809198,0.48567122,0.49156046,0.49886313,0.50601214,0.51198334,0.5158344,0.5230141,0.52716225,0.5277665,0.5277563,0.5287702,0.5300403,0.53213996,0.54562885,0.55466247,0.5634502,0.5730881,0.5829411,0.592118,0.59848875,0.6039068,0.6117318,0.61627936,0.62325424,0.6286314,0.6358624,0.64590997,0.6562443,0.6659948,0.6765955,0.688292,0.6992307,0.70580614,0.7129142,0.7250102,0.73392093,0.74137723,0.74948907,0.75712967,0.76605064,0.7722676,0.7791709,0.78784597,0.7966337,0.80333215,0.81179214,0.8203239,0.82583416,0.8316722,0.8363324,0.83773553,999999.0,0.8617432,0.8640477,0.8679397,0.8723234,0.87538576,0.87818193,0.8824631,0.88487005,999999.0,0.90129846,0.9045862,0.90699315,0.90962535,0.91243166,999999.0,0.92584896,0.9288192,0.93094957,999999.0,0.9447662,0.9473165,0.94950837,0.95,0.94076157,0.9309905,0.92602307,0.92159843,0.9166515,0.9109261,0.90412533,0.8979902,0.89193714,0.88266796,0.8718727,0.8631771,0.85576177,0.8464107,0.84016293,0.8321945,0.8250865,0.8206004,0.81308264,0.80432564,0.7957939,0.78763086,0.77972394,0.77385515,0.76680857,0.7584202,0.7500114,0.7416333,0.7356211,0.7311658,0.7264544,999999.0,0.7178612,0.7178407,0.71781003,0.70193464,0.6958303,0.6913442,0.68880415,0.68887585,0.68952113,0.69118035,0.6922558,0.69362825,0.69437593,0.69455,0.6930649,0.6907092,0.6856598,999999.0};
float y[]={0.16027875,0.1566202,0.15034842,0.143554,0.13885017,0.13623694,0.13414635,0.13310105,0.13519163,0.13571429,0.13885017,0.14198606,0.14564459,0.14982578,0.15452962,0.15923345,0.16445993,0.17073171,0.17700347,0.18170731,0.18536586,0.18536586,0.18432055,0.18536586,0.1848432,0.18432055,0.18275261,0.18170731,0.180662,0.17909408,0.17909408,0.180662,0.18170731,0.18327525,0.18850173,0.19216028,0.19372821,0.19477351,0.19372821,0.18954703,0.18536586,0.18013936,0.17439024,0.16916376,0.16393729,0.15923345,0.15609756,0.14930314,0.14250872,0.13101044,0.12212543,0.11271778,0.1054007,0.09756097,0.09076655,0.083972126,0.07770035,0.07195122,0.0630662,0.05783972,0.052090593,0.0510453,0.051567946,0.05,0.050522648,0.0510453,0.0510453,0.052090593,0.055226482,0.062020905,0.070905924,0.08240418,0.09442508,0.10383275,0.11010453,0.1174216,0.12578396,0.13205574,0.13989547,0.1477352,0.1566202,0.16341463,0.17020905,0.18327525,0.19163762,0.20209059,0.21202089,0.22142857,0.23449476,0.24233449,0.2512195,0.25905922,0.26689896,0.27369338,0.28310105,0.29303136,0.30139375,0.30923346,0.31811848,0.32334495,0.33118466,0.3379791,0.34581882,0.35313588,0.36149827,0.3750871,0.3813589,0.38972124,0.39703834,0.4043554,0.415331,0.42421603,0.4357143,0.44512194,0.45296168,0.4608014,0.46811846,0.47700348,0.4869338,0.49738675,0.5062717,0.51777,0.526655,0.5360627,999999.0,0.5522648,0.56010455,0.56010455,0.5606272,0.57264805,0.5783972,0.58310103,0.5893728,0.5945993,0.6019164,0.60714287,0.61393726,0.61811846,0.6212543,0.6222997,0.6238676,0.62543553,0.62961674,0.63588846,0.641115,0.6473867,0.65365857,0.66254354,0.67142856,0.6803136,0.68763065,0.6933798,0.6980836,0.70121956,0.7048781,0.706446,0.7069686,0.71062714,0.71062714,0.7101045,0.71062714,0.71219516,0.71219516,0.71376306,0.71376306,0.71480834,0.716899,0.716899,0.71898955,0.72160274,0.72839725,0.72996515,0.7320558,0.73466897,0.74094075,0.7482579,0.75662017,0.7649826,0.77125436,0.77752614,0.7869338,0.7952962,0.8036585,0.8109756,0.8167247,0.82456446,0.82560974,0.8240418,0.8240418,0.8229965,0.8235191,0.82508713,0.8324042,0.837108,0.84076655,0.84494776,0.8470383,0.8512195,0.85592335,0.8595819,0.8648084,0.86742157,0.8695122,0.8736934,0.87682927,0.87839717,0.8804878,0.88310105,0.88414633,0.88571423,0.88937277,0.89303136,0.89930314,0.9029617,0.90975606,0.91498256,0.92073166,0.92595816,0.9296167,0.9337979,0.9385017,0.9458188,0.95,0.94738674,0.9437282,0.9390244,0.93432057,0.9270035,0.92125434,0.9181185,999999.0,0.8428571,0.8329268,0.8209059,0.810453,0.8005226,0.7926829,0.7801393,0.7702091,999999.0,0.6949477,0.6850174,0.6761324,0.66672474,0.6567944,999999.0,0.6066202,0.59773517,0.58885014,999999.0,0.52874565,0.5203833,0.5114982,0.50418115,0.5026132,0.5005226,0.49425086,0.48850176,0.48327526,0.47700348,0.47125438,0.46393728,0.44564462,0.4425087,0.434669,0.42526132,0.4174216,0.40853658,0.4022648,0.39494774,0.3860627,0.378223,0.3729965,0.3682927,0.3651568,0.36045295,0.3541812,0.3463415,0.33954704,0.33327526,0.32752612,0.32125434,0.31393728,0.31027874,0.3076655,999999.0,0.30348432,0.30348432,0.30348432,0.2998258,0.29825783,0.29303136,0.28153312,0.27108014,0.26062718,0.2522648,0.23972124,0.23188153,0.21933797,0.20993032,0.20104529,0.19268292,0.17961672,999999.0};
float z[]={0.0,0.005075678,0.0,0.040608525,0.030456392,0.050761428,0.055837106,0.071065694,0.08629427,0.0964464,0.10659853,0.09136995,0.11167499,0.14213139,0.1675121,0.17258854,0.14720784,0.1522843,0.18274067,0.20812139,0.23857856,0.26903495,0.22842643,0.1928928,0.16243643,0.1522843,0.13197926,0.1522843,0.1675121,0.16243643,0.1675121,0.16243643,0.1522843,0.177665,0.17258854,0.16243643,0.13197926,0.13705571,0.14213139,0.16243643,0.1675121,0.16243643,0.1522843,0.13197926,0.11167499,0.10659853,0.11167499,0.10659853,0.0964464,0.050761428,0.06598924,0.055837106,0.025380714,0.06091356,0.06598924,0.06091356,0.071065694,0.08629427,0.050761428,0.055837106,0.07614215,0.1675121,0.23857856,0.34010142,0.3705578,0.42639568,0.45685285,0.5177664,0.59390855,0.62944144,0.59390855,0.5583757,0.6040607,0.6548221,0.6598986,0.64467,0.6091372,0.59898424,0.58375645,0.57868,0.54314715,0.54822284,0.59390855,0.63451785,0.6700507,0.6700507,0.63451785,0.63959354,0.63451785,0.64467,0.63959354,0.64467,0.6852793,0.7461929,0.71066,0.69035494,0.6852793,0.7005071,0.6700507,0.68020284,0.6954314,0.7055836,0.7055836,0.7005071,0.68020284,0.58883214,0.57868,0.59390855,0.624365,0.6497457,0.6649743,0.63959354,0.6192893,0.5634514,0.5228421,0.5279186,0.51268995,0.48730925,0.44669995,0.42131925,0.40609142,0.3705578,0.38071072,0.36548212,999999.0,0.18274067,0.51268995,0.5279186,0.5380707,0.48223358,0.48730925,0.49746138,0.5177664,0.5177664,0.47715712,0.47715712,0.47715712,0.46700498,0.47208068,0.47715712,0.48730925,0.5380707,0.59390855,0.63959354,0.6598986,0.6751264,0.6649743,0.73096424,0.7461929,0.77157354,0.77664924,0.80202997,0.822335,0.822335,0.8730964,0.9086293,0.9137057,0.89340067,0.90355283,0.93400997,0.93400997,0.96954286,0.98477143,0.99492353,1.0,0.9898479,0.95431423,0.92385787,0.9187814,0.9086293,0.84263927,0.8629443,0.8730964,0.86802,0.80710644,0.7411164,0.63451785,0.5228421,0.47208068,0.44669995,0.39593852,0.39593852,0.38071072,0.33502498,0.31979638,0.36040568,0.43654782,0.45177642,0.43147215,0.41624355,0.43654782,0.43654782,0.47715712,0.47208068,0.48223358,0.46700498,0.48730925,0.48223358,0.46192855,0.46700498,0.46700498,0.45177642,0.46700498,0.49746138,0.5228421,0.49746138,0.48730925,0.5177664,0.54314715,0.5736035,0.5583757,0.5279186,0.5380707,0.54822284,0.54314715,0.5228421,0.5380707,0.5228421,0.48730925,0.49238572,0.44669995,0.47208068,0.5076143,0.49746138,0.5076143,0.5279186,0.532995,0.5228421,0.5380707,0.5228421,999999.0,0.45177642,0.38071072,0.35533,0.36548212,0.3705578,0.36040568,0.35533,0.34517708,999999.0,0.34010142,0.32487285,0.32487285,0.3299493,0.31979638,999999.0,0.34010142,0.34517708,0.36548212,999999.0,0.42639568,0.44162428,0.44669995,0.45685285,0.47208068,0.5228421,0.48223358,0.49238572,0.5076143,0.5076143,0.50253785,0.50253785,0.49238572,0.49238572,0.45685285,0.47208068,0.47208068,0.46192855,0.49238572,0.50253785,0.50253785,0.51268995,0.5380707,0.55329925,0.6142128,0.6091372,0.64467,0.63451785,0.6548221,0.63451785,0.624365,0.57868,0.5583757,0.5380707,0.5279186,999999.0,0.5076143,0.50253785,0.50253785,0.49746138,0.47208068,0.44162428,0.43147215,0.41624355,0.40609142,0.40101498,0.38578638,0.40101498,0.34517708,0.32487285,0.34517708,0.35533,0.36548212,999999.0};
float t[]={0.0,0.024642682,0.049285363,0.07392804,0.09857073,0.12321341,0.14785609,0.17249876,0.19714145,0.22178413,0.24642682,0.2710695,0.29571217,0.32035485,0.34499753,0.36964023,0.3942829,0.41892558,0.44356826,0.46821094,0.49285364,0.51749635,0.542139,0.56678164,0.59142435,0.616067,0.6407097,0.6653524,0.68999505,0.71463776,0.73928046,0.76392305,0.7885658,0.81320846,0.83785117,0.8624938,0.8871365,0.91177917,0.9364219,0.9610646,0.9857073,1.0103499,1.0349927,1.0596353,1.084278,1.1089207,1.1335633,1.158206,1.1828487,1.2074914,1.232134,1.2567768,1.2814194,1.306062,1.3307048,1.3553475,1.3799901,1.4046328,1.4292755,1.4539182,1.4785609,1.5032035,1.5278461,1.5524889,1.5771316,1.6017742,1.6264169,1.6510596,1.6757023,1.700345,1.7249876,1.7496305,1.774273,1.7989157,1.8235583,1.8482012,1.8728437,1.8974864,1.9221292,1.9467717,1.9714146,1.9960572,2.0206997,2.0453424,2.0699854,2.0946279,2.1192706,2.1439133,2.168556,2.1931987,2.2178414,2.2424839,2.2671266,2.2917695,2.316412,2.3410547,2.3656974,2.39034,2.4149828,2.4396255,2.464268,2.488911,2.5135536,2.538196,2.5628388,2.5874815,2.612124,2.6367667,2.6614096,2.6860523,2.710695,2.7353377,2.7599802,2.784623,2.8092656,2.838837,2.858551,2.8831937,2.9078364,2.9324791,2.9571218,2.9817643,3.0113358,3.0310497,999999.0,4.5638247,4.588467,4.6131096,4.6377525,4.662395,4.687038,4.711681,4.7363234,4.760966,4.785609,4.810251,4.834894,4.8595366,4.8841796,4.908822,4.933465,4.9581075,4.98275,5.007393,5.032036,5.056678,5.081321,5.105963,5.130606,5.1552486,5.1798916,5.2045345,5.229177,5.25382,5.2784624,5.3031054,5.3277473,5.3523903,5.3770328,5.4016757,5.4263186,5.450961,5.475604,5.500246,5.524889,5.5495315,5.5741744,5.598817,5.62346,5.6481028,5.677674,5.697388,5.7220306,5.7466736,5.7713156,5.7959585,5.820601,5.845244,5.874815,5.899458,5.9241004,5.9487433,5.9733863,5.9980288,6.0226717,6.0473137,6.0719566,6.096599,6.121242,6.1458845,6.1705275,6.1951704,6.2198124,6.2444553,6.269098,6.2937407,6.318383,6.343026,6.3676686,6.3923116,6.4169545,6.441597,6.46624,6.490882,6.515525,6.5401673,6.5648103,6.589453,6.6140957,6.6387386,6.6633806,6.6880236,6.712666,6.737309,6.7619514,6.7865944,6.8112373,6.83588,6.8605227,6.885165,6.909808,6.93445,6.959093,6.9837356,7.0083785,7.0330215,7.057664,7.082307,7.106949,7.131592,999999.0,7.3533764,7.3780184,7.4026613,7.4273043,7.4519467,7.4765897,7.501232,7.525875,999999.0,7.703302,7.7230163,7.7525873,7.7772303,7.801873,999999.0,7.925086,7.949729,7.9743714,999999.0,8.122228,8.14687,8.171513,8.196156,8.2207985,8.245441,8.270083,8.294726,8.319369,8.344012,8.368654,8.393297,8.41794,8.442582,8.467225,8.491868,8.516511,8.541153,8.565796,8.590439,8.615082,8.639725,8.664367,8.68901,8.713652,8.738295,8.762938,8.7875805,8.8122225,8.836865,8.861508,8.88615,8.910793,8.935436,8.960079,999999.0,9.576146,9.600788,9.63036,9.655003,9.679646,9.69936,9.72893,9.748645,9.778215,9.79793,9.822573,9.847216,9.876786,9.901429,9.926072,9.9457855,9.975357,999999.0};

int[] swidth=new int[t.length];
int[] salpha=new int[t.length];

int numpoints=x.length;
int stime,r,g,b,br,bg,bb,c=1;
float tmin=999999;
float tmax=-999999;
float sca=0.9;
int xoff=20;
int yoff=-25;
PImage back;

void setup()
{
  back = loadImage("http://www.geocomputing.co.uk/images/edgres.gif");
  back.resize(width, height);
  stime=millis();
  for(int c=1;c<numpoints;c++)
  {
    if(x[c-1]!=999999 && x[c]!=999999)
    {
      if((t[c]-t[c-1])<tmin) tmin=t[c]-t[c-1];
      if((t[c]-t[c-1])>tmax) tmax=t[c]-t[c-1];
    }
  }
  for(int c=0;c<numpoints;c++)
  {
    if(x[c]!=999999)
    {
      x[c]=xoff+int(x[c]*float(width)*sca);
      y[c]=yoff+height-int(y[c]*float(height)*sca);
    }
    if(x[c]!=999999 && c>0)
    {
      swidth[c]=int(map(t[c]-t[c-1],tmin,tmax,20,5));
      salpha[c]=int(map(t[c]-t[c-1],tmin,tmax,255,50));
      if(swidth[c]>10) swidth[c]=10;
    }
  }
  image(back,0,0);
}

void draw()
{
  if(x[c]==999999 && c<(numpoints-1)) c++;
  else
  {
    if(((t[c]*1000)<(millis()-stime)) && c<numpoints)
    {
      if(x[c-1]!=999999 && x[c]!=999999)
      {
        strokeWeight(swidth[c]);
        stroke(255,0,0,salpha[c]);
        line(x[c-1],y[c-1],x[c],y[c]);
      }
      c++;
    }
  }
}

void mouseReleased()
{
  c=1;
  stime=millis();
  image(back,0,0);
}

