@@ -3,6 +3,8 @@ import { Feature } from 'ol';
3
3
import { GeoJSON } from 'ol/format' ;
4
4
import { Polygon } from 'ol/geom' ;
5
5
import Projection from 'ol/proj/Projection' ;
6
+ import { FeatureLike } from 'ol/Feature' ;
7
+ import { Feature as GeoJSonFeature , Polygon as GeoJSonPolygon } from 'geojson' ;
6
8
7
9
@Component ( {
8
10
selector : 'app-modify-polygon' ,
@@ -27,7 +29,7 @@ import Projection from 'ol/proj/Projection';
27
29
<aol-source-vector>
28
30
<aol-feature>
29
31
<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'">
31
33
</aol-collection-coordinates>
32
34
</aol-geometry-polygon>
33
35
</aol-feature>
@@ -65,22 +67,27 @@ export class ModifyPolygonComponent {
65
67
displayProj = new Projection ( { code : 'EPSG:3857' } ) ;
66
68
inputProj = new Projection ( { code : 'EPSG:4326' } ) ;
67
69
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
+ ] ,
76
80
] ,
77
- ] ) ,
78
- } ) ;
81
+ type : 'Polygon' ,
82
+ } ,
83
+ properties : { } ,
84
+ type : 'Feature' ,
85
+ } ;
79
86
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 > , {
82
89
dataProjection : this . inputProj ,
83
90
featureProjection : this . displayProj ,
84
- } ) as unknown as Feature < Polygon > ;
91
+ } ) as GeoJSonFeature < GeoJSonPolygon > ;
85
92
}
86
93
}
0 commit comments