Bemérés nézet: pont bemérése, törlése, lista, mentés sqlite-ba, exportálás
This commit is contained in:
@@ -2,7 +2,7 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
import 'dart:math' as math;
|
||||
//import 'dart:math' as math;
|
||||
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -28,6 +28,7 @@ import 'package:terepi_seged/enums/map_survey_mode.dart';
|
||||
import 'package:terepi_seged/enums/note_type.dart';
|
||||
import 'package:terepi_seged/eov/convert_coordinate.dart';
|
||||
import 'package:terepi_seged/eov/eov.dart';
|
||||
import 'package:terepi_seged/models/measured_point.dart';
|
||||
import 'package:terepi_seged/models/note_item.dart';
|
||||
import 'package:terepi_seged/models/point_to_measure.dart';
|
||||
import 'package:terepi_seged/models/point_with_description_model.dart';
|
||||
@@ -47,6 +48,8 @@ import 'package:terepi_seged/widgets/map/imported_layer_overlay.dart';
|
||||
import 'package:terepi_seged/widgets/map_edit_tools/map_feature_save_sheet.dart';
|
||||
import 'package:terepi_seged/widgets/shared_map_widgets.dart';
|
||||
|
||||
import '../views/measured_points_sheet.dart';
|
||||
|
||||
class MapSurveyController extends GetxController {
|
||||
static MapSurveyController get to => Get.find();
|
||||
|
||||
@@ -274,6 +277,7 @@ class MapSurveyController extends GetxController {
|
||||
ever(ProjectService.to.activeProject, (_) => _loadNoteItems());
|
||||
|
||||
await _loadNoteItems();
|
||||
await _loadMeasurePoints();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -719,9 +723,9 @@ class MapSurveyController extends GetxController {
|
||||
'heightOfGeoid': _gnss.geoidSeparation.value,
|
||||
'eovX': eov.value.X,
|
||||
'eovY': eov.value.Y,
|
||||
'eovZ': eovHeight.value,
|
||||
'poleHeight': double.tryParse(gpsHeightController.text),
|
||||
'horizontalError':
|
||||
max(_gnss.latitudeError.value, _gnss.longitudeError.value),
|
||||
'horizontalError': _gnss.horizontalAccuracy,
|
||||
'verticalError': _gnss.altitudeError.value,
|
||||
'description': pointDescriptionController.text,
|
||||
'isDeleted': false,
|
||||
@@ -732,6 +736,26 @@ class MapSurveyController extends GetxController {
|
||||
.from('TerepiSeged_Receiver')
|
||||
.update({'isMeasured': true}).eq('pointNumber', pointId);
|
||||
|
||||
// SQLite mentés
|
||||
final projectId = ProjectService.to.activeProjectId;
|
||||
if (projectId != null) {
|
||||
await AppDatabase.instance.insertMeasuredPoint(MeasuredPoint(
|
||||
projectId: projectId,
|
||||
name: pointId.toString(),
|
||||
eovY: eov.value.Y,
|
||||
eovX: eov.value.X,
|
||||
eovZ: eovHeight.value! -
|
||||
(double.tryParse(gpsHeightController.text) ?? 0.0),
|
||||
latitude: _gnss.latitude.value,
|
||||
longitude: _gnss.longitude.value,
|
||||
altitude: _gnss.altitude.value,
|
||||
accuracy: _gnss.horizontalAccuracy,
|
||||
fixQuality: _gnss.gpsQuality.value,
|
||||
timestamp: DateTime.now(),
|
||||
note: pointDescriptionController.text,
|
||||
));
|
||||
}
|
||||
|
||||
// Következő pont léptetése
|
||||
_advancePointSelection();
|
||||
|
||||
@@ -1243,6 +1267,51 @@ class MapSurveyController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _loadMeasurePoints() async {
|
||||
final projectId = ProjectService.to.activeProject.value?.id;
|
||||
|
||||
pointNotesMarker.clear();
|
||||
pointWithDescriptionList.clear();
|
||||
|
||||
if (projectId == null) return;
|
||||
|
||||
final points = await AppDatabase.instance.listMeasuredPoints(projectId);
|
||||
|
||||
for (final pt in points) {
|
||||
if (pt.latitude != null && pt.longitude != null) {
|
||||
pointNotesMarker.add(Marker(
|
||||
point: LatLng(pt.latitude!, pt.longitude!),
|
||||
width: 15.0,
|
||||
height: 15.0,
|
||||
child: Container(
|
||||
width: 15.0,
|
||||
height: 15.0,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.amber[700],
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(width: 1.0, color: Colors.black)),
|
||||
)));
|
||||
}
|
||||
pointWithDescriptionList.add(PointWithDescription(
|
||||
int.tryParse(pt.name) ?? 0,
|
||||
pt.timestamp,
|
||||
pt.note,
|
||||
pt.eovY ?? 0.0,
|
||||
pt.eovX ?? 0.0,
|
||||
pt.latitude ?? 0.0,
|
||||
pt.longitude ?? 0.0,
|
||||
pt.accuracy ?? 0.0,
|
||||
0.0));
|
||||
}
|
||||
|
||||
if (points.isNotEmpty) {
|
||||
final maxId = points
|
||||
.map((p) => int.tryParse(p.name) ?? 0)
|
||||
.fold(0, (prev, id) => id > prev ? id : prev);
|
||||
pointId = maxId + 1;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> finishDraft() async {
|
||||
if (editingNoteItemId != null) {
|
||||
if (polygonEditorController.points.isEmpty) {
|
||||
@@ -1702,4 +1771,20 @@ class MapSurveyController extends GetxController {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void openMeasuredPointsList() {
|
||||
Get.bottomSheet(
|
||||
DraggableScrollableSheet(
|
||||
initialChildSize: 0.6,
|
||||
minChildSize: 0.4,
|
||||
maxChildSize: 0.92,
|
||||
snap: true,
|
||||
expand: false,
|
||||
builder: (_, __) => const MeasuredPointsSheet(),
|
||||
),
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
ignoreSafeArea: false,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user