Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreGrabber.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreGrabber.java	(revision 20246)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreGrabber.java	(revision 20247)
@@ -19,6 +19,4 @@
 
 public class CadastreGrabber {
-
-    public final static double epsilon = 1e-11;
 
     private CadastreInterface wmsInterface = new CadastreInterface();
@@ -62,9 +60,5 @@
     private URL getURLVector(EastNorth lambertMin, EastNorth lambertMax) throws MalformedURLException {
         String str = new String(wmsInterface.baseURL+"/scpc/wms?version=1.1&request=GetMap");
-        str += "&layers=CDIF:LS3,CDIF:LS2,CDIF:LS1,CDIF:PARCELLE,CDIF:NUMERO";
-        str += ",CDIF:PT3,CDIF:PT2,CDIF:PT1,CDIF:LIEUDIT";
-        str += ",CDIF:SUBSECTION";
-        str += ",CDIF:SECTION";
-        str += ",CDIF:COMMUNE";
+        str += "&layers="+CadastrePlugin.grabLayers;
         str += "&format=image/png";
         //str += "&format=image/jpeg";
@@ -75,8 +69,5 @@
         str += "&width="+CadastrePlugin.imageWidth+"&height="+CadastrePlugin.imageHeight;
         //str += "&exception=application/vnd.ogc.se_inimage"; // used by normal client but not required
-        str += "&styles=LS3_90,LS2_90,LS1_90,PARCELLE_90,NUMERO_90,PT3_90,PT2_90,PT1_90,LIEUDIT_90";
-        str += ",SUBSECTION_90";
-        str += ",SECTION_90";
-        str += ",COMMUNE_90";
+        str += "&styles="+CadastrePlugin.grabStyles;
         System.out.println("URL="+str);
         return new URL(str.replace(" ", "%20"));
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java	(revision 20246)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java	(revision 20247)
@@ -100,4 +100,5 @@
  *                 - raster image adjustment using default system menu modifier (ctrl for windows) for Mac support
  *                 - image resolution configurable (high, medium, low) like the online interface
+ *                 - layer selection configurable for vectorized images
  *                 - from Erik Amzallag:
  *                 -     possibility to modify the auto-sourcing text just before upload 
@@ -132,4 +133,6 @@
 
     public static int imageWidth, imageHeight;
+    
+    public static String grabLayers, grabStyles = null;
 
     static private boolean menuEnabled = false;
@@ -221,4 +224,46 @@
             imageWidth = 600; imageHeight = 400;
         }
+        grabLayers = "";
+        grabStyles = "";
+        if (Main.pref.getBoolean("cadastrewms.layerWater", true)) {
+            grabLayers += "CDIF:LS3,";
+            grabStyles += "LS3_90,";
+        }
+        if (Main.pref.getBoolean("cadastrewms.layerBuilding", true)) {
+            grabLayers += "CDIF:LS2,";
+            grabStyles += "LS2_90,";
+        }
+        if (Main.pref.getBoolean("cadastrewms.layerSymbol", true)) {
+            grabLayers += "CDIF:LS1,";
+            grabStyles += "LS1_90,";
+        }
+        if (Main.pref.getBoolean("cadastrewms.layerParcel", true)) {
+            grabLayers += "CDIF:PARCELLE,";
+            grabStyles += "PARCELLE_90,";
+        }
+        if (Main.pref.getBoolean("cadastrewms.layerNumero", true)) {
+            grabLayers += "CDIF:NUMERO,";
+            grabStyles += "NUMERO_90,";
+        }
+        if (Main.pref.getBoolean("cadastrewms.layerLabel", true)) {
+            grabLayers += "CDIF:PT3,CDIF:PT2,CDIF:PT1,";
+            grabStyles += "PT3_90,PT2_90,PT1_90,";
+        }
+        if (Main.pref.getBoolean("cadastrewms.layerLieudit", true)) {
+            grabLayers += "CDIF:LIEUDIT,";
+            grabStyles += "NUMERO_90,";
+        }
+        if (Main.pref.getBoolean("cadastrewms.layerSection", true)) {
+            grabLayers += "CDIF:SUBSECTION,CDIF:SECTION,";
+            grabStyles += "SUBSECTION_90,SECTION_90,";
+        }
+        if (Main.pref.getBoolean("cadastrewms.layerCommune", true)) {
+            grabLayers += "CDIF:COMMUNE,";
+            grabStyles += "COMMUNE_90,";
+        }
+        if (grabLayers.length() > 0) { // remove the last ','
+            grabLayers = grabLayers.substring(0, grabLayers.length()-1);
+            grabStyles = grabStyles.substring(0, grabStyles.length()-1);
+        }
         
         // overwrite F11 shortcut used from the beginning by this plugin and recently used
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePreferenceSetting.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePreferenceSetting.java	(revision 20246)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePreferenceSetting.java	(revision 20247)
@@ -63,4 +63,14 @@
 
     private JRadioButton grabRes3 = new JRadioButton("low");
+
+    private JCheckBox layerLS3 = new JCheckBox(tr("water"));
+    private JCheckBox layerLS2 = new JCheckBox(tr("building"));
+    private JCheckBox layerLS1 = new JCheckBox(tr("symbol"));
+    private JCheckBox layerParcel = new JCheckBox(tr("parcel"));
+    private JCheckBox layerLabel = new JCheckBox(tr("parcel number"));
+    private JCheckBox layerNumero = new JCheckBox(tr("address"));
+    private JCheckBox layerLieudit = new JCheckBox(tr("locality"));
+    private JCheckBox layerSection = new JCheckBox(tr("section"));
+    private JCheckBox layerCommune = new JCheckBox(tr("commune"));
 
     static final int DEFAULT_SQUARE_SIZE = 100;
@@ -227,4 +237,35 @@
         cadastrewms.add(grabMultiplier4Size, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 0, 5));
 
+        // WMS layers selection
+        JLabel jLabelLayers = new JLabel(tr("Layers:"));
+        cadastrewms.add(jLabelLayers, GBC.std().insets(0, 5, 10, 0));
+        layerLS3.setSelected(Main.pref.getBoolean("cadastrewms.layerWater", true));
+        layerLS3.setToolTipText(tr("See, rivers, swimming pools."));
+        cadastrewms.add(layerLS3, GBC.std().insets(5, 0, 5, 0));
+        layerLS2.setSelected(Main.pref.getBoolean("cadastrewms.layerBuilding", true));
+        layerLS2.setToolTipText(tr("Buildings, covers, underground constructions."));
+        cadastrewms.add(layerLS2, GBC.std().insets(5, 0, 5, 0));
+        layerLS1.setSelected(Main.pref.getBoolean("cadastrewms.layerSymbol", true));
+        layerLS1.setToolTipText(tr("Symbols like cristian cross."));
+        cadastrewms.add(layerLS1, GBC.std().insets(5, 0, 5, 0));
+        layerParcel.setSelected(Main.pref.getBoolean("cadastrewms.layerParcel", true));
+        layerParcel.setToolTipText(tr("Parcels."));
+        cadastrewms.add(layerParcel, GBC.eop().insets(5, 0, 5, 0));
+        layerLabel.setSelected(Main.pref.getBoolean("cadastrewms.layerLabel", true));
+        layerLabel.setToolTipText(tr("Parcels numbers, street names."));
+        cadastrewms.add(layerLabel, GBC.std().insets(70, 0, 5, 0));
+        layerNumero.setSelected(Main.pref.getBoolean("cadastrewms.layerNumero", true));
+        layerNumero.setToolTipText(tr("Address, houses numbers."));
+        cadastrewms.add(layerNumero, GBC.std().insets(5, 0, 5, 0));
+        layerLieudit.setSelected(Main.pref.getBoolean("cadastrewms.layerLieudit", true));
+        layerLieudit.setToolTipText(tr("Locality, hamlet, place."));
+        cadastrewms.add(layerLieudit, GBC.std().insets(5, 0, 5, 0));
+        layerSection.setSelected(Main.pref.getBoolean("cadastrewms.layerSection", true));
+        layerSection.setToolTipText(tr("Cadastral sections and subsections."));
+        cadastrewms.add(layerSection, GBC.std().insets(5, 0, 5, 0));
+        layerCommune.setSelected(Main.pref.getBoolean("cadastrewms.layerCommune", true));
+        layerCommune.setToolTipText(tr("Municipality administrative borders."));
+        cadastrewms.add(layerCommune, GBC.eop().insets(5, 0, 5, 0));
+        
         // separator
         cadastrewms.add(new JSeparator(SwingConstants.HORIZONTAL), GBC.eol().fill(GBC.HORIZONTAL));
@@ -323,4 +364,13 @@
             }
         }
