feat: partial broken guesture detection
This commit is contained in:
@ -2,7 +2,7 @@ import 'package:anyhow/anyhow.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:geojson_vi/geojson_vi.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
|
||||
part 'model.freezed.dart';
|
||||
@ -15,27 +15,30 @@ class Feature with _$Feature {
|
||||
required String name,
|
||||
required FeatureType type,
|
||||
String? description,
|
||||
required dynamic geometry,
|
||||
required GeoJSONGeometry geometry,
|
||||
int? level,
|
||||
}) = _Feature;
|
||||
|
||||
bool isPolygon() {
|
||||
return geometry is GeoJsonFeature<GeoJsonPolygon>;
|
||||
return geometry is GeoJSONPolygon;
|
||||
}
|
||||
|
||||
bool isPoint() {
|
||||
return geometry is GeoJsonFeature<GeoJsonPoint>;
|
||||
return geometry is GeoJSONPoint;
|
||||
}
|
||||
|
||||
Result<Polygon> getPolygon({Polygon Function(List<LatLng>)? constructor}) {
|
||||
if (isPolygon()) {
|
||||
constructor ??= (pts) => Polygon(
|
||||
points: pts, borderColor: Colors.black26, borderStrokeWidth: 2.0);
|
||||
final polygon = geometry as GeoJsonFeature<GeoJsonPolygon>;
|
||||
points: pts,
|
||||
borderColor: Colors.black26,
|
||||
borderStrokeWidth: 2.0,
|
||||
);
|
||||
final polygon = geometry as GeoJSONPolygon;
|
||||
// print(polygon.geometry!.geoSeries[0].geoPoints);
|
||||
final points = polygon.geometry!.geoSeries[0].geoPoints
|
||||
.map((e) => LatLng(e.latitude, e.longitude))
|
||||
.toList();
|
||||
final points =
|
||||
// polygon.coordinates[0].map((e) => LatLng(e[0], e[1])).toList();
|
||||
polygon.coordinates[0].map((e) => LatLng(e[1], e[0])).toList();
|
||||
|
||||
// print(points);
|
||||
return Ok(constructor(points));
|
||||
@ -46,9 +49,8 @@ class Feature with _$Feature {
|
||||
|
||||
Result<LatLng> getPoint() {
|
||||
if (isPoint()) {
|
||||
final point = geometry as GeoJsonFeature<GeoJsonPoint>;
|
||||
return Ok(LatLng(point.geometry!.geoPoint.latitude,
|
||||
point.geometry!.geoPoint.longitude));
|
||||
final point = geometry as GeoJSONPoint;
|
||||
return Ok(LatLng(point.coordinates[1], point.coordinates[0]));
|
||||
} else {
|
||||
return bail("Feature Geometry is not a Point");
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
import 'package:anyhow/anyhow.dart';
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:geojson_vi/geojson_vi.dart';
|
||||
import 'package:uninav/data/geo/model.dart';
|
||||
import 'package:yaml/yaml.dart';
|
||||
|
||||
Result<Feature> parseFeature(
|
||||
Map<String, dynamic> properties, dynamic geometry) {
|
||||
Map<String, dynamic> properties, GeoJSONGeometry geometry) {
|
||||
final name = properties['name'] as String?;
|
||||
final description_yaml = properties['description'] as String? ?? '';
|
||||
final layer = properties['layer'] as String?;
|
||||
|
Reference in New Issue
Block a user