--- id: point_in_polygon_py_geo name: point_in_polygon kind: function lang: py domain: geo version: "1.0.0" purity: pure signature: "point_in_polygon(lon: float, lat: float, polygon: list[list[tuple[float, float]]]) -> bool" description: "Determina si el punto esta dentro del poligono GeoJSON (exterior + holes). True si esta en el anillo exterior y NO en ningun hole." tags: [geo, polygon, point-in-polygon, holes] uses_functions: [point_in_ring_py_geo] uses_types: [] returns: [] returns_optional: false error_type: "" imports: [] example: | from geo.point_in_polygon import point_in_polygon outer = [(0.0, 0.0), (4.0, 0.0), (4.0, 4.0), (0.0, 4.0)] hole = [(1.0, 1.0), (3.0, 1.0), (3.0, 3.0), (1.0, 3.0)] point_in_polygon(0.5, 0.5, [outer, hole]) # True (exterior, fuera del hole) point_in_polygon(2.0, 2.0, [outer, hole]) # False (dentro del hole) tested: true tests: ["punto_en_exterior", "punto_en_hole", "punto_fuera", "poligono_vacio"] test_file_path: "python/functions/geo/tests/test_point_in_polygon.py" file_path: "python/functions/geo/point_in_polygon.py" params: - {name: lon, desc: "longitud del punto a comprobar en grados decimales"} - {name: lat, desc: "latitud del punto a comprobar en grados decimales"} - {name: polygon, desc: "lista de anillos; el primero es el exterior, el resto son agujeros (holes)"} output: "True si el punto esta dentro del poligono y fuera de todos los holes" source_repo: "internal:footprint_aurgi" source_license: "internal-aurgi" source_file: "zonas_mapas_aurgi/backend/app.py:733" --- ## Ejemplo ```python from geo.point_in_polygon import point_in_polygon outer = [(0.0, 0.0), (4.0, 0.0), (4.0, 4.0), (0.0, 4.0)] hole = [(1.0, 1.0), (3.0, 1.0), (3.0, 3.0), (1.0, 3.0)] point_in_polygon(0.5, 0.5, [outer, hole]) # True point_in_polygon(2.0, 2.0, [outer, hole]) # False ``` ## Notas Compone point_in_ring. Soporta el formato de coordenadas GeoJSON (lista de anillos).