Mercurial > gemma
comparison client/src/components/Pdftool.vue @ 2767:3063f1485ad6
client:fix typo
* scalenominator
author | Fadi Abbud <fadi.abbud@intevation.de> |
---|---|
date | Fri, 22 Mar 2019 09:48:12 +0100 |
parents | d0f6c222f4f9 |
children | a6eea3002e6e |
comparison
equal
deleted
inserted
replaced
2766:1f173d1a731d | 2767:3063f1485ad6 |
---|---|
285 let metersPerPixel = // average meters (reality) per pixel (map) | 285 let metersPerPixel = // average meters (reality) per pixel (map) |
286 getPointResolution(proj, view.getResolution(), view.getCenter()) * | 286 getPointResolution(proj, view.getResolution(), view.getCenter()) * |
287 proj.getMetersPerUnit(); | 287 proj.getMetersPerUnit(); |
288 // DEBUG console.log("metersPerPixel = ", metersPerPixel); | 288 // DEBUG console.log("metersPerPixel = ", metersPerPixel); |
289 | 289 |
290 let scaleNominator = Math.round( | 290 let scaleDenominator = Math.round( |
291 // the x in 1:x map scale | 291 // the x in 1:x map scale |
292 1000 * pixelsPerMapMillimeter * metersPerPixel | 292 1000 * pixelsPerMapMillimeter * metersPerPixel |
293 ); | 293 ); |
294 console.log("scaleNominator = ", scaleNominator); | 294 console.log("scaleDenominator = ", scaleDenominator); |
295 | 295 |
296 var data = canvas.toDataURL("image/jpeg"); | 296 var data = canvas.toDataURL("image/jpeg"); |
297 this.pdf.doc.addImage( | 297 this.pdf.doc.addImage( |
298 data, | 298 data, |
299 "JPEG", | 299 "JPEG", |
384 ); | 384 ); |
385 break; | 385 break; |
386 } | 386 } |
387 case "scalebar": { | 387 case "scalebar": { |
388 this.addScaleBar( | 388 this.addScaleBar( |
389 scaleNominator, | 389 scaleDenominator, |
390 e.position, | 390 e.position, |
391 e.offset || defaultOffset, | 391 e.offset || defaultOffset, |
392 e.rounding === 0 || e.rounding ? e.rounding : defaultRounding, | 392 e.rounding === 0 || e.rounding ? e.rounding : defaultRounding, |
393 e.brcolor || defaultBorderColor | 393 e.brcolor || defaultBorderColor |
394 ); | 394 ); |
395 break; | 395 break; |
396 } | 396 } |
397 case "scale": { | 397 case "scale": { |
398 this.addScale( | 398 this.addScale( |
399 scaleNominator, | 399 scaleDenominator, |
400 e.position, | 400 e.position, |
401 e.width, | 401 e.width, |
402 e.offset || defaultOffset, | 402 e.offset || defaultOffset, |
403 e.fontSize || defaultFontSize, | 403 e.fontSize || defaultFontSize, |
404 e.color || defaultTextColor | 404 e.color || defaultTextColor |
444 this.openLayersMap.setSize(this.mapSize); | 444 this.openLayersMap.setSize(this.mapSize); |
445 this.openLayersMap.getView().fit(this.mapExtent, { size: this.mapSize }); | 445 this.openLayersMap.getView().fit(this.mapExtent, { size: this.mapSize }); |
446 this.readyToGenerate = true; | 446 this.readyToGenerate = true; |
447 }, | 447 }, |
448 // add the used map scale and papersize | 448 // add the used map scale and papersize |
449 addScale(scalenominator, position, width, offset, fontSize, color) { | 449 addScale(scaleDenominator, position, width, offset, fontSize, color) { |
450 //TODO: check the correctence of the scalnominator value here. | 450 //TODO: check the correctence of the scalnominator value here. |
451 let str = | 451 let str = |
452 this.$gettext("Scale") + | 452 this.$gettext("Scale") + |
453 " 1 : " + | 453 " 1 : " + |
454 scalenominator + | 454 scaleDenominator + |
455 " " + | 455 " " + |
456 "(DIN" + | 456 "(DIN" + |
457 " " + | 457 " " + |
458 this.form.paperSize.toUpperCase() + | 458 this.form.paperSize.toUpperCase() + |
459 ")"; | 459 ")"; |
576 } | 576 } |
577 } | 577 } |
578 | 578 |
579 this.pdf.doc.addImage(image, x, y, width, height); | 579 this.pdf.doc.addImage(image, x, y, width, height); |
580 }, | 580 }, |
581 addScaleBar(scaleNominator, position, offset, rounding, brcolor) { | 581 addScaleBar(scaleDenominator, position, offset, rounding, brcolor) { |
582 // scaleNominator is the x in 1:x of the map scale | 582 // scaleDenominator is the x in 1:x of the map scale |
583 | 583 |
584 // hardcode maximal width for now | 584 // hardcode maximal width for now |
585 let maxWidth = 80; // in mm | 585 let maxWidth = 80; // in mm |
586 | 586 |
587 // reduce width until we'll find a nice number for printing | 587 // reduce width until we'll find a nice number for printing |
596 Math.log10 || // more precise, but unsupported by IE | 596 Math.log10 || // more precise, but unsupported by IE |
597 function(x) { | 597 function(x) { |
598 return Math.log(x) * Math.LOG10E; | 598 return Math.log(x) * Math.LOG10E; |
599 }; | 599 }; |
600 | 600 |
601 let maxLength = maxWidth * scaleNominator; | 601 let maxLength = maxWidth * scaleDenominator; |
602 | 602 |
603 let unit = "mm"; | 603 let unit = "mm"; |
604 let unitConversionFactor = 1; | 604 let unitConversionFactor = 1; |
605 if (maxLength >= 1e7) { | 605 if (maxLength >= 1e7) { |
606 // >= 10 km | 606 // >= 10 km |
633 length = 2 * factor; | 633 length = 2 * factor; |
634 } else { | 634 } else { |
635 length = factor; | 635 length = factor; |
636 } | 636 } |
637 | 637 |
638 let size = (length * unitConversionFactor) / scaleNominator / 4; | 638 let size = (length * unitConversionFactor) / scaleDenominator / 4; |
639 let fullSize = size * 4; | 639 let fullSize = size * 4; |
640 | 640 |
641 // x/y defaults to offset for topleft corner (normal x/y coordinates) | 641 // x/y defaults to offset for topleft corner (normal x/y coordinates) |
642 let x = offset.x; | 642 let x = offset.x; |
643 let y = offset.y; | 643 let y = offset.y; |