Comments (5)
Hi Wavded,
I try another way to create Post request like below, but it can not find the path of zip file,
var parameters ={
json:GeoJson,
outputName:"zippedshp.zip"
}
var options ={
url:"http://ogre.adc4gis.com/convertJson",
type: "POST",
data: parameters,
contentype:"application/zip",
success:function(data){
if(data){
console.log(data.path);
if(data.path) {
//Create an hidden iframe, with the 'src' attribute set to the created ZIP file.
var dlif = $('<iframe/>',{'src':data.path}).hide();
//Append the iFrame to the context
this.append(dlif);
}
else if (data.error){
alert (data.error);
}
else{
alert ("Somthing wrong");
}
}
}
}
$.ajax(options);
from ogre.
hi Waveded,
I find one solution can download the zipped shapefile through Post request , as shown below. however, the download zip file can not be used due to : Windows cannot open the folder. The compressed (zipped) Folder 'C:\Users\niuzh\Downloads\zippedshp(6).zip' is invalid.
Thanks for your comments.
var params ={
json:GeoJson,
outputName:"zippedshp.zip"
}
$.ajax({
url:'http://ogre.adc4gis.com/convertJson',
type: "POST",
data: params,
success: function(response, status, xhr) {
var filename = "zippedshp";
var type = xhr.getResponseHeader('Content-Type');
var blob = new Blob([response], { type: type });
if (typeof window.navigator.msSaveBlob !== 'undefined') {
window.navigator.msSaveBlob(blob, filename);
}
else {
var URL = window.URL || window.webkitURL;
var downloadUrl = URL.createObjectURL(blob);
//console.log(downloadUrl);
if (filename){
var a = document.createElement("a");
if (typeof a.download === 'undefined') {
window.location = downloadUrl;
}
else {
a.href = downloadUrl;
a.download = filename;
document.body.appendChild(a);
a.click();
}
}
else {
window.location = downloadUrl;
}
setTimeout(function () { URL.revokeObjectURL(downloadUrl); }, 100);
}
}
});
from ogre.
I am not up to speed on latest browser file handling but my current understanding is that you cannot trigger a download from an AJAX request. I believe you want to create a hidden form and submit that to get the download behavior.
from ogre.
Thank you so much. it is working well.
is it possible to host the similar service locally?
from ogre.
yes, the readme has instructions, there also is a Dockerfile
included in the project if you want to build it that way.
from ogre.
Related Issues (20)
- outputName param is not working HOT 1
- Issue while converting a shapefile to geojson HOT 3
- Converting from CSV: Geometry not being structured correctly HOT 2
- /convertJson returning 400 HOT 3
- DeprecationWarning: Invalid 'main' field in HOT 6
- stdout maxBuffer length exceeded HOT 3
- spawn ogr2ogr ENOENT HOT 1
- Questions about KMZ conversion and Polar Projections HOT 3
- using fetch in typescript returns {"error":true,"message":"Unexpected field"} HOT 1
- Build OGRE with latest version of GDAL/ogr2ogr to extend abilities, including support for KMZ files HOT 3
- Use ogre directly from another Script (without API) HOT 5
- Features from all layers get thrown into 1 layer HOT 2
- Random response structure in GeoJson format. HOT 1
- Convert to GeoJSON HOT 2
- Error on conversion to DXF HOT 4
- /convert endpoint broken HOT 12
- Export to DGN HOT 9
- Stdout maxbuffer length exceeded while converting to geojson HOT 3
- HTTP Post Unexpected Field HOT 2
- /convert unable to convert .zip files HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ogre.