Pakete, Repositories und App-Kategorien suchen

Paketdetailsv0.0.2

turf_pip

Eine kleine Bibliothek zum Erkennen, ob ein Punkt innerhalb eines Polygons liegt

AndroidiOSWebmacOSWindowsLinux
30-Tage-Downloads
162.000
Likes
1
Pub-Punkte
150

Paket installieren

flutter pub add turf_pip

Paketübersicht

Aus öffentlichen Paketdaten erstellte Orientierung.

turf_pip ist eine leichte Dart-Bibliothek, die dazu dient festzustellen, ob ein geografischer Punkt innerhalb eines Polygons liegt. Sie implementiert den Punkt-in-Polygon-Algorithmus, der häufig in räumlichen Analysen und Kartenanwendungen verwendet wird. Das Paket unterstützt mehrere Plattformen wie Android, iOS, Web, macOS, Windows und Linux und eignet sich somit für plattformübergreifende geospatialen Logik. Es ist ideal für Anwendungsfälle mit ortsbasierten Diensten, Karteninteraktionen oder räumlicher Datenvalidierung. Die Bibliothek lässt sich einfach über den Pub-Paketmanager von Flutter integrieren.

Anwendungsfälle

  • Geolokationsüberprüfung
  • Kartenbasierte Filterung
  • räumliche Datenanalyse
  • Interaktive Kartenfunktionen
  • Standortbasierte Anwendungen
  • GIS-Verarbeitung

Hauptmerkmale

  • Punkt-in-Polygon-Erkennung
  • Plattformübergreifende Unterstützung
  • Leicht und schnell
  • Einfache Integration mit Flutter
  • Reine Dart-Implementierung
  • Keine externen Abhängigkeiten

Geeignet für

  • Flutter-Entwickler, die mit Karten arbeiten
  • Anwendungen, die räumliche Abfragen erfordern
  • Backend- oder Frontend-Geodatenlogik
  • Mobile und Web-Apps mit Standortfunktionen
  • Entwickler, die minimale Fußabdruck-Tools suchen

Hinweise

  • Beschränkt auf 2D-Punkt- und Polygongeometrie
  • Unterstützt keine komplexen Geometrien wie Multipolygon
  • Keine Koordinatentransformation oder Projektionshandhabung
  • Gehen Sie davon aus, dass die Eingabekoordinaten im WGS84-Format (Breite/Länge) vorliegen
  • Nicht für häufige Echtzeit-Überprüfungen optimiert

Original-README

Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.

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

Kategorien

Abhängigkeiten

Abhängigkeiten 1 Einträge

Quell-Repository

Projekte, die dieses Paket verwenden