mod divers data
This commit is contained in:
@@ -5,17 +5,6 @@ class Environment {
|
||||
static const String appwriteProjectName = 'Flutter Projects';
|
||||
static const String appwriteRealtimeCollectionId = '68a22f520035a95d6666';
|
||||
static const String appwriteDatabaseId = '68a22ef90021b90f0f43';
|
||||
static const String ptvApiKey =
|
||||
'NTYxMDQ3NTY2OWI3NDI5ZGIzZWIxOWNiNTNhMDEwODY6YTQ4MTJhYzYtYmYzOC00ZmE4LTk4YzYtZDBjNzYyZTAyNjBk';
|
||||
static const String locationIQKey = 'pk.dea65023dc6fed25c96902bb97fb231d';
|
||||
static const double lat=47.93875449671056;
|
||||
static const double lon=13.762706553431048;
|
||||
//https://eu1.locationiq.com/v1/reverse?key=pk.dea65023dc6fed25c96902bb97fb231d&lat=47.93875449671056&lon=13.762706553431048&format=json
|
||||
static const String locationIQBaseUrl =
|
||||
'https://eu1.locationiq.com/v1/reverse?key=$locationIQKey&'; //47.93875449671056, 13.762706553431048
|
||||
static const String ptvApiVersion = '3';
|
||||
// Lokaler Reverse Proxy für Entwicklung (CORS-Workaround)
|
||||
static const String localProxyUrl = 'http://localhost:3000';
|
||||
static const bool useLocalProxy =
|
||||
true; // true = lokaler Proxy, false = Appwrite Function
|
||||
static const String locationIQBaseUrl = 'https://eu1.locationiq.com/v1/reverse?key=$locationIQKey&';
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter_tank_web_app/services/appwrite_service.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../models/tank_model.dart';
|
||||
import '../pages/edit_view.dart';
|
||||
import '../services/appwrite_service.dart';
|
||||
|
||||
class DetailController extends GetxController {
|
||||
late TankModel tank;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
|
||||
import '../models/locationiq_model.dart';
|
||||
import '../models/tank_model.dart';
|
||||
import '../services/appwrite_service.dart';
|
||||
@@ -62,78 +61,6 @@ class EditController extends GetxController {
|
||||
'${now.year}-${now.month.toString().padLeft(2, '0')}-${now.day.toString().padLeft(2, '0')}';
|
||||
}
|
||||
|
||||
// Future<void> _requestLocation() async {
|
||||
// bool serviceEnabled;
|
||||
// LocationPermission permission;
|
||||
|
||||
// try {
|
||||
// isLoadingLocation.value = true;
|
||||
|
||||
// // 1. Prüfen, ob Standortdienste aktiviert sind
|
||||
// serviceEnabled = await Geolocator.isLocationServiceEnabled();
|
||||
// if (!serviceEnabled) {
|
||||
// return Future.error('Standortdienste sind deaktiviert.');
|
||||
// }
|
||||
|
||||
// // 2. Berechtigungen prüfen
|
||||
// permission = await Geolocator.checkPermission();
|
||||
// if (permission == LocationPermission.denied) {
|
||||
// permission = await Geolocator.requestPermission();
|
||||
// if (permission == LocationPermission.denied) {
|
||||
// return Future.error('Berechtigung verweigert.');
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 3. Position abrufen
|
||||
// Position position = await Geolocator.getCurrentPosition(
|
||||
// locationSettings: const LocationSettings(
|
||||
// accuracy: LocationAccuracy.high,
|
||||
// ),
|
||||
// );
|
||||
|
||||
// // 4. Standort über Backend-Proxy abrufen
|
||||
// var lat = position.latitude;
|
||||
// var lon = position.longitude;
|
||||
|
||||
// print('📍 Verwende Backend-Proxy für Geocoding...');
|
||||
// String location = await appwriteService.geocodeLocation(lat, lon);
|
||||
// locationController.text = location;
|
||||
|
||||
// // Info anzeigen basierend auf Ergebnis
|
||||
// if (location.startsWith('Lat:')) {
|
||||
// Get.snackbar(
|
||||
// 'Hinweis',
|
||||
// 'Adresse konnte nicht abgerufen werden. Koordinaten gespeichert.',
|
||||
// snackPosition: SnackPosition.BOTTOM,
|
||||
// backgroundColor: Colors.orange[100],
|
||||
// colorText: Colors.orange[900],
|
||||
// duration: const Duration(seconds: 3),
|
||||
// );
|
||||
// } else {
|
||||
// Get.snackbar(
|
||||
// 'Erfolg',
|
||||
// 'Standort: $location',
|
||||
// snackPosition: SnackPosition.BOTTOM,
|
||||
// backgroundColor: Colors.green[100],
|
||||
// colorText: Colors.green[900],
|
||||
// duration: const Duration(seconds: 2),
|
||||
// );
|
||||
// }
|
||||
// } catch (e) {
|
||||
// Get.snackbar(
|
||||
// "Fehler",
|
||||
// "Standort konnte nicht abgerufen werden: $e",
|
||||
// snackPosition: SnackPosition.BOTTOM,
|
||||
// backgroundColor: Colors.red[100],
|
||||
// colorText: Colors.red[900],
|
||||
// );
|
||||
// print("Fehler beim Abrufen des Standorts: $e");
|
||||
// locationController.text = '';
|
||||
// } finally {
|
||||
// isLoadingLocation.value = false;
|
||||
// }
|
||||
// }
|
||||
|
||||
Future<void> _requestLocationIQ() async {
|
||||
bool serviceEnabled;
|
||||
LocationPermission permission;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter_tank_web_app/models/tank_model.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../models/tank_model.dart';
|
||||
|
||||
class GraphController extends GetxController {
|
||||
final listTankModel = <TankModel>[].obs;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
//import 'dart:convert';
|
||||
|
||||
import 'package:appwrite/models.dart';
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
//import 'package:http/http.dart' as http;
|
||||
import '../config/environment.dart';
|
||||
|
||||
class AppwriteService {
|
||||
@@ -167,47 +166,4 @@ class AppwriteService {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// // Geocode coordinates using local proxy or Appwrite Function
|
||||
// Future<String> geocodeLocation(double lat, double lon) async {
|
||||
// // Wenn lokaler Proxy aktiviert ist, diesen verwenden
|
||||
// if (Environment.useLocalProxy) {
|
||||
// return _geocodeViaLocalProxy(lat, lon);
|
||||
// }
|
||||
|
||||
// // Fallback: Koordinaten zurückgeben
|
||||
// return 'Lat: ${lat.toStringAsFixed(6)}, Lon: ${lon.toStringAsFixed(6)}';
|
||||
// }
|
||||
|
||||
// // Geocoding über lokalen Reverse Proxy
|
||||
// Future<String> _geocodeViaLocalProxy(double lat, double lon) async {
|
||||
// try {
|
||||
// final proxyUrl = '${Environment.localProxyUrl}/?lat=$lat&lon=$lon&apiKey=${Environment.ptvApiKey}';
|
||||
|
||||
// print('🔄 Verwende lokalen Proxy: ${Environment.localProxyUrl}');
|
||||
|
||||
// final response = await http.get(Uri.parse(proxyUrl));
|
||||
|
||||
// if (response.statusCode == 200) {
|
||||
// final data = jsonDecode(response.body);
|
||||
|
||||
// if (data['success'] == true) {
|
||||
// final location = data['location'] as String;
|
||||
// print('✅ Geocoding erfolgreich (Proxy): $location');
|
||||
// return location;
|
||||
// } else {
|
||||
// print('❌ Geocoding fehlgeschlagen (Proxy): ${data['error']}');
|
||||
// return data['fallbackLocation'] ??
|
||||
// 'Lat: ${lat.toStringAsFixed(6)}, Lon: ${lon.toStringAsFixed(6)}';
|
||||
// }
|
||||
// } else {
|
||||
// print('⚠️ Proxy Response Status: ${response.statusCode}');
|
||||
// return 'Lat: ${lat.toStringAsFixed(6)}, Lon: ${lon.toStringAsFixed(6)}';
|
||||
// }
|
||||
// } catch (e) {
|
||||
// print('❌ Lokaler Proxy nicht erreichbar: $e');
|
||||
// print('💡 Tipp: Starten Sie den Proxy mit: cd proxy-server && node server.js');
|
||||
// return 'Lat: ${lat.toStringAsFixed(6)}, Lon: ${lon.toStringAsFixed(6)}';
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -1,21 +1,16 @@
|
||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:convert';
|
||||
|
||||
import '../config/environment.dart';
|
||||
import '../models/locationiq_model.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class LocationIQService {
|
||||
static final String baseUrl = Environment.locationIQBaseUrl;
|
||||
late LocationIQ locationIQ;
|
||||
|
||||
Future<void> fetchLocationIQ(double lat, double lon) async {
|
||||
// Hier würde die eigentliche API-Anfrage an LocationIQ erfolgen
|
||||
// Zum Beispiel mit http.get() und der URL aus Environment.locationIQUrl
|
||||
// Die Antwort würde dann in das LocationIQ-Modell umgewandelt werden
|
||||
// https://eu1.locationiq.com/v1/reverse?key=$locationIQKey&lat=47.93875449671056&lon=13.762706553431048&format=json
|
||||
// locationIQ = LocationIQ.fromJson(responseData);
|
||||
// Simulierte Antwort (für Testzwecke)
|
||||
locationIQ = LocationIQ(
|
||||
placeId: '12345',
|
||||
|
||||
Reference in New Issue
Block a user