Skip to content

Commit

Permalink
Removed unused places functionality from navi module.
Browse files Browse the repository at this point in the history
Fixed SendLocation hanlders to work with waypoints.
Small updates in waypoints logic.
  • Loading branch information
AKalinich-Luxoft committed Mar 2, 2018
1 parent b92e7ab commit b8c7648
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 219 deletions.
189 changes: 31 additions & 158 deletions app/controller/NavigationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,6 @@ SDL.NavigationController = Em.Object.create(
* Model binding
*/
modelBinding: 'SDL.NavigationModel',
/**
* POI list switcher method
*/
showPoiList: function() {
if (!this.model.poi && this.model.LocationDetails.length == 0) {
SDL.PopUp.create().appendTo('body').popupActivate(
'List is empty. Please navigate to some new places!'
);
return;
}
if (this.model.poi == false && this.model.wp) {
this.model.toggleProperty('wp');
}
this.model.toggleProperty('poi');
},
/**
* WP list switcher method
*/
Expand All @@ -62,9 +47,6 @@ SDL.NavigationController = Em.Object.create(
);
return;
}
if (this.model.wp == false && this.model.poi) {
this.model.toggleProperty('poi');
}
this.model.toggleProperty('wp');
},
/**
Expand All @@ -76,6 +58,8 @@ SDL.NavigationController = Em.Object.create(
SDL.NavigationController.startAnimation();
}

SDL.NavigationController.clearRoutes();

SDL.NavigationController.addPOIMarker(
request.params.latitudeDegrees,
request.params.longitudeDegrees
Expand Down Expand Up @@ -193,10 +177,13 @@ SDL.NavigationController = Em.Object.create(
SDL.NavigationController.startAnimation();
}

SDL.NavigationController.clearRoutes();

SDL.NavigationController.addPOIMarker(
request.params.latitudeDegrees,
request.params.longitudeDegrees
);

SDL.NavigationController.setRoutes();

FFW.Navigation.sendNavigationResult(
Expand All @@ -217,8 +204,8 @@ SDL.NavigationController = Em.Object.create(
var dt =
SDL.NavigationController.convertDateTimeStructure(request.params.timeStamp);

var locations = SDL.deepCopy(SDL.NavigationModel.LocationDetails);
var insertInd = SDL.NavigationController.getInsertLocationIndex(locations, dt);
var waypoints = SDL.deepCopy(SDL.NavigationModel.WayPointDetails)
var insertInd = SDL.NavigationController.getInsertLocationIndex(waypoints, dt);
var timeStampStuct = SDL.NavigationController.convertDateObject(dt);
var location = {
coordinate: {
Expand All @@ -235,11 +222,25 @@ SDL.NavigationController = Em.Object.create(
};

if (insertInd >= 0) {
locations.splice(insertInd, 0, location);
waypoints.splice(insertInd, 0, location);
} else {
locations.push(location);
waypoints.push(location);
}
SDL.NavigationModel.set('WayPointDetails', waypoints);

var latlng = new google.maps.LatLng(
request.params.latitudeDegrees, request.params.longitudeDegrees
);
var marker = new google.maps.Marker({
position: latlng,
map: SDL.NavigationController.map
});
SDL.NavigationModel.WayPointMarkers.push(marker);

if(SDL.NavigationController.isRouteSet){
SDL.NavigationController.set('isRouteSet', false);
SDL.NavigationController.setRoutes();
}
SDL.NavigationModel.set('LocationDetails', locations);
}

FFW.Navigation.sendNavigationResult(
Expand Down Expand Up @@ -277,46 +278,6 @@ SDL.NavigationController = Em.Object.create(
}
return -1;
},
/**
* Navigation view List Button action handler
* Opens selected WayPoint structure
*
* @param {Object} element
*/
openDestPoint: function(element) {
var itemID = element.itemID;
this.model.set(
'currentWayPointData',
JSON.stringify(SDL.NavigationModel.LocationDetails[itemID], null, 2)
);
SDL.NavigationView.codeEditor.activate(
function(data, isDeleted) {
if (isDeleted) {
var location = SDL.NavigationModel.LocationDetails[itemID];
SDL.NavigationModel.LocationDetails.removeObject(location);
if (SDL.NavigationModel.LocationDetails.length == 0) {
SDL.NavigationModel.set('poi', false);
}
} else {
var locations = SDL.deepCopy(SDL.NavigationModel.LocationDetails);
var old_coords = locations[itemID].coordinate;
var new_location = JSON.parse(data);
locations.splice(itemID, 1);
var dt =
SDL.NavigationController.convertDateTimeStructure(new_location.timeStamp);
var insertInd =
SDL.NavigationController.getInsertLocationIndex(locations, dt);

if (insertInd >= 0) {
locations.splice(insertInd, 0, new_location);
} else {
locations.push(new_location);
}
SDL.NavigationModel.set('LocationDetails', locations);
}
}
);
},
/**
* Navigation view List Button action handler
* Selects current WayPoint
Expand Down Expand Up @@ -644,8 +605,8 @@ SDL.NavigationController = Em.Object.create(
}
},
getLocationByCoord: function(lat, lng) {
for (var i = 0; i < this.model.LocationDetails.length; ++i) {
var point = this.model.LocationDetails[i];
for (var i = 0; i < this.model.WayPointDetails.length; ++i) {
var point = this.model.WayPointDetails[i];
if (point.coordinate.latitudeDegrees == lat &&
point.coordinate.longitudeDegrees == lng) {
return {
Expand Down Expand Up @@ -702,94 +663,13 @@ SDL.NavigationController = Em.Object.create(
);
data.push(wp);
SDL.NavigationModel.set("WayPointDetails",data);

this.model.set("wp", true);

SDL.NavigationModel.selectedLocationMarker.setMap(null);
if(SDL.NavigationController.isRouteSet){
SDL.NavigationController.set('isRouteSet', false);
SDL.NavigationController.setRoutes();
}
else{
SDL.NavigationModel.selectedLocationMarker.setMap(null);
FFW.Navigation.onWayPointChange(SDL.NavigationModel.WayPointDetails);
}
},
addWaypointLocation: function(latlng) {
var res = SDL.NavigationController.getLocationByCoord(
latlng.lat(), latlng.lng()
);

if (res.index >= 0) {
return;
}

var dt = new Date();
var location = {
coordinate: {
latitudeDegrees: latlng.lat(),
longitudeDegrees: latlng.lng()
},
locationName: 'Unknown Location',
addressLines: [],
locationDescription: '',
phoneNumber: '',
locationImage: {
value: '',
imageType: 'DYNAMIC'
},
searchAddress: {
countryName: '',
countryCode: '',
postalCode: '',
administrativeArea: '',
subAdministrativeArea: '',
locality: '',
subLocality: '',
thoroughfare: '',
subThoroughfare: ''
},
timeStamp: SDL.NavigationController.convertDateObject(dt)
};

var locations = SDL.deepCopy(SDL.NavigationModel.LocationDetails);
var insertInd = SDL.NavigationController.getInsertLocationIndex(locations, dt);
if (insertInd >= 0) {
locations.splice(insertInd, 0, location);
} else {
locations.push(location);
}
SDL.NavigationModel.set('LocationDetails', locations);

geocoder = new google.maps.Geocoder();
geocoder.geocode({'location': latlng}, function(results, status) {
if (status === 'OK') {
var res = SDL.NavigationController.getLocationByCoord(
latlng.lat(), latlng.lng()
);
if (res.index < 0) {
return;
}
if (results[0]) {
res.location.addressLines = [results[0].formatted_address];
}
if (results[1]) {
res.location.locationName = results[1].formatted_address;
}

for (i = 0; i < results.length; ++i) {
var item = results[i];
for (j = 0; j < item.address_components.length; ++j) {
SDL.NavigationController.setLocationInfoFromItem(
item.address_components[j], res.location
);
}
}

var locations = SDL.deepCopy(SDL.NavigationModel.LocationDetails);
locations[res.index] = res.location;
SDL.NavigationModel.set('LocationDetails', locations);
} else {
Em.Logger.error('Navigation: Geocoder failed due to: ' + status);
}
});
},
waypointSelected: function() {
var data = SDL.NavigationView.codeEditor.content;
Expand Down Expand Up @@ -959,12 +839,12 @@ SDL.NavigationController = Em.Object.create(
if (SDL.NavigationController.isRouteSet == false &&
SDL.NavigationModel.selectedLocationMarker.getMap() == null) {
var markerCounts = SDL.NavigationModel.WayPointMarkers.length;
if(markerCounts == 0){
if(markerCounts == 0){
SDL.PopUp.create().appendTo('body').popupActivate(
'Error: Destination point is not set. Please select the destination point'
);
return false;
}else{
} else {
var marker = SDL.NavigationModel.WayPointMarkers.pop();
SDL.NavigationModel.selectedLocationMarker.setMap(this.map);
SDL.NavigationModel.selectedLocationMarker.setPosition(marker.getPosition());
Expand All @@ -983,10 +863,6 @@ SDL.NavigationController = Em.Object.create(
return;
}

SDL.NavigationController.addWaypointLocation(
SDL.NavigationModel.selectedLocationMarker.getPosition()
);

if (SDL.NavigationController.polyline) {
SDL.NavigationController.polyline.setMap(null);
}
Expand Down Expand Up @@ -1105,9 +981,6 @@ SDL.NavigationController = Em.Object.create(
SDL.NavigationController.clearRoutes();
return;
}
if (this.model.poi) {
this.model.toggleProperty('poi');
}
if (this.model.wp) {
this.model.toggleProperty('wp');
}
Expand Down
1 change: 0 additions & 1 deletion app/controller/sdl/FuncSwitcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ SDL.FuncSwitcher = Em.Object.create(
}.property('FLAGS.SimpleFunctionality'),
rev: function() {
var result = parseInt(FLAGS.SimpleFunctionality) === 1;
SDL.NavigationModel.set('poi', !result);
return result;
}.property('FLAGS.SimpleFunctionality'),
pan: function() {
Expand Down
10 changes: 0 additions & 10 deletions app/model/NavigationModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ SDL.NavigationModel = Em.Object.create({
*/
initialLoc: '230 Canal St, New York, NY 10013, USA',

/**
* POI list switcher flag
*/
poi: false,

/**
* WP list switcher flag
*/
Expand Down Expand Up @@ -80,11 +75,6 @@ SDL.NavigationModel = Em.Object.create({
*/
selectedLocationMarker: null,

/**
* Saved destination points array
*/
LocationDetails: [],

/**
* Saved waypoints array
*/
Expand Down
Loading

0 comments on commit b8c7648

Please sign in to comment.