@geogirafe/lib-geoportal 1.1.0-dev.2433737633 → 1.1.0-dev.2438155631

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.
@@ -1,6 +1,6 @@
1
1
  import { Style } from 'ol/style.js';
2
2
  import type { IBrainSerializable } from '../../tools/state/brain/decorators.js';
3
- import type { Geometry } from 'ol/geom.js';
3
+ import type { Circle as CircleGeom, Geometry } from 'ol/geom.js';
4
4
  import type Feature from 'ol/Feature.js';
5
5
  import IGirafeContext from '../../tools/context/icontext.js';
6
6
  export declare enum DrawingShape {
@@ -99,6 +99,7 @@ export default class DrawingFeature {
99
99
  getLengthText(length: number): string;
100
100
  getAreaText(area: number): string;
101
101
  getCoordText(coord: number[]): string;
102
+ getAzimuthText(circle: CircleGeom): string;
102
103
  isPointOrPolyline(): boolean;
103
104
  getVertexStyle(activeNode?: boolean): Style;
104
105
  static deserialize(serializedFeature: SerializedFeature, context: IGirafeContext): DrawingFeature;
@@ -3,7 +3,7 @@ import { v4 as uuidv4 } from 'uuid';
3
3
  import { Fill, RegularShape, Stroke, Style } from 'ol/style.js';
4
4
  import { toRadians } from 'ol/math.js';
5
5
  import GeoJSON from 'ol/format/GeoJSON.js';
6
- import { getAreaAsMetricText, getLengthAsMetricText } from '../../tools/utils/olutils.js';
6
+ import { getAreaAsMetricText, getAzimuthAsText, getLengthAsMetricText } from '../../tools/utils/olutils.js';
7
7
  export var DrawingShape;
8
8
  (function (DrawingShape) {
9
9
  DrawingShape[DrawingShape["Point"] = 0] = "Point";
@@ -203,6 +203,9 @@ export default class DrawingFeature {
203
203
  }
204
204
  return 'E ' + coord[0].toFixed(2) + '\nN ' + coord[1].toFixed(2);
205
205
  }
206
+ getAzimuthText(circle) {
207
+ return getAzimuthAsText(this.displayMeasure ? circle.getProperties()['azimuth'] ?? undefined : undefined);
208
+ }
206
209
  isPointOrPolyline() {
207
210
  return (this.type === DrawingShape.Point ||
208
211
  this.type === DrawingShape.Polyline ||
@@ -259,12 +262,17 @@ export default class DrawingFeature {
259
262
  static geojsonFromOlFeature(olFeature, shapeType) {
260
263
  if (shapeType === DrawingShape.Disk) {
261
264
  const disk = olFeature.getGeometry();
265
+ const center = disk.getCenter();
266
+ const radius = disk.getRadius();
267
+ const pointer = disk.getProperties()['pointer'] ?? [center[0] + radius, center[1]];
262
268
  return {
263
269
  type: 'Feature',
264
270
  geometry: {
265
271
  type: 'Disk',
266
- center: disk.getCenter(),
267
- radius: disk.getRadius()
272
+ center: center,
273
+ radius: radius,
274
+ azimuth: disk.getProperties()['azimuth'] ?? 0,
275
+ pointer: pointer,
268
276
  }
269
277
  };
270
278
  }
@@ -138,6 +138,25 @@ export default class OlDrawing {
138
138
  pixelTolerance: this.map.pixelTolerance
139
139
  });
140
140
  this.map.olMap.addInteraction(this.modify);
141
+ this.modify.on('modifystart', (e) => {
142
+ e.features.forEach((olFeature) => {
143
+ olFeature.on('change', (e) => {
144
+ const geometry = e.target.getGeometry();
145
+ if (geometry && geometry.getType() == 'Circle') {
146
+ const circle = geometry;
147
+ const newRadius = circle.getRadius();
148
+ const properties = circle.getProperties();
149
+ const { pointer } = properties;
150
+ const oldRadiusLine = new LineString([circle.getCenter(), pointer]);
151
+ oldRadiusLine.scale(newRadius / oldRadiusLine.getLength());
152
+ circle.setProperties({
153
+ ...properties,
154
+ pointer: oldRadiusLine.getLastCoordinate()
155
+ });
156
+ }
157
+ });
158
+ });
159
+ });
141
160
  // Update the modified geometries in the state
142
161
  this.modify.on('modifyend', (e) => {
143
162
  e.features.forEach((olFeature) => this.updateGeometryInState(olFeature)); //NOSONAR(typescript:S7728) Collection<?> is a custom Implementation with custom forEach
@@ -434,7 +453,12 @@ export default class OlDrawing {
434
453
  const geometry = dFeature.geojson.geometry;
435
454
  let olFeature;
436
455
  if (geometry.type == 'Disk') {
437
- olFeature = new Feature(new CircleGeom(geometry.center, geometry.radius));
456
+ const geom = new CircleGeom(geometry.center, geometry.radius);
457
+ geom.setProperties({
458
+ azimuth: geometry.azimuth,
459
+ pointer: geometry.pointer
460
+ });
461
+ olFeature = new Feature(geom);
438
462
  }
439
463
  else {
440
464
  olFeature = new Feature(new GeoJSON().readFeatures(dFeature.geojson)[0].getGeometry());
@@ -468,6 +492,10 @@ export default class OlDrawing {
468
492
  this.fixLastLength(this.fixedLength, coord);
469
493
  geom = geom ?? new CircleGeom(coord[0], getDistance(coord, this.state.projection));
470
494
  geom.setCenterAndRadius(coord[0], getDistance(coord, this.state.projection));
495
+ geom.setProperties({
496
+ azimuth: ((90 - (Math.atan2(coord[1][1] - coord[0][1], coord[1][0] - coord[0][0]) * (180 / Math.PI)) + 360) % 360),
497
+ pointer: coord[1]
498
+ });
471
499
  return geom;
472
500
  }
473
501
  addDrawInteraction(tool) {
@@ -661,12 +689,13 @@ export default class OlDrawing {
661
689
  addLabel(polygon.getInteriorPoint(), dFeature.getAreaText(getAreaOfPolygon(polygon, this.state.projection)));
662
690
  }
663
691
  else if (dFeature.type == DrawingShape.Disk) {
664
- const radiusDataForCircle = getRadiusDataForCircle(geometry, defaultStyle, new Stroke({ color: measureColor, width: dFeature.strokeWidth }));
665
- if (!dFeature.displayMeasure) {
666
- radiusDataForCircle.style.setGeometry(new LineString([]));
692
+ if (dFeature.displayMeasure) {
693
+ const radiusDataForCircle = getRadiusDataForCircle(geometry, defaultStyle, new Stroke({ color: measureColor, width: dFeature.strokeWidth }));
694
+ styles.push(radiusDataForCircle.style);
695
+ const lengthText = dFeature.getLengthText(radiusDataForCircle.radius);
696
+ const azimuthText = dFeature.getAzimuthText(geometry);
697
+ addLabel(getHalfPoint(radiusDataForCircle.radiusLine), `${lengthText}, ${azimuthText}`);
667
698
  }
668
- styles.push(radiusDataForCircle.style);
669
- addLabel(getHalfPoint(radiusDataForCircle.radiusLine), dFeature.getLengthText(radiusDataForCircle.radius));
670
699
  }
671
700
  else if (dFeature.type == DrawingShape.FreehandPolygon) {
672
701
  const polygon = geometry;
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "name": "GeoGirafe PSC",
6
6
  "url": "https://doc.geomapfish.dev"
7
7
  },
8
- "version": "1.1.0-dev.2433737633",
8
+ "version": "1.1.0-dev.2438155631",
9
9
  "type": "module",
10
10
  "engines": {
11
11
  "node": ">=20.19.0"
@@ -1 +1 @@
1
- {"version":"1.1.0-dev.2433737633", "build":"2433737633", "date":"07/04/2026"}
1
+ {"version":"1.1.0-dev.2438155631", "build":"2438155631", "date":"08/04/2026"}
package/tools/main.d.ts CHANGED
@@ -106,7 +106,7 @@ export { default as UserDataManager } from './userdata/userdatamanager.js';
106
106
  export { default as ColumnAliasHelper } from './utils/aliases.js';
107
107
  export { debounce } from './utils/debounce.js';
108
108
  export { default as GirafeColorPicker } from './utils/girafecolorpicker.js';
109
- export { unByKeyAll, getOlayerByName, removeUnwantedOlParams, polygonFromCircle, getDistance, getAreaOfPolygon, getAreaOfCircle, isCoordinateInDegrees, getSelectionBoxFromMapClick, reprojectGeometry, ensurePolygonIsProperlyClosed, getHalfPoint, getLabelStyle, getRadiusDataForCircle, getLengthAsMetricText, getAreaAsMetricText } from './utils/olutils.js';
109
+ export { unByKeyAll, getOlayerByName, removeUnwantedOlParams, polygonFromCircle, getDistance, getAreaOfPolygon, getAreaOfCircle, isCoordinateInDegrees, getSelectionBoxFromMapClick, reprojectGeometry, ensurePolygonIsProperlyClosed, getHalfPoint, getLabelStyle, getRadiusDataForCircle, getLengthAsMetricText, getAreaAsMetricText, getAzimuthAsText } from './utils/olutils.js';
110
110
  export { getPropertyByPath, setPropertyByPath, createObjectFromPath, deletePropertyByPath, mergeObjects } from './utils/pathUtils.js';
111
111
  export { generateQrCode } from './utils/qrcode.js';
112
112
  export { default as ServiceWorkerHelper } from './utils/swhelper.js';
package/tools/main.js CHANGED
@@ -81,7 +81,7 @@ export { default as UserDataManager } from './userdata/userdatamanager.js';
81
81
  export { default as ColumnAliasHelper } from './utils/aliases.js';
82
82
  export { debounce } from './utils/debounce.js';
83
83
  export { default as GirafeColorPicker } from './utils/girafecolorpicker.js';
84
- export { unByKeyAll, getOlayerByName, removeUnwantedOlParams, polygonFromCircle, getDistance, getAreaOfPolygon, getAreaOfCircle, isCoordinateInDegrees, getSelectionBoxFromMapClick, reprojectGeometry, ensurePolygonIsProperlyClosed, getHalfPoint, getLabelStyle, getRadiusDataForCircle, getLengthAsMetricText, getAreaAsMetricText } from './utils/olutils.js';
84
+ export { unByKeyAll, getOlayerByName, removeUnwantedOlParams, polygonFromCircle, getDistance, getAreaOfPolygon, getAreaOfCircle, isCoordinateInDegrees, getSelectionBoxFromMapClick, reprojectGeometry, ensurePolygonIsProperlyClosed, getHalfPoint, getLabelStyle, getRadiusDataForCircle, getLengthAsMetricText, getAreaAsMetricText, getAzimuthAsText } from './utils/olutils.js';
85
85
  export { getPropertyByPath, setPropertyByPath, createObjectFromPath, deletePropertyByPath, mergeObjects } from './utils/pathUtils.js';
86
86
  export { generateQrCode } from './utils/qrcode.js';
87
87
  export { default as ServiceWorkerHelper } from './utils/swhelper.js';
@@ -48,3 +48,4 @@ export declare const getRadiusDataForCircle: (circle: Circle, defaultStyle: Styl
48
48
  };
49
49
  export declare const getLengthAsMetricText: (length?: number) => string;
50
50
  export declare const getAreaAsMetricText: (area?: number) => string;
51
+ export declare const getAzimuthAsText: (azimuth?: number) => string;
@@ -148,7 +148,8 @@ export const getLabelStyle = (position, text, labelStyle) => {
148
148
  export const getRadiusDataForCircle = (circle, defaultStyle, stroke) => {
149
149
  const radius = circle.getRadius();
150
150
  const center = circle.getCenter();
151
- const radiusLine = [center, [center[0] + radius, center[1]]];
151
+ const pointer = circle.getProperties()['pointer'] ?? [center[0] + radius, center[1]];
152
+ const radiusLine = [center, pointer];
152
153
  const radiusLineStyle = defaultStyle.clone();
153
154
  radiusLineStyle.setStroke(stroke);
154
155
  radiusLineStyle.getText().setText('');
@@ -173,3 +174,9 @@ export const getAreaAsMetricText = (area) => {
173
174
  }
174
175
  return '';
175
176
  };
177
+ export const getAzimuthAsText = (azimuth) => {
178
+ if (azimuth) {
179
+ return `${azimuth.toFixed(0)}°`;
180
+ }
181
+ return '';
182
+ };