asw_component/__init__.py +3−0 View file@@ -0,0 +1,3 @@
1 +
from .component import execute 2 +
3 +
__all__ = ["execute"][참조 MVP] 농경지 공간정보 DB — 농경지·장애물 GeoJSON 피처를 경계상자 기준으로 검색하는 경량 저장 모델입니다.
https://git.agrithing.ai/jbnu/spatial-information-db.git 3bc873b 7cfcc9e 2aec80b 29690c7 68d8ce2 ff0d18b 68d8ce2503c3a5069e1fea5065a71f6b085e20f6 asw_component/__init__.py +3−0 View filefrom .component import execute__all__ = ["execute"]asw_component/component.py +8−0 View filefrom __future__ import annotationsdef execute(payload: dict) -> dict: xmin, ymin, xmax, ymax = map(float, payload["bbox"]) if xmin > xmax or ymin > ymax: raise ValueError("invalid bbox") matches = [feature for feature in payload.get("features", []) if xmin <= float(feature["x"]) <= xmax and ymin <= float(feature["y"]) <= ymax] return {"type": "FeatureCollection", "count": len(matches), "features": [{"type": "Feature", "id": item["id"], "properties": {"feature_type": item["type"]}, "geometry": {"type": "Point", "coordinates": [item["x"], item["y"]]}} for item in matches]}examples/input.json +22−0 View file{ "bbox": [ 0, 0, 10, 10 ], "features": [ { "id": "field-1", "type": "field", "x": 5, "y": 4 }, { "id": "tree-9", "type": "obstacle", "x": 15, "y": 12 } ]}pyproject.toml +8−0 View file[project]name = "spatial_information_db"version = "0.1.0"description = "농경지·장애물 GeoJSON 피처를 경계상자 기준으로 검색하는 경량 저장 모델입니다."requires-python = ">=3.11"[tool.unittest]test-path = "tests"run.py +10−0 View filefrom __future__ import annotationsimport jsonimport sysfrom asw_component import executeif __name__ == "__main__": path = sys.argv[1] if len(sys.argv) > 1 else None with open(path, encoding="utf-8") if path else sys.stdin as source: payload = json.load(source) print(json.dumps(execute(payload), ensure_ascii=False, indent=2))