Search in sources :

Example 1 with CommonPreference

use of net.osmand.plus.OsmandSettings.CommonPreference in project Osmand by osmandapp.

the class MapRenderRepositories method loadMap.

public synchronized void loadMap(RotatedTileBox tileRect, MapTileDownloader mapTileDownloader) {
    boolean prevInterrupted = interrupted;
    interrupted = false;
    // added to avoid zoomAnimation != 0 which produces wrong map position on the screen
    tileRect.setZoomAndAnimation(tileRect.getZoom(), 0);
    // prevent editing
    requestedBox = new RotatedTileBox(tileRect);
    log.info("RENDER MAP: new request " + tileRect);
    if (currentRenderingContext != null) {
        currentRenderingContext = null;
    }
    try {
        // find selected rendering type
        OsmandApplication app = ((OsmandApplication) context.getApplicationContext());
        boolean nightMode = app.getDaynightHelper().isNightMode();
        // boolean moreDetail = prefs.SHOW_MORE_MAP_DETAIL.get();
        RenderingRulesStorage storage = app.getRendererRegistry().getCurrentSelectedRenderer();
        RenderingRuleSearchRequest renderingReq = new RenderingRuleSearchRequest(storage);
        renderingReq.setBooleanFilter(renderingReq.ALL.R_NIGHT_MODE, nightMode);
        for (RenderingRuleProperty customProp : storage.PROPS.getCustomRules()) {
            if (customProp.isBoolean()) {
                if (customProp.getAttrName().equals(RenderingRuleStorageProperties.A_ENGINE_V1)) {
                    renderingReq.setBooleanFilter(customProp, true);
                } else if (RenderingRuleStorageProperties.UI_CATEGORY_HIDDEN.equals(customProp.getCategory())) {
                    renderingReq.setBooleanFilter(customProp, false);
                } else {
                    CommonPreference<Boolean> pref = prefs.getCustomRenderBooleanProperty(customProp.getAttrName());
                    renderingReq.setBooleanFilter(customProp, pref.get());
                }
            } else if (RenderingRuleStorageProperties.UI_CATEGORY_HIDDEN.equals(customProp.getCategory())) {
                if (customProp.isString()) {
                    renderingReq.setStringFilter(customProp, "");
                } else {
                    renderingReq.setIntFilter(customProp, 0);
                }
            } else {
                CommonPreference<String> settings = prefs.getCustomRenderProperty(customProp.getAttrName());
                String res = settings.get();
                if (!Algorithms.isEmpty(res)) {
                    if (customProp.isString()) {
                        renderingReq.setStringFilter(customProp, res);
                    } else {
                        try {
                            renderingReq.setIntFilter(customProp, Integer.parseInt(res));
                        } catch (NumberFormatException e) {
                            e.printStackTrace();
                        }
                    }
                } else {
                    if (customProp.isString()) {
                        renderingReq.setStringFilter(customProp, "");
                    }
                }
            }
        }
        renderingReq.saveState();
        NativeOsmandLibrary nativeLib = !prefs.SAFE_MODE.get() ? NativeOsmandLibrary.getLibrary(storage, context) : null;
        // calculate data box
        QuadRect dataBox = requestedBox.getLatLonBounds();
        int dataBoxZoom = requestedBox.getZoom();
        long now = System.currentTimeMillis();
        if (cObjectsBox.left > dataBox.left || cObjectsBox.top < dataBox.top || cObjectsBox.right < dataBox.right || cObjectsBox.bottom > dataBox.bottom || (nativeLib != null) == (cNativeObjects == null) || dataBoxZoom != cObjectsZoom || prevInterrupted) {
            // increase data box in order for rotate
            if ((dataBox.right - dataBox.left) > (dataBox.top - dataBox.bottom)) {
                double wi = (dataBox.right - dataBox.left) * .05;
                dataBox.left -= wi;
                dataBox.right += wi;
            } else {
                double hi = (dataBox.top - dataBox.bottom) * .05;
                dataBox.top += hi;
                dataBox.bottom -= hi;
            }
            validateLatLonBox(dataBox);
            renderedState = 0;
            boolean loaded;
            if (nativeLib != null) {
                cObjects = new LinkedList<BinaryMapDataObject>();
                loaded = loadVectorDataNative(dataBox, requestedBox.getZoom(), renderingReq, nativeLib);
            } else {
                cNativeObjects = null;
                loaded = loadVectorData(dataBox, requestedBox.getZoom(), renderingReq);
            }
            if (!loaded || checkWhetherInterrupted()) {
                return;
            }
        }
        final long searchTime = System.currentTimeMillis() - now;
        currentRenderingContext = new OsmandRenderer.RenderingContext(context);
        renderingReq.clearState();
        renderingReq.setIntFilter(renderingReq.ALL.R_MINZOOM, requestedBox.getZoom());
        if (renderingReq.searchRenderingAttribute(RenderingRuleStorageProperties.A_DEFAULT_COLOR)) {
            currentRenderingContext.defaultColor = renderingReq.getIntPropertyValue(renderingReq.ALL.R_ATTR_COLOR_VALUE);
        }
        renderingReq.clearState();
        renderingReq.setIntFilter(renderingReq.ALL.R_MINZOOM, requestedBox.getZoom());
        if (renderingReq.searchRenderingAttribute(RenderingRuleStorageProperties.A_SHADOW_RENDERING)) {
            currentRenderingContext.shadowRenderingMode = renderingReq.getIntPropertyValue(renderingReq.ALL.R_ATTR_INT_VALUE);
            currentRenderingContext.shadowRenderingColor = renderingReq.getIntPropertyValue(renderingReq.ALL.R_SHADOW_COLOR);
        }
        if (renderingReq.searchRenderingAttribute("polygonMinSizeToDisplay")) {
            currentRenderingContext.polygonMinSizeToDisplay = renderingReq.getIntPropertyValue(renderingReq.ALL.R_ATTR_INT_VALUE);
        }
        final QuadPointDouble lt = requestedBox.getLeftTopTile(requestedBox.getZoom());
        double cfd = MapUtils.getPowZoom(requestedBox.getZoomFloatPart()) * requestedBox.getMapDensity();
        lt.x *= cfd;
        lt.y *= cfd;
        // LatLon ltn = requestedBox.getLeftTopLatLon();
        final double tileDivisor = MapUtils.getPowZoom(31 - requestedBox.getZoom()) / cfd;
        currentRenderingContext.leftX = lt.x;
        currentRenderingContext.topY = lt.y;
        currentRenderingContext.zoom = requestedBox.getZoom();
        currentRenderingContext.rotate = requestedBox.getRotate();
        currentRenderingContext.width = requestedBox.getPixWidth();
        currentRenderingContext.height = requestedBox.getPixHeight();
        currentRenderingContext.nightMode = nightMode;
        if (requestedBox.getZoom() <= zoomOnlyForBasemaps && "".equals(prefs.MAP_PREFERRED_LOCALE.get())) {
            currentRenderingContext.preferredLocale = app.getLanguage();
            currentRenderingContext.transliterate = !"ru".equals(app.getLanguage()) && !"uk".equals(app.getLanguage()) && !"be".equals(app.getLanguage()) && !"bg".equals(app.getLanguage()) && !"mk".equals(app.getLanguage()) && !"sr".equals(app.getLanguage());
        } else {
            currentRenderingContext.preferredLocale = prefs.MAP_PREFERRED_LOCALE.get();
            currentRenderingContext.transliterate = prefs.MAP_TRANSLITERATE_NAMES.get();
            if (currentRenderingContext.preferredLocale.equals("en")) {
                currentRenderingContext.transliterate = true;
            }
        }
        final float mapDensity = (float) requestedBox.getMapDensity();
        currentRenderingContext.setDensityValue(mapDensity);
        // Text/icon scales according to mapDensity (so text is size of road)
        // currentRenderingContext.textScale = (requestedBox.getDensity()*app.getSettings().TEXT_SCALE.get());
        // Text/icon stays same for all sizes
        currentRenderingContext.textScale = (requestedBox.getDensity() * app.getSettings().TEXT_SCALE.get()) / mapDensity;
        currentRenderingContext.screenDensityRatio = 1 / Math.max(1, requestedBox.getDensity());
        // init rendering context
        currentRenderingContext.tileDivisor = tileDivisor;
        if (checkWhetherInterrupted()) {
            return;
        }
        now = System.currentTimeMillis();
        Bitmap bmp;
        boolean transparent = false;
        RenderingRuleProperty rr = storage.PROPS.get("noPolygons");
        if (rr != null) {
            transparent = renderingReq.getIntPropertyValue(rr) > 0;
        }
        // 1. generate image step by step
        Bitmap reuse = prevBmp;
        this.prevBmp = this.bmp;
        this.prevBmpLocation = this.bmpLocation;
        // necessary for transparent, otherwise 2 times smaller
        Config cfg = transparent ? Config.ARGB_8888 : Config.RGB_565;
        if (reuse != null && reuse.getWidth() == currentRenderingContext.width && reuse.getHeight() == currentRenderingContext.height && cfg == reuse.getConfig()) {
            bmp = reuse;
            bmp.eraseColor(currentRenderingContext.defaultColor);
        } else {
            if (reuse != null) {
                log.warn(String.format("Create new image ? %d != %d (w) %d != %d (h) ", currentRenderingContext.width, reuse.getWidth(), currentRenderingContext.height, reuse.getHeight()));
            }
            bmp = Bitmap.createBitmap(currentRenderingContext.width, currentRenderingContext.height, cfg);
            if (reuse != null) {
                reuse.recycle();
            }
        }
        this.bmp = bmp;
        this.bmpLocation = tileRect;
        if (nativeLib != null) {
            renderer.generateNewBitmapNative(currentRenderingContext, nativeLib, cNativeObjects, bmp, renderingReq, mapTileDownloader);
        } else {
            renderer.generateNewBitmap(currentRenderingContext, cObjects, bmp, renderingReq, mapTileDownloader);
        }
        // Force to use rendering request in order to prevent Garbage Collector when it is used in C++
        if (renderingReq != null) {
            log.info("Debug :" + renderingReq != null);
        }
        String renderingDebugInfo = currentRenderingContext.renderingDebugInfo;
        currentRenderingContext.ended = true;
        if (checkWhetherInterrupted()) {
            // (be smart a bit do not revert if road already drawn)
            if (currentRenderingContext.lastRenderedKey < OsmandRenderer.DEFAULT_LINE_MAX) {
                reuse = this.bmp;
                this.bmp = this.prevBmp;
                this.bmpLocation = this.prevBmpLocation;
                this.prevBmp = reuse;
                this.prevBmpLocation = null;
            }
            currentRenderingContext = null;
            return;
        } else {
            visibleRenderingContext = currentRenderingContext;
            this.checkedRenderedState = renderedState;
            this.checkedBox = this.bmpLocation;
        }
        currentRenderingContext = null;
        // 2. replace whole image
        // keep cache
        // this.prevBmp = null;
        this.prevBmpLocation = null;
        if (prefs.DEBUG_RENDERING_INFO.get() && OsmandPlugin.getEnabledPlugin(OsmandDevelopmentPlugin.class) != null) {
            // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
            String timeInfo = "Searching: " + searchTime + " ms";
            if (renderingDebugInfo != null) {
                timeInfo += "\n" + renderingDebugInfo;
            }
            final String msg = timeInfo;
            log.info(msg);
            handler.post(new Runnable() {

                @Override
                public void run() {
                    Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
                }
            });
        }
    } catch (RuntimeException e) {
        // $NON-NLS-1$
        log.error("Runtime memory exception", e);
        handler.post(new Runnable() {

            @Override
            public void run() {
                Toast.makeText(context, R.string.rendering_exception, Toast.LENGTH_SHORT).show();
            }
        });
    } catch (OutOfMemoryError e) {
        // $NON-NLS-1$
        log.error("Out of memory error", e);
        cObjects = new ArrayList<BinaryMapDataObject>();
        cObjectsBox = new QuadRect();
        handler.post(new Runnable() {

            @Override
            public void run() {
                // ActivityManager activityManager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
                // ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
                // activityManager.getMemoryInfo(memoryInfo);
                // int avl = (int) (memoryInfo.availMem / (1 << 20));
                int max = (int) (Runtime.getRuntime().maxMemory() / (1 << 20));
                int avl = (int) (Runtime.getRuntime().freeMemory() / (1 << 20));
                String s = " (" + avl + " MB available of " + max + ") ";
                Toast.makeText(context, context.getString(R.string.rendering_out_of_memory) + s, Toast.LENGTH_SHORT).show();
            }
        });
    } finally {
        if (currentRenderingContext != null) {
            currentRenderingContext.ended = true;
        }
    }
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) Config(android.graphics.Bitmap.Config) TIntArrayList(gnu.trove.list.array.TIntArrayList) ArrayList(java.util.ArrayList) TLongArrayList(gnu.trove.list.array.TLongArrayList) QuadRect(net.osmand.data.QuadRect) Bitmap(android.graphics.Bitmap) BinaryMapDataObject(net.osmand.binary.BinaryMapDataObject) RenderingContext(net.osmand.plus.render.OsmandRenderer.RenderingContext) RotatedTileBox(net.osmand.data.RotatedTileBox) CommonPreference(net.osmand.plus.OsmandSettings.CommonPreference) RenderingRuleProperty(net.osmand.render.RenderingRuleProperty) RenderingRulesStorage(net.osmand.render.RenderingRulesStorage) RenderingRuleSearchRequest(net.osmand.render.RenderingRuleSearchRequest) QuadPointDouble(net.osmand.data.QuadPointDouble)

