[josm-dev] two suggestions to improve JOSM a lot

2008-08-03 Thread Tobias Wendorff
Hi there,

suggestion 1:
Stop drawing Nodes by pressing "ESC" ... every professional GIS has it,
every graphic application has it. It's a very important "panic"-button!

suggestion 2:
"Angle Snapping" for 45° and 90° angles ... starting from the last node.
This is very helpful for drawing houses and places.

May parts of my study at University have to do with GIS and CAD. Since
man-made constructions mainly use 45° and 90° angles, it's okay to
work with this fixed values.

What do you think?

Best regards,
Tobias

___
josm-dev mailing list
josm-dev@openstreetmap.org
http://lists.openstreetmap.org/listinfo/josm-dev


Re: [josm-dev] Automatic tag correction

2008-08-03 Thread Robin Rattay
Dirk Stöcker schrieb:
> On Sun, 3 Aug 2008, Robin Rattay wrote:
> This does not work:
> +   return applyCorrections(
> +   tagCorrections,
> +   way,
> +   tr("When reverting this way " + nameVisitor.name
> +   + ", following changes to the properties are 
> suggested "
> +   + "in order to maintain data consistency."));
> 
> You cannot join translatable strings.
> 
> Use {0} for arguments. tr(" {0} yyy {1}...", arg1, arg2);

Whoops.

Could you change that, or just drop that change? I've already continued
the development and undid that anyway, since it doesn't fit into my
plans anymore.

Otherwise I would directly modify the patch file and re-send that if you
prefer.

Robin

___
josm-dev mailing list
josm-dev@openstreetmap.org
http://lists.openstreetmap.org/listinfo/josm-dev


Re: [josm-dev] Automatic tag correction

2008-08-03 Thread Dirk Stöcker
On Sun, 3 Aug 2008, Robin Rattay wrote:

> here is a small update of the TagCorrector. Some code cleanup and
> addition of the key prefixes/suffixes "forward" and "backward".

This does not work:
+   return applyCorrections(
+   tagCorrections,
+   way,
+   tr("When reverting this way " + nameVisitor.name
+   + ", following changes to the properties are 
suggested "
+   + "in order to maintain data consistency."));

You cannot join translatable strings.

Use {0} for arguments. tr(" {0} yyy {1}...", arg1, arg2);

Ciao
-- 
http://www.dstoecker.eu/ (PGP key available)

___
josm-dev mailing list
josm-dev@openstreetmap.org
http://lists.openstreetmap.org/listinfo/josm-dev


Re: [josm-dev] Automatic tag correction

2008-08-03 Thread Robin Rattay
Hi,

here is a small update of the TagCorrector. Some code cleanup and
addition of the key prefixes/suffixes "forward" and "backward".

Robin

Index: src/org/openstreetmap/josm/actions/ReverseWayAction.java
===
--- src/org/openstreetmap/josm/actions/ReverseWayAction.java(revision 743)
+++ src/org/openstreetmap/josm/actions/ReverseWayAction.java(working copy)
@@ -16,6 +16,7 @@
 import org.openstreetmap.josm.command.Command;
 import org.openstreetmap.josm.command.SequenceCommand;
 import org.openstreetmap.josm.corrector.ReverseWayTagCorrector;
+import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Relation;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -60,7 +61,7 @@
}
Main.main.undoRedo.add(new SequenceCommand(tr("Reverse ways"), 
c));
if (propertiesUpdated)
-   Main.ds.fireSelectionChanged(Main.ds.getSelected());
+   DataSet.fireSelectionChanged(Main.ds.getSelected());
Main.map.repaint();
 }
 }
Index: src/org/openstreetmap/josm/corrector/ReverseWayTagCorrector.java
===
--- src/org/openstreetmap/josm/corrector/ReverseWayTagCorrector.java
(revision 743)
+++ src/org/openstreetmap/josm/corrector/ReverseWayTagCorrector.java
(working copy)
@@ -9,15 +9,48 @@
 
 import org.openstreetmap.josm.data.osm.OsmUtils;
 import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.data.osm.visitor.NameVisitor;
 
 public class ReverseWayTagCorrector extends TagCorrector {
 
-   private static final Pattern leftRightStartRegex = Pattern.compile(
-   "^(left|right):.*", Pattern.CASE_INSENSITIVE);
+   private static class PrefixSuffixSwitcher {
 
-   private static final Pattern leftRightEndRegex = Pattern.compile(
-   ".*:(left|right)$", Pattern.CASE_INSENSITIVE);
+   private final String a;
+   private final String b;
 
+   private final Pattern startPattern;
+   private final Pattern endPattern;
+
+   public PrefixSuffixSwitcher(String a, String b) {
+   this.a = a;
+   this.b = b;
+   startPattern = Pattern.compile("^(" + a + "|" + b + 
"):.*",
+   Pattern.CASE_INSENSITIVE);
+   endPattern = Pattern.compile(".*:(" + a + "|" + b + 
")$",
+   Pattern.CASE_INSENSITIVE);
+   }
+
+   public String apply(String text) {
+   Matcher m = startPattern.matcher(text);
+   if (!m.matches())
+   m = endPattern.matcher(text);
+
+   if (m.matches()) {
+   String leftRight = m.group(1).toLowerCase();
+
+   return text.substring(0, m.start(1)).concat(
+   leftRight.equals(a) ? b : a).concat(
+   text.substring(m.end(1)));
+   }
+   return text;
+   }
+   }
+
+   private static PrefixSuffixSwitcher[] prefixSuffixSwitchers = new 
PrefixSuffixSwitcher[] {
+   new PrefixSuffixSwitcher("left", "right"),
+   new PrefixSuffixSwitcher("forward", "backward")
+   };
+   
@Override public boolean execute(Way way) {
 
ArrayList tagCorrections = new 
ArrayList();
@@ -37,27 +70,26 @@
}
}
} else {
-   Matcher m = leftRightStartRegex.matcher(key);
-   if (!m.matches())
-   m = leftRightEndRegex.matcher(key);
-
-   if (m.matches()) {
-   String leftRight = 
m.group(1).toLowerCase();
-
-   newKey = key.substring(0, 
m.start(1)).concat(
-   leftRight.equals("left") ? 
"right" : "left")
-   
.concat(key.substring(m.end(1)));
-   }
+   for (PrefixSuffixSwitcher prefixSuffixSwitcher 
: prefixSuffixSwitchers) {
+   newKey = 
prefixSuffixSwitcher.apply(key);
+   if (!key.equals(newKey))
+   break;
+}  
}
 
-   if (key != newKey || value != newValue)
+   if (!key.equals(newKey) || !value.equals(n