@regionerne/gis-komponent 0.0.103 → 0.0.104

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.
@@ -1941,27 +1941,27 @@ class OverlapService {
1941
1941
  }
1942
1942
  else {
1943
1943
  // Check if the existing feature is totally within the new
1944
+ // or if they are the same geometry (item # 234 when importing WKT from existing active object, then keep only the new one)
1944
1945
  const fcReversed = featureCollection([newFeatureGeoJson, f]);
1945
1946
  const featureDiffReversed = difference(fcReversed);
1946
- if (featureDiffReversed) {
1947
- const reversedDiffArea = area(featureDiffReversed);
1948
- if (reversedDiffArea) {
1949
- // The only way to get here is that the new feature completely overlaps this one. This one should be removed
1950
- // and added to the output-array, because that is used for hiding features in preview
1951
- if (isPreview) {
1952
- const featureToHide = new Feature(f.geometry);
1953
- featureToHide.setId(f.id);
1954
- featuresToAddToOutput.push(featureToHide);
1955
- const overlappedFeature = features.find(existingFeature => existingFeature.getId() === f.id);
1956
- if (overlappedFeature) {
1957
- overlappedFeature.setGeometry(undefined);
1958
- }
1947
+ const featureArea = area(f.geometry);
1948
+ const newFeatureArea = area(newFeatureGeoJson.geometry);
1949
+ if ((featureDiffReversed && area(featureDiffReversed)) || (Math.abs(featureArea - newFeatureArea) < this.EPSILON)) {
1950
+ // The only way to get here is that the new feature completely overlaps this one. This one should be removed
1951
+ // and added to the output-array, because that is used for hiding features in preview
1952
+ if (isPreview) {
1953
+ const featureToHide = new Feature(f.geometry);
1954
+ featureToHide.setId(f.id);
1955
+ featuresToAddToOutput.push(featureToHide);
1956
+ const overlappedFeature = features.find(existingFeature => existingFeature.getId() === f.id);
1957
+ if (overlappedFeature) {
1958
+ overlappedFeature.setGeometry(undefined);
1959
1959
  }
1960
- else {
1961
- const featureToRemove = this._drawLayerService.source.getFeatureById(f.id);
1962
- if (featureToRemove) {
1963
- this._drawLayerService.source.removeFeature(featureToRemove);
1964
- }
1960
+ }
1961
+ else {
1962
+ const featureToRemove = this._drawLayerService.source.getFeatureById(f.id);
1963
+ if (featureToRemove) {
1964
+ this._drawLayerService.source.removeFeature(featureToRemove);
1965
1965
  }
1966
1966
  }
1967
1967
  }
@@ -3541,6 +3541,11 @@ class ToolboxComponent {
3541
3541
  this._confirmService.open({ message, primaryText: 'Ok', title: 'Advarsel' }).subscribe();
3542
3542
  return;
3543
3543
  }
3544
+ // Validate against invalid holes - item # 234
3545
+ if (featureType === 'Polygon' && this._polygonCleanupService.cleanupPolygonTurf(feature.getGeometry()) === 'changed') {
3546
+ this._confirmService.open({ primaryText: 'OK', title: 'Fejl i geometri', message: 'WKT kunne ikke indlæses - den geometri kunne ikke valideres' }).subscribe();
3547
+ return;
3548
+ }
3544
3549
  this._settingsHelper.getStyle(this.selectedDrawItem?.style, this.profile.styleRepositoryWorkspace, this.profile.styleRepositoryGeoserver, featureType).subscribe({
3545
3550
  next: featureStyle => {
3546
3551
  if (featureType === 'Polygon') {
@@ -3574,6 +3579,44 @@ class ToolboxComponent {
3574
3579
  }
3575
3580
  }
3576
3581
  });
3582
+ //Handle MultyPolygon - item # 234
3583
+ }
3584
+ else if (feature.getGeometry()?.getType() === 'MultiPolygon') {
3585
+ const polys = this._featureHelper.splitMultiPolygonFeature(feature.getGeometry());
3586
+ polys.forEach(poly => {
3587
+ const newFeature = feature.clone();
3588
+ newFeature.setGeometry(poly);
3589
+ this.handleFeatureValidation(newFeature).subscribe({
3590
+ next: (result) => {
3591
+ if (result) {
3592
+ result.forEach(feature => {
3593
+ feature.setStyle(featureStyle);
3594
+ this._featureHelper.setTypeId(feature, this.selectedDrawItem?.typeId || '');
3595
+ this._featureHelper.setId(feature);
3596
+ });
3597
+ this._overlap.handleOverlaps(result).pipe(filter(f => !!f)).subscribe({
3598
+ next: f => {
3599
+ if (f) {
3600
+ f.forEach(feature => {
3601
+ this._drawLayerService.source.addFeature(feature);
3602
+ });
3603
+ this._zoomService.zoomToFeatures(f);
3604
+ if (f.length > 1) {
3605
+ this._confirmService.open({ message: `Den indtegnede flade var ikke gyldig, men rettet til ${f.length} nye flader`, primaryText: 'OK', title: 'Advarsel' }).subscribe();
3606
+ }
3607
+ if (f.length > 0) {
3608
+ this._undoRedo.addStep();
3609
+ }
3610
+ }
3611
+ }
3612
+ });
3613
+ }
3614
+ else {
3615
+ this._confirmService.open({ message: `Validering af de tegnede flader resulterede i ingen flader`, primaryText: 'OK', title: 'Advarsel' }).subscribe();
3616
+ }
3617
+ }
3618
+ });
3619
+ });
3577
3620
  }
3578
3621
  else {
3579
3622
  feature.setStyle(featureStyle);