[OpenLayers-Users] WFS popup alignment

Joanne Cook j.cook at oxfordarch.co.uk
Mon Dec 8 12:55:36 EST 2008


Hi All,

In one way, I've made progress with this, but in another I've taken a step backwards. I got my layers to both successfully overlay on the metacarta vmap0 layer (avoiding the whole spherical mercator issue) and everything worked fine. However, when I try and bite the bullet and go for overlaying on a spherical mercator layer, only the wms layer displays (correctly). 

What I have done:
Add EPSG:900913 to the epsg file for proj4 to use. Add it as both a wms_srs and wfs_srs in both the layer and web components of my mapfile. Add the appropriate projection parameters to my openlayers page. Looking at the url being passed to mapserver using httpfox, this is the url that openlayers is passing: 

http://10.0.10.106/cgi-bin/mapservpostgis.cgi?typename=ms%3Aoasites&maxfeatures=200&featureNS=http%3A%2F%2Fmapserver.gis.umn.edu%2Fmapserver&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&SRS=EPSG%3A900913&BBOX=-367512.1319292969,7119551.287262592,-40973.14715351557,7337549.691892866

and this is the result in httpfox:

<?xml version='1.0' encoding="ISO-8859-1" ?>
<wfs:FeatureCollection
   xmlns:ms="http://mapserver.gis.umn.edu/mapserver"
   xmlns:wfs="http://www.opengis.net/wfs"
   xmlns:gml="http://www.opengis.net/gml"
   xmlns:ogc="http://www.opengis.net/ogc"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd 
                       http://mapserver.gis.umn.edu/mapserver http://10.0.10.106/cgi-bin/mapserv?map=/var/www/OS_Coverage/OANSitespostgis.map&amp;SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=ms:oasites&amp;OUTPUTFORMAT=XMLSCHEMA">
   <gml:boundedBy>
      <gml:null>missing</gml:null>
   </gml:boundedBy>
</wfs:FeatureCollection>

So, I think I must be missing something very basic here. Do I need to add a second geometry column with EPSG:900913 to my postgres table and have everything in the map file just working in that projection, or should mapserver be able to reproject for me? I'd very much appreciate some assistance if possible!

Thanks

Jo

-----------------------------------------------------
Joanne Cook
Senior IT Support and Development
Oxford Archaeology (North)
01524 880212
http://thehumanjourney.net

----- Original Message -----
From: "Joanne Cook" <j.cook at oxfordarch.co.uk>
To: "Andrew Parker" <andrew at source3.com>
Cc: users at openlayers.org
Sent: Friday, 5 December, 2008 17:22:58 GMT +00:00 GMT Britain, Ireland, Portugal
Subject: Re: [OpenLayers-Users] WFS popup alignment

Hi Andrew,

I did eventually figure out that it was the "spherical mercator" problem, again, though I was/am confused as to why the popup would be placed correctly yet the feature it was derived from was not!

Unfortuntely, it's not always possible to get enough access to alter the epsg file and add 900913 support for mapserver. For example, you may have access to only the web folders on a server (from personal experience). In those cases, you have to find a different solution to the problem, although of course you can use different background imagery and eschew the commercial layers...

Thanks again

Jo

-----------------------------------------------------
Joanne Cook
Senior IT Support and Development
Oxford Archaeology (North)
01524 880212
http://thehumanjourney.net

----- Original Message -----
From: "Andrew Parker" <andrew at source3.com>
To: users at openlayers.org
Sent: Thursday, 4 December, 2008 15:32:08 GMT +00:00 GMT Britain, Ireland, Portugal
Subject: Re: [OpenLayers-Users] WFS popup alignment


Hello Joanne: 

I am headed out of the office but wanted to give you something to consider....have you read: http://docs.openlayers.org/spherical_mercator/ which discusses projection issues using google, yahoo, ve, etc with user created layers. 

