Ignore:
Timestamp:
2010-03-09T22:02:00+01:00 (15 years ago)
Author:
pieren
Message:

Many small fixes and improvements

File:
1 edited

Legend:

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

    r20247 r20390  
    3535                imageModified = new RasterImageModifier(img);
    3636            else
    37                 imageModified = new VectorImageModifier(img);
     37                imageModified = new VectorImageModifier(img, false);
    3838            return new GeorefImage(imageModified.bufferedImage, lambertMin, lambertMax);
    3939        } catch (MalformedURLException e) {
     
    4242    }
    4343
     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);
     61        } catch (MalformedURLException e) {
     62            throw (IOException) new IOException(tr("CadastreGrabber: Illegal url.")).initCause(e);
     63        }
     64    }
     65   
    4466    private URL getURLRaster(WMSLayer wmsLayer, EastNorth lambertMin, EastNorth lambertMax) throws MalformedURLException {
    4567        // GET /scpc/wms?version=1.1&request=GetMap&layers=CDIF:PMC@QH4480001701&format=image/png&bbox=-1186,0,13555,8830&width=576&height=345&exception=application/vnd.ogc.se_inimage&styles= HTTP/1.1
     
    4971        str += wmsLayer.getCodeCommune();
    5072        str += "&format=image/png";
     73        //str += "&format=image/jpeg";
    5174        str += "&bbox=";
    5275        str += wmsLayer.eastNorth2raster(lambertMin, lambertMax);
    53         //str += "&width=1000&height=800"; // maximum allowed by wms server
    5476        str += "&width="+cRasterX+"&height="; // maximum allowed by wms server (576/345, 800/378, 1000/634)
    5577        str += (int)(cRasterX*(wmsLayer.communeBBox.max.getY() - wmsLayer.communeBBox.min.getY())/(wmsLayer.communeBBox.max.getX() - wmsLayer.communeBBox.min.getX()));
    56         str += "&exception=application/vnd.ogc.se_inimage&styles=";
     78        str += "&exception=application/vnd.ogc.se_inimage&styles="; // required for raster images
     79        System.out.println("URL="+str);
    5780        return new URL(str.replace(" ", "%20"));
    5881    }
    5982
    60     private URL getURLVector(EastNorth lambertMin, EastNorth lambertMax) throws MalformedURLException {
     83    private URL buildURLVector(String layers, String styles,
     84            int width, int height,
     85            EastNorth lambertMin, EastNorth lambertMax) throws MalformedURLException {
    6186        String str = new String(wmsInterface.baseURL+"/scpc/wms?version=1.1&request=GetMap");
    62         str += "&layers="+CadastrePlugin.grabLayers;
     87        str += "&layers="+ layers; 
    6388        str += "&format=image/png";
    6489        //str += "&format=image/jpeg";
     
    6792        str += lambertMax.east() + ",";
    6893        str += lambertMax.north();
    69         str += "&width="+CadastrePlugin.imageWidth+"&height="+CadastrePlugin.imageHeight;
    70         //str += "&exception=application/vnd.ogc.se_inimage"; // used by normal client but not required
    71         str += "&styles="+CadastrePlugin.grabStyles;
     94        str += "&width="+width+"&height="+height;
     95        str += "&exception=application/vnd.ogc.se_inimage"; // works also without (but slower ?)
     96        str += "&styles=" + styles;
    7297        System.out.println("URL="+str);
    7398        return new URL(str.replace(" ", "%20"));
     99    }
     100
     101    private URL getURLVector(EastNorth lambertMin, EastNorth lambertMax) throws MalformedURLException {
     102        return buildURLVector(CadastrePlugin.grabLayers, CadastrePlugin.grabStyles,
     103                CadastrePlugin.imageWidth, CadastrePlugin.imageHeight,
     104                lambertMin, lambertMax);
     105    }
     106
     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);
    74113    }
    75114
Note: See TracChangeset for help on using the changeset viewer.