Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 73: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 74: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 75: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 76: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 77: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /bbc_download.php on line 78: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
package net.mobilefight.trackbuilder; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.IOException; import java.util.List; import java.util.StringTokenizer; import java.util.Vector; import com.google.android.maps.Point; import android.location.Location; public class TrackFactory { private static long time = 0; public static double euclDistance(Point p1, Point p2) { return Math.sqrt(((double)p1.getLatitudeE6()-p2.getLatitudeE6())*((double)p1.getLatitudeE6()-p2.getLatitudeE6()) + ((double)p1.getLongitudeE6()-p2.getLongitudeE6())*((double)p1.getLongitudeE6()-p2.getLongitudeE6())); } private static double genStepSmallPoints(double fstep, Point start, Point end, final double step, List computed) { double dist = euclDistance(start, end); if (fstep > dist) { return fstep - dist; } double t = fstep / dist; computed.add(new Point((int) (start.getLatitudeE6() * (1 - t) + end.getLatitudeE6() * t), (int) (start.getLongitudeE6() * (1 - t) + end.getLongitudeE6() * t))); int points_no = (int)((dist-fstep)/step); for (int i = 0; i < points_no; ++i) { t += step / dist; computed.add(new Point((int) (start.getLatitudeE6() * (1 - t) + end.getLatitudeE6() * t), (int) (start.getLongitudeE6() * (1 - t) + end.getLongitudeE6() * t))); } return step - (dist - fstep - (points_no*step)); } public static List genAllSteps(List big_points, double step) { List ret = new Vector(); double fstep = 0.0; for (int i = 0; i < big_points.size() - 1; ++i) { Location loc = big_points.get(i); Point pointI = new Point((int) loc.getLatitude(), (int) loc.getLongitude()); loc = big_points.get(i+1); Point pointIp1 = new Point((int) loc.getLatitude(), (int) loc.getLongitude()); fstep = genStepSmallPoints(fstep, pointI, pointIp1, step, ret); } return ret; } private static String prepareTrackSequence(Point point) { StringBuilder toReturn = new StringBuilder(); toReturn.append(time); toReturn.append(" "); toReturn.append((double)point.getLongitudeE6() / 1E6); toReturn.append(" "); toReturn.append((double)point.getLatitudeE6() / 1E6); toReturn.append(" 0"); time += 1000; return toReturn.toString(); } public final static boolean saveFile(List path, TrackBuilder context, String filename, int step) { try { BufferedOutputStream output = new BufferedOutputStream(context.openFileOutput(filename + "_track", 0)); List points = genAllSteps(path, step); for (Point point : points) { output.write((prepareTrackSequence(point) + "\n").getBytes()); } output.close(); } catch (IOException e) { return false; } return true; } public final static boolean savePath(List path, TrackBuilder context, String filename) { try { BufferedOutputStream output = new BufferedOutputStream(context.openFileOutput(filename + "_path", 0)); for (Location loc : path) { output.write((loc.getLongitude() + " " + loc.getLatitude() + "\n").getBytes()); } output.close(); } catch (IOException e) { return false; } return true; } public final static boolean loadPath(List path, TrackBuilder context, String filename) { try { BufferedInputStream input = new BufferedInputStream(context.openFileInput(filename)); StringBuilder data = new StringBuilder(); byte[] buffer = new byte[4096]; while (input.read(buffer) != -1) { data.append(new String(buffer)); } StringTokenizer tokenizer = new StringTokenizer(data.toString(), " \n"); try { while (tokenizer.hasMoreTokens()) { Location location = new Location(); location.setLongitude(Double.valueOf(tokenizer.nextToken())); location.setLatitude(Double.valueOf(tokenizer.nextToken())); path.add(location); } } catch (Exception e) { // do nothing } input.close(); } catch (IOException e) { return false; } return true; } }