kopia lustrzana https://github.com/JOSM/MapWithAI
Mass rename of RapiD -> MapWithAI. Jar name stays the same (for now)
Signed-off-by: Taylor Smock <taylor.smock@kaart.com>pull/1/head
rodzic
d937c1046e
commit
43a5995c6d
|
@ -139,7 +139,7 @@ tests:
|
|||
# stage: deploy
|
||||
# environment:
|
||||
# name: transifex
|
||||
# url: https://www.transifex.com/josm/josm/josm-plugin_rapid/
|
||||
# url: https://www.transifex.com/josm/josm/josm-plugin_$CI_PROJECT_NAME
|
||||
# before_script:
|
||||
# - apt-get update && apt-get install -yq gettext git
|
||||
# - pip install git+https://github.com/transifex/transifex-client.git
|
||||
|
@ -148,18 +148,18 @@ tests:
|
|||
# dependencies:
|
||||
# - build
|
||||
# only:
|
||||
# - master@smocktaylor/rapid
|
||||
# - master@$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME
|
||||
|
||||
release:
|
||||
stage: deploy
|
||||
environment:
|
||||
name: pages branch / dist directory
|
||||
url: https://gitlab.com/smocktaylor/rapid/tree/pages/public/dist
|
||||
url: https://gitlab.com/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/tree/pages/public/dist
|
||||
script:
|
||||
- &clone_pages_branch |
|
||||
echo "$SSH_PRIVATE_DEPLOY_KEY" > ~/.ssh/id_rsa
|
||||
chmod 600 ~/.ssh/id_rsa
|
||||
git clone --depth 1 --branch pages git@gitlab.com:smocktaylor/rapid.git pages
|
||||
git clone --depth 1 --branch pages git@gitlab.com:$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME.git pages
|
||||
- |
|
||||
version=`git describe --always --dirty`
|
||||
longVersion=`git describe --always --long --dirty`
|
||||
|
@ -172,20 +172,20 @@ release:
|
|||
- &push_pages_branch |
|
||||
cd pages/
|
||||
git config user.name "Deploy with GitLab CI"
|
||||
git config user.email "smocktaylor/rapid@gitlab.com"
|
||||
git config user.email "$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME@$CI_SERVER_HOST"
|
||||
git stage .
|
||||
git commit -a -m "$commitMessage"
|
||||
git push origin pages
|
||||
dependencies:
|
||||
- build
|
||||
only:
|
||||
- tags@smocktaylor/rapid
|
||||
- tags@$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME
|
||||
|
||||
publish master update site:
|
||||
stage: deploy
|
||||
environment:
|
||||
name: pages branch / snapshot update site
|
||||
url: https://gitlab.com/smocktaylor/rapid/tree/pages
|
||||
url: https://gitlab.com/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/tree/pages
|
||||
script:
|
||||
- *clone_pages_branch
|
||||
- |
|
||||
|
@ -200,16 +200,16 @@ publish master update site:
|
|||
dependencies:
|
||||
- build
|
||||
only:
|
||||
- master@smocktaylor/rapid
|
||||
- master@$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME
|
||||
|
||||
publish to / GitLab.com packages:
|
||||
stage: deploy
|
||||
environment:
|
||||
name: GitLab.com / JOSM-rapid packages
|
||||
url: https://gitlab.com/smocktaylor/rapid/-/packages
|
||||
name: GitLab.com / JOSM-$CI_PROJECT_NAME packages
|
||||
url: https://gitlab.com/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/-/packages
|
||||
script:
|
||||
- ./gradlew publishPluginPublicationToGitlabRepository
|
||||
dependencies:
|
||||
- build
|
||||
only:
|
||||
- tags@smocktaylor/rapid
|
||||
- tags@$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME
|
||||
|
|
16
.project
16
.project
|
@ -1,17 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>JOSM-rapid</name>
|
||||
<name>JOSM-MapWithAI</name>
|
||||
<comment></comment>
|
||||
<projects/>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments/>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<linkedResources/>
|
||||
<filteredResources/>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
|
|
@ -6,7 +6,7 @@ plugin.main.version = 15229
|
|||
plugin.compile.version = 15229
|
||||
plugin.canloadatruntime = true
|
||||
plugin.author = Taylor Smock <incoming+smocktaylor/rapid@incoming.gitlab.com>
|
||||
plugin.class = org.openstreetmap.josm.plugins.rapid.RapiDPlugin
|
||||
plugin.class = org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin
|
||||
#plugin.icon = images/dialogs/rapid.svg
|
||||
plugin.link = https://gitlab.com/smocktaylor/rapid
|
||||
plugin.description = Allows the use of RapiD data in JOSM (currently VERY rudimentary)
|
||||
plugin.description = Allows the use of MapWithAI data in JOSM (same data as used in RapiD) (currently VERY rudimentary)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.rapid;
|
||||
package org.openstreetmap.josm.plugins.mapwithai;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
@ -17,31 +17,31 @@ import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
|
|||
import org.openstreetmap.josm.io.remotecontrol.RequestProcessor;
|
||||
import org.openstreetmap.josm.plugins.Plugin;
|
||||
import org.openstreetmap.josm.plugins.PluginInformation;
|
||||
import org.openstreetmap.josm.plugins.rapid.backend.RapiDAction;
|
||||
import org.openstreetmap.josm.plugins.rapid.backend.RapiDArbitraryAction;
|
||||
import org.openstreetmap.josm.plugins.rapid.backend.RapiDDataUtils;
|
||||
import org.openstreetmap.josm.plugins.rapid.backend.RapiDMoveAction;
|
||||
import org.openstreetmap.josm.plugins.rapid.backend.RapiDRemoteControl;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIAction;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIArbitraryAction;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIDataUtils;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIMoveAction;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIRemoteControl;
|
||||
import org.openstreetmap.josm.tools.Logging;
|
||||
|
||||
public final class RapiDPlugin extends Plugin {
|
||||
public final class MapWithAIPlugin extends Plugin {
|
||||
/** The name of the plugin */
|
||||
public static final String NAME = "RapiD";
|
||||
public static final String NAME = "MapWithAI";
|
||||
private static String versionInfo;
|
||||
|
||||
private final PreferenceSetting preferenceSetting;
|
||||
|
||||
private static final Map<Class<? extends JosmAction>, Boolean> MENU_ENTRIES = new LinkedHashMap<>();
|
||||
static {
|
||||
MENU_ENTRIES.put(RapiDAction.class, false);
|
||||
MENU_ENTRIES.put(RapiDArbitraryAction.class, true);
|
||||
MENU_ENTRIES.put(RapiDMoveAction.class, false);
|
||||
MENU_ENTRIES.put(MapWithAIAction.class, false);
|
||||
MENU_ENTRIES.put(MapWithAIArbitraryAction.class, true);
|
||||
MENU_ENTRIES.put(MapWithAIMoveAction.class, false);
|
||||
}
|
||||
|
||||
public RapiDPlugin(PluginInformation info) {
|
||||
public MapWithAIPlugin(PluginInformation info) {
|
||||
super(info);
|
||||
|
||||
preferenceSetting = new RapiDPreferences();
|
||||
preferenceSetting = new MapWithAIPreferences();
|
||||
|
||||
final JMenu dataMenu = MainApplication.getMenu().dataMenu;
|
||||
for (final Entry<Class<? extends JosmAction>, Boolean> entry : MENU_ENTRIES.entrySet()) {
|
||||
|
@ -63,10 +63,10 @@ public final class RapiDPlugin extends Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
RapiDDataUtils.addRapiDPaintStyles();
|
||||
MapWithAIDataUtils.addMapWithAIPaintStyles();
|
||||
|
||||
setVersionInfo(info.localversion);
|
||||
RequestProcessor.addRequestHandlerClass("mapwithai", RapiDRemoteControl.class);
|
||||
RequestProcessor.addRequestHandlerClass("mapwithai", MapWithAIRemoteControl.class);
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,4 +1,4 @@
|
|||
package org.openstreetmap.josm.plugins.rapid;
|
||||
package org.openstreetmap.josm.plugins.mapwithai;
|
||||
|
||||
import static org.openstreetmap.josm.tools.I18n.tr;
|
||||
|
||||
|
@ -18,42 +18,42 @@ import javax.swing.SpinnerNumberModel;
|
|||
import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
|
||||
import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
|
||||
import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
|
||||
import org.openstreetmap.josm.plugins.rapid.backend.RapiDDataUtils;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIDataUtils;
|
||||
|
||||
public class RapiDPreferences implements SubPreferenceSetting {
|
||||
private final JComboBox<String> possibleRapidApiUrl;
|
||||
public class MapWithAIPreferences implements SubPreferenceSetting {
|
||||
private final JComboBox<String> possibleMapWithAIApiUrl;
|
||||
|
||||
private final JCheckBox switchLayerCheckBox;
|
||||
|
||||
private final JSpinner maximumAdditionSpinner;
|
||||
|
||||
public RapiDPreferences() {
|
||||
possibleRapidApiUrl = new JComboBox<>();
|
||||
public MapWithAIPreferences() {
|
||||
possibleMapWithAIApiUrl = new JComboBox<>();
|
||||
switchLayerCheckBox = new JCheckBox();
|
||||
maximumAdditionSpinner = new JSpinner(new SpinnerNumberModel(RapiDDataUtils.getMaximumAddition(), 0, 100, 1));
|
||||
maximumAdditionSpinner = new JSpinner(new SpinnerNumberModel(MapWithAIDataUtils.getMaximumAddition(), 0, 100, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGui(PreferenceTabbedPane gui) {
|
||||
final JLabel rapidApiUrl = new JLabel(tr("RapiD API URL"));
|
||||
final JLabel mapWithAIApiUrl = new JLabel(tr("{0} API URL", MapWithAIPlugin.NAME));
|
||||
final JLabel switchLayer = new JLabel(tr("Automatically switch layers"));
|
||||
final JLabel maximumAddition = new JLabel(tr("Maximum features (add)"));
|
||||
final JPanel container = new JPanel(new GridBagLayout());
|
||||
container.setAlignmentY(Component.TOP_ALIGNMENT);
|
||||
final GridBagConstraints constraints = new GridBagConstraints();
|
||||
|
||||
possibleRapidApiUrl.setEditable(true);
|
||||
possibleRapidApiUrl.setPrototypeDisplayValue("https://example.url/some/end/point");
|
||||
final Component textField = possibleRapidApiUrl.getEditor().getEditorComponent();
|
||||
possibleMapWithAIApiUrl.setEditable(true);
|
||||
possibleMapWithAIApiUrl.setPrototypeDisplayValue("https://example.url/some/end/point");
|
||||
final Component textField = possibleMapWithAIApiUrl.getEditor().getEditorComponent();
|
||||
if (textField instanceof JTextField) {
|
||||
((JTextField) textField).setColumns(36);
|
||||
}
|
||||
for (final String url : RapiDDataUtils.getRapiDURLs()) {
|
||||
possibleRapidApiUrl.addItem(url);
|
||||
for (final String url : MapWithAIDataUtils.getMapWithAIURLs()) {
|
||||
possibleMapWithAIApiUrl.addItem(url);
|
||||
}
|
||||
possibleRapidApiUrl.setSelectedItem(RapiDDataUtils.getRapiDURL());
|
||||
possibleMapWithAIApiUrl.setSelectedItem(MapWithAIDataUtils.getMapWithAIUrl());
|
||||
|
||||
switchLayerCheckBox.setSelected(RapiDDataUtils.isSwitchLayers());
|
||||
switchLayerCheckBox.setSelected(MapWithAIDataUtils.isSwitchLayers());
|
||||
|
||||
constraints.gridx = 0;
|
||||
constraints.gridy = 0;
|
||||
|
@ -62,10 +62,10 @@ public class RapiDPreferences implements SubPreferenceSetting {
|
|||
constraints.insets = new Insets(5, 10, 5, 10);
|
||||
constraints.anchor = GridBagConstraints.EAST;
|
||||
constraints.fill = GridBagConstraints.HORIZONTAL;
|
||||
container.add(rapidApiUrl, constraints);
|
||||
container.add(mapWithAIApiUrl, constraints);
|
||||
|
||||
constraints.gridx++;
|
||||
container.add(possibleRapidApiUrl, constraints);
|
||||
container.add(possibleMapWithAIApiUrl, constraints);
|
||||
|
||||
constraints.gridx--;
|
||||
constraints.gridy++;
|
||||
|
@ -80,16 +80,16 @@ public class RapiDPreferences implements SubPreferenceSetting {
|
|||
constraints.gridx++;
|
||||
container.add(maximumAdditionSpinner, constraints);
|
||||
|
||||
getTabPreferenceSetting(gui).addSubTab(this, "RapiD", container);
|
||||
getTabPreferenceSetting(gui).addSubTab(this, MapWithAIPlugin.NAME, container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ok() {
|
||||
RapiDDataUtils.setRapiDUrl((String) possibleRapidApiUrl.getSelectedItem(), true);
|
||||
RapiDDataUtils.setSwitchLayers(switchLayerCheckBox.isSelected(), true);
|
||||
MapWithAIDataUtils.setMapWithAIUrl((String) possibleMapWithAIApiUrl.getSelectedItem(), true);
|
||||
MapWithAIDataUtils.setSwitchLayers(switchLayerCheckBox.isSelected(), true);
|
||||
final Object value = maximumAdditionSpinner.getValue();
|
||||
if (value instanceof Number) {
|
||||
RapiDDataUtils.setMaximumAddition(((Number) value).intValue(), true);
|
||||
MapWithAIDataUtils.setMaximumAddition(((Number) value).intValue(), true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -105,10 +105,10 @@ public class RapiDPreferences implements SubPreferenceSetting {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return {@code JComboBox} with possible rapid api urls
|
||||
* @return {@code JComboBox} with possible MapWithAI api urls
|
||||
*/
|
||||
public JComboBox<String> getPossibleRapidApiUrl() {
|
||||
return possibleRapidApiUrl;
|
||||
public JComboBox<String> getPossibleMapWithAIApiUrl() {
|
||||
return possibleMapWithAIApiUrl;
|
||||
}
|
||||
|
||||
/**
|
|
@ -1,5 +1,5 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.rapid.backend;
|
||||
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
||||
|
||||
import static org.openstreetmap.josm.tools.I18n.tr;
|
||||
|
||||
|
@ -17,18 +17,18 @@ import org.openstreetmap.josm.data.osm.BBox;
|
|||
import org.openstreetmap.josm.gui.MainApplication;
|
||||
import org.openstreetmap.josm.gui.layer.GpxLayer;
|
||||
import org.openstreetmap.josm.gui.layer.Layer;
|
||||
import org.openstreetmap.josm.plugins.rapid.RapiDPlugin;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
|
||||
|
||||
/**
|
||||
* @author Taylor Smock
|
||||
*
|
||||
*/
|
||||
public final class DetectTaskingManagerUtils {
|
||||
public static final String RAPID_CROP_AREA = tr("{0}: Crop Area", RapiDPlugin.NAME);
|
||||
public static final String MAPWITHAI_CROP_AREA = tr("{0}: Crop Area", MapWithAIPlugin.NAME);
|
||||
private static final List<Pattern> PATTERNS = new ArrayList<>();
|
||||
static {
|
||||
PATTERNS.add(Pattern.compile("^Task Boundaries.*$"));
|
||||
PATTERNS.add(Pattern.compile("^" + RAPID_CROP_AREA + "$"));
|
||||
PATTERNS.add(Pattern.compile("^" + MAPWITHAI_CROP_AREA + "$"));
|
||||
}
|
||||
|
||||
private DetectTaskingManagerUtils() {
|
|
@ -1,5 +1,5 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.rapid.backend;
|
||||
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
||||
|
||||
import static org.openstreetmap.josm.tools.I18n.tr;
|
||||
|
||||
|
@ -7,22 +7,23 @@ import java.awt.event.ActionEvent;
|
|||
import java.awt.event.KeyEvent;
|
||||
|
||||
import org.openstreetmap.josm.actions.JosmAction;
|
||||
import org.openstreetmap.josm.plugins.rapid.RapiDPlugin;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
|
||||
import org.openstreetmap.josm.tools.Shortcut;
|
||||
|
||||
public class RapiDAction extends JosmAction {
|
||||
public class MapWithAIAction extends JosmAction {
|
||||
/** UID */
|
||||
private static final long serialVersionUID = 8886705479253246588L;
|
||||
|
||||
public RapiDAction() {
|
||||
super(tr("{0}: Download data", RapiDPlugin.NAME), null, tr("Get data from RapiD"),
|
||||
Shortcut.registerShortcut("data:rapid", tr("Data: {0}", tr("RapiD")), KeyEvent.VK_R, Shortcut.SHIFT),
|
||||
public MapWithAIAction() {
|
||||
super(tr("{0}: Download data", MapWithAIPlugin.NAME), null, tr("Get data from {0}", MapWithAIPlugin.NAME),
|
||||
Shortcut.registerShortcut("data:mapWithAI", tr("Data: {0}", MapWithAIPlugin.NAME), KeyEvent.VK_R,
|
||||
Shortcut.SHIFT),
|
||||
true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
RapiDDataUtils.getRapiDData(RapiDDataUtils.getLayer(true));
|
||||
MapWithAIDataUtils.getMapWithAIData(MapWithAIDataUtils.getLayer(true));
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,5 +1,5 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.rapid.backend;
|
||||
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
||||
|
||||
import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
|
||||
import static org.openstreetmap.josm.tools.I18n.tr;
|
||||
|
@ -27,7 +27,7 @@ import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils;
|
|||
import org.openstreetmap.josm.gui.layer.GpxLayer;
|
||||
import org.openstreetmap.josm.gui.widgets.JosmTextField;
|
||||
import org.openstreetmap.josm.gui.widgets.SelectAllOnFocusGainedDecorator;
|
||||
import org.openstreetmap.josm.plugins.rapid.RapiDPlugin;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
|
||||
import org.openstreetmap.josm.spi.preferences.Config;
|
||||
import org.openstreetmap.josm.tools.GBC;
|
||||
import org.openstreetmap.josm.tools.OsmUrlToBounds;
|
||||
|
@ -36,7 +36,7 @@ import org.openstreetmap.josm.tools.Shortcut;
|
|||
/**
|
||||
* @author Taylor Smock
|
||||
*/
|
||||
public class RapiDArbitraryAction extends JosmAction {
|
||||
public class MapWithAIArbitraryAction extends JosmAction {
|
||||
private static final long serialVersionUID = 9048113038651190619L;
|
||||
|
||||
private final JosmTextField lowerLat = new JosmTextField();
|
||||
|
@ -45,11 +45,11 @@ public class RapiDArbitraryAction extends JosmAction {
|
|||
private final JosmTextField rightLon = new JosmTextField();
|
||||
private final JCheckBox checkbox = new JCheckBox();
|
||||
|
||||
private static final String ARBITRARY_DATA_STRING = "Get arbitrary data from RapiD";
|
||||
private static final String ARBITRARY_DATA_STRING = tr("Get arbitrary data from {0}", MapWithAIPlugin.NAME);
|
||||
|
||||
public RapiDArbitraryAction() {
|
||||
super(tr("{0}: Download arbitrary data", RapiDPlugin.NAME), null, tr(ARBITRARY_DATA_STRING),
|
||||
Shortcut.registerShortcut("data:arbitraryrapid",
|
||||
public MapWithAIArbitraryAction() {
|
||||
super(tr("{0}: Download arbitrary data", MapWithAIPlugin.NAME), null, tr(ARBITRARY_DATA_STRING),
|
||||
Shortcut.registerShortcut("data:arbitrarymapwithai",
|
||||
tr("Data: Arbitrary {0} Data", tr(ARBITRARY_DATA_STRING)), KeyEvent.VK_R,
|
||||
Shortcut.ALT_CTRL_SHIFT), true);
|
||||
}
|
||||
|
@ -59,13 +59,13 @@ public class RapiDArbitraryAction extends JosmAction {
|
|||
showDownloadDialog();
|
||||
}
|
||||
|
||||
static class RapiDArbitraryDialog extends ExtendedDialog {
|
||||
static class MapWithAIArbitraryDialog extends ExtendedDialog {
|
||||
private static final long serialVersionUID = 2795301151521238635L;
|
||||
|
||||
RapiDArbitraryDialog(String[] buttons, JPanel panel) {
|
||||
MapWithAIArbitraryDialog(String[] buttons, JPanel panel) {
|
||||
super(MainApplication.getMainFrame(), tr(ARBITRARY_DATA_STRING), buttons);
|
||||
setButtonIcons("ok", "cancel");
|
||||
configureContextsensitiveHelp(ht("/Action/DownloadArbitraryRapiDData"), true);
|
||||
configureContextsensitiveHelp(ht("/Action/DownloadArbitraryMapWithAIData"), true);
|
||||
setContent(panel);
|
||||
setCancelButton(2);
|
||||
}
|
||||
|
@ -82,7 +82,8 @@ public class RapiDArbitraryAction extends JosmAction {
|
|||
}
|
||||
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.add(new JLabel("<html>" + tr("Enter Lat/Lon to download RapiD data.") + "<br>" + "</html>"),
|
||||
panel.add(new JLabel(
|
||||
"<html>" + tr("Enter Lat/Lon to download {0} data.", MapWithAIPlugin.NAME) + "<br>" + "</html>"),
|
||||
BorderLayout.NORTH);
|
||||
|
||||
SelectAllOnFocusGainedDecorator.decorate(lowerLat);
|
||||
|
@ -107,7 +108,7 @@ public class RapiDArbitraryAction extends JosmAction {
|
|||
final String[] buttons = { tr("Download"), tr("Cancel") };
|
||||
BBox bbox = new BBox();
|
||||
while (!bbox.isInWorld()) {
|
||||
final int option = new RapiDArbitraryDialog(buttons, panel).showDialog().getValue();
|
||||
final int option = new MapWithAIArbitraryDialog(buttons, panel).showDialog().getValue();
|
||||
if (option != 1) {
|
||||
return;
|
||||
}
|
||||
|
@ -125,10 +126,10 @@ public class RapiDArbitraryAction extends JosmAction {
|
|||
|
||||
if (checkbox.isSelected()) {
|
||||
MainApplication.getLayerManager().addLayer(new GpxLayer(
|
||||
DetectTaskingManagerUtils.createTaskingManagerGpxData(bbox), DetectTaskingManagerUtils.RAPID_CROP_AREA));
|
||||
DetectTaskingManagerUtils.createTaskingManagerGpxData(bbox), DetectTaskingManagerUtils.MAPWITHAI_CROP_AREA));
|
||||
}
|
||||
|
||||
RapiDDataUtils.getRapiDData(RapiDDataUtils.getLayer(true), bbox);
|
||||
MapWithAIDataUtils.getMapWithAIData(MapWithAIDataUtils.getLayer(true), bbox);
|
||||
}
|
||||
|
||||
private void setBounds(Bounds b) {
|
|
@ -1,5 +1,5 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.rapid.backend;
|
||||
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
||||
|
||||
import static org.openstreetmap.josm.tools.I18n.tr;
|
||||
|
||||
|
@ -33,7 +33,7 @@ import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
|||
import org.openstreetmap.josm.gui.progress.swing.PleaseWaitProgressMonitor;
|
||||
import org.openstreetmap.josm.io.IllegalDataException;
|
||||
import org.openstreetmap.josm.io.OsmReader;
|
||||
import org.openstreetmap.josm.plugins.rapid.RapiDPlugin;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
|
||||
import org.openstreetmap.josm.spi.preferences.Config;
|
||||
import org.openstreetmap.josm.tools.HttpClient;
|
||||
import org.openstreetmap.josm.tools.HttpClient.Response;
|
||||
|
@ -43,32 +43,32 @@ import org.openstreetmap.josm.tools.Logging;
|
|||
* @author Taylor Smock
|
||||
*
|
||||
*/
|
||||
public final class RapiDDataUtils {
|
||||
public static final String DEFAULT_RAPID_API = "https://www.facebook.com/maps/ml_roads?conflate_with_osm=true&theme=ml_road_vector&collaborator=josm&token=ASb3N5o9HbX8QWn8G_NtHIRQaYv3nuG2r7_f3vnGld3KhZNCxg57IsaQyssIaEw5rfRNsPpMwg4TsnrSJtIJms5m&hash=ASawRla3rBcwEjY4HIY&result_type=road_building_vector_xml&bbox={bbox}";
|
||||
public final class MapWithAIDataUtils {
|
||||
public static final String DEFAULT_MAPWITHAI_API = "https://www.facebook.com/maps/ml_roads?conflate_with_osm=true&theme=ml_road_vector&collaborator=josm&token=ASb3N5o9HbX8QWn8G_NtHIRQaYv3nuG2r7_f3vnGld3KhZNCxg57IsaQyssIaEw5rfRNsPpMwg4TsnrSJtIJms5m&hash=ASawRla3rBcwEjY4HIY&result_type=road_building_vector_xml&bbox={bbox}";
|
||||
public static final int MAXIMUM_SIDE_DIMENSIONS = 1000; // 1 km
|
||||
|
||||
static final Object LAYER_LOCK = new Object();
|
||||
|
||||
private RapiDDataUtils() {
|
||||
private MapWithAIDataUtils() {
|
||||
// Hide the constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first {@link RapiDLayer} that we can find.
|
||||
* Get the first {@link MapWithAILayer} that we can find.
|
||||
*
|
||||
* @param create true if we want to create a new layer
|
||||
* @return A RapiDLayer, or a new RapiDLayer if none exist. May return
|
||||
* @return A MapWithAILayer, or a new MapWithAILayer if none exist. May return
|
||||
* {@code null} if {@code create} is {@code false}.
|
||||
*/
|
||||
public static RapiDLayer getLayer(boolean create) {
|
||||
final List<RapiDLayer> rapidLayers = MainApplication.getLayerManager().getLayersOfType(RapiDLayer.class);
|
||||
RapiDLayer layer = null;
|
||||
public static MapWithAILayer getLayer(boolean create) {
|
||||
final List<MapWithAILayer> mapWithAILayers = MainApplication.getLayerManager().getLayersOfType(MapWithAILayer.class);
|
||||
MapWithAILayer layer = null;
|
||||
synchronized (LAYER_LOCK) {
|
||||
if (rapidLayers.isEmpty() && create) {
|
||||
layer = new RapiDLayer(new DataSet(), RapiDPlugin.NAME, null);
|
||||
if (mapWithAILayers.isEmpty() && create) {
|
||||
layer = new MapWithAILayer(new DataSet(), MapWithAIPlugin.NAME, null);
|
||||
MainApplication.getLayerManager().addLayer(layer);
|
||||
} else if (!rapidLayers.isEmpty()) {
|
||||
layer = rapidLayers.get(0);
|
||||
} else if (!mapWithAILayers.isEmpty()) {
|
||||
layer = mapWithAILayers.get(0);
|
||||
}
|
||||
}
|
||||
return layer;
|
||||
|
@ -86,7 +86,7 @@ public final class RapiDDataUtils {
|
|||
final PleaseWaitProgressMonitor monitor = new PleaseWaitProgressMonitor();
|
||||
monitor.setCancelable(Boolean.FALSE);
|
||||
final List<BBox> bboxes = reduceBBoxSize(bbox);
|
||||
monitor.beginTask(tr("Downloading {0} data", RapiDPlugin.NAME), bboxes.size());
|
||||
monitor.beginTask(tr("Downloading {0} data", MapWithAIPlugin.NAME), bboxes.size());
|
||||
final ForkJoinPool pool = new ForkJoinPool();
|
||||
for (final BBox tbbox : bboxes) {
|
||||
pool.submit(new GetDataRunnable(tbbox, dataSet, monitor));
|
||||
|
@ -103,7 +103,7 @@ public final class RapiDDataUtils {
|
|||
}
|
||||
|
||||
/* Microsoft buildings don't have a source, so we add one */
|
||||
RapiDDataUtils.addSourceTags(dataSet, "building", "Microsoft");
|
||||
MapWithAIDataUtils.addSourceTags(dataSet, "building", "Microsoft");
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ public final class RapiDDataUtils {
|
|||
@Override
|
||||
public void run() {
|
||||
final DataSet temporaryDataSet = getDataReal(getBbox());
|
||||
synchronized (RapiDDataUtils.GetDataRunnable.class) {
|
||||
synchronized (MapWithAIDataUtils.GetDataRunnable.class) {
|
||||
getDataSet().mergeFrom(temporaryDataSet);
|
||||
}
|
||||
monitor.worked(1);
|
||||
|
@ -144,7 +144,7 @@ public final class RapiDDataUtils {
|
|||
private static DataSet getDataReal(BBox bbox) {
|
||||
InputStream inputStream = null;
|
||||
final DataSet dataSet = new DataSet();
|
||||
String urlString = getRapiDURL();
|
||||
String urlString = getMapWithAIUrl();
|
||||
if (DetectTaskingManagerUtils.hasTaskingManagerLayer()) {
|
||||
urlString += "&crop_bbox={crop_bbox}";
|
||||
}
|
||||
|
@ -160,9 +160,9 @@ public final class RapiDDataUtils {
|
|||
if (defaultUserAgent.toString().trim().length() == 0) {
|
||||
defaultUserAgent.append("JOSM");
|
||||
}
|
||||
defaultUserAgent.append(tr("/ {0} {1}", RapiDPlugin.NAME, RapiDPlugin.getVersionInfo()));
|
||||
defaultUserAgent.append(tr("/ {0} {1}", MapWithAIPlugin.NAME, MapWithAIPlugin.getVersionInfo()));
|
||||
client.setHeader("User-Agent", defaultUserAgent.toString());
|
||||
Logging.debug("{0}: Getting {1}", RapiDPlugin.NAME, client.getURL().toString());
|
||||
Logging.debug("{0}: Getting {1}", MapWithAIPlugin.NAME, client.getURL().toString());
|
||||
final Response response = client.connect();
|
||||
inputStream = response.getContent();
|
||||
final DataSet mergeData = OsmReader.parseDataSet(inputStream, null);
|
||||
|
@ -244,93 +244,93 @@ public final class RapiDDataUtils {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the current RapiD url
|
||||
* Get the current MapWithAI url
|
||||
*
|
||||
* @return A RapiD url
|
||||
* @return A MapWithAI url
|
||||
*/
|
||||
public static String getRapiDURL() {
|
||||
final RapiDLayer layer = getLayer(false);
|
||||
String url = Config.getPref().get(RapiDPlugin.NAME.concat(".current_api"), DEFAULT_RAPID_API);
|
||||
if (layer != null && layer.getRapiDUrl() != null) {
|
||||
url = layer.getRapiDUrl();
|
||||
public static String getMapWithAIUrl() {
|
||||
final MapWithAILayer layer = getLayer(false);
|
||||
String url = Config.getPref().get(MapWithAIPlugin.NAME.concat(".current_api"), DEFAULT_MAPWITHAI_API);
|
||||
if (layer != null && layer.getMapWithAIUrl() != null) {
|
||||
url = layer.getMapWithAIUrl();
|
||||
} else {
|
||||
final List<String> urls = getRapiDURLs();
|
||||
final List<String> urls = getMapWithAIURLs();
|
||||
if (!urls.contains(url)) {
|
||||
url = DEFAULT_RAPID_API;
|
||||
setRapiDUrl(DEFAULT_RAPID_API, true);
|
||||
url = DEFAULT_MAPWITHAI_API;
|
||||
setMapWithAIUrl(DEFAULT_MAPWITHAI_API, true);
|
||||
}
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the RapiD url
|
||||
* Set the MapWithAI url
|
||||
*
|
||||
* @param url The url to set as the default
|
||||
* @param permanent {@code true} if we want the setting to persist between
|
||||
* sessions
|
||||
*/
|
||||
public static void setRapiDUrl(String url, boolean permanent) {
|
||||
final RapiDLayer layer = getLayer(false);
|
||||
public static void setMapWithAIUrl(String url, boolean permanent) {
|
||||
final MapWithAILayer layer = getLayer(false);
|
||||
if (permanent) {
|
||||
final List<String> urls = getRapiDURLs();
|
||||
final List<String> urls = getMapWithAIURLs();
|
||||
if (!urls.contains(url)) {
|
||||
urls.add(url);
|
||||
setRapiDURLs(urls);
|
||||
setMapWithAIURLs(urls);
|
||||
}
|
||||
Config.getPref().put(RapiDPlugin.NAME.concat(".current_api"), url);
|
||||
Config.getPref().put(MapWithAIPlugin.NAME.concat(".current_api"), url);
|
||||
} else if (layer != null) {
|
||||
layer.setRapiDUrl(url);
|
||||
layer.setMapWithAIUrl(url);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the RapiD urls
|
||||
* Set the MapWithAI urls
|
||||
*
|
||||
* @param urls A list of URLs
|
||||
*/
|
||||
public static void setRapiDURLs(List<String> urls) {
|
||||
Config.getPref().putList(RapiDPlugin.NAME.concat(".apis"), urls);
|
||||
public static void setMapWithAIURLs(List<String> urls) {
|
||||
Config.getPref().putList(MapWithAIPlugin.NAME.concat(".apis"), urls);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the RapiD urls (or the default)
|
||||
* Get the MapWithAI urls (or the default)
|
||||
*
|
||||
* @return The urls for RapiD endpoints
|
||||
* @return The urls for MapWithAI endpoints
|
||||
*/
|
||||
public static List<String> getRapiDURLs() {
|
||||
return Config.getPref().getList(RapiDPlugin.NAME.concat(".apis"),
|
||||
new ArrayList<>(Arrays.asList(DEFAULT_RAPID_API)));
|
||||
public static List<String> getMapWithAIURLs() {
|
||||
return Config.getPref().getList(MapWithAIPlugin.NAME.concat(".apis"),
|
||||
new ArrayList<>(Arrays.asList(DEFAULT_MAPWITHAI_API)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a paintstyle from the jar (TODO)
|
||||
*/
|
||||
public static void addRapiDPaintStyles() {
|
||||
public static void addMapWithAIPaintStyles() {
|
||||
// TODO figure out how to use the one in the jar file
|
||||
final ExtendedSourceEntry rapid = new ExtendedSourceEntry(SourceType.MAP_PAINT_STYLE, "rapid.mapcss",
|
||||
final ExtendedSourceEntry mapWithAI = new ExtendedSourceEntry(SourceType.MAP_PAINT_STYLE, "rapid.mapcss",
|
||||
"https://gitlab.com/smocktaylor/rapid/raw/master/src/resources/styles/standard/rapid.mapcss");
|
||||
final List<SourceEntry> paintStyles = MapPaintPrefHelper.INSTANCE.get();
|
||||
for (final SourceEntry paintStyle : paintStyles) {
|
||||
if (rapid.url.equals(paintStyle.url)) {
|
||||
if (mapWithAI.url.equals(paintStyle.url)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
paintStyles.add(rapid);
|
||||
paintStyles.add(mapWithAI);
|
||||
MapPaintPrefHelper.INSTANCE.put(paintStyles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether or not a we switch from the RapiD layer to an OSM data layer
|
||||
* Set whether or not a we switch from the MapWithAI layer to an OSM data layer
|
||||
*
|
||||
* @param selected true if we are going to switch layers
|
||||
* @param permanent {@code true} if we want the setting to persist between
|
||||
* sessions
|
||||
*/
|
||||
public static void setSwitchLayers(boolean selected, boolean permanent) {
|
||||
final RapiDLayer layer = getLayer(false);
|
||||
final MapWithAILayer layer = getLayer(false);
|
||||
if (permanent) {
|
||||
Config.getPref().putBoolean(RapiDPlugin.NAME.concat(".autoswitchlayers"), selected);
|
||||
Config.getPref().putBoolean(MapWithAIPlugin.NAME.concat(".autoswitchlayers"), selected);
|
||||
} else if (layer != null) {
|
||||
layer.setSwitchLayers(selected);
|
||||
}
|
||||
|
@ -340,8 +340,8 @@ public final class RapiDDataUtils {
|
|||
* @return {@code true} if we want to automatically switch layers
|
||||
*/
|
||||
public static boolean isSwitchLayers() {
|
||||
final RapiDLayer layer = getLayer(false);
|
||||
boolean returnBoolean = Config.getPref().getBoolean(RapiDPlugin.NAME.concat(".autoswitchlayers"), true);
|
||||
final MapWithAILayer layer = getLayer(false);
|
||||
boolean returnBoolean = Config.getPref().getBoolean(MapWithAIPlugin.NAME.concat(".autoswitchlayers"), true);
|
||||
if (layer != null && layer.isSwitchLayers() != null) {
|
||||
returnBoolean = layer.isSwitchLayers();
|
||||
}
|
||||
|
@ -354,10 +354,10 @@ public final class RapiDDataUtils {
|
|||
* @return The maximum selection. If 0, allow any number.
|
||||
*/
|
||||
public static int getMaximumAddition() {
|
||||
final RapiDLayer rapidLayer = RapiDDataUtils.getLayer(false);
|
||||
Integer defaultReturn = Config.getPref().getInt(RapiDPlugin.NAME.concat(".maximumselection"), 5);
|
||||
if (rapidLayer != null && rapidLayer.getMaximumAddition() != null) {
|
||||
defaultReturn = rapidLayer.getMaximumAddition();
|
||||
final MapWithAILayer mapWithAILayer = MapWithAIDataUtils.getLayer(false);
|
||||
Integer defaultReturn = Config.getPref().getInt(MapWithAIPlugin.NAME.concat(".maximumselection"), 5);
|
||||
if (mapWithAILayer != null && mapWithAILayer.getMaximumAddition() != null) {
|
||||
defaultReturn = mapWithAILayer.getMaximumAddition();
|
||||
}
|
||||
return defaultReturn;
|
||||
}
|
||||
|
@ -371,11 +371,11 @@ public final class RapiDDataUtils {
|
|||
* sessions
|
||||
*/
|
||||
public static void setMaximumAddition(int max, boolean permanent) {
|
||||
final RapiDLayer rapidLayer = getLayer(false);
|
||||
final MapWithAILayer mapWithAILayer = getLayer(false);
|
||||
if (permanent) {
|
||||
Config.getPref().putInt(RapiDPlugin.NAME.concat(".maximumselection"), max);
|
||||
} else if (rapidLayer != null) {
|
||||
rapidLayer.setMaximumAddition(max);
|
||||
Config.getPref().putInt(MapWithAIPlugin.NAME.concat(".maximumselection"), max);
|
||||
} else if (mapWithAILayer != null) {
|
||||
mapWithAILayer.setMaximumAddition(max);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -429,21 +429,21 @@ public final class RapiDDataUtils {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the data for RapiD
|
||||
* Get the data for MapWithAI
|
||||
*
|
||||
* @param layer A pre-existing {@link RapiDLayer}
|
||||
* @param layer A pre-existing {@link MapWithAILayer}
|
||||
* @param bboxes The bboxes to get the data in
|
||||
*/
|
||||
public static void getRapiDData(RapiDLayer layer, Collection<BBox> bboxes) {
|
||||
final DataSet rapidSet = layer.getDataSet();
|
||||
final List<BBox> rapidBounds = rapidSet.getDataSourceBounds().stream().map(Bounds::toBBox).collect(Collectors.toList());
|
||||
public static void getMapWithAIData(MapWithAILayer layer, Collection<BBox> bboxes) {
|
||||
final DataSet mapWithAISet = layer.getDataSet();
|
||||
final List<BBox> mapWithAIBounds = mapWithAISet.getDataSourceBounds().stream().map(Bounds::toBBox).collect(Collectors.toList());
|
||||
final List<BBox> editSetBBoxes = bboxes.stream()
|
||||
.filter(bbox -> rapidBounds.stream().noneMatch(tBBox -> tBBox.bounds(bbox)))
|
||||
.filter(bbox -> mapWithAIBounds.stream().noneMatch(tBBox -> tBBox.bounds(bbox)))
|
||||
.collect(Collectors.toList());
|
||||
final ForkJoinPool pool = new ForkJoinPool();
|
||||
for (final BBox bbox : editSetBBoxes) {
|
||||
// TODO remove bounds that are already downloaded
|
||||
if (rapidBounds.parallelStream().filter(bbox::bounds).count() == 0) {
|
||||
if (mapWithAIBounds.parallelStream().filter(bbox::bounds).count() == 0) {
|
||||
pool.execute(() -> {
|
||||
final DataSet newData = getData(bbox);
|
||||
synchronized (LAYER_LOCK) {
|
||||
|
@ -468,36 +468,36 @@ public final class RapiDDataUtils {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the data for RapiD
|
||||
* Get the data for MapWithAI
|
||||
*
|
||||
* @param layer A pre-existing {@link RapiDLayer}
|
||||
* @param layer A pre-existing {@link MapWithAILayer}
|
||||
* @param bboxes The bboxes to get the data in
|
||||
*/
|
||||
public static void getRapiDData(RapiDLayer layer, BBox... bboxes) {
|
||||
getRapiDData(layer, Arrays.asList(bboxes));
|
||||
public static void getMapWithAIData(MapWithAILayer layer, BBox... bboxes) {
|
||||
getMapWithAIData(layer, Arrays.asList(bboxes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data for RapiD
|
||||
* Get the data for MapWithAI
|
||||
*
|
||||
* @param layer A pre-existing {@link RapiDLayer}
|
||||
* @param layer A pre-existing {@link MapWithAILayer}
|
||||
* @param osmLayer The osm datalayer with a set of bounds
|
||||
*/
|
||||
public static void getRapiDData(RapiDLayer layer, OsmDataLayer osmLayer) {
|
||||
getRapiDData(layer,
|
||||
public static void getMapWithAIData(MapWithAILayer layer, OsmDataLayer osmLayer) {
|
||||
getMapWithAIData(layer,
|
||||
osmLayer.getDataSet().getDataSourceBounds().stream().map(Bounds::toBBox).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data for a {@link RapiDLayer}
|
||||
* Get data for a {@link MapWithAILayer}
|
||||
*
|
||||
* @param layer The {@link RapiDLayer} to add data to
|
||||
* @param layer The {@link MapWithAILayer} to add data to
|
||||
*/
|
||||
public static void getRapiDData(RapiDLayer layer) {
|
||||
public static void getMapWithAIData(MapWithAILayer layer) {
|
||||
final List<OsmDataLayer> osmLayers = MainApplication.getLayerManager().getLayersOfType(OsmDataLayer.class);
|
||||
for (final OsmDataLayer osmLayer : osmLayers) {
|
||||
if (!osmLayer.isLocked()) {
|
||||
getRapiDData(layer, osmLayer);
|
||||
getMapWithAIData(layer, osmLayer);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.rapid.backend;
|
||||
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
||||
|
||||
import static org.openstreetmap.josm.tools.I18n.tr;
|
||||
|
||||
|
@ -17,19 +17,19 @@ import org.openstreetmap.josm.tools.GBC;
|
|||
* @author Taylor Smock
|
||||
*
|
||||
*/
|
||||
public class RapiDLayer extends OsmDataLayer {
|
||||
public class MapWithAILayer extends OsmDataLayer {
|
||||
private Integer maximumAddition = null;
|
||||
private String url = null;
|
||||
private Boolean switchLayers = null;
|
||||
|
||||
/**
|
||||
* Create a new RapiD layer
|
||||
* Create a new MapWithAI layer
|
||||
*
|
||||
* @param data OSM data from rapid
|
||||
* @param data OSM data from MapWithAI
|
||||
* @param name Layer name
|
||||
* @param associatedFile an associated file (can be null)
|
||||
*/
|
||||
public RapiDLayer(DataSet data, String name, File associatedFile) {
|
||||
public MapWithAILayer(DataSet data, String name, File associatedFile) {
|
||||
super(data, name, associatedFile);
|
||||
this.lock();
|
||||
data.setUploadPolicy(UploadPolicy.BLOCKED);
|
||||
|
@ -48,11 +48,11 @@ public class RapiDLayer extends OsmDataLayer {
|
|||
return maximumAddition;
|
||||
}
|
||||
|
||||
public void setRapiDUrl(String url) {
|
||||
public void setMapWithAIUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getRapiDUrl() {
|
||||
public String getMapWithAIUrl() {
|
||||
return url;
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.openstreetmap.josm.plugins.rapid.backend;
|
||||
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
||||
|
||||
import static org.openstreetmap.josm.tools.I18n.tr;
|
||||
|
||||
|
@ -14,31 +14,34 @@ import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
|||
import org.openstreetmap.josm.gui.MainApplication;
|
||||
import org.openstreetmap.josm.gui.layer.Layer;
|
||||
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
||||
import org.openstreetmap.josm.plugins.rapid.RapiDPlugin;
|
||||
import org.openstreetmap.josm.plugins.rapid.commands.RapiDAddCommand;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.commands.MapWithAIAddCommand;
|
||||
import org.openstreetmap.josm.tools.Shortcut;
|
||||
|
||||
public class RapiDMoveAction extends JosmAction {
|
||||
public class MapWithAIMoveAction extends JosmAction {
|
||||
/** UID for abstract action */
|
||||
private static final long serialVersionUID = 319374598;
|
||||
|
||||
public RapiDMoveAction() {
|
||||
super(tr("{0}: Add selected data", RapiDPlugin.NAME), null, tr("Add data from RapiD"),
|
||||
public MapWithAIMoveAction() {
|
||||
super(tr("{0}: Add selected data", MapWithAIPlugin.NAME), null, tr("Add data from {0}", MapWithAIPlugin.NAME),
|
||||
Shortcut.registerShortcut(
|
||||
"data:rapidadd", tr("Rapid: {0}", tr("Add selected data")), KeyEvent.VK_A, Shortcut.SHIFT), true);
|
||||
"data:mapwithaiadd", tr("{0}: {1}", MapWithAIPlugin.NAME, tr("Add selected data")),
|
||||
KeyEvent.VK_A,
|
||||
Shortcut.SHIFT),
|
||||
true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
for (final RapiDLayer rapid : MainApplication.getLayerManager().getLayersOfType(RapiDLayer.class)) {
|
||||
for (final MapWithAILayer mapWithAI : MainApplication.getLayerManager().getLayersOfType(MapWithAILayer.class)) {
|
||||
final List<OsmDataLayer> osmLayers = MainApplication.getLayerManager().getLayersOfType(OsmDataLayer.class);
|
||||
OsmDataLayer editLayer = null;
|
||||
final int maxAddition = RapiDDataUtils.getMaximumAddition();
|
||||
final int maxAddition = MapWithAIDataUtils.getMaximumAddition();
|
||||
Collection<OsmPrimitive> selected;
|
||||
if (maxAddition > 0) {
|
||||
selected = rapid.getDataSet().getSelected().stream().limit(maxAddition).collect(Collectors.toList());
|
||||
selected = mapWithAI.getDataSet().getSelected().stream().limit(maxAddition).collect(Collectors.toList());
|
||||
} else {
|
||||
selected = rapid.getDataSet().getSelected();
|
||||
selected = mapWithAI.getDataSet().getSelected();
|
||||
}
|
||||
for (final OsmDataLayer osmLayer : osmLayers) {
|
||||
if (!osmLayer.isLocked() && osmLayer.isVisible() && osmLayer.isUploadable()
|
||||
|
@ -48,9 +51,9 @@ public class RapiDMoveAction extends JosmAction {
|
|||
}
|
||||
}
|
||||
if (editLayer != null) {
|
||||
final RapiDAddCommand command = new RapiDAddCommand(rapid, editLayer, selected);
|
||||
final MapWithAIAddCommand command = new MapWithAIAddCommand(mapWithAI, editLayer, selected);
|
||||
UndoRedoHandler.getInstance().add(command);
|
||||
if (RapiDDataUtils.isSwitchLayers()) {
|
||||
if (MapWithAIDataUtils.isSwitchLayers()) {
|
||||
MainApplication.getLayerManager().setActiveLayer(editLayer);
|
||||
}
|
||||
}
|
||||
|
@ -74,9 +77,9 @@ public class RapiDMoveAction extends JosmAction {
|
|||
private boolean checkIfActionEnabled() {
|
||||
boolean returnValue = false;
|
||||
final Layer active = getLayerManager().getActiveLayer();
|
||||
if (active instanceof RapiDLayer) {
|
||||
final RapiDLayer rapid = (RapiDLayer) active;
|
||||
final Collection<OsmPrimitive> selection = rapid.getDataSet().getAllSelected();
|
||||
if (active instanceof MapWithAILayer) {
|
||||
final MapWithAILayer mapWithAILayer = (MapWithAILayer) active;
|
||||
final Collection<OsmPrimitive> selection = mapWithAILayer.getDataSet().getAllSelected();
|
||||
returnValue = selection != null && !selection.isEmpty();
|
||||
}
|
||||
return returnValue;
|
|
@ -1,5 +1,5 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.rapid.backend;
|
||||
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
||||
|
||||
import static org.openstreetmap.josm.tools.I18n.tr;
|
||||
|
||||
|
@ -12,9 +12,9 @@ import org.openstreetmap.josm.gui.layer.GpxLayer;
|
|||
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
||||
import org.openstreetmap.josm.io.remotecontrol.PermissionPrefWithDefault;
|
||||
import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler;
|
||||
import org.openstreetmap.josm.plugins.rapid.RapiDPlugin;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
|
||||
|
||||
public class RapiDRemoteControl extends RequestHandler.RawURLParseRequestHandler {
|
||||
public class MapWithAIRemoteControl extends RequestHandler.RawURLParseRequestHandler {
|
||||
|
||||
private BBox download = null;
|
||||
private BBox crop = null;
|
||||
|
@ -25,7 +25,7 @@ public class RapiDRemoteControl extends RequestHandler.RawURLParseRequestHandler
|
|||
private static final String MAX_OBJ = "max_obj";
|
||||
private static final String SWITCH_LAYER = "switch_layer";
|
||||
|
||||
public RapiDRemoteControl() {
|
||||
public MapWithAIRemoteControl() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
@ -77,28 +77,28 @@ public class RapiDRemoteControl extends RequestHandler.RawURLParseRequestHandler
|
|||
protected void handleRequest() throws RequestHandlerErrorException, RequestHandlerBadRequestException {
|
||||
if (crop != null && crop.isInWorld()) {
|
||||
MainApplication.getLayerManager().addLayer(new GpxLayer(
|
||||
DetectTaskingManagerUtils.createTaskingManagerGpxData(crop), DetectTaskingManagerUtils.RAPID_CROP_AREA));
|
||||
DetectTaskingManagerUtils.createTaskingManagerGpxData(crop), DetectTaskingManagerUtils.MAPWITHAI_CROP_AREA));
|
||||
}
|
||||
|
||||
final RapiDLayer layer = RapiDDataUtils.getLayer(true);
|
||||
final MapWithAILayer layer = MapWithAIDataUtils.getLayer(true);
|
||||
|
||||
if (maxObj != null) {
|
||||
RapiDDataUtils.setMaximumAddition(maxObj, false);
|
||||
MapWithAIDataUtils.setMaximumAddition(maxObj, false);
|
||||
}
|
||||
if (url != null) {
|
||||
RapiDDataUtils.setRapiDUrl(url, false);
|
||||
MapWithAIDataUtils.setMapWithAIUrl(url, false);
|
||||
}
|
||||
if (switchLayer != null) {
|
||||
RapiDDataUtils.setSwitchLayers(switchLayer, false);
|
||||
MapWithAIDataUtils.setSwitchLayers(switchLayer, false);
|
||||
}
|
||||
|
||||
if (download != null && download.isInWorld()) {
|
||||
RapiDDataUtils.getRapiDData(layer, download);
|
||||
MapWithAIDataUtils.getMapWithAIData(layer, download);
|
||||
} else if (MainApplication.getLayerManager().getLayersOfType(OsmDataLayer.class).stream()
|
||||
.anyMatch(tLayer -> !(tLayer instanceof RapiDLayer))) {
|
||||
RapiDDataUtils.getRapiDData(layer);
|
||||
.anyMatch(tLayer -> !(tLayer instanceof MapWithAILayer))) {
|
||||
MapWithAIDataUtils.getMapWithAIData(layer);
|
||||
} else if (crop != null && crop.isInWorld()) {
|
||||
RapiDDataUtils.getRapiDData(layer, crop);
|
||||
MapWithAIDataUtils.getMapWithAIData(layer, crop);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ public class RapiDRemoteControl extends RequestHandler.RawURLParseRequestHandler
|
|||
sb.append(url);
|
||||
sb.append(")");
|
||||
sb.append(br);
|
||||
sb.append(tr("{0} will ", RapiDPlugin.NAME));
|
||||
sb.append(tr("{0} will ", MapWithAIPlugin.NAME));
|
||||
if (!switchLayer) {
|
||||
sb.append(tr("not "));
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.rapid.commands;
|
||||
package org.openstreetmap.josm.plugins.mapwithai.commands;
|
||||
|
||||
import static org.openstreetmap.josm.tools.I18n.tr;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.rapid.commands;
|
||||
package org.openstreetmap.josm.plugins.mapwithai.commands;
|
||||
|
||||
import static org.openstreetmap.josm.tools.I18n.tr;
|
||||
|
||||
|
@ -29,7 +29,7 @@ import org.openstreetmap.josm.gui.MainApplication;
|
|||
import org.openstreetmap.josm.gui.io.DownloadPrimitivesTask;
|
||||
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
||||
import org.openstreetmap.josm.gui.progress.swing.PleaseWaitProgressMonitor;
|
||||
import org.openstreetmap.josm.plugins.rapid.RapiDPlugin;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
|
||||
import org.openstreetmap.josm.tools.Geometry;
|
||||
import org.openstreetmap.josm.tools.Logging;
|
||||
import org.openstreetmap.josm.tools.Pair;
|
||||
|
@ -63,7 +63,7 @@ public class CreateConnectionsCommand extends Command {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create connections based off of current RapiD syntax
|
||||
* Create connections based off of current MapWithAI syntax
|
||||
*
|
||||
* @param dataSet The {@link DataSet} that should have the primitives we are
|
||||
* connecting to
|
||||
|
@ -114,7 +114,7 @@ public class CreateConnectionsCommand extends Command {
|
|||
private static List<Command> duplicateNode(DataSet dataSet, Node node) {
|
||||
final OsmPrimitive[] primitiveConnections = getPrimitives(dataSet, node.get(DUPE_KEY));
|
||||
if (primitiveConnections.length != 1) {
|
||||
Logging.error("{0}: {3} connection connected to more than one node? ({3}={1})", RapiDPlugin.NAME,
|
||||
Logging.error("{0}: {3} connection connected to more than one node? ({3}={1})", MapWithAIPlugin.NAME,
|
||||
node.get(DUPE_KEY), DUPE_KEY);
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ public class CreateConnectionsCommand extends Command {
|
|||
type = OsmPrimitiveType.RELATION;
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
tr("{0}: We don't know how to handle {1} types", RapiDPlugin.NAME, firstChar));
|
||||
tr("{0}: We don't know how to handle {1} types", MapWithAIPlugin.NAME, firstChar));
|
||||
}
|
||||
primitiveConnections[i] = dataSet.getPrimitiveById(id, type);
|
||||
if (primitiveConnections[i] == null) {
|
||||
|
@ -249,7 +249,7 @@ public class CreateConnectionsCommand extends Command {
|
|||
}
|
||||
|
||||
private static String getRealDescriptionText() {
|
||||
return tr("Create connections from {0} data", RapiDPlugin.NAME);
|
||||
return tr("Create connections from {0} data", MapWithAIPlugin.NAME);
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,4 +1,4 @@
|
|||
package org.openstreetmap.josm.plugins.rapid.commands;
|
||||
package org.openstreetmap.josm.plugins.mapwithai.commands;
|
||||
|
||||
import static org.openstreetmap.josm.tools.I18n.tr;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.rapid.commands;
|
||||
package org.openstreetmap.josm.plugins.mapwithai.commands;
|
||||
|
||||
import static org.openstreetmap.josm.tools.I18n.tr;
|
||||
|
||||
|
@ -13,39 +13,39 @@ import org.openstreetmap.josm.command.SequenceCommand;
|
|||
import org.openstreetmap.josm.data.osm.DataSet;
|
||||
import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
||||
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
||||
import org.openstreetmap.josm.plugins.rapid.RapiDPlugin;
|
||||
import org.openstreetmap.josm.plugins.rapid.backend.RapiDDataUtils;
|
||||
import org.openstreetmap.josm.plugins.rapid.backend.RapiDLayer;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIDataUtils;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAILayer;
|
||||
import org.openstreetmap.josm.tools.Logging;
|
||||
|
||||
public class RapiDAddCommand extends Command implements Runnable {
|
||||
public class MapWithAIAddCommand extends Command implements Runnable {
|
||||
DataSet editable;
|
||||
DataSet rapid;
|
||||
DataSet mapWithAI;
|
||||
Collection<OsmPrimitive> primitives;
|
||||
Command command = null;
|
||||
|
||||
/**
|
||||
* Add primitives from RapiD to the OSM data layer
|
||||
* Add primitives from MapWithAI to the OSM data layer
|
||||
*
|
||||
* @param rapidLayer The rapid layer
|
||||
* @param editableLayer The OSM layer
|
||||
* @param selection The primitives to add from RapiD
|
||||
* @param mapWithAILayer The MapWithAI layer
|
||||
* @param editableLayer The OSM layer
|
||||
* @param selection The primitives to add from MapWithAI
|
||||
*/
|
||||
public RapiDAddCommand(RapiDLayer rapidLayer, OsmDataLayer editLayer, Collection<OsmPrimitive> selection) {
|
||||
this(rapidLayer.getDataSet(), editLayer.getDataSet(), selection);
|
||||
public MapWithAIAddCommand(MapWithAILayer mapWithAILayer, OsmDataLayer editLayer, Collection<OsmPrimitive> selection) {
|
||||
this(mapWithAILayer.getDataSet(), editLayer.getDataSet(), selection);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add primitives from RapiD to the OSM data layer
|
||||
* Add primitives from MapWithAI to the OSM data layer
|
||||
*
|
||||
* @param rapid The rapid dataset
|
||||
* @param mapWithAI The MapWithAI dataset
|
||||
* @param editable The OSM dataset
|
||||
* @param selection The primitives to add from RapiD
|
||||
* @param selection The primitives to add from MapWithAI
|
||||
*/
|
||||
public RapiDAddCommand(DataSet rapid, DataSet editable, Collection<OsmPrimitive> selection) {
|
||||
super(rapid);
|
||||
this.rapid = rapid;
|
||||
public MapWithAIAddCommand(DataSet mapWithAI, DataSet editable, Collection<OsmPrimitive> selection) {
|
||||
super(mapWithAI);
|
||||
this.mapWithAI = mapWithAI;
|
||||
this.editable = editable;
|
||||
this.primitives = selection;
|
||||
}
|
||||
|
@ -62,20 +62,20 @@ public class RapiDAddCommand extends Command implements Runnable {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
if (rapid.equals(editable)) {
|
||||
Logging.error("{0}: DataSet rapid ({1}) should not be the same as DataSet editable ({2})", RapiDPlugin.NAME,
|
||||
rapid, editable);
|
||||
if (mapWithAI.equals(editable)) {
|
||||
Logging.error("{0}: DataSet mapWithAI ({1}) should not be the same as DataSet editable ({2})", MapWithAIPlugin.NAME,
|
||||
mapWithAI, editable);
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
synchronized (this) {
|
||||
final boolean locked = rapid.isLocked();
|
||||
final boolean locked = mapWithAI.isLocked();
|
||||
try {
|
||||
if (locked) {
|
||||
rapid.unlock();
|
||||
mapWithAI.unlock();
|
||||
}
|
||||
final Command movePrimitivesCommand = new MovePrimitiveDataSetCommand(editable, rapid, primitives);
|
||||
final Command movePrimitivesCommand = new MovePrimitiveDataSetCommand(editable, mapWithAI, primitives);
|
||||
final List<OsmPrimitive> allPrimitives = new ArrayList<>();
|
||||
RapiDDataUtils.addPrimitivesToCollection(allPrimitives, primitives);
|
||||
MapWithAIDataUtils.addPrimitivesToCollection(allPrimitives, primitives);
|
||||
final Command createConnectionsCommand = createConnections(editable, allPrimitives);
|
||||
if (command == null) { // needed for undo/redo (don't create a new command)
|
||||
command = new SequenceCommand(getDescriptionText(), movePrimitivesCommand, createConnectionsCommand);
|
||||
|
@ -83,14 +83,14 @@ public class RapiDAddCommand extends Command implements Runnable {
|
|||
command.executeCommand();
|
||||
} finally {
|
||||
if (locked) {
|
||||
rapid.lock();
|
||||
mapWithAI.lock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create connections based off of current RapiD syntax
|
||||
* Create connections based off of current MapWithAI syntax
|
||||
*
|
||||
* @param dataSet The {@link DataSet} that should have the primitives we are
|
||||
* connecting to
|
||||
|
@ -103,10 +103,10 @@ public class RapiDAddCommand extends Command implements Runnable {
|
|||
|
||||
@Override
|
||||
public void undoCommand() {
|
||||
final boolean locked = rapid.isLocked();
|
||||
final boolean locked = mapWithAI.isLocked();
|
||||
try {
|
||||
if (locked) {
|
||||
rapid.unlock();
|
||||
mapWithAI.unlock();
|
||||
}
|
||||
synchronized (this) {
|
||||
if (command != null) {
|
||||
|
@ -115,14 +115,14 @@ public class RapiDAddCommand extends Command implements Runnable {
|
|||
}
|
||||
} finally {
|
||||
if (locked) {
|
||||
rapid.lock();
|
||||
mapWithAI.lock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescriptionText() {
|
||||
return tr("Add object from RapiD");
|
||||
return tr("Add object from {0}", MapWithAIPlugin.NAME);
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,5 +1,5 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.rapid.commands;
|
||||
package org.openstreetmap.josm.plugins.mapwithai.commands;
|
||||
|
||||
import static org.openstreetmap.josm.tools.I18n.tr;
|
||||
import static org.openstreetmap.josm.tools.I18n.trn;
|
||||
|
@ -16,7 +16,7 @@ import org.openstreetmap.josm.data.osm.DataSet;
|
|||
import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
||||
import org.openstreetmap.josm.data.osm.PrimitiveData;
|
||||
import org.openstreetmap.josm.data.osm.visitor.MergeSourceBuildingVisitor;
|
||||
import org.openstreetmap.josm.plugins.rapid.RapiDPlugin;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
|
||||
import org.openstreetmap.josm.tools.Logging;
|
||||
|
||||
/**
|
||||
|
@ -30,7 +30,7 @@ public class MovePrimitiveDataSetCommand extends Command {
|
|||
public MovePrimitiveDataSetCommand(DataSet to, DataSet from, Collection<OsmPrimitive> primitives) {
|
||||
super(to);
|
||||
if (from == null || to.isLocked() || from.isLocked() || to.equals(from)) {
|
||||
Logging.error("{0}: Cannot move primitives from {1} to {2}", RapiDPlugin.NAME, from, to);
|
||||
Logging.error("{0}: Cannot move primitives from {1} to {2}", MapWithAIPlugin.NAME, from, to);
|
||||
} else {
|
||||
command = moveCollection(from, to, primitives);
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.rapid;
|
||||
package org.openstreetmap.josm.plugins.mapwithai;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
|
@ -21,13 +21,13 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|||
/**
|
||||
* @author Taylor Smock
|
||||
*/
|
||||
public class RapiDPluginTest {
|
||||
public class MapWithAIPluginTest {
|
||||
@Rule
|
||||
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
||||
public JOSMTestRules test = new JOSMTestRules().preferences().main();
|
||||
|
||||
public PluginInformation info;
|
||||
public RapiDPlugin plugin;
|
||||
public MapWithAIPlugin plugin;
|
||||
|
||||
private static final String VERSION = "no-such-version";
|
||||
|
||||
|
@ -37,39 +37,39 @@ public class RapiDPluginTest {
|
|||
@Before
|
||||
public void setUp() throws Exception {
|
||||
final InputStream in = new ByteArrayInputStream("".getBytes(StandardCharsets.UTF_8));
|
||||
info = new PluginInformation(in, "Rapid", null);
|
||||
info = new PluginInformation(in, "MapWithAI", null);
|
||||
info.localversion = VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link RapiDPlugin#getPreferenceSetting()}.
|
||||
* Test method for {@link MapWithAIPlugin#getPreferenceSetting()}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetPreferenceSetting() {
|
||||
plugin = new RapiDPlugin(info);
|
||||
Assert.assertTrue(plugin.getPreferenceSetting() instanceof RapiDPreferences);
|
||||
plugin = new MapWithAIPlugin(info);
|
||||
Assert.assertTrue(plugin.getPreferenceSetting() instanceof MapWithAIPreferences);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link RapiDPlugin#RapiDPlugin(PluginInformation)}.
|
||||
* Test method for {@link MapWithAIPlugin#MapWithAIPlugin(PluginInformation)}.
|
||||
*/
|
||||
@Test
|
||||
public void testRapiDPlugin() {
|
||||
public void testMapWithAIPlugin() {
|
||||
final JMenu dataMenu = MainApplication.getMenu().dataMenu;
|
||||
final int originalPaintStyles = MapPaintPrefHelper.INSTANCE.get().size();
|
||||
final int dataMenuSize = dataMenu.getMenuComponentCount();
|
||||
plugin = new RapiDPlugin(info);
|
||||
plugin = new MapWithAIPlugin(info);
|
||||
Assert.assertEquals(dataMenuSize + 3, dataMenu.getMenuComponentCount());
|
||||
Assert.assertEquals(originalPaintStyles + 1, MapPaintPrefHelper.INSTANCE.get().size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link RapiDPlugin#getVersionInfo()}.
|
||||
* Test method for {@link MapWithAIPlugin#getVersionInfo()}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetVersionInfo() {
|
||||
plugin = new RapiDPlugin(info); // needs to be called for version info to be initialized.
|
||||
Assert.assertEquals(VERSION, RapiDPlugin.getVersionInfo());
|
||||
plugin = new MapWithAIPlugin(info); // needs to be called for version info to be initialized.
|
||||
Assert.assertEquals(VERSION, MapWithAIPlugin.getVersionInfo());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.rapid;
|
||||
package org.openstreetmap.josm.plugins.mapwithai;
|
||||
|
||||
import javax.swing.SpinnerNumberModel;
|
||||
|
||||
|
@ -8,7 +8,8 @@ import org.junit.Before;
|
|||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
|
||||
import org.openstreetmap.josm.plugins.rapid.backend.RapiDDataUtils;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPreferences;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIDataUtils;
|
||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
@ -17,23 +18,23 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|||
* @author Taylor Smock
|
||||
*
|
||||
*/
|
||||
public class RapiDPreferencesTest {
|
||||
public class MapWithAIPreferencesTest {
|
||||
@Rule
|
||||
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
||||
public JOSMTestRules test = new JOSMTestRules().preferences().main();
|
||||
|
||||
private RapiDPreferences preferences;
|
||||
private MapWithAIPreferences preferences;
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
preferences = new RapiDPreferences();
|
||||
preferences = new MapWithAIPreferences();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link RapiDPreferences#addGui(PreferenceTabbedPane)}.
|
||||
* Test method for {@link MapWithAIPreferences#addGui(PreferenceTabbedPane)}.
|
||||
*/
|
||||
@Test
|
||||
public void testAddGui() {
|
||||
|
@ -46,16 +47,16 @@ public class RapiDPreferencesTest {
|
|||
Assert.assertEquals(tabs + 1, pane.getPluginPreference().getTabPane().getTabCount());
|
||||
Assert.assertEquals(pane.getPluginPreference(), preferences.getTabPreferenceSetting(pane));
|
||||
|
||||
final boolean switchLayers = RapiDDataUtils.isSwitchLayers();
|
||||
final boolean switchLayers = MapWithAIDataUtils.isSwitchLayers();
|
||||
|
||||
Assert.assertEquals(switchLayers, preferences.getSwitchLayerCheckBox().isSelected());
|
||||
preferences.ok();
|
||||
Assert.assertEquals(switchLayers, RapiDDataUtils.isSwitchLayers());
|
||||
Assert.assertEquals(switchLayers, MapWithAIDataUtils.isSwitchLayers());
|
||||
|
||||
preferences.getSwitchLayerCheckBox().setSelected(!switchLayers);
|
||||
Assert.assertNotEquals(!switchLayers, RapiDDataUtils.isSwitchLayers());
|
||||
Assert.assertNotEquals(!switchLayers, MapWithAIDataUtils.isSwitchLayers());
|
||||
preferences.ok();
|
||||
Assert.assertEquals(!switchLayers, RapiDDataUtils.isSwitchLayers());
|
||||
Assert.assertEquals(!switchLayers, MapWithAIDataUtils.isSwitchLayers());
|
||||
|
||||
final Object tmp = preferences.getMaximumAdditionSpinner().getModel();
|
||||
SpinnerNumberModel spinnerModel = null;
|
||||
|
@ -63,18 +64,18 @@ public class RapiDPreferencesTest {
|
|||
spinnerModel = (SpinnerNumberModel) tmp;
|
||||
}
|
||||
Assert.assertNotNull(spinnerModel);
|
||||
final Number currentNumber = RapiDDataUtils.getMaximumAddition();
|
||||
final Number currentNumber = MapWithAIDataUtils.getMaximumAddition();
|
||||
Assert.assertEquals(currentNumber.intValue(), spinnerModel.getNumber().intValue());
|
||||
spinnerModel.setValue(currentNumber.intValue() + 3);
|
||||
Assert.assertNotEquals(spinnerModel.getNumber().intValue(), RapiDDataUtils.getMaximumAddition());
|
||||
Assert.assertNotEquals(spinnerModel.getNumber().intValue(), MapWithAIDataUtils.getMaximumAddition());
|
||||
preferences.ok();
|
||||
Assert.assertEquals(spinnerModel.getNumber().intValue(), RapiDDataUtils.getMaximumAddition());
|
||||
Assert.assertEquals(spinnerModel.getNumber().intValue(), MapWithAIDataUtils.getMaximumAddition());
|
||||
|
||||
Assert.assertNotNull(preferences.getPossibleRapidApiUrl().getSelectedItem());
|
||||
Assert.assertNotNull(preferences.getPossibleMapWithAIApiUrl().getSelectedItem());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link RapiDPreferences#isExpert()}.
|
||||
* Test method for {@link MapWithAIPreferences#isExpert()}.
|
||||
*/
|
||||
@Test
|
||||
public void testIsExpert() {
|
|
@ -1,5 +1,5 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.rapid.backend;
|
||||
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
|
@ -10,6 +10,7 @@ import org.openstreetmap.josm.data.gpx.WayPoint;
|
|||
import org.openstreetmap.josm.data.osm.BBox;
|
||||
import org.openstreetmap.josm.gui.MainApplication;
|
||||
import org.openstreetmap.josm.gui.layer.GpxLayer;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.backend.DetectTaskingManagerUtils;
|
||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
@ -65,7 +66,7 @@ public class DetectTaskingManagerUtilsTest {
|
|||
|
||||
final BBox bbox = new BBox(0, 0, 1, 1);
|
||||
MainApplication.getLayerManager().addLayer(new GpxLayer(DetectTaskingManagerUtils.createTaskingManagerGpxData(bbox),
|
||||
DetectTaskingManagerUtils.RAPID_CROP_AREA));
|
||||
DetectTaskingManagerUtils.MAPWITHAI_CROP_AREA));
|
||||
|
||||
Assert.assertTrue(DetectTaskingManagerUtils.hasTaskingManagerLayer());
|
||||
Assert.assertTrue(DetectTaskingManagerUtils.getTaskingManagerBBox().bounds(bbox));
|
|
@ -0,0 +1,66 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.openstreetmap.josm.data.Bounds;
|
||||
import org.openstreetmap.josm.data.DataSource;
|
||||
import org.openstreetmap.josm.data.osm.DataSet;
|
||||
import org.openstreetmap.josm.gui.MainApplication;
|
||||
import org.openstreetmap.josm.gui.layer.Layer;
|
||||
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIDataUtils;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAILayer;
|
||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
public class MapWithAIActionTest {
|
||||
@Rule
|
||||
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
||||
public JOSMTestRules test = new JOSMTestRules().preferences().main().projection();
|
||||
|
||||
@Test
|
||||
public void testGetLayer() {
|
||||
Layer mapWithAILayer = MapWithAIDataUtils.getLayer(false);
|
||||
Assert.assertNull(mapWithAILayer);
|
||||
|
||||
mapWithAILayer = MapWithAIDataUtils.getLayer(true);
|
||||
Assert.assertEquals(MapWithAILayer.class, mapWithAILayer.getClass());
|
||||
|
||||
Layer tMapWithAI = MapWithAIDataUtils.getLayer(false);
|
||||
Assert.assertSame(mapWithAILayer, tMapWithAI);
|
||||
|
||||
tMapWithAI = MapWithAIDataUtils.getLayer(true);
|
||||
Assert.assertSame(mapWithAILayer, tMapWithAI);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetData() {
|
||||
final MapWithAILayer mapWithAILayer = MapWithAIDataUtils.getLayer(true);
|
||||
final OsmDataLayer osm = new OsmDataLayer(new DataSet(), "test", null);
|
||||
MainApplication.getLayerManager().addLayer(osm);
|
||||
MapWithAIDataUtils.getMapWithAIData(mapWithAILayer, osm);
|
||||
|
||||
Assert.assertTrue(mapWithAILayer.getDataSet().getDataSourceBounds().isEmpty());
|
||||
|
||||
osm.getDataSet().addDataSource(new DataSource(new Bounds(0, 0, 0.001, 0.001), "random test"));
|
||||
|
||||
osm.lock();
|
||||
MapWithAIDataUtils.getMapWithAIData(mapWithAILayer);
|
||||
Assert.assertTrue(mapWithAILayer.getDataSet().getDataSourceBounds().isEmpty());
|
||||
osm.unlock();
|
||||
|
||||
MapWithAIDataUtils.getMapWithAIData(mapWithAILayer);
|
||||
Assert.assertFalse(mapWithAILayer.getDataSet().getDataSourceBounds().isEmpty());
|
||||
Assert.assertEquals(1, mapWithAILayer.getDataSet().getDataSourceBounds().parallelStream().distinct().count());
|
||||
|
||||
osm.getDataSet().addDataSource(new DataSource(new Bounds(-0.001, -0.001, 0, 0), "random test"));
|
||||
MapWithAIDataUtils.getMapWithAIData(mapWithAILayer);
|
||||
Assert.assertEquals(2, mapWithAILayer.getDataSet().getDataSourceBounds().parallelStream().distinct().count());
|
||||
|
||||
MapWithAIDataUtils.getMapWithAIData(mapWithAILayer);
|
||||
Assert.assertEquals(2, mapWithAILayer.getDataSet().getDataSourceBounds().parallelStream().distinct().count());
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.rapid.backend;
|
||||
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
@ -27,24 +27,24 @@ import org.openstreetmap.josm.testutils.JOSMTestRules;
|
|||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
public class RapiDDataUtilsTest {
|
||||
public class MapWithAIDataUtilsTest {
|
||||
@Rule
|
||||
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
||||
public JOSMTestRules test = new JOSMTestRules().preferences().main().projection();
|
||||
|
||||
/**
|
||||
* This gets data from RapiD. This test may fail if someone adds the data to
|
||||
* This gets data from MapWithAI. This test may fail if someone adds the data to
|
||||
* OSM.
|
||||
*/
|
||||
@Test
|
||||
public void testGetData() {
|
||||
final BBox testBBox = getTestBBox();
|
||||
final DataSet ds = new DataSet(RapiDDataUtils.getData(testBBox));
|
||||
final DataSet ds = new DataSet(MapWithAIDataUtils.getData(testBBox));
|
||||
Assert.assertEquals(1, ds.getWays().size());
|
||||
}
|
||||
|
||||
/**
|
||||
* This gets data from RapiD. This test may fail if someone adds the data to
|
||||
* This gets data from MapWithAI. This test may fail if someone adds the data to
|
||||
* OSM.
|
||||
*/
|
||||
@Test
|
||||
|
@ -53,10 +53,10 @@ public class RapiDDataUtilsTest {
|
|||
final GpxData gpxData = new GpxData();
|
||||
gpxData.addWaypoint(new WayPoint(new LatLon(39.0735205, -108.5711561)));
|
||||
gpxData.addWaypoint(new WayPoint(new LatLon(39.0736682, -108.5708568)));
|
||||
final GpxLayer gpx = new GpxLayer(gpxData, DetectTaskingManagerUtils.RAPID_CROP_AREA);
|
||||
final DataSet originalData = RapiDDataUtils.getData(testBBox);
|
||||
final GpxLayer gpx = new GpxLayer(gpxData, DetectTaskingManagerUtils.MAPWITHAI_CROP_AREA);
|
||||
final DataSet originalData = MapWithAIDataUtils.getData(testBBox);
|
||||
MainApplication.getLayerManager().addLayer(gpx);
|
||||
final DataSet ds = RapiDDataUtils.getData(testBBox);
|
||||
final DataSet ds = MapWithAIDataUtils.getData(testBBox);
|
||||
Assert.assertEquals(1, ds.getWays().size());
|
||||
Assert.assertEquals(3, ds.getNodes().size());
|
||||
Assert.assertEquals(1, originalData.getWays().size());
|
||||
|
@ -71,7 +71,7 @@ public class RapiDDataUtilsTest {
|
|||
final String source = "random source";
|
||||
|
||||
Assert.assertNull(way1.get("source"));
|
||||
RapiDDataUtils.addSourceTags(ds, "highway", source);
|
||||
MapWithAIDataUtils.addSourceTags(ds, "highway", source);
|
||||
Assert.assertEquals(source, way1.get("source"));
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ public class RapiDDataUtilsTest {
|
|||
new Node(new LatLon(0, 0.1)));
|
||||
final Collection<OsmPrimitive> collection = new TreeSet<>();
|
||||
Assert.assertEquals(0, collection.size());
|
||||
RapiDDataUtils.addPrimitivesToCollection(collection, Collections.singletonList(way1));
|
||||
MapWithAIDataUtils.addPrimitivesToCollection(collection, Collections.singletonList(way1));
|
||||
Assert.assertEquals(3, collection.size());
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ public class RapiDDataUtilsTest {
|
|||
ds1.addPrimitive(way1);
|
||||
|
||||
Assert.assertEquals(3, ds1.allPrimitives().size());
|
||||
RapiDDataUtils.removePrimitivesFromDataSet(Collections.singleton(way1));
|
||||
MapWithAIDataUtils.removePrimitivesFromDataSet(Collections.singleton(way1));
|
||||
Assert.assertEquals(0, ds1.allPrimitives().size());
|
||||
}
|
||||
|
||||
|
@ -112,52 +112,52 @@ public class RapiDDataUtilsTest {
|
|||
List<SourceEntry> paintStyles = MapPaintPrefHelper.INSTANCE.get();
|
||||
// There are two default paint styles
|
||||
Assert.assertEquals(2, paintStyles.size());
|
||||
RapiDDataUtils.addRapiDPaintStyles();
|
||||
MapWithAIDataUtils.addMapWithAIPaintStyles();
|
||||
paintStyles = MapPaintPrefHelper.INSTANCE.get();
|
||||
Assert.assertEquals(3, paintStyles.size());
|
||||
RapiDDataUtils.addRapiDPaintStyles();
|
||||
MapWithAIDataUtils.addMapWithAIPaintStyles();
|
||||
paintStyles = MapPaintPrefHelper.INSTANCE.get();
|
||||
Assert.assertEquals(3, paintStyles.size());
|
||||
RapiDDataUtils.addRapiDPaintStyles();
|
||||
MapWithAIDataUtils.addMapWithAIPaintStyles();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRapiDURLPreferences() {
|
||||
public void testMapWithAIURLPreferences() {
|
||||
final String fakeUrl = "https://fake.url";
|
||||
Assert.assertEquals(RapiDDataUtils.DEFAULT_RAPID_API, RapiDDataUtils.getRapiDURL());
|
||||
RapiDDataUtils.setRapiDUrl(fakeUrl, true);
|
||||
Assert.assertEquals(fakeUrl, RapiDDataUtils.getRapiDURL());
|
||||
final List<String> urls = new ArrayList<>(RapiDDataUtils.getRapiDURLs());
|
||||
Assert.assertEquals(MapWithAIDataUtils.DEFAULT_MAPWITHAI_API, MapWithAIDataUtils.getMapWithAIUrl());
|
||||
MapWithAIDataUtils.setMapWithAIUrl(fakeUrl, true);
|
||||
Assert.assertEquals(fakeUrl, MapWithAIDataUtils.getMapWithAIUrl());
|
||||
final List<String> urls = new ArrayList<>(MapWithAIDataUtils.getMapWithAIURLs());
|
||||
Assert.assertEquals(2, urls.size());
|
||||
RapiDDataUtils.setRapiDUrl(RapiDDataUtils.DEFAULT_RAPID_API, true);
|
||||
Assert.assertEquals(RapiDDataUtils.DEFAULT_RAPID_API, RapiDDataUtils.getRapiDURL());
|
||||
RapiDDataUtils.setRapiDUrl(fakeUrl, true);
|
||||
Assert.assertEquals(fakeUrl, RapiDDataUtils.getRapiDURL());
|
||||
MapWithAIDataUtils.setMapWithAIUrl(MapWithAIDataUtils.DEFAULT_MAPWITHAI_API, true);
|
||||
Assert.assertEquals(MapWithAIDataUtils.DEFAULT_MAPWITHAI_API, MapWithAIDataUtils.getMapWithAIUrl());
|
||||
MapWithAIDataUtils.setMapWithAIUrl(fakeUrl, true);
|
||||
Assert.assertEquals(fakeUrl, MapWithAIDataUtils.getMapWithAIUrl());
|
||||
urls.remove(fakeUrl);
|
||||
RapiDDataUtils.setRapiDURLs(urls);
|
||||
Assert.assertEquals(RapiDDataUtils.DEFAULT_RAPID_API, RapiDDataUtils.getRapiDURL());
|
||||
MapWithAIDataUtils.setMapWithAIURLs(urls);
|
||||
Assert.assertEquals(MapWithAIDataUtils.DEFAULT_MAPWITHAI_API, MapWithAIDataUtils.getMapWithAIUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSplitBounds() {
|
||||
final BBox bbox = new BBox(0, 0, 0.0001, 0.0001);
|
||||
List<BBox> bboxes = RapiDDataUtils.reduceBBoxSize(bbox);
|
||||
List<BBox> bboxes = MapWithAIDataUtils.reduceBBoxSize(bbox);
|
||||
Assert.assertEquals(1, bboxes.size());
|
||||
checkInBBox(bbox, bboxes);
|
||||
|
||||
bbox.add(0.001, 0.001);
|
||||
bboxes = RapiDDataUtils.reduceBBoxSize(bbox);
|
||||
bboxes = MapWithAIDataUtils.reduceBBoxSize(bbox);
|
||||
Assert.assertEquals(1, bboxes.size());
|
||||
checkInBBox(bbox, bboxes);
|
||||
|
||||
bbox.add(0.01, 0.01);
|
||||
bboxes = RapiDDataUtils.reduceBBoxSize(bbox);
|
||||
bboxes = MapWithAIDataUtils.reduceBBoxSize(bbox);
|
||||
Assert.assertEquals(4, bboxes.size());
|
||||
checkInBBox(bbox, bboxes);
|
||||
checkBBoxesConnect(bbox, bboxes);
|
||||
|
||||
bbox.add(0.1, 0.1);
|
||||
bboxes = RapiDDataUtils.reduceBBoxSize(bbox);
|
||||
bboxes = MapWithAIDataUtils.reduceBBoxSize(bbox);
|
||||
Assert.assertEquals(144, bboxes.size());
|
||||
checkInBBox(bbox, bboxes);
|
||||
checkBBoxesConnect(bbox, bboxes);
|
|
@ -1,5 +1,5 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.rapid.backend;
|
||||
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
||||
|
||||
import static org.openstreetmap.josm.tools.I18n.tr;
|
||||
|
||||
|
@ -15,6 +15,7 @@ import org.junit.Before;
|
|||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.openstreetmap.josm.data.osm.DataSet;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAILayer;
|
||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
@ -23,16 +24,16 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|||
* @author Taylor Smock
|
||||
*
|
||||
*/
|
||||
public class RapiDLayerTest {
|
||||
public class MapWithAILayerTest {
|
||||
@Rule
|
||||
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
||||
public JOSMTestRules test = new JOSMTestRules().preferences().main().projection();
|
||||
|
||||
RapiDLayer layer;
|
||||
MapWithAILayer layer;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
layer = new RapiDLayer(new DataSet(), "test", null);
|
||||
layer = new MapWithAILayer(new DataSet(), "test", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -55,7 +56,7 @@ public class RapiDLayerTest {
|
|||
Assert.assertFalse(label.getText().contains("Switch Layers"));
|
||||
}
|
||||
|
||||
layer.setRapiDUrl("bad_url");
|
||||
layer.setMapWithAIUrl("bad_url");
|
||||
layer.setMaximumAddition(0);
|
||||
layer.setSwitchLayers(false);
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.rapid.backend;
|
||||
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
@ -13,14 +13,14 @@ import org.openstreetmap.josm.data.osm.Node;
|
|||
import org.openstreetmap.josm.data.osm.Way;
|
||||
import org.openstreetmap.josm.gui.MainApplication;
|
||||
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
||||
import org.openstreetmap.josm.plugins.rapid.commands.CreateConnectionsCommand;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.commands.CreateConnectionsCommand;
|
||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
public class RapiDMoveActionTest {
|
||||
RapiDMoveAction moveAction;
|
||||
DataSet rapidData;
|
||||
public class MapWithAIMoveActionTest {
|
||||
MapWithAIMoveAction moveAction;
|
||||
DataSet mapWithAIData;
|
||||
OsmDataLayer osmLayer;
|
||||
Way way1;
|
||||
Way way2;
|
||||
|
@ -31,29 +31,29 @@ public class RapiDMoveActionTest {
|
|||
|
||||
@Before
|
||||
public void setUp() {
|
||||
moveAction = new RapiDMoveAction();
|
||||
moveAction = new MapWithAIMoveAction();
|
||||
final DataSet osmData = new DataSet();
|
||||
rapidData = new DataSet();
|
||||
mapWithAIData = new DataSet();
|
||||
way1 = TestUtils.newWay("highway=residential", new Node(new LatLon(0, 0)),
|
||||
new Node(new LatLon(0.1, 0.1)));
|
||||
way2 = TestUtils.newWay("highway=residential", new Node(new LatLon(-0.1, -0.1)),
|
||||
new Node(new LatLon(0.1, 0.1)));
|
||||
way1.getNodes().forEach(node -> rapidData.addPrimitive(node));
|
||||
way1.getNodes().forEach(node -> mapWithAIData.addPrimitive(node));
|
||||
way2.getNodes().forEach(node -> osmData.addPrimitive(node));
|
||||
osmData.addPrimitive(way2);
|
||||
rapidData.addPrimitive(way1);
|
||||
mapWithAIData.addPrimitive(way1);
|
||||
|
||||
osmLayer = new OsmDataLayer(osmData, "osm", null);
|
||||
final RapiDLayer rapidLayer = new RapiDLayer(rapidData, "rapid",
|
||||
final MapWithAILayer mapWithAILayer = new MapWithAILayer(mapWithAIData, "MapWithAI",
|
||||
null);
|
||||
MainApplication.getLayerManager().addLayer(osmLayer);
|
||||
MainApplication.getLayerManager().addLayer(rapidLayer);
|
||||
MainApplication.getLayerManager().setActiveLayer(rapidLayer);
|
||||
MainApplication.getLayerManager().addLayer(mapWithAILayer);
|
||||
MainApplication.getLayerManager().setActiveLayer(mapWithAILayer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMoveAction() {
|
||||
rapidData.addSelected(way1);
|
||||
mapWithAIData.addSelected(way1);
|
||||
moveAction.actionPerformed(null);
|
||||
Assert.assertEquals(osmLayer, MainApplication.getLayerManager().getActiveLayer());
|
||||
Assert.assertNotNull(osmLayer.getDataSet().getPrimitiveById(way1));
|
||||
|
@ -63,10 +63,10 @@ public class RapiDMoveActionTest {
|
|||
|
||||
@Test
|
||||
public void testConflationDupeKeyRemoval() {
|
||||
rapidData.unlock();
|
||||
mapWithAIData.unlock();
|
||||
way1.lastNode().put(CreateConnectionsCommand.DUPE_KEY, "n" + Long.toString(way2.lastNode().getUniqueId()));
|
||||
rapidData.lock();
|
||||
rapidData.addSelected(way1);
|
||||
mapWithAIData.lock();
|
||||
mapWithAIData.addSelected(way1);
|
||||
final DataSet ds = osmLayer.getDataSet();
|
||||
|
||||
moveAction.actionPerformed(null);
|
||||
|
@ -80,11 +80,11 @@ public class RapiDMoveActionTest {
|
|||
|
||||
@Test
|
||||
public void testConflationConnKeyRemoval() {
|
||||
rapidData.unlock();
|
||||
mapWithAIData.unlock();
|
||||
way1.lastNode().put(CreateConnectionsCommand.CONN_KEY, "w" + Long.toString(way2.getUniqueId()) + ",n"
|
||||
+ Long.toString(way2.lastNode().getUniqueId()) + ",n" + Long.toString(way2.firstNode().getUniqueId()));
|
||||
rapidData.lock();
|
||||
rapidData.addSelected(way1);
|
||||
mapWithAIData.lock();
|
||||
mapWithAIData.addSelected(way1);
|
||||
|
||||
moveAction.actionPerformed(null);
|
||||
Assert.assertFalse(way2.lastNode().hasKey(CreateConnectionsCommand.CONN_KEY));
|
|
@ -1,5 +1,5 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.rapid.backend;
|
||||
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
|
@ -8,6 +8,9 @@ import org.junit.rules.ExpectedException;
|
|||
import org.openstreetmap.josm.data.osm.BBox;
|
||||
import org.openstreetmap.josm.gui.MainApplication;
|
||||
import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler.RequestHandlerBadRequestException;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIDataUtils;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAILayer;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIRemoteControl;
|
||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||
import org.openstreetmap.josm.tools.Utils;
|
||||
|
||||
|
@ -17,7 +20,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|||
* @author Taylor Smock
|
||||
*
|
||||
*/
|
||||
public class RapiDRemoteControlTest {
|
||||
public class MapWithAIRemoteControlTest {
|
||||
|
||||
/**
|
||||
* Rule used for tests throwing exceptions.
|
||||
|
@ -32,8 +35,8 @@ public class RapiDRemoteControlTest {
|
|||
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
||||
public JOSMTestRules test = new JOSMTestRules().main().projection();
|
||||
|
||||
private static RapiDRemoteControl newHandler(String url) throws RequestHandlerBadRequestException {
|
||||
final RapiDRemoteControl req = new RapiDRemoteControl();
|
||||
private static MapWithAIRemoteControl newHandler(String url) throws RequestHandlerBadRequestException {
|
||||
final MapWithAIRemoteControl req = new MapWithAIRemoteControl();
|
||||
if (url != null) {
|
||||
req.setUrl(url);
|
||||
}
|
||||
|
@ -62,21 +65,21 @@ public class RapiDRemoteControlTest {
|
|||
*/
|
||||
@Test
|
||||
public void testNominalRequest() throws Exception {
|
||||
newHandler("https://localhost?url=" + Utils.encodeUrl(RapiDDataUtils.getRapiDURL())).handle();
|
||||
Assert.assertFalse(MainApplication.getLayerManager().getLayersOfType(RapiDLayer.class).isEmpty());
|
||||
newHandler("https://localhost?url=" + Utils.encodeUrl(MapWithAIDataUtils.getMapWithAIUrl())).handle();
|
||||
Assert.assertFalse(MainApplication.getLayerManager().getLayersOfType(MapWithAILayer.class).isEmpty());
|
||||
|
||||
Assert.assertTrue(RapiDDataUtils.getLayer(false).getDataSet().getDataSourceBounds().isEmpty());
|
||||
Assert.assertTrue(MapWithAIDataUtils.getLayer(false).getDataSet().getDataSourceBounds().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTemporaryUrl() throws Exception {
|
||||
String badUrl = "https://bad.url";
|
||||
newHandler("https://localhost?url=" + Utils.encodeUrl(badUrl)).handle();
|
||||
Assert.assertFalse(MainApplication.getLayerManager().getLayersOfType(RapiDLayer.class).isEmpty());
|
||||
Assert.assertFalse(MainApplication.getLayerManager().getLayersOfType(MapWithAILayer.class).isEmpty());
|
||||
|
||||
Assert.assertEquals(badUrl, RapiDDataUtils.getRapiDURL());
|
||||
MainApplication.getLayerManager().removeLayer(RapiDDataUtils.getLayer(false));
|
||||
Assert.assertNotEquals(badUrl, RapiDDataUtils.getRapiDURL());
|
||||
Assert.assertEquals(badUrl, MapWithAIDataUtils.getMapWithAIUrl());
|
||||
MainApplication.getLayerManager().removeLayer(MapWithAIDataUtils.getLayer(false));
|
||||
Assert.assertNotEquals(badUrl, MapWithAIDataUtils.getMapWithAIUrl());
|
||||
|
||||
badUrl = "NothingToSeeHere";
|
||||
thrown.expect(RequestHandlerBadRequestException.class);
|
||||
|
@ -90,11 +93,11 @@ public class RapiDRemoteControlTest {
|
|||
final Integer maxObj = 1;
|
||||
newHandler("http://127.0.0.1:8111/mapwithai?bbox=" + getTestBBox().toStringCSV(",") + "&max_obj="
|
||||
+ maxObj.toString()).handle();
|
||||
Assert.assertFalse(MainApplication.getLayerManager().getLayersOfType(RapiDLayer.class).isEmpty());
|
||||
Assert.assertFalse(MainApplication.getLayerManager().getLayersOfType(MapWithAILayer.class).isEmpty());
|
||||
|
||||
Assert.assertEquals(maxObj.intValue(), RapiDDataUtils.getMaximumAddition());
|
||||
MainApplication.getLayerManager().removeLayer(RapiDDataUtils.getLayer(false));
|
||||
Assert.assertNotEquals(maxObj.intValue(), RapiDDataUtils.getMaximumAddition());
|
||||
Assert.assertEquals(maxObj.intValue(), MapWithAIDataUtils.getMaximumAddition());
|
||||
MainApplication.getLayerManager().removeLayer(MapWithAIDataUtils.getLayer(false));
|
||||
Assert.assertNotEquals(maxObj.intValue(), MapWithAIDataUtils.getMaximumAddition());
|
||||
|
||||
thrown.expect(RequestHandlerBadRequestException.class);
|
||||
thrown.expectMessage("NumberFormatException (For input string: \"BAD_VALUE\")");
|
||||
|
@ -107,12 +110,12 @@ public class RapiDRemoteControlTest {
|
|||
public void testBBox() throws Exception {
|
||||
BBox temp = getTestBBox();
|
||||
newHandler("http://127.0.0.1:8111/mapwithai?bbox={bbox}".replace("{bbox}", temp.toStringCSV(","))).handle();
|
||||
Assert.assertFalse(MainApplication.getLayerManager().getLayersOfType(RapiDLayer.class).isEmpty());
|
||||
Assert.assertFalse(MainApplication.getLayerManager().getLayersOfType(MapWithAILayer.class).isEmpty());
|
||||
|
||||
final BBox added = RapiDDataUtils.getLayer(false).getDataSet().getDataSourceBounds().iterator().next().toBBox();
|
||||
final BBox added = MapWithAIDataUtils.getLayer(false).getDataSet().getDataSourceBounds().iterator().next().toBBox();
|
||||
Assert.assertTrue(temp.bounds(added));
|
||||
|
||||
MainApplication.getLayerManager().removeLayer(RapiDDataUtils.getLayer(false));
|
||||
MainApplication.getLayerManager().removeLayer(MapWithAIDataUtils.getLayer(false));
|
||||
temp = new BBox(39.0621223, -108.4625421, 39.0633059, -108.4594728);
|
||||
thrown.expect(RequestHandlerBadRequestException.class);
|
||||
thrown.expectMessage(
|
|
@ -1,5 +1,5 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.rapid.commands;
|
||||
package org.openstreetmap.josm.plugins.mapwithai.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -14,6 +14,7 @@ import org.openstreetmap.josm.data.osm.DataSet;
|
|||
import org.openstreetmap.josm.data.osm.Node;
|
||||
import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
||||
import org.openstreetmap.josm.data.osm.Way;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.commands.AddNodeToWayCommand;
|
||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
@ -1,5 +1,5 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.rapid.commands;
|
||||
package org.openstreetmap.josm.plugins.mapwithai.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
@ -18,6 +18,7 @@ import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
|
|||
import org.openstreetmap.josm.data.osm.Way;
|
||||
import org.openstreetmap.josm.gui.MainApplication;
|
||||
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.commands.CreateConnectionsCommand;
|
||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
@ -1,5 +1,5 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.rapid.commands;
|
||||
package org.openstreetmap.josm.plugins.mapwithai.commands;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
|
@ -11,6 +11,7 @@ import org.openstreetmap.josm.data.coor.LatLon;
|
|||
import org.openstreetmap.josm.data.osm.DataSet;
|
||||
import org.openstreetmap.josm.data.osm.Node;
|
||||
import org.openstreetmap.josm.data.osm.Way;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.commands.DeletePrimitivesCommand;
|
||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
@ -1,5 +1,5 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.rapid.commands;
|
||||
package org.openstreetmap.josm.plugins.mapwithai.commands;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
@ -15,11 +15,12 @@ import org.openstreetmap.josm.data.osm.DataSet;
|
|||
import org.openstreetmap.josm.data.osm.Node;
|
||||
import org.openstreetmap.josm.data.osm.Tag;
|
||||
import org.openstreetmap.josm.data.osm.Way;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.commands.MapWithAIAddCommand;
|
||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
public class RapiDAddComandTest {
|
||||
public class MapWithAIAddComandTest {
|
||||
private final static String HIGHWAY_RESIDENTIAL = "highway=residential";
|
||||
|
||||
@Rule
|
||||
|
@ -46,7 +47,7 @@ public class RapiDAddComandTest {
|
|||
}
|
||||
}
|
||||
ds1.lock();
|
||||
RapiDAddCommand command = new RapiDAddCommand(ds1, ds2, Arrays.asList(way1, way2));
|
||||
MapWithAIAddCommand command = new MapWithAIAddCommand(ds1, ds2, Arrays.asList(way1, way2));
|
||||
command.executeCommand();
|
||||
Assert.assertNotNull(ds2.getPrimitiveById(way1));
|
||||
Assert.assertNotNull(ds2.getPrimitiveById(way1.firstNode()));
|
||||
|
@ -58,7 +59,7 @@ public class RapiDAddComandTest {
|
|||
Assert.assertTrue(way2.isDeleted());
|
||||
|
||||
Assert.assertNull(ds2.getPrimitiveById(way3));
|
||||
command = new RapiDAddCommand(ds1, ds2, Arrays.asList(way3));
|
||||
command = new MapWithAIAddCommand(ds1, ds2, Arrays.asList(way3));
|
||||
command.executeCommand();
|
||||
Assert.assertNotNull(ds2.getPrimitiveById(way3));
|
||||
Assert.assertNotNull(ds2.getPrimitiveById(way3.firstNode()));
|
||||
|
@ -87,7 +88,7 @@ public class RapiDAddComandTest {
|
|||
way2.getNodes().forEach(node -> ds1.addPrimitive(node));
|
||||
ds1.addPrimitive(way2);
|
||||
ds1.addPrimitive(way1);
|
||||
RapiDAddCommand.createConnections(ds1, Collections.singletonList(way2.firstNode())).executeCommand();
|
||||
MapWithAIAddCommand.createConnections(ds1, Collections.singletonList(way2.firstNode())).executeCommand();
|
||||
Assert.assertEquals(3, way1.getNodesCount());
|
||||
Assert.assertFalse(way1.isFirstLastNode(way2.firstNode()));
|
||||
|
||||
|
@ -97,7 +98,7 @@ public class RapiDAddComandTest {
|
|||
way3.getNodes().forEach(node -> ds1.addPrimitive(node));
|
||||
ds1.addPrimitive(way3);
|
||||
final Node way3Node1 = way3.firstNode();
|
||||
RapiDAddCommand.createConnections(ds1, Collections.singletonList(way3.firstNode())).executeCommand();
|
||||
MapWithAIAddCommand.createConnections(ds1, Collections.singletonList(way3.firstNode())).executeCommand();
|
||||
Assert.assertNotEquals(way3Node1, way3.firstNode());
|
||||
Assert.assertEquals(way1.firstNode(), way3.firstNode());
|
||||
Assert.assertTrue(way3Node1.isDeleted());
|
||||
|
@ -106,39 +107,39 @@ public class RapiDAddComandTest {
|
|||
@Test
|
||||
public void testCreateConnectionsUndo() {
|
||||
final DataSet osmData = new DataSet();
|
||||
final DataSet rapidData = new DataSet();
|
||||
final DataSet mapWithAIData = new DataSet();
|
||||
final Way way1 = TestUtils.newWay(HIGHWAY_RESIDENTIAL, new Node(new LatLon(0, 0)),
|
||||
new Node(new LatLon(0.1, 0.1)));
|
||||
final Way way2 = TestUtils.newWay(HIGHWAY_RESIDENTIAL, new Node(new LatLon(-0.1, -0.1)),
|
||||
new Node(new LatLon(0.1, 0.1)));
|
||||
way1.getNodes().forEach(node -> rapidData.addPrimitive(node));
|
||||
way1.getNodes().forEach(node -> mapWithAIData.addPrimitive(node));
|
||||
way2.getNodes().forEach(node -> osmData.addPrimitive(node));
|
||||
osmData.addPrimitive(way2);
|
||||
rapidData.addPrimitive(way1);
|
||||
rapidData.setSelected(way1);
|
||||
mapWithAIData.addPrimitive(way1);
|
||||
mapWithAIData.setSelected(way1);
|
||||
|
||||
Assert.assertEquals(3, osmData.allNonDeletedPrimitives().size());
|
||||
Assert.assertEquals(3, rapidData.allNonDeletedPrimitives().size());
|
||||
Assert.assertEquals(3, mapWithAIData.allNonDeletedPrimitives().size());
|
||||
|
||||
RapiDAddCommand command = new RapiDAddCommand(rapidData, osmData, rapidData.getSelected());
|
||||
MapWithAIAddCommand command = new MapWithAIAddCommand(mapWithAIData, osmData, mapWithAIData.getSelected());
|
||||
command.executeCommand();
|
||||
Assert.assertEquals(6, osmData.allNonDeletedPrimitives().size());
|
||||
Assert.assertTrue(rapidData.allNonDeletedPrimitives().isEmpty());
|
||||
Assert.assertTrue(mapWithAIData.allNonDeletedPrimitives().isEmpty());
|
||||
|
||||
command.undoCommand();
|
||||
Assert.assertEquals(3, osmData.allNonDeletedPrimitives().size());
|
||||
Assert.assertEquals(3, rapidData.allNonDeletedPrimitives().size());
|
||||
Assert.assertEquals(3, mapWithAIData.allNonDeletedPrimitives().size());
|
||||
|
||||
final Tag dupe = new Tag("dupe", "n".concat(Long.toString(way2.lastNode().getUniqueId())));
|
||||
way1.lastNode().put(dupe);
|
||||
command = new RapiDAddCommand(rapidData, osmData, rapidData.getSelected());
|
||||
command = new MapWithAIAddCommand(mapWithAIData, osmData, mapWithAIData.getSelected());
|
||||
command.executeCommand();
|
||||
Assert.assertEquals(5, osmData.allNonDeletedPrimitives().size());
|
||||
Assert.assertTrue(rapidData.allNonDeletedPrimitives().isEmpty());
|
||||
Assert.assertTrue(mapWithAIData.allNonDeletedPrimitives().isEmpty());
|
||||
|
||||
command.undoCommand();
|
||||
Assert.assertEquals(3, osmData.allNonDeletedPrimitives().size());
|
||||
Assert.assertEquals(3, rapidData.allNonDeletedPrimitives().size());
|
||||
Assert.assertEquals(3, mapWithAIData.allNonDeletedPrimitives().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -151,7 +152,7 @@ public class RapiDAddComandTest {
|
|||
from.addPrimitive(way1);
|
||||
from.addPrimitive(new Node(new LatLon(-0.1, 0.1)));
|
||||
|
||||
UndoRedoHandler.getInstance().add(new RapiDAddCommand(from, to, Collections.singleton(way1)));
|
||||
UndoRedoHandler.getInstance().add(new MapWithAIAddCommand(from, to, Collections.singleton(way1)));
|
||||
|
||||
final Node tNode = (Node) to.getPrimitiveById(way1.firstNode());
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.rapid.commands;
|
||||
package org.openstreetmap.josm.plugins.mapwithai.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -17,6 +17,7 @@ import org.openstreetmap.josm.data.osm.DataSet;
|
|||
import org.openstreetmap.josm.data.osm.Node;
|
||||
import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
||||
import org.openstreetmap.josm.data.osm.Way;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.commands.MovePrimitiveDataSetCommand;
|
||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
@ -1,64 +0,0 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.rapid.backend;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.openstreetmap.josm.data.Bounds;
|
||||
import org.openstreetmap.josm.data.DataSource;
|
||||
import org.openstreetmap.josm.data.osm.DataSet;
|
||||
import org.openstreetmap.josm.gui.MainApplication;
|
||||
import org.openstreetmap.josm.gui.layer.Layer;
|
||||
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
public class RapiDActionTest {
|
||||
@Rule
|
||||
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
||||
public JOSMTestRules test = new JOSMTestRules().preferences().main().projection();
|
||||
|
||||
@Test
|
||||
public void testGetLayer() {
|
||||
Layer rapid = RapiDDataUtils.getLayer(false);
|
||||
Assert.assertNull(rapid);
|
||||
|
||||
rapid = RapiDDataUtils.getLayer(true);
|
||||
Assert.assertEquals(RapiDLayer.class, rapid.getClass());
|
||||
|
||||
Layer tRapid = RapiDDataUtils.getLayer(false);
|
||||
Assert.assertSame(rapid, tRapid);
|
||||
|
||||
tRapid = RapiDDataUtils.getLayer(true);
|
||||
Assert.assertSame(rapid, tRapid);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetData() {
|
||||
final RapiDLayer rapid = RapiDDataUtils.getLayer(true);
|
||||
final OsmDataLayer osm = new OsmDataLayer(new DataSet(), "test", null);
|
||||
MainApplication.getLayerManager().addLayer(osm);
|
||||
RapiDDataUtils.getRapiDData(rapid, osm);
|
||||
|
||||
Assert.assertTrue(rapid.getDataSet().getDataSourceBounds().isEmpty());
|
||||
|
||||
osm.getDataSet().addDataSource(new DataSource(new Bounds(0, 0, 0.001, 0.001), "random test"));
|
||||
|
||||
osm.lock();
|
||||
RapiDDataUtils.getRapiDData(rapid);
|
||||
Assert.assertTrue(rapid.getDataSet().getDataSourceBounds().isEmpty());
|
||||
osm.unlock();
|
||||
|
||||
RapiDDataUtils.getRapiDData(rapid);
|
||||
Assert.assertFalse(rapid.getDataSet().getDataSourceBounds().isEmpty());
|
||||
Assert.assertEquals(1, rapid.getDataSet().getDataSourceBounds().parallelStream().distinct().count());
|
||||
|
||||
osm.getDataSet().addDataSource(new DataSource(new Bounds(-0.001, -0.001, 0, 0), "random test"));
|
||||
RapiDDataUtils.getRapiDData(rapid);
|
||||
Assert.assertEquals(2, rapid.getDataSet().getDataSourceBounds().parallelStream().distinct().count());
|
||||
|
||||
RapiDDataUtils.getRapiDData(rapid);
|
||||
Assert.assertEquals(2, rapid.getDataSet().getDataSourceBounds().parallelStream().distinct().count());
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue