Ignore:
Timestamp:
2010-03-02T15:15:29+01:00 (14 years ago)
Author:
pieren
Message:

layer selection configurable for vectorized images

Location:
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreGrabber.java

    r20240 r20247  
    1919
    2020public class CadastreGrabber {
    21 
    22     public final static double epsilon = 1e-11;
    2321
    2422    private CadastreInterface wmsInterface = new CadastreInterface();
     
    6260    private URL getURLVector(EastNorth lambertMin, EastNorth lambertMax) throws MalformedURLException {
    6361        String str = new String(wmsInterface.baseURL+"/scpc/wms?version=1.1&request=GetMap");
    64         str += "&layers=CDIF:LS3,CDIF:LS2,CDIF:LS1,CDIF:PARCELLE,CDIF:NUMERO";
    65         str += ",CDIF:PT3,CDIF:PT2,CDIF:PT1,CDIF:LIEUDIT";
    66         str += ",CDIF:SUBSECTION";
    67         str += ",CDIF:SECTION";
    68         str += ",CDIF:COMMUNE";
     62        str += "&layers="+CadastrePlugin.grabLayers;
    6963        str += "&format=image/png";
    7064        //str += "&format=image/jpeg";
     
    7569        str += "&width="+CadastrePlugin.imageWidth+"&height="+CadastrePlugin.imageHeight;
    7670        //str += "&exception=application/vnd.ogc.se_inimage"; // used by normal client but not required
    77         str += "&styles=LS3_90,LS2_90,LS1_90,PARCELLE_90,NUMERO_90,PT3_90,PT2_90,PT1_90,LIEUDIT_90";
    78         str += ",SUBSECTION_90";
    79         str += ",SECTION_90";
    80         str += ",COMMUNE_90";
     71        str += "&styles="+CadastrePlugin.grabStyles;
    8172        System.out.println("URL="+str);
    8273        return new URL(str.replace(" ", "%20"));
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java

    r20240 r20247  
    100100 *                 - raster image adjustment using default system menu modifier (ctrl for windows) for Mac support
    101101 *                 - image resolution configurable (high, medium, low) like the online interface
     102 *                 - layer selection configurable for vectorized images
    102103 *                 - from Erik Amzallag:
    103104 *                 -     possibility to modify the auto-sourcing text just before upload
     
    132133
    133134    public static int imageWidth, imageHeight;
     135   
     136    public static String grabLayers, grabStyles = null;
    134137
    135138    static private boolean menuEnabled = false;
     
    221224            imageWidth = 600; imageHeight = 400;
    222225        }
     226        grabLayers = "";
     227        grabStyles = "";
     228        if (Main.pref.getBoolean("cadastrewms.layerWater", true)) {
     229            grabLayers += "CDIF:LS3,";
     230            grabStyles += "LS3_90,";
     231        }
     232        if (Main.pref.getBoolean("cadastrewms.layerBuilding", true)) {
     233            grabLayers += "CDIF:LS2,";
     234            grabStyles += "LS2_90,";
     235        }
     236        if (Main.pref.getBoolean("cadastrewms.layerSymbol", true)) {
     237            grabLayers += "CDIF:LS1,";
     238            grabStyles += "LS1_90,";
     239        }
     240        if (Main.pref.getBoolean("cadastrewms.layerParcel", true)) {
     241            grabLayers += "CDIF:PARCELLE,";
     242            grabStyles += "PARCELLE_90,";
     243        }
     244        if (Main.pref.getBoolean("cadastrewms.layerNumero", true)) {
     245            grabLayers += "CDIF:NUMERO,";
     246            grabStyles += "NUMERO_90,";
     247        }
     248        if (Main.pref.getBoolean("cadastrewms.layerLabel", true)) {
     249            grabLayers += "CDIF:PT3,CDIF:PT2,CDIF:PT1,";
     250            grabStyles += "PT3_90,PT2_90,PT1_90,";
     251        }
     252        if (Main.pref.getBoolean("cadastrewms.layerLieudit", true)) {
     253            grabLayers += "CDIF:LIEUDIT,";
     254            grabStyles += "NUMERO_90,";
     255        }
     256        if (Main.pref.getBoolean("cadastrewms.layerSection", true)) {
     257            grabLayers += "CDIF:SUBSECTION,CDIF:SECTION,";
     258            grabStyles += "SUBSECTION_90,SECTION_90,";
     259        }
     260        if (Main.pref.getBoolean("cadastrewms.layerCommune", true)) {
     261            grabLayers += "CDIF:COMMUNE,";
     262            grabStyles += "COMMUNE_90,";
     263        }
     264        if (grabLayers.length() > 0) { // remove the last ','
     265            grabLayers = grabLayers.substring(0, grabLayers.length()-1);
     266            grabStyles = grabStyles.substring(0, grabStyles.length()-1);
     267        }
    223268       
    224269        // overwrite F11 shortcut used from the beginning by this plugin and recently used
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePreferenceSetting.java

    r20240 r20247  
    6363
    6464    private JRadioButton grabRes3 = new JRadioButton("low");
     65
     66    private JCheckBox layerLS3 = new JCheckBox(tr("water"));
     67    private JCheckBox layerLS2 = new JCheckBox(tr("building"));
     68    private JCheckBox layerLS1 = new JCheckBox(tr("symbol"));
     69    private JCheckBox layerParcel = new JCheckBox(tr("parcel"));
     70    private JCheckBox layerLabel = new JCheckBox(tr("parcel number"));
     71    private JCheckBox layerNumero = new JCheckBox(tr("address"));
     72    private JCheckBox layerLieudit = new JCheckBox(tr("locality"));
     73    private JCheckBox layerSection = new JCheckBox(tr("section"));
     74    private JCheckBox layerCommune = new JCheckBox(tr("commune"));
    6575
    6676    static final int DEFAULT_SQUARE_SIZE = 100;
     
    227237        cadastrewms.add(grabMultiplier4Size, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 0, 5));
    228238
     239        // WMS layers selection
     240        JLabel jLabelLayers = new JLabel(tr("Layers:"));
     241        cadastrewms.add(jLabelLayers, GBC.std().insets(0, 5, 10, 0));
     242        layerLS3.setSelected(Main.pref.getBoolean("cadastrewms.layerWater", true));
     243        layerLS3.setToolTipText(tr("See, rivers, swimming pools."));
     244        cadastrewms.add(layerLS3, GBC.std().insets(5, 0, 5, 0));
     245        layerLS2.setSelected(Main.pref.getBoolean("cadastrewms.layerBuilding", true));
     246        layerLS2.setToolTipText(tr("Buildings, covers, underground constructions."));
     247        cadastrewms.add(layerLS2, GBC.std().insets(5, 0, 5, 0));
     248        layerLS1.setSelected(Main.pref.getBoolean("cadastrewms.layerSymbol", true));
     249        layerLS1.setToolTipText(tr("Symbols like cristian cross."));
     250        cadastrewms.add(layerLS1, GBC.std().insets(5, 0, 5, 0));
     251        layerParcel.setSelected(Main.pref.getBoolean("cadastrewms.layerParcel", true));
     252        layerParcel.setToolTipText(tr("Parcels."));
     253        cadastrewms.add(layerParcel, GBC.eop().insets(5, 0, 5, 0));
     254        layerLabel.setSelected(Main.pref.getBoolean("cadastrewms.layerLabel", true));
     255        layerLabel.setToolTipText(tr("Parcels numbers, street names."));
     256        cadastrewms.add(layerLabel, GBC.std().insets(70, 0, 5, 0));
     257        layerNumero.setSelected(Main.pref.getBoolean("cadastrewms.layerNumero", true));
     258        layerNumero.setToolTipText(tr("Address, houses numbers."));
     259        cadastrewms.add(layerNumero, GBC.std().insets(5, 0, 5, 0));
     260        layerLieudit.setSelected(Main.pref.getBoolean("cadastrewms.layerLieudit", true));
     261        layerLieudit.setToolTipText(tr("Locality, hamlet, place."));
     262        cadastrewms.add(layerLieudit, GBC.std().insets(5, 0, 5, 0));
     263        layerSection.setSelected(Main.pref.getBoolean("cadastrewms.layerSection", true));
     264        layerSection.setToolTipText(tr("Cadastral sections and subsections."));
     265        cadastrewms.add(layerSection, GBC.std().insets(5, 0, 5, 0));
     266        layerCommune.setSelected(Main.pref.getBoolean("cadastrewms.layerCommune", true));
     267        layerCommune.setToolTipText(tr("Municipality administrative borders."));
     268        cadastrewms.add(layerCommune, GBC.eop().insets(5, 0, 5, 0));
     269       
    229270        // separator
    230271        cadastrewms.add(new JSeparator(SwingConstants.HORIZONTAL), GBC.eol().fill(GBC.HORIZONTAL));
     
    323364            }
    324365        }
     366        Main.pref.put("cadastrewms.layerWater", layerLS3.isSelected());
     367        Main.pref.put("cadastrewms.layerBuilding", layerLS2.isSelected());
     368        Main.pref.put("cadastrewms.layerSymbol", layerLS1.isSelected());
     369        Main.pref.put("cadastrewms.layerParcel", layerParcel.isSelected());
     370        Main.pref.put("cadastrewms.layerLabel", layerLabel.isSelected());
     371        Main.pref.put("cadastrewms.layerNumero", layerNumero.isSelected());
     372        Main.pref.put("cadastrewms.layerLieudit", layerLieudit.isSelected());
     373        Main.pref.put("cadastrewms.layerSection", layerSection.isSelected());
     374        Main.pref.put("cadastrewms.layerCommune", layerCommune.isSelected());
    325375        try {
    326376            int i = Integer.parseInt(rasterDivider.getText());
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/ImageModifier.java

    r18544 r20247  
    11// License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others
     2// Some of the procedures below are imported from image4j.sourceforge.net, license LGPL.
    23package cadastre_fr;
    34
     5import java.awt.Transparency;
    46import java.awt.image.BufferedImage;
     7import java.awt.image.ColorConvertOp;
     8import java.awt.image.DataBuffer;
     9import java.awt.image.IndexColorModel;
    510
    611public abstract class ImageModifier {
     
    1419    public BufferedImage bufferedImage;
    1520
     21    protected BufferedImage convert1(BufferedImage src) {
     22        IndexColorModel icm = new IndexColorModel(
     23            1, 2, new byte[] { (byte) 0, (byte) 0xFF },
     24            new byte[] { (byte) 0, (byte) 0xFF },
     25            new byte[] { (byte) 0, (byte) 0xFF }
     26        );
     27       
     28        BufferedImage dest = new BufferedImage(
     29            src.getWidth(), src.getHeight(),
     30            BufferedImage.TYPE_BYTE_BINARY,
     31            icm
     32            );
     33       
     34        ColorConvertOp cco = new ColorConvertOp(
     35            src.getColorModel().getColorSpace(),
     36            dest.getColorModel().getColorSpace(),
     37            null
     38            );
     39       
     40        cco.filter(src, dest);
     41       
     42        return dest;
     43      }
     44
     45    /**
     46     * Converts the source image to 4-bit colour
     47     * using the default 16-colour palette:
     48     * <ul>
     49     *  <li>black</li><li>dark red</li><li>dark green</li>
     50     *  <li>dark yellow</li><li>dark blue</li><li>dark magenta</li>
     51     *  <li>dark cyan</li><li>dark grey</li><li>light grey</li>
     52     *  <li>red</li><li>green</li><li>yellow</li><li>blue</li>
     53     *  <li>magenta</li><li>cyan</li><li>white</li>
     54     * </ul>
     55     * No transparency.
     56     * @param src the source image to convert
     57     * @return a copy of the source image with a 4-bit colour depth, with the default colour pallette
     58     */
     59    protected BufferedImage convert4(BufferedImage src) {
     60        int[] cmap = new int[] {
     61          0x000000, 0x800000, 0x008000, 0x808000,
     62          0x000080, 0x800080, 0x008080, 0x808080,
     63          0xC0C0C0, 0xFF0000, 0x00FF00, 0xFFFF00,
     64          0x0000FF, 0xFF00FF, 0x00FFFF, 0xFFFFFF
     65        };
     66        return convert4(src, cmap);
     67      }
     68       
     69      /**
     70       * Converts the source image to 4-bit colour
     71       * using the given colour map.  No transparency.
     72       * @param src the source image to convert
     73       * @param cmap the colour map, which should contain no more than 16 entries
     74       * The entries are in the form RRGGBB (hex).
     75       * @return a copy of the source image with a 4-bit colour depth, with the custom colour pallette
     76       */
     77    protected BufferedImage convert4(BufferedImage src, int[] cmap) {
     78        IndexColorModel icm = new IndexColorModel(
     79            4, cmap.length, cmap, 0, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE
     80            );
     81        BufferedImage dest = new BufferedImage(
     82            src.getWidth(), src.getHeight(),
     83            BufferedImage.TYPE_BYTE_BINARY,
     84            icm
     85            );
     86        ColorConvertOp cco = new ColorConvertOp(
     87            src.getColorModel().getColorSpace(),
     88            dest.getColorModel().getColorSpace(),
     89            null
     90            );
     91        cco.filter(src, dest);
     92       
     93        return dest;
     94      }
     95     
     96    protected BufferedImage convert8(BufferedImage src) {
     97        BufferedImage dest = new BufferedImage(
     98            src.getWidth(), src.getHeight(),
     99            BufferedImage.TYPE_BYTE_INDEXED
     100            );
     101        ColorConvertOp cco = new ColorConvertOp(
     102            src.getColorModel().getColorSpace(),
     103            dest.getColorModel().getColorSpace(),
     104            null
     105            );
     106        cco.filter(src, dest);
     107        return dest;
     108      }
    16109}
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/VectorImageModifier.java

    r19948 r20247  
    2626        if (Main.pref.getBoolean("cadastrewms.invertGrey"))
    2727            invertGrey();
     28        //bufferedImage = convert8(convert1(bufferedImage));
    2829    }
    2930
Note: See TracChangeset for help on using the changeset viewer.