Skip to content
Open
Show file tree
Hide file tree
Changes from 9 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
4 changes: 4 additions & 0 deletions app/formats/json/ExploreFormats.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ object ExploreFormats {
zoom: Int,
lat: Option[Float],
lng: Option[Float],
gsvLat: Option[Float],
gsvLng: Option[Float],
computationMethod: Option[String]
)
case class LabelSubmission(
Expand Down Expand Up @@ -237,6 +239,8 @@ object ExploreFormats {
(JsPath \ "zoom").read[Int] and
(JsPath \ "lat").readNullable[Float] and
(JsPath \ "lng").readNullable[Float] and
(JsPath \ "gsv_lat").readNullable[Float] and
(JsPath \ "gsv_lng").readNullable[Float] and
(JsPath \ "computation_method").readNullable[String]
)(LabelPointSubmission.apply _)

Expand Down
17 changes: 10 additions & 7 deletions app/formats/json/LabelFormats.scala
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,13 @@ object LabelFormats {

def resumeLabelMetadatatoJson(label: ResumeLabelMetadata, allTags: Seq[Tag]): JsObject = {
Json.obj(
"labelId" -> label.labelData.labelId,
"labelType" -> label.labelType,
"panoId" -> label.labelData.gsvPanoramaId,
"panoLat" -> label.panoLat,
"panoLng" -> label.panoLng,
"originalPov" -> Json.obj(
"labelId" -> label.labelData.labelId,
"labelType" -> label.labelType,
"panoCaptureDate" -> label.panoCaptureDate,
"panoId" -> label.labelData.gsvPanoramaId,
"panoLat" -> label.panoLat,
"panoLng" -> label.panoLng,
"originalPov" -> Json.obj(
"heading" -> label.pointData.heading,
"pitch" -> label.pointData.pitch,
"zoom" -> label.pointData.zoom
Expand All @@ -216,7 +217,9 @@ object LabelFormats {
"auditTaskId" -> label.labelData.auditTaskId,
"missionId" -> label.labelData.missionId,
"labelLat" -> label.pointData.lat,
"labelLng" -> label.pointData.lng
"labelLng" -> label.pointData.lng,
"gsvLat" -> label.pointData.gsvLat,
"gsvLng" -> label.pointData.gsvLng
)
}
}
6 changes: 5 additions & 1 deletion app/models/label/LabelPointTable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ case class LabelPoint(
zoom: Int,
lat: Option[Float],
lng: Option[Float],
gsvLat: Option[Float],
gsvLng: Option[Float],
geom: Option[Point],
computationMethod: Option[String]
)
Expand All @@ -36,10 +38,12 @@ class LabelPointTableDef(tag: slick.lifted.Tag) extends Table[LabelPoint](tag, "
def zoom: Rep[Int] = column[Int]("zoom")
def lat: Rep[Option[Float]] = column[Option[Float]]("lat")
def lng: Rep[Option[Float]] = column[Option[Float]]("lng")
def gsvLat: Rep[Option[Float]] = column[Option[Float]]("gsv_lat")
def gsvLng: Rep[Option[Float]] = column[Option[Float]]("gsv_lng")
def geom: Rep[Option[Point]] = column[Option[Point]]("geom")
def computationMethod: Rep[Option[String]] = column[Option[String]]("computation_method")

def * = (labelPointId, labelId, panoX, panoY, canvasX, canvasY, heading, pitch, zoom, lat, lng, geom,
def * = (labelPointId, labelId, panoX, panoY, canvasX, canvasY, heading, pitch, zoom, lat, lng, gsvLat, gsvLng, geom,
computationMethod) <> ((LabelPoint.apply _).tupled, LabelPoint.unapply)

// def label: ForeignKeyQuery[LabelTable, Label] =
Expand Down
6 changes: 4 additions & 2 deletions app/models/label/LabelTable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ case class ResumeLabelMetadata(
labelData: Label,
labelType: String,
pointData: LabelPoint,
panoCaptureDate: String,
panoLat: Option[Float],
panoLng: Option[Float],
cameraHeading: Option[Float],
Expand Down Expand Up @@ -1218,8 +1219,9 @@ class LabelTable @Inject() (protected val dbConfigProvider: DatabaseConfigProvid
_gsvData <- gsvData if _label.gsvPanoramaId === _gsvData.gsvPanoramaId
if _mission.regionId === regionId && _mission.userId === userId
if _labelPoint.lat.isDefined && _labelPoint.lng.isDefined
} yield (_label, _labelType.labelType, _labelPoint, _gsvData.lat, _gsvData.lng, _gsvData.cameraHeading,
_gsvData.cameraPitch, _gsvData.width, _gsvData.height)).result.map(_.map(ResumeLabelMetadata.tupled))
} yield (_label, _labelType.labelType, _labelPoint, _gsvData.captureDate, _gsvData.lat, _gsvData.lng,
_gsvData.cameraHeading, _gsvData.cameraPitch, _gsvData.width, _gsvData.height)).result
.map(_.map(ResumeLabelMetadata.tupled))
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/service/ExploreService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ class ExploreServiceImpl @Inject() (
// Add an entry to the label_point table.
_ <- labelPointTable.insert(
LabelPoint(0, newLabelId, point.panoX, point.panoY, point.canvasX, point.canvasY, point.heading, point.pitch,
point.zoom, point.lat, point.lng, pointGeom, point.computationMethod)
point.zoom, point.lat, point.lng, point.gsvLat, point.gsvLng, pointGeom, point.computationMethod)
)
} yield {
(newLabelId, label.temporaryLabelId, timeCreated)
Expand Down
9 changes: 9 additions & 0 deletions conf/evolutions/default/277.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# --- !Ups
ALTER TABLE label_point
ADD COLUMN gsv_lat double precision,
ADD COLUMN gsv_lng double precision;

# --- !Downs
ALTER TABLE label_point
DROP COLUMN gsv_lat,
DROP COLUMN gsv_lng;
8 changes: 7 additions & 1 deletion public/javascripts/SVLabel/src/SVLabel/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ function Main (params) {
});
logPageFocus();

svl.overlay = new google.maps.OverlayView();
svl.overlay.onAdd = function () {};
svl.overlay.draw = function () {};
svl.overlay.onRemove = function () {};
svl.overlay.setMap(svl.panorama);

// Modals
var modalMissionCompleteMap = new ModalMissionCompleteMap(svl.ui.modalMissionComplete);
var modalMissionCompleteProgressBar = new ModalMissionCompleteProgressBar(svl.ui.modalMissionComplete);
Expand Down Expand Up @@ -320,7 +326,7 @@ function Main (params) {

svl.labelContainer.fetchLabelsToResumeMission(neighborhood.getRegionId(), function (result) {
svl.statusFieldNeighborhood.setLabelCount(svl.labelContainer.countLabels());
svl.canvas.setOnlyLabelsOnPanoAsVisible(svl.map.getPanoId());
svl.canvas.setOnlyLabelsInViewAsVisible(svl.map.getPanoId());

// Count the labels of each label type to initialize the current mission label counts.
var counter = {'CurbRamp': 0, 'NoCurbRamp': 0, 'Obstacle': 0, 'SurfaceProblem': 0, 'NoSidewalk': 0, 'Other': 0};
Expand Down
8 changes: 4 additions & 4 deletions public/javascripts/SVLabel/src/SVLabel/canvas/Canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function Canvas(ribbon) {
if (!status.disableLabeling && currTime - mouseStatus.prevMouseUpTime > 300) {
createLabel(mouseStatus.leftUpX, mouseStatus.leftUpY);
clear();
setOnlyLabelsOnPanoAsVisible(svl.map.getPanoId());
setOnlyLabelsInViewAsVisible(svl.map.getPanoId());
render();
}

Expand Down Expand Up @@ -330,10 +330,10 @@ function Canvas(ribbon) {
/**
* Sets labels on the given pano as visible, all others as hidden.
*/
function setOnlyLabelsOnPanoAsVisible(panoramaId) {
function setOnlyLabelsInViewAsVisible(panoramaId) {
var labels = svl.labelContainer.getCanvasLabels();
for (var i = 0; i < labels.length; i += 1) {
if (labels[i].getPanoId() === panoramaId && !labels[i].isDeleted()) {
if (!labels[i].isDeleted()) {
labels[i].setVisibility('visible');
} else {
labels[i].setVisibility('hidden');
Expand Down Expand Up @@ -376,7 +376,7 @@ function Canvas(ribbon) {
self.setStatus = setStatus;
self.showLabelHoverInfo = showLabelHoverInfo;
self.setVisibility = setVisibility;
self.setOnlyLabelsOnPanoAsVisible = setOnlyLabelsOnPanoAsVisible;
self.setOnlyLabelsInViewAsVisible = setOnlyLabelsInViewAsVisible;
self.unlockDisableLabelDelete = unlockDisableLabelDelete;
self.saveGSVScreenshot = saveGSVScreenshot;

Expand Down
12 changes: 11 additions & 1 deletion public/javascripts/SVLabel/src/SVLabel/data/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ function Form (labelContainer, missionModel, missionContainer, navigationModel,
var labelLatLng = label.toLatLng();
var tempLabelId = label.getProperty('temporaryLabelId');
var auditTaskId = label.getProperty('auditTaskId');

var labelGsvLat = label.getProperty('gsvLat');
var labelGsvLng = label.getProperty('gsvLng');

// If this label is a new label, get the timestamp of its creation from the corresponding interaction.
var associatedInteraction = data.interactions.find(interaction =>
Expand Down Expand Up @@ -127,7 +130,9 @@ function Form (labelContainer, missionModel, missionContainer, navigationModel,
pitch: prop.originalPov.pitch,
zoom : prop.originalPov.zoom,
lat : null,
lng : null
lng : null,
gsv_lat : null,
gsv_lng : null
}
};

Expand All @@ -137,6 +142,11 @@ function Form (labelContainer, missionModel, missionContainer, navigationModel,
temp.label_point.computation_method = labelLatLng.latLngComputationMethod;
}

if (labelGsvLat && labelGsvLng) {
temp.label_point.gsv_lat = labelGsvLat;
temp.label_point.gsv_lng = labelGsvLng;
}

data.labels.push(temp)
}

Expand Down
60 changes: 56 additions & 4 deletions public/javascripts/SVLabel/src/SVLabel/label/Label.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,13 @@ function Label(params) {
povOfLabelIfCentered: undefined,
labelLat: undefined,
labelLng: undefined,
gsvLat: undefined,
gsvLng: undefined,
latLngComputationMethod: undefined,
panoId: undefined,
panoLat: undefined,
panoLng: undefined,
panoCaptureDate: undefined,
cameraHeading: undefined,
panoWidth: undefined,
panoHeight: undefined,
Expand Down Expand Up @@ -94,6 +97,7 @@ function Label(params) {
properties.panoXY = util.panomarker.calculatePanoXYFromPov(
properties.povOfLabelIfCentered, properties.cameraHeading, properties.panoWidth, properties.panoHeight
);
properties.panoCaptureDate = panoData.imageDate;
}

// Create the marker on the minimap.
Expand Down Expand Up @@ -203,9 +207,32 @@ function Label(params) {

// Update the coordinates of the label on the canvas.
if (svl.map.getPovChangeStatus()) {
properties.currCanvasXY = util.panomarker.getCanvasCoordinate(
properties.povOfLabelIfCentered, pov, util.EXPLORE_CANVAS_WIDTH, util.EXPLORE_CANVAS_HEIGHT, svl.LABEL_ICON_RADIUS
);
if(svl.map.getPanoId() == properties.panoId) {
properties.currCanvasXY = util.panomarker.getCanvasCoordinate(
properties.povOfLabelIfCentered, pov, util.EXPLORE_CANVAS_WIDTH, util.EXPLORE_CANVAS_HEIGHT, svl.LABEL_ICON_RADIUS
);
} else {
let latLng = null;
if(getProperty('gsvLat') && getProperty('gsvLng')) {
latLng = new google.maps.LatLng(getProperty('gsvLat'), getProperty('gsvLng'));
} else if(getProperty('labelLat') && getProperty('labelLng')) {
// Fallback to regression-calculated lat/lng if GSV lat/lng is not available.
latLng = this.toLatLng();
}
const projection = svl.overlay.getProjection();
const canvasXY = projection.fromLatLngToContainerPixel(latLng);
if(canvasXY != null) {
properties.currCanvasXY = {
x: canvasXY.x,
y: canvasXY.y
};
} else {
properties.currCanvasXY = {
x: null,
y: null
};
}
}
}

// Draw the label icon if it's in the visible part of the pano.
Expand Down Expand Up @@ -353,7 +380,32 @@ function Label(params) {
*/
function toLatLng() {
if (!properties.labelLat) {
// Estimate the latlng point from the camera position and the heading when point cloud data isn't available.
// Estimating lat/lng from GSV canvas coordinates.
let gsvEstimatedLatLng = null;
if(properties.currCanvasXY.x) {
try {
const projection = svl.overlay.getProjection();

const latLng = projection.fromContainerPixelToLatLng({
x: properties.currCanvasXY.x,
y: properties.currCanvasXY.y
});

gsvEstimatedLatLng = {lat: latLng.lat(), lng: latLng.lng()}
} catch (e) {
console.error('Error estimating GSV lat/lng for label:', e);
}
}
if(gsvEstimatedLatLng) {
var latlng = {
lat: gsvEstimatedLatLng.lat,
lng: gsvEstimatedLatLng.lng,
};
setProperty('gsvLat', latlng.lat);
setProperty('gsvLng', latlng.lng);
}

// Estimate the latlng point from the camera position and the heading
var panoLat = getProperty("panoLat");
var panoLng = getProperty("panoLng");
var panoHeading = getProperty("originalPov").heading;
Expand Down
26 changes: 23 additions & 3 deletions public/javascripts/SVLabel/src/SVLabel/label/LabelContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,31 @@ function LabelContainer ($, nextTemporaryLabelId) {
}

/**
* Returns labels for the current pano ID.
* Returns labels for the current view.
*/
this.getCanvasLabels = function () {
let panoId = svl.map.getPanoId();
return allLabels[panoId] ? allLabels[panoId] : [];
const panoId = svl.map.getPanoId();
const panoLatLng = svl.map.getPosition();
// During the transition to the next panorama, the new panorama might not be in the container.
// Therefore, we must check if the panorama exists before proceeding.
if (svl.panoramaContainer.getPanorama(panoId) === null) {
return [];
}
const panoDate = svl.panoramaContainer.getPanorama(panoId).data().imageDate;
return this.getAllLabels().filter(function (label) {
// Is the label in the current pano?
const presentInPano = label.getPanoId() === svl.map.getPanoId();
// Calculate distance between label and current pano.
const labelLatLng = label.toLatLng();
const distance = turf.distance(turf.point([labelLatLng.lng, labelLatLng.lat]),
turf.point([panoLatLng.lng, panoLatLng.lat]), { units: "meters" });
// Check if date of label and pano match.
const dateMatches = panoDate === label.getProperty('panoCaptureDate');

// We may want to do further testing to determine the optimal distance threshold.
// For now, we use 25m as a threshold.
return presentInPano || (distance < 25 && dateMatches);
});
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ function MapService (canvas, neighborhoodModel, uiMap, params) {

povChange["status"] = true;
_canvas.clear();
_canvas.setOnlyLabelsOnPanoAsVisible(panoId);
_canvas.setOnlyLabelsInViewAsVisible(panoId);
_canvas.render();
povChange["status"] = false;

Expand Down Expand Up @@ -1115,7 +1115,7 @@ function MapService (canvas, neighborhoodModel, uiMap, params) {
function updateCanvas() {
_canvas.clear();
if (status.currPanoId !== getPanoId()) {
_canvas.setOnlyLabelsOnPanoAsVisible(getPanoId());
_canvas.setOnlyLabelsInViewAsVisible(getPanoId());
}
status.currPanoId = getPanoId();
_canvas.render();
Expand Down