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

패키지 상세v1.0.0

geojson

GeoJSON 데이터를 작업하는 데 사용할 수 있는 유틸리티입니다. 반응형 API를 갖춘 파서, 검색 및 지오페싱

AndroidiOSmacOSWindowsLinux
30일 다운로드
1.4천
좋아요
63
Pub 점수
140

패키지 설치

flutter pub add geojson

패키지 개요

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

geojson 패키지는 Flutter 애플리케이션에서 GeoJSON 데이터를 처리하기 위한 유틸리티를 제공합니다. 실시간으로 GeoJSON 구조를 처리할 수 있는 반응형 파서를 포함하며, 공간 검색 작업을 지원하고 위치 기반 트리거를 위한 지오페싱 기능도 제공합니다. 지도 및 지리공간 기능을 통합하는 개발자를 위해 설계되었으며, 다양한 플랫폼에서 GeoJSON 콘텐츠의 파싱과 조작을 간편하게 만듭니다. 내비게이션 도구, 위치 추적 또는 인터랙티브 맵과 같은 동적 지도 데이터 처리가 필요한 앱에 이상적입니다.

사용 사례

  • 인터랙티브 지도 애플리케이션
  • 위치 기반 알림
  • 지리공간 데이터 시각화
  • 실시간 경로 계획
  • 지도 레이어 관리

주요 기능

  • 반응형 GeoJSON 파싱
  • 내장된 공간 검색
  • 지오펜싱 지원
  • 크로스 플랫폼 호환성
  • 스트림 기반 데이터 처리

적합한 대상

  • 모바일 및 데스크톱 지도 앱
  • 위치 인식 서비스
  • GIS 통합
  • 실시간 데이터 대시보드
  • 지리공간 프로젝트에 Flutter를 사용하는 개발 팀

고려 사항

  • GeoJSON 형식에 대한 이해가 필요합니다
  • 완전한 지도 렌더링을 위해 추가 종속성이 필요할 수 있습니다
  • 성능은 데이터 크기에 따라 달라집니다
  • 기본 지리공간 논리에 제한됨
  • 완전한 GIS 솔루션이 아님

원본 README

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

Geojson

pub package Build Status Coverage Status

Utilities to work with geojson data in Dart. Features:

  • Parser with a reactive api: streams are available to retrieve the geojson features as soon as they are parsed
  • Search: search for properties
  • Geofencing: geofence points in a polygon or from a distance

Note: the data is parsed in an isolate to avoid slowing down the main thread

Simple functions

featuresFromGeoJson: get a FeaturesCollection from geojson string data. Parameters:

  • data: a string with the geojson data, required
  • nameProperty: the property used for the geoserie name, automaticaly set if null
  • verbose: print the parsed data if true

featuresFromGeoJsonFile: get a FeaturesCollection from a geojson file. Parameters:

  • file: the file to load, required
  • nameProperty: the property used for the geoserie name, automaticaly set if null
  • verbose: print the parsed data if true

These functions are suitable for small data. Example:

final features = await featuresFromGeoJson(data);

Web support

featuresFromGeoJsonMainThread: as the web do not support isolates use this function to parse in the main thread. Parameters:

  • data: a string with the geojson data, required
  • nameProperty: the property used for the geoserie name, automaticaly set if null
  • verbose: print the parsed data if true

Reactive api

Parse and listen

Typed streams are available to retrieve the features as soon as they are parsed. This is useful when the data is big.

  • processedFeatures: the parsed features: all the geometries
  • processedPoints: the parsed points
  • processedMultipoints: the parsed multipoints
  • processedLines: the parsed lines
  • processedMultilines: the parsed multilines
  • processedPolygons: the parsed polygons
  • processedMultipolygons: the parsed multipolygons
  • endSignal: parsing is finished indicator

