wavded / ogre

ogr2ogr geojson-focused web client
http://ogre.adc4gis.com
MIT License
266 stars 79 forks source link

Error on conversion to DXF #86

Closed GastonZalba closed 3 years ago

GastonZalba commented 4 years ago

An error occurs everytime dxf is set as the output format. The problem is that the ogr2ogr module can't create this format in stream mode using .exec() like all the other formats, you must use the .destination('file.dxf') method.

The error: "ERROR 6: Read or update mode not supported on /vsistdout\nERROR 4: Failed to open '/vsistdout/' for writing.\nERROR 1: DXF driver failed to create /vsistdout/\n

Reference

abjardim commented 3 years ago

Can somebody give me a tip on how to handle this error when using XMLHttpRequest? Below is the code I'm using. With it I'm able to open a download window with the zipped shapefile, but when I change the format to DXF I receive the error mentioned above.

    var http = new XMLHttpRequest();
    var url = "http://ogre.adc4gis.com/convertJson";
    var params = "json=" + JSON.stringify(resultAsGeojson) +
      "&skipFailures=" + true +
      "&format=" + "DXF";
    http.open("POST", url, true);

    //Send the proper header information along with the request
    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

    http.onreadystatechange = function() {//Call a function when the state changes.
      var a;
      if(http.readyState == 4 && http.status == 200) {
            a = document.createElement('a');
            a.href = window.URL.createObjectURL(http.response);
            a.download = "test-file.zip";
            a.style.display = 'none';
            document.body.appendChild(a);
            a.click()
        }
    }

    http.responseType = 'blob';
    http.send(params);

I am very new to js, so thanks in advance!

GastonZalba commented 3 years ago

The online version still has this issue unsolved, so DXF format is broken. Check this PR #87 if you want to try running your own instance.

wavded commented 3 years ago

This fix has been released, thx again @GastonZalba !

abjardim commented 3 years ago

That's great, thank you!