패키지, 저장소 및 앱 카테고리 검색

패키지 상세v0.0.2

turf_pip

점이 다각형 내부에 있는지 여부를 감지하는 작은 라이브러리

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
16.2만
좋아요
1
Pub 점수
150

패키지 설치

flutter pub add turf_pip

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

turf_pip은 지리적 점이 다각형 내부에 있는지 여부를 판단하기 위해 설계된 가벼운 Dart 라이브러리입니다. 점-다각형 알고리즘을 구현하여 공간 분석 및 지도 애플리케이션에서 흔히 사용됩니다. 이 패키지는 Android, iOS, Web, macOS, Windows, Linux 등 여러 플랫폼을 지원하며, 크로스플랫폼 지리공간 로직에 적합합니다. 위치 기반 서비스, 지도 상호작용 또는 공간 데이터 검증과 같은 사례에 이상적입니다. Flutter의 pub 패키지 매니저를 통해 간단하게 통합할 수 있습니다.

사용 사례

  • 지리 정보 검증
  • 지도 기반 필터링
  • 공간 데이터 분석
  • 인터랙티브 지도 기능
  • 위치 인식 애플리케이션
  • GIS 처리

주요 기능

  • 점-다각형 감지
  • 크로스 플랫폼 지원
  • 경량이고 빠름
  • Flutter와의 간편한 통합
  • 순수 Dart 구현
  • 외부 종속성 없음

적합한 대상

  • 지도를 사용하는 Flutter 개발자
  • 공간 쿼리가 필요한 응용 프로그램
  • 백엔드 또는 프론트엔드 지리공간 논리
  • 위치 기능을 갖춘 모바일 및 웹 앱
  • 최소한의 크기의 유틸리티를 찾는 개발자

고려 사항

  • 2차원 점 및 다각형 기하학으로 제한
  • 다중 다각형과 같은 복잡한 기하학적 구조를 지원하지 않습니다
  • 좌표 변환 또는 투영 처리 없음
  • 입력 좌표가 WGS84(lat/lon) 형식이라고 가정합니다
  • 고주파 실시간 검사에 최적화되지 않음

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

turf_pip

A small library for detecting if a point lies inside a polygon.

A port of: point-in-polygon-hao NPM package.

Point in polygon library based on the paper "Optimal Reliable Point-in-Polygon Test and Differential Coding Boolean Operations on Polygons" by Hao.

Features

  • Works on polygons with holes
  • Works with degenerate/self-intersecting polyons
  • Returns PointInPolygonResult.isOnEdge if on the edge, PointInPolygonResult.isInside if inside and PointInPolygonResult.isOutside if outside
  • Not effected by floating point errors
Usage

Install via dart pub add turf_pip

import 'package:turf_pip/turf_pip.dart';

const polygon = Polygon(coordinates:[
  [
    Position.of([1, 1]),
    Position.of([1, 2]),
    Position.of([2, 2]),
    Position.of([2, 1]),
    Position.of([1, 1])
  ]
]);

pointInPolygon(Point(coordinates: Position.of([ 1.5, 1.5 ]), polygon)
// => PointInPolygonResult.isInside

pointInPolygon(Point(coordinates: Position.of([ 4.9, 1.2 ]), polygon)
// => PointInPolygonResult.isOutside

pointInPolygon(Point(coordinates: Position.of([1, 2]), polygon)
// => PointInPolygonResult.isOnEdge

Note: The input polygon format aligns with the GeoJson specification for polygons. This means that the first and last coordinate in a polygon must be repeated, if not this library will throw an error.

var polygonWithHole = Polygon(coordinates:([
  [
    Position.of([0, 0]),
    Position.of([1, 0]),
    Position.of([1, 1]),
    Position.of([0, 1]),
    Position.of([0, 0]),
  ],
  [
    Position.of([0.1, 0.1]),
    Position.of([0.1, 0.9]),
    Position.of([0.9, 0.9]),
    Position.of([0.9, 0.1]),
    Position.of([0.1, 0.1]),
  ]
]);

The library does not support multi-polygons.

Comparisons

Some rough comparisons to similar libraries. While point-in-polygon is slightly faster in most cases it does not support polygons with holes or degenerate polygons.

// For a point in a much larger geometry (700+ vertices)
point-in-poly-hao x 474,180 ops/sec ±0.55% (93 runs sampled)
point-in-polygon x 489,649 ops/sec ±0.75% (91 runs sampled)
robust-point-in-polygon x 376,268 ops/sec ±0.79% (89 runs sampled)
// For a point in bounding box check
point-in-poly-hao x 29,365,704 ops/sec ±1.30% (90 runs sampled)
point-in-polygon x 42,339,450 ops/sec ±0.78% (95 runs sampled)
robust-point-in-polygon x 20,675,569 ops/sec ±0.65% (95 runs sampled)
Algorithm

This library is based on the paper Optimal Reliable Point-in-Polygon Test and Differential Coding Boolean Operations on Polygons

Other notes
  • Works irrespective of winding order of polygon
  • Does not appear to be effected by floating point errors compared to point-in-polygon or robust-point-in-polygon

카테고리

의존성

의존성 목록 1 개

소스 저장소

이 패키지를 사용하는 프로젝트