refactoring (Localization -> Location)

pull/1/head
Michael Peter Christen 13 years ago
parent b8b3c87ba7
commit d45718251e

@ -24,8 +24,8 @@ import java.net.MalformedURLException;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.services.federated.yacy.CacheStrategy;
import net.yacy.document.LibraryProvider;
import net.yacy.document.geolocalization.GeonamesLocalization;
import net.yacy.document.geolocalization.OpenGeoDBLocalization;
import net.yacy.document.geolocalization.GeonamesLocation;
import net.yacy.document.geolocalization.OpenGeoDBLocation;
import net.yacy.kelondro.data.meta.DigestURI;
import net.yacy.kelondro.logging.Log;
import net.yacy.kelondro.util.FileUtils;
@ -68,7 +68,7 @@ public class DictionaryLoader_p {
final Response response = sb.loader.load(sb.loader.request(new DigestURI(LibraryProvider.Dictionary.GEON0.url), false, true), CacheStrategy.NOCACHE, Integer.MAX_VALUE, false);
final byte[] b = response.getContent();
FileUtils.copy(b, LibraryProvider.Dictionary.GEON0.file());
LibraryProvider.geoLoc.addLocalization(LibraryProvider.Dictionary.GEON0.nickname, new GeonamesLocalization(LibraryProvider.Dictionary.GEON0.file()));
LibraryProvider.geoLoc.addLocalization(LibraryProvider.Dictionary.GEON0.nickname, new GeonamesLocation(LibraryProvider.Dictionary.GEON0.file()));
LibraryProvider.autotagging.addPlaces(LibraryProvider.geoLoc);
prop.put("geon0Status", LibraryProvider.Dictionary.GEON0.file().exists() ? 1 : 0);
prop.put("geon0ActionLoaded", 1);
@ -98,7 +98,7 @@ public class DictionaryLoader_p {
if (post.containsKey("geon0Activate")) {
LibraryProvider.Dictionary.GEON0.fileDisabled().renameTo(LibraryProvider.Dictionary.GEON0.file());
LibraryProvider.geoLoc.addLocalization(LibraryProvider.Dictionary.GEON0.nickname, new GeonamesLocalization(LibraryProvider.Dictionary.GEON0.file()));
LibraryProvider.geoLoc.addLocalization(LibraryProvider.Dictionary.GEON0.nickname, new GeonamesLocation(LibraryProvider.Dictionary.GEON0.file()));
LibraryProvider.autotagging.addPlaces(LibraryProvider.geoLoc);
prop.put("geon0ActionActivated", 1);
}
@ -111,7 +111,7 @@ public class DictionaryLoader_p {
final byte[] b = response.getContent();
FileUtils.copy(b, LibraryProvider.Dictionary.GEODB1.file());
LibraryProvider.geoLoc.removeLocalization(LibraryProvider.Dictionary.GEODB0.nickname);
LibraryProvider.geoLoc.addLocalization(LibraryProvider.Dictionary.GEODB1.nickname, new OpenGeoDBLocalization(LibraryProvider.Dictionary.GEODB1.file(), false));
LibraryProvider.geoLoc.addLocalization(LibraryProvider.Dictionary.GEODB1.nickname, new OpenGeoDBLocation(LibraryProvider.Dictionary.GEODB1.file(), false));
LibraryProvider.autotagging.addPlaces(LibraryProvider.geoLoc);
prop.put("geo1Status", LibraryProvider.Dictionary.GEODB1.file().exists() ? 1 : 0);
prop.put("geo1ActionLoaded", 1);
@ -141,7 +141,7 @@ public class DictionaryLoader_p {
if (post.containsKey("geo1Activate")) {
LibraryProvider.Dictionary.GEODB1.fileDisabled().renameTo(LibraryProvider.Dictionary.GEODB1.file());
LibraryProvider.geoLoc.addLocalization(LibraryProvider.Dictionary.GEODB1.nickname, new OpenGeoDBLocalization(LibraryProvider.Dictionary.GEODB1.file(), false));
LibraryProvider.geoLoc.addLocalization(LibraryProvider.Dictionary.GEODB1.nickname, new OpenGeoDBLocation(LibraryProvider.Dictionary.GEODB1.file(), false));
LibraryProvider.autotagging.addPlaces(LibraryProvider.geoLoc);
prop.put("geo1ActionActivated", 1);
}

@ -40,9 +40,9 @@ import java.util.zip.ZipException;
import java.util.zip.ZipFile;
import net.yacy.cora.document.MultiProtocolURI;
import net.yacy.document.geolocalization.GeonamesLocalization;
import net.yacy.document.geolocalization.OpenGeoDBLocalization;
import net.yacy.document.geolocalization.OverarchingLocalization;
import net.yacy.document.geolocalization.GeonamesLocation;
import net.yacy.document.geolocalization.OpenGeoDBLocation;
import net.yacy.document.geolocalization.OverarchingLocation;
import net.yacy.kelondro.logging.Log;
import net.yacy.kelondro.util.FileUtils;
@ -57,7 +57,7 @@ public class LibraryProvider {
public static WordCache dymLib = new WordCache(null);
public static Autotagging autotagging = new Autotagging(null, tagPrefix);
public static OverarchingLocalization geoLoc = new OverarchingLocalization();
public static OverarchingLocation geoLoc = new OverarchingLocation();
private static File dictSource = null;
private static File dictRoot = null;
@ -125,11 +125,11 @@ public class LibraryProvider {
if ( geo0.exists() ) {
geo0.renameTo(Dictionary.GEODB0.fileDisabled());
}
geoLoc.addLocalization(Dictionary.GEODB1.nickname, new OpenGeoDBLocalization(geo1, false));
geoLoc.addLocalization(Dictionary.GEODB1.nickname, new OpenGeoDBLocation(geo1, false));
return;
}
if ( geo0.exists() ) {
geoLoc.addLocalization(Dictionary.GEODB0.nickname, new OpenGeoDBLocalization(geo0, false));
geoLoc.addLocalization(Dictionary.GEODB0.nickname, new OpenGeoDBLocation(geo0, false));
return;
}
}
@ -137,7 +137,7 @@ public class LibraryProvider {
public static void integrateGeonames() {
final File geon = Dictionary.GEON0.file();
if ( geon.exists() ) {
geoLoc.addLocalization(Dictionary.GEON0.nickname, new GeonamesLocalization(geon));
geoLoc.addLocalization(Dictionary.GEON0.nickname, new GeonamesLocation(geon));
return;
}
}

@ -42,7 +42,7 @@ import java.util.zip.ZipFile;
import net.yacy.document.StringBuilderComparator;
import net.yacy.kelondro.logging.Log;
public class GeonamesLocalization implements Locations
public class GeonamesLocation implements Locations
{
/*
@ -73,7 +73,7 @@ public class GeonamesLocalization implements Locations
private final TreeMap<StringBuilder, List<Integer>> name2ids;
private final File file;
public GeonamesLocalization(final File file) {
public GeonamesLocation(final File file) {
// this is a processing of the cities1000.zip file from http://download.geonames.org/export/dump/
this.file = file;

@ -49,7 +49,7 @@ import net.yacy.kelondro.logging.Log;
* of more than 100MB! This class will provide a super-fast access to the OpenGeoDB, since all request are
* evaluated using data in the RAM.
*/
public class OpenGeoDBLocalization implements Locations
public class OpenGeoDBLocation implements Locations
{
private final Map<Integer, GeoLocation> id2loc;
@ -59,7 +59,7 @@ public class OpenGeoDBLocalization implements Locations
private final Map<String, Integer> zip2id;
private final File file;
public OpenGeoDBLocalization(final File file, final boolean lonlat) {
public OpenGeoDBLocation(final File file, final boolean lonlat) {
this.file = file;
this.id2loc = new HashMap<Integer, GeoLocation>();

@ -28,14 +28,14 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
public class OverarchingLocalization implements Locations {
public class OverarchingLocation implements Locations {
private final Map<String, Locations> services;
/**
* create a new overarching localization object
*/
public OverarchingLocalization() {
public OverarchingLocation() {
this.services = new HashMap<String, Locations>();
}
Loading…
Cancel
Save