@Override public boolean onTouchEvent(PointF point) { if (routeLayer != null && routeLayer.getHelper().isRouterEnabled()) { if (boundsForMiniRoute.contains(point.x, point.y) && routeLayer.getHelper().isFollowingMode()) { showMiniMap = !showMiniMap; view.refreshMap(); return true; } if (boundsForLeftTime.contains(point.x, point.y) && routeLayer.getHelper().isFollowingMode()) { showArrivalTime = !showArrivalTime; view.getSettings().SHOW_ARRIVAL_TIME_OTHERWISE_EXPECTED_TIME.set(showArrivalTime); view.refreshMap(); return true; } } if (cachedDistString != null && boundsForDist.contains(point.x, point.y)) { AnimateDraggingMapThread thread = view.getAnimatedDraggingThread(); LatLon pointToNavigate = view.getSettings().getPointToNavigate(); if (pointToNavigate != null) { int fZoom = view.getZoom() < 15 ? 15 : view.getZoom(); thread.startMoving( pointToNavigate.getLatitude(), pointToNavigate.getLongitude(), fZoom, true); } } return false; }
@Override public synchronized boolean checkCachedObjects( double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, int zoom, List<TransportStop> toFill, boolean fillFound) { boolean inside = cTopLatitude >= topLatitude && cLeftLongitude <= leftLongitude && cRightLongitude >= rightLongitude && cBottomLatitude <= bottomLatitude && cZoom == zoom; boolean noNeedToSearch = inside; if ((inside || fillFound) && toFill != null) { for (TransportStop a : cachedObjects) { LatLon location = a.getLocation(); if (location.getLatitude() <= topLatitude && location.getLongitude() >= leftLongitude && location.getLongitude() <= rightLongitude && location.getLatitude() >= bottomLatitude) { toFill.add(a); } } } return noNeedToSearch; }
public void searchTransport() { // use progress stopsAdapter.clear(); searchArea.setText(getSearchArea()); boolean routeCalculated = isRouteCalculated(); searchTransportLevel.setEnabled(false); if (!routeCalculated && getLocationToStart() != null) { final LatLon locationToStart = getLocationToStart(); final LatLon locationToGo = getLocationToGo(); List<TransportIndexRepository> rs = ((OsmandApplication) getApplication()) .getResourceManager() .searchTransportRepositories( locationToStart.getLatitude(), locationToStart.getLongitude()); if (!rs.isEmpty()) { repo = rs.get(0); progress.setVisibility(View.VISIBLE); synchronized (this) { final Thread previousThread = thread; thread = new Thread( new Runnable() { @Override public void run() { if (previousThread != null) { try { previousThread.join(); } catch (InterruptedException e) { } } List<RouteInfoLocation> res = repo.searchTransportRouteStops( locationToStart.getLatitude(), locationToStart.getLongitude(), locationToGo, zoom); updateUIList(res); } }, "SearchingTransport"); //$NON-NLS-1$ thread.start(); } } else { repo = null; } } else { updateSearchMoreButton(); } }
private Intent createIntent(Class<?> cl) { LatLon location = null; Intent intent = getIntent(); if (intent != null) { double lat = intent.getDoubleExtra(SearchActivity.SEARCH_LAT, 0); double lon = intent.getDoubleExtra(SearchActivity.SEARCH_LON, 0); if (lat != 0 || lon != 0) { location = new LatLon(lat, lon); } } if (location == null && getParent() instanceof SearchActivity) { location = ((SearchActivity) getParent()).getSearchPoint(); } Intent newIntent = new Intent(SearchAddressActivity.this, cl); if (location != null) { newIntent.putExtra(SearchActivity.SEARCH_LAT, location.getLatitude()); newIntent.putExtra(SearchActivity.SEARCH_LON, location.getLongitude()); } return newIntent; }
private void updateIntentToLaunch(Intent intentToLaunch) { LatLon loc = null; boolean searchAround = false; Intent intent = getIntent(); if (intent != null) { double lat = intent.getDoubleExtra(SEARCH_LAT, 0); double lon = intent.getDoubleExtra(SEARCH_LON, 0); if (lat != 0 || lon != 0) { loc = new LatLon(lat, lon); } } if (loc == null && getParent() instanceof SearchActivity) { loc = ((SearchActivity) getParent()).getSearchPoint(); searchAround = ((SearchActivity) getParent()).isSearchAroundCurrentLocation(); } if (loc == null && !searchAround) { loc = ((OsmandApplication) getApplication()).getSettings().getLastKnownMapLocation(); } if (loc != null && !searchAround) { intentToLaunch.putExtra(SearchActivity.SEARCH_LAT, loc.getLatitude()); intentToLaunch.putExtra(SearchActivity.SEARCH_LON, loc.getLongitude()); } }
public void showOnMap(boolean navigateTo) { if (searchPoint == null) { return; } String historyName = null; String objectName = ""; int zoom = 12; if (!Algoritms.isEmpty(street2) && !Algoritms.isEmpty(street)) { String cityName = !Algoritms.isEmpty(postcode) ? postcode : city; objectName = street; historyName = MessageFormat.format( getString(R.string.search_history_int_streets), street, street2, cityName); zoom = 16; } else if (!Algoritms.isEmpty(building)) { String cityName = !Algoritms.isEmpty(postcode) ? postcode : city; objectName = street + " " + building; historyName = MessageFormat.format( getString(R.string.search_history_building), building, street, cityName); zoom = 16; } else if (!Algoritms.isEmpty(street)) { String cityName = postcode != null ? postcode : city; objectName = street; historyName = MessageFormat.format(getString(R.string.search_history_street), street, cityName); zoom = 15; } else if (!Algoritms.isEmpty(city)) { historyName = MessageFormat.format(getString(R.string.search_history_city), city); objectName = city; zoom = 13; } if (selectAddressMode) { Intent intent = getIntent(); intent.putExtra(SELECT_ADDRESS_POINT_INTENT_KEY, objectName); intent.putExtra(SELECT_ADDRESS_POINT_LAT, searchPoint.getLatitude()); intent.putExtra(SELECT_ADDRESS_POINT_LON, searchPoint.getLongitude()); setResult(SELECT_ADDRESS_POINT_RESULT_OK, intent); finish(); } else { if (navigateTo) { OsmandApplication app = (OsmandApplication) getApplication(); app.getTargetPointsHelper() .navigatePointDialogAndLaunchMap( SearchAddressActivity.this, searchPoint.getLatitude(), searchPoint.getLongitude(), historyName); } else { osmandSettings.setMapLocationToShow( searchPoint.getLatitude(), searchPoint.getLongitude(), zoom, historyName); MapActivity.launchMapActivityMoveToTop(SearchAddressActivity.this); } } }
void printResults(RoutingContext ctx, LatLon start, LatLon end, List<RouteSegmentResult> result) { float completeTime = 0; float completeDistance = 0; for (RouteSegmentResult r : result) { completeTime += r.getSegmentTime(); completeDistance += r.getDistance(); } println("ROUTE : "); double startLat = start.getLatitude(); double startLon = start.getLongitude(); double endLat = end.getLatitude(); double endLon = end.getLongitude(); StringBuilder add = new StringBuilder(); add.append("loadedTiles = \"").append(ctx.loadedTiles).append("\" "); add.append("visitedSegments = \"").append(ctx.visitedSegments).append("\" "); add.append("complete_distance = \"").append(completeDistance).append("\" "); add.append("complete_time = \"").append(completeTime).append("\" "); add.append("routing_time = \"").append(ctx.routingTime).append("\" "); println( MessageFormat.format( "<test regions=\"\" description=\"\" best_percent=\"\" vehicle=\"{4}\" \n" + " start_lat=\"{0}\" start_lon=\"{1}\" target_lat=\"{2}\" target_lon=\"{3}\" {5} >", startLat + "", startLon + "", endLat + "", endLon + "", ctx.config.routerName, add.toString())); if (PRINT_TO_CONSOLE_ROUTE_INFORMATION_TO_TEST) { for (RouteSegmentResult res : result) { String name = res.getObject().getName(); String ref = res.getObject().getRef(); if (name == null) { name = ""; } if (ref != null) { name += " (" + ref + ") "; } StringBuilder additional = new StringBuilder(); additional.append("time = \"").append(res.getSegmentTime()).append("\" "); additional.append("name = \"").append(name).append("\" "); // float ms = res.getSegmentSpeed(); float ms = res.getObject().getMaximumSpeed(); if (ms > 0) { additional .append("maxspeed = \"") .append(ms * 3.6f) .append("\" ") .append(res.getObject().getHighway()) .append(" "); } additional.append("distance = \"").append(res.getDistance()).append("\" "); if (res.getTurnType() != null) { additional.append("turn = \"").append(res.getTurnType()).append("\" "); additional .append("turn_angle = \"") .append(res.getTurnType().getTurnAngle()) .append("\" "); if (res.getTurnType().getLanes() != null) { additional .append("lanes = \"") .append(Arrays.toString(res.getTurnType().getLanes())) .append("\" "); } } additional.append("start_bearing = \"").append(res.getBearingBegin()).append("\" "); additional.append("end_bearing = \"").append(res.getBearingEnd()).append("\" "); additional.append("description = \"").append(res.getDescription()).append("\" "); println( MessageFormat.format( "\t<segment id=\"{0}\" start=\"{1}\" end=\"{2}\" {3}/>", (res.getObject().getId()) + "", res.getStartPointIndex() + "", res.getEndPointIndex() + "", additional.toString())); } } println("</test>"); }