From: John P. <byh...@gm...> - 2011-01-12 17:21:43
|
Thanks for the help so far. I've got the two maps overlaying ok now but I have another problem. I use the GetFeatureInfo control to capture the click event and send a getfeatureinfo query to the geoserver which returns with text ok. Now I take the xy object returned and transform the coordinates to each of the layer projections to get a bounding box in each layers coordinate system to request features. That request returns with WKT data and I use the following code to turn it into feature objects reprojected into the map display projection. My problem is that the reprojection does not seem to take place, and the bounding box of the returned features remains in the layer coordinates and the data is not shown on the map. JSObject params = JSObjectHelper.createObject(); params.setProperty("request", "getfeature"); params.setProperty("service", "wfs"); params.setProperty("version", "1.0"); params.setProperty("typename", "feature1"); params.setProperty("maxFeatures", 10); params.setProperty("bbox",ProjectionUtilities.transform(bbox, mapProjection, layerProjection).toBBox(0)); MyHTTPRequestUtilities.loadFeature("http://localhost:8086/geoserver/wfs", params, new RequestCallback() { public void onSuccess(String response) { // erase any previously highlighted layers WKTOptions options = new WKTOptions(); options.setInternalProjection(new Projection(layerProjection)); options.setExternalProjection(new Projection(mapProjection)); VectorFeature[] vf = new GML().read(response, options); for (int i=0; i<vf.length; i++) { if (i==0) com.google.gwt.user.client.Window.alert("FEATURE[0]="+vf[i].getFeatureId()+", BOUNDS:"+vf[i].getGeometry().getBounds().toBBox(0)); selectedLayer.addFeature(vf[i]); } } public void onFailure(String exception) { } } Is there something I'm missing. John On Wed, Jan 12, 2011 at 9:02 AM, Edwin Commandeur <com...@gm...> wrote: > 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 >> > |