Ignore:
Timestamp:
2009-06-17T09:46:26+02:00 (16 years ago)
Author:
stoecker
Message:

fix build issues

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

Legend:

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

    r13545 r15961  
    44 * wait status on GUI, fast saving even in big file). A separate thread is created for each WMS
    55 * layer to not suspend the GUI until disk I/O is terminated (a file for the cache can take
    6  * several MB's). If the cache file already exists, new images are just appended to the file 
    7  * (performance). Since we use the ObjectStream methods, it is required to modify the standard 
    8  * ObjectOutputStream in order to have objects appended readable (otherwise a stream header 
     6 * several MB's). If the cache file already exists, new images are just appended to the file
     7 * (performance). Since we use the ObjectStream methods, it is required to modify the standard
     8 * ObjectOutputStream in order to have objects appended readable (otherwise a stream header
    99 * is inserted before each append and an exception is raised at objects read).
    1010 */
     
    3131
    3232    public static boolean cacheEnabled = true;
    33    
     33
    3434    public static int cacheSize = 500;
    35    
    36    
     35
     36
    3737    public WMSLayer wmsLayer = null;
    38    
     38
    3939    private ArrayList<GeorefImage> imagesToSave = new ArrayList<GeorefImage>();
    4040    private Lock imagesLock = new ReentrantLock();
    41      
     41
    4242    public CacheControl(WMSLayer wmsLayer) {
    4343        cacheEnabled = Main.pref.getBoolean("cadastrewms.enableCaching", true);
     
    5555        new Thread(this).start();
    5656    }
    57    
     57
    5858    private void checkDirSize(File path) {
    5959        long size = 0;
     
    6969        }
    7070        if (size > cacheSize*1024*1024) {
    71             System.out.println("Delete oldest file  \""+ files[oldestFile].getName() 
     71            System.out.println("Delete oldest file  \""+ files[oldestFile].getName()
    7272                    + "\" in cache dir to stay under the limit of " + cacheSize + " MB.");
    7373            files[oldestFile].delete();
     
    7575        }
    7676    }
    77    
     77
    7878    public boolean loadCacheIfExist() {
    7979        try {
    8080            File file = new File(CadastrePlugin.cacheDir + wmsLayer.name + "." + String.valueOf(wmsLayer.lambertZone+1));
    8181            if (file.exists()) {
    82                 int reply = JOptionPane.showConfirmDialog(null, 
     82                int reply = JOptionPane.showConfirmDialog(null,
    8383                        "Location \""+wmsLayer.name+"\" found in cache.\n"+
    8484                        "Load cache first ?\n"+
     
    9090                } else
    9191                    file.delete();
    92             }           
     92            }
    9393        } catch (Exception e) {
    9494            e.printStackTrace(System.out);
     
    9696        return false;
    9797    }
    98    
     98
    9999    public void deleteCacheFile() {
    100100        try {
     
    106106        }
    107107    }
    108    
     108
    109109    public boolean loadCache(File file, int currentLambertZone) {
    110110        try {
     
    166166        }
    167167    }
    168 
    169168}
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheFileFilter.java

    r13497 r15961  
    1313    private final String description;
    1414
    15     public static CacheFileFilter[] filters = { 
     15    public static CacheFileFilter[] filters = {
    1616        new CacheFileFilter("1", tr("Lambert Zone 1 cache file (.1)")),
    1717        new CacheFileFilter("2", tr("Lambert Zone 2 cache file (.2)")),
    1818        new CacheFileFilter("3", tr("Lambert Zone 3 cache file (.3)")),
    19         new CacheFileFilter("4", tr("Lambert Zone 4 cache file (.4)")) 
     19        new CacheFileFilter("4", tr("Lambert Zone 4 cache file (.4)"))
    2020        };
    2121
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreGrabber.java

    r13784 r15961  
    1414import org.openstreetmap.josm.Main;
    1515import org.openstreetmap.josm.data.coor.EastNorth;
     16import org.openstreetmap.josm.io.OsmTransferException;
    1617import org.openstreetmap.josm.io.ProgressInputStream;
    1718
    1819public class CadastreGrabber {
    1920
    20         public static final double epsilon = 1e-11;
    21        
    22         private CadastreInterface wmsInterface = new CadastreInterface(this);
     21    public static final double epsilon = 1e-11;
     22
     23    private CadastreInterface wmsInterface = new CadastreInterface(this);
    2324    private String lastWMSLayerName = null;
    24        
    25         CadastreGrabber() {
    26         getWmsInterface().downloadCancelled = false;       
    27         }
    28        
    29     public GeorefImage grab(WMSLayer wmsLayer, EastNorth lambertMin, EastNorth lambertMax) throws IOException {
     25
     26    CadastreGrabber() {
     27        getWmsInterface().downloadCancelled = false;
     28    }
     29
     30    public GeorefImage grab(WMSLayer wmsLayer, EastNorth lambertMin, EastNorth lambertMax) throws IOException, OsmTransferException {
    3031
    3132        try {
     
    5859    private URL getURLVector(EastNorth lambertMin, EastNorth lambertMax) throws MalformedURLException {
    5960        String str = new String(wmsInterface.baseURL+"/scpc/wms?version=1.1&request=GetMap");
    60                 str += "&layers=CDIF:LS3,CDIF:LS2,CDIF:LS1,CDIF:PARCELLE,CDIF:NUMERO";
    61                 str += ",CDIF:PT3,CDIF:PT2,CDIF:PT1,CDIF:LIEUDIT";
    62                 str += ",CDIF:SUBSECTION";
    63                 str += ",CDIF:SECTION";
    64                 str += ",CDIF:COMMUNE";
    65                 str += "&format=image/png";
    66                 //str += "&format=image/jpeg";
    67                 str += "&bbox="+lambertMin.east()+",";
    68                 str += lambertMin.north() + ",";
    69                 str += lambertMax.east() + ",";
    70                 str += lambertMax.north();
    71                 //str += "&width=800&height=600"; // maximum allowed by wms server
     61        str += "&layers=CDIF:LS3,CDIF:LS2,CDIF:LS1,CDIF:PARCELLE,CDIF:NUMERO";
     62        str += ",CDIF:PT3,CDIF:PT2,CDIF:PT1,CDIF:LIEUDIT";
     63        str += ",CDIF:SUBSECTION";
     64        str += ",CDIF:SECTION";
     65        str += ",CDIF:COMMUNE";
     66        str += "&format=image/png";
     67        //str += "&format=image/jpeg";
     68        str += "&bbox="+lambertMin.east()+",";
     69        str += lambertMin.north() + ",";
     70        str += lambertMax.east() + ",";
     71        str += lambertMax.north();
     72        //str += "&width=800&height=600"; // maximum allowed by wms server
    7273        str += "&width=1000&height=800"; // maximum allowed by wms server
    73                 str += "&styles=LS3_90,LS2_90,LS1_90,PARCELLE_90,NUMERO_90,PT3_90,PT2_90,PT1_90,LIEUDIT_90";
    74                 str += ",SUBSECTION_90";
    75                 str += ",SECTION_90";
    76                 str += ",COMMUNE_90";
    77                 System.out.println("URL="+str);
     74        str += "&styles=LS3_90,LS2_90,LS1_90,PARCELLE_90,NUMERO_90,PT3_90,PT2_90,PT1_90,LIEUDIT_90";
     75        str += ",SUBSECTION_90";
     76        str += ",SECTION_90";
     77        str += ",COMMUNE_90";
     78        System.out.println("URL="+str);
    7879        return new URL(str.replace(" ", "%20"));
    79         }
     80    }
    8081
    81         private BufferedImage grab(URL url) throws IOException {
    82             wmsInterface.urlConn = (HttpURLConnection)url.openConnection();
    83             wmsInterface.urlConn.setRequestMethod("GET");
    84             wmsInterface.setCookie();
    85                 InputStream is = new ProgressInputStream(wmsInterface.urlConn, Main.pleaseWaitDlg);
    86                 BufferedImage img = ImageIO.read(is);
     82    private BufferedImage grab(URL url) throws IOException, OsmTransferException {
     83        wmsInterface.urlConn = (HttpURLConnection)url.openConnection();
     84        wmsInterface.urlConn.setRequestMethod("GET");
     85        wmsInterface.setCookie();
     86        InputStream is = new ProgressInputStream(wmsInterface.urlConn, Main.pleaseWaitDlg);
     87        BufferedImage img = ImageIO.read(is);
    8788        is.close();
    8889        return img;
    89         }
     90    }
    9091
    9192    public CadastreInterface getWmsInterface() {
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java

    r13611 r15961  
    4141    final String cBBoxCommunStart = "new GeoBox(";
    4242    final String cBBoxCommunEnd = ")";
    43    
     43
    4444    final String cInterfaceVector = "afficherCarteCommune.do";
    4545    final String cInterfaceRaster = "afficherCarteTa.do";
    46        
     46
    4747    CadastreInterface(CadastreGrabber cadastreGrabber) {
    4848        this.cadastreGrabber = cadastreGrabber;
    4949    }
    50    
     50
    5151    public boolean retrieveInterface(WMSLayer wmsLayer) throws DuplicateLayerException {
    5252        if (wmsLayer.name.equals(""))
     
    6464            JOptionPane.showMessageDialog(Main.parent,
    6565                    tr("Town/city {0} not found or not available in WMS.\n" +
    66                                 "Please check its availibility on www.cadastre.gouv.fr", wmsLayer.getLocation()));
     66                            "Please check its availibility on www.cadastre.gouv.fr", wmsLayer.getLocation()));
    6767            return false;
    6868        }
     
    9999        cadastreGrabber.setLastWMSLayerName(null);
    100100    }
    101    
     101
    102102    public void resetCookieIfNewLayer(String newWMSLayerName) {
    103103        if (!newWMSLayerName.equals(cadastreGrabber.getLastWMSLayerName())) {
     
    105105        }
    106106    }
    107    
     107
    108108    public void setCookie() {
    109109        urlConn.setRequestProperty("Cookie", cookie);
    110110    }
    111    
     111
    112112    private void getInterface(WMSLayer wmsLayer) throws IOException, DuplicateLayerException {
    113113        // first attempt : search for given name without codeCommune
     
    134134            }
    135135        }
    136        
     136
    137137        if (interfaceRef == null)
    138138            throw new IOException("Town/city " + wmsLayer.getLocation() + " not found.");
    139139    }
    140    
     140
    141141    private void openInterface() throws IOException  {
    142142        try {
     
    158158        }
    159159    }
    160    
     160
    161161    /**
    162162     * Post the form with the commune name and check the returned answer which is embedded
    163163     * in HTTP XML packets. This function doesn't use an XML parser yet but that would be a good idea
    164164     * for the next releases.
    165      * Two possibilities : 
     165     * Two possibilities :
    166166     * - either the commune name matches and we receive an URL starting with "afficherCarteCommune.do" or
    167167     * - we don't receive a single answer but a list of possible values. This answer looks like:
     
    171171     *   <option value="QK066" >COLMAR - 68000</option>
    172172     *   </select>
    173      * 
     173     *
    174174     * @param location
    175175     * @param codeCommune
     
    245245        return null;
    246246    }
    247    
     247
    248248    private void parseCommuneList(String input) {
    249249        if (input.indexOf(c0ptionListStart) != -1) {
     
    264264        }
    265265    }
    266    
     266
    267267    private void parseTAList(String input) {
    268268        while (input.indexOf(cInterfaceRaster) != -1) {
     
    272272            if (!listOfTA.contains(codeTA)) {
    273273                System.out.println("parse "+codeTA);
    274                 listOfTA.add(codeTA);               
     274                listOfTA.add(codeTA);
    275275            }
    276276            input = input.substring(cInterfaceRaster.length());
     
    314314        return cInterfaceRaster + "?f=" + codeCommune;
    315315    }
    316    
     316
    317317    public EastNorthBound retrieveCommuneBBox() throws IOException {
    318318        if (interfaceRef == null)
     
    340340        return parseBBoxCommune(line);
    341341    }
    342    
     342
    343343    private EastNorthBound parseBBoxCommune(String input) {
    344344        if (input.indexOf(cBBoxCommunStart) != -1) {
     
    356356        return null;
    357357    }
    358    
     358
    359359    private void checkLayerDuplicates(WMSLayer wmsLayer) throws DuplicateLayerException {
    360360        if (Main.map != null) {
     
    369369        }
    370370    }
    371    
    372     public void cancel() {     
     371
     372    public void cancel() {
    373373        Main.pleaseWaitDlg.currentAction.setText(tr("Aborting..."));
    374374        if (urlConn != null) {
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java

    r15904 r15961  
    190190            transparency = 1.0f;
    191191        }
    192         // overwrite F11 shortcut used from the beginning by this plugin and recently used 
     192        // overwrite F11 shortcut used from the beginning by this plugin and recently used
    193193        // for full-screen switch in JOSM core
    194194        int i = 0;
     
    202202        }
    203203        if (!alreadyRedefined) {
    204             int reply = JOptionPane.showConfirmDialog(null, 
     204            int reply = JOptionPane.showConfirmDialog(null,
    205205                    tr("Plugin cadastre-fr used traditionaly for grabbing the key shortcut F11\n"+
    206206                    "which is currently allocated for full-screen switch by default\n"+
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePreferenceSetting.java

    r13784 r15961  
    1515/**
    1616 * Preference settings for the French Cadastre plugin
    17  * 
     17 *
    1818 * @author Pieren <pieren3@gmail.com>
    1919 */
    2020public class CadastrePreferenceSetting implements PreferenceSetting {
    21    
     21
    2222    static final int TRANS_MIN = 1;
    2323    static final int TRANS_MAX = 10;
    24     private JSlider sliderTrans = new JSlider(JSlider.HORIZONTAL, TRANS_MIN, TRANS_MAX, TRANS_MAX); 
    25    
     24    private JSlider sliderTrans = new JSlider(JSlider.HORIZONTAL, TRANS_MIN, TRANS_MAX, TRANS_MAX);
     25
    2626    private JTextField sourcing = new JTextField(20);
    2727
     
    2929
    3030    private JCheckBox reversGrey = new JCheckBox(tr("Reverse grey colors (for black backgrounds)."));
    31    
     31
    3232    private JCheckBox transparency = new JCheckBox(tr("Set background transparent."));
    33    
     33
    3434    private JCheckBox drawBoundaries = new JCheckBox(tr("Draw boundaries of downloaded data."));
    3535
     
    3939
    4040    private JRadioButton grabMultiplier3 = new JRadioButton("", true);
    41    
     41
    4242    private JRadioButton grabMultiplier4 = new JRadioButton("", true);
    4343
     
    9797        sliderTrans.setPaintLabels(false);
    9898        cadastrewms.add(sliderTrans, GBC.eol().fill(GBC.HORIZONTAL).insets(20, 0, 250, 0));
    99        
     99
    100100        // option to draw boundaries of downloaded data
    101101        drawBoundaries.setSelected(Main.pref.getBoolean("cadastrewms.drawBoundaries", false));
     
    150150        grabMultiplier4Size.setEnabled(currentScale.equals(Scale.SQUARE_100M.value));
    151151        cadastrewms.add(grabMultiplier4Size, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 0, 5));
    152        
     152
    153153        // option to enable automatic caching
    154154        enableCache.addActionListener(new ActionListener() {
     
    197197        }
    198198        Main.pref.put("cadastrewms.enableCaching", enableCache.isSelected());
    199        
     199
    200200        // spread data into objects instead of restarting the application
    201201        try {
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CheckSourceUploadHook.java

    r13611 r15961  
    2424/**
    2525 * This hook is called at JOSM upload and will check if new nodes and ways provide
    26  * a tag "source=". If not and if auto-sourcing is enabled, it will add 
     26 * a tag "source=". If not and if auto-sourcing is enabled, it will add
    2727 * automatically a tag "source"="Cadastre..." as defined in the plugin preferences.
    2828 */
    2929public class CheckSourceUploadHook implements UploadHook
    3030{
    31         /** Serializable ID */
     31    /** Serializable ID */
    3232    private static final long serialVersionUID = -1;
    3333
     
    4040            Collection<OsmPrimitive> sel = new HashSet<OsmPrimitive>();
    4141            for (OsmPrimitive osm : add) {
    42                 if ((osm instanceof Node || osm instanceof Way) 
     42                if ((osm instanceof Node || osm instanceof Way)
    4343                        && (osm.keys == null || !tagSourceExist(osm))) {
    4444                    sel.add(osm);
     
    5151        return true;
    5252    }
    53    
     53
    5454    /**
    5555     * Check whenever one of the keys of the object is "source"
     
    6565        return false;
    6666    }
    67    
     67
    6868    /**
    69      * Displays a screen with the list of objects which will be tagged with 
     69     * Displays a screen with the list of objects which will be tagged with
    7070     * source="cadastre.." if it is approved.
    7171     * @param sel the list of elements added without a key "source"
    7272     */
    73     private void displaySource(Collection<OsmPrimitive> sel) 
     73    private void displaySource(Collection<OsmPrimitive> sel)
    7474    {
    7575        if (!sel.isEmpty()) {
     
    8686                Main.main.undoRedo.add(new ChangePropertyCommand(sel, "source", CadastrePlugin.source));
    8787        }
    88                
    89     }   
     88
     89    }
    9090}
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGBuilding.java

    r13784 r15961  
    2929import org.openstreetmap.josm.gui.MapView;
    3030import org.openstreetmap.josm.gui.PleaseWaitRunnable;
     31import org.openstreetmap.josm.io.OsmTransferException;
    3132import org.openstreetmap.josm.io.ProgressInputStream;
    3233
     
    3940    private static EastNorthBound currentView = null;
    4041    private EastNorthBound viewBox = null;
    41    
     42
    4243    public DownloadSVGBuilding(WMSLayer wmsLayer) {
    4344        super(tr("Downloading {0}", wmsLayer.name));
     
    4849
    4950    @Override
    50     public void realRun() throws IOException {
     51    public void realRun() throws IOException, OsmTransferException {
    5152        Main.pleaseWaitDlg.currentAction.setText(tr("Contacting WMS Server..."));
    5253        try {
     
    7778        double[] box = new SVGParser().getViewBox(svg);
    7879        if (box != null) {
    79             viewBox = new EastNorthBound(new EastNorth(box[0], box[1]), 
     80            viewBox = new EastNorthBound(new EastNorth(box[0], box[1]),
    8081                    new EastNorth(box[0]+box[2], box[1]+box[3]));
    8182            return true;
     
    8485        return false;
    8586    }
    86    
     87
    8788    /**
    8889     *  The svg contains more than one commune boundary defined by path elements. So detect
     
    9293        String[] SVGpaths = new SVGParser().getClosedPaths(svg);
    9394        ArrayList<ArrayList<EastNorth>> eastNorths = new ArrayList<ArrayList<EastNorth>>();
    94        
    95         // convert SVG nodes to eastNorth coordinates 
     95
     96        // convert SVG nodes to eastNorth coordinates
    9697        for (int i=0; i< SVGpaths.length; i++) {
    9798            ArrayList<EastNorth> eastNorth = new ArrayList<EastNorth>();
     
    107108            for (EastNorth eastNorth : path) {
    108109                Node nodeToAdd = new Node(Main.proj.eastNorth2latlon(eastNorth));
    109                 // check if new node is not already created by another new path 
    110                 Node nearestNewNode = checkNearestNode(nodeToAdd, svgDataSet.nodes); 
     110                // check if new node is not already created by another new path
     111                Node nearestNewNode = checkNearestNode(nodeToAdd, svgDataSet.nodes);
    111112                if (nearestNewNode == nodeToAdd)
    112113                    svgDataSet.addPrimitive(nearestNewNode);
     
    116117            svgDataSet.addPrimitive(wayToAdd);
    117118        }
    118        
     119
    119120        // TODO remove small boxes (4 nodes with less than 1 meter distance)
    120121        /*
     
    130131        // check if the new way or its nodes is already in OSM layer
    131132        for (Node n : svgDataSet.nodes) {
    132             Node nearestNewNode = checkNearestNode(n, Main.ds.nodes); 
     133            Node nearestNewNode = checkNearestNode(n, Main.ds.nodes);
    133134            if (nearestNewNode != n) {
    134135                // replace the SVG node by the OSM node
     
    145146                n.delete(true);
    146147            }
    147                
     148
    148149        }
    149150
     
    158159        Main.map.repaint();
    159160    }
    160    
     161
    161162    private void createNodes(String SVGpath, ArrayList<EastNorth> eastNorth) {
    162163        // looks like "M981283.38 368690.15l143.81 72.46 155.86 ..."
     
    170171            }
    171172            double east = dx+=Double.parseDouble(coor[i]);
    172             double north = dy+=Double.parseDouble(coor[i+1]); 
     173            double north = dy+=Double.parseDouble(coor[i+1]);
    173174            eastNorth.add(new EastNorth(east,north));
    174175        }
    175         // flip the image (svg using a reversed Y coordinate system)           
     176        // flip the image (svg using a reversed Y coordinate system)
    176177        double pivot = viewBox.min.getY() + (viewBox.max.getY() - viewBox.min.getY()) / 2;
    177178        for (EastNorth en : eastNorth) {
     
    183184    /**
    184185     * Check if node can be reused.
    185      * @param nodeToAdd the candidate as new node 
    186      * @return the already existing node (if any), otherwise the new node candidate. 
     186     * @param nodeToAdd the candidate as new node
     187     * @return the already existing node (if any), otherwise the new node candidate.
    187188     */
    188189    private Node checkNearestNode(Node nodeToAdd, Collection<Node> nodes) {
     
    199200    }
    200201
    201     private String grabBoundary(EastNorthBound bbox) throws IOException {
    202 
     202    private String grabBoundary(EastNorthBound bbox) throws IOException, OsmTransferException {
    203203        try {
    204204            URL url = null;
     
    210210        }
    211211    }
    212    
     212
    213213    private URL getURLsvg(EastNorthBound bbox) throws MalformedURLException {
    214214        String str = new String(wmsInterface.baseURL+"/scpc/wms?version=1.1&request=GetMap");
     
    228228    }
    229229
    230     private String grabSVG(URL url) throws IOException {
     230    private String grabSVG(URL url) throws IOException, OsmTransferException {
    231231        wmsInterface.urlConn = (HttpURLConnection)url.openConnection();
    232232        wmsInterface.urlConn.setRequestMethod("GET");
     
    259259        currentView = new EastNorthBound(mv.getEastNorth(0, mv.getHeight()),
    260260                mv.getEastNorth(mv.getWidth(), 0));
    261         if ((currentView.max.east() - currentView.min.east()) > 1000 || 
     261        if ((currentView.max.east() - currentView.min.east()) > 1000 ||
    262262                (currentView.max.north() - currentView.min.north() > 1000)) {
    263263            JOptionPane.showMessageDialog(Main.parent,
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGTask.java

    r13784 r15961  
    2929import org.openstreetmap.josm.data.osm.Way;
    3030import org.openstreetmap.josm.gui.PleaseWaitRunnable;
     31import org.openstreetmap.josm.io.OsmTransferException;
    3132import org.openstreetmap.josm.io.ProgressInputStream;
    3233/**
    33  * Grab the SVG administrative boundaries of the active commune layer (cadastre), 
     34 * Grab the SVG administrative boundaries of the active commune layer (cadastre),
    3435 * isolate the SVG path of the concerned commune (other municipalities are also
    3536 * downloaded in the SVG data), convert to OSM nodes and way plus simplify.
     
    4344    private String svg = null;
    4445    private EastNorthBound viewBox = null;
    45    
     46
    4647    public DownloadSVGTask(WMSLayer wmsLayer) {
    4748        super(tr("Downloading {0}", wmsLayer.name));
     
    5253
    5354    @Override
    54     public void realRun() throws IOException {
     55    public void realRun() throws IOException, OsmTransferException {
    5556        Main.pleaseWaitDlg.currentAction.setText(tr("Contacting WMS Server..."));
    5657        try {
     
    8384        double[] box = new SVGParser().getViewBox(svg);
    8485        if (box != null) {
    85             viewBox = new EastNorthBound(new EastNorth(box[0], box[1]), 
     86            viewBox = new EastNorthBound(new EastNorth(box[0], box[1]),
    8687                    new EastNorth(box[0]+box[2], box[1]+box[3]));
    8788            return true;
     
    9091        return false;
    9192    }
    92    
     93
    9394    /**
    9495     *  The svg contains more than one commune boundary defined by path elements. So detect
     
    9798    private void createWay(String svg) {
    9899        String[] SVGpaths = new SVGParser().getClosedPaths(svg);
    99         ArrayList<Double> fitViewBox = new ArrayList<Double>(); 
     100        ArrayList<Double> fitViewBox = new ArrayList<Double>();
    100101        ArrayList<ArrayList<EastNorth>> eastNorths = new ArrayList<ArrayList<EastNorth>>();
    101102        for (int i=0; i< SVGpaths.length; i++) {
     
    118119        }
    119120        wayToAdd.nodes.add(wayToAdd.nodes.get(0)); // close the circle
    120        
     121
    121122        // simplify the way
    122123        double threshold = Double.parseDouble(Main.pref.get("cadastrewms.simplify-way-boundary", "1.0"));
    123124        new SimplifyWay().simplifyWay(wayToAdd, Main.ds, threshold);
    124        
     125
    125126        cmds.add(new AddCommand(wayToAdd));
    126127        Main.main.undoRedo.add(new SequenceCommand(tr("Create boundary"), cmds));
    127128        Main.map.repaint();
    128129    }
    129    
     130
    130131    private double createNodes(String SVGpath, ArrayList<EastNorth> eastNorth) {
    131132        // looks like "M981283.38 368690.15l143.81 72.46 155.86 ..."
     
    139140        for (int i=3; i<coor.length; i+=2){
    140141            double east = dx+=Double.parseDouble(coor[i]);
    141             double north = dy+=Double.parseDouble(coor[i+1]); 
     142            double north = dy+=Double.parseDouble(coor[i+1]);
    142143            eastNorth.add(new EastNorth(east,north));
    143             minX = minX > east ? east : minX; 
    144             minY = minY > north ? north : minY; 
    145             maxX = maxX < east ? east : maxX; 
    146             maxY = maxY < north ? north : maxY; 
    147         }
    148         // flip the image (svg using a reversed Y coordinate system)           
     144            minX = minX > east ? east : minX;
     145            minY = minY > north ? north : minY;
     146            maxX = maxX < east ? east : maxX;
     147            maxY = maxY < north ? north : maxY;
     148        }
     149        // flip the image (svg using a reversed Y coordinate system)
    149150        double pivot = viewBox.min.getY() + (viewBox.max.getY() - viewBox.min.getY()) / 2;
    150151        for (EastNorth en : eastNorth) {
     
    154155        +Math.abs(minY - viewBox.min.getY())+Math.abs(maxY - viewBox.max.getY());
    155156    }
    156    
    157     private String grabBoundary(EastNorthBound bbox) throws IOException {
    158 
     157
     158    private String grabBoundary(EastNorthBound bbox) throws IOException, OsmTransferException {
    159159        try {
    160160            URL url = null;
     
    166166        }
    167167    }
    168    
     168
    169169    private URL getURLsvg(EastNorthBound bbox) throws MalformedURLException {
    170170        String str = new String(wmsInterface.baseURL+"/scpc/wms?version=1.1&request=GetMap");
     
    183183    }
    184184
    185     private String grabSVG(URL url) throws IOException {
     185    private String grabSVG(URL url) throws IOException, OsmTransferException {
    186186        wmsInterface.urlConn = (HttpURLConnection)url.openConnection();
    187187        wmsInterface.urlConn.setRequestMethod("GET");
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSTask.java

    r13545 r15961  
    3838                    }
    3939                    if (wmsLayer.isRaster())
    40                         // set raster image commune bounding box based on current view (before adjustment) 
     40                        // set raster image commune bounding box based on current view (before adjustment)
    4141                        wmsLayer.setRasterBounds(bounds);
    4242                    else
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/EastNorthBound.java

    r13611 r15961  
    88
    99    private static final long serialVersionUID = 8451650309216472069L;
    10    
     10
    1111    public EastNorth min, max;
    1212    public EastNorthBound(EastNorth min, EastNorth max) {
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/GeorefImage.java

    r13784 r15961  
    2828
    2929    public BufferedImage image;
    30    
     30
    3131    private double angle = 0; // in radian
    32    
     32
    3333    private BufferedImage rotated_image; // only if angle <> 0
    3434
     
    4747        max = new EastNorth(max.east() + dx, max.north() + dy);
    4848    }
    49    
     49
    5050    public void resize(EastNorth rasterCenter, double proportion) {
    5151        min = min.interpolate(rasterCenter, proportion);
     
    5353        updatePixelPer();
    5454    }
    55    
     55
    5656    public void rotate(EastNorth pivot, double delta) {
    5757        if (angle == 0) {
    58             org_min = min; 
     58            org_min = min;
    5959            org_max = max;
    6060        }
    6161        this.angle += delta;
    62        
     62
    6363        EastNorth imageCenter = org_min.interpolate(org_max, 0.5);
    6464        EastNorth newimageCenter = imageCenter.rotate(pivot, angle);
     
    7474        max2 = max2.rotate(newimageCenter, angle);
    7575        getNewBounding(min, max, min2, max2);
    76        
     76
    7777        rotated_image = tilt(image, angle);
    7878    }
    79    
     79
    8080    public static BufferedImage tilt(BufferedImage image, double angle) {
    8181        double sin = Math.abs(Math.sin(angle)), cos = Math.abs(Math.cos(angle));
     
    9696        return gd.getDefaultConfiguration();
    9797    }
    98    
     98
    9999    private void getNewBounding(EastNorth min, EastNorth max, EastNorth c, EastNorth d) {
    100100        EastNorth pt[] = new EastNorth[4];
     
    116116        max.setLocation(highestEast, highestNorth);
    117117    }
    118    
     118
    119119    public boolean contains(EastNorth en) {
    120120        return min.east() <= en.east() && en.east() <= max.east() && min.north() <= en.north()
     
    165165    /**
    166166     * Make all pixels masked by the given georefImage transparent in this image
    167      * 
     167     *
    168168     * @param georefImage
    169169     */
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/ImageModifier.java

    r13784 r15961  
    1818    public static final int cadastreBackground = -1; // white
    1919
    20     public static final int cadastreBackgroundTransp = 1; // original white but transparent 
     20    public static final int cadastreBackgroundTransp = 1; // original white but transparent
    2121
    2222    public BufferedImage bufferedImage;
     
    2525
    2626    private int backgroundPixel = 0;
    27    
     27
    2828    private int backgroundSampleX, backgroundSampleY;
    2929
     
    3434        else if (Main.pref.getBoolean("cadastrewms.alterColors"))
    3535            replaceBackground();
    36        
     36
    3737        if (Main.pref.getBoolean("cadastrewms.invertGrey"))
    3838            invertGrey();
     
    5959        }
    6060    }
    61    
     61
    6262    /**
    6363     * Invert black/white/grey pixels (to change original black characters to white).
     
    7878    /**
    7979     * Reverse the grey value if the pixel is grey (light grey becomes dark grey)
    80      * Used for texts. 
     80     * Used for texts.
    8181     * @param pixel
    8282     * @return
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionGrab.java

    r13497 r15961  
    2121    public MenuActionGrab() {
    2222        super(tr(name), "cadastre_small", tr("Download Image from french Cadastre WMS"),
    23                 Shortcut.registerShortcut("cadastre:grab", tr("Cadastre: {0}", tr("Download Image from french Cadastre WMS")), 
     23                Shortcut.registerShortcut("cadastre:grab", tr("Cadastre: {0}", tr("Download Image from french Cadastre WMS")),
    2424                KeyEvent.VK_F11, Shortcut.GROUP_DIRECT), false);
    2525    }
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionLoadFromCache.java

    r13497 r15961  
    3131            String ext = (filename.lastIndexOf(".")==-1)?"":filename.substring(filename.lastIndexOf(".")+1,filename.length());
    3232            String location = filename.substring(0, filename.lastIndexOf("."));
    33             // check the extension and its Lambert zone consistency 
     33            // check the extension and its Lambert zone consistency
    3434            try {
    3535                int cacheZone = Integer.parseInt(ext) - 1;
     
    6363                Main.main.addLayer(wmsLayer);
    6464        }
    65        
     65
    6666    }
    6767
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionNewLocation.java

    r13545 r15961  
    2121public class MenuActionNewLocation extends JosmAction {
    2222
    23         private static final long serialVersionUID = 1L;
    24        
    25         public MenuActionNewLocation() {
    26                 super(tr("Change location"), "cadastre_small", tr("Set a new location for the next request"), null, false);
    27         }
     23    private static final long serialVersionUID = 1L;
    2824
    29         public void actionPerformed(ActionEvent e) {
     25    public MenuActionNewLocation() {
     26        super(tr("Change location"), "cadastre_small", tr("Set a new location for the next request"), null, false);
     27    }
     28
     29    public void actionPerformed(ActionEvent e) {
    3030        WMSLayer wmsLayer = addNewLayer(new ArrayList<WMSLayer>());
    3131        if (wmsLayer != null)
    3232            DownloadWMSTask.download(wmsLayer);
    3333    }
    34        
    35         public WMSLayer addNewLayer(ArrayList<WMSLayer> existingLayers) {
     34
     35    public WMSLayer addNewLayer(ArrayList<WMSLayer> existingLayers) {
    3636        if (Main.map == null) {
    3737            JOptionPane.showMessageDialog(Main.parent,
     
    8888                System.out.println("Add new layer with Location:" + inputTown.getText());
    8989            } else if (existingLayers != null && existingLayers.size() > 0 && inputWMSList.getSelectedIndex() > 0) {
    90                 wmsLayer = existingLayers.get(inputWMSList.getSelectedIndex()-1);           
     90                wmsLayer = existingLayers.get(inputWMSList.getSelectedIndex()-1);
    9191                resetCookie = true;
    9292            }
     
    9797        }
    9898    }
    99        
     99
    100100}
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionResetCookie.java

    r13497 r15961  
    1010
    1111    /**
    12      * 
     12     *
    1313     */
    1414    private static final long serialVersionUID = 1L;
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/Scale.java

    r13497 r15961  
    66 * view is split in 2x2 bounding boxes and X3 is 3x3 boxes.
    77 * SQUARE_100M is a special value where bounding boxes have a fixed size of 100x100 meters
    8  * and east,north are rounded to the lowest 100 meter as well, thus none of the bounding boxes 
     8 * and east,north are rounded to the lowest 100 meter as well, thus none of the bounding boxes
    99 * are overlapping each others.
    1010 */
    11 public enum Scale { 
    12     X1("1"), 
     11public enum Scale {
     12    X1("1"),
    1313    X2("2"),
    1414    X3("3"),
     
    1919     */
    2020    public final String value;
    21    
     21
    2222    Scale(String value) {
    2323        this.value = value;
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSAdjustAction.java

    r15841 r15961  
    1 package cadastre_fr; 
     1package cadastre_fr;
    22
    33import static org.openstreetmap.josm.tools.I18n.tr;
     
    2020
    2121public class WMSAdjustAction extends MapMode implements
    22                 MouseListener, MouseMotionListener{
     22        MouseListener, MouseMotionListener{
    2323
    2424    private static final long serialVersionUID = 1L;
    2525    GeorefImage selectedImage;
    2626    private ArrayList<WMSLayer> modifiedLayers = new ArrayList<WMSLayer>();
    27         WMSLayer selectedLayer;
    28         private boolean rasterMoved;
    29         private EastNorth prevEastNorth;
     27    WMSLayer selectedLayer;
     28    private boolean rasterMoved;
     29    private EastNorth prevEastNorth;
    3030    enum Mode { moveXY, moveZ, rotate}
    3131    private Mode mode = null;
    3232
    33         public WMSAdjustAction(MapFrame mapFrame) {
    34                 super(tr("Adjust WMS"), "adjustxywms", 
    35                                                 tr("Adjust the position of the WMS layer (raster images only)"), mapFrame, 
    36                                                 ImageProvider.getCursor("normal", "move"));
    37         }
     33    public WMSAdjustAction(MapFrame mapFrame) {
     34        super(tr("Adjust WMS"), "adjustxywms",
     35                        tr("Adjust the position of the WMS layer (raster images only)"), mapFrame,
     36                        ImageProvider.getCursor("normal", "move"));
     37    }
    3838
    39         @Override public void enterMode() {
    40                 super.enterMode();
    41                 Main.map.mapView.addMouseListener(this);
    42                 Main.map.mapView.addMouseMotionListener(this);
    43                 rasterMoved = false;
    44                 /*/ FOR TEST
     39    @Override public void enterMode() {
     40        super.enterMode();
     41        Main.map.mapView.addMouseListener(this);
     42        Main.map.mapView.addMouseMotionListener(this);
     43        rasterMoved = false;
     44        /*/ FOR TEST
    4545        for (Layer layer : Main.map.mapView.getAllLayers()) {
    4646            if (layer.visible && layer instanceof WMSLayer) {
     
    5050        }
    5151        Main.map.mapView.repaint();*/
    52         }
     52    }
    5353
    54         @Override public void exitMode() {
    55                 super.exitMode();
    56                 Main.map.mapView.removeMouseListener(this);
    57                 Main.map.mapView.removeMouseMotionListener(this);
    58                 if (rasterMoved && CacheControl.cacheEnabled) {
    59             int reply = JOptionPane.showConfirmDialog(null, 
     54    @Override public void exitMode() {
     55        super.exitMode();
     56        Main.map.mapView.removeMouseListener(this);
     57        Main.map.mapView.removeMouseMotionListener(this);
     58        if (rasterMoved && CacheControl.cacheEnabled) {
     59            int reply = JOptionPane.showConfirmDialog(null,
    6060                    "Save the changes in cache ?",
    6161                    "Update cache",
    62                     JOptionPane.YES_NO_OPTION);             
     62                    JOptionPane.YES_NO_OPTION);
    6363            if (reply == JOptionPane.OK_OPTION) {
    6464                saveModifiedLayers();
    6565            }
    66                 }
    67                 modifiedLayers.clear();
    68         }
     66        }
     67        modifiedLayers.clear();
     68    }
    6969
    70         @Override
     70    @Override
    7171    public void mousePressed(MouseEvent e) {
    7272        if (e.getButton() != MouseEvent.BUTTON1)
     
    9393    }
    9494
    95         @Override public void mouseDragged(MouseEvent e) {
    96                 if(selectedImage != null && (mode == Mode.moveXY || mode == Mode.moveZ || mode == Mode.rotate)) {
     95    @Override public void mouseDragged(MouseEvent e) {
     96        if(selectedImage != null && (mode == Mode.moveXY || mode == Mode.moveZ || mode == Mode.rotate)) {
    9797            EastNorth newEastNorth = Main.map.mapView.getEastNorth(e.getX(),e.getY());
    98                     if (mode == Mode.moveXY) {
    99                         displace(prevEastNorth, newEastNorth);
    100                 } else if (mode == Mode.moveZ) {
    101                     resize(newEastNorth);
    102                 } else if (mode == Mode.rotate) {
    103                     rotate(prevEastNorth, newEastNorth);
    104                 }
     98            if (mode == Mode.moveXY) {
     99                displace(prevEastNorth, newEastNorth);
     100            } else if (mode == Mode.moveZ) {
     101                resize(newEastNorth);
     102            } else if (mode == Mode.rotate) {
     103                rotate(prevEastNorth, newEastNorth);
     104            }
    105105            rasterMoved = true;
    106106            if (!modifiedLayers.contains(selectedLayer))
     
    108108            Main.map.mapView.repaint();
    109109            prevEastNorth = newEastNorth;
    110                 }
    111         }
    112        
    113         private void displace(EastNorth start, EastNorth end) {
     110        }
     111    }
     112
     113    private void displace(EastNorth start, EastNorth end) {
    114114        selectedLayer.displace(end.east()-start.east(), end.north()-start.north());
    115         }
    116        
    117         private void resize(EastNorth newEastNorth) {
     115    }
     116
     117    private void resize(EastNorth newEastNorth) {
    118118        double dPrev = prevEastNorth.distance(selectedLayer.getRasterCenter().east(), selectedLayer.getRasterCenter().north());
    119119        double dNew = newEastNorth.distance(selectedLayer.getRasterCenter().east(), selectedLayer.getRasterCenter().north());
    120120        selectedLayer.resize(1 - dNew/dPrev);
    121         }
    122        
    123         private void rotate(EastNorth start, EastNorth end) {
    124             EastNorth pivot = selectedLayer.getRasterCenter();
    125             double startAngle = Math.atan2(start.east()-pivot.east(), start.north()-pivot.north());
    126             double endAngle = Math.atan2(end.east()-pivot.east(), end.north()-pivot.north());
     121    }
     122
     123    private void rotate(EastNorth start, EastNorth end) {
     124        EastNorth pivot = selectedLayer.getRasterCenter();
     125        double startAngle = Math.atan2(start.east()-pivot.east(), start.north()-pivot.north());
     126        double endAngle = Math.atan2(end.east()-pivot.east(), end.north()-pivot.north());
    127127        double rotationAngle = endAngle - startAngle;
    128         selectedLayer.rotate(rotationAngle);                       
    129         }
     128        selectedLayer.rotate(rotationAngle);
     129    }
    130130
    131         @Override public void mouseReleased(MouseEvent e) {
    132                 //Main.map.mapView.repaint();
    133                 Main.map.mapView.setCursor(Cursor.getDefaultCursor());
    134                 selectedImage = null;   
    135                 prevEastNorth = null;
    136                 selectedLayer = null;
    137                 mode = null;
    138         }
     131    @Override public void mouseReleased(MouseEvent e) {
     132        //Main.map.mapView.repaint();
     133        Main.map.mapView.setCursor(Cursor.getDefaultCursor());
     134        selectedImage = null;
     135        prevEastNorth = null;
     136        selectedLayer = null;
     137        mode = null;
     138    }
    139139
    140         public void mouseEntered(MouseEvent e) {
    141         }
    142         public void mouseExited(MouseEvent e) {
    143         }
    144         public void mouseMoved(MouseEvent e) {
    145         }
     140    public void mouseEntered(MouseEvent e) {
     141    }
     142    public void mouseExited(MouseEvent e) {
     143    }
     144    public void mouseMoved(MouseEvent e) {
     145    }
    146146
    147         @Override public void mouseClicked(MouseEvent e) {
    148         }
    149        
    150         private void saveModifiedLayers() {
     147    @Override public void mouseClicked(MouseEvent e) {
     148    }
     149
     150    private void saveModifiedLayers() {
    151151        for (WMSLayer wmsLayer : modifiedLayers) {
    152152            wmsLayer.saveNewCache();
    153153        }
    154         }
     154    }
    155155}
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSDownloadAction.java

    r13784 r15961  
    1616    private static final long serialVersionUID = 1L;
    1717
    18         public WMSDownloadAction(String layerName) {
    19                 super(layerName, "wmsmenu", tr("Download WMS tile from {0}",layerName), null, false);
    20         }
    21        
    22         public void actionPerformed(ActionEvent e) {           
    23                 DownloadWMSTask.download(getLayer());
    24         }
     18    public WMSDownloadAction(String layerName) {
     19        super(layerName, "wmsmenu", tr("Download WMS tile from {0}",layerName), null, false);
     20    }
    2521
    26         public static WMSLayer getLayer() {
    27                 // check if we already have a layer created. if not, create; if yes, reuse.
     22    public void actionPerformed(ActionEvent e) {
     23        DownloadWMSTask.download(getLayer());
     24    }
     25
     26    public static WMSLayer getLayer() {
     27        // check if we already have a layer created. if not, create; if yes, reuse.
    2828        if (Main.map != null) {
    2929            Layer activeLayer = Main.map.mapView.getActiveLayer();
     
    4444        }
    4545        return null;
    46         }
     46    }
    4747};
    4848
Note: See TracChangeset for help on using the changeset viewer.