From: Edwin C. <com...@gm...> - 2011-01-12 14:02:54
|
Hi John, For transforming vector data you will have to include proj4js. The OpenLayers transform methods are adapters to proj4js functionality. For reprojecting raster layers, or at least WMS layers, there is no standard functionality. On one project I worked on we had a Control to switch projections and others have also put this in a custom control: http://dev.bnhelp.cz/trac/hslayers/browser/trunk/source/HSLayers/Control/ProjectionSwitcher.js?rev=4246 You can also check the OL sandboxes if people have worked on this: http://dev.openlayers.org/sandbox/ Greetings, Edwin On 11 January 2011 21:09, John Preston <byh...@gm...> wrote: > 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 > > ------------------------------------------------------------------------------ > Protect Your Site and Customers from Malware Attacks > Learn about various malware tactics and how to avoid them. Understand > malware threats, the impact they can have on your business, and how you > can protect your company and customers by using code signing. > http://p.sf.net/sfu/oracle-sfdevnl > _______________________________________________ > Gwt-openlayers-users mailing list > Gwt...@li... > https://lists.sourceforge.net/lists/listinfo/gwt-openlayers-users > |