Remove not used countries info

This commit is contained in:
vshcherb 2013-11-11 01:46:38 +01:00
parent 77b8c8cb66
commit 047a42cf42
4 changed files with 1 additions and 1440 deletions

File diff suppressed because it is too large Load diff

View file

@ -5,9 +5,6 @@ import gnu.trove.list.array.TIntArrayList;
import java.util.ArrayList;
import java.util.List;
import net.osmand.map.OsmandRegionInfo.OsmAndRegion;
import net.osmand.util.Algorithms;
public class RegionCountry {
public String continentName;
public int left, right, top, bottom;
@ -146,45 +143,7 @@ public class RegionCountry {
return regions;
}
public static RegionCountry construct(OsmAndRegion reg) {
RegionCountry rc = new RegionCountry();
if (reg.hasContinentName()) {
rc.continentName = reg.getContinentName();
}
rc.name = reg.getName();
int px = 0;
int py = 0;
for (int i = 0; i < reg.getDegXCount(); i++) {
px = reg.getDegX(i) + px;
py = reg.getDegY(i) + py;
rc.add(px, py);
}
for (int i = 0; i < reg.getSubregionsCount(); i++) {
rc.addSubregion(construct(reg.getSubregions(i)));
}
return rc;
}
public OsmAndRegion convert() {
OsmAndRegion.Builder reg = OsmAndRegion.newBuilder();
// System.out.println(r.name + " " + r.tiles.size() + " ?= " + r.calculateTileSet(new TLongHashSet(), 8).size());
int px = 0;
int py = 0;
for (int i = 0; i < this.getTileSize(); i++) {
reg.addDegX(this.getLon(i) - px);
reg.addDegY(this.getLat(i) - py);
px = this.getLon(i);
py = this.getLat(i);
}
String n = Algorithms.capitalizeFirstLetterAndLowercase(this.name.replace('_', ' '));
reg.setName(n);
if(this.continentName != null) {
reg.setContinentName(Algorithms.capitalizeFirstLetterAndLowercase(this.continentName));
}
for (RegionCountry c : this.regions) {
reg.addSubregions(c.convert());
}
return reg.build();
}
}

View file

@ -1,44 +0,0 @@
package net.osmand.map;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import net.osmand.PlatformUtil;
import net.osmand.map.OsmandRegionInfo.OsmAndRegionInfo;
import org.apache.commons.logging.Log;
public class RegionRegistry {
public static final String fileName = "countries.reginfo";
private static final Log log = PlatformUtil.getLog(RegionRegistry.class);
private static RegionRegistry r = null;
private List<RegionCountry> countries = new ArrayList<RegionCountry>();
public static RegionRegistry getRegionRegistry(){
if(r == null) {
try {
long t = -System.currentTimeMillis();
r = new RegionRegistry();
InputStream in = RegionRegistry.class.getResourceAsStream(RegionRegistry.fileName);
OsmAndRegionInfo regInfo = OsmAndRegionInfo.newBuilder().mergeFrom(in).build();
for(int j = 0; j < regInfo.getRegionInfo().getRegionsCount(); j++) {
r.countries.add(RegionCountry.construct(regInfo.getRegionInfo().getRegions(j)));
}
t += System.currentTimeMillis();
log.info("Initialize regions from file" + t + " ms");
} catch (IOException e) {
log.error("IO exception reading regions", e);
}
}
return r;
}
public List<RegionCountry> getCountries() {
return countries;
}
}

View file

