Ignore:
Timestamp:
2010-12-29T23:18:37+01:00 (14 years ago)
Author:
pieren
Message:

Removed the building shapes recognition

Location:
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr
Files:
3 deleted
7 edited

Legend:

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

    r23190 r24907  
    9696    public boolean loadCacheIfExist() {
    9797        try {
    98             if (!wmsLayer.isBuildingsOnly()) {
    99                 File file = new File(CadastrePlugin.cacheDir + wmsLayer.getName() + "." + WMSFileExtension());
    100                 if (file.exists()) {
    101                     JOptionPane pane = new JOptionPane(
    102                             tr("Location \"{0}\" found in cache.\n"+
    103                             "Load cache first ?\n"+
    104                             "(No = new cache)", wmsLayer.getName()),
    105                             JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null);
    106                     // this below is a temporary workaround to fix the "always on top" issue
    107                     JDialog dialog = pane.createDialog(Main.parent, tr("Select Feuille"));
    108                     CadastrePlugin.prepareDialog(dialog);
    109                     dialog.setVisible(true);
    110                     int reply = (Integer)pane.getValue();
    111                     // till here
    112 
    113                     if (reply == JOptionPane.OK_OPTION && loadCache(file, wmsLayer.getLambertZone())) {
    114                         return true;
    115                     } else {
    116                         delete(file);
    117                     }
    118                 }
    119             } else {
    120                 int i=0;
    121                 while (new File(CadastrePlugin.cacheDir + wmsLayer.getName() + "."+i+"."+ WMSFileExtension()).exists())
    122                     i++;
    123                 wmsLayer.setName(wmsLayer.getName()+"."+i);
     98            File file = new File(CadastrePlugin.cacheDir + wmsLayer.getName() + "." + WMSFileExtension());
     99            if (file.exists()) {
     100                JOptionPane pane = new JOptionPane(
     101                        tr("Location \"{0}\" found in cache.\n"+
     102                        "Load cache first ?\n"+
     103                        "(No = new cache)", wmsLayer.getName()),
     104                        JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null);
     105                // this below is a temporary workaround to fix the "always on top" issue
     106                JDialog dialog = pane.createDialog(Main.parent, tr("Select Feuille"));
     107                CadastrePlugin.prepareDialog(dialog);
     108                dialog.setVisible(true);
     109                int reply = (Integer)pane.getValue();
     110                // till here
     111
     112                if (reply == JOptionPane.OK_OPTION && loadCache(file, wmsLayer.getLambertZone())) {
     113                    return true;
     114                } else {
     115                    delete(file);
     116                }
    124117            }
    125118        } catch (Exception e) {
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreGrabber.java

    r23190 r24907  
    3737                imageModified = new VectorImageModifier(img, false);
    3838            return new GeorefImage(imageModified.bufferedImage, lambertMin, lambertMax);
    39         } catch (MalformedURLException e) {
    40             throw (IOException) new IOException(tr("CadastreGrabber: Illegal url.")).initCause(e);
    41         }
    42     }
    43 
    44     public GeorefImage grabBuildings(WMSLayer wmsLayer, EastNorth lambertMin, EastNorth lambertMax) throws IOException, OsmTransferException {
    45         try {
    46             URL url = getURLVectorBuildings(lambertMin, lambertMax);
    47             BufferedImage img = grab(url);
    48             ImageModifier imageModified = new VectorImageModifier(img, true);
    49             return new GeorefImage(imageModified.bufferedImage, lambertMin, lambertMax);
    50         } catch (MalformedURLException e) {
    51             throw (IOException) new IOException(tr("CadastreGrabber: Illegal url.")).initCause(e);
    52         }
    53     }
    54 
    55     public GeorefImage grabParcels(WMSLayer wmsLayer, EastNorth lambertMin, EastNorth lambertMax) throws IOException, OsmTransferException {
    56         try {
    57             URL url = getURLVectorParcels(lambertMin, lambertMax);
    58             BufferedImage img = grab(url);
    59             //ImageModifier imageModified = new VectorImageModifier(img, true);
    60             return new GeorefImage(/*imageModified.bufferedImage*/img, lambertMin, lambertMax);
    6139        } catch (MalformedURLException e) {
    6240            throw (IOException) new IOException(tr("CadastreGrabber: Illegal url.")).initCause(e);
     
    10583    }
    10684
    107     private URL getURLVectorBuildings(EastNorth lambertMin, EastNorth lambertMax) throws MalformedURLException {
    108         return buildURLVector("CDIF:LS2", "LS2_90", 1000, 800, lambertMin, lambertMax);
    109     }
    110 
    111     private URL getURLVectorParcels(EastNorth lambertMin, EastNorth lambertMax) throws MalformedURLException {
    112         return buildURLVector("CDIF:PARCELLE", "PARCELLE_90", 1000, 800, lambertMin, lambertMax);
    113     }
    114 
    11585    private BufferedImage grab(URL url) throws IOException, OsmTransferException {
    11686        wmsInterface.urlConn = (HttpURLConnection)url.openConnection();
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSVectorImage.java

    r24899 r24907  
    2020    private static String errorMessage;
    2121
    22     public DownloadWMSVectorImage(WMSLayer wmsLayer, Bounds bounds, boolean buildingsOnly) {
     22    public DownloadWMSVectorImage(WMSLayer wmsLayer, Bounds bounds) {
    2323        super(tr("Downloading {0}", wmsLayer.getName()));
    2424
    2525        this.wmsLayer = wmsLayer;
    2626        this.bounds = bounds;
    27         this.wmsLayer.setBuildingsOnly(buildingsOnly);
    2827    }
    2928
     
    8483    }
    8584
    86     public static void download(WMSLayer wmsLayer, boolean buildingsOnly) {
     85    public static void download(WMSLayer wmsLayer) {
    8786        MapView mv = Main.map.mapView;
    8887        Bounds bounds = new Bounds(mv.getLatLon(0, mv.getHeight()), mv.getLatLon(mv.getWidth(), 0));
    8988
    90         Main.worker.execute(new DownloadWMSVectorImage(wmsLayer, bounds, buildingsOnly));
     89        Main.worker.execute(new DownloadWMSVectorImage(wmsLayer, bounds));
    9190        if (errorMessage != null)
    9291            JOptionPane.showMessageDialog(Main.parent, errorMessage);
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionGrab.java

    r20390 r24907  
    3333                WMSLayer wmsLayer = WMSDownloadAction.getLayer();
    3434                if (wmsLayer != null)
    35                     DownloadWMSVectorImage.download(wmsLayer, false);
     35                    DownloadWMSVectorImage.download(wmsLayer);
    3636            } else {
    3737                JOptionPane.showMessageDialog(Main.parent,
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionNewLocation.java

    r23190 r24907  
    5858        WMSLayer wmsLayer = addNewLayer(new ArrayList<WMSLayer>());
    5959        if (wmsLayer != null)
    60             DownloadWMSVectorImage.download(wmsLayer, false);
     60            DownloadWMSVectorImage.download(wmsLayer);
    6161    }
    6262
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSDownloadAction.java

    r20390 r24907  
    3030        if (Main.map != null) {
    3131            Layer activeLayer = Main.map.mapView.getActiveLayer();
    32             if (activeLayer instanceof WMSLayer && !((WMSLayer)activeLayer).isBuildingsOnly())
     32            if (activeLayer instanceof WMSLayer)
    3333                return (WMSLayer) activeLayer;
    3434            for (Layer l : Main.map.mapView.getAllLayers()) {
    35                 if (l instanceof WMSLayer && !((WMSLayer)l).isBuildingsOnly()) {
     35                if (l instanceof WMSLayer) {
    3636                    existingWMSlayers.add((WMSLayer)l);
    3737                }
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java

    r23190 r24907  
    5959    public static int currentFormat;
    6060
    61     private static final int cBBoxForBuildings = 50; // hard coded size of grabbed boxes for building layers
    62 
    6361    private ArrayList<EastNorthBound> dividedBbox = new ArrayList<EastNorthBound>();
    6462
     
    7775    private boolean isRaster = false;
    7876    private boolean isAlreadyGeoreferenced = false;
    79     private boolean buildingsOnly = false;
    8077    public double X0, Y0, angle, fX, fY;
    8178
     
    9592
    9693    public WMSLayer(String location, String codeCommune, int lambertZone) {
    97         super(buildName(location, codeCommune, false));
     94        super(buildName(location, codeCommune));
    9895        this.location = location;
    9996        this.codeCommune = codeCommune;
     
    118115    }
    119116
    120     private static String buildName(String location, String codeCommune, boolean buildingOnly) {
     117    private static String buildName(String location, String codeCommune) {
    121118        String ret = location.toUpperCase();
    122119        if (codeCommune != null && !codeCommune.equals(""))
    123120            ret += "(" + codeCommune + ")";
    124         if (buildingOnly)
    125             ret += ".b";
    126121        return  ret;
    127122    }
    128123
    129124    private String rebuildName() {
    130         return buildName(this.location.toUpperCase(), this.codeCommune, this.buildingsOnly);
     125        return buildName(this.location.toUpperCase(), this.codeCommune);
    131126    }
    132127
     
    142137                divideBbox(b, Integer.parseInt(Main.pref.get("cadastrewms.rasterDivider",
    143138                        CadastrePreferenceSetting.DEFAULT_RASTER_DIVIDER)), 0);
    144             } else if (buildingsOnly)
    145                 divideBbox(b, 5, cBBoxForBuildings);
    146             else
     139            } else
    147140                divideBbox(b, Integer.parseInt(Main.pref.get("cadastrewms.scale", Scale.X1.toString())), 0);
    148141        } else
     
    155148            GeorefImage newImage;
    156149            try {
    157                 if (buildingsOnly == false)
    158                     newImage = grabber.grab(this, n.min, n.max);
    159                 else { // TODO
    160                     GeorefImage buildings = grabber.grabBuildings(this, n.min, n.max);
    161                     GeorefImage parcels = grabber.grabParcels(this, n.min, n.max);
    162                     new BuildingsImageModifier(buildings, parcels);
    163                     newImage = buildings;
    164                 }
     150                newImage = grabber.grab(this, n.min, n.max);
    165151            } catch (IOException e) {
    166152                System.out.println("Download action cancelled by user or server did not respond");
     
    189175        }
    190176        if (!cancelled) {
    191             if (buildingsOnly)
    192                 joinBufferedImages();
    193177            for (int i=lastSavedImage; i < images.size(); i++)
    194178                saveToCache(images.get(i));
     
    197181
    198182    /**
    199      *
     183     * Divides the bounding box in smaller polygons.
     184     *
    200185     * @param b      the original bbox, usually the current bbox on screen
    201186     * @param factor 1 = source bbox 1:1
     
    398383    }
    399384
    400     public boolean isBuildingsOnly() {
    401         return buildingsOnly;
    402     }
    403 
    404     public void setBuildingsOnly(boolean buildingsOnly) {
    405         this.buildingsOnly = buildingsOnly;
    406         setName(rebuildName());
    407     }
    408 
    409385    public boolean isRaster() {
    410386        return isRaster;
     
    458434        oos.writeInt(this.lambertZone);
    459435        oos.writeBoolean(this.isRaster);
    460         oos.writeBoolean(this.buildingsOnly);
     436        oos.writeBoolean(false); // previously buildingsOnly
    461437        if (this.isRaster) {
    462438            oos.writeDouble(this.rasterMin.getX());
     
    491467        this.setRaster(ois.readBoolean());
    492468        if (currentFormat >= 4)
    493             this.setBuildingsOnly(ois.readBoolean());
     469            ois.readBoolean();
    494470        if (this.isRaster) {
    495471            double X = ois.readDouble();
Note: See TracChangeset for help on using the changeset viewer.