diff --git a/.classpath b/.classpath index 76b90a4..e15a877 100644 --- a/.classpath +++ b/.classpath @@ -1,12 +1,7 @@ - - + + + diff --git a/.gitignore b/.gitignore index 0370598..9cf442e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ # Some Files # ################### -nbproject -build \ No newline at end of file +nbproject/ +build/ +*.class +*.log \ No newline at end of file diff --git a/.project b/.project new file mode 100644 index 0000000..229b05a --- /dev/null +++ b/.project @@ -0,0 +1,22 @@ + + + JOSM-tofix + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.sonarlint.eclipse.core.sonarlintBuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..7ac4839 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,101 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/README.md b/README.md index 9b18cc9..7566b4d 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,42 @@ -# JOSM To-Fix Plugin +# To-Fix Plugin for JOSM -Make [To-Fix](http://osmlab.github.io/to-fix) OpenStreetMap microtasking challenges available in [JOSM](http://josm.openstreetmap.de/) editor. +This plugin makes [To-Fix](http://osmlab.github.io/to-fix) OpenStreetMap microtasking challenges available directly from within the [JOSM](http://josm.openstreetmap.de/) editor. -![josm](https://cloud.githubusercontent.com/assets/1152236/7286852/ddfc4114-e914-11e4-93c7-b9cf72a30fcc.gif) +Instead of picking new tasks and confirming accomplished tasks through the web interface of To-Fix on [http://osmlab.github.io/to-fix](http://osmlab.github.io/to-fix) this plugin allows you to work with To-Fix tasks without ever having to switch out of JOSM. + +![tofix-wor2k](https://cloud.githubusercontent.com/assets/1152236/10491901/9b17bf5c-726e-11e5-9575-3c62d0412140.gif) ## Installation -*Download* +- Open "Preferences" in your JOSM editor (editor available on [josm.openstreetmap.de](http://josm.openstreetmap.de/)) +- Click "Update plugins" +- Select "Plugins" and check "tofix" +- Confirm with "OK" and restart JOSM + +![tofix](https://cloud.githubusercontent.com/assets/1152236/10457988/417882b4-718e-11e5-94b5-6ecf4a30eb43.gif) + +## Configuration + +- Select "To-fix" from "Windows", the To-fix window will appear as a panel on your screen (at least one layer must be enabled to select options within Windows) +- Select a task from the drop down. + +## Working with the plugin + +- **Skip:** Click to select a new task at any time. +- **Not an error:** Click if a task does not require any editing. +- **Fixed:** click when you are done editing on a task. This will automatically start the upload process. Fill in a comment like `#to-fix:tigerdelta`. After uploading the plugin will download the next task. + +## Shortcuts + +Default shortcuts: + +- **Skip button:** ALT + SHIFT + S +- **Not a error button :** ALT + SHIFT + N +- **Fixed button :** ALT + SHIFT + F -- Download: https://github.com/osmlab/josm-tofix-plugin/blob/master/dist/tofix.jar?raw=true -- or clone from GitHub: `git clone https://github.com/Rub21/josm-tofix-plugin.git` +Example to configure your own shortcuts: -*Copy to plugins directory* -- Ubuntu: `cp tofix.jar ~/.josm/plugins/` -- Mac OSX: `cp tofix.jar ~/Library/JOSM/plugins` +![screenshot from 2015-06-18 09 30 05](https://cloud.githubusercontent.com/assets/1152236/8237229/6268a12a-15b3-11e5-8496-d67fdc1fc4b8.png) -*Activate plugin* -![image](https://cloud.githubusercontent.com/assets/1152236/7150157/803d6e24-e2dc-11e4-9245-93e0d7ccaada.png) diff --git a/build.xml b/build.xml index 7f2d216..ee68929 100644 --- a/build.xml +++ b/build.xml @@ -1,12 +1,13 @@ - - - + + + - + - + + diff --git a/data/ast.lang b/data/ast.lang new file mode 100644 index 0000000..6abbfab Binary files /dev/null and b/data/ast.lang differ diff --git a/data/be.lang b/data/be.lang new file mode 100644 index 0000000..b87cb24 Binary files /dev/null and b/data/be.lang differ diff --git a/data/bg.lang b/data/bg.lang new file mode 100644 index 0000000..75c60ff Binary files /dev/null and b/data/bg.lang differ diff --git a/data/ca-valencia.lang b/data/ca-valencia.lang new file mode 100644 index 0000000..088b341 Binary files /dev/null and b/data/ca-valencia.lang differ diff --git a/data/ca.lang b/data/ca.lang new file mode 100644 index 0000000..15a266c Binary files /dev/null and b/data/ca.lang differ diff --git a/data/cs.lang b/data/cs.lang new file mode 100644 index 0000000..0cd849a Binary files /dev/null and b/data/cs.lang differ diff --git a/data/da.lang b/data/da.lang new file mode 100644 index 0000000..77b5fc9 Binary files /dev/null and b/data/da.lang differ diff --git a/data/de.lang b/data/de.lang new file mode 100644 index 0000000..5714795 Binary files /dev/null and b/data/de.lang differ diff --git a/data/el.lang b/data/el.lang new file mode 100644 index 0000000..76a66ff Binary files /dev/null and b/data/el.lang differ diff --git a/data/en.lang b/data/en.lang new file mode 100644 index 0000000..e6b2e00 Binary files /dev/null and b/data/en.lang differ diff --git a/data/en_AU.lang b/data/en_AU.lang new file mode 100644 index 0000000..758d4eb Binary files /dev/null and b/data/en_AU.lang differ diff --git a/data/en_GB.lang b/data/en_GB.lang new file mode 100644 index 0000000..cabe460 --- /dev/null +++ b/data/en_GB.lang @@ -0,0 +1 @@ +ÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿÿ \ No newline at end of file diff --git a/data/es.lang b/data/es.lang new file mode 100644 index 0000000..e123ae6 Binary files /dev/null and b/data/es.lang differ diff --git a/data/et.lang b/data/et.lang new file mode 100644 index 0000000..58faecc Binary files /dev/null and b/data/et.lang differ diff --git a/data/fi.lang b/data/fi.lang new file mode 100644 index 0000000..32d61e3 Binary files /dev/null and b/data/fi.lang differ diff --git a/data/fr.lang b/data/fr.lang new file mode 100644 index 0000000..39123da Binary files /dev/null and b/data/fr.lang differ diff --git a/data/gl.lang b/data/gl.lang new file mode 100644 index 0000000..c3fe375 Binary files /dev/null and b/data/gl.lang differ diff --git a/data/hu.lang b/data/hu.lang new file mode 100644 index 0000000..9b32b47 Binary files /dev/null and b/data/hu.lang differ diff --git a/data/id.lang b/data/id.lang new file mode 100644 index 0000000..bb12234 Binary files /dev/null and b/data/id.lang differ diff --git a/data/it.lang b/data/it.lang new file mode 100644 index 0000000..d216ab3 Binary files /dev/null and b/data/it.lang differ diff --git a/data/ja.lang b/data/ja.lang new file mode 100644 index 0000000..d8d2ee6 Binary files /dev/null and b/data/ja.lang differ diff --git a/data/km.lang b/data/km.lang new file mode 100644 index 0000000..dab6454 Binary files /dev/null and b/data/km.lang differ diff --git a/data/lt.lang b/data/lt.lang new file mode 100644 index 0000000..b725ba0 Binary files /dev/null and b/data/lt.lang differ diff --git a/data/nb.lang b/data/nb.lang new file mode 100644 index 0000000..8c6e223 Binary files /dev/null and b/data/nb.lang differ diff --git a/data/nl.lang b/data/nl.lang new file mode 100644 index 0000000..a8c18fe Binary files /dev/null and b/data/nl.lang differ diff --git a/data/pl.lang b/data/pl.lang new file mode 100644 index 0000000..d4f6336 Binary files /dev/null and b/data/pl.lang differ diff --git a/data/pt.lang b/data/pt.lang new file mode 100644 index 0000000..1893abf Binary files /dev/null and b/data/pt.lang differ diff --git a/data/pt_BR.lang b/data/pt_BR.lang new file mode 100644 index 0000000..89e01a2 Binary files /dev/null and b/data/pt_BR.lang differ diff --git a/data/ru.lang b/data/ru.lang new file mode 100644 index 0000000..24b99a6 Binary files /dev/null and b/data/ru.lang differ diff --git a/data/sk.lang b/data/sk.lang new file mode 100644 index 0000000..b196bad Binary files /dev/null and b/data/sk.lang differ diff --git a/data/sv.lang b/data/sv.lang new file mode 100644 index 0000000..92e62fe Binary files /dev/null and b/data/sv.lang differ diff --git a/data/uk.lang b/data/uk.lang new file mode 100644 index 0000000..628039c Binary files /dev/null and b/data/uk.lang differ diff --git a/data/vi.lang b/data/vi.lang new file mode 100644 index 0000000..e765d1a Binary files /dev/null and b/data/vi.lang differ diff --git a/data/zh_CN.lang b/data/zh_CN.lang new file mode 100644 index 0000000..be0dea9 Binary files /dev/null and b/data/zh_CN.lang differ diff --git a/data/zh_TW.lang b/data/zh_TW.lang new file mode 100644 index 0000000..a589155 Binary files /dev/null and b/data/zh_TW.lang differ diff --git a/dist/tofix.jar b/dist/tofix.jar deleted file mode 100644 index 0a93efb..0000000 Binary files a/dist/tofix.jar and /dev/null differ diff --git a/images/dialogs/icontofix.png b/images/dialogs/icontofix.png index f00ff55..ce8bdb0 100644 Binary files a/images/dialogs/icontofix.png and b/images/dialogs/icontofix.png differ diff --git a/images/icontofix.png b/images/icontofix.png index 41fc7da..ce8bdb0 100644 Binary files a/images/icontofix.png and b/images/icontofix.png differ diff --git a/images/icontofix_layer.png b/images/icontofix_layer.png new file mode 100644 index 0000000..f596d83 Binary files /dev/null and b/images/icontofix_layer.png differ diff --git a/images/mapmode/edit.png b/images/mapmode/edit.png deleted file mode 100644 index bcbb0b3..0000000 Binary files a/images/mapmode/edit.png and /dev/null differ diff --git a/images/mapmode/fixed.png b/images/mapmode/fixed.png index ad8c166..8d1462b 100644 Binary files a/images/mapmode/fixed.png and b/images/mapmode/fixed.png differ diff --git a/images/mapmode/icontofix.png b/images/mapmode/icontofix.png index 41fc7da..ce8bdb0 100644 Binary files a/images/mapmode/icontofix.png and b/images/mapmode/icontofix.png differ diff --git a/images/mapmode/noterror.png b/images/mapmode/noterror.png new file mode 100644 index 0000000..ad8c166 Binary files /dev/null and b/images/mapmode/noterror.png differ diff --git a/lib/gson-2.2.4.jar b/lib/gson-2.2.4.jar deleted file mode 100644 index 9478253..0000000 Binary files a/lib/gson-2.2.4.jar and /dev/null differ diff --git a/src/org/openstreetmap/josm/plugins/tofix/TofixDialog.java b/src/org/openstreetmap/josm/plugins/tofix/TofixDialog.java index ab664ec..f8a0f99 100644 --- a/src/org/openstreetmap/josm/plugins/tofix/TofixDialog.java +++ b/src/org/openstreetmap/josm/plugins/tofix/TofixDialog.java @@ -1,50 +1,54 @@ package org.openstreetmap.josm.plugins.tofix; -import java.awt.FlowLayout; +import static org.openstreetmap.josm.tools.I18n.tr; + +import java.awt.Cursor; import java.awt.GridLayout; -import java.awt.Polygon; +import java.awt.Label; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; import java.awt.event.KeyEvent; -import java.util.ArrayList; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; import java.util.Arrays; -import java.util.List; +import java.util.Hashtable; + import javax.swing.AbstractAction; -import static javax.swing.Action.NAME; -import static javax.swing.Action.SHORT_DESCRIPTION; -import static javax.swing.Action.SMALL_ICON; +import javax.swing.JCheckBox; import javax.swing.JComboBox; +import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; +import javax.swing.JSlider; +import javax.swing.JTabbedPane; + import org.openstreetmap.josm.Main; -import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask; -import org.openstreetmap.josm.data.Bounds; -import org.openstreetmap.josm.data.coor.LatLon; -import org.openstreetmap.josm.data.osm.Node; +import org.openstreetmap.josm.actions.UploadAction; import org.openstreetmap.josm.gui.JosmUserIdentityManager; import org.openstreetmap.josm.gui.MapView; +import org.openstreetmap.josm.gui.Notification; import org.openstreetmap.josm.gui.SideButton; import org.openstreetmap.josm.gui.dialogs.ToggleDialog; -import org.openstreetmap.josm.plugins.tofix.bean.AccessTaskBean; -import org.openstreetmap.josm.plugins.tofix.bean.AttributesBean; -import org.openstreetmap.josm.plugins.tofix.bean.ItemFixedBean; -import org.openstreetmap.josm.plugins.tofix.bean.ItemKeeprightBean; -import org.openstreetmap.josm.plugins.tofix.bean.ItemNycbuildingsBean; -import org.openstreetmap.josm.plugins.tofix.bean.ItemTigerdeltaBean; -import org.openstreetmap.josm.plugins.tofix.bean.ItemUnconnectedBean; +import org.openstreetmap.josm.gui.io.UploadDialog; +import org.openstreetmap.josm.plugins.tofix.bean.AccessToTask; import org.openstreetmap.josm.plugins.tofix.bean.ListTaskBean; import org.openstreetmap.josm.plugins.tofix.bean.TrackBean; +import org.openstreetmap.josm.plugins.tofix.bean.items.Item; import org.openstreetmap.josm.plugins.tofix.controller.ItemController; -import org.openstreetmap.josm.plugins.tofix.controller.ItemEditController; -import org.openstreetmap.josm.plugins.tofix.controller.ItemFixedController; -import org.openstreetmap.josm.plugins.tofix.controller.ItemSkipController; +import org.openstreetmap.josm.plugins.tofix.controller.ItemTrackController; import org.openstreetmap.josm.plugins.tofix.controller.ListTaskController; -import org.openstreetmap.josm.plugins.tofix.layer.TofixLayer; -import org.openstreetmap.josm.plugins.tofix.util.*; -import org.openstreetmap.josm.tools.Geometry; -import static org.openstreetmap.josm.tools.I18n.tr; +import org.openstreetmap.josm.plugins.tofix.util.Config; +import org.openstreetmap.josm.plugins.tofix.util.Status; import org.openstreetmap.josm.tools.ImageProvider; +import org.openstreetmap.josm.tools.OpenBrowser; import org.openstreetmap.josm.tools.Shortcut; +import java.util.ArrayList; +import org.openstreetmap.josm.data.Bounds; +import org.openstreetmap.josm.plugins.tofix.bean.ActionBean; /** * @@ -52,256 +56,415 @@ */ public class TofixDialog extends ToggleDialog implements ActionListener { - // private final SideButton editButton; + boolean validator; private final SideButton skipButton; private final SideButton fixedButton; + private final SideButton noterrorButton; + private Shortcut skipShortcut = null; + private Shortcut fixedShortcut = null; + private Shortcut noterrorButtonShortcut = null; + JSlider slider = new JSlider(JSlider.HORIZONTAL, 1, 5, 1); - // To-Fix host - AccessTaskBean accessTaskBean = null; + //size to download + double zise = 0.001; //per default + + AccessToTask mainAccessToTask = null; // Task list ListTaskBean listTaskBean = null; ListTaskController listTaskController = new ListTaskController(); + //Item + Item item = new Item(); ItemController itemController = new ItemController(); - Bounds bounds = null; - DownloadOsmTask downloadOsmTask = new DownloadOsmTask(); - // To-Fix layer MapView mv = Main.map.mapView; - TofixLayer tofixLayer = new TofixLayer("Tofix-layer"); - JPanel valuePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); - JPanel jcontenpanel = new JPanel(new GridLayout(1, 0)); + ItemTrackController itemTrackController = new ItemTrackController(); + + JTabbedPane TabbedPanel = new javax.swing.JTabbedPane(); + + JPanel jcontenTasks = new JPanel(new GridLayout(2, 1)); + JPanel valuePanel = new JPanel(new GridLayout(1, 1)); + + JPanel jcontenConfig = new JPanel(new GridLayout(2, 1)); + JPanel panelslide = new JPanel(new GridLayout(1, 1)); + + JPanel jcontenActivation = new JPanel(new GridLayout(3, 1)); + JPanel panelactivationPlugin = new JPanel(new GridLayout(1, 1)); + JPanel panelactivationLayer = new JPanel(new GridLayout(1, 1)); JosmUserIdentityManager josmUserIdentityManager = JosmUserIdentityManager.getInstance(); + TofixTask tofixTask = new TofixTask(); + boolean checkboxStatus; + boolean checkboxStatusLayer; + public TofixDialog() { super(tr("To-fix"), "icontofix", tr("Open to-fix window."), - Shortcut.registerShortcut("tool:to-fix", tr("Toggle: {0}", tr("To-fix")), - KeyEvent.VK_F, Shortcut.CTRL_SHIFT), 75); + Shortcut.registerShortcut("Tool:To-fix", tr("Toggle: {0}", tr("Tool:To-fix")), + KeyEvent.VK_T, Shortcut.ALT_CTRL_SHIFT), 170); + + //ENABLE-DISABLE CHECKBOX + JCheckBox checkPlugin = new JCheckBox(tr("Enable Tofix plugin")); + checkPlugin.setSelected(true); + checkboxStatus = checkPlugin.isSelected(); + + checkPlugin.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + checkboxStatus = true; + } else { + checkboxStatus = false; + } + return; + } + }); + + //AUTO DELETE LAYER + JCheckBox checkLayer = new JCheckBox(tr("Auto delete layer")); + checkLayer.setSelected(true); + checkboxStatusLayer = checkLayer.isSelected(); + + checkLayer.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + checkboxStatusLayer = e.getStateChange() == ItemEvent.SELECTED; + } + }); - // Request data - accessTaskBean = new AccessTaskBean("mixedlayer", "keepright", false); + jcontenActivation.add(new Label(tr("Select the checkbox to:"))); + panelactivationPlugin.add(checkPlugin); + panelactivationLayer.add(checkLayer); + jcontenActivation.add(panelactivationPlugin); + jcontenActivation.add(panelactivationLayer); + //BUTTONS + // "Skip" button skipButton = new SideButton(new AbstractAction() { { putValue(NAME, tr("Skip")); - putValue(SMALL_ICON, ImageProvider.get("mapmode", "skip.png")); + new ImageProvider("mapmode", "skip").getResource().attachImageIcon(this); putValue(SHORT_DESCRIPTION, tr("Skip Error")); } @Override public void actionPerformed(ActionEvent e) { - skip(); - get_new_item(); + if (checkboxStatus) { + action("skip"); + deleteLayer(); + + } else { + msg(); + } } }); skipButton.setEnabled(false); + // "Fixed" button fixedButton = new SideButton(new AbstractAction() { { putValue(NAME, tr("Fixed")); - putValue(SMALL_ICON, ImageProvider.get("mapmode", "fixed.png")); + new ImageProvider("mapmode", "fixed").getResource().attachImageIcon(this); putValue(SHORT_DESCRIPTION, tr("Fixed Error")); } @Override public void actionPerformed(ActionEvent e) { - fixed(); + if (checkboxStatus) { + eventFixed(e); + } else { + msg(); + } } }); + fixedButton.setEnabled(false); - // Panels - valuePanel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); - jcontenpanel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); + + // "Not a error" button + noterrorButton = new SideButton(new AbstractAction() { + { + putValue(NAME, tr("Not an error")); + new ImageProvider("mapmode", "noterror").getResource().attachImageIcon(this); + putValue(SHORT_DESCRIPTION, tr("Not an error")); + } + + @Override + public void actionPerformed(ActionEvent e) { + if (checkboxStatus) { + action("noterror"); + deleteLayer(); + } else { + msg(); + } + } + }); + + noterrorButton.setEnabled(false); + + //add tittle for To-fix task + JLabel title_tasks = new javax.swing.JLabel(); + title_tasks.setText(tr("List of tasks")); + title_tasks.setCursor(new Cursor(Cursor.HAND_CURSOR)); + title_tasks.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + OpenBrowser.displayUrl(Config.URL_TOFIX); + } + }); + jcontenTasks.add(title_tasks); + // JComboBox for each task - ArrayList tasksList = new ArrayList(); - tasksList.add("Select a task ..."); + ArrayList tasksList = new ArrayList<>(); + tasksList.add(tr("Select a task ...")); + if (Status.isInternetReachable()) { //checkout internet connection listTaskBean = listTaskController.getListTasksBean(); for (int i = 0; i < listTaskBean.getTasks().size(); i++) { - tasksList.add(listTaskBean.getTasks().get(i).getTitle()); + tasksList.add(listTaskBean.getTasks().get(i).getName()); } + JComboBox jcomboBox = new JComboBox<>(tasksList.toArray(new String[]{})); + valuePanel.add(jcomboBox); + jcomboBox.addActionListener(this); + jcontenTasks.add(valuePanel); + + //add title to download + jcontenConfig.add(new Label(tr("Set download area (m²)"))); + + //Add Slider to download + slider.setMinorTickSpacing(2); + slider.setMajorTickSpacing(5); + slider.setPaintTicks(true); + slider.setPaintLabels(true); + //slider.setLabelTable((slider.createStandardLabels(1))); + Hashtable table = new Hashtable<>(); + table.put(1, new JLabel(tr("~.02"))); + table.put(3, new JLabel("~.20")); + table.put(5, new JLabel("~.40")); + slider.setLabelTable(table); + + slider.addChangeListener(new javax.swing.event.ChangeListener() { + @Override + public void stateChanged(javax.swing.event.ChangeEvent evt) { + zise = slider.getValue() * 0.001; + } + }); + panelslide.add(slider); + jcontenConfig.add(panelslide); + + //PANEL TASKS + valuePanel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); + panelslide.setBorder(javax.swing.BorderFactory.createEtchedBorder()); + panelactivationPlugin.setBorder(javax.swing.BorderFactory.createEtchedBorder()); + panelactivationLayer.setBorder(javax.swing.BorderFactory.createEtchedBorder()); + + TabbedPanel.addTab(tr("Tasks"), jcontenTasks); + TabbedPanel.addTab(tr("Config"), jcontenConfig); + TabbedPanel.addTab(tr("Activation"), jcontenActivation); + + //add panels in JOSM + createLayout(TabbedPanel, false, Arrays.asList(new SideButton[]{ + skipButton, noterrorButton, fixedButton + })); + + if (!Status.server()) { + jcomboBox.setEnabled(false); + skipButton.setEnabled(false); + fixedButton.setEnabled(false); + noterrorButton.setEnabled(false); + } else { +// start(); + //Shortcuts + skipShortcut = Shortcut.registerShortcut("tofix:skip", tr("tofix:Skip item"), KeyEvent.VK_S, Shortcut.ALT_SHIFT); + Main.registerActionShortcut(new Skip_key_Action(), skipShortcut); + + fixedShortcut = Shortcut.registerShortcut("tofix:fixed", tr("tofix:Fixed item"), KeyEvent.VK_F, Shortcut.ALT_SHIFT); + Main.registerActionShortcut(new Fixed_key_Action(), fixedShortcut); + noterrorButtonShortcut = Shortcut.registerShortcut("tofix:noterror", tr("tofix:Not a Error item"), KeyEvent.VK_N, Shortcut.ALT_SHIFT); + Main.registerActionShortcut(new NotError_key_Action(), noterrorButtonShortcut); + } } + } - JComboBox jcomboBox = new JComboBox(tasksList.toArray()); + public final void start() { + mainAccessToTask = new AccessToTask("mixedlayer", false);//start mixedlayer task by default + } - valuePanel.add(jcomboBox); - jcomboBox.addActionListener(this); - createLayout(jcontenpanel, false, Arrays.asList(new SideButton[]{ - skipButton, fixedButton - })); - jcontenpanel.add(valuePanel); + public void msg() { + JOptionPane.showMessageDialog( + Main.parent, + tr("Activate to-fix plugin."), + tr("Warning"), + JOptionPane.WARNING_MESSAGE + ); + } - if (!Status.server()) { - jcomboBox.setEnabled(false); - skipButton.setEnabled(false); - fixedButton.setEnabled(false); + public class Skip_key_Action extends AbstractAction { + + @Override + public void actionPerformed(ActionEvent e) { + if (checkboxStatus) { + action("skip"); + deleteLayer(); + } else { + msg(); + } + } + } + + public class Fixed_key_Action extends AbstractAction { + + @Override + public void actionPerformed(ActionEvent e) { + if (checkboxStatus) { + eventFixed(e); + } else { + msg(); + } + } + } + + public class NotError_key_Action extends AbstractAction { + + @Override + public void actionPerformed(ActionEvent e) { + if (checkboxStatus) { + action("noterror"); + deleteLayer(); + } else { + msg(); + } } } @Override public void actionPerformed(ActionEvent e) { - JComboBox cb = (JComboBox) e.getSource(); + start(); + JComboBox cb = (JComboBox) e.getSource(); if (cb.getSelectedIndex() != 0) { - accessTaskBean.setTask(listTaskBean.getTasks().get(cb.getSelectedIndex() - 1).getId()); - accessTaskBean.setTask_source(listTaskBean.getTasks().get(cb.getSelectedIndex() - 1).getSource()); + mainAccessToTask.setTask_idtask(listTaskBean.getTasks().get(cb.getSelectedIndex() - 1).getIdtask()); + mainAccessToTask.setTask_isCompleted(listTaskBean.getTasks().get(cb.getSelectedIndex() - 1).getIsCompleted()); + mainAccessToTask.setTask_name(listTaskBean.getTasks().get(cb.getSelectedIndex() - 1).getName()); + mainAccessToTask.setTask_description(listTaskBean.getTasks().get(cb.getSelectedIndex() - 1).getDescription()); + mainAccessToTask.setTask_updated(listTaskBean.getTasks().get(cb.getSelectedIndex() - 1).getUpdated()); + mainAccessToTask.setTask_changesetComment(listTaskBean.getTasks().get(cb.getSelectedIndex() - 1).getChangesetComment()); + mainAccessToTask.setTask_date(listTaskBean.getTasks().get(cb.getSelectedIndex() - 1).getDate()); + mainAccessToTask.setTask_edit(listTaskBean.getTasks().get(cb.getSelectedIndex() - 1).getEdit()); + mainAccessToTask.setTask_fixed(listTaskBean.getTasks().get(cb.getSelectedIndex() - 1).getFixed()); + mainAccessToTask.setTask_skip(listTaskBean.getTasks().get(cb.getSelectedIndex() - 1).getSkip()); + mainAccessToTask.setTask_items(listTaskBean.getTasks().get(cb.getSelectedIndex() - 1).getItems()); + mainAccessToTask.setTask_noterror(listTaskBean.getTasks().get(cb.getSelectedIndex() - 1).getNoterror()); + deleteLayer(); get_new_item(); skipButton.setEnabled(true); fixedButton.setEnabled(true); + noterrorButton.setEnabled(true); } else { skipButton.setEnabled(false); fixedButton.setEnabled(false); + noterrorButton.setEnabled(false); } } public void edit() { - if (accessTaskBean.isAccess()) { - Download.Download(downloadOsmTask, bounds, accessTaskBean.getOsm_obj_id()); + if (mainAccessToTask.isAccess()) { TrackBean trackBean = new TrackBean(); - AttributesBean attributesBean = new AttributesBean(); - attributesBean.setAction("edit"); - attributesBean.setEditor("josm"); - attributesBean.setUser(josmUserIdentityManager.getUserName()); - attributesBean.setKey(accessTaskBean.getKey()); - trackBean.setAttributes(attributesBean); - ItemEditController itemEditController = new ItemEditController(accessTaskBean.getTrack_url(), trackBean); - itemEditController.sendTrackBean(); + trackBean.getAttributes().setEditor("josm"); + trackBean.getAttributes().setUser(josmUserIdentityManager.getUserName()); + itemTrackController.send_track_edit(mainAccessToTask.getTask_url(), trackBean); } } - public void skip() { - if (accessTaskBean.isAccess()) { - TrackBean trackBean = new TrackBean(); - AttributesBean attributesBean = new AttributesBean(); - attributesBean.setAction("skip"); - attributesBean.setEditor("josm"); - attributesBean.setUser(josmUserIdentityManager.getUserName()); - attributesBean.setKey(accessTaskBean.getKey()); - trackBean.setAttributes(attributesBean); - ItemSkipController skipController = new ItemSkipController(accessTaskBean.getTrack_url(), trackBean); - skipController.sendTrackBean(); + public void action(String action) { //fixed, noterror or skip + if (mainAccessToTask.isAccess()) { + ActionBean trackBean = new ActionBean(); + trackBean.setAction(action); + trackBean.setEditor("josm"); + trackBean.setUser(josmUserIdentityManager.getUserName()); + trackBean.setKey(mainAccessToTask.getKey()); + itemTrackController.send_track_action(mainAccessToTask.getTask_url(), trackBean); } get_new_item(); } - public void fixed() { - if (accessTaskBean.isAccess()) { - ItemFixedBean itemFixedBean = new ItemFixedBean(); - itemFixedBean.setUser(josmUserIdentityManager.getUserName()); - itemFixedBean.setKey(accessTaskBean.getKey()); - //itemFixedBean.setEditor("josm"); - ItemFixedController itemFixedController = new ItemFixedController(accessTaskBean.getFixed_url(), itemFixedBean); - itemFixedController.sendTrackBean(); - } - get_new_item(); - } - private void get_new_item() { - if (accessTaskBean.getTask_source().equals("keepright")) { - get_item_keepright(); - edit(); - } - - if (accessTaskBean.getTask_source().equals("unconnected")) { - if (accessTaskBean.getTask().equals("unconnected_minor1")) { - JOptionPane.showConfirmDialog(Main.panel, "Not implemented yet"); - } else { - get_item_unconnected(); + item.setStatus(0); + itemController.setAccessToTask(mainAccessToTask); + item = itemController.getItem(); + switch (item.getStatus()) { + case 200: + mainAccessToTask.setAccess(true); + mainAccessToTask = tofixTask.work(item, mainAccessToTask, zise); edit(); - } - } - if (accessTaskBean.getTask_source().equals("tigerdelta")) { - get_item_tigerdelta(); - edit(); - } - - if (accessTaskBean.getTask_source().equals("nycbuildings")) { - get_item_nycbuildings(); - edit(); - } - } - - private void get_item_keepright() { - ItemKeeprightBean itemKeeprightBean = null; - itemController.setUrl(accessTaskBean.getTask_url()); - itemKeeprightBean = itemController.getItemKeeprightBean(); - Util.print(itemKeeprightBean.getKey()); - if (itemKeeprightBean != null) { - accessTaskBean.setAccess(true); - accessTaskBean.setOsm_obj_id(itemKeeprightBean.getValue().getObject_id()); - accessTaskBean.setKey(itemKeeprightBean.getKey()); - LatLon latLon = Util.format_St_astext_Keepright(itemKeeprightBean.getValue().getSt_astext()); - bounds = new Bounds(latLon.toBBox(0.0007).toRectangle()); - - TofixDraw.draw_Node(tofixLayer, latLon); - } else { - accessTaskBean.setAccess(false); - JOptionPane.showMessageDialog(Main.parent, "Something went wrong on Server!, Please change the Task or try to again"); + break; + case 410: + mainAccessToTask.setAccess(false); + tofixTask.task_complete(item, mainAccessToTask); + break; + case 503: + mainAccessToTask.setAccess(false); + new Notification(tr("Maintenance server")).show(); + break; + case 520: + mainAccessToTask.setAccess(false); + JLabel text = new javax.swing.JLabel(); + text.setText(tr("Something went wrong, please update the plugin or report an issue at josm-tofix-plugin/issues")); + text.setCursor(new Cursor(Cursor.HAND_CURSOR)); + text.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + OpenBrowser.displayUrl(Config.URL_TOFIX_ISSUES); + } + }); + JOptionPane.showMessageDialog(Main.panel, text, tr("Warning"), JOptionPane.WARNING_MESSAGE); + break; + default: + mainAccessToTask.setAccess(false); + new Notification(tr("Something went wrong, try again")).show(); } } - private void get_item_unconnected() { - ItemUnconnectedBean itemUnconnectedBean = null; - itemController.setUrl(accessTaskBean.getTask_url()); - itemUnconnectedBean = itemController.getItemBean(); - if (itemUnconnectedBean != null) { - accessTaskBean.setAccess(true); - accessTaskBean.setOsm_obj_id(itemUnconnectedBean.getValue().getNode_id()); - accessTaskBean.setKey(itemUnconnectedBean.getKey()); - // itemUnconnectedBean. - //Util.print(itemUnconnectedBean.getValue().getY()+" o "+itemUnconnectedBean.getValue().getX()); - LatLon latLon = new LatLon(itemUnconnectedBean.getValue().getY(), itemUnconnectedBean.getValue().getX()); - bounds = new Bounds(latLon.toBBox(0.0007).toRectangle()); - TofixDraw.draw_Node(tofixLayer, latLon); + private void eventFixed(ActionEvent e) { + if (!Main.getLayerManager().getEditDataSet().isModified()) { + new Notification(tr("No change to upload!")).show(); + action("skipeventFixed"); + } else if (new Bounds(Main.getLayerManager().getEditDataSet().getDataSourceArea().getBounds()).getArea() < 30) { + validator = false; + UploadDialog.getUploadDialog().addComponentListener(new ComponentAdapter() { + @Override + public void componentShown(ComponentEvent e) { + validator = true; + } + }); + Main.getLayerManager().getEditLayer().data.getChangeSetTags().put("comment", mainAccessToTask.getTask_changesetComment()); + Main.getLayerManager().getEditLayer().data.getChangeSetTags().put("source", Main.map.mapView.getLayerInformationForSourceTag()); + + new UploadAction().actionPerformed(e); + + if (validator && !UploadDialog.getUploadDialog().isCanceled() && UploadDialog.getUploadDialog().getChangeset().isNew()) { + action("fixed"); + deleteLayer(); + } } else { - accessTaskBean.setAccess(false); - JOptionPane.showMessageDialog(Main.parent, "Something went wrong on Server!, Please change the Task or try to again"); + new Notification(tr("The bounding box is too big.")).show(); } } - private void get_item_nycbuildings() { - ItemNycbuildingsBean itemNycbuildingsBean = null; - itemController.setUrl(accessTaskBean.getTask_url()); - itemNycbuildingsBean = itemController.getItemNycbuildingsBean(); - Util.print(accessTaskBean.getTask_url()); - if (itemNycbuildingsBean != null) { - accessTaskBean.setAccess(true); - accessTaskBean.setOsm_obj_id(Util.format_Elems_Nycbuildings(itemNycbuildingsBean.getValue().getElems())); - accessTaskBean.setKey(itemNycbuildingsBean.getKey()); - LatLon latLon = new LatLon(itemNycbuildingsBean.getValue().getLat(), itemNycbuildingsBean.getValue().getLon()); - Util.print(latLon); - bounds = new Bounds(latLon.toBBox(0.0007).toRectangle()); - TofixDraw.draw_Node(tofixLayer, latLon); - } else { - accessTaskBean.setAccess(false); - JOptionPane.showMessageDialog(Main.parent, "Something went wrong on Server!, Please change the Task or try to again"); + public void deleteLayer() { + if (checkboxStatusLayer) { + if (Main.getLayerManager().getEditLayer() != null) { + Main.getLayerManager().getEditLayer().data.clear(); + Main.getLayerManager().removeLayer(Main.getLayerManager().getEditLayer()); + } } - } - private void get_item_tigerdelta() { - ItemTigerdeltaBean itemTigerdeltaBean = null; - itemController.setUrl(accessTaskBean.getTask_url()); - itemTigerdeltaBean = itemController.getItemTigerdeltaBean(); - Util.print(accessTaskBean.getTask_url()); - if (itemTigerdeltaBean != null) { - accessTaskBean.setAccess(true); - accessTaskBean.setOsm_obj_id(itemTigerdeltaBean.getValue().getWay()); - accessTaskBean.setKey(itemTigerdeltaBean.getKey()); - List> list = Util.format_st_astext_Tigerdelta(itemTigerdeltaBean.getValue().getSt_astext()); - LatLon latLon = new LatLon(list.get(0).get(0).getCoor().lat(), list.get(0).get(0).getCoor().lon());// Util.print(latLon); - bounds = new Bounds(latLon.toBBox(0.001).toRectangle()); - TofixDraw.draw_line(tofixLayer, latLon, list); - - } else { - accessTaskBean.setAccess(false); - JOptionPane.showMessageDialog(Main.parent, "Something went wrong on Server!, Please change the Task or try to again"); - } - + public void downloadCancelled() { + action("skip"); + deleteLayer(); } } diff --git a/src/org/openstreetmap/josm/plugins/tofix/TofixDraw.java b/src/org/openstreetmap/josm/plugins/tofix/TofixDraw.java index 26710b5..f43c368 100644 --- a/src/org/openstreetmap/josm/plugins/tofix/TofixDraw.java +++ b/src/org/openstreetmap/josm/plugins/tofix/TofixDraw.java @@ -1,39 +1,33 @@ package org.openstreetmap.josm.plugins.tofix; +import static org.openstreetmap.josm.tools.I18n.tr; + import java.util.List; + import javax.swing.JOptionPane; + import org.openstreetmap.josm.Main; import org.openstreetmap.josm.data.Bounds; import org.openstreetmap.josm.data.coor.LatLon; import org.openstreetmap.josm.data.osm.Node; import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; -import org.openstreetmap.josm.gui.MapView; -import org.openstreetmap.josm.plugins.tofix.bean.ItemUnconnectedBean; -import org.openstreetmap.josm.plugins.tofix.layer.TofixLayer; -import static org.openstreetmap.josm.tools.I18n.tr; - /** * * @author ruben */ public class TofixDraw { - ItemUnconnectedBean itemBean = null; - public static void draw_Node(final TofixLayer tofixLayer, LatLon latLon) { - MapView mv = Main.map.mapView; - Bounds bounds = null; if (latLon.isOutSideWorld()) { - JOptionPane.showMessageDialog(Main.parent, tr("Can not find outside of the world.")); + JOptionPane.showMessageDialog(Main.parent, tr("Cannot place a node outside of the world.")); return; } BoundingXYVisitor v = new BoundingXYVisitor(); - //double ex = 0.0001; = 2.34 m - //double ex = 0.0007;// 16.7 m + v.visit(new Bounds(latLon.toBBox(0.0007).toRectangle())); Main.map.mapView.zoomTo(v); - if (!Main.map.mapView.hasLayer(tofixLayer)) { - mv.addLayer(tofixLayer); + if (!Main.getLayerManager().containsLayer(tofixLayer)) { + Main.getLayerManager().addLayer(tofixLayer); tofixLayer.add_Node(latLon); } else { tofixLayer.add_Node(latLon); @@ -41,23 +35,34 @@ public static void draw_Node(final TofixLayer tofixLayer, LatLon latLon) { } public static void draw_line(final TofixLayer tofixLayer, LatLon latLon, List> list_nodes) { - MapView mv = Main.map.mapView; - Bounds bounds = null; if (latLon.isOutSideWorld()) { - JOptionPane.showMessageDialog(Main.parent, tr("Can not find outside of the world.")); + JOptionPane.showMessageDialog(Main.parent, tr("Cannot place a node outside of the world.")); return; } BoundingXYVisitor v = new BoundingXYVisitor(); - //double ex = 0.0001; = 2.34 m - //double ex = 0.0007;// 16.7 m v.visit(new Bounds(latLon.toBBox(0.0007).toRectangle())); Main.map.mapView.zoomTo(v); - if (!Main.map.mapView.hasLayer(tofixLayer)) { - mv.addLayer(tofixLayer); + if (!Main.getLayerManager().containsLayer(tofixLayer)) { + Main.getLayerManager().addLayer(tofixLayer); tofixLayer.add_Line(list_nodes); } else { tofixLayer.add_Line(list_nodes); } } + public static void draw_nodes(final TofixLayer tofixLayer, LatLon latLon, List list_nodes) { + if (latLon.isOutSideWorld()) { + JOptionPane.showMessageDialog(Main.parent, tr("Cannot place a node outside of the world.")); + return; + } + BoundingXYVisitor v = new BoundingXYVisitor(); + v.visit(new Bounds(latLon.toBBox(0.0007).toRectangle())); + Main.map.mapView.zoomTo(v); + if (!Main.getLayerManager().containsLayer(tofixLayer)) { + Main.getLayerManager().addLayer(tofixLayer); + tofixLayer.add_Nodes(list_nodes); + } else { + tofixLayer.add_Nodes(list_nodes); + } + } } diff --git a/src/org/openstreetmap/josm/plugins/tofix/layer/TofixLayer.java b/src/org/openstreetmap/josm/plugins/tofix/TofixLayer.java similarity index 70% rename from src/org/openstreetmap/josm/plugins/tofix/layer/TofixLayer.java rename to src/org/openstreetmap/josm/plugins/tofix/TofixLayer.java index 58466ec..aee596f 100644 --- a/src/org/openstreetmap/josm/plugins/tofix/layer/TofixLayer.java +++ b/src/org/openstreetmap/josm/plugins/tofix/TofixLayer.java @@ -1,46 +1,55 @@ -package org.openstreetmap.josm.plugins.tofix.layer; +package org.openstreetmap.josm.plugins.tofix; + +import static org.openstreetmap.josm.tools.I18n.tr; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Point; +import java.awt.Stroke; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Collection; import java.util.List; + import javax.swing.Action; import javax.swing.Icon; import javax.swing.JOptionPane; + import org.openstreetmap.josm.Main; import org.openstreetmap.josm.data.Bounds; import org.openstreetmap.josm.data.coor.LatLon; import org.openstreetmap.josm.data.osm.Node; import org.openstreetmap.josm.data.osm.OsmPrimitive; import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; +import org.openstreetmap.josm.data.osm.visitor.paint.MapRendererFactory; import org.openstreetmap.josm.gui.MapView; import org.openstreetmap.josm.gui.dialogs.LayerListDialog; import org.openstreetmap.josm.gui.dialogs.LayerListPopup; import org.openstreetmap.josm.gui.layer.Layer; -import static org.openstreetmap.josm.tools.I18n.tr; import org.openstreetmap.josm.tools.ImageProvider; public class TofixLayer extends Layer implements ActionListener { LatLon latLon; - List> list_nodes; - boolean isnode = true; + List> list_list_nodes; + List list_nodes; + String type = ""; + float width; - //List listcoordinates = new LinkedList(); + final Collection points = Main.main.getInProgressSelection(); + + /** + * Constructs a new {@code TofixLayer}. + * @param name layer name + */ public TofixLayer(String name) { super(name); } - // private static final Icon icon = new ImageIcon("icontofix.png"); - final Collection points = Main.main.getInProgressSelection(); @Override public Icon getIcon() { - //return icon; - return ImageProvider.get("layer", "marker_small"); + return ImageProvider.get("icontofix_layer"); } @Override @@ -54,38 +63,52 @@ public boolean isMergable(Layer other) { } public void add_Node(LatLon latLon) { - //listcoordinates.add(coordinate); - isnode = true; + type = "draw_node"; this.latLon = latLon; Main.map.mapView.repaint(); - } public void add_Line(List> list_nodes) { - //listcoordinates.add(coordinate); - isnode = false; - this.list_nodes = list_nodes; + type = "draw_line"; + this.list_list_nodes = list_nodes; Main.map.mapView.repaint(); + } + public void add_Nodes(List list_nodes) { + type = "draw_nodes"; + this.list_nodes = list_nodes; + Main.map.mapView.repaint(); } @Override public void paint(Graphics2D g, final MapView mv, Bounds bounds) { + Stroke ss = g.getStroke(); + if (MapRendererFactory.getInstance().isWireframeMapRendererActive()) { + width = 1f; + } else { + width = 5f; + } + g.setColor(new Color(254, 30, 123)); - g.setStroke(new BasicStroke((float) 5)); - if (isnode) { + g.setStroke(new BasicStroke((float) width)); + if ("draw_node".equals(type)) { Point pnt = mv.getPoint(latLon); g.drawOval(pnt.x - 25, pnt.y - 25, 50, 50); - } else { - for (List l_nodes : list_nodes) { + } else if ("draw_line".equals(type)) { + for (List l_nodes : list_list_nodes) { for (int i = 0; i < l_nodes.size() - 1; i++) { Point pnt1 = mv.getPoint(l_nodes.get(i).getCoor()); Point pnt2 = mv.getPoint(l_nodes.get(i + 1).getCoor()); g.drawLine(pnt1.x, pnt1.y, pnt2.x, pnt2.y); } } + } else if ("draw_nodes".equals(type)) { + for (Node node : list_nodes) { + Point pnt = mv.getPoint(node.getCoor()); + g.drawOval(pnt.x - 10, pnt.y - 10, 20, 20); + } } - + g.setStroke(ss); } @Override @@ -114,5 +137,6 @@ public void actionPerformed(ActionEvent e) { @Override public void mergeFrom(Layer layer) { + } } diff --git a/src/org/openstreetmap/josm/plugins/tofix/TofixMode.java b/src/org/openstreetmap/josm/plugins/tofix/TofixMode.java deleted file mode 100644 index b1977cb..0000000 --- a/src/org/openstreetmap/josm/plugins/tofix/TofixMode.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.openstreetmap.josm.plugins.tofix; - -import java.awt.Cursor; -import org.openstreetmap.josm.Main; -import org.openstreetmap.josm.actions.mapmode.MapMode; -import org.openstreetmap.josm.gui.MapFrame; - -/** - * - * @author ruben - */ -public class TofixMode extends MapMode { - - public TofixMode(MapFrame mapFrame, String name, String desc) { - super(name, "icontofix.png", desc, mapFrame, Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); - } - - @Override - public void enterMode() { - super.enterMode(); - Main.map.mapView.addMouseListener(this); - } - - @Override - public void exitMode() { - super.exitMode(); - Main.map.mapView.removeMouseListener(this); - } -} diff --git a/src/org/openstreetmap/josm/plugins/tofix/TofixPlugin.java b/src/org/openstreetmap/josm/plugins/tofix/TofixPlugin.java index 6ff228e..8563330 100644 --- a/src/org/openstreetmap/josm/plugins/tofix/TofixPlugin.java +++ b/src/org/openstreetmap/josm/plugins/tofix/TofixPlugin.java @@ -1,36 +1,25 @@ package org.openstreetmap.josm.plugins.tofix; -import org.openstreetmap.josm.gui.IconToggleButton; +import java.awt.GraphicsEnvironment; + import org.openstreetmap.josm.gui.MapFrame; import org.openstreetmap.josm.plugins.Plugin; import org.openstreetmap.josm.plugins.PluginInformation; public class TofixPlugin extends Plugin { - private IconToggleButton btn; - protected static TofixDialog tofixDialog; - private TofixMode mode; - + /** + * Constructs a new {@code TofixPlugin}. + * @param info plugin information + */ public TofixPlugin(PluginInformation info) { super(info); } @Override public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { - if (newFrame != null) { - newFrame.addToggleDialog(tofixDialog = new TofixDialog()); - //mode = new TofixMode(newFrame, "To-Fix", tr("To-fix mode")); -// btn = new IconToggleButton(mode); -// btn.setVisible(true); -// newFrame.addMapMode(btn); - + if (newFrame != null && !GraphicsEnvironment.isHeadless()) { + newFrame.addToggleDialog(new TofixDialog()); } -// else { -// btn = null; -// mode = null; -// tofixDialog = null; -// //Rub21 -// } - } } diff --git a/src/org/openstreetmap/josm/plugins/tofix/TofixTask.java b/src/org/openstreetmap/josm/plugins/tofix/TofixTask.java new file mode 100644 index 0000000..e8dae3a --- /dev/null +++ b/src/org/openstreetmap/josm/plugins/tofix/TofixTask.java @@ -0,0 +1,97 @@ +package org.openstreetmap.josm.plugins.tofix; + +import static org.openstreetmap.josm.tools.I18n.tr; + +import java.text.DecimalFormat; +import java.util.List; + +import org.openstreetmap.josm.Main; +import org.openstreetmap.josm.data.Bounds; +import org.openstreetmap.josm.data.coor.LatLon; +import org.openstreetmap.josm.data.osm.Node; +import org.openstreetmap.josm.gui.MapView; +import org.openstreetmap.josm.gui.Notification; +import org.openstreetmap.josm.gui.io.UploadDialog; +import org.openstreetmap.josm.plugins.tofix.bean.AccessToTask; +import org.openstreetmap.josm.plugins.tofix.bean.items.Item; +import org.openstreetmap.josm.plugins.tofix.bean.items.ItemOsmlintLinestring; +import org.openstreetmap.josm.plugins.tofix.bean.items.ItemOsmlintMultipoint; +import org.openstreetmap.josm.plugins.tofix.bean.items.ItemOsmlintPoint; +import org.openstreetmap.josm.plugins.tofix.controller.ItemController; +import org.openstreetmap.josm.plugins.tofix.util.Download; + +/** + * + * @author ruben + */ +public class TofixTask { + + ItemController itemController = new ItemController(); + Bounds bounds = null; + + Node node = null; + MapView mv = null; + TofixLayer tofixLayer = new TofixLayer("Tofix-layer"); + + public AccessToTask work(Item item, AccessToTask accessToTask, double size) { //size to download + if ("Point".equals(item.getType())) { + accessToTask = work_osmlintpoint(item.getItemOsmlintPoint(), accessToTask, size); + } + if ("LineString".equals(item.getType())) { + accessToTask = work_osmlintlinestring(item.getItemOsmlintLinestring(), accessToTask, size); + } + if ("MultiPoint".equals(item.getType())) { + accessToTask = work_osmlintmultipoint(item.getItemOsmlintMultipoint(), accessToTask, size); + } + + UploadDialog.getUploadDialog().getChangeset().getCommentsCount(); + return accessToTask; + } + + private AccessToTask work_osmlintpoint(ItemOsmlintPoint itemOsmlintPoint, AccessToTask accessToTask, double size) { + accessToTask.setKey(itemOsmlintPoint.getKey()); + node = itemOsmlintPoint.get_node(); + bounds = new Bounds(node.getCoor().toBBox(size).toRectangle()); + checkTofixLayer(); + TofixDraw.draw_Node(tofixLayer, node.getCoor()); + Download.download(bounds, itemOsmlintPoint.getWay()); + return accessToTask; + } + + private AccessToTask work_osmlintlinestring(ItemOsmlintLinestring itemOsmlintLinestring, AccessToTask accessToTask, double size) { + accessToTask.setKey(itemOsmlintLinestring.getKey()); + List> list = itemOsmlintLinestring.get_nodes(); + node = new Node(new LatLon(list.get(0).get(0).getCoor().lat(), list.get(0).get(0).getCoor().lon())); + bounds = new Bounds(node.getCoor().toBBox(size).toRectangle()); + checkTofixLayer(); + TofixDraw.draw_line(tofixLayer, node.getCoor(), list); + + Download.download(bounds, itemOsmlintLinestring.getWay()); + return accessToTask; + } + + private AccessToTask work_osmlintmultipoint(ItemOsmlintMultipoint itemOsmlintMultipoint, AccessToTask accessToTask, double size) { + accessToTask.setKey(itemOsmlintMultipoint.getKey()); + List list = itemOsmlintMultipoint.get_nodes(); + node = new Node(new LatLon(list.get(0).getCoor().lat(), list.get(0).getCoor().lon())); + bounds = new Bounds(node.getCoor().toBBox(size).toRectangle()); + checkTofixLayer(); + TofixDraw.draw_nodes(tofixLayer, node.getCoor(), list); + Download.download(bounds, itemOsmlintMultipoint.getWay()); + return accessToTask; + } + + public void task_complete(Item item, AccessToTask accessToTask) { + DecimalFormat myFormatter = new DecimalFormat("#,###"); + String num = myFormatter.format(item.getTaskCompleteBean().getTotal()); + String message = "Task " + accessToTask.getTask_name() + " is complete\n" + + num + " issues fixed"; + new Notification(tr(message)).show(); + } + + public final void checkTofixLayer() { + if (!Main.getLayerManager().containsLayer(tofixLayer)) { + Main.getLayerManager().addLayer(tofixLayer); + } + } +} diff --git a/src/org/openstreetmap/josm/plugins/tofix/bean/AccessTaskBean.java b/src/org/openstreetmap/josm/plugins/tofix/bean/AccessTaskBean.java deleted file mode 100644 index bddef6c..0000000 --- a/src/org/openstreetmap/josm/plugins/tofix/bean/AccessTaskBean.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.openstreetmap.josm.plugins.tofix.bean; - -/** - * - * @author ruben - */ -public class AccessTaskBean { - - private String host = "http://54.147.184.23:8000"; - private String task; - private String task_source; - private boolean access; - private Long osm_obj_id; - private String key; - - public AccessTaskBean(String task, String task_source, boolean access) { - this.task = task; - this.task_source = task_source; - this.access = access; - } - - public String getHost() { - return host; - } - - public void setHost(String host) { - this.host = host; - } - - public String getTask_url() { - String url = this.getHost() + "/task/" + this.getTask(); - return url; - } - - public String getTask() { - return task; - } - - public void setTask(String task) { - this.task = task; - } - - public String getTask_source() { - return task_source; - } - - public void setTask_source(String task_source) { - this.task_source = task_source; - } - - public boolean isAccess() { - return access; - } - - public void setAccess(boolean access) { - this.access = access; - } - - public String getTrack_url() { - return getHost() + "/track/" + getTask(); - } - - public String getFixed_url() { - return getHost() + "/fixed/" + getTask(); - } - - public Long getOsm_obj_id() { - return osm_obj_id; - } - - public void setOsm_obj_id(Long osm_obj_id) { - this.osm_obj_id = osm_obj_id; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - - -} diff --git a/src/org/openstreetmap/josm/plugins/tofix/bean/AccessToTask.java b/src/org/openstreetmap/josm/plugins/tofix/bean/AccessToTask.java new file mode 100644 index 0000000..71c1a50 --- /dev/null +++ b/src/org/openstreetmap/josm/plugins/tofix/bean/AccessToTask.java @@ -0,0 +1,167 @@ +package org.openstreetmap.josm.plugins.tofix.bean; + +import org.openstreetmap.josm.plugins.tofix.util.Config; + +/** + * + * @author ruben + */ +public class AccessToTask { + + private String host = Config.HOST; + + private String task_idtask; + private boolean task_isCompleted; + private String task_name; + private String task_description; + private String task_updated; + private String task_changesetComment; + private String task_date; + private int task_edit; + private int task_fixed; + private int task_skip; + private int task_items; + private int task_noterror; + + private boolean access; + private Long osm_obj_id; + private String key; + + public AccessToTask(String task_id, boolean access) { + this.task_idtask = task_id; + this.access = access; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public String getTask_url() { + String url = this.getHost() + "/tasks/" + this.getTask_idtask()+"/items"; + return url; + } + + public boolean isAccess() { + return access; + } + + public void setAccess(boolean access) { + this.access = access; + } + + public Long getOsm_obj_id() { + return osm_obj_id; + } + + public void setOsm_obj_id(Long osm_obj_id) { + this.osm_obj_id = osm_obj_id; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getTask_name() { + return task_name; + } + + public void setTask_name(String task_name) { + this.task_name = task_name; + } + + public String getTask_idtask() { + return task_idtask; + } + + public void setTask_idtask(String task_idtask) { + this.task_idtask = task_idtask; + } + + public boolean getTask_isCompleted() { + return task_isCompleted; + } + + public void setTask_isCompleted(boolean task_isCompleted) { + this.task_isCompleted = task_isCompleted; + } + + public String getTask_description() { + return task_description; + } + + public void setTask_description(String task_description) { + this.task_description = task_description; + } + + public String getTask_updated() { + return task_updated; + } + + public void setTask_updated(String task_updated) { + this.task_updated = task_updated; + } + + public String getTask_changesetComment() { + return task_changesetComment; + } + + public void setTask_changesetComment(String task_changesetComment) { + this.task_changesetComment = task_changesetComment; + } + + public String getTask_date() { + return task_date; + } + + public void setTask_date(String task_date) { + this.task_date = task_date; + } + + public int getTask_edit() { + return task_edit; + } + + public void setTask_edit(int task_edit) { + this.task_edit = task_edit; + } + + public int getTask_fixed() { + return task_fixed; + } + + public void setTask_fixed(int task_fixed) { + this.task_fixed = task_fixed; + } + + public int getTask_skip() { + return task_skip; + } + + public void setTask_skip(int task_skip) { + this.task_skip = task_skip; + } + + public int getTask_items() { + return task_items; + } + + public void setTask_items(int task_items) { + this.task_items = task_items; + } + + public int getTask_noterror() { + return task_noterror; + } + + public void setTask_noterror(int task_noterror) { + this.task_noterror = task_noterror; + } +} diff --git a/src/org/openstreetmap/josm/plugins/tofix/bean/AttributesBean.java b/src/org/openstreetmap/josm/plugins/tofix/bean/ActionBean.java similarity index 82% rename from src/org/openstreetmap/josm/plugins/tofix/bean/AttributesBean.java rename to src/org/openstreetmap/josm/plugins/tofix/bean/ActionBean.java index dd677ac..00cfded 100644 --- a/src/org/openstreetmap/josm/plugins/tofix/bean/AttributesBean.java +++ b/src/org/openstreetmap/josm/plugins/tofix/bean/ActionBean.java @@ -4,12 +4,12 @@ * * @author ruben */ -public class AttributesBean { +public class ActionBean { - String user; - String action; - String key; - String editor; + private String user; + private String key; + private String editor; + private String action; public String getUser() { return user; @@ -19,14 +19,6 @@ public void setUser(String user) { this.user = user; } - public String getAction() { - return action; - } - - public void setAction(String action) { - this.action = action; - } - public String getKey() { return key; } @@ -43,4 +35,12 @@ public void setEditor(String editor) { this.editor = editor; } + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + } diff --git a/src/org/openstreetmap/josm/plugins/tofix/bean/ItemFixedBean.java b/src/org/openstreetmap/josm/plugins/tofix/bean/ItemFixedBean.java deleted file mode 100644 index f40a931..0000000 --- a/src/org/openstreetmap/josm/plugins/tofix/bean/ItemFixedBean.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.openstreetmap.josm.plugins.tofix.bean; - -/** - * - * @author ruben - */ -public class ItemFixedBean { - private String user; - private String key; - //private String editor; - - public String getUser() { - return user; - } - - public void setUser(String user) { - this.user = user; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - -} diff --git a/src/org/openstreetmap/josm/plugins/tofix/bean/ItemKeeprightBean.java b/src/org/openstreetmap/josm/plugins/tofix/bean/ItemKeeprightBean.java deleted file mode 100644 index 67bcc75..0000000 --- a/src/org/openstreetmap/josm/plugins/tofix/bean/ItemKeeprightBean.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.openstreetmap.josm.plugins.tofix.bean; - -/** - * - * @author ruben - */ -public class ItemKeeprightBean { - - private String key; - private ItemKeeprightValueBean value; - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public ItemKeeprightValueBean getValue() { - return value; - } - - public void setValue(ItemKeeprightValueBean value) { - this.value = value; - } - -} diff --git a/src/org/openstreetmap/josm/plugins/tofix/bean/ItemKeeprightValueBean.java b/src/org/openstreetmap/josm/plugins/tofix/bean/ItemKeeprightValueBean.java deleted file mode 100644 index b48822a..0000000 --- a/src/org/openstreetmap/josm/plugins/tofix/bean/ItemKeeprightValueBean.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.openstreetmap.josm.plugins.tofix.bean; - -/** - * - * @author ruben - */ -public class ItemKeeprightValueBean { - String object_type; - Long object_id; - String st_astext; - - public String getObject_type() { - return object_type; - } - - public void setObject_type(String object_type) { - this.object_type = object_type; - } - - public Long getObject_id() { - return object_id; - } - - public void setObject_id(Long object_id) { - this.object_id = object_id; - } - - - public String getSt_astext() { - return st_astext; - } - - public void setSt_astext(String st_astext) { - this.st_astext = st_astext; - } - - -} diff --git a/src/org/openstreetmap/josm/plugins/tofix/bean/ItemNycbuildingsBean.java b/src/org/openstreetmap/josm/plugins/tofix/bean/ItemNycbuildingsBean.java deleted file mode 100644 index 62fc295..0000000 --- a/src/org/openstreetmap/josm/plugins/tofix/bean/ItemNycbuildingsBean.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.openstreetmap.josm.plugins.tofix.bean; - -/** - * - * @author ruben - */ -public class ItemNycbuildingsBean { - private String key; - private ItemNycbuildingsValueBean value; - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public ItemNycbuildingsValueBean getValue() { - return value; - } - - public void setValue(ItemNycbuildingsValueBean value) { - this.value = value; - } - -} - diff --git a/src/org/openstreetmap/josm/plugins/tofix/bean/ItemNycbuildingsValueBean.java b/src/org/openstreetmap/josm/plugins/tofix/bean/ItemNycbuildingsValueBean.java deleted file mode 100644 index 256c742..0000000 --- a/src/org/openstreetmap/josm/plugins/tofix/bean/ItemNycbuildingsValueBean.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.openstreetmap.josm.plugins.tofix.bean; - -/** - * - * @author ruben - */ -public class ItemNycbuildingsValueBean { - - private Double lat; - private Double lon; - private String elems; - - public Double getLat() { - return lat; - } - - public void setLat(Double lat) { - this.lat = lat; - } - - public Double getLon() { - return lon; - } - - public void setLon(Double lon) { - this.lon = lon; - } - - public String getElems() { - return elems; - } - - public void setElems(String elems) { - this.elems = elems; - } - - - -} diff --git a/src/org/openstreetmap/josm/plugins/tofix/bean/ItemTigerdeltaBean.java b/src/org/openstreetmap/josm/plugins/tofix/bean/ItemTigerdeltaBean.java deleted file mode 100644 index 7f72d6e..0000000 --- a/src/org/openstreetmap/josm/plugins/tofix/bean/ItemTigerdeltaBean.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.openstreetmap.josm.plugins.tofix.bean; - -/** - * - * @author ruben - */ -public class ItemTigerdeltaBean { - - private String key; - private ItemTigerdeltaValueBean value; - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public ItemTigerdeltaValueBean getValue() { - return value; - } - - public void setValue(ItemTigerdeltaValueBean value) { - this.value = value; - } - -} diff --git a/src/org/openstreetmap/josm/plugins/tofix/bean/ItemTigerdeltaValueBean.java b/src/org/openstreetmap/josm/plugins/tofix/bean/ItemTigerdeltaValueBean.java deleted file mode 100644 index 5793c22..0000000 --- a/src/org/openstreetmap/josm/plugins/tofix/bean/ItemTigerdeltaValueBean.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.openstreetmap.josm.plugins.tofix.bean; - -/** - * - * @author ruben - */ -public class ItemTigerdeltaValueBean { - - private String name; - private Long way; - private String st_astext; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Long getWay() { - return way; - } - - public void setWay(Long way) { - this.way = way; - } - - public String getSt_astext() { - return st_astext; - } - - public void setSt_astext(String st_astext) { - this.st_astext = st_astext; - } - -} diff --git a/src/org/openstreetmap/josm/plugins/tofix/bean/ItemUnconnectedBean.java b/src/org/openstreetmap/josm/plugins/tofix/bean/ItemUnconnectedBean.java deleted file mode 100644 index 8fac5d0..0000000 --- a/src/org/openstreetmap/josm/plugins/tofix/bean/ItemUnconnectedBean.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.openstreetmap.josm.plugins.tofix.bean; - -/** - * - * @author ruben - */ -public class ItemUnconnectedBean { - private String key; - private ItemUnconnectedValueBean value; - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public ItemUnconnectedValueBean getValue() { - return value; - } - - public void setValue(ItemUnconnectedValueBean value) { - this.value = value; - } -} diff --git a/src/org/openstreetmap/josm/plugins/tofix/bean/ItemUnconnectedValueBean.java b/src/org/openstreetmap/josm/plugins/tofix/bean/ItemUnconnectedValueBean.java deleted file mode 100644 index 3c21f4d..0000000 --- a/src/org/openstreetmap/josm/plugins/tofix/bean/ItemUnconnectedValueBean.java +++ /dev/null @@ -1,91 +0,0 @@ -package org.openstreetmap.josm.plugins.tofix.bean; - -/** - * - * @author ruben - */ -public class ItemUnconnectedValueBean { - - Double X; - Double Y; - Float weight; - Integer problem_id; - Long way_id; - Long node_id; - String highwaykey; - Double distance; - String iso_a2; - - public Double getX() { - return X; - } - - public void setX(Double X) { - this.X = X; - } - - public Double getY() { - return Y; - } - - public void setY(Double Y) { - this.Y = Y; - } - - public Float getWeight() { - return weight; - } - - public void setWeight(Float weight) { - this.weight = weight; - } - - public Integer getProblem_id() { - return problem_id; - } - - public void setProblem_id(Integer problem_id) { - this.problem_id = problem_id; - } - - public Long getWay_id() { - return way_id; - } - - public void setWay_id(Long way_id) { - this.way_id = way_id; - } - - public Long getNode_id() { - return node_id; - } - - public void setNode_id(Long node_id) { - this.node_id = node_id; - } - - public String getHighwaykey() { - return highwaykey; - } - - public void setHighwaykey(String highwaykey) { - this.highwaykey = highwaykey; - } - - public Double getDistance() { - return distance; - } - - public void setDistance(Double distance) { - this.distance = distance; - } - - public String getIso_a2() { - return iso_a2; - } - - public void setIso_a2(String iso_a2) { - this.iso_a2 = iso_a2; - } - -} diff --git a/src/org/openstreetmap/josm/plugins/tofix/bean/ResponseBean.java b/src/org/openstreetmap/josm/plugins/tofix/bean/ResponseBean.java new file mode 100644 index 0000000..48927bd --- /dev/null +++ b/src/org/openstreetmap/josm/plugins/tofix/bean/ResponseBean.java @@ -0,0 +1,37 @@ +package org.openstreetmap.josm.plugins.tofix.bean; + +/** + * + * + * @author ruben + */ +public class ResponseBean { + + private int status; + private String value;//String from server response + + public ResponseBean() { + } + + public ResponseBean(int status, String value) { + this.status = status; + this.value = value; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/src/org/openstreetmap/josm/plugins/tofix/bean/StatusBean.java b/src/org/openstreetmap/josm/plugins/tofix/bean/StatusBean.java index 8b56676..fcde6b8 100644 --- a/src/org/openstreetmap/josm/plugins/tofix/bean/StatusBean.java +++ b/src/org/openstreetmap/josm/plugins/tofix/bean/StatusBean.java @@ -8,10 +8,6 @@ public class StatusBean { private String status; - public StatusBean(String status) { - this.status = status; - } - public String getStatus() { return status; } diff --git a/src/org/openstreetmap/josm/plugins/tofix/bean/TaskBean.java b/src/org/openstreetmap/josm/plugins/tofix/bean/TaskBean.java index d0bcc28..d29b0e2 100644 --- a/src/org/openstreetmap/josm/plugins/tofix/bean/TaskBean.java +++ b/src/org/openstreetmap/josm/plugins/tofix/bean/TaskBean.java @@ -1,36 +1,136 @@ package org.openstreetmap.josm.plugins.tofix.bean; + /** * * @author ruben */ public class TaskBean { - private String id; - private String title; - private String source; + private String idtask; + private boolean isCompleted; + private boolean isAllItemsLoad; + private String name; + private String description; + private String updated; + private String changesetComment; + private String date; + private int edit; + private int fixed; + private int skip; + private int items; + private int noterror; + + private String geometry; + + public String getIdtask() { + return idtask; + } + + public void setIdtask(String idtask) { + this.idtask = idtask; + } + + public boolean getIsCompleted() { + return isCompleted; + } + + public void setIsCompleted(boolean isCompleted) { + this.isCompleted = isCompleted; + } + + public String getName() { + return name; + } - public String getId() { - return id; + public void setName(String name) { + this.name = name; } - public void setId(String id) { - this.id = id; + public String getDescription() { + return description; } - public String getTitle() { - return title; + public void setDescription(String description) { + this.description = description; } - public void setTitle(String title) { - this.title = title; + public String getUpdated() { + return updated; } - public String getSource() { - return source; + public void setUpdated(String updated) { + this.updated = updated; } - public void setSource(String source) { - this.source = source; + public String getChangesetComment() { + return changesetComment; } + public void setChangesetComment(String changesetComment) { + this.changesetComment = changesetComment; + } + + public String getDate() { + return date; + } + + public void setDate(String date) { + this.date = date; + } + + public int getEdit() { + return edit; + } + + public void setEdit(int edit) { + this.edit = edit; + } + + public int getFixed() { + return fixed; + } + + public void setFixed(int fixed) { + this.fixed = fixed; + } + + public int getSkip() { + return skip; + } + + public void setSkip(int skip) { + this.skip = skip; + } + + public int getItems() { + return items; + } + + public void setItems(int items) { + this.items = items; + } + + public int getNoterror() { + return noterror; + } + + public void setNoterror(int noterror) { + this.noterror = noterror; + } + + public String getGeometry() { + return geometry; + } + + public void setGeometry(String geometry) { + this.geometry = geometry; + } + + public boolean isIsAllItemsLoad() { + return isAllItemsLoad; + } + + public void setIsAllItemsLoad(boolean isAllItemsLoad) { + this.isAllItemsLoad = isAllItemsLoad; + } } diff --git a/src/org/openstreetmap/josm/plugins/tofix/bean/TaskCompleteBean.java b/src/org/openstreetmap/josm/plugins/tofix/bean/TaskCompleteBean.java new file mode 100644 index 0000000..ad9c7a1 --- /dev/null +++ b/src/org/openstreetmap/josm/plugins/tofix/bean/TaskCompleteBean.java @@ -0,0 +1,19 @@ +package org.openstreetmap.josm.plugins.tofix.bean; + +/** + * + * @author ruben + */ +public class TaskCompleteBean { + + int total; + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + +} diff --git a/src/org/openstreetmap/josm/plugins/tofix/bean/TrackBean.java b/src/org/openstreetmap/josm/plugins/tofix/bean/TrackBean.java index 73a29a2..3ff9134 100644 --- a/src/org/openstreetmap/josm/plugins/tofix/bean/TrackBean.java +++ b/src/org/openstreetmap/josm/plugins/tofix/bean/TrackBean.java @@ -5,8 +5,8 @@ * @author ruben */ public class TrackBean { - - AttributesBean attributes; + + AttributesBean attributes = new AttributesBean(); public AttributesBean getAttributes() { return attributes; @@ -15,5 +15,47 @@ public AttributesBean getAttributes() { public void setAttributes(AttributesBean attributes) { this.attributes = attributes; } - + + //Atributos + public static class AttributesBean { + + String user; + String action; + String key; + String editor; + + public String getUser() { + return user; + } + + public void setUser(String user) { + this.user = user; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getEditor() { + return editor; + } + + public void setEditor(String editor) { + this.editor = editor; + } + + } + } diff --git a/src/org/openstreetmap/josm/plugins/tofix/bean/items/AbstractItemGeom.java b/src/org/openstreetmap/josm/plugins/tofix/bean/items/AbstractItemGeom.java new file mode 100644 index 0000000..99b65b0 --- /dev/null +++ b/src/org/openstreetmap/josm/plugins/tofix/bean/items/AbstractItemGeom.java @@ -0,0 +1,27 @@ +package org.openstreetmap.josm.plugins.tofix.bean.items; + +/** + * + * @author samely + */ +public abstract class AbstractItemGeom extends ItemTask { + + private String geometry; + private String coordinates; + + public String getGeometry() { + return geometry; + } + + public void setGeometry(String geom) { + this.geometry = geom; + } + + public String getCoordinates() { + return coordinates; + } + + public void setCoordinates(String coordinates) { + this.coordinates = coordinates; + } +} diff --git a/src/org/openstreetmap/josm/plugins/tofix/bean/items/AbstractItemOsmlint.java b/src/org/openstreetmap/josm/plugins/tofix/bean/items/AbstractItemOsmlint.java new file mode 100644 index 0000000..bb3ff0b --- /dev/null +++ b/src/org/openstreetmap/josm/plugins/tofix/bean/items/AbstractItemOsmlint.java @@ -0,0 +1,18 @@ +package org.openstreetmap.josm.plugins.tofix.bean.items; + +/** + * + * @author samely + */ +public abstract class AbstractItemOsmlint extends AbstractItemGeom { + + private Long way; + + public Long getWay() { + return way; + } + + public void setWay(Long way) { + this.way = way; + } +} diff --git a/src/org/openstreetmap/josm/plugins/tofix/bean/items/Item.java b/src/org/openstreetmap/josm/plugins/tofix/bean/items/Item.java new file mode 100644 index 0000000..842512e --- /dev/null +++ b/src/org/openstreetmap/josm/plugins/tofix/bean/items/Item.java @@ -0,0 +1,66 @@ +package org.openstreetmap.josm.plugins.tofix.bean.items; + +import org.openstreetmap.josm.plugins.tofix.bean.TaskCompleteBean; + +/** + * + * @author ruben + */ +public class Item { + + private int status; + private String type; + private TaskCompleteBean taskCompleteBean; + private ItemOsmlintPoint itemOsmlintPoint; + private ItemOsmlintMultipoint itemOsmlintMultipoint; + private ItemOsmlintLinestring itemOsmlintLinestring; + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public TaskCompleteBean getTaskCompleteBean() { + return taskCompleteBean; + } + + public void setTaskCompleteBean(TaskCompleteBean taskCompleteBean) { + this.taskCompleteBean = taskCompleteBean; + } + + public ItemOsmlintPoint getItemOsmlintPoint() { + return itemOsmlintPoint; + } + + public void setItemOsmlintPoint(ItemOsmlintPoint itemOsmlintPoint) { + this.itemOsmlintPoint = itemOsmlintPoint; + } + + public ItemOsmlintMultipoint getItemOsmlintMultipoint() { + return itemOsmlintMultipoint; + } + + public void setItemOsmlintMultipoint(ItemOsmlintMultipoint itemOsmlintMultipoint) { + this.itemOsmlintMultipoint = itemOsmlintMultipoint; + } + + public ItemOsmlintLinestring getItemOsmlintLinestring() { + return itemOsmlintLinestring; + } + + public void setItemOsmlintLinestring(ItemOsmlintLinestring itemOsmlintLinestring) { + this.itemOsmlintLinestring = itemOsmlintLinestring; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + +} diff --git a/src/org/openstreetmap/josm/plugins/tofix/bean/items/ItemOsmlintLinestring.java b/src/org/openstreetmap/josm/plugins/tofix/bean/items/ItemOsmlintLinestring.java new file mode 100644 index 0000000..734ceb3 --- /dev/null +++ b/src/org/openstreetmap/josm/plugins/tofix/bean/items/ItemOsmlintLinestring.java @@ -0,0 +1,31 @@ +package org.openstreetmap.josm.plugins.tofix.bean.items; + +import java.util.LinkedList; +import java.util.List; + +import org.openstreetmap.josm.data.coor.LatLon; +import org.openstreetmap.josm.data.osm.Node; + +/** + * + * @author samely + */ +public class ItemOsmlintLinestring extends AbstractItemOsmlint { + + public List> get_nodes() { + String geostring = getCoordinates(); + List> list = new LinkedList<>(); + geostring = geostring.replace("[[", "").replace("]]", ""); + String[] array = geostring.replace("[", "").split("],"); + List l = new LinkedList<>(); + + for (int i = 0; i < array.length; i++) { + LatLon latLon = new LatLon(Double.parseDouble(array[i].split(",")[1]), Double.parseDouble(array[i].split(",")[0])); + Node node = new Node(latLon); + l.add(node); + } + list.add(l); + + return list; + } +} diff --git a/src/org/openstreetmap/josm/plugins/tofix/bean/items/ItemOsmlintMultipoint.java b/src/org/openstreetmap/josm/plugins/tofix/bean/items/ItemOsmlintMultipoint.java new file mode 100644 index 0000000..810493e --- /dev/null +++ b/src/org/openstreetmap/josm/plugins/tofix/bean/items/ItemOsmlintMultipoint.java @@ -0,0 +1,29 @@ +package org.openstreetmap.josm.plugins.tofix.bean.items; + +import java.util.LinkedList; +import java.util.List; + +import org.openstreetmap.josm.data.coor.LatLon; +import org.openstreetmap.josm.data.osm.Node; + +/** + * + * @author samely + */ +public class ItemOsmlintMultipoint extends AbstractItemOsmlint { + + public List get_nodes() { + String geoString = getCoordinates(); + List list = new LinkedList<>(); + geoString = geoString.replace("[[", "").replace("]]", ""); + String[] arr = geoString.split("],"); + + for (int i = 0; i < arr.length; i++) { + String temp_array = arr[i].replace("[", ""); + LatLon latLon = new LatLon(Double.parseDouble(temp_array.split(",")[1]), Double.parseDouble(temp_array.split(",")[0])); + Node node = new Node(latLon); + list.add(node); + } + return list; + } +} diff --git a/src/org/openstreetmap/josm/plugins/tofix/bean/items/ItemOsmlintPoint.java b/src/org/openstreetmap/josm/plugins/tofix/bean/items/ItemOsmlintPoint.java new file mode 100644 index 0000000..b432283 --- /dev/null +++ b/src/org/openstreetmap/josm/plugins/tofix/bean/items/ItemOsmlintPoint.java @@ -0,0 +1,19 @@ +package org.openstreetmap.josm.plugins.tofix.bean.items; + +import org.openstreetmap.josm.data.coor.LatLon; +import org.openstreetmap.josm.data.osm.Node; + +/** + * + * @author samely + */ +public class ItemOsmlintPoint extends AbstractItemOsmlint { + + public Node get_node() { + String geoString = getCoordinates(); + geoString = geoString.replace("[", "").replace("]", ""); + String[] array = geoString.split(","); + LatLon latLon = new LatLon(Double.parseDouble(array[1]), Double.parseDouble(array[0])); + return new Node(latLon); + } +} diff --git a/src/org/openstreetmap/josm/plugins/tofix/bean/items/ItemTask.java b/src/org/openstreetmap/josm/plugins/tofix/bean/items/ItemTask.java new file mode 100644 index 0000000..53a5c8d --- /dev/null +++ b/src/org/openstreetmap/josm/plugins/tofix/bean/items/ItemTask.java @@ -0,0 +1,20 @@ + +package org.openstreetmap.josm.plugins.tofix.bean.items; + +/** + * + * @author ruben + */ +public class ItemTask { + + private String key; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + +} diff --git a/src/org/openstreetmap/josm/plugins/tofix/controller/ItemController.java b/src/org/openstreetmap/josm/plugins/tofix/controller/ItemController.java index 15cb7d5..cbe347f 100644 --- a/src/org/openstreetmap/josm/plugins/tofix/controller/ItemController.java +++ b/src/org/openstreetmap/josm/plugins/tofix/controller/ItemController.java @@ -1,14 +1,21 @@ package org.openstreetmap.josm.plugins.tofix.controller; -import com.google.gson.Gson; +import java.io.StringReader; +import java.net.HttpURLConnection; import java.util.logging.Level; import java.util.logging.Logger; -import javax.swing.JOptionPane; -import org.openstreetmap.josm.plugins.tofix.bean.ItemUnconnectedBean; -import org.openstreetmap.josm.plugins.tofix.bean.ItemKeeprightBean; -import org.openstreetmap.josm.plugins.tofix.bean.ItemNycbuildingsBean; -import org.openstreetmap.josm.plugins.tofix.bean.ItemTigerdeltaBean; +import javax.json.Json; +import javax.json.JsonObject; +import javax.json.JsonReader; +import org.openstreetmap.josm.plugins.tofix.bean.AccessToTask; +import org.openstreetmap.josm.plugins.tofix.bean.ResponseBean; +import org.openstreetmap.josm.plugins.tofix.bean.TaskCompleteBean; +import org.openstreetmap.josm.plugins.tofix.bean.items.Item; +import org.openstreetmap.josm.plugins.tofix.bean.items.ItemOsmlintLinestring; +import org.openstreetmap.josm.plugins.tofix.bean.items.ItemOsmlintMultipoint; +import org.openstreetmap.josm.plugins.tofix.bean.items.ItemOsmlintPoint; import org.openstreetmap.josm.plugins.tofix.util.Request; +import org.openstreetmap.josm.plugins.tofix.util.Util; /** * @@ -16,73 +23,88 @@ */ public class ItemController { - private String url; + Item item = new Item(); + ResponseBean responseBean = new ResponseBean(); - Gson gson = new Gson(); + AccessToTask accessToTask; - public String getUrl() { - return url; + public AccessToTask getAccessToTask() { + return accessToTask; } - public void setUrl(String url) { - this.url = url; + public void setAccessToTask(AccessToTask accessToTask) { + this.accessToTask = accessToTask; } - public ItemUnconnectedBean getItemBean() { - ItemUnconnectedBean itemUnconnectedBean = new ItemUnconnectedBean(); - String stringItem = null; - try { - stringItem = Request.sendPOST(getUrl()); - itemUnconnectedBean = gson.fromJson(stringItem, ItemUnconnectedBean.class); - return itemUnconnectedBean; - } catch (Exception ex) { - JOptionPane.showConfirmDialog(null, "null"); - Logger.getLogger(ItemController.class.getName()).log(Level.SEVERE, null, ex); - } - return null; - } + public Item getItem() { - public ItemKeeprightBean getItemKeeprightBean() { - ItemKeeprightBean itemKeeprightBean = new ItemKeeprightBean(); - String stringItem = null; try { - stringItem = Request.sendPOST(getUrl()); - itemKeeprightBean = gson.fromJson(stringItem, ItemKeeprightBean.class); - return itemKeeprightBean; - } catch (Exception ex) { - JOptionPane.showConfirmDialog(null, "null"); - Logger.getLogger(ItemController.class.getName()).log(Level.SEVERE, null, ex); - } - return null; - } + responseBean = Request.sendPOST(accessToTask.getTask_url()); + item.setStatus(responseBean.getStatus()); + Util.print(responseBean.getValue()); + JsonReader reader = Json.createReader(new StringReader(responseBean.getValue())); + JsonObject object = reader.readObject(); - public ItemNycbuildingsBean getItemNycbuildingsBean() { - ItemNycbuildingsBean itemNycbuildingsBean = new ItemNycbuildingsBean(); - String stringItem = null; - try { - stringItem = Request.sendPOST(getUrl()); - itemNycbuildingsBean = gson.fromJson(stringItem, ItemNycbuildingsBean.class); + switch (responseBean.getStatus()) { + case HttpURLConnection.HTTP_OK: + JsonObject geometry = (JsonObject) object.get("geometry"); + JsonObject properties = (JsonObject) object.get("properties"); + item.setType(geometry.getString("type")); - return itemNycbuildingsBean; - } catch (Exception ex) { - JOptionPane.showConfirmDialog(null, "null"); - Logger.getLogger(ItemController.class.getName()).log(Level.SEVERE, null, ex); - } - return null; - } + if (geometry.getString("type").equals("Point")) { + ItemOsmlintPoint iop = new ItemOsmlintPoint(); + iop.setKey(properties.getString("_key")); + if (properties.containsKey("_osmId") && geometry.containsKey("type")) { + iop.setWay(Long.parseLong(properties.getJsonNumber("_osmId").toString())); + iop.setGeometry(geometry.getJsonString("type").toString()); + iop.setCoordinates(geometry.get("coordinates").toString()); + item.setItemOsmlintPoint(iop); + } else { + item.setStatus(520); + } + } + if (geometry.getString("type").equals("MultiPoint")) { + ItemOsmlintMultipoint iom = new ItemOsmlintMultipoint(); + iom.setKey(properties.getString("_key")); + if (properties.containsKey("_osmId") && geometry.containsKey("type")) { + iom.setWay(Long.parseLong(properties.getJsonNumber("_osmId").toString())); + iom.setGeometry(geometry.getJsonString("type").toString()); + iom.setCoordinates(geometry.get("coordinates").toString()); + item.setItemOsmlintMultipoint(iom); + } else { + item.setStatus(520); + } - public ItemTigerdeltaBean getItemTigerdeltaBean() { - ItemTigerdeltaBean itemTigerdeltaBean = new ItemTigerdeltaBean(); - String stringItem = null; - try { - stringItem = Request.sendPOST(getUrl()); - itemTigerdeltaBean = gson.fromJson(stringItem, ItemTigerdeltaBean.class); + } + if (geometry.getString("type").equals("LineString")) { + ItemOsmlintLinestring iol = new ItemOsmlintLinestring(); + iol.setKey(properties.getString("_key")); + if (object.containsKey("geometry")) { + iol.setGeometry(geometry.getJsonString("type").toString()); + iol.setCoordinates(geometry.get("coordinates").toString()); + item.setItemOsmlintLinestring(iol); + } else { + item.setStatus(520); + } + + } + break; + case 410: + TaskCompleteBean taskCompleteBean = new TaskCompleteBean(); + taskCompleteBean.setTotal(0); + item.setTaskCompleteBean(taskCompleteBean); + break; + case 503: + //Servidor en mantenimiento + break; + } + + reader.close(); - return itemTigerdeltaBean; } catch (Exception ex) { - JOptionPane.showConfirmDialog(null, "null"); + Util.alert(ex); Logger.getLogger(ItemController.class.getName()).log(Level.SEVERE, null, ex); } - return null; + return item; } } diff --git a/src/org/openstreetmap/josm/plugins/tofix/controller/ItemEditController.java b/src/org/openstreetmap/josm/plugins/tofix/controller/ItemEditController.java deleted file mode 100644 index d0c4dd2..0000000 --- a/src/org/openstreetmap/josm/plugins/tofix/controller/ItemEditController.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.openstreetmap.josm.plugins.tofix.controller; - -import com.google.gson.Gson; -import java.io.IOException; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.openstreetmap.josm.plugins.tofix.bean.TrackBean; -import org.openstreetmap.josm.plugins.tofix.util.Request; -import org.openstreetmap.josm.plugins.tofix.util.Util; - -/** - * - * @author ruben - */ -public class ItemEditController { - - private String url; - private TrackBean trackBean; - - public ItemEditController(String url, TrackBean trackBean) { - this.url = url; - this.trackBean = trackBean; - } - - public void sendTrackBean() { - Gson gson = new Gson(); - String string_obj = gson.toJson(trackBean).toString(); - Util.print(string_obj); - try { - Request.sendPOST_Json(url, string_obj); - - } catch (IOException ex) { - Logger.getLogger(ItemController.class.getName()).log(Level.SEVERE, null, ex); - } - - } -} diff --git a/src/org/openstreetmap/josm/plugins/tofix/controller/ItemFixedController.java b/src/org/openstreetmap/josm/plugins/tofix/controller/ItemFixedController.java deleted file mode 100644 index e2ff2a4..0000000 --- a/src/org/openstreetmap/josm/plugins/tofix/controller/ItemFixedController.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.openstreetmap.josm.plugins.tofix.controller; - -import com.google.gson.Gson; -import java.io.IOException; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.openstreetmap.josm.plugins.tofix.bean.ItemFixedBean; -import org.openstreetmap.josm.plugins.tofix.bean.TrackBean; -import org.openstreetmap.josm.plugins.tofix.util.Request; -import org.openstreetmap.josm.plugins.tofix.util.Util; - -/** - * - * @author ruben - */ -public class ItemFixedController { - - private String url; - private ItemFixedBean itemFixedBean; - public ItemFixedController(String url, ItemFixedBean itemFixedBean) { - this.url = url; - this.itemFixedBean = itemFixedBean; - } - - public void sendTrackBean() { - Gson gson = new Gson(); - String string_obj = gson.toJson(itemFixedBean).toString(); - Util.print(string_obj); - try { - Request.sendPOST_Json(url, string_obj); - - } catch (IOException ex) { - Logger.getLogger(ItemController.class.getName()).log(Level.SEVERE, null, ex); - } - } -} diff --git a/src/org/openstreetmap/josm/plugins/tofix/controller/ItemSkipController.java b/src/org/openstreetmap/josm/plugins/tofix/controller/ItemSkipController.java deleted file mode 100644 index 1aacb05..0000000 --- a/src/org/openstreetmap/josm/plugins/tofix/controller/ItemSkipController.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.openstreetmap.josm.plugins.tofix.controller; - -import com.google.gson.Gson; -import java.io.IOException; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.openstreetmap.josm.plugins.tofix.bean.TrackBean; -import org.openstreetmap.josm.plugins.tofix.util.Request; -import org.openstreetmap.josm.plugins.tofix.util.Util; - -/** - * - * @author ruben - */ -public class ItemSkipController { - - private String url; - private TrackBean trackBean; - - public ItemSkipController(String url, TrackBean trackBean) { - this.url = url; - this.trackBean = trackBean; - } - - public void sendTrackBean() { - Gson gson = new Gson(); - String string_obj = gson.toJson(trackBean).toString(); - Util.print(string_obj); - try { - Request.sendPOST_Json(url, string_obj); - - } catch (IOException ex) { - Logger.getLogger(ItemController.class.getName()).log(Level.SEVERE, null, ex); - } - } -} diff --git a/src/org/openstreetmap/josm/plugins/tofix/controller/ItemTrackController.java b/src/org/openstreetmap/josm/plugins/tofix/controller/ItemTrackController.java new file mode 100644 index 0000000..29a7b3d --- /dev/null +++ b/src/org/openstreetmap/josm/plugins/tofix/controller/ItemTrackController.java @@ -0,0 +1,42 @@ +package org.openstreetmap.josm.plugins.tofix.controller; + +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.json.Json; +import javax.json.JsonObject; +import javax.json.JsonObjectBuilder; +import org.openstreetmap.josm.plugins.tofix.bean.ActionBean; +import org.openstreetmap.josm.plugins.tofix.bean.TrackBean; +import org.openstreetmap.josm.plugins.tofix.util.Request; + +public class ItemTrackController { + + public void send_track_edit(String url, TrackBean trackBean) { + JsonObjectBuilder attributesBuilder = Json.createObjectBuilder(); + JsonObjectBuilder trackBeanBuilder = Json.createObjectBuilder(); + trackBeanBuilder.add("user", trackBean.getAttributes().getUser()) + .add("editor", trackBean.getAttributes().getEditor()); + attributesBuilder.add("attributes", trackBeanBuilder); + JsonObject track_edit = attributesBuilder.build(); + try { + Request.sendPOST_Json(url, track_edit.toString()); + } catch (IOException ex) { + Logger.getLogger(ItemTrackController.class.getName()).log(Level.SEVERE, null, ex); + } + } + + public void send_track_action(String url, ActionBean trackBean) { //skip, fixed and noterror + JsonObjectBuilder trackBeanBuilder = Json.createObjectBuilder(); + trackBeanBuilder.add("user", trackBean.getUser()) + .add("action", trackBean.getAction()) + .add("key", trackBean.getKey()) + .add("editor", trackBean.getEditor()); + JsonObject track_skip = trackBeanBuilder.build(); + try { + Request.sendPUT_Json(url, track_skip.toString()); + } catch (IOException ex) { + Logger.getLogger(ItemTrackController.class.getName()).log(Level.SEVERE, null, ex); + } + } +} diff --git a/src/org/openstreetmap/josm/plugins/tofix/controller/ListTaskController.java b/src/org/openstreetmap/josm/plugins/tofix/controller/ListTaskController.java index d16e180..5677e1e 100644 --- a/src/org/openstreetmap/josm/plugins/tofix/controller/ListTaskController.java +++ b/src/org/openstreetmap/josm/plugins/tofix/controller/ListTaskController.java @@ -1,9 +1,22 @@ package org.openstreetmap.josm.plugins.tofix.controller; -import com.google.gson.Gson; +import java.io.IOException; +import java.io.StringReader; +import java.text.Collator; +import java.util.Collections; +import java.util.Comparator; +import java.util.LinkedList; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; +import javax.json.Json; +import javax.json.JsonArray; +import javax.json.JsonObject; +import javax.json.JsonReader; +import javax.json.JsonValue; import org.openstreetmap.josm.plugins.tofix.bean.ListTaskBean; +import org.openstreetmap.josm.plugins.tofix.bean.TaskBean; +import org.openstreetmap.josm.plugins.tofix.util.Config; import org.openstreetmap.josm.plugins.tofix.util.Request; /** @@ -12,25 +25,54 @@ */ public class ListTaskController { - private ListTaskBean listTasksBean = null; + private ListTaskBean listTasksBean = new ListTaskBean(); private String url; + /** + * Constructs a new {@code ListTaskController}. + */ public ListTaskController() { - this.url = "http://osmlab.github.io/to-fix/src/data/tasks.json"; + this.url = Config.HOST + "/tasks"; } public ListTaskBean getListTasksBean() { - Gson gson = new Gson(); - String stringListTaskBean = null; - try { - stringListTaskBean = Request.sendGET(url); - } catch (Exception ex) { - Logger.getLogger(StatusController.class.getName()).log(Level.SEVERE, null, ex); - } - listTasksBean = gson.fromJson(stringListTaskBean, ListTaskBean.class); + List tasks = new LinkedList<>(); + try (JsonReader jsonReader = Json.createReader(new StringReader(Request.sendGET(url)))) { + JsonObject jsonObject = jsonReader.readObject(); + JsonArray jsonArray = jsonObject.getJsonArray("tasks"); + for (JsonValue value : jsonArray) { + TaskBean taskBean = new TaskBean(); + try (JsonReader jsonReader2 = Json.createReader(new StringReader(value.toString()))) { + JsonObject jsontask = jsonReader2.readObject(); + JsonObject value_jsontask = (JsonObject) jsontask.get("value"); + JsonObject stats_jsontask = (JsonObject) value_jsontask.get("stats"); + taskBean.setIdtask(jsontask.getString("idtask")); + taskBean.setIsCompleted(jsontask.getBoolean("isCompleted")); + taskBean.setIsAllItemsLoad(jsontask.getBoolean("isAllItemsLoad")); + taskBean.setName(value_jsontask.getString("name")); + taskBean.setDescription(value_jsontask.getString("description")); + taskBean.setUpdated(value_jsontask.getJsonNumber("updated").toString()); + taskBean.setChangesetComment(value_jsontask.getString("changesetComment")); + taskBean.setDate(stats_jsontask.getJsonNumber("date").toString()); + taskBean.setEdit(Integer.parseInt(stats_jsontask.getJsonNumber("edit").toString())); + taskBean.setFixed(Integer.parseInt(stats_jsontask.getJsonNumber("fixed").toString())); + taskBean.setSkip(Integer.parseInt(stats_jsontask.getJsonNumber("skip").toString())); + taskBean.setItems(Integer.parseInt(stats_jsontask.getJsonNumber("items").toString())); + taskBean.setNoterror(Integer.parseInt(stats_jsontask.getJsonNumber("noterror").toString())); + } + tasks.add(taskBean); + } + } catch (IOException ex) { + Logger.getLogger(ListTaskController.class.getName()).log(Level.SEVERE, null, ex); + } + Collections.sort(tasks, new Comparator() { + @Override + public int compare(TaskBean o1, TaskBean o2) { + return Collator.getInstance().compare(o1.getName(), o2.getName()); + } + }); + listTasksBean.setTasks(tasks); return listTasksBean; - } - } diff --git a/src/org/openstreetmap/josm/plugins/tofix/controller/StatusController.java b/src/org/openstreetmap/josm/plugins/tofix/controller/StatusController.java index 958b384..e434cf1 100644 --- a/src/org/openstreetmap/josm/plugins/tofix/controller/StatusController.java +++ b/src/org/openstreetmap/josm/plugins/tofix/controller/StatusController.java @@ -1,8 +1,13 @@ package org.openstreetmap.josm.plugins.tofix.controller; -import com.google.gson.Gson; +import java.io.IOException; +import java.io.StringReader; import java.util.logging.Level; import java.util.logging.Logger; + +import javax.json.Json; +import javax.json.JsonReader; + import org.openstreetmap.josm.plugins.tofix.bean.StatusBean; import org.openstreetmap.josm.plugins.tofix.util.Request; @@ -12,25 +17,22 @@ */ public class StatusController { - private StatusBean statusBean; private final String url; - Gson gson = new Gson(); + /** + * Constructs a new {@code StatusController}. + */ public StatusController(String url) { this.url = url; } public StatusBean getStatusBean() { - String stringStatusBean = null; - try { - stringStatusBean = Request.sendGET(url); - } catch (Exception ex) { + StatusBean statusBean = new StatusBean(); + try (JsonReader jsonReader = Json.createReader(new StringReader(Request.sendGET(url)))) { + statusBean.setStatus(jsonReader.readObject().getString("status")); + } catch (IOException ex) { Logger.getLogger(StatusController.class.getName()).log(Level.SEVERE, null, ex); } - - statusBean = gson.fromJson(stringStatusBean, StatusBean.class); - //statusBean.sumary(); - return statusBean; } } diff --git a/src/org/openstreetmap/josm/plugins/tofix/util/Config.java b/src/org/openstreetmap/josm/plugins/tofix/util/Config.java new file mode 100644 index 0000000..af5539f --- /dev/null +++ b/src/org/openstreetmap/josm/plugins/tofix/util/Config.java @@ -0,0 +1,9 @@ +package org.openstreetmap.josm.plugins.tofix.util; + +public class Config { + + public static final String HOST = "https://build-to-fix-production.mapbox.com"; + public static final String URL_TOFIX = "http://osmlab.github.io/to-fix/"; + public static final String URL_OSM = "http://www.openstreetmap.org"; + public static final String URL_TOFIX_ISSUES = "https://github.com/JOSM/tofix/issues"; +} diff --git a/src/org/openstreetmap/josm/plugins/tofix/util/Download.java b/src/org/openstreetmap/josm/plugins/tofix/util/Download.java index 8c1df0e..a88a62c 100644 --- a/src/org/openstreetmap/josm/plugins/tofix/util/Download.java +++ b/src/org/openstreetmap/josm/plugins/tofix/util/Download.java @@ -6,9 +6,11 @@ import java.util.concurrent.Future; import java.util.logging.Level; import java.util.logging.Logger; + import org.openstreetmap.josm.Main; import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask; import org.openstreetmap.josm.data.Bounds; +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.Relation; @@ -22,28 +24,43 @@ */ public class Download { - private static Future future; - - public static void Download(final DownloadOsmTask task, Bounds bounds, final Long osm_obj_id) { + public static void download(Bounds bounds, final Long osm_obj_id) { + DownloadOsmTask task = new DownloadOsmTask(); ProgressMonitor monitor = null; final Future future = task.download(true, bounds, monitor); - Runnable runAfterTask = new Runnable() { + Runnable runAfterTask; + runAfterTask = new Runnable() { @Override public void run() { try { - future.get(); - Node node = new Node(osm_obj_id); - Relation relation = new Relation(osm_obj_id); - Way way = new Way(osm_obj_id); - List selection = new ArrayList<>(); - selection.add(way); - selection.add(node); - selection.add(relation); - Main.main.getCurrentDataSet().setSelected(selection); - } catch (InterruptedException ex) { - Logger.getLogger(TofixDialog.class.getName()).log(Level.SEVERE, null, ex); - } catch (ExecutionException ex) { + if (osm_obj_id != 0) { + future.get(); + //create object + if (future.isDone()) { + DataSet dataset = Main.getLayerManager().getEditLayer().data; + Node node = new Node(osm_obj_id); + Relation relation = new Relation(osm_obj_id); + Way way = new Way(osm_obj_id); + + //create list of objects + List selection = new ArrayList<>(); + + if (dataset.allPrimitives().contains(node)) { + selection.add(node); + Main.getLayerManager().getEditDataSet().setSelected(selection); + + } else if (dataset.allPrimitives().contains(way)) { + selection.add(way); + Main.getLayerManager().getEditDataSet().setSelected(selection); + + } else if (dataset.allPrimitives().contains(relation)) { + selection.add(relation); + Main.getLayerManager().getEditDataSet().setSelected(selection); + } + } + } + } catch (InterruptedException | ExecutionException ex) { Logger.getLogger(TofixDialog.class.getName()).log(Level.SEVERE, null, ex); } } diff --git a/src/org/openstreetmap/josm/plugins/tofix/util/Request.java b/src/org/openstreetmap/josm/plugins/tofix/util/Request.java index 43713bb..5301c7c 100644 --- a/src/org/openstreetmap/josm/plugins/tofix/util/Request.java +++ b/src/org/openstreetmap/josm/plugins/tofix/util/Request.java @@ -1,11 +1,17 @@ package org.openstreetmap.josm.plugins.tofix.util; -import java.io.BufferedReader; +import java.nio.charset.StandardCharsets; +import java.net.*; import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.URL; +import java.io.OutputStreamWriter; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import org.openstreetmap.josm.gui.JosmUserIdentityManager; + +import org.openstreetmap.josm.plugins.tofix.bean.ResponseBean; +import org.openstreetmap.josm.tools.HttpClient; +import org.openstreetmap.josm.tools.HttpClient.Response; /** * @@ -13,75 +19,52 @@ */ public class Request { - public static String sendPOST(String url) throws Exception { - Util.print(url); - URL obj = new URL(url); - HttpURLConnection con = (HttpURLConnection) obj.openConnection(); - con.setRequestMethod("POST"); - //START - POST - con.setDoOutput(true); - OutputStream os = con.getOutputStream(); - os.flush(); - os.close(); - //POST - END - int responseCode = con.getResponseCode(); - if (responseCode == HttpURLConnection.HTTP_OK) { - BufferedReader in = new BufferedReader(new InputStreamReader( - con.getInputStream())); - String inputLine; - StringBuffer response = new StringBuffer(); - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); + public static ResponseBean sendPOST(String url) throws IOException { + Map params = new LinkedHashMap<>(); + params.put("user", JosmUserIdentityManager.getInstance().getUserName()); + params.put("editor", "josm"); + + StringBuilder postData = new StringBuilder(); + for (Map.Entry param : params.entrySet()) { + if (postData.length() != 0) { + postData.append('&'); } - in.close(); - Util.print(response.toString()); - return response.toString(); + postData.append(URLEncoder.encode(param.getKey(), "UTF-8")); + postData.append('='); + postData.append(URLEncoder.encode(String.valueOf(param.getValue()), "UTF-8")); + } + String urlParameters = postData.toString(); - } else { - return null; + Response resp = HttpClient.create(new URL(url), "POST").setRequestBody(url.getBytes(StandardCharsets.UTF_8)).setRequestBody(urlParameters.getBytes(StandardCharsets.UTF_8)).connect(); - } + //Crear un ResponseBean para que regrese el String y el status de la peticion. + ResponseBean responseBean = new ResponseBean(); + responseBean.setStatus(resp.getResponseCode());//agregar el estatus + responseBean.setValue(resp.fetchContent());//agrega el valor de la respuesta + resp.disconnect(); + return responseBean; } public static void sendPOST_Json(String url, String object) throws IOException { - HttpURLConnection con = (HttpURLConnection) ((new URL(url).openConnection())); - con.setDoOutput(true); - con.setRequestProperty("Content-Type", "application/json"); - con.setRequestProperty("Accept", "application/json"); - con.setRequestMethod("POST"); - con.connect(); - byte[] outputBytes = object.getBytes("UTF-8"); - OutputStream os = con.getOutputStream(); - os.write(outputBytes); - os.close(); - int responseCode = con.getResponseCode(); - Util.print(responseCode); + HttpClient.create(new URL(url), "POST") + .setHeader("Content-Type", "application/json") + .setAccept("application/json") + .setRequestBody(object.getBytes(StandardCharsets.UTF_8)) + .connect().disconnect(); } public static String sendGET(String url) throws IOException { - URL obj = new URL(url); - HttpURLConnection con = (HttpURLConnection) obj.openConnection(); - con.setRequestMethod("GET"); - // con.setRequestProperty("User-Agent", USER_AGENT); - int responseCode = con.getResponseCode(); - if (responseCode == HttpURLConnection.HTTP_OK) { - BufferedReader in = new BufferedReader(new InputStreamReader( - con.getInputStream())); - String inputLine; - StringBuffer response = new StringBuffer(); - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - in.close(); - - System.out.println(response.toString()); - return response.toString(); - - } else { - System.out.println("GET request not worked"); - return null; - } - + Response response = HttpClient.create(new URL(url)).connect(); + String result = response.fetchContent(); + response.disconnect(); + return result; } + public static void sendPUT_Json(String url, String object) throws IOException { + HttpClient.create(new URL(url), "PUT") + .setHeader("Content-Type", "application/json") + .setAccept("application/json") + .setRequestBody(object.getBytes(StandardCharsets.UTF_8)) + .connect().disconnect(); + } } diff --git a/src/org/openstreetmap/josm/plugins/tofix/util/Status.java b/src/org/openstreetmap/josm/plugins/tofix/util/Status.java index 7641072..b02fcc0 100644 --- a/src/org/openstreetmap/josm/plugins/tofix/util/Status.java +++ b/src/org/openstreetmap/josm/plugins/tofix/util/Status.java @@ -1,12 +1,11 @@ package org.openstreetmap.josm.plugins.tofix.util; import java.io.IOException; -import java.net.HttpURLConnection; import java.net.URL; -import java.net.UnknownHostException; -import javax.swing.JOptionPane; + import org.openstreetmap.josm.Main; import org.openstreetmap.josm.plugins.tofix.controller.StatusController; +import org.openstreetmap.josm.tools.HttpClient; /** * @@ -14,34 +13,19 @@ */ public class Status { - final static String host = "http://54.147.184.23:8000/status"; + static final String host = Config.HOST; public static boolean server() { - StatusController statusController = new StatusController(host); - if (statusController.getStatusBean().getStatus().equals("a ok")) { - return true; - } else { - JOptionPane.showConfirmDialog(Main.parent, "The server is on maintenance!"); - return false; - } - + return "a ok".equals(new StatusController(host).getStatusBean().getStatus()); } public static boolean isInternetReachable() { try { - URL url = new URL("http://www.openstreetmap.org"); - HttpURLConnection urlConnect = (HttpURLConnection) url.openConnection(); - //is no connection, this line will fail - Object objData = urlConnect.getContent(); - - } catch (UnknownHostException e) { - e.printStackTrace(); - return false; + HttpClient.create(new URL(Config.URL_OSM)).connect().disconnect(); + return true; } catch (IOException e) { - e.printStackTrace(); + Main.error(e, "Couldn't connect to the osm server. Please check your internet connection."); return false; } - return true; } - } diff --git a/src/org/openstreetmap/josm/plugins/tofix/util/Util.java b/src/org/openstreetmap/josm/plugins/tofix/util/Util.java index c0ca712..98629b7 100644 --- a/src/org/openstreetmap/josm/plugins/tofix/util/Util.java +++ b/src/org/openstreetmap/josm/plugins/tofix/util/Util.java @@ -1,87 +1,18 @@ package org.openstreetmap.josm.plugins.tofix.util; -import java.util.AbstractList; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; -import org.openstreetmap.josm.data.coor.CachedLatLon; -import org.openstreetmap.josm.data.coor.LatLon; -import org.openstreetmap.josm.data.osm.Node; -import org.openstreetmap.josm.data.osm.Way; -import org.openstreetmap.josm.tools.Geometry; +import javax.swing.JOptionPane; + /** * * @author ruben */ public class Util { + public static void alert(Object object) { + JOptionPane.showMessageDialog(null, object); + } public static void print(Object object) { System.err.println(object); } - - public static LatLon format_St_astext_Keepright(String st_astext) { - String str = st_astext.replaceAll("[^-?0-9.]+", " "); - Double lat = Double.parseDouble(Arrays.asList(str.trim().split(" ")).get(1)); - Double lon = Double.parseDouble(Arrays.asList(str.trim().split(" ")).get(0)); - LatLon coor = new LatLon(lat, lon); - Util.print(coor); - return coor; - } - - public static Long format_Elems_Nycbuildings(String elems) { - String[] arr = elems.replace("way", "").split("_"); - - Util.print(arr); - return Long.valueOf(arr[0]); - } - - public static List format_st_astext_Tigerdelta(String st_astext) { - // String[] list = st_astext.replaceAll("[^-?0-9.]+", " ").split(" "); - st_astext = st_astext.replace("MULTILINESTRING(", "").replace("))", ")"); - Double[][] cordinates; - - List> list = new LinkedList>(); - String[] array; - if (st_astext.contains("),(")) { - st_astext = st_astext.replace(")", "").replace("(", ""); - array = st_astext.split(",\\("); - for (int i = 0; i < array.length; i++) { - List l = new LinkedList(); - String[] a = array[i].split(","); - for (int j = 0; j < a.length; j++) { - LatLon latLon = new LatLon(Double.parseDouble(a[j].split(" ")[1]), Double.parseDouble(a[j].split(" ")[0])); - Node node = new Node(latLon); - l.add(node); - } - list.add(l); - } - } else { - st_astext = st_astext.replace(")", "").replace("(", ""); - array = st_astext.split(","); - List l = new LinkedList(); - for (int i = 0; i < array.length; i++) { - LatLon latLon = new LatLon(Double.parseDouble(array[i].split(" ")[1]), Double.parseDouble(array[i].split(" ")[0])); - Node node = new Node(latLon); - l.add(node); - } - list.add(l); - - } - -// for (List l : list) { -// for (Double[] s : l) { -// Util.print(s[0] + " , " + s[1]); -// } -// } - -//:"MULTILINESTRING((-95.434784 30.066343,-95.434784 30.066349),(-95.434814 30.066545,-95.434845 30.066711),(-95.43486 30.06678,-95.434906 30.067045,-95.434952 30.067226))"}} -//"MULTILINESTRING((-83.312073 35.471603,-83.3125 35.471741,-83.312843 35.471855))"}} -// Double lat = Double.parseDouble(list[2]); -// Double lon = Double.parseDouble(list[1]); - // LatLon coor = new LatLon(4, 6); - // Util.print(coor); - return list; - - } }