@regionerne/gis-komponent 0.0.75 → 0.0.76

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.
@@ -1058,7 +1058,6 @@ class LayerSelectorComponent {
1058
1058
  }
1059
1059
  group.noOfVisibleLayers = group.layers.filter(l => l.activeInSelector && l.visible).length;
1060
1060
  group.visible = group.layers.some(l => l.visible);
1061
- group.expanded = group.layers.some(l => l.visible);
1062
1061
  });
1063
1062
  // DMP Layer
1064
1063
  this.dmpLayers.forEach(dmpLayer => { if (dmpLayer.datasetId === layerId)
@@ -2085,14 +2084,14 @@ class OverlapService {
2085
2084
  const primaryFeaturesForPreview = this._handleUnlockedFeaturesOverlapping(primaryFeatures, 'primary', true);
2086
2085
  const secondaryFeaturesForPreview = this._handleUnlockedFeaturesOverlapping(secondaryFeatures, 'secondary', true);
2087
2086
  return this._confirmService.open({
2088
- primaryText: 'Nye',
2089
- secondaryText: 'Eksisterende',
2087
+ primaryText: 'Beskær den aktive',
2088
+ secondaryText: 'Bevar den aktive',
2090
2089
  disableClose: false,
2091
2090
  previewEnabled: true,
2092
2091
  primaryFeaturesForPreview: primaryFeaturesForPreview,
2093
2092
  secondaryFeaturesForPreview: secondaryFeaturesForPreview,
2094
2093
  drawLayerSourceService: this._drawLayerService,
2095
- message: 'Den nye flade overlapper med eksisterende flade. Ønsker du at beskære de nye eller de eksisterende (hold musen over for at se forhåndsvisning)?',
2094
+ message: 'Fladerne beskæres for at undgå overlap (hold musen over for at se forhåndsvisning)?',
2096
2095
  title: 'Beskæring'
2097
2096
  }).pipe(map(msg => {
2098
2097
  return this._handleUnlockedFeaturesOverlapping(features, msg);
@@ -2108,6 +2107,7 @@ class OverlapService {
2108
2107
  return clonedFeature;
2109
2108
  }
2110
2109
  _handleUnlockedFeaturesOverlapping(features, msg, isPreview) {
2110
+ const featuresToHideInPreview = []; // Holds features from the map that are completely within the new feature.
2111
2111
  features.forEach(feature => {
2112
2112
  const overlappingUnlockedFeatures = this._drawLayerService.source.getFeatures().filter(f => !this._featureHelper.isLocked(f) && f.getGeometry()?.intersectsExtent(feature.getGeometry().getExtent()));
2113
2113
  if (overlappingUnlockedFeatures.length > 0) {
@@ -2145,67 +2145,39 @@ class OverlapService {
2145
2145
  }
2146
2146
  }
2147
2147
  }
2148
+ else {
2149
+ // Check if the existing feature is totally within the new
2150
+ const fcReversed = featureCollection([newFeatureGeoJson, f]);
2151
+ const featureDiffReversed = difference(fcReversed);
2152
+ if (featureDiffReversed) {
2153
+ const reversedDiffArea = area(featureDiffReversed);
2154
+ if (reversedDiffArea) {
2155
+ // The only way to get here is that the new feature completely overlaps this one. This one should be removed
2156
+ // and added to the output-array, because that is used for hiding features in preview
2157
+ if (isPreview) {
2158
+ const featureToHide = new Feature(f.geometry);
2159
+ featureToHide.setId(f.id);
2160
+ featuresToHideInPreview.push(featureToHide);
2161
+ const overlappedFeature = features.find(existingFeature => existingFeature.getId() === f.id);
2162
+ if (overlappedFeature) {
2163
+ overlappedFeature.setGeometry(undefined);
2164
+ }
2165
+ }
2166
+ else {
2167
+ const featureToRemove = this._drawLayerService.source.getFeatureById(f.id);
2168
+ if (featureToRemove) {
2169
+ this._drawLayerService.source.removeFeature(featureToRemove);
2170
+ }
2171
+ }
2172
+ }
2173
+ }
2174
+ }
2148
2175
  });
2149
2176
  }
2150
2177
  }
2151
2178
  });
2152
2179
  features = features.filter(feature => feature.getGeometry() !== undefined);
2153
- return features;
2154
- }
2155
- handleOverlap(feature) {
2156
- // Handle the locked.
2157
- const overlappingLockedFeatures = this._drawLayerService.source.getFeatures().filter(f => this._featureHelper.isLocked(f) && f.getGeometry()?.intersectsExtent(feature.getGeometry().getExtent()));
2158
- const clipped = this._handleLockedFeaturesOverlapping(overlappingLockedFeatures, feature);
2159
- if (clipped) {
2160
- this._confirmService.open({ message: 'Der var overlap med låste flader, så den indtegnede flade er blevet beskåret', primaryText: 'OK', title: 'Advarsel' }).subscribe();
2161
- }
2162
- // Handle the unlocked.
2163
- const overlappingUnlockedFeatures = this._drawLayerService.source.getFeatures().filter(f => !this._featureHelper.isLocked(f) && f.getGeometry()?.intersectsExtent(feature.getGeometry().getExtent()));
2164
- if (overlappingUnlockedFeatures.length === 0) {
2165
- return of(feature);
2166
- }
2167
- else {
2168
- let newFeatureGeoJson = this._geoJsonFormat.writeFeatureObject(feature);
2169
- const newFeatureArea = area(newFeatureGeoJson);
2170
- const unlockedFeaturesAsGeoJson = overlappingUnlockedFeatures.map(f => this._geoJsonFormat.writeFeatureObject(f));
2171
- const newClippedFeature = difference(featureCollection([newFeatureGeoJson, ...unlockedFeaturesAsGeoJson]));
2172
- // if the new feature is completely inside one of the existing features, newClippedFeature will be null
2173
- const areaNewClippedFeature = newClippedFeature ? area(newClippedFeature) : 1;
2174
- if (Math.abs(newFeatureArea - areaNewClippedFeature) < this.EPSILON) {
2175
- return of(feature);
2176
- }
2177
- else {
2178
- return this._confirmService.open({
2179
- primaryText: 'Nye',
2180
- secondaryText: 'Eksisterende',
2181
- disableClose: true,
2182
- message: 'Den nye flade overlapper med eksisterende flade. Ønsker du at beskære de nye eller de eksisterende?',
2183
- title: 'Beskæring'
2184
- }).pipe(map(msg => {
2185
- if (msg === 'primary') {
2186
- const newGeometry = this._geoJsonFormat.readGeometry(newClippedFeature.geometry);
2187
- feature.setGeometry(newGeometry);
2188
- return feature;
2189
- }
2190
- else {
2191
- unlockedFeaturesAsGeoJson.forEach(f => {
2192
- const featureArea = area(f.geometry);
2193
- const fc = featureCollection([f, newFeatureGeoJson]);
2194
- const featureDiff = difference(fc);
2195
- const featureDiffArea = area(featureDiff.geometry);
2196
- if (Math.abs(featureArea - featureDiffArea) > this.EPSILON) {
2197
- const existingFeature = this._drawLayerService.source.getFeatureById(f.id);
2198
- if (existingFeature) {
2199
- const newGeometry = this._geoJsonFormat.readGeometry(featureDiff?.geometry);
2200
- existingFeature.setGeometry(newGeometry);
2201
- }
2202
- }
2203
- });
2204
- return feature;
2205
- }
2206
- }));
2207
- }
2208
- }
2180
+ return [...features, ...featuresToHideInPreview];
2209
2181
  }
2210
2182
  _handleLockedFeaturesOverlapping(overlappingFeatures, orgFeature) {
2211
2183
  let newFeatureGeoJson = this._geoJsonFormat.writeFeatureObject(orgFeature);