diff --git a/README.md b/README.md index 2b50695..621ee30 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Rugreefer -**Rugreefer** is a Dart library for retrieving metadata about geographic coordinates from a **dopecarpet** server. It converts coordinates into a geohash, fetches a gzipped GeoJSON file from the API, and extracts relevant spatial data such as polygons and lines. The library also supports caching with optional expiration to improve performance. +**Rugreefer** is a Dart library for retrieving metadata about geographic coordinates from a [dopecarpet](http://github.com/TheRandonauts/dopecarpet) server. It converts coordinates into a geohash, fetches a gzipped GeoJSON file from the API, and extracts relevant spatial data such as polygons and lines. The library also supports caching with optional expiration to improve performance. ## Features - Converts latitude/longitude to geohash (precision: 4 characters) @@ -32,7 +32,7 @@ flutter pub get import 'package:rugreefer/rugreefer.dart'; void main() async { - final lookup = GeoMetadataLookup( + final lookup = RugReefer( apiUrl: 'http://localhost:8000/get_geodata/?format=geojson&geohash=', enableCacheExpiration: true, ); @@ -44,39 +44,12 @@ void main() async { ### **Custom Cache Settings** ```dart -final lookup = GeoMetadataLookup( +final lookup = RugReefer( apiUrl: 'http://your-api.com/get_geodata/?format=geojson&geohash=', enableCacheExpiration: true, cacheExpirationDuration: Duration(days: 7), ); ``` -## API Reference - -### **`GeoMetadataLookup` Constructor** -```dart -GeoMetadataLookup({ - required String apiUrl, - bool enableCacheExpiration = false, - Duration cacheExpirationDuration = const Duration(days: 14), -}); -``` - -### **Methods** -#### **`lookup(double latitude, double longitude, {double distanceThreshold = 10.0})`** -- Fetches and processes metadata for a given coordinate. -- **Returns:** `Future>>` - -#### **`enableCacheExpiration` (bool)** -- Enables or disables automatic cache cleanup. - -#### **`cacheExpirationDuration` (Duration)** -- Specifies how long cached files are kept before deletion. - -## Changes in Data Handling -- The library now ensures compatibility with **Point** instead of **Position** for `booleanPointInPolygon` and `_isPointNearLine`. -- Web caching uses `SharedPreferences`, while file-based caching is used on other platforms. -- `lookup()` internally converts coordinates into `Point(coordinates: [longitude, latitude])`. - ## Author [@randogoth](https://github.com/randogoth) \ No newline at end of file diff --git a/lib/rugreefer.dart b/lib/rugreefer.dart index 9072223..6fa64ac 100644 --- a/lib/rugreefer.dart +++ b/lib/rugreefer.dart @@ -7,14 +7,14 @@ import 'package:path_provider/path_provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter/foundation.dart' show kIsWeb; -class GeoMetadataLookup { +class RugReefer { final String apiUrl; final bool enableCacheExpiration; final Duration cacheExpirationDuration; final http.Client httpClient; Directory? cacheDir; - GeoMetadataLookup({ + RugReefer({ required this.apiUrl, this.enableCacheExpiration = false, this.cacheExpirationDuration = const Duration(days: 14),