package btools.routingapp; import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import android.os.Environment; import btools.router.OsmNodeNamed; /** * Read coordinates from a gpx-file */ public abstract class CoordinateReader { public List waypoints; public List nogopoints; public String basedir; public String rootdir; public String tracksdir; public Map allpoints; private HashMap pointmap; protected static String[] posnames = new String[]{ "from", "via1", "via2", "via3", "via4", "via5", "via6", "via7", "via8", "via9", "to" }; public CoordinateReader( String basedir ) { this.basedir = basedir; } public abstract long getTimeStamp() throws Exception; /* * read the from, to and via-positions from a gpx-file */ public void readFromTo() throws Exception { pointmap = new HashMap(); waypoints = new ArrayList(); nogopoints = new ArrayList(); readPointmap(); boolean fromToMissing = false; for( int i=0; i rl = new ArrayList(); rl.add( new CoordinateReaderOsmAnd(basedir) ); rl.add( new CoordinateReaderLocus(basedir) ); rl.add( new CoordinateReaderOrux(basedir) ); // eventually add standard-sd File standardbase = Environment.getExternalStorageDirectory(); if ( standardbase != null ) { String base2 = standardbase.getAbsolutePath(); if ( !base2.equals( basedir ) ) { rl.add( new CoordinateReaderOsmAnd(base2) ); rl.add( new CoordinateReaderLocus(base2) ); rl.add( new CoordinateReaderOrux(base2) ); } } long tmax = 0; for( CoordinateReader r : rl ) { long t = r.getTimeStamp(); if ( t > tmax ) { tmax = t; cor = r; } } if ( cor == null ) { cor = new CoordinateReaderNone(); } cor.readFromTo(); return cor; } }