Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2013-07-22 02:20:23 +02:00
commit b5df7f7003

View file

@ -203,13 +203,12 @@ public class TileSourceManager {
public static void createMetaInfoFile(File dir, TileSourceTemplate tm, boolean override) throws IOException { public static void createMetaInfoFile(File dir, TileSourceTemplate tm, boolean override) throws IOException {
File metainfo = new File(dir, ".metainfo"); //$NON-NLS-1$ File metainfo = new File(dir, ".metainfo"); //$NON-NLS-1$
Map<String, String> properties = new LinkedHashMap<String, String>(); Map<String, String> properties = new LinkedHashMap<String, String>();
if (tm instanceof BeanShellTileSourceTemplate) { if (tm.getRule() != null && tm.getRule().length() > 0) {
properties.put("rule", RULE_BEANSHELL); properties.put("rule", tm.getRule());
}
if (tm.getUrlTemplate() == null && !RULE_YANDEX_TRAFFIC.equalsIgnoreCase(tm.getRule())) {
return;
} }
if(tm.getUrlTemplate() != null) {
properties.put("url_template", tm.getUrlTemplate()); properties.put("url_template", tm.getUrlTemplate());
}
properties.put("ext", tm.getTileFormat()); properties.put("ext", tm.getTileFormat());
properties.put("min_zoom", tm.getMinimumZoomSupported() + ""); properties.put("min_zoom", tm.getMinimumZoomSupported() + "");
@ -221,12 +220,14 @@ public class TileSourceManager {
if (tm.isEllipticYTile()) { if (tm.isEllipticYTile()) {
properties.put("ellipsoid", tm.isEllipticYTile() + ""); properties.put("ellipsoid", tm.isEllipticYTile() + "");
} }
if (override || !metainfo.exists()) {
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(metainfo))); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(metainfo)));
for (String key : properties.keySet()) { for (String key : properties.keySet()) {
writer.write("[" + key + "]\n" + properties.get(key) + "\n"); writer.write("[" + key + "]\n" + properties.get(key) + "\n");
} }
writer.close(); writer.close();
} }
}
public static boolean isTileSourceMetaInfoExist(File dir){ public static boolean isTileSourceMetaInfoExist(File dir){
return new File(dir, ".metainfo").exists() || new File(dir, "url").exists(); return new File(dir, ".metainfo").exists() || new File(dir, "url").exists();