A map_survey-ben a bemért pontok mentése és elküldése. Hibajavítás: a field_trip-ben vonalak és területek megjelenítése szerkesztés után.
This commit is contained in:
parent
ee4fd6d059
commit
688922808b
@ -3,6 +3,7 @@ import 'package:flutter_map/flutter_map.dart';
|
|||||||
import 'package:flutter_map_polygon_editor/polygon_editor/polygon_editor_controller.dart';
|
import 'package:flutter_map_polygon_editor/polygon_editor/polygon_editor_controller.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:latlong2/latlong.dart';
|
import 'package:latlong2/latlong.dart';
|
||||||
|
import 'package:geolocator/geolocator.dart';
|
||||||
|
|
||||||
class FieldTripController extends GetxController {
|
class FieldTripController extends GetxController {
|
||||||
RxBool mapIsInitialized = false.obs;
|
RxBool mapIsInitialized = false.obs;
|
||||||
@ -25,7 +26,17 @@ class FieldTripController extends GetxController {
|
|||||||
// TODO: implement onInit
|
// TODO: implement onInit
|
||||||
super.onInit();
|
super.onInit();
|
||||||
|
|
||||||
|
LatLng initialCenter = const LatLng(47.5, 19.0);
|
||||||
|
try {
|
||||||
|
final last = await Geolocator.getLastKnownPosition();
|
||||||
|
if (last != null) {
|
||||||
|
initialCenter = LatLng(last.latitude, last.longitude);
|
||||||
|
}
|
||||||
|
} catch (_) {}
|
||||||
|
|
||||||
mapOptions = MapOptions(
|
mapOptions = MapOptions(
|
||||||
|
initialCenter: initialCenter,
|
||||||
|
initialZoom: 13,
|
||||||
onLongPress: (tapPosition, point) {
|
onLongPress: (tapPosition, point) {
|
||||||
if (mapInEditorMode.value) {
|
if (mapInEditorMode.value) {
|
||||||
polygonEditorController.addPoint(point);
|
polygonEditorController.addPoint(point);
|
||||||
@ -94,9 +105,10 @@ class FieldTripController extends GetxController {
|
|||||||
print("Points number in line: ${polygonEditorController.points.length}");
|
print("Points number in line: ${polygonEditorController.points.length}");
|
||||||
print(
|
print(
|
||||||
"1. point coords: ${polygonEditorController.points[0].latitude} - ${polygonEditorController.points[0].longitude}");
|
"1. point coords: ${polygonEditorController.points[0].latitude} - ${polygonEditorController.points[0].longitude}");
|
||||||
|
if (polygonEditorController.points.length < 2) return;
|
||||||
|
|
||||||
Polyline polyline = Polyline(
|
Polyline polyline = Polyline(
|
||||||
points: polygonEditorController.points,
|
points: List.from(polygonEditorController.points),
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
strokeWidth: 8,
|
strokeWidth: 8,
|
||||||
// hitValue: (
|
// hitValue: (
|
||||||
@ -119,7 +131,7 @@ class FieldTripController extends GetxController {
|
|||||||
"Points number in polygon: ${polygonEditorController.points.length}");
|
"Points number in polygon: ${polygonEditorController.points.length}");
|
||||||
|
|
||||||
Polygon polygon = Polygon(
|
Polygon polygon = Polygon(
|
||||||
points: polygonEditorController.points,
|
points: List.from(polygonEditorController.points),
|
||||||
color: Colors.purple,
|
color: Colors.purple,
|
||||||
borderColor: Colors.yellow,
|
borderColor: Colors.yellow,
|
||||||
borderStrokeWidth: 4,
|
borderStrokeWidth: 4,
|
||||||
@ -131,8 +143,8 @@ class FieldTripController extends GetxController {
|
|||||||
);
|
);
|
||||||
|
|
||||||
polygonNotes.add(polygon);
|
polygonNotes.add(polygon);
|
||||||
polygonNotes.refresh();
|
//polygonNotes.refresh();
|
||||||
update();
|
//update();
|
||||||
|
|
||||||
print("Points number in polygonNotes: ${polygonNotes.length}");
|
print("Points number in polygonNotes: ${polygonNotes.length}");
|
||||||
|
|
||||||
|
|||||||
@ -39,14 +39,15 @@ class FieldTripView extends GetView<FieldTripController> {
|
|||||||
CurrentLocationLayer(
|
CurrentLocationLayer(
|
||||||
alignPositionOnUpdate: AlignOnUpdate.once,
|
alignPositionOnUpdate: AlignOnUpdate.once,
|
||||||
),
|
),
|
||||||
MarkerLayer(markers: controller.pointNotes),
|
Obx(() =>
|
||||||
PolylineLayer(
|
MarkerLayer(markers: [...controller.pointNotes])),
|
||||||
polylines: controller.polylineNotes,
|
Obx(() => PolylineLayer(
|
||||||
),
|
polylines: [...controller.polylineNotes],
|
||||||
PolygonLayer(
|
)),
|
||||||
polygons: controller.polygonNotes,
|
Obx(() => PolygonLayer(
|
||||||
useAltRendering: true,
|
polygons: [...controller.polygonNotes],
|
||||||
),
|
useAltRendering: true,
|
||||||
|
)),
|
||||||
// PolylineLayer(polylines: [
|
// PolylineLayer(polylines: [
|
||||||
// Polyline(
|
// Polyline(
|
||||||
// points: [
|
// points: [
|
||||||
|
|||||||
@ -19,6 +19,7 @@ import 'package:nmea/nmea.dart';
|
|||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart'
|
import 'package:permission_handler/permission_handler.dart'
|
||||||
as permission_handler;
|
as permission_handler;
|
||||||
|
import 'package:share_plus/share_plus.dart';
|
||||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||||
import 'package:terepi_seged/eov/convert_coordinate.dart';
|
import 'package:terepi_seged/eov/convert_coordinate.dart';
|
||||||
import 'package:terepi_seged/eov/eov.dart';
|
import 'package:terepi_seged/eov/eov.dart';
|
||||||
@ -30,6 +31,7 @@ import 'package:terepi_seged/models/point_with_description_model.dart';
|
|||||||
import 'package:proj4dart/proj4dart.dart' as proj4;
|
import 'package:proj4dart/proj4dart.dart' as proj4;
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:terepi_seged/pages/map_survey/presentations/views/measured_points_table_dialog.dart';
|
import 'package:terepi_seged/pages/map_survey/presentations/views/measured_points_table_dialog.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
class MapSurveyController extends GetxController {
|
class MapSurveyController extends GetxController {
|
||||||
// String gpsAddress = "E8:31:CD:14:8B:B2";
|
// String gpsAddress = "E8:31:CD:14:8B:B2";
|
||||||
@ -873,4 +875,61 @@ class MapSurveyController extends GetxController {
|
|||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SaveMeasuredPointsToFile() async {
|
||||||
|
// var pointsDirectory = await getExternalStorageDirectory();
|
||||||
|
var pointsDirectory = await getApplicationDocumentsDirectory();
|
||||||
|
print(directory!.path);
|
||||||
|
// String newPath = '';
|
||||||
|
// List<String> folders = directory!.path.split("/");
|
||||||
|
// for (int i = 1; i < folders.length; i++) {
|
||||||
|
// String folder = folders[i];
|
||||||
|
// if (folder != "Android") {
|
||||||
|
// newPath += "/" + folder;
|
||||||
|
// } else {
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// newPath = newPath + "/TerepisSegedApp";
|
||||||
|
// directory = Directory(newPath);
|
||||||
|
if (!await pointsDirectory!.exists()) {
|
||||||
|
await pointsDirectory.create(recursive: true);
|
||||||
|
}
|
||||||
|
var oldMeasuredPointsFile = File("${directory!.path}/measuredsPoints.csv");
|
||||||
|
|
||||||
|
if (await oldMeasuredPointsFile.exists()) {
|
||||||
|
await oldMeasuredPointsFile.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
var measuredPointsFile =
|
||||||
|
await File("${directory!.path}/measuredsPoints.csv").create();
|
||||||
|
|
||||||
|
if (await pointsDirectory.exists()) {
|
||||||
|
if (await measuredPointsFile.exists()) {
|
||||||
|
await measuredPointsFile.writeAsString(
|
||||||
|
"Id;DateTime;Description;EovX;EovY;Altitude;Hor.Err;Vert.Err\r\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = await readMeasuredPoints();
|
||||||
|
|
||||||
|
data.forEach((d) {
|
||||||
|
measuredPointsFile.writeAsStringSync(
|
||||||
|
"${d['id']};${d['created_at']};${d['description']};${formatEov.format(d['eovY'])};${formatEov.format(d['eovX'])};${formatEovZ.format(d['altitude'] - d['poleHeight'])};${formatAltitudeError.format(d['horizontalError'])};${formatAltitudeError.format(d['verticalError'])}\r\n",
|
||||||
|
flush: true,
|
||||||
|
mode: FileMode.append,
|
||||||
|
encoding: utf8);
|
||||||
|
});
|
||||||
|
|
||||||
|
print('Number of data: ${data.length}');
|
||||||
|
|
||||||
|
final params = ShareParams(
|
||||||
|
text: "Mérési eredmények",
|
||||||
|
// files: [XFile('$measuredPointsFile')],
|
||||||
|
files: [XFile("${directory!.path}/measuredsPoints.csv")],
|
||||||
|
subject: 'Mérési eredmények',
|
||||||
|
title: 'Mérési eredmények');
|
||||||
|
|
||||||
|
final result = await SharePlus.instance.share(params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,6 +22,14 @@ class MeasuredPointsTableDialog extends StatelessWidget {
|
|||||||
Get.back();
|
Get.back();
|
||||||
},
|
},
|
||||||
icon: const Icon(Icons.close)),
|
icon: const Icon(Icons.close)),
|
||||||
|
SizedBox(
|
||||||
|
width: 10,
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
controller.SaveMeasuredPointsToFile();
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.save)),
|
||||||
TextButton(
|
TextButton(
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
overlayColor:
|
overlayColor:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user