diff --git a/app/lib/pages/default_page.dart b/app/lib/pages/default_page.dart index 7d4830e90ccb156dd6aaa8da0932b33e73c89686..150adf275bf249635d7f6035904dd9ab4abc85aa 100644 --- a/app/lib/pages/default_page.dart +++ b/app/lib/pages/default_page.dart @@ -1,6 +1,7 @@ import 'dart:async'; -import 'package:flutter/material.dart'; import 'dart:typed_data'; +import 'package:fuzzy/fuzzy.dart'; +import 'package:flutter/material.dart'; import '../consts.dart'; import 'loading_page.dart'; @@ -25,6 +26,26 @@ class _DefaultPageState extends State<DefaultPage> { late Future<List<Measurement>> markerListFuture; late Future<Uint8List> relationFuture; + late List<String> testSearchNames = [ + "Mjøsa", + "Bogstadsvannet", + "Einavatnet", + "Femsjøen", + "Femunden", + "Fjellsjøen", + "Gjende", + "Gjersjøen" + ]; + // Searching function for lake names using Fuzzy library + List<String> searchLakeNames(String query) { + final options = FuzzyOptions(threshold: 0.3, findAllMatches: true); + final matcher = Fuzzy(testSearchNames, options: options); + final results = matcher.search(query); + + // Extracting lake names from the results and casting them to strings + return results.map((result) => result.item as String).toList(); + } + @override void initState() { super.initState(); diff --git a/app/pubspec.lock b/app/pubspec.lock index 1e7728945e251625cd3e67a58f210351b54ea845..73538620a0a9ffeefd9ba57ea9b53da96d8dabc0 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -120,6 +120,14 @@ packages: description: flutter source: sdk version: "0.0.0" + fuzzy: + dependency: "direct main" + description: + name: fuzzy + sha256: af5fbd36f2f8de0663a5b562ef5ca209aea957e81a2f0e97f97475cfbed044ec + url: "https://pub.dev" + source: hosted + version: "0.5.1" google_fonts: dependency: "direct main" description: @@ -453,6 +461,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" + stringr: + dependency: transitive + description: + name: stringr + sha256: "2846b6811c3cbb34c8937a35e623986e3fbf7203b3bb33ffe7f80e496ea3eff2" + url: "https://pub.dev" + source: hosted + version: "1.0.0" syncfusion_flutter_core: dependency: "direct main" description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 342332141b76348b360cf5fba965bc78079b807d..c87dfe4687ef61b2a1849409c71d948d5a22c588 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -16,9 +16,10 @@ dependencies: fl_chart: ^0.20.0-nullsafety1 # Charts and diagrams google_fonts: any # Fonts syncfusion_flutter_maps: ^20.4.41 # Choropleth map_handler - syncfusion_flutter_core: any # Choropleth shape selection + syncfusion_flutter_core: any # Choropleth shape selection path_provider: ^2.0.8 shared_preferences: any # Persistent data storage + fuzzy: any # Search algorithm dev_dependencies: flutter_test: diff --git a/server/map_handler/__pycache__/add_new_lake.cpython-311.pyc b/server/map_handler/__pycache__/add_new_lake.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1ebfb30e892fc06a0ebe716236c82ae01c6ae030 Binary files /dev/null and b/server/map_handler/__pycache__/add_new_lake.cpython-311.pyc differ diff --git a/server/map_handler/lake_relations/all_system_relations.txt b/server/map_handler/lake_relations/all_system_relations.txt new file mode 100644 index 0000000000000000000000000000000000000000..6a20bd4ab252d2b49eb5b1c23bc9aff62a24b9f3 --- /dev/null +++ b/server/map_handler/lake_relations/all_system_relations.txt @@ -0,0 +1,2 @@ +Mjøsa - mjosa +TestLake - testlake \ No newline at end of file