Changeset 20390 in osm for applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreGrabber.java
- Timestamp:
- 2010-03-09T22:02:00+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreGrabber.java
r20247 r20390 35 35 imageModified = new RasterImageModifier(img); 36 36 else 37 imageModified = new VectorImageModifier(img); 37 imageModified = new VectorImageModifier(img, false); 38 38 return new GeorefImage(imageModified.bufferedImage, lambertMin, lambertMax); 39 39 } catch (MalformedURLException e) { … … 42 42 } 43 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); 61 } catch (MalformedURLException e) { 62 throw (IOException) new IOException(tr("CadastreGrabber: Illegal url.")).initCause(e); 63 } 64 } 65 44 66 private URL getURLRaster(WMSLayer wmsLayer, EastNorth lambertMin, EastNorth lambertMax) throws MalformedURLException { 45 67 // 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 … … 49 71 str += wmsLayer.getCodeCommune(); 50 72 str += "&format=image/png"; 73 //str += "&format=image/jpeg"; 51 74 str += "&bbox="; 52 75 str += wmsLayer.eastNorth2raster(lambertMin, lambertMax); 53 //str += "&width=1000&height=800"; // maximum allowed by wms server54 76 str += "&width="+cRasterX+"&height="; // maximum allowed by wms server (576/345, 800/378, 1000/634) 55 77 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); 57 80 return new URL(str.replace(" ", "%20")); 58 81 } 59 82 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 { 61 86 String str = new String(wmsInterface.baseURL+"/scpc/wms?version=1.1&request=GetMap"); 62 str += "&layers="+ CadastrePlugin.grabLayers;87 str += "&layers="+ layers; 63 88 str += "&format=image/png"; 64 89 //str += "&format=image/jpeg"; … … 67 92 str += lambertMax.east() + ","; 68 93 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 required71 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; 72 97 System.out.println("URL="+str); 73 98 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); 74 113 } 75 114
Note:
See TracChangeset
for help on using the changeset viewer.