Skip to content

Commit

Permalink
fix: Custom KML paths did not render properly. Fixed rendering. Also …
Browse files Browse the repository at this point in the history
…created algorithm for footprint path texture in KML.
  • Loading branch information
AritraBiswas9788 committed Jul 1, 2024
1 parent 9fa4564 commit a5b76d6
Show file tree
Hide file tree
Showing 10 changed files with 390 additions and 53 deletions.
1 change: 1 addition & 0 deletions lib/components/MapKmlElement.dart
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ class _MapkmlelementState extends State<Mapkmlelement> {
print("resetData");
points.clear();
points.add(widget.position.toLatLng());
widget.elementIndex=idx;
if (idx == 1) {
var p1 = widget.position.toLatLng();
p1 = LatLng(p1.latitude, p1.longitude + 2);
Expand Down
2 changes: 1 addition & 1 deletion lib/components/autocomplete_locationfield.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:super_liquid_galaxy_controller/utils/autocomplete_controller.dart';
import 'package:super_liquid_galaxy_controller/utils/galaxy_colors.dart';

import '../data_class/PlaceSuggestionResponse.dart';
import '../data_class/place_suggestion_response.dart';

class AutoCompleteLocationField extends StatefulWidget {
AutoCompleteLocationField(
Expand Down
27 changes: 23 additions & 4 deletions lib/components/navisland.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import 'package:flutter/material.dart';
import 'package:super_liquid_galaxy_controller/screens/kml_builder.dart';
import 'package:super_liquid_galaxy_controller/screens/maps_controller.dart';
import 'package:get/get.dart';
import 'package:super_liquid_galaxy_controller/utils/api_manager.dart';
import 'package:latlong2/latlong.dart';
import 'package:super_liquid_galaxy_controller/screens/test.dart';
import 'package:super_liquid_galaxy_controller/utils/kmlgenerator.dart';

import 'dart:math' as Math;
import '../generated/assets.dart';

//ignore_for_file: prefer_const_constructors
Expand Down Expand Up @@ -144,9 +148,24 @@ class NavIsland extends StatelessWidget {
color: Colors.transparent,
child: InkWell(
onTap: () async {
/*var manager = ApiManager.instance;
var response = await manager.getAutoCompleteResponse("How");
print(response.data);*/
/*LatLng centerPoint = LatLng(37.7749, -122.4194); // Example center point (San Francisco)
double length = 120.0; // Length of the footprint in meters
double width = 70.0; // Width of the footprint in meters
double angle = 0 * (Math.pi / 180); // Angle of rotation in radians (45 degrees in this case)
String kmlOutput = KMLGenerator.generateFootprintBottomPolygon(centerPoint, length, width, angle);
print(kmlOutput);*/
LatLng start = LatLng(1,6);
LatLng end = LatLng(5, 3);

double dashLength = 10000.0; // Length of each dash in meters
double gapLength = 5000.0; // Length of gap between dashes in meters

String kmlOutput = KMLGenerator.generatefootPrintLine(end,start, dashLength, gapLength);
print(kmlOutput.length);

print(kmlOutput);
Get.to(()=>TestScreen(kml: kmlOutput));
},
borderRadius: BorderRadius.circular(15),
child: Container(
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:google_maps_flutter_android/google_maps_flutter_android.dart';
import 'package:super_liquid_galaxy_controller/screens/dashboard.dart';
import 'package:super_liquid_galaxy_controller/screens/kml_builder.dart';
import 'package:super_liquid_galaxy_controller/screens/maps_controller.dart';
import 'package:super_liquid_galaxy_controller/screens/splashscreen.dart';
import 'package:super_liquid_galaxy_controller/screens/test.dart';
import 'package:super_liquid_galaxy_controller/utils/api_manager.dart';
import 'package:super_liquid_galaxy_controller/utils/lg_connection.dart';
Expand Down Expand Up @@ -48,7 +49,7 @@ class MyApp extends StatelessWidget {
debugShowCheckedModeBanner: false,
initialRoute: '/',
routes: {
'/': (context) => const KmlUploader(), // Root route
'/': (context) => const SplashScreen(), // Root route
// Settings route
},
theme: ThemeData(
Expand Down
7 changes: 6 additions & 1 deletion lib/screens/kml_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:super_liquid_galaxy_controller/components/glassbox.dart';
import 'package:super_liquid_galaxy_controller/components/kml_elements/linestring.dart';
import 'package:super_liquid_galaxy_controller/components/kml_elements/placemark.dart';
import 'package:super_liquid_galaxy_controller/components/kml_elements/polygon.dart';
import 'package:super_liquid_galaxy_controller/screens/test.dart';
import 'package:super_liquid_galaxy_controller/utils/galaxy_colors.dart';
import 'package:super_liquid_galaxy_controller/utils/kmlgenerator.dart';
import 'package:super_liquid_galaxy_controller/utils/lg_connection.dart';
Expand Down Expand Up @@ -250,12 +251,15 @@ class _KmlUploaderState extends State<KmlUploader> {
await sshClient.connectToLG();
//await sshClient.clearKml();
File? file = await sshClient.makeFile(filename,
KMLGenerator.generateKml('slave_1', kmlList));
KMLGenerator.generateCustomKml('slave_1', kmlList));
//String kml = KMLGenerator.generateCustomKml('slave_1', kmlList);
print("made successfully");
await sshClient.kmlFileUpload(
context, file!, filename);
print("uploaded successfully");
await sshClient.runKml(filename);

//Get.to(()=> TestScreen(kml: kml));
},
backgroundColor: GalaxyColors.blue.withOpacity(0.4),
),
Expand Down Expand Up @@ -392,6 +396,7 @@ class _KmlUploaderState extends State<KmlUploader> {
addElementToList(KmlElement elementData) {
setState(() {
kmlList.add(elementData);
print("added: $elementData");
});
}

Expand Down
5 changes: 3 additions & 2 deletions lib/screens/maps_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:avatar_glow/avatar_glow.dart';
import 'package:super_liquid_galaxy_controller/components/autocomplete_locationfield.dart';
import 'package:super_liquid_galaxy_controller/components/tray_button.dart';
import 'package:super_liquid_galaxy_controller/data_class/PlaceSuggestionResponse.dart';
import 'package:super_liquid_galaxy_controller/data_class/place_suggestion_response.dart';
import 'package:super_liquid_galaxy_controller/data_class/coordinate.dart';
import 'package:super_liquid_galaxy_controller/data_class/map_position.dart';
import 'package:super_liquid_galaxy_controller/generated/assets.dart';
Expand Down Expand Up @@ -270,12 +270,13 @@ class MapControllerState extends State<MapController> {
);
}

void _onCameraMove(CameraPosition camera) {
void _onCameraMove(CameraPosition camera) async {
if (!locationSet) {
return;
}
position.updateFromCameraPosition(camera);
print(position);
_onCameraIdle();
}

void _onCameraIdle() async {
Expand Down
44 changes: 6 additions & 38 deletions lib/screens/test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,50 +19,18 @@ class _TestScreenState extends State<TestScreen> {
void initState() {
//controller.text = widget.kml;
super.initState();
speechController = Get.find();
//speechController = Get.find();
controller.text = widget.kml;
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Obx(() {
controller.text = speechController.wordsString.value;
return TextField(
controller: controller,
);
}),
),
floatingActionButton: Material(
color: Colors.transparent,
child: InkWell(
onTapUp: (TapUpDetails tapdetails) {
print('up: ${tapdetails.kind}');
speechController.stopListening();
},
onTapDown: (TapDownDetails details) {
print('down: ${details.kind}');
speechController.startListening();
},
onTapCancel: () {
print('cancel');
speechController.stopListening();
},
child: Container(
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.circular(30.0),
),
child: const Padding(
padding: EdgeInsets.all(8.0),
child: Icon(
Icons.mic,
size: 45,
),
),
),
child: TextField(
controller: controller,
),
),
);

));
}
}
2 changes: 1 addition & 1 deletion lib/utils/autocomplete_controller.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'dart:async';

import 'package:super_liquid_galaxy_controller/data_class/PlaceSuggestionResponse.dart';
import 'package:super_liquid_galaxy_controller/data_class/place_suggestion_response.dart';
import 'package:super_liquid_galaxy_controller/utils/api_manager.dart';
import 'package:get/get.dart';

Expand Down
Loading

0 comments on commit a5b76d6

Please sign in to comment.