Example 2 with CommonPreference

use of net.osmand.plus.OsmandSettings.CommonPreference in project Osmand by osmandapp.

the class ConfigureMapMenu method showPreferencesDialog.

protected void showPreferencesDialog(final ContextMenuAdapter adapter, final ArrayAdapter<?> a, final int pos, final MapActivity activity, String category, List<RenderingRuleProperty> ps, final List<CommonPreference<Boolean>> prefs, final boolean useDescription, ListStringPreference defaultSettings, boolean useDefault, final List<RenderingRuleProperty> customRulesIncluded) {
    AlertDialog.Builder bld = new AlertDialog.Builder(activity);
    boolean[] checkedItems = new boolean[prefs.size()];
    final boolean[] tempPrefs = new boolean[prefs.size()];
    for (int i = 0; i < prefs.size(); i++) {
        tempPrefs[i] = checkedItems[i] = defaultSettings != null && useDefault ? defaultSettings.containsValue(prefs.get(i).getId()) : prefs.get(i).get();
    }
    final String[] vals = new String[ps.size()];
    for (int i = 0; i < ps.size(); i++) {
        RenderingRuleProperty p = ps.get(i);
        String propertyName = SettingsActivity.getStringPropertyName(activity, p.getAttrName(), p.getName());
        vals[i] = propertyName;
    }
    bld.setMultiChoiceItems(vals, checkedItems, new OnMultiChoiceClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which, boolean isChecked) {
            tempPrefs[which] = isChecked;
        }
    });
    bld.setTitle(category);
    bld.setNegativeButton(R.string.shared_string_cancel, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            boolean selected = false;
            for (int i = 0; i < prefs.size(); i++) {
                selected |= prefs.get(i).get();
            }
            adapter.getItem(pos).setSelected(selected);
            adapter.getItem(pos).setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
            a.notifyDataSetInvalidated();
        }
    });
    bld.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            boolean selected = false;
            for (int i = 0; i < prefs.size(); i++) {
                prefs.get(i).set(tempPrefs[i]);
                selected |= tempPrefs[i];
            }
            final List<OsmandSettings.CommonPreference<String>> includedPrefs = new ArrayList<>();
            if (customRulesIncluded != null) {
                for (RenderingRuleProperty p : customRulesIncluded) {
                    if (p.getAttrName().equals(HIKING_ROUTES_OSMC_ATTR)) {
                        final OsmandSettings.CommonPreference<String> pref = activity.getMyApplication().getSettings().getCustomRenderProperty(p.getAttrName());
                        includedPrefs.add(pref);
                        if (hikingRouteOSMCValue == 0) {
                            pref.set("");
                        } else {
                            pref.set(p.getPossibleValues()[hikingRouteOSMCValue - 1]);
                            selected = true;
                        }
                        break;
                    }
                }
            }
            if (adapter != null) {
                if (useDescription) {
                    adapter.getItem(pos).setDescription(getDescription(prefs, includedPrefs));
                } else {
                    adapter.getItem(pos).setSelected(selected);
                }
                adapter.getItem(pos).setColorRes(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
            }
            a.notifyDataSetInvalidated();
            refreshMapComplete(activity);
            activity.getMapLayers().updateLayers(activity.getMapView());
        }
    });
    final AlertDialog dialog = bld.create();
    if (customRulesIncluded != null) {
        for (RenderingRuleProperty p : customRulesIncluded) {
            if (!p.isBoolean()) {
                final OsmandSettings.CommonPreference<String> pref = activity.getMyApplication().getSettings().getCustomRenderProperty(p.getAttrName());
                LayoutInflater inflater = activity.getLayoutInflater();
                View spinnerView = inflater.inflate(R.layout.spinner_rule_layout, null);
                TextView title = (TextView) spinnerView.findViewById(R.id.title);
                final Spinner spinner = (Spinner) spinnerView.findViewById(R.id.spinner);
                TextView description = (TextView) spinnerView.findViewById(R.id.description);
                String propertyName = SettingsActivity.getStringPropertyName(activity, p.getAttrName(), p.getName());
                String propertyDescr = SettingsActivity.getStringPropertyDescription(activity, p.getAttrName(), p.getName());
                title.setText(propertyName);
                description.setText(propertyDescr);
                int i = Arrays.asList(p.getPossibleValues()).indexOf(pref.get());
                if (i >= 0) {
                    i++;
                } else if (Algorithms.isEmpty(pref.get())) {
                    i = 0;
                }
                String[] possibleValuesString = new String[p.getPossibleValues().length + 1];
                possibleValuesString[0] = SettingsActivity.getStringPropertyValue(activity, p.getDefaultValueDescription());
                for (int j = 0; j < p.getPossibleValues().length; j++) {
                    possibleValuesString[j + 1] = SettingsActivity.getStringPropertyValue(activity, p.getPossibleValues()[j]);
                }
                StringSpinnerArrayAdapter arrayAdapter = new StringSpinnerArrayAdapter(activity);
                for (String val : possibleValuesString) {
                    arrayAdapter.add(val);
                }
                spinner.setAdapter(arrayAdapter);
                hikingRouteOSMCValue = i;
                spinner.setSelection(i);
                spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

                    @Override
                    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                        hikingRouteOSMCValue = position;
                    }

                    @Override
                    public void onNothingSelected(AdapterView<?> parent) {
                    }
                });
                dialog.getListView().addFooterView(spinnerView);
            }
        }
    }
    dialog.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) OnMultiChoiceClickListener(android.content.DialogInterface.OnMultiChoiceClickListener) DialogInterface(android.content.DialogInterface) Spinner(android.widget.Spinner) TIntArrayList(gnu.trove.list.array.TIntArrayList) List(java.util.List) ArrayList(java.util.ArrayList) AppCompatCheckedTextView(android.support.v7.widget.AppCompatCheckedTextView) TextView(android.widget.TextView) CommonPreference(net.osmand.plus.OsmandSettings.CommonPreference) RenderingRuleProperty(net.osmand.render.RenderingRuleProperty) AppCompatCheckedTextView(android.support.v7.widget.AppCompatCheckedTextView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) OsmandSettings(net.osmand.plus.OsmandSettings) LayoutInflater(android.view.LayoutInflater) AdapterView(android.widget.AdapterView)

