Jesus Loves GRASS

Technical blog about GRASS/GIS,open source geoinformatics and MAPSERVER.

Tuesday, September 29, 2009

WMS/WFS getfeature on hover, problem to display the GML (mapserver)

I had a hard time programming something similar to the "WFS GetFeature Example" shown in the OpenLayers examples, the example uses calls to a WFS/WMS services that have the same name and data origin.

The WFS/WMS service call is done with the OpenLayers.Protocol.WFS.fromWMSLayer as follows (the layerWMS is a OpenLayrs.Layer.WMS object)

control = new OpenLayers.Control.GetFeature({
protocol: OpenLayers.Protocol.WFS.fromWMSLayer(layerWMS),
hover: true
});

Using firebug it is possible to see the requests going back-and-forward when hovering the polygons, but in the end the polygons aren't select, because trigger-events aren't called.

The problem is cause by the namespace used in the WFS of mapserver (since the example given in the web site uses geoserver, everything is ok), the solution is to indicate the namespace and featureTypeName.

In my mapserver response I have something like this:
<gml:featureMember>
<ms:wdpa gml:id="wdpa.67886">

Therefore control has to be changed as follows:

control = new OpenLayers.Control.GetFeature({
protocol: OpenLayers.Protocol.WFS.fromWMSLayer(layerWMS,{featureType:"wdpa",featurePrefix:"ms"}),
hover: true
});


It seems that the same has to be done for the standard WFS layer when using mapserver.

Labels: , , ,

Wednesday, April 29, 2009

Problem with Tomcat 5.5. HTTP Status 404 - The requested resource (...) is not available. (mod_jk)

Dealing with tomcat errors can be a pain in the neck.

For example a situation like this:

1) Considering that tomcat is running and apache's mod_jk is being used to connect to it.
a. Tomcat works fine when using http://mysite.com:8180/mypage
b. http://mysite.com/mypage generates a HTTP error 404 with resource not found.

2) Probably there is a miss match between the httpd.conf file and the server.xml configuration file
- ServerName, server IP or ports may be different in the 2 configuration files
- If you recompiled Apache, then you need to recompile mod_jk


If you are a newbie in tomcat (like me) this error may take some time to figure it out, since the error logs of apache are clean and the tomcat error logs don't help much

Labels: , , , ,

Tuesday, February 26, 2008

$oMap->setExtent problems and general data gathering

I made some PHP programming/MapScript for rendering a GeoTiff created by an interpolation service (WPS) as a PNG. The Geotiff is stored in the server's temporary folder and all the mapserver parameters are set by PHP programing.

The fist part of the posted code gets the image info using GdalInfo and regular expressions to obtain the extent value of the image, I haven't managed to do this properly using the PHP's Exif lib....

The major problem was the SetExtent of the Map object it was always complaining that the values had some problem, the problem was that the parameters were being passed as a string, and they needed to be as double, even if they are passed as float (or int?) the SetExtent will complain

//Some code before

$FileName=/usr/local/apache2/htdocs/tmp/interpolation3454.tiff;
$CmdStr="/usr/local/bin/gdalinfo ".$FileName;
//General string for getting float numbers
$StrPattern='/[-+]?\b[0-9]*\.?[0-9]+\b/';
exec($CmdStr,$ResultArray);

//Upper left point info
$UpperLeftPoint=$ResultArray[6];
preg_match_all($StrPattern,$UpperLeftPoint,$TmpArray);
$MinX=$TmpArray[0][0];
$MaxY=$TmpArray[0][1];

//Lower right point info
$LowerRightPoint=$ResultArray[9];
preg_match_all($StrPattern,$LowerRightPoint,$TmpArray);
$MaxX=$TmpArray[0][0];
$MinY=$TmpArray[0][1];

//Passing to Map object
//double minx, double miny, double maxx, double maxy
$oMap->setExtent((double)$MinY,(double)$MinY,(double)$MaxX,(double)$MaxY);

//Same code after

Labels: , , , , , ,

Sunday, June 10, 2007

XML parse problem with getElementsByTagName()

Today a college checked the WebGIS and she noticed the WCS request was not working. With me everything was fine but not with her, the difference is that I use Firefox while she is on IE6

So I have discovered that there is a problem parsing the XML of the describeCoverage request of the WCS.

I was using something like this to get the pixel resolution from the offsetVector information of the XML reply

var RESnode=xmldoc.getElementsByTagName("offsetVector");
var sRESX=RESnode[0].firstChild.nodeValue;
var RESX=sRESX.split(" "); //array with resx in this case the first value is the important one
var sRESY=RESnode[1].firstChild.nodeValue;
var RESY=sRESY.split(" ");

This gets the X,Y resolution of the image using FireFox

The problem is that tag offsetVector is in reality gml:offsetVector, as the specification of the WCS is to include the type of XML structure, well FireFox doesn't care about anything before the :

I have found a simple solution in this blog:
http://learningremix.net/w2007integ/jeff/2007/03/re_problem_related_to_parsing_xml.shtml

So in case the XML reply is empty I am using another tag name:

var RESnode=xmldoc.getElementsByTagName("offsetVector");
if (RESnode.length == 0) {
var RESnode = xmldoc.getElementsByTagName("gml:offsetVector");
}
var sRESX=RESnode[0].firstChild.nodeValue;
var RESX=sRESX.split(" "); //array with resx in this case the first value is the important one
var sRESY=RESnode[1].firstChild.nodeValue;
var RESY=sRESY.split(" ");

PROBLEM SOLVED !!!

Labels: , , , , ,