{"action":"created","issue":{"url":"https://api.github.com/repos/wavded/ogre/issues/41","labels_url":"https://api.github.com/repos/wavded/ogre/issues/41/labels{/name}","comments_url":"https://api.github.com/repos/wavded/ogre/issues/41/comments","events_url":"https://api.github.com/repos/wavded/ogre/issues/41/events","html_url":"https://github.com/wavded/ogre/issues/41","id":90133076,"number":41,"title":"how to use Post to download zip shapefile itself? ","user":{"login":"zhengniu","id":3997203,"avatar_url":"https://avatars.githubusercontent.com/u/3997203?v=3","gravatar_id":"","url":"https://api.github.com/users/zhengniu","html_url":"https://github.com/zhengniu","followers_url":"https://api.github.com/users/zhengniu/followers","following_url":"https://api.github.com/users/zhengniu/following{/other_user}","gists_url":"https://api.github.com/users/zhengniu/gists{/gist_id}","starred_url":"https://api.github.com/users/zhengniu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhengniu/subscriptions","organizations_url":"https://api.github.com/users/zhengniu/orgs","repos_url":"https://api.github.com/users/zhengniu/repos","events_url":"https://api.github.com/users/zhengniu/events{/privacy}","received_events_url":"https://api.github.com/users/zhengniu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"wavded","id":26638,"avatar_url":"https://avatars.githubusercontent.com/u/26638?v=3","gravatar_id":"","url":"https://api.github.com/users/wavded","html_url":"https://github.com/wavded","followers_url":"https://api.github.com/users/wavded/followers","following_url":"https://api.github.com/users/wavded/following{/other_user}","gists_url":"https://api.github.com/users/wavded/gists{/gist_id}","starred_url":"https://api.github.com/users/wavded/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wavded/subscriptions","organizations_url":"https://api.github.com/users/wavded/orgs","repos_url":"https://api.github.com/users/wavded/repos","events_url":"https://api.github.com/users/wavded/events{/privacy}","received_events_url":"https://api.github.com/users/wavded/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2015-06-22T15:30:52Z","updated_at":"2015-06-23T19:22:55Z","closed_at":null,"body":"Thanks for sharing this great tool\r\n\r\nI have tried to use Post request in my code to get zipped file download through web client, but no clue how to do it in callback function to fullfil the same ability as the convert button \"Convert to Shapefile\" does.\r\n\r\nCould you please provide newbies some help? Many Thanks \r\n\r\n\r\n\r\n\r\n\r\n<script src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js\"></script>\r\n\r\n\r\n\r\n\t\r\n\tvar objectcol={\"displayFieldName\":\"\",\"geometryType\":\"esriGeometryPolygon\",\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857},\"fields\":[{\"name\":\"OID\",\"type\":\"esriFieldTypeOID\",\"alias\":\"OID\"},{\"name\":\"Name\",\"type\":\"esriFieldTypeString\",\"alias\":\"Name\",\"length\":60},{\"name\":\"BUFF_DIST\",\"type\":\"esriFieldTypeDouble\",\"alias\":\"BUFF_DIST\"},{\"name\":\"SUM_CLIPPOP\",\"type\":\"esriFieldTypeInteger\",\"alias\":\"SUM_CLIPPOP\"},{\"name\":\"SUM_CLIPEMP\",\"type\":\"esriFieldTypeInteger\",\"alias\":\"SUM_CLIPEMP\"},{\"name\":\"Shape_Length\",\"type\":\"esriFieldTypeDouble\",\"alias\":\"Shape_Length\"},{\"name\":\"Shape_Area\",\"type\":\"esriFieldTypeDouble\",\"alias\":\"Shape_Area\"}],\"features\":[{\"geometry\":{\"type\":\"polygon\",\"rings\":[[[-8841308.9388,5412113.0163],[-8841274.2092,5412109.977899998],[-8841240.5348,5412100.954800002],[-8841208.9388,5412086.2214],[-8841180.3813,5412066.225199997],[-8841155.7299,5412041.573799998],[-8841135.7337,5412013.0163],[-8841121.0003,5411981.420299999],[-8841111.9772,5411947.745899998],[-8841108.9388,5411913.0163],[-8841111.9772,5411878.286700003],[-8841121.0003,5411844.612300001],[-8841135.7337,5411813.0163],[-8841155.7299,5411784.458800003],[-8841180.3813,5411759.807400003],[-8841208.9388,5411739.8112],[-8841240.5348,5411725.077799998],[-8841274.2092,5411716.054700002],[-8841308.9388,5411713.0163],[-8841343.6684,5411716.054700002],[-8841377.3428,5411725.077799998],[-8841408.9388,5411739.8112],[-8841437.4963,5411759.807400003],[-8841462.1477,5411784.458800003],[-8841482.1439,5411813.0163],[-8841496.8773,5411844.612300001],[-8841505.9004,5411878.286700003],[-8841508.9388,5411913.0163],[-8841505.9004,5411947.745899998],[-8841496.8773,5411981.420299999],[-8841482.1439,5412013.0163],[-8841462.1477,5412041.573799998],[-8841437.4963,5412066.225199997],[-8841408.9388,5412086.2214],[-8841377.3428,5412100.954800002],[-8841343.6684,5412109.977899998],[-8841308.9388,5412113.0163]]],\"_ring\":0,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}},\"attributes\":{\"OID\":1,\"Name\":null,\"BUFF_DIST\":200,\"SUM_CLIPPOP\":2,\"SUM_CLIPEMP\":null,\"Shape_Length\":1255.0427251988326,\"Shape_Area\":125026.69382391222}},{\"geometry\":{\"type\":\"polygon\",\"rings\":[[[-8840769.1023,5412624.188900001],[-8840734.3727,5412621.1504999995],[-8840700.6983,5412612.127400003],[-8840669.1023,5412597.394000001],[-8840640.5448,5412577.3977999985],[-8840615.8934,5412552.746399999],[-8840595.8972,5412524.188900001],[-8840581.1638,5412492.5929000005],[-8840572.1407,5412458.918499999],[-8840569.1023,5412424.188900001],[-8840572.1407,5412389.4592999965],[-8840581.1638,5412355.784900002],[-8840595.8972,5412324.188900001],[-8840615.8934,5412295.631399997],[-8840640.5448,5412270.979999997],[-8840669.1023,5412250.983800001],[-8840700.6983,5412236.250399999],[-8840734.3727,5412227.227300003],[-8840769.1023,5412224.188900001],[-8840803.8319,5412227.227300003],[-8840837.5063,5412236.250399999],[-8840869.1023,5412250.983800001],[-8840897.6598,5412270.979999997],[-8840922.3112,5412295.631399997],[-8840942.3074,5412324.188900001],[-8840957.0408,5412355.784900002],[-8840966.0639,5412389.4592999965],[-8840969.1023,5412424.188900001],[-8840966.0639,5412458.918499999],[-8840957.0408,5412492.5929000005],[-8840942.3074,5412524.188900001],[-8840922.3112,5412552.746399999],[-8840897.6598,5412577.3977999985],[-8840869.1023,5412597.394000001],[-8840837.5063,5412612.127400003],[-8840803.8319,5412621.1504999995],[-8840769.1023,5412624.188900001]]],\"_ring\":0,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}},\"attributes\":{\"OID\":2,\"Name\":null,\"BUFF_DIST\":200,\"SUM_CLIPPOP\":401,\"SUM_CLIPEMP\":103,\"Shape_Length\":1255.0427252029426,\"Shape_Area\":125026.69382473118}},{\"geometry\":{\"type\":\"polygon\",\"rings\":[[[-8840644.8921,5411926.700999998],[-8840610.1625,5411923.662600003],[-8840576.4881,5411914.6395],[-8840544.8921,5411899.906099997],[-8840516.3346,5411879.909900002],[-8840491.6832,5411855.258500002],[-8840471.687,5411826.700999998],[-8840456.9536,5411795.104999997],[-8840447.9305,5411761.430600002],[-8840444.8921,5411726.700999998],[-8840447.9305,5411691.9714],[-8840456.9536,5411658.296999998],[-8840471.687,5411626.700999998],[-8840491.6832,5411598.1435],[-8840516.3346,5411573.4921],[-8840544.8921,5411553.495899998],[-8840576.4881,5411538.762500003],[-8840610.1625,5411529.739399999],[-8840644.8921,5411526.700999998],[-8840679.6217,5411529.739399999],[-8840713.2961,5411538.762500003],[-8840744.8921,5411553.495899998],[-8840773.4496,5411573.4921],[-8840798.101,5411598.1435],[-8840818.0972,5411626.700999998],[-8840832.8306,5411658.296999998],[-8840841.8537,5411691.9714],[-8840844.8921,5411726.700999998],[-8840841.8537,5411761.430600002],[-8840832.8306,5411795.104999997],[-8840818.0972,5411826.700999998],[-8840798.101,5411855.258500002],[-8840773.4496,5411879.909900002],[-8840744.8921,5411899.906099997],[-8840713.2961,5411914.6395],[-8840679.6217,5411923.662600003],[-8840644.8921,5411926.700999998]]],\"_ring\":0,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}},\"attributes\":{\"OID\":3,\"Name\":null,\"BUFF_DIST\":200,\"SUM_CLIPPOP\":200,\"SUM_CLIPEMP\":65,\"Shape_Length\":1255.04272520306,\"Shape_Area\":125026.69382475453}},{\"geometry\":{\"type\":\"polygon\",\"rings\":[[[-8838528.5419,5411850.263999999],[-8838493.8123,5411847.225599997],[-8838460.1379,5411838.202500001],[-8838428.5419,5411823.4690999985],[-8838399.9844,5411803.472900003],[-8838375.333,5411778.821500003],[-8838355.3368,5411750.263999999],[-8838340.6034,5411718.667999998],[-8838331.5803,5411684.993600003],[-8838328.5419,5411650.263999999],[-8838331.5803,5411615.534400001],[-8838340.6034,5411581.859999999],[-8838355.3368,5411550.263999999],[-8838375.333,5411521.706500001],[-8838399.9844,5411497.055100001],[-8838428.5419,5411477.058899999],[-8838460.1379,5411462.325499997],[-8838493.8123,5411453.3024],[-8838528.5419,5411450.263999999],[-8838563.2715,5411453.3024],[-8838596.9459,5411462.325499997],[-8838628.5419,5411477.058899999],[-8838657.0994,5411497.055100001],[-8838681.7508,5411521.706500001],[-8838701.747,5411550.263999999],[-8838716.4804,5411581.859999999],[-8838725.5035,5411615.534400001],[-8838728.5419,5411650.263999999],[-8838725.5035,5411684.993600003],[-8838716.4804,5411718.667999998],[-8838701.747,5411750.263999999],[-8838681.7508,5411778.821500003],[-8838657.0994,5411803.472900003],[-8838628.5419,5411823.4690999985],[-8838596.9459,5411838.202500001],[-8838563.2715,5411847.225599997],[-8838528.5419,5411850.263999999]]],\"_ring\":0,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}},\"attributes\":{\"OID\":4,\"Name\":null,\"BUFF_DIST\":200,\"SUM_CLIPPOP\":22,\"SUM_CLIPEMP\":37,\"Shape_Length\":1255.0427252029426,\"Shape_Area\":125026.69382473118}},{\"geometry\":{\"type\":\"polygon\",\"rings\":[[[-8840687.888,5411573.179799996],[-8840653.1584,5411570.141400002],[-8840619.484,5411561.118299998],[-8840587.888,5411546.384900004],[-8840559.3305,5411526.388700001],[-8840534.6791,5411501.737300001],[-8840514.6829,5411473.179799996],[-8840499.9495,5411441.583800003],[-8840490.9264,5411407.909400001],[-8840487.888,5411373.179799996],[-8840490.9264,5411338.450199999],[-8840499.9495,5411304.775799997],[-8840514.6829,5411273.179799996],[-8840534.6791,5411244.622299999],[-8840559.3305,5411219.970899999],[-8840587.888,5411199.974699996],[-8840619.484,5411185.241300002],[-8840653.1584,5411176.218199998],[-8840687.888,5411173.179799996],[-8840722.6176,5411176.218199998],[-8840756.292,5411185.241300002],[-8840787.888,5411199.974699996],[-8840816.4455,5411219.970899999],[-8840841.0969,5411244.622299999],[-8840861.0931,5411273.179799996],[-8840875.8265,5411304.775799997],[-8840884.8496,5411338.450199999],[-8840887.888,5411373.179799996],[-8840884.8496,5411407.909400001],[-8840875.8265,5411441.583800003],[-8840861.0931,5411473.179799996],[-8840841.0969,5411501.737300001],[-8840816.4455,5411526.388700001],[-8840787.888,5411546.384900004],[-8840756.292,5411561.118299998],[-8840722.6176,5411570.141400002],[-8840687.888,5411573.179799996]]],\"_ring\":0,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}},\"attributes\":{\"OID\":5,\"Name\":null,\"BUFF_DIST\":200,\"SUM_CLIPPOP\":183,\"SUM_CLIPEMP\":59,\"Shape_Length\":1255.0427252061977,\"Shape_Area\":125026.69382537971}}],\"exceededTransferLimit\":false} ;\r\n\r\n\tfunction Esri2geo(data){\r\n\t\tconsole.log(\"json converted to object\");\r\n\t\tconsole.log(\"begin parsing json\");\r\n\t\tvar geomType,\r\n\t\toriginCRS={\r\n\t\t\t\"type\": \"EPSG\",\r\n\t\t\t\"properties\": {\r\n\t\t\t\t\"code\": 3857\r\n\t\t\t}\r\n\t\t};\r\n\t\tfunction parseGeometryType(type){\r\n\t\t\tif (type === \"esriGeometryPoint\"){\r\n\t\t\t\treturn \"Point\";\r\n\t\t\t}\r\n\t\t\telse if (type === \"esriGeometryMultipoint\") {\r\n\t\t\t\treturn \"MultiPoint\";\r\n\t\t\t}\r\n\t\t\telse if (type === \"esriGeometryPolyline\") {\r\n\t\t\t\treturn \"LineString\";\r\n\t\t\t} \r\n\t\t\telse if (type === \"esriGeometryPolygon\") {\r\n\t\t\t\treturn \"Polygon\";\r\n\t\t\t}\r\n\t\t\telse{\r\n\t\t\t\treturn \"Empty\";\r\n\t\t\t}\r\n\t\t\t\r\n\t\t}\r\n\t\tfunction featureToGeo (feature_in,geomType){\r\n\t\t\tvar geometry = {};\r\n\t\t\tgeometry.type = geomType;\r\n\t\t\t// grab the rings to coordinates\r\n\t\t\tvar geom = feature_in.geometry;\r\n\t\t\tvar coordinates;\r\n\t\t\tif (geomType === \"Polygon\") {\r\n\t\t\t\tcoordinates = geom.rings;\r\n\t\t\t} else if (geomType === \"LineString\") {\r\n\t\t\t\tcoordinates = geom.paths;\r\n\t\t\t} else if (geomType === \"Point\") {\r\n\t\t\t\tcoordinates = [geom.x, geom.y];\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tgeometry.coordinates = coordinates;\t\t\r\n\t\t\t// convert attributes to properties\r\n\t\t\tvar properties = {};\r\n\t\t\tvar attr = feature_in.attributes;\r\n\t\t\tfor (var field in attr) {\r\n\t\t\t\tproperties[field] = attr[field];\r\n\t\t\t}\t\t\r\n\t\t\tvar feature_out = {};\r\n\t\t\tfeature_out.type = \"Feature\";\r\n\t\t\tfeature_out.geometry = geometry;\r\n\t\t\tfeature_out.properties = properties;\r\n\t\t\treturn feature_out;\r\n\t\t}\r\n\t\tvar result;\r\n\t\t\r\n\t\tgeomType=parseGeometryType(data.geometryType);\r\n\t\tconsole.log(geomType);\r\n\t\tconsole.log(data.features);\r\n\t\tvar features = [];\r\n\t\tfor (var i = 0, feature = {}; feature = data.features[i]; i++) {\r\n\t\t\t// prepare the main parts of the GeoJSON\r\n\t\t\tvar feat = featureToGeo(feature, geomType);\r\n\t\t\tfeatures.push(feat);\r\n\t\t}\r\n\t\tvar featColl = {};\r\n\t\tfeatColl.type = \"FeatureCollection\";\r\n\t\tfeatColl.crs= originCRS;\r\n\t\tfeatColl.features = features;\r\n\t\tresult = JSON.stringify(featColl, function(key, value) {\r\n\t\t\tif (typeof value === 'number' && !isFinite(value)){\r\n\t\t\t\treturn String(value);\r\n\t\t\t}\r\n\t\t\treturn value;\r\n\t\t});\r\n\t\tconsole.log(\"json parsed, return it\");\r\n\t\t//console.log(result);\r\n\t\treturn result;\r\n\t}\r\n\t//var data= objectcol;\r\n\tvar GeoJson=Esri2geo(objectcol);\r\n\t//console.log(typeof(GeoJson));\r\n\tconsole.log(GeoJson);\r\n\t$.post(\"http://ogre.adc4gis.com/convertJson\",\r\n\t\t{json:GeoJson, \r\n\t\toutputName:\"zippedshp\"\r\n\t\t},\r\n\t\tfunction(result){\r\n\t\t\tconsole.info(result);\r\n\r\n\t\t});\r\n\t\r\n\r\n\t\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/wavded/ogre/issues/comments/114615858","html_url":"https://github.com/wavded/ogre/issues/41#issuecomment-114615858","issue_url":"https://api.github.com/repos/wavded/ogre/issues/41","id":114615858,"user":{"login":"zhengniu","id":3997203,"avatar_url":"https://avatars.githubusercontent.com/u/3997203?v=3","gravatar_id":"","url":"https://api.github.com/users/zhengniu","html_url":"https://github.com/zhengniu","followers_url":"https://api.github.com/users/zhengniu/followers","following_url":"https://api.github.com/users/zhengniu/following{/other_user}","gists_url":"https://api.github.com/users/zhengniu/gists{/gist_id}","starred_url":"https://api.github.com/users/zhengniu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhengniu/subscriptions","organizations_url":"https://api.github.com/users/zhengniu/orgs","repos_url":"https://api.github.com/users/zhengniu/repos","events_url":"https://api.github.com/users/zhengniu/events{/privacy}","received_events_url":"https://api.github.com/users/zhengniu/received_events","type":"User","site_admin":false},"created_at":"2015-06-23T19:22:55Z","updated_at":"2015-06-23T19:22:55Z","body":"hi Waveded, \r\n\r\nI 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. \r\n\r\nThanks for your comments.\r\n\r\n\r\n\tvar params ={\r\n\t\tjson:GeoJson, \r\n\t\toutputName:\"zippedshp.zip\"\r\n\t}\r\n\r\n\t$.ajax({\r\n\t\turl:'http://ogre.adc4gis.com/convertJson',\r\n\t\ttype: \"POST\",\r\n\t\tdata: params,\r\n\t\tsuccess: function(response, status, xhr) {\r\n\t\t\tvar filename = \"zippedshp\";\r\n\t\t\tvar type = xhr.getResponseHeader('Content-Type');\r\n\t\t\tvar blob = new Blob([response], { type: type });\r\n\t\t\t\r\n\t\t\tif (typeof window.navigator.msSaveBlob !== 'undefined') {\r\n\t\t\t\twindow.navigator.msSaveBlob(blob, filename);\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tvar URL = window.URL || window.webkitURL;\r\n\t\t\t\tvar downloadUrl = URL.createObjectURL(blob);\r\n\t\t\t\t//console.log(downloadUrl);\r\n\t\t\t\tif (filename){\r\n\t\t\t\t\tvar a = document.createElement(\"a\");\r\n\t\t\t\t\tif (typeof a.download === 'undefined') {\r\n\t\t\t\t\t\twindow.location = downloadUrl;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse {\r\n\t\t\t\t\t\ta.href = downloadUrl;\r\n\t\t\t\t\t\ta.download = filename;\r\n\t\t\t\t\t\tdocument.body.appendChild(a);\r\n\t\t\t\t\t\ta.click();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse {\r\n\t\t\t\t\twindow.location = downloadUrl;\r\n\t\t\t\t}\r\n\t\t\t\tsetTimeout(function () { URL.revokeObjectURL(downloadUrl); }, 100);\r\n\t\t\t}\r\n\t\t}\r\n\t});\r\n"}}