1

I am developing browser application using MapServer and JavaScript. I've got part where on map click I get FeatureInfo about an object:

function getFeatureInfoGML(map){
    var openwindowhandle=window.open('', "openwindow")
    if (openwindowhandle){ openwindowhandle.close()}
    map.on('singleclick', function(evt) {
    var viewResolution = /** @type {number} */ (view.getResolution());
    var url = immovableSource.getGetFeatureInfoUrl(
        evt.coordinate, viewResolution, 'EPSG:4326',
        {'INFO_FORMAT': 'gml'});

    if (url) {
                infoWindow=window.open(url, "openwindow", "width=500,height=600");
            }                   
    });

}

where

    immovableSource = new ol.source.ImageWMS({
        url: 'http://localhost:8000/cgi-bin/mapserv.exe?map=c:/ms4w/project/info.map',
        params: {'LAYERS': 'immovable'},
        ratio: 1,
        serverType: 'mapserver'
        }),

in my map file my output format is:

OUTPUTFORMAT
    NAME "OGRGML"
    DRIVER "OGR/GML"
    MIMETYPE "text/xml; subtype=gml/2.1.2; driver=ogr"
    FORMATOPTION "STORAGE=memory"
    FORMATOPTION "FORM=multipart"
    FORMATOPTION "FILENAME=rezult.gml"
END

When I click on the map a file is downloaded with name "mapserv.exe", but I want it to be *.gml. When I open mapserv.exe it's a GML file, I just want to change the name of the downloaded file.

  • Your title and body ask different questions (the title being extremely difficult). Don't you just want to change the name of the downloaded file? This very nearly a plain vanilla JavaScript issue (part of the download request). – Vince May 9 at 10:40
  • @Vince, I really don't know how to fix it and where the problem is. I accept your remark about the title and the body - my fault – BananaGrape May 9 at 11:06
  • You have to add a Content-Disposition header to the HTTP response. I don't see a MapServer option; you might need to override this in the web server. – CL. May 10 at 7:49
0

If you want a downloaded file called result.gml from a WFS request for a GML output the following works:

OUTPUTFORMAT
    NAME "OGRGML"
    DRIVER "OGR/GML"
    MIMETYPE "text/xml; subtype=gml/2.1.2; driver=ogr"
    FORMATOPTION "STORAGE=filesystem"
    FORMATOPTION "FORM=multipart"
    FORMATOPTION "FILENAME=result.gml"
END

and in your service WEB > METADATA

WEB
    ...
    METADATA
        "WFS_GETFEATURE_FORMATLIST" "CSVSTREAM,JSON,MIDMIF,SHAPEZIP,OGRGML"
        ...
    END

and a request like:

http://xxx/ows?service=WFS&request=GetFeature&version=2.0.0&typenames=ENERGY_STATUS_2016&srsName=EPSG:4326&bbox=2.3319787109375003,32.20465253906251,3.4415978515625003,33.31427167968751,EPSG:4326&outputformat=OGRGML&

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.