From 85c98dd2f00b7007b4297953bc6d5226ebe04d9b Mon Sep 17 00:00:00 2001 From: Jeremy Eychenne Date: Thu, 21 Mar 2024 15:56:29 +0100 Subject: [PATCH] doc: fix modify polygon demo --- .../modify-polygon.component.ts | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/app/modify-polygon/modify-polygon.component.ts b/src/app/modify-polygon/modify-polygon.component.ts index bb54654d..9ed4be57 100644 --- a/src/app/modify-polygon/modify-polygon.component.ts +++ b/src/app/modify-polygon/modify-polygon.component.ts @@ -3,6 +3,8 @@ import { Feature } from 'ol'; import { GeoJSON } from 'ol/format'; import { Polygon } from 'ol/geom'; import Projection from 'ol/proj/Projection'; +import { FeatureLike } from 'ol/Feature'; +import { Feature as GeoJSonFeature, Polygon as GeoJSonPolygon } from 'geojson'; @Component({ selector: 'app-modify-polygon', @@ -27,7 +29,7 @@ import Projection from 'ol/proj/Projection'; - + @@ -65,22 +67,27 @@ export class ModifyPolygonComponent { displayProj = new Projection({ code: 'EPSG:3857' }); inputProj = new Projection({ code: 'EPSG:4326' }); - feature = new Feature({ - geometry: new Polygon([ - [ - [-1.7138671875, 43.35713822211053], - [4.515380859375, 43.35713822211053], - [4.515380859375, 47.76886840424207], - [-1.7138671875, 47.76886840424207], - [-1.7138671875, 43.35713822211053], + feature: GeoJSonFeature = { + geometry: { + coordinates: [ + [ + [-1.7138671875, 43.35713822211053], + [4.515380859375, 43.35713822211053], + [4.515380859375, 47.76886840424207], + [-1.7138671875, 47.76886840424207], + [-1.7138671875, 43.35713822211053], + ], ], - ]), - }); + type: 'Polygon', + }, + properties: {}, + type: 'Feature', + }; - modifyEnd(feature: Feature) { - this.feature = this.format.writeFeatureObject(feature, { + modifyEnd(feature: FeatureLike): void { + this.feature = this.format.writeFeatureObject(feature as Feature, { dataProjection: this.inputProj, featureProjection: this.displayProj, - }) as unknown as Feature; + }) as GeoJSonFeature; } }