Jesus Loves GRASS

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

Tuesday, June 12, 2007

IE header problem in Ka Map print_map.php

I was thinking that everything was ok with the printing system, but yesterday I was with my supervisors and he used Internet Explorer, when he tried to download and image file with the screen content of Ka-maps, the IE said:
"Internet Explorer cannot download...cale12000000&output_type=JPEG"

"Internet Explorer was not able to open this Internet site"

Since I saw the & and some GET like structure I thought it was some PHP error....

The problem is in the header creation of the print_map.php, which works fine for Firefox but it has some problems with IE.

I have searched on the PHP tutorial help and read several things and so far the best header is something like this:


$mm_type="image".strtolower($_REQUEST['output_type']);
$filename_ext=$oMap->name . ".".strtolower($_REQUEST['output_type']);
header("Cache-Control: public, must-revalidate\n");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT\n");
header('Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT'.'\n');
header("Cache-Control: no-store, no-cache, must-revalidate\n");
header("Cache-Control: post-check=0, pre-check=0\n", false );
header("Pragma: Internet Explorer is shitty\n"); //Otherwise it will give error
header("Content-Type: " . $mm_type."\n");
header("Content-Length: " .(string)(filesize($szImg))."\n");
header('Content-Disposition: attachment; filename='.$filename_ext."\n");
header("Content-Transfer-Encoding: binary\n");
fpassthru($h);
fclose($h);

-The headers for what I read are prepared for non-cache in HTTP 1.0 and 1.1
-Without the Pragma: (something), IE will give the same error, I haven't found why, but is what people do
- The \n is seems to be necessary for IE7 that needs a more tight header (but I haven't checked if it's true)

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: , , , , ,

Monday, June 04, 2007

Mapserver Versus Google Earth

Thinking of using google earth as a WMS layer in your mapserver project ??! Then think again !!!

Gregor Mosheh
Reply-To: Gregor Mosheh
Date: Thu, 1 Mar 2007 10:17:58 -0700
Content-Type: text/plain

There's no way to use Google Maps in Mapserver, due to Google's terms of
use. Some folks wrote a WMS gateway to Google Maps, for example, and got a
cease-and-desist for it.

There are other options, though, if you're willing/able to serve up your
Mapserver output via WMS. A) You could use Mapserver's WMS output in a
Google Map, because Google doesn't have a problem with that. B) Look for a
framework that supports both WMS and Google Maps and use that to import
both your WMS output and Google's basemap; I know that OpenLayers had
Google Maps support on their drawing board, but I don't know the status of
it.


Source: Mapserver Mailing List

Labels: , ,