@regionerne/gis-komponent 0.0.113 → 0.0.115

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -50,7 +50,6 @@ import * as i1$4 from '@angular/material/dialog';
50
50
  import { MatDialog, MatDialogModule, MatDialogContent, MatDialogActions, MAT_DIALOG_DATA, MatDialogRef, MatDialogTitle } from '@angular/material/dialog';
51
51
  import 'ol/ol.css';
52
52
  import { MultiPolygon, Polygon, Point as Point$1, LineString } from 'ol/geom';
53
- import { getArea, getLength } from 'ol/sphere';
54
53
  import Draw, { createBox, createRegularPolygon } from 'ol/interaction/Draw';
55
54
  import { Draw as Draw$1, Snap, Select as Select$1, Modify } from 'ol/interaction';
56
55
  import { Style, Fill, Circle, Stroke, Icon, Text, RegularShape } from 'ol/style';
@@ -80,6 +79,7 @@ import PrecisionModel from 'jsts/org/locationtech/jts/geom/PrecisionModel';
80
79
  import { polygon } from '@turf/helpers';
81
80
  import booleanWithin$1 from '@turf/boolean-within';
82
81
  import booleanOverlap from '@turf/boolean-overlap';
82
+ import { getArea } from 'ol/sphere';
83
83
  import * as i5 from '@angular/material/autocomplete';
84
84
  import { MatAutocompleteModule } from '@angular/material/autocomplete';
85
85
  import { map as map$1 } from 'rxjs/operators';
@@ -4263,7 +4263,7 @@ class ToolboxComponent {
4263
4263
  zIndex: 999,
4264
4264
  style: (feature) => {
4265
4265
  const geom = feature.getGeometry();
4266
- const area = getArea(geom);
4266
+ const area = geom.getArea();
4267
4267
  const formattedArea = this.settings.sizeInHa
4268
4268
  ? `(${this._formatNumber(area / 10000, 2)} ha)`
4269
4269
  : (area > 1000000
@@ -4308,7 +4308,7 @@ class ToolboxComponent {
4308
4308
  zIndex: 999,
4309
4309
  style: (feature) => {
4310
4310
  const geom = feature.getGeometry();
4311
- const length = getLength(geom);
4311
+ const length = geom.getLength(); // getLength(geom);
4312
4312
  const formattedLength = `${this._formatNumber(length, 2)} m`;
4313
4313
  return new Style({
4314
4314
  stroke: new Stroke({
@@ -4341,16 +4341,19 @@ class ToolboxComponent {
4341
4341
  // In order to add the distance to each segment of the distance measure feature, we need some extra handling like this.
4342
4342
  this._distanceMeasureDraw.on('drawstart', (evt) => {
4343
4343
  const sketch = evt.feature;
4344
+ this._featureHelper.setId(sketch);
4344
4345
  sketch.getGeometry().on('change', (geomEvt) => {
4345
4346
  const geom = geomEvt.target;
4346
4347
  const coords = geom.getCoordinates();
4347
- this._distanceLabelSource.clear(); // Clear existing labels for each change
4348
+ // Cleanup the labels for current item for each change.
4349
+ const featuresToRemove = this._distanceLabelSource.getFeatures().filter(f => f.get('_lineFeatureId') == sketch.getId());
4350
+ this._distanceLabelSource.removeFeatures(featuresToRemove);
4348
4351
  let totalLength = 0;
4349
4352
  for (let i = 0; i < coords.length - 1; i++) {
4350
4353
  const c1 = coords[i];
4351
4354
  const c2 = coords[i + 1];
4352
4355
  const segment = new LineString([c1, c2]);
4353
- const length = getLength(segment);
4356
+ const length = segment.getLength(); // getLength(segment, { projection: 'EPSG:25832' });
4354
4357
  totalLength += length;
4355
4358
  const mid = [(c1[0] + c2[0]) / 2, (c1[1] + c2[1]) / 2];
4356
4359
  const formatted = `${this._formatNumber(length, 2)} m`;
@@ -4358,6 +4361,7 @@ class ToolboxComponent {
4358
4361
  geometry: new Point$1(mid),
4359
4362
  label: formatted
4360
4363
  });
4364
+ labelFeature.set('_lineFeatureId', sketch.getId());
4361
4365
  this._distanceLabelSource.addFeature(labelFeature);
4362
4366
  }
4363
4367
  // Add total length at the last point
@@ -4368,6 +4372,7 @@ class ToolboxComponent {
4368
4372
  geometry: new Point$1(positionPoint),
4369
4373
  label: `Total: ${formattedTotal}`
4370
4374
  });
4375
+ totalFeature.set('_lineFeatureId', sketch.getId());
4371
4376
  this._distanceLabelSource.addFeature(totalFeature);
4372
4377
  }
4373
4378
  });