Index: applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationSettings.java
===================================================================
--- applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationSettings.java	(revision 28036)
+++ applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationSettings.java	(revision 28037)
@@ -21,4 +21,10 @@
     private OsmDataLayer subjectLayer;
     private DataSet referenceDataSet;
+    
+    public double distanceWeight;
+    public double distanceCutoff;
+    public String keyString;
+    public double stringWeight;
+    public double stringCutoff;
 
     /**
Index: applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationToggleDialog.java
===================================================================
--- applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationToggleDialog.java	(revision 28036)
+++ applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationToggleDialog.java	(revision 28037)
@@ -274,5 +274,5 @@
             for (int j = 0; j < m; j++) {
                 cost[i][j] = ConflationUtils.calcCost(
-                        settings.getSubjectSelection().get(i), settings.getReferenceSelection().get(j));
+                        settings.getSubjectSelection().get(i), settings.getReferenceSelection().get(j), settings);
             }
         }
Index: applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationUtils.java
===================================================================
--- applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationUtils.java	(revision 28036)
+++ applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/ConflationUtils.java	(revision 28037)
@@ -5,4 +5,5 @@
 import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.tools.StringMetrics;
 
 public final class ConflationUtils {
@@ -22,16 +23,34 @@
      * @param   subjectObject   the non-reference <code>OsmPrimitive</code>.
      */
-    public static double calcCost(OsmPrimitive referenceObject, OsmPrimitive subjectObject) {
+    public static double calcCost(OsmPrimitive referenceObject, OsmPrimitive subjectObject, ConflationSettings settings) {
+        double cost;
+
         if (referenceObject==subjectObject) {
             return MAX_COST;
         }
+
+        double distance = 0;
+        double stringCost = 1.0;
+        if (settings.distanceWeight != 0) {
+            distance = getCenter(referenceObject).distance(getCenter(subjectObject));
+        }
+        if (settings.stringWeight != 0) {
+            String referenceString = referenceObject.getKeys().get(settings.keyString);
+            String subjectString = subjectObject.getKeys().get(settings.keyString);
+            
+            if (referenceString == null ? subjectString == null : referenceString.equals(subjectString))
+                stringCost = 0.0;
+            else if (referenceString == null || subjectString == null)
+                stringCost = 1.0;
+            else
+                stringCost = 1.0 - StringMetrics.getByName("levenshtein").getSimilarity(subjectString, referenceString);
+        }
         
-        try {
-            return getCenter(referenceObject).distance(getCenter(subjectObject));
-        } catch (Exception e) {
-            return MAX_COST;
-        }
+        if (distance > settings.distanceCutoff || stringCost > settings.stringCutoff)
+            cost = MAX_COST;
+        else
+            cost = distance * settings.distanceWeight + stringCost * settings.stringWeight;
 
-        // TODO: use other "distance" measures, i.e. matching tags
+        return cost;
     }
 }
Index: applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/SettingsDialog.java
===================================================================
--- applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/SettingsDialog.java	(revision 28036)
+++ applications/editors/josm/plugins/conflation/src/org/openstreetmap/josm/plugins/conflation/SettingsDialog.java	(revision 28037)
@@ -2,4 +2,5 @@
 
 import java.awt.Component;
+import java.awt.GridBagLayout;
 import java.awt.event.ActionEvent;
 import java.util.ArrayList;
@@ -10,4 +11,5 @@
 import org.openstreetmap.josm.gui.ExtendedDialog;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
+import org.openstreetmap.josm.tools.GBC;
 import static org.openstreetmap.josm.tools.I18n.tr;
 
