readme and rename
This commit is contained in:
parent
7409b9d4cd
commit
040f592ca2
2 changed files with 5 additions and 32 deletions
33
README.md
33
README.md
|
|
@ -1,6 +1,6 @@
|
||||||
# Rugreefer
|
# 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
|
## Features
|
||||||
- Converts latitude/longitude to geohash (precision: 4 characters)
|
- Converts latitude/longitude to geohash (precision: 4 characters)
|
||||||
|
|
@ -32,7 +32,7 @@ flutter pub get
|
||||||
import 'package:rugreefer/rugreefer.dart';
|
import 'package:rugreefer/rugreefer.dart';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
final lookup = GeoMetadataLookup(
|
final lookup = RugReefer(
|
||||||
apiUrl: 'http://localhost:8000/get_geodata/?format=geojson&geohash=',
|
apiUrl: 'http://localhost:8000/get_geodata/?format=geojson&geohash=',
|
||||||
enableCacheExpiration: true,
|
enableCacheExpiration: true,
|
||||||
);
|
);
|
||||||
|
|
@ -44,39 +44,12 @@ void main() async {
|
||||||
|
|
||||||
### **Custom Cache Settings**
|
### **Custom Cache Settings**
|
||||||
```dart
|
```dart
|
||||||
final lookup = GeoMetadataLookup(
|
final lookup = RugReefer(
|
||||||
apiUrl: 'http://your-api.com/get_geodata/?format=geojson&geohash=',
|
apiUrl: 'http://your-api.com/get_geodata/?format=geojson&geohash=',
|
||||||
enableCacheExpiration: true,
|
enableCacheExpiration: true,
|
||||||
cacheExpirationDuration: Duration(days: 7),
|
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
|
## Author
|
||||||
[@randogoth](https://github.com/randogoth)
|
[@randogoth](https://github.com/randogoth)
|
||||||
|
|
@ -7,14 +7,14 @@ import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||||
|
|
||||||
class GeoMetadataLookup {
|
class RugReefer {
|
||||||
final String apiUrl;
|
final String apiUrl;
|
||||||
final bool enableCacheExpiration;
|
final bool enableCacheExpiration;
|
||||||
final Duration cacheExpirationDuration;
|
final Duration cacheExpirationDuration;
|
||||||
final http.Client httpClient;
|
final http.Client httpClient;
|
||||||
Directory? cacheDir;
|
Directory? cacheDir;
|
||||||
|
|
||||||
GeoMetadataLookup({
|
RugReefer({
|
||||||
required this.apiUrl,
|
required this.apiUrl,
|
||||||
this.enableCacheExpiration = false,
|
this.enableCacheExpiration = false,
|
||||||
this.cacheExpirationDuration = const Duration(days: 14),
|
this.cacheExpirationDuration = const Duration(days: 14),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue