Commit 766701d6 authored by Yuri Astrakhan's avatar Yuri Astrakhan

renamed Wikosm to Sophox, updated URLs

git-svn-id: https://svn.openstreetmap.org/applications/editors/josm/plugins/wikipedia@33808 b9d5c4c9-76e1-0310-9c85-f3177eceb1e4
parent 1243669c
<?xml version="1.0" encoding="utf-8"?>
<project name="wikipedia" default="dist" basedir=".">
<project name="wikipedia" default="dist2" basedir=".">
<!-- enter the SVN commit message -->
<property name="commit.message" value="Commit message"/>
......@@ -16,4 +16,8 @@
<!-- ** include targets that all plugins have in common ** -->
<import file="../build-common.xml"/>
<target name="dist2" depends="dist">
<copy file="${plugin.jar}" todir="${plugin.dist.dir}/../.josm/plugins"/>
</target>
</project>
......@@ -27,7 +27,7 @@ public class WikipediaPlugin extends Plugin {
MainMenu.add(dataMenu, new FetchWikidataAction());
MainMenu.add(dataMenu, new WikidataItemSearchDialog.Action());
DownloadDialog.addDownloadSource(new WikosmDownloadSource());
DownloadDialog.addDownloadSource(new SophoxDownloadReader());
}
@Override
......@@ -41,7 +41,7 @@ public class WikipediaPlugin extends Plugin {
@Override
public PreferenceSetting getPreferenceSetting() {
if (preferences == null) {
preferences = (new WikosmServerPreference.Factory()).createPreferenceSetting();
preferences = (new SophoxServerPreference.Factory()).createPreferenceSetting();
}
return preferences;
}
......
......@@ -17,22 +17,22 @@ import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
import org.openstreetmap.josm.gui.widgets.HistoryComboBox;
import org.openstreetmap.josm.tools.GBC;
import org.wikipedia.io.WikosmDownloadReader;
import org.wikipedia.io.SophoxDownloadReader;
/**
* Preferences related to Wikosm API servers.
* Preferences related to Sophox API servers.
*/
public class WikosmServerPreference implements SubPreferenceSetting {
public class SophoxServerPreference implements SubPreferenceSetting {
private final HistoryComboBox wikosmServer = new HistoryComboBox();
private final HistoryComboBox SophoxServer = new HistoryComboBox();
/**
* Factory used to create a new {@link WikosmServerPreference}.
* Factory used to create a new {@link SophoxServerPreference}.
*/
public static class Factory implements PreferenceSettingFactory {
@Override
public PreferenceSetting createPreferenceSetting() {
return new WikosmServerPreference();
return new SophoxServerPreference();
}
}
......@@ -47,9 +47,9 @@ public class WikosmServerPreference implements SubPreferenceSetting {
panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
panel.add(new JLabel(tr("Server: ")), GBC.std().insets(5, 5, 5, 5));
panel.add(wikosmServer, GBC.eop().fill(GBC.HORIZONTAL));
wikosmServer.setPossibleItems(WikosmDownloadReader.WIKOSM_SERVER_HISTORY.get());
wikosmServer.setText(WikosmDownloadReader.WIKOSM_SERVER.get());
panel.add(SophoxServer, GBC.eop().fill(GBC.HORIZONTAL));
SophoxServer.setPossibleItems(SophoxDownloadReader.SOPHOX_SERVER_HISTORY.get());
SophoxServer.setText(SophoxDownloadReader.SOPHOX_SERVER.get());
panel.add(Box.createVerticalGlue(), GBC.eol().fill());
......@@ -58,8 +58,8 @@ public class WikosmServerPreference implements SubPreferenceSetting {
@Override
public boolean ok() {
WikosmDownloadReader.WIKOSM_SERVER.put(wikosmServer.getText());
WikosmDownloadReader.WIKOSM_SERVER_HISTORY.put(wikosmServer.getHistory());
SophoxDownloadReader.SOPHOX_SERVER.put(SophoxServer.getText());
SophoxDownloadReader.SOPHOX_SERVER_HISTORY.put(SophoxServer.getHistory());
return false;
}
......
......@@ -35,45 +35,45 @@ import java.util.regex.Pattern;
import static org.openstreetmap.josm.tools.I18n.tr;
/**
* Read content from an Wikosm server.
* Read content from an Sophox server.
*/
public class WikosmDownloadReader extends BoundingBoxDownloader {
public class SophoxDownloadReader extends BoundingBoxDownloader {
/**
* Property for current Wikosm server.
* Property for current Sophox server.
*/
public static final StringProperty WIKOSM_SERVER = new StringProperty("download.wikosm.server",
"http://88.99.164.208/bigdata/namespace/wdq/sparql");
public static final StringProperty SOPHOX_SERVER = new StringProperty("download.sophox.server",
"https://sophox.org/bigdata/namespace/wdq/sparql");
/**
* Property for list of known Wikosm servers.
* Property for list of known Sophox servers.
*/
// TODO: Core dependency:
// public static final ListProperty WIKOSM_SERVER_HISTORY = new ListProperty("download.wikosm.servers",
// Arrays.asList("http://88.99.164.208/bigdata/namespace/wdq/sparql"));
public static final ListProperty WIKOSM_SERVER_HISTORY = new ListProperty("download.wikosm.servers",
Arrays.asList("http://88.99.164.208/bigdata/namespace/wdq/sparql"));
// public static final ListProperty SOPHOX_SERVER_HISTORY = new ListProperty("download.sophox.servers",
// Arrays.asList("https://sophox.org/bigdata/namespace/wdq/sparql"));
public static final ListProperty SOPHOX_SERVER_HISTORY = new ListProperty("download.sophox.servers",
Arrays.asList("https://sophox.org/bigdata/namespace/wdq/sparql"));
private static final String DATA_PREFIX = "?query=";
private final String wikosmServer;
private final String wikosmQuery;
private final String sophoxServer;
private final String sophoxQuery;
private final boolean asNewLayer;
private final boolean downloadReferrers;
private final boolean downloadFull;
/**
* Constructs a new {@code WikosmDownloadReader}.
* Constructs a new {@code SophoxDownloadReader}.
*
* @param downloadArea The area to download
* @param wikosmServer The Wikosm server to use
* @param wikosmQuery The Wikosm query
* @param sophoxServer The Sophox server to use
* @param sophoxQuery The Sophox query
*/
public WikosmDownloadReader(Bounds downloadArea, String wikosmServer, String wikosmQuery,
public SophoxDownloadReader(Bounds downloadArea, String sophoxServer, String sophoxQuery,
boolean asNewLayer, boolean downloadReferrers, boolean downloadFull) {
super(downloadArea);
setDoAuthenticate(false);
this.wikosmServer = wikosmServer;
this.wikosmQuery = wikosmQuery.trim();
this.sophoxServer = sophoxServer;
this.sophoxQuery = sophoxQuery.trim();
this.asNewLayer = asNewLayer;
this.downloadReferrers = downloadReferrers;
this.downloadFull = downloadFull;
......@@ -81,12 +81,12 @@ public class WikosmDownloadReader extends BoundingBoxDownloader {
@Override
protected String getBaseUrl() {
return wikosmServer;
return sophoxServer;
}
@Override
protected String getRequestForBbox(double lon1, double lat1, double lon2, double lat2) {
final String query = this.wikosmQuery
final String query = this.sophoxQuery
.replace("{{boxParams}}", boxParams(lon1, lat1, lon2, lat2))
.replace("{{center}}", center(lon1, lat1, lon2, lat2));
return DATA_PREFIX + Utils.encodeUrl(query);
......@@ -203,7 +203,7 @@ public class WikosmDownloadReader extends BoundingBoxDownloader {
@Override
protected void adaptRequest(HttpClient request) {
// see https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#timeout
final Matcher timeoutMatcher = Pattern.compile("#timeout:(\\d+)").matcher(wikosmQuery);
final Matcher timeoutMatcher = Pattern.compile("#timeout:(\\d+)").matcher(sophoxQuery);
final int timeout;
if (timeoutMatcher.find()) {
timeout = (int) TimeUnit.SECONDS.toMillis(Integer.parseInt(timeoutMatcher.group(1)));
......@@ -264,8 +264,8 @@ public class WikosmDownloadReader extends BoundingBoxDownloader {
DataSet ds = super.parseOsm(progressMonitor);
// add bounds if necessary (note that Wikosm API does not return bounds in the response XML)
if (ds != null && ds.getDataSources().isEmpty() && wikosmQuery.contains("{{boxParams}}")) {
// add bounds if necessary (note that Sophox API does not return bounds in the response XML)
if (ds != null && ds.getDataSources().isEmpty() && sophoxQuery.contains("{{boxParams}}")) {
if (crosses180th) {
Bounds bounds = new Bounds(lat1, lon1, lat2, 180.0);
DataSource src = new DataSource(bounds, getBaseUrl());
......
......@@ -12,9 +12,9 @@ import org.openstreetmap.josm.testutils.JOSMTestRules;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
/**
* Unit tests of {@link WikosmServerPreference} class.
* Unit tests of {@link SophoxServerPreference} class.
*/
public class WikosmServerPreferenceTest {
public class SophoxServerPreferenceTest {
/**
* Setup tests
......@@ -24,18 +24,18 @@ public class WikosmServerPreferenceTest {
public JOSMTestRules test = new JOSMTestRules().preferences().platform();
/**
* Unit test of {@link WikosmServerPreference}.
* Unit test of {@link SophoxServerPreference}.
*/
@Test
public void testWikosmServerPreference() {
assertNotNull(new WikosmServerPreference.Factory().createPreferenceSetting());
public void testSophoxServerPreference() {
assertNotNull(new SophoxServerPreference.Factory().createPreferenceSetting());
}
/**
* Unit test of {@link WikosmServerPreference#addGui}.
* Unit test of {@link SophoxServerPreference#addGui}.
*/
@Test
public void testAddGui() {
PreferencesTestUtils.doTestPreferenceSettingAddGui(new WikosmServerPreference.Factory(), ServerAccessPreference.class);
PreferencesTestUtils.doTestPreferenceSettingAddGui(new SophoxServerPreference.Factory(), ServerAccessPreference.class);
}
}
......@@ -20,9 +20,9 @@ import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
/**
* Unit tests of {@link WikosmDownloadReader} class.
* Unit tests of {@link SophoxDownloadReader} class.
*/
public class WikosmDownloadReaderTest {
public class SophoxDownloadReaderTest {
/**
* Base test environment is enough
......@@ -36,9 +36,9 @@ public class WikosmDownloadReaderTest {
*/
@Test
public void testPoint() throws UnsupportedEncodingException {
assertThat(WikosmDownloadReader.point(9.5, 47.16),
assertThat(SophoxDownloadReader.point(9.5, 47.16),
is("\"Point(9.5 47.16)\"^^geo:wktLiteral"));
assertThat(WikosmDownloadReader.boxParams(1.1, 2.2, 3.3, 4.4),
assertThat(SophoxDownloadReader.boxParams(1.1, 2.2, 3.3, 4.4),
is("\nbd:serviceParam wikibase:cornerWest \"Point(1.1 2.2)\"^^geo:wktLiteral." +
"\nbd:serviceParam wikibase:cornerEast \"Point(3.3 4.4)\"^^geo:wktLiteral.\n"));
}
......@@ -57,7 +57,7 @@ public class WikosmDownloadReaderTest {
);
InputStream stream = new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8.name()));
List<PrimitiveId> actual = WikosmDownloadReader.getPrimitiveIds(stream);
List<PrimitiveId> actual = SophoxDownloadReader.getPrimitiveIds(stream);
List<PrimitiveId> expected = Arrays.asList(new PrimitiveId[]{
new SimplePrimitiveId(12345, OsmPrimitiveType.NODE),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment