From: John P. <byh...@gm...> - 2011-01-11 20:09:59
|
I have a problem getting reprojection of wms layer maps working and I would apprciate if someone could tell me what I'm doing wrong. I have two maps in two different projections and I would like to overlay them. I use the following code to do this. ////////////////////////////////////////////////////////////////////////////////////////// MapOptions mapOptions = new MapOptions(); mapOptions.setNumZoomLevels(10); mapOptions.setProjection("EPSG:3448"); mapOptions.setDisplayProjection(new Projection("EPSG:3448")); mapOptions.setUnits("m"); mapOptions.setMaxExtent(new Bounds(100000, 100000, 900000, 700000)); mapOptions.setAllOverlays(true); mapOptions.setMaxResolutionToAuto(); mapWidget = new MapWidget("100%", "100%", mapOptions); add(mapWidget, new BorderLayoutData(LayoutRegion.CENTER)); Map map = mapWidget.getMap(); // Defining a WMS and adding it to the map WMSParams wmsParams = new WMSParams(); wmsParams.setFormat("image/png"); wmsParams.setLayers("area1"); wmsParams.setIsTransparent(true); wmsParams.setStyles(""); WMSOptions wmsLayerParams = new WMSOptions(); wmsLayerParams.setBuffer(0); wmsLayerParams.setSingleTile(false); wmsLayerParams.setMaxExtent(new Bounds(100000, 100000, 300000, 200000)); wmsLayerParams.setProjection("EPSG:24200"); WMS wmsLayer = new WMS("First map on old projection", "http://localhost:8086/geoserver/wms", wmsParams, wmsLayerParams); // Add layer to open layers map map.addLayer(wmsLayer); // Defining a WMS and adding it to the map wmsParams = new WMSParams(); wmsParams.setFormat("image/png"); wmsParams.setLayers("area2"); wmsParams.setIsTransparent(true); wmsParams.setStyles(""); wmsLayerParams = new WMSOptions(); wmsLayerParams.setBuffer(0); wmsLayerParams.setSingleTile(false); wmsLayerParams.setMaxExtent(new Bounds(500000, 500000, 800000, 700000)); wmsLayerParams.setProjection("EPSG:24200"); WMS wmsLayer = new WMS("Second map in new projection", "http://localhost:8086/geoserver/wms", wmsParams, wmsLayerParams); // Add layer to open layers map map.addLayer(wmsLayer); map.setCenter(new LonLat(400000, 400000)); ////////////////////////////////////////////////////////////////////////////////////////// The two maps hold data for adjacent areas but they are in different projections. I want to be able to set the map display projection to one of the projections, EPSG:3448 for instance, and re-project (on the fly) the other map so I can overlay them. Hence I set the map display projection to EPSG:3448, and when I am creating the wms layer I set the srs of the request to the display projection. However I get an empty map if I do this. When I set the projection of the wms request to the projection of the data it contains then I get the map but it has not been reprojected. I've searched for a simple reprojection example to try and follow but I can't find any. I've also noticed that if I try to tranform coordinates from one projection to another I get no change. When I try the following code the coordinates of the lonlat object remain the same instead of them being offset by about 500000 for the x and y values. LonLat pt = new LonLat(250000, 140000); pt.transform("EPSG:3448", "EPSG:24200"); Do I need to include some extra javascripts to get the projection working. Can anyone help me. John |