Search in sources :

Example 16 with WorldRegion

use of net.osmand.map.WorldRegion in project Osmand by osmandapp.

the class ItemViewHolder method download.

protected void download(IndexItem indexItem, DownloadResourceGroup parentOptional) {
    boolean handled = false;
    if (parentOptional != null) {
        WorldRegion region = DownloadResourceGroup.getRegion(parentOptional);
        context.setDownloadItem(region, indexItem.getTargetFile(context.getMyApplication()).getAbsolutePath());
    }
    if (indexItem.getType() == DownloadActivityType.ROADS_FILE && parentOptional != null) {
        for (IndexItem ii : parentOptional.getIndividualResources()) {
            if (ii.getType() == DownloadActivityType.NORMAL_FILE) {
                if (ii.isDownloaded()) {
                    handled = true;
                    confirmDownload(indexItem);
                }
                break;
            }
        }
    }
    if (!handled) {
        context.startDownload(indexItem);
    }
}
Also used : WorldRegion(net.osmand.map.WorldRegion) IndexItem(net.osmand.plus.download.IndexItem)

Example 17 with WorldRegion

use of net.osmand.map.WorldRegion in project Osmand by osmandapp.

the class DownloadedRegionsLayer method getFilter.

public String getFilter(StringBuilder btnName) {
    StringBuilder filter = new StringBuilder();
    int zoom = view.getZoom();
    RotatedTileBox queriedBox = data.getQueriedBox();
    final List<BinaryMapDataObject> currentObjects = data.results;
    if (osmandRegions.isInitialized() && queriedBox != null) {
        if (zoom >= ZOOM_TO_SHOW_MAP_NAMES && Math.abs(queriedBox.getZoom() - zoom) <= ZOOM_THRESHOLD && currentObjects != null) {
            btnName.setLength(0);
            btnName.append(view.getResources().getString(R.string.shared_string_download));
            filter.setLength(0);
            Set<String> set = new TreeSet<String>();
            int cx = view.getCurrentRotatedTileBox().getCenter31X();
            int cy = view.getCurrentRotatedTileBox().getCenter31Y();
            if ((currentObjects.size() > 0)) {
                for (int i = 0; i < currentObjects.size(); i++) {
                    final BinaryMapDataObject o = currentObjects.get(i);
                    if (!osmandRegions.contain(o, cx, cy)) {
                        continue;
                    }
                    String fullName = osmandRegions.getFullName(o);
                    WorldRegion rd = osmandRegions.getRegionData(fullName);
                    if (rd != null && rd.isRegionMapDownload() && rd.getRegionDownloadName() != null) {
                        String name = rd.getLocaleName();
                        if (checkIfObjectDownloaded(rd.getRegionDownloadName())) {
                            return null;
                        }
                        if (!set.add(name)) {
                            continue;
                        }
                        if (set.size() > 1) {
                            btnName.append(" ").append(view.getResources().getString(R.string.shared_string_or)).append(" ");
                            filter.append(", ");
                        } else {
                            btnName.append(" ");
                        }
                        filter.append(name);
                        btnName.append(name);
                    }
                }
            }
        }
    }
    if (filter.length() == 0) {
        return null;
    }
    return filter.toString();
}
Also used : RotatedTileBox(net.osmand.data.RotatedTileBox) WorldRegion(net.osmand.map.WorldRegion) BinaryMapDataObject(net.osmand.binary.BinaryMapDataObject) TreeSet(java.util.TreeSet) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint)

Aggregations

WorldRegion (net.osmand.map.WorldRegion)17 BinaryMapDataObject (net.osmand.binary.BinaryMapDataObject)10 OsmandRegions (net.osmand.map.OsmandRegions)8 LinkedHashMap (java.util.LinkedHashMap)6 LinkedList (java.util.LinkedList)6 ArrayList (java.util.ArrayList)4 IndexItem (net.osmand.plus.download.IndexItem)4 TLongObjectHashMap (gnu.trove.map.hash.TLongObjectHashMap)3 IOException (java.io.IOException)3 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 HashMap (java.util.HashMap)3 Paint (android.graphics.Paint)2 SpannableString (android.text.SpannableString)2 TextPaint (android.text.TextPaint)2 File (java.io.File)2 Connection (java.sql.Connection)2 List (java.util.List)2 Map (java.util.Map)2 TagValuePair (net.osmand.binary.BinaryMapIndexReader.TagValuePair)2