@ -1,140 +0,0 @@
package net.osmand.plus.download;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import net.osmand.IndexConstants;
import net.osmand.map.RegionCountry;
import net.osmand.plus.ClientContext;
import net.osmand.plus.R;
import net.osmand.plus.Version;
public class SrtmIndexItem extends IndexItem {
private RegionCountry item;
private List<String> tilesToDownload = new ArrayList<String>();
public SrtmIndexItem(RegionCountry item, Map<String, String> existingFileNames) {
super(fileName(item), "Elevation lines", "", item.getTileSize()+"", null);
this.item = item;
type = DownloadActivityType.SRTM_FILE;
updateExistingTiles(existingFileNames);
}
public void updateExistingTiles(Map<String, String> existingFileNames) {
tilesToDownload.clear();
for (int i = 0; i < item.getTileSize(); i++) {
int lat = item.getLat(i);
int lon = item.getLon(i);
String fname = getFileName(lat, lon);
if (!existingFileNames.containsKey(fname + IndexConstants.BINARY_MAP_INDEX_EXT)) {
tilesToDownload.add(fname);
}
}
}
private String getFileName(int lat, int lon) {
String fn = lat >= 0 ? "N" : "S";
if(Math.abs(lat) < 10) {
fn += "0";
}
fn += Math.abs(lat);
fn += lon >= 0 ? "e" : "w";
if(Math.abs(lon) < 10) {
fn += "00";
} else if(Math.abs(lon) < 100) {
fn += "0";
}
fn += Math.abs(lon);
return fn;
}
private static String fileName(RegionCountry r) {
if(r.parent == null) {
return (r.continentName + " " + r.name).trim();
} else {
return (r.parent.continentName + " " + r.parent.name + " " + r.name).trim();
}
}
@Override
public boolean isAccepted() {
return true;
}
@Override
public List<DownloadEntry> createDownloadEntry(ClientContext ctx, DownloadActivityType type,
List<DownloadEntry> downloadEntries) {
File parent = ctx.getAppPath(IndexConstants.SRTM_INDEX_DIR);
parent.mkdirs();
List<DownloadEntry> toDownload = new ArrayList<DownloadEntry>();
if (parent == null || !parent.exists()) {
ctx.showToastMessage(R.string.sd_dir_not_accessible);
} else {
for (String fileToDownload : tilesToDownload) {
DownloadEntry entry = new DownloadEntry();
entry.type = type;
entry.baseName = fileToDownload;
String url = "http://" + IndexConstants.INDEX_DOWNLOAD_DOMAIN;
url += "/download?event=2&srtm=yes&";
url += Version.getVersionAsURLParam(ctx) + "&";
String fullName = fileToDownload + "_" + IndexConstants.BINARY_MAP_VERSION + IndexConstants.BINARY_MAP_INDEX_EXT_ZIP;
entry.urlToDownload = url +"file=" + fullName;
// url + "file=" + fileName;
entry.unzipFolder = false;
entry.zipStream = true;
entry.dateModified = System.currentTimeMillis();
entry.sizeMB = 10;
entry.parts = 1;
entry.targetFile = new File(parent, entry.baseName + IndexConstants.BINARY_MAP_INDEX_EXT);
downloadEntries.add(entry);
toDownload.size();
}
}
return downloadEntries;
}
@Override
public String getTargetFileName() {
return fileName+".nonexistent";
}
@Override
public String getBasename() {
return fileName;
}
@Override
public String getSizeDescription(ClientContext ctx) {
return (item.getTileSize() - tilesToDownload.size()) + "/" + item.getTileSize() + " " + ctx.getString(R.string.index_srtm_parts);
}
@Override
public String getVisibleDescription(ClientContext ctx) {
return ctx.getString(R.string.index_srtm_ele);
}
@Override
public boolean isAlreadyDownloaded(Map<String, String> listAlreadyDownloaded) {
for (int i = 0; i < item.getTileSize(); i++) {
int lat = item.getLat(i);
int lon = item.getLon(i);
String fname = getFileName(lat, lon);
if (listAlreadyDownloaded.containsKey(fname + IndexConstants.BINARY_MAP_INDEX_EXT)) {
return true;
}
}
return false;
}
@Override
public String getVisibleName(ClientContext ctx) {
if(item.parent == null) {
return item.name;
} else {
return item.parent.name +" "+item.name;
}
}
}