Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int getDistance(string id, string von, string zu)
- {
- QueryReader qr = new QueryReader(db, "select t.x, t.y from stdortboote b, table (sdo_util.getvertices(b.shape)) t " +
- "where b.idboot = " + id + " and b.datum between to_date('" + von + "', 'DD.MM.YYYY HH24:MI') and to_date('" + zu + "', 'DD.MM.YYYY HH24:MI')");
- double dist = 0;
- if (qr.Open())
- {
- int i = 0;
- double lx = 0, ly = 0;
- //performance
- while (qr.Read())
- {
- int _x = qr.OracleReader.GetInt32(0);
- int _y = qr.OracleReader.GetInt32(1);
- double tx = _x;
- double ty = _y;
- //
- // this makes sense if you think about it
- // calc distance between to points
- //
- // (x1,y1)
- // /
- // /
- // (x0, y0)
- //
- // so dist = sqrt((x1-x0)^2 + (y1-y1)^2)
- //
- if (i % 2 == 0)
- {
- if (i > 0)
- {
- double delta = Math.Sqrt(Math.Pow(tx - lx, 2) + Math.Pow(ty - ly, 2));
- dist += delta;
- }
- lx = tx;
- ly = ty;
- }
- else
- {
- double delta = Math.Sqrt(Math.Pow(tx - lx, 2) + Math.Pow(ty - ly, 2));
- dist += delta;
- lx = tx;
- ly = ty;
- //MessageBox.Show(delta + " --> " + dist);
- }
- i++;
- }
- qr.Close();
- }
- return (int)(dist*100);
- }
Add Comment
Please, Sign In to add comment