readme and rename

This commit is contained in:
randogoth 2025-02-27 23:14:03 +02:00
parent 7409b9d4cd
commit 040f592ca2
2 changed files with 5 additions and 32 deletions

View file

@ -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<List<Map<String, dynamic>>>`
#### **`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)

View file

@ -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),