Skip to content

Commit

Permalink
feat: All SSH logic and LG visualizations for POIs implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
AritraBiswas9788 committed Jul 22, 2024
1 parent 3da380b commit 3e39831
Show file tree
Hide file tree
Showing 32 changed files with 782 additions and 159 deletions.
2 changes: 1 addition & 1 deletion lib/components/MapKmlElement.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:super_liquid_galaxy_controller/data_class/kml_element.dart';
import 'package:super_liquid_galaxy_controller/data_class/map_position.dart';
import 'package:super_liquid_galaxy_controller/screens/map_kml_fullscreen.dart';
import 'package:super_liquid_galaxy_controller/utils/galaxy_colors.dart';
import 'package:super_liquid_galaxy_controller/utils/map_movement_controller.dart';
import 'package:super_liquid_galaxy_controller/controllers/map_movement_controller.dart';

class Mapkmlelement extends StatefulWidget {
Mapkmlelement(
Expand Down
2 changes: 1 addition & 1 deletion lib/components/apimanager_block.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:super_liquid_galaxy_controller/utils/api_manager.dart';
import 'package:super_liquid_galaxy_controller/controllers/api_manager.dart';
import '../generated/assets.dart';
import 'custom_dialog.dart';
import 'galaxytextfield.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/components/autocomplete_locationfield.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import 'package:flutter/material.dart';
import 'package:super_liquid_galaxy_controller/utils/autocomplete_controller.dart';
import 'package:super_liquid_galaxy_controller/controllers/autocomplete_controller.dart';
import 'package:super_liquid_galaxy_controller/utils/galaxy_colors.dart';

import '../data_class/place_suggestion_response.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/components/location_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:super_liquid_galaxy_controller/data_class/country_data.dart';
import 'package:super_liquid_galaxy_controller/screens/location_picker.dart';
import 'package:super_liquid_galaxy_controller/utils/galaxy_colors.dart';
import 'package:geocoding/geocoding.dart';
import 'package:super_liquid_galaxy_controller/utils/tour_controller.dart';
import 'package:super_liquid_galaxy_controller/controllers/tour_controller.dart';
import '../generated/assets.dart';

class LocationSelector extends StatefulWidget {
Expand Down
45 changes: 45 additions & 0 deletions lib/utils/api_manager.dart → lib/controllers/api_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,23 @@ class ApiManager extends getx.GetxController {
return response;
}



Future<Response> getNearbyPlaces(Coordinates point) async {
await _connectApi(2);
var response = await _apiClient.get(placesEndPoint, queryParameters: {
'filter': 'circle:${point.longitude},${point.latitude},50000',
'bias':'proximity:${point.longitude},${point.latitude}',
'apiKey': _placesApiKey.trim(),
'categories': 'commercial,tourism,entertainment,leisure,building',
'limit': '50'
});
if (response.statusCode != 200) {
handleError(response);
}
return response;
}

Future<Response> getPlaces(String id, String categories) async {
await _connectApi(2);
var response = await _apiClient.get(placesEndPoint, queryParameters: {
Expand Down Expand Up @@ -306,6 +323,33 @@ class ApiManager extends getx.GetxController {
return (kml:'',obj: null,places:<PlaceInfo>[]);
}

Future<({String kml,pr.PlaceResponse? obj,List<PlaceInfo> places})> tryPlaceResponseForCoordinates(
Coordinates coords) async {
Response places = await getNearbyPlaces(coords);
if (places.statusCode != 200) {
return (kml:'',obj: null,places:<PlaceInfo>[]);
}
var placeObj = pr.PlaceResponse.fromJson(places.data);
//print(placeObj);
if (placeObj.features!=null && placeObj.features!.isNotEmpty) {
var list = placeObj.features;
List<PlaceInfo> coordinates = [];
for (final feature in list!) {
try {
// var name = (feature.properties!.name != null)?feature.properties!.name!.replaceAll('&', 'and'):feature.properties!.addressLine1!;
coordinates.add(getPlaceInfo(feature));
} catch (e) {
print(e);
print(feature);
}
}
String kml = KMLGenerator.addPlaces(coordinates);
//getx.Get.to(() => TestScreen(kml: KMLGenerator.generateKml('69', kml)));
return (kml:kml,obj:placeObj,places: coordinates);
}
return (kml:'',obj: null,places:<PlaceInfo>[]);
}

PlaceInfo getPlaceInfo(pr.Features feature) {
var name = (feature.properties!.name != null)?feature.properties!.name!.replaceAll('&', 'and'):feature.properties!.addressLine1!;
var category = 'default';
Expand All @@ -328,4 +372,5 @@ class ApiManager extends getx.GetxController {
}



}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:async';

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

const Duration debounceDuration = Duration(milliseconds: 250);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:io';

import '../utils/balloongenerator.dart';
import '../utils/constants.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:dartssh2/dartssh2.dart';
Expand Down Expand Up @@ -306,6 +307,43 @@ fi
}
}

Future<bool> cleanBalloon() async {
try {
if(_client==null)
{
await reConnectToLG();
if(isConnected.value==false) {
return false;
}
}

await _client?.run(
"echo '${BalloonGenerator.blankBalloon()}' > /var/www/html/kml/slave_${int.parse(_numberOfRigs).rightMostRig}.kml");
return true;
} catch (error) {
print(error);
return false;
}
}

Future<bool> flyToInstantWithoutSaving(MapPosition position) async {
try {
if(_client==null)
{
await reConnectToLG();
if(isConnected.value==false) {
return false;
}
}
await _client?.run(
'echo "flytoview=${KMLGenerator.lookAtLinearInstant(position)}" > /tmp/query.txt');
return true;
} catch (error) {
print(error);
return false;
}
}


Future<bool> moveTo(MapPosition position) async {
print(position);
Expand Down Expand Up @@ -353,5 +391,22 @@ fi
print("error : $e");
}
}
Future<bool> flyToOrbit(MapPosition position) async {
try {
if(_client==null)
{
await reConnectToLG();
if(isConnected.value==false) {
return false;
}
}
await _client?.run(
'echo "flytoview=${KMLGenerator.orbitLookAtLinear(position)}" > /tmp/query.txt');
return true;
} catch (error) {
print(error);
return false;
}
}

}
File renamed without changes.
Loading

0 comments on commit 3e39831

Please sign in to comment.