@@ -3,6 +3,8 @@ import { Feature } from 'ol';
33import { GeoJSON } from 'ol/format' ;
44import { Polygon } from 'ol/geom' ;
55import Projection from 'ol/proj/Projection' ;
6+ import { FeatureLike } from 'ol/Feature' ;
7+ import { Feature as GeoJSonFeature , Polygon as GeoJSonPolygon } from 'geojson' ;
68
79@Component ( {
810 selector : 'app-modify-polygon' ,
@@ -27,7 +29,7 @@ import Projection from 'ol/proj/Projection';
2729 <aol-source-vector>
2830 <aol-feature>
2931 <aol-geometry-polygon>
30- <aol-collection-coordinates [coordinates]="feature.getGeometry().getCoordinates() " [srid]="'EPSG:4326'">
32+ <aol-collection-coordinates [coordinates]="feature.geometry.coordinates " [srid]="'EPSG:4326'">
3133 </aol-collection-coordinates>
3234 </aol-geometry-polygon>
3335 </aol-feature>
@@ -65,22 +67,27 @@ export class ModifyPolygonComponent {
6567 displayProj = new Projection ( { code : 'EPSG:3857' } ) ;
6668 inputProj = new Projection ( { code : 'EPSG:4326' } ) ;
6769
68- feature = new Feature < Polygon > ( {
69- geometry : new Polygon ( [
70- [
71- [ - 1.7138671875 , 43.35713822211053 ] ,
72- [ 4.515380859375 , 43.35713822211053 ] ,
73- [ 4.515380859375 , 47.76886840424207 ] ,
74- [ - 1.7138671875 , 47.76886840424207 ] ,
75- [ - 1.7138671875 , 43.35713822211053 ] ,
70+ feature : GeoJSonFeature < GeoJSonPolygon > = {
71+ geometry : {
72+ coordinates : [
73+ [
74+ [ - 1.7138671875 , 43.35713822211053 ] ,
75+ [ 4.515380859375 , 43.35713822211053 ] ,
76+ [ 4.515380859375 , 47.76886840424207 ] ,
77+ [ - 1.7138671875 , 47.76886840424207 ] ,
78+ [ - 1.7138671875 , 43.35713822211053 ] ,
79+ ] ,
7680 ] ,
77- ] ) ,
78- } ) ;
81+ type : 'Polygon' ,
82+ } ,
83+ properties : { } ,
84+ type : 'Feature' ,
85+ } ;
7986
80- modifyEnd ( feature : Feature < Polygon > ) {
81- this . feature = this . format . writeFeatureObject ( feature , {
87+ modifyEnd ( feature : FeatureLike ) : void {
88+ this . feature = this . format . writeFeatureObject ( feature as Feature < Polygon > , {
8289 dataProjection : this . inputProj ,
8390 featureProjection : this . displayProj ,
84- } ) as unknown as Feature < Polygon > ;
91+ } ) as GeoJSonFeature < GeoJSonPolygon > ;
8592 }
8693}
0 commit comments