Ignore:
Timestamp:
2009-10-24T20:06:29+02:00 (16 years ago)
Author:
pieren
Message:

Added autodetection and use of raster images already georeferenced

File:
1 edited

Legend:

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

    r17702 r18271  
    9494        boolean loadedFromCache = downloadWMSPlanImage.waitFinished();
    9595        if (wmsLayer.images.size() == 1 && !loadedFromCache) {
    96             mouseClickedTime = System.currentTimeMillis();
    97             Main.map.mapView.addMouseListener(this);
    98             if (Main.pref.getBoolean("cadastrewms.noImageCropping", false) == false)
    99                 startCropping();
    100             else
    101                 startGeoreferencing();
     96            int reply = JOptionPane.CANCEL_OPTION;
     97            if (wmsLayer.isAlreadyGeoreferenced()) {
     98                reply = JOptionPane.showConfirmDialog(null,
     99                        tr("This image contains georeference data.\n"+
     100                                "Do you want to use them ?"),
     101                        null,
     102                        JOptionPane.YES_NO_OPTION);
     103            }
     104            if (reply == JOptionPane.OK_OPTION) {
     105                transformGeoreferencedImg();
     106            } else {
     107                mouseClickedTime = System.currentTimeMillis();
     108                Main.map.mapView.addMouseListener(this);
     109                if (Main.pref.getBoolean("cadastrewms.noImageCropping", false) == false)
     110                    startCropping();
     111                else
     112                    startGeoreferencing();
     113            }
    102114        } else // action cancelled or image loaded from cache (and already georeferenced)
    103115            Main.map.repaint();
     
    310322    }
    311323
     324    private void transformGeoreferencedImg() {
     325        georefpoint1 = new EastNorth(wmsLayer.X0, wmsLayer.Y0);
     326        georefpoint2 = new EastNorth(wmsLayer.X0+wmsLayer.fX*wmsLayer.communeBBox.max.getX(),
     327                wmsLayer.Y0+wmsLayer.fY*wmsLayer.communeBBox.max.getX());
     328        ea1 = new EastNorth(wmsLayer.images.get(0).min.east(), wmsLayer.images.get(0).max.north());
     329        EastNorth ea2 = wmsLayer.images.get(0).max;
     330        affineTransform(ea1, ea2, georefpoint1, georefpoint2);
     331        wmsLayer.saveNewCache();
     332        Main.map.mapView.repaint();
     333    }
     334
    312335    public void mouseEntered(MouseEvent arg0) {
    313336    }
Note: See TracChangeset for help on using the changeset viewer.