@regionerne/gis-komponent 0.0.105 → 0.0.106

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.
@@ -53,24 +53,24 @@ import { MultiPolygon, Polygon, Point as Point$1, LineString } from 'ol/geom';
53
53
  import { getArea, getLength } from 'ol/sphere';
54
54
  import Draw, { createBox, createRegularPolygon } from 'ol/interaction/Draw';
55
55
  import { Draw as Draw$1, Snap, Select as Select$1, Modify } from 'ol/interaction';
56
- import { Style, Circle, Stroke, Fill, Icon, Text, RegularShape } from 'ol/style';
56
+ import { Style, Fill, Circle, Stroke, Icon, Text, RegularShape } from 'ol/style';
57
57
  import * as SLDReader from '@nieuwlandgeo/sldreader';
58
+ import Point from 'ol/geom/Point';
59
+ import CircleStyle from 'ol/style/Circle';
60
+ import Feature from 'ol/Feature';
58
61
  import WKT from 'ol/format/WKT';
59
- import Feature$1 from 'ol/Feature';
60
62
  import { always, never } from 'ol/events/condition';
61
63
  import { buffer, lineIntersect, lineSplit, featureCollection, difference, area, flatten, feature, booleanIntersects, booleanWithin, intersect, union, booleanPointInPolygon, point, bboxPolygon } from '@turf/turf';
62
64
  import GeoJSON$1 from 'ol/format/GeoJSON';
63
65
  import { containsXY, extend, createEmpty, buffer as buffer$1 } from 'ol/extent';
64
- import { Feature } from 'ol';
66
+ import { Feature as Feature$1 } from 'ol';
65
67
  import { easeOut } from 'ol/easing';
66
68
  import Select from 'ol/interaction/Select';
67
69
  import * as i2$1 from '@angular/material/button';
68
70
  import { MatButtonModule } from '@angular/material/button';
69
71
  import html2canvas from 'html2canvas-pro';
70
- import CircleStyle from 'ol/style/Circle';
71
72
  import { transform, toLonLat } from 'ol/proj';
72
73
  import WFS from 'ol/format/WFS';
73
- import Point from 'ol/geom/Point';
74
74
  import { intersects, dwithin, contains, like } from 'ol/format/filter';
75
75
  import Rotate from 'ol/control/Rotate';
76
76
  import { BufferOp } from 'jsts/org/locationtech/jts/operation/buffer';
@@ -1308,6 +1308,51 @@ class KomponentSettingsHelperService {
1308
1308
  }
1309
1309
  }));
1310
1310
  }
1311
+ createCursorLayer(fillColor) {
1312
+ const feature = new Feature(new Point([0, 0]));
1313
+ feature.setStyle(new Style({
1314
+ image: new CircleStyle({
1315
+ radius: 4,
1316
+ fill: new Fill({ color: fillColor })
1317
+ }),
1318
+ }));
1319
+ const source = new VectorSource({
1320
+ features: [feature],
1321
+ });
1322
+ const layer = new VectorLayer({
1323
+ source,
1324
+ });
1325
+ // store reference for updates
1326
+ layer._cursorFeature = feature;
1327
+ return layer;
1328
+ }
1329
+ attachCursorToMap(map, layer) {
1330
+ const feature = layer._cursorFeature;
1331
+ map.on('pointermove', (evt) => {
1332
+ if (evt.dragging)
1333
+ return;
1334
+ feature.getGeometry().setCoordinates(evt.coordinate);
1335
+ });
1336
+ }
1337
+ getFillColorFromStyle(style) {
1338
+ let styles;
1339
+ // resolve StyleFunction
1340
+ if (typeof style === 'function') {
1341
+ // we call it with a dummy feature just to get styles
1342
+ const dummyFeature = new Feature(new Point([0, 0]));
1343
+ styles = style(dummyFeature, 0);
1344
+ }
1345
+ else {
1346
+ styles = style;
1347
+ }
1348
+ // normalize to array
1349
+ if (!Array.isArray(styles)) {
1350
+ styles = [styles];
1351
+ }
1352
+ // find first style with fill
1353
+ const fillStyle = styles.find((s) => s?.getFill?.());
1354
+ return fillStyle?.getFill()?.getColor() || null;
1355
+ }
1311
1356
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: KomponentSettingsHelperService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1312
1357
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: KomponentSettingsHelperService, providedIn: 'root' });
1313
1358
  }