Example 3 with CommonPreference

use of net.osmand.plus.OsmandSettings.CommonPreference in project Osmand by osmandapp.

the class MapRendererContext method getMapStyleSettings.

protected QStringStringHash getMapStyleSettings() {
    // Apply map style settings
    OsmandSettings prefs = app.getSettings();
    RenderingRulesStorage storage = app.getRendererRegistry().getCurrentSelectedRenderer();
    Map<String, String> props = new HashMap<String, String>();
    for (RenderingRuleProperty customProp : storage.PROPS.getCustomRules()) {
        if (RenderingRuleStorageProperties.UI_CATEGORY_HIDDEN.equals(customProp.getCategory())) {
            continue;
        } else if (customProp.isBoolean()) {
            CommonPreference<Boolean> pref = prefs.getCustomRenderBooleanProperty(customProp.getAttrName());
            props.put(customProp.getAttrName(), pref.get() + "");
        } else {
            CommonPreference<String> settings = prefs.getCustomRenderProperty(customProp.getAttrName());
            String res = settings.get();
            if (!Algorithms.isEmpty(res)) {
                props.put(customProp.getAttrName(), res);
            }
        }
    }
    QStringStringHash convertedStyleSettings = new QStringStringHash();
    for (Map.Entry<String, String> setting : props.entrySet()) {
        convertedStyleSettings.set(setting.getKey(), setting.getValue());
    }
    if (nightMode) {
        convertedStyleSettings.set("nightMode", "true");
    }
    return convertedStyleSettings;
}
Also used : CommonPreference(net.osmand.plus.OsmandSettings.CommonPreference) HashMap(java.util.HashMap) QStringStringHash(net.osmand.core.jni.QStringStringHash) RenderingRuleProperty(net.osmand.render.RenderingRuleProperty) HashMap(java.util.HashMap) Map(java.util.Map) OsmandSettings(net.osmand.plus.OsmandSettings) RenderingRulesStorage(net.osmand.render.RenderingRulesStorage)