Also, I am working on projection issues as well. I started a post which discusses projection issues which may help you with yours. If you go to my layer intialization script ( http://webmap.rthicksconsult.com/c2corgCreateMap_projection.js ) you will see how I had to add {'shericalMercator':true}. As an example 

gsatellite = new OpenLayers.Layer.Google("Google Satellite", {type:G_HYBRID_MAP, 'sphericalMercator': true, buffer:0} );
	map.addLayer (gsatellite); 
My thread is at http://www.nabble.com/Cannot-display-search-marker-when-projecting-layers-to-EPSG-900913-td20771840.html#a20771840 . 


Hope this will give some insight to your issue. 


Andrew Parker 
Joanne Cook wrote: 

Hi List,

I have both WMS and WFS layers from a postgres table (starting with WMS but moving to WFS as you zoom in), on top of Microsoft Virtua Earth. You click the WFS points and get a framedcloud popup of the feature attribute data. This aspect works fine, but there is an issue with the alignment of the WFS points. There are some zoom levels where I can see that the WFS layer does not align correctly with the WMS, this is worse at the bottom of the map square and better towards the top. Not only that, the anchor for the popup aligns correctly with the WMS rather than the WFS. So you click on a point and the popup appears next to the correct location rather than where you have clicked.

I assume this is something to do with projections, but I'm a little stuck and would appreciate some assistance. I can't show the map itself because it isn't available to the outside world, but the salient bits of the code are here:

 var map, ve, wms, wfs, drawControls, selectControl, selectedFeature;
        function onPopupClose(evt) {
            selectControl.unselect(selectedFeature);
        }
        function onFeatureSelect(feature) {
          selectedFeature = feature;
			var projcode = selectedFeature.attributes['projcode'];
			var sitecode = selectedFeature.attributes['sitecode'];
			var projnam = selectedFeature.attributes['projnam'];
			var year = selectedFeature.attributes['year'];
            popup = new OpenLayers.Popup.FramedCloud("info", 
                                     feature.geometry.getBounds().getCenterLonLat(),
                                     null,
                                     "<div style='font-size:.8em'>Project Code: " + projcode +"<br />Site Code: " + sitecode+"<br />Project Name: " + projnam + "<br />Year: " + year + "</div>",
                                     null, true, onPopupClose);
            feature.popup = popup;
            map.addPopup(popup);
        }
        function onFeatureUnselect(feature) {
            map.removePopup(feature.popup);
            feature.popup.destroy();
            feature.popup = null;
        }    
        function init(){
            map = new OpenLayers.Map('map');
            ve = new OpenLayers.Layer.VirtualEarth( "Virtual Earth",{'type': VEMapStyle.Hybrid});
            wms = new OpenLayers.Layer.WMS("OA Sites WMS", "http://10.0.10.106/cgi-bin/mapservpostgis.cgi?" ,
                               {layers: 'oasites', transparent: true, format: 'image/png', buffer:0},
                                {isBaseLayer: false, reproject: true},
                                {scales: [14000000,500000]});
            wfs = new OpenLayers.Layer.WFS("OA Sites WFS", "http://10.0.10.106/cgi-bin/mapservpostgis.cgi?" ,
                                {typename: 'oasites', maxfeatures: 200, featureNS: ' http://mapserver.gis.umn.edu/mapserver ', typename: 'ms:oasites'},
                                {scales: [500000, 10], extractAttributes: true},
                                {style: OpenLayers.Util.extend({},OpenLayers.Feature.Vector.style['default'])});


Thanks

Jo

-----------------------------------------------------
Joanne Cook
Senior IT Support and Development
Oxford Archaeology (North)
01524 880212 http://thehumanjourney.net ------
Files attached to this email may be in ISO 26300 format (OASIS Open Document Format). If you have difficulty opening them, please visit http://iso26300.info for more information.

_______________________________________________
Users mailing list Users at openlayers.org http://openlayers.org/mailman/listinfo/users 
_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users


------
Files attached to this email may be in ISO 26300 format (OASIS Open Document Format). If you have difficulty opening them, please visit http://iso26300.info for more information.




More information about the Users mailing list