@@ -1693,7 +1738,7 @@ class HighlightService {
1693
1738
  return;
1694
1739
  }
1695
1740
  const newFeatures = feature.map(f => {
1696
- const newFeature = new Feature({ geometry: f.getGeometry(), style: this._getFadedStyle(1) });
1741
+ const newFeature = new Feature$1({ geometry: f.getGeometry(), style: this._getFadedStyle(1) });
1697
1742
  const now = performance.now();
1698
1743
  newFeature.set(this.fadeStart, now);
1699
1744
  const fadeMs = this._current.gisKomponentSettings?.highlightFadeTimerMs ?? 2000;
@@ -1954,7 +1999,7 @@ class OverlapService {
1954
1999
  // The only way to get here is that the new feature completely overlaps this one. This one should be removed
1955
2000
  // and added to the output-array, because that is used for hiding features in preview
1956
2001
  if (isPreview) {
1957
- const featureToHide = new Feature(f.geometry);
2002
+ const featureToHide = new Feature$1(f.geometry);
1958
2003
  featureToHide.setId(f.id);
1959
2004
  featuresToAddToOutput.push(featureToHide);
1960
2005
  const overlappedFeature = features.find(existingFeature => existingFeature.getId() === f.id);
@@ -2040,7 +2085,7 @@ class OverlapService {
2040
2085
  const result = [];
2041
2086
  if (aTurfFeature.geometry.type === 'MultiPolygon') {
2042
2087
  aTurfFeature.geometry.coordinates.forEach((coords) => {
2043
- const newFeature = new Feature(this._geoJSONToOl({
2088
+ const newFeature = new Feature$1(this._geoJSONToOl({
2044
2089
  type: 'Polygon',
2045
2090
  coordinates: coords,
2046
2091
  style: style
@@ -2051,7 +2096,7 @@ class OverlapService {
2051
2096
  });
2052
2097
  }
2053
2098
  else {
2054
- const newFeature = new Feature(this._geoJSONToOl(aTurfFeature.geometry));
2099
+ const newFeature = new Feature$1(this._geoJSONToOl(aTurfFeature.geometry));
2055
2100
  if (style)
2056
2101
  newFeature.setStyle(style);
2057
2102
  result.push(newFeature);
@@ -3025,6 +3070,7 @@ class ToolboxComponent {
3025
3070
  _originalMapWidth = 0;
3026
3071
  _originalMapHeight = 0;
3027
3072
  pointClickKey;
3073
+ _cursorLayerForDraw;
3028
3074
  _geometrySearchService = inject(GeometrySearchService);
3029
3075
  _polygonCleanupService = inject(PolygonCleanupService);
3030
3076
  drawInteraction;
@@ -3799,6 +3845,10 @@ class ToolboxComponent {
3799
3845
  if (this.activeMode === 'draw') {
3800
3846
  this._clearAllInteractions();
3801
3847
  this.activeMode = null;
3848
+ if (this._cursorLayerForDraw) {
3849
+ this.map.removeLayer(this._cursorLayerForDraw);
3850
+ this._cursorLayerForDraw = undefined;
3851
+ }
3802
3852
  }
3803
3853
  else {
3804
3854
  this.activeMode = 'draw';
@@ -3931,7 +3981,7 @@ class ToolboxComponent {
3931
3981
  let feature = wktFormat.readFeature(item.wkt, { featureProjection: 'EPSG:25832', dataProjection: 'EPSG:25832' });
3932
3982
  if (withBuffer) {
3933
3983
  const bufferedGeometry = this._bufferGeometry(feature.getGeometry(), this.bufferInMeters);
3934
- feature = new Feature$1({ geometry: bufferedGeometry });
3984
+ feature = new Feature({ geometry: bufferedGeometry });
3935
3985
  }
3936
3986
  const geomType = feature.getGeometry()?.getType();
3937
3987
  if (!geomType) {
@@ -4087,6 +4137,19 @@ class ToolboxComponent {
4087
4137
  this._settingsHelper.getStyle(style, this.profile.styleRepositoryWorkspace, this.profile.styleRepositoryGeoserver, geomType)
4088
4138
  .subscribe({
4089
4139
  next: style => {
4140
+ if (geomType === 'Polygon' || geomType === 'LineString') {
4141
+ // Clear circle preview from previous Polygon\LineString style if needed
4142
+ if (this._cursorLayerForDraw) {
4143
+ this.map.removeLayer(this._cursorLayerForDraw);
4144
+ this._cursorLayerForDraw = undefined;
4145
+ }
4146
+ // Extract fill color from style
4147
+ const fillColor = this._settingsHelper.getFillColorFromStyle(style) || 'rgba(0,0,255,0.3)';
4148
+ // Create cursor layer (circle showing the Polygon's fill color)
4149
+ this._cursorLayerForDraw = this._settingsHelper.createCursorLayer(fillColor);
4150
+ this.map.addLayer(this._cursorLayerForDraw);
4151
+ this._settingsHelper.attachCursorToMap(this.map, this._cursorLayerForDraw);
4152
+ }
4090
4153
  const drawInteraction = new Draw({
4091
4154
  type: geomType,
4092
4155
  source: new VectorSource(),
@@ -4146,7 +4209,6 @@ class ToolboxComponent {
4146
4209
  });
4147
4210
  this._interactionHelper.setAsTemp(drawInteraction);
4148
4211
  this.map.addInteraction(drawInteraction);
4149
- this.map.getTargetElement().style.cursor = 'crosshair'; // Placeholder for now
4150
4212
  this._addSnap();
4151
4213
  }
4152
4214
  });
@@ -4248,7 +4310,7 @@ class ToolboxComponent {
4248
4310
  totalLength += length;
4249
4311
  const mid = [(c1[0] + c2[0]) / 2, (c1[1] + c2[1]) / 2];
4250
4312
  const formatted = `${this._formatNumber(length, 2)} m`;
4251
- const labelFeature = new Feature$1({
4313
+ const labelFeature = new Feature({
4252
4314
  geometry: new Point$1(mid),
4253
4315
  label: formatted
4254
4316
  });
@@ -4258,7 +4320,7 @@ class ToolboxComponent {
4258
4320
  if (coords.length > 1) {
4259
4321
  const positionPoint = coords[0];
4260
4322
  const formattedTotal = `${this._formatNumber(totalLength, 2)} m`;
4261
- const totalFeature = new Feature$1({
4323
+ const totalFeature = new Feature({
4262
4324
  geometry: new Point$1(positionPoint),
4263
4325
  label: `Total: ${formattedTotal}`
4264
4326
  });
@@ -4281,6 +4343,10 @@ class ToolboxComponent {
4281
4343
  if (clearPrintDrawTool) {
4282
4344
  this._active = 'No';
4283
4345
  }
4346
+ if (this._cursorLayerForDraw) {
4347
+ this.map.removeLayer(this._cursorLayerForDraw);
4348
+ this._cursorLayerForDraw = undefined;
4349
+ }
4284
4350
  this.map.getTargetElement().style.cursor = "";
4285
4351
  }
4286
4352
  ngOnInit() {
@@ -5665,7 +5731,7 @@ class ShowInfoHoverService {
5665
5731
  .flatMap(f => f.values)
5666
5732
  .map(f => {
5667
5733
  const styleForFeature = this._getStyle(f.showValue);
5668
- const newFeature = new Feature({ geometry: f.center });
5734
+ const newFeature = new Feature$1({ geometry: f.center });
5669
5735
  newFeature.setStyle(styleForFeature);
5670
5736
  return newFeature;
5671
5737
  });