+        Main.pref.put("cadastrewms.layerWater", layerLS3.isSelected());
+        Main.pref.put("cadastrewms.layerBuilding", layerLS2.isSelected());
+        Main.pref.put("cadastrewms.layerSymbol", layerLS1.isSelected());
+        Main.pref.put("cadastrewms.layerParcel", layerParcel.isSelected());
+        Main.pref.put("cadastrewms.layerLabel", layerLabel.isSelected());
+        Main.pref.put("cadastrewms.layerNumero", layerNumero.isSelected());
+        Main.pref.put("cadastrewms.layerLieudit", layerLieudit.isSelected());
+        Main.pref.put("cadastrewms.layerSection", layerSection.isSelected());
+        Main.pref.put("cadastrewms.layerCommune", layerCommune.isSelected());
         try {
             int i = Integer.parseInt(rasterDivider.getText());
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/ImageModifier.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/ImageModifier.java	(revision 20246)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/ImageModifier.java	(revision 20247)
@@ -1,6 +1,11 @@
 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others
+// Some of the procedures below are imported from image4j.sourceforge.net, license LGPL.
 package cadastre_fr;
 
+import java.awt.Transparency;
 import java.awt.image.BufferedImage;
+import java.awt.image.ColorConvertOp;
+import java.awt.image.DataBuffer;
+import java.awt.image.IndexColorModel;
 
 public abstract class ImageModifier {
@@ -14,3 +19,91 @@
     public BufferedImage bufferedImage;
 
+    protected BufferedImage convert1(BufferedImage src) {
+        IndexColorModel icm = new IndexColorModel(
+            1, 2, new byte[] { (byte) 0, (byte) 0xFF },
+            new byte[] { (byte) 0, (byte) 0xFF },
+            new byte[] { (byte) 0, (byte) 0xFF }
+        );
+        
+        BufferedImage dest = new BufferedImage(
+            src.getWidth(), src.getHeight(),
+            BufferedImage.TYPE_BYTE_BINARY,
+            icm
+            );
+        
+        ColorConvertOp cco = new ColorConvertOp(
+            src.getColorModel().getColorSpace(),
+            dest.getColorModel().getColorSpace(),
+            null
+            );
+        
+        cco.filter(src, dest);
+        
+        return dest;
+      }
+
+    /**
+     * Converts the source image to 4-bit colour
+     * using the default 16-colour palette:
+     * <ul>
+     *  <li>black</li><li>dark red</li><li>dark green</li>
+     *  <li>dark yellow</li><li>dark blue</li><li>dark magenta</li>
+     *  <li>dark cyan</li><li>dark grey</li><li>light grey</li>
+     *  <li>red</li><li>green</li><li>yellow</li><li>blue</li>
+     *  <li>magenta</li><li>cyan</li><li>white</li>
+     * </ul>
+     * No transparency.
+     * @param src the source image to convert
+     * @return a copy of the source image with a 4-bit colour depth, with the default colour pallette
+     */
+    protected BufferedImage convert4(BufferedImage src) {
+        int[] cmap = new int[] {
+          0x000000, 0x800000, 0x008000, 0x808000,
+          0x000080, 0x800080, 0x008080, 0x808080,
+          0xC0C0C0, 0xFF0000, 0x00FF00, 0xFFFF00,
+          0x0000FF, 0xFF00FF, 0x00FFFF, 0xFFFFFF
+        };
+        return convert4(src, cmap);
+      }
+        
+      /**
+       * Converts the source image to 4-bit colour
+       * using the given colour map.  No transparency.
+       * @param src the source image to convert
+       * @param cmap the colour map, which should contain no more than 16 entries
+       * The entries are in the form RRGGBB (hex).
+       * @return a copy of the source image with a 4-bit colour depth, with the custom colour pallette
+       */
+    protected BufferedImage convert4(BufferedImage src, int[] cmap) {
+        IndexColorModel icm = new IndexColorModel(
+            4, cmap.length, cmap, 0, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE
+            );
+        BufferedImage dest = new BufferedImage(
+            src.getWidth(), src.getHeight(),
+            BufferedImage.TYPE_BYTE_BINARY,
+            icm
+            );
+        ColorConvertOp cco = new ColorConvertOp(
+            src.getColorModel().getColorSpace(),
+            dest.getColorModel().getColorSpace(),
+            null
+            );
+        cco.filter(src, dest);
+        
+        return dest;
+      }
+      
+    protected BufferedImage convert8(BufferedImage src) {
+        BufferedImage dest = new BufferedImage(
+            src.getWidth(), src.getHeight(),
+            BufferedImage.TYPE_BYTE_INDEXED
+            );
+        ColorConvertOp cco = new ColorConvertOp(
+            src.getColorModel().getColorSpace(),
+            dest.getColorModel().getColorSpace(),
+            null
+            );
+        cco.filter(src, dest);
+        return dest;
+      }
 }
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/VectorImageModifier.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/VectorImageModifier.java	(revision 20246)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/VectorImageModifier.java	(revision 20247)
@@ -26,4 +26,5 @@
         if (Main.pref.getBoolean("cadastrewms.invertGrey"))
             invertGrey();
+        //bufferedImage = convert8(convert1(bufferedImage));
     }
 
