Skip to content

Commit

Permalink
Merge pull request #892 from valeria-foco/FixExportShape
Browse files Browse the repository at this point in the history
fix export Shaper per geometrie poligonali e lineari (cambio versione…
  • Loading branch information
diegosanmartino committed Apr 15, 2021
2 parents 92313a4 + 0cda6a7 commit 2b67928
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 29 deletions.
2 changes: 1 addition & 1 deletion frontend/assets/puntiScaricoIndustriale.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@
"valueId":"toponimo",
"valueLabel":"toponimo",
"dependson":{
"field": "decsiraogc_stabilimenti:desProvincia",
"field": "decsiraogc_scarichi:desProvincia",
"from": "sigla",
"to": "sigla_provincia"
}
Expand Down
9 changes: 7 additions & 2 deletions frontend/js/utils/ExporterUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/
const FileSaver = require('file-saver');
const shpwrite = require('shp-write');
const shpwrite = require('fixed-shp-write');
const JSZip = require('jszip');
const GeoJSON = require('ol/format/GeoJSON').default;
const ProWKTDef = require('./ProjWKTDef');
Expand Down Expand Up @@ -51,6 +51,11 @@ const ExporterUtils = {
const olFeatures = format.readFeatures(featureCollection);
olFeatures.map((f) => f.getGeometry().transform('EPSG:4326', outputSrs));
const geoObject = format.writeFeaturesObject(olFeatures);
geoObject.features.map((ft) => {
if (ft.geometry.type === "LineString") {
ft.geometry.coordinates = [ft.geometry.coordinates];
}
});
const shpString = shpwrite.zip({
type: 'FeatureCollection',
features: geoObject.features
Expand Down Expand Up @@ -141,7 +146,7 @@ const ExporterUtils = {
res.push({
type: ft.type,
id: ft.id,
geometry: ft. geometry,
geometry: ft.geometry,
properties: cols.reduce((obj, col) => {
obj[col.header] = ft.properties[col.id];
return obj;
Expand Down
48 changes: 24 additions & 24 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
"es6-promise": "2.3.0",
"eventlistener": "0.0.1",
"file-saver": "1.3.3",
"fixed-shp-write": "^0.3.3",
"fs-extra": "3.0.1",
"geostyler-geocss-parser": "https://github.com/allyoucanmap/geostyler-geocss-parser/tarball/build",
"geostyler-openlayers-parser": "1.1.4",
Expand Down Expand Up @@ -240,7 +241,6 @@
"resize-observer-polyfill": "1.5.0",
"rxjs": "5.1.1",
"screenfull": "4.0.0",
"shp-write": "0.3.0",
"shpjs": "3.4.2",
"stickybits": "3.6.6",
"swipe-js-iso": "2.0.3",
Expand All @@ -255,8 +255,8 @@
"uuid": "3.0.1",
"vis": "4.21.0",
"w3c-schemas": "1.3.1",
"wellknown": "0.5.0",
"webfontloader": "1.6.28",
"wellknown": "0.5.0",
"xml2js": "0.4.17",
"xmldom": "0.3.0",
"xpath": "0.0.27"
Expand Down

0 comments on commit 2b67928

Please sign in to comment.