Example 4 with CommonPreference

use of net.osmand.plus.OsmandSettings.CommonPreference in project Osmand by osmandapp.

the class RouteProvider method initOsmAndRoutingConfig.

private RoutingConfiguration initOsmAndRoutingConfig(Builder config, final RouteCalculationParams params, OsmandSettings settings, GeneralRouter generalRouter) throws IOException, FileNotFoundException {
    GeneralRouterProfile p;
    if (params.mode.isDerivedRoutingFrom(ApplicationMode.BICYCLE)) {
        p = GeneralRouterProfile.BICYCLE;
    } else if (params.mode.isDerivedRoutingFrom(ApplicationMode.PEDESTRIAN)) {
        p = GeneralRouterProfile.PEDESTRIAN;
    } else if (params.mode.isDerivedRoutingFrom(ApplicationMode.CAR)) {
        p = GeneralRouterProfile.CAR;
    } else if (params.mode.isDerivedRoutingFrom(ApplicationMode.BOAT)) {
        p = GeneralRouterProfile.BOAT;
    } else {
        return null;
    }
    Map<String, String> paramsR = new LinkedHashMap<String, String>();
    for (Map.Entry<String, RoutingParameter> e : generalRouter.getParameters().entrySet()) {
        String key = e.getKey();
        RoutingParameter pr = e.getValue();
        String vl;
        if (key.equals(GeneralRouter.USE_SHORTEST_WAY)) {
            Boolean bool = !settings.FAST_ROUTE_MODE.getModeValue(params.mode);
            vl = bool ? "true" : null;
        } else if (pr.getType() == RoutingParameterType.BOOLEAN) {
            CommonPreference<Boolean> pref = settings.getCustomRoutingBooleanProperty(key, pr.getDefaultBoolean());
            Boolean bool = pref.getModeValue(params.mode);
            vl = bool ? "true" : null;
        } else {
            vl = settings.getCustomRoutingProperty(key, "").getModeValue(params.mode);
        }
        if (vl != null && vl.length() > 0) {
            paramsR.put(key, vl);
        }
    }
    if (params.inSnapToRoadMode) {
        paramsR.put(GeneralRouter.ALLOW_PRIVATE, "true");
    }
    float mb = (1 << 20);
    Runtime rt = Runtime.getRuntime();
    // make visible
    int memoryLimit = (int) (0.95 * ((rt.maxMemory() - rt.totalMemory()) + rt.freeMemory()) / mb);
    log.warn("Use " + memoryLimit + " MB Free " + rt.freeMemory() / mb + " of " + rt.totalMemory() / mb + " max " + rt.maxMemory() / mb);
    RoutingConfiguration cf = config.build(p.name().toLowerCase(), params.start.hasBearing() ? params.start.getBearing() / 180d * Math.PI : null, memoryLimit, paramsR);
    return cf;
}
Also used : CommonPreference(net.osmand.plus.OsmandSettings.CommonPreference) GeneralRouterProfile(net.osmand.router.GeneralRouter.GeneralRouterProfile) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) LocationPoint(net.osmand.data.LocationPoint) LinkedHashMap(java.util.LinkedHashMap) RoutingParameter(net.osmand.router.GeneralRouter.RoutingParameter) RoutingConfiguration(net.osmand.router.RoutingConfiguration) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

CommonPreference (net.osmand.plus.OsmandSettings.CommonPreference)4 RenderingRuleProperty (net.osmand.render.RenderingRuleProperty)3 TIntArrayList (gnu.trove.list.array.TIntArrayList)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 OsmandSettings (net.osmand.plus.OsmandSettings)2 RenderingRulesStorage (net.osmand.render.RenderingRulesStorage)2 DialogInterface (android.content.DialogInterface)1 OnMultiChoiceClickListener (android.content.DialogInterface.OnMultiChoiceClickListener)1 Bitmap (android.graphics.Bitmap)1 Config (android.graphics.Bitmap.Config)1 AlertDialog (android.support.v7.app.AlertDialog)1 AppCompatCheckedTextView (android.support.v7.widget.AppCompatCheckedTextView)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 Spinner (android.widget.Spinner)1 TextView (android.widget.TextView)1