Skip to content

Commit

Permalink
doc: fix modify polygon demo
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-eychenne committed Mar 26, 2024
1 parent 9ead980 commit 85c98dd
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions src/app/modify-polygon/modify-polygon.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -27,7 +29,7 @@ import Projection from 'ol/proj/Projection';
<aol-source-vector>
<aol-feature>
<aol-geometry-polygon>
<aol-collection-coordinates [coordinates]="feature.getGeometry().getCoordinates()" [srid]="'EPSG:4326'">
<aol-collection-coordinates [coordinates]="feature.geometry.coordinates" [srid]="'EPSG:4326'">
</aol-collection-coordinates>
</aol-geometry-polygon>
</aol-feature>
Expand Down Expand Up @@ -65,22 +67,27 @@ export class ModifyPolygonComponent {
displayProj = new Projection({ code: 'EPSG:3857' });
inputProj = new Projection({ code: 'EPSG:4326' });

feature = new Feature<Polygon>({
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<GeoJSonPolygon> = {
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<Polygon>) {
this.feature = this.format.writeFeatureObject(feature, {
modifyEnd(feature: FeatureLike): void {
this.feature = this.format.writeFeatureObject(feature as Feature<Polygon>, {
dataProjection: this.inputProj,
featureProjection: this.displayProj,
}) as unknown as Feature<Polygon>;
}) as GeoJSonFeature<GeoJSonPolygon>;
}
}

0 comments on commit 85c98dd

Please sign in to comment.