Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds unexplored tasks to minimap #3287

Merged
merged 4 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions public/javascripts/SVLabel/src/SVLabel/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,7 @@ function Main (params) {
});
});

svl.taskContainer.getCurrentTask().render();
svl.taskContainer.renderTasksFromPreviousSessions();
svl.taskContainer.renderAllTasks();
var unit = {units: i18next.t('common:unit-distance')};
var distance = svl.taskContainer.getCompletedTaskDistance();
svl.statusFieldNeighborhood.setAuditedDistance(distance, unit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ function MapService (canvas, neighborhoodModel, uiMap, params) {
if (svl.neighborhoodModel.isRouteOrNeighborhoodComplete() || !task.isConnectedTo(nextTask)) {
// If jumping to a new place, set the newTask before jumping.
if (nextTask && !task.isConnectedTo(nextTask)) {
nextTask.eraseFromMinimap();
svl.taskContainer.setBeforeJumpNewTask(nextTask);
}
status.labelBeforeJumpListenerSet = true;
Expand Down Expand Up @@ -793,13 +794,13 @@ function MapService (canvas, neighborhoodModel, uiMap, params) {
svl.compass.update();
}
if (!isOnboarding && "taskContainer" in svl && svl.taskContainer.tasksLoaded()) {
svl.taskContainer.update();

// End of the task if the user is close enough to the end point and we aren't in the tutorial.
var task = svl.taskContainer.getCurrentTask();
if (!isOnboarding && task && task.isAtEnd(position.lat(), position.lng(), END_OF_STREET_THRESHOLD)) {
_endTheCurrentTask(task, currentMission);
}
svl.taskContainer.updateCurrentTask();
}
if ("observedArea" in svl) {
svl.observedArea.panoChanged();
Expand Down
14 changes: 9 additions & 5 deletions public/javascripts/SVLabel/src/SVLabel/task/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,20 +405,24 @@ function Task (geojson, tutorialTask, currentLat, currentLng, startPointReversed
this.render = function () {
if ('map' in svl && google) {
self.eraseFromMinimap();
if (self.isComplete()) {
// If the task has been completed already, set the paths to a green polyline
// If the task has been completed already, or if it has not been completed and is not the current task,
// render it using one green or gray Polyline, respectively.
if (self.isComplete() || self.getStreetEdgeId() !== svl.taskContainer.getCurrentTaskStreetEdgeId()) {
var gCoordinates = _geojson.features[0].geometry.coordinates.map(function (coord) {
return new google.maps.LatLng(coord[1], coord[0]);
});
var color = self.isComplete() ? '#00ff00' : '#808080';
var opacity = self.isComplete() ? 1.0 : 0.75;
paths = [
new google.maps.Polyline({
path: gCoordinates,
geodesic: true,
strokeColor: '#00ff00',
strokeOpacity: 1.0,
strokeColor: color,
strokeOpacity: opacity,
strokeWeight: 2
})
];
// If the task is incomplete and is the current task, render it using two Polylines (red and green).
} else {
var latlng = svl.map.getPosition();
paths = self.getGooglePolylines(latlng.lat, latlng.lng);
Expand All @@ -431,7 +435,7 @@ function Task (geojson, tutorialTask, currentLat, currentLng, startPointReversed
};

/**
* Flip the coordinates of the line string if the last point is closer to the end point of the current street segment.
* Flip the coordinates of the linestring if the last point is closer to the endpoint of the current street segment.
*/
this.reverseCoordinates = function() {
_geojson.features[0].geometry.coordinates.reverse();
Expand Down
30 changes: 13 additions & 17 deletions public/javascripts/SVLabel/src/SVLabel/task/TaskContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ function TaskContainer (navigationModel, neighborhoodModel, streetViewService, s
if (status === google.maps.StreetViewStatus.OK) {
lat = streetViewPanoramaData.location.latLng.lat();
lng = streetViewPanoramaData.location.latLng.lng();
let beforeJumpTask = currentTask;
self.setCurrentTask(nextTaskIn);
beforeJumpTask.render();
navigationModel.setPosition(lat, lng, function(){
navigationModel.preparePovReset();
});
Expand Down Expand Up @@ -113,7 +115,7 @@ function TaskContainer (navigationModel, neighborhoodModel, streetViewService, s
pushATask(task); // Push the data into previousTasks.

// Updates the segments that the user has already explored.
self.update();
self.updateCurrentTask();
// Renders the next street that the user will explore.
if(nextTask) nextTask.render();

Expand Down Expand Up @@ -381,7 +383,7 @@ function TaskContainer (navigationModel, neighborhoodModel, streetViewService, s
}

/**
* Get the next task and set it as a current task.
* Get the next task.
*
* Procedure:
* Get the list of the highest priority streets that this user has not audited
Expand Down Expand Up @@ -545,14 +547,10 @@ function TaskContainer (navigationModel, neighborhoodModel, streetViewService, s

/**
* This method is called from Map.handlerPositionUpdate() to update the color of audited and unaudited street
* segments on Google Maps.
* segments of the current task on Google Maps.
* TODO This should be done somewhere else.
*/
function update() {
for (var i = 0, len = previousTasks.length; i < len; i++) {
previousTasks[i].render();
}

function updateCurrentTask() {
var currentLatLng = navigationModel.getPosition();
currentTask.updateTheFurthestPointReached(currentLatLng.lat, currentLatLng.lng);
currentTask.render();
Expand Down Expand Up @@ -583,14 +581,12 @@ function TaskContainer (navigationModel, neighborhoodModel, streetViewService, s
}

/**
* Renders all previously completed tasks. Should be called at page load so it does not render redundantly.
* Renders all tasks to draw both unexplored and previously completed tasks. Should be called at page load
* so it does not render redundantly.
*/
function renderTasksFromPreviousSessions() {
var completedTasks = getCompletedTasks();
if (completedTasks) {
for (let i = 0; i < completedTasks.length; ++i) {
completedTasks[i].render();
}
function renderAllTasks() {
for (let task of self._tasks) {
task.render();
}
}

Expand All @@ -605,10 +601,10 @@ function TaskContainer (navigationModel, neighborhoodModel, streetViewService, s
self.isFirstTask = isFirstTask;
self.length = length;
self.push = pushATask;
self.renderTasksFromPreviousSessions = renderTasksFromPreviousSessions;
self.renderAllTasks = renderAllTasks;
self.hasMaxPriorityTask = hasMaxPriorityTask;
self.totalLineDistanceInNeighborhood = totalLineDistanceInNeighborhood;
self.update = update;
self.updateCurrentTask = updateCurrentTask;
self.updateAuditedDistance = updateAuditedDistance;
self.updateTaskPriorities = updateTaskPriorities;
self.getCurrentTaskStreetEdgeId = getCurrentTaskStreetEdgeId;
Expand Down