@@ -16,7 +18,5 @@
  */
 public class SettingsDialog extends ExtendedDialog {
-
-    private JPanel costsPanel;
-    private JCheckBox distanceCheckBox;
+    
     private JButton freezeReferenceButton;
     private JButton freezeSubjectButton;
@@ -31,4 +31,12 @@
     private JPanel subjectPanel;
     private JLabel subjectSelectionLabel;
+    JCheckBox distanceCheckBox;
+    JSpinner distanceWeightSpinner;
+    JSpinner distanceCutoffSpinner;
+    JCheckBox stringCheckBox;
+    JSpinner stringWeightSpinner;
+    JSpinner stringCutoffSpinner;
+    JTextField stringTextField;
+    
     ArrayList<OsmPrimitive> subjectSelection = null;
     ArrayList<OsmPrimitive> referenceSelection = null;
@@ -41,5 +49,5 @@
         super(Main.parent,
                 tr("Configure conflation settings"),
-                new String[]{tr("Conflate"), tr("Cancel")},
+                new String[]{tr("OK"), tr("Cancel")},
                 false);
         initComponents();
@@ -62,6 +70,4 @@
         restoreSubjectButton = new JButton(new RestoreSubjectAction());
         freezeSubjectButton = new JButton(new FreezeSubjectAction());
-        costsPanel = new JPanel();
-        distanceCheckBox = new JCheckBox();
         JPanel pnl = new JPanel();
         pnl.setLayout(new BoxLayout(pnl, BoxLayout.PAGE_AXIS));
@@ -91,10 +97,33 @@
         subjectPanel.add(jPanel5);
         pnl.add(subjectPanel);
+        
+        JPanel costsPanel = new JPanel();
         costsPanel.setBorder(BorderFactory.createTitledBorder(tr("Costs")));
-        costsPanel.setLayout(new BoxLayout(costsPanel, BoxLayout.LINE_AXIS));
+        costsPanel.setLayout(new GridBagLayout());
+        
+        costsPanel.add(GBC.glue(1, 1), GBC.std());
+        costsPanel.add(new JLabel(tr("Weight")), GBC.std());
+        costsPanel.add(new JLabel(tr("Cutoff")), GBC.eol());
+        
+        distanceCheckBox = new JCheckBox();
         distanceCheckBox.setSelected(true);
         distanceCheckBox.setText(tr("Distance"));
-        distanceCheckBox.setEnabled(false);
-        costsPanel.add(distanceCheckBox);
+        costsPanel.add(distanceCheckBox, GBC.std());
+        distanceWeightSpinner = new JSpinner(new SpinnerNumberModel(1.0, null, null, 1.0));
+        costsPanel.add(distanceWeightSpinner, GBC.std());
+        distanceCutoffSpinner = new JSpinner(new SpinnerNumberModel(100.0, null, null, 1.0));
+        costsPanel.add(distanceCutoffSpinner, GBC.eol());
+        
+        stringCheckBox = new JCheckBox();
+        stringCheckBox.setSelected(false);
+        stringCheckBox.setText(tr("String"));
+        costsPanel.add(stringCheckBox, GBC.std());
+        stringWeightSpinner = new JSpinner(new SpinnerNumberModel(10.0, null, null, 1.0));
+        costsPanel.add(stringWeightSpinner, GBC.std());
+        stringCutoffSpinner = new JSpinner(new SpinnerNumberModel(100.0, null, null, 1.0));
+        costsPanel.add(stringCutoffSpinner, GBC.eol());
+        stringTextField = new JTextField("name", 14);
+        costsPanel.add(stringTextField, GBC.std());
+        
         pnl.add(costsPanel);
         setContent(pnl);
@@ -120,4 +149,18 @@
         settings.setSubjectLayer(subjectLayer);
         settings.setSubjectSelection(subjectSelection);
+        
+        settings.distanceCutoff = (Double)distanceCutoffSpinner.getValue();
+        if (distanceCheckBox.isSelected())
+            settings.distanceWeight = (Double)distanceWeightSpinner.getValue();
+        else
+            settings.distanceWeight = 0;
+        settings.stringCutoff = (Double)stringCutoffSpinner.getValue();
+        if (stringCheckBox.isSelected())
+            settings.stringWeight = (Double)stringWeightSpinner.getValue();
+        else
+            settings.stringWeight = 0;
+            
+        settings.keyString = stringTextField.getText();
+        
         return settings;
     }
