use of org.oscim.core.GeoPoint in project PocketMaps by junjunguo.
the class NaviEngine method getNewInstruction.
private NaviInstruction getNewInstruction() {
nearestP.arrPos = 0;
nearestP.distance = Double.MAX_VALUE;
uiJob = UiJob.UpdateInstruction;
if (instructions.size() > 0) {
Instruction in = instructions.get(0);
long fullTime = countFullTime(in.getTime());
GeoPoint curPos = new GeoPoint(in.getPoints().getLat(0), in.getPoints().getLon(0));
double partDistance = countPartDistance(curPos, in, 0);
if (partDistance == 0) {
partDistanceScaler = 1;
} else {
partDistanceScaler = in.getDistance() / partDistance;
}
Instruction nextIn = null;
if (instructions.size() > 1) {
nextIn = instructions.get(1);
}
NaviInstruction nIn = new NaviInstruction(in, nextIn, fullTime);
if (speakDistanceCheck(in.getDistance()) && nearestP.isDirectionOk()) {
naviVoice.speak(nIn.getVoiceText());
naviVoiceSpoken = true;
} else {
naviVoiceSpoken = false;
}
return nIn;
}
uiJob = UiJob.Finished;
return null;
}
use of org.oscim.core.GeoPoint in project PocketMaps by junjunguo.
the class NaviEngine method findClosestStreet.
private GeoPoint findClosestStreet(GeoPoint fromPos) {
QueryResult pos = MapHandler.getMapHandler().getHopper().getLocationIndex().findClosest(fromPos.getLatitude(), fromPos.getLongitude(), EdgeFilter.ALL_EDGES);
int n = pos.getClosestEdge().getBaseNode();
NodeAccess nodeAccess = MapHandler.getMapHandler().getHopper().getGraphHopperStorage().getNodeAccess();
GeoPoint gp = new GeoPoint(nodeAccess.getLat(n), nodeAccess.getLon(n));
return gp;
}
use of org.oscim.core.GeoPoint in project graphhopper by graphhopper.
the class MainActivity method loadMap.
void loadMap(File areaFolder) {
logUser("loading map");
// Map events receiver
mapView.map().layers().add(new MapEventsReceiver(mapView.map()));
// Map file source
MapFileTileSource tileSource = new MapFileTileSource();
tileSource.setMapFile(new File(areaFolder, currentArea + ".map").getAbsolutePath());
VectorTileLayer l = mapView.map().setBaseMap(tileSource);
mapView.map().setTheme(VtmThemes.DEFAULT);
mapView.map().layers().add(new BuildingLayer(mapView.map(), l));
mapView.map().layers().add(new LabelLayer(mapView.map(), l));
// Markers layer
itemizedLayer = new ItemizedLayer<>(mapView.map(), (MarkerSymbol) null);
mapView.map().layers().add(itemizedLayer);
// Map position
GeoPoint mapCenter = tileSource.getMapInfo().boundingBox.getCenterPoint();
mapView.map().setMapPosition(mapCenter.getLatitude(), mapCenter.getLongitude(), 1 << 15);
setContentView(mapView);
loadGraphStorage();
}
use of org.oscim.core.GeoPoint in project graphhopper by graphhopper.
the class MainActivity method createPathLayer.
private PathLayer createPathLayer(PathWrapper response) {
Style style = Style.builder().fixed(true).generalization(Style.GENERALIZATION_SMALL).strokeColor(0x9900cc33).strokeWidth(4 * getResources().getDisplayMetrics().density).build();
PathLayer pathLayer = new PathLayer(mapView.map(), style);
List<GeoPoint> geoPoints = new ArrayList<>();
PointList pointList = response.getPoints();
for (int i = 0; i < pointList.getSize(); i++) geoPoints.add(new GeoPoint(pointList.getLatitude(i), pointList.getLongitude(i)));
pathLayer.setPoints(geoPoints);
return pathLayer;
}
use of org.oscim.core.GeoPoint in project PocketMaps by junjunguo.
the class GeocodeActivity method createAddAddrClickListener.
private OnClickListener createAddAddrClickListener(Spinner sp, final EditText addr1, final EditText addr2, final EditText addr3, final EditText addr4) {
final GeoPoint loc;
if (sp.getSelectedItem().toString().equals(SEL_FROM)) {
loc = locations[0];
} else if (sp.getSelectedItem().toString().equals(SEL_TO)) {
loc = locations[1];
} else {
loc = locations[2];
}
OnClickListener l = new OnClickListener() {
@Override
public void onClick(View v) {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
Address addr = new Address(Locale.getDefault());
addr.setAddressLine(0, addr1.getText().toString());
addr.setAddressLine(1, addr2.getText().toString());
addr.setAddressLine(2, addr3.getText().toString());
addr.setAddressLine(3, addr4.getText().toString());
addr.setLatitude(loc.getLatitude());
addr.setLongitude(loc.getLongitude());
AddressLoc.addToProp(favourites, addr);
String mapDir = Variable.getVariable().getMapsFolder().getParent();
String propFile = new File(mapDir, FAV_PROP_FILE).getPath();
try (FileOutputStream fos = new FileOutputStream(propFile)) {
favourites.store(fos, "List of favourites");
} catch (IOException e) {
logUser("Unable to store favourites");
}
return null;
}
}.execute();
GeocodeActivity.this.finish();
}
};
return l;
}
Aggregations