24 lines
660 B
TypeScript
24 lines
660 B
TypeScript
import { boundingExtent, getCenter } from 'ol/extent';
|
|
import Feature from 'ol/Feature';
|
|
import Geometry from 'ol/geom/Geometry';
|
|
|
|
export function medianCoordinate2D(feature: Feature<Geometry>) {
|
|
// Feature를 입력 받아 중심 좌표를 계산하는 함수
|
|
if (!feature) {
|
|
console.warn("유효한 피처가 없습니다.");
|
|
return;
|
|
}
|
|
|
|
console.log(feature)
|
|
|
|
const geometry = feature.getGeometry();
|
|
if (!geometry) {
|
|
console.warn("피처에 geometry가 없습니다.");
|
|
return;
|
|
}
|
|
|
|
const extent = geometry.getExtent();
|
|
const center = getCenter(extent);
|
|
const centerExtent = boundingExtent([center]);
|
|
return centerExtent;
|
|
} |