Example: add assets on a Flutter map:

  import 'package:flutter/services.dart' show rootBundle;
  import 'package:geojson/geojson.dart';
  import 'package:flutter_map/flutter_map.dart';

  /// Data for the Flutter map polylines layer
  final lines = <Polyline>[];

  Future<void> parseAndDrawAssetsOnMap() async {
    final geo = GeoJson();
    geo.processedLines.listen((GeoJsonLine line) {
      /// when a line is parsed add it to the map right away
      setState(() => lines.add(Polyline(
          strokeWidth: 2.0, color: Colors.blue, points: line.geoSerie.toLatLng())));
    });
    geo.endSignal.listen((_) => geo.dispose());
    final data = await rootBundle
        .loadString('assets/railroads_of_north_america.geojson');
    await geo.parse(data, verbose: true);
  }
Data properties

After the data is parsed the GeoJson instance has properties to access the data:

List<GeoJsonFeature> features;
List<GeoJsonPoint> points;
List<GeoJsonMultiPoint> multipoints;
List<GeoJsonLine> lines;
List<GeoJsonMultiLine> multilines;
List<GeoJsonPolygon> polygons;
List<GeoJsonMultiPolygon> multipolygons;

Example:

final List<GeoJsonLine> lines = geo.lines;

Search

Search in a geojson file:

final geo = GeoJson();
await geo.searchInFile("countries.geojson",
    query: GeoJsonQuery(
        geometryType: GeoJsonFeatureType.multipolygon,
        matchCase: false,
        property: "name",
        value: "Zimbabwe"),
    verbose: true);
List<GeoJsonMultiPolygon> result = geo.multipolygons;

A search method is also available, taking string data in parameter instead of a file path. The streams are available to retrieve the data as soon as it is found

Geofencing

Geofence points within a distance of a given point:

final geo = GeoJson();
/// `point` is the [GeoJsonPoint] to search from
/// `points` is the list of [GeoJsonPoint] to search in
/// `distance` is the distance to search in meters
await geo.geofenceDistance(
      point: point, points: points, distance: distance);
 List<GeoPoint> foundPoints = geo.points;

Geofence points in a polygon:

final geo = GeoJson();
/// `polygon` is the [GeoJsonPolygon] to check
/// `points` is the list of [GeoJsonPoint] to search in
await geo.geofencePolygon(polygon: polygon, points: points);
 List<GeoPoint> foundPoints = geo.points;

Note: the processedPoints stream is available to retrieve geofenced points as soon as they are found

Maps

To draw geojson data on a map check the Map controller package

Supported geojson features

All the data structures use GeoPoint and GeoSerie from the GeoPoint package to store the geometry data. Data structures used:

GeoJsonFeatureCollection:

  • String name
  • List<GeoJsonFeature> collection

GeoJsonFeature:

  • GeoJsonFeatureType type: types

  • Map<String, dynamic> properties: the json properties of the feature

  • dynamic geometry: the geometry data, depends on the feature type, see below

GeoJsonPoint:

  • String name
  • GeoPoint geoPoint: the geometry data

GeoJsonMultiPoint:

  • String name
  • GeoSerie geoSerie: the geometry data: this will produce a geoSerie of type GeoSerieType.group

GeoJsonLine:

  • String name
  • GeoSerie geoSerie: the geometry data: this will produce a geoSerie of type GeoSerieType.line

GeoJsonMultiLine:

  • String name
  • List<GeoJsonLine> lines

GeoJsonPolygon:

  • String name
  • List<GeoSerie> geoSeries: the geometry data: this will produce a list of geoSerie of type GeoSerieType.polygon*

GeoJsonMultiPolygon:

  • String name
  • List<GeoJsonPolygon> polygons

GeoJsonGeometryCollection:

  • String name
  • List<GeoJsonFeature> geometries

Note: none of the parameters is final for all of these data structures

카테고리

의존성

의존성 목록 4 개

  • geodesy^0.4.0-nullsafety.0
  • geopoint^1.0.0
  • iso^1.0.0
  • pedantic^1.11.1

소스 저장소

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