Skip to content

Commit

Permalink
Merge pull request #3050 from ProjectSidewalk/340-long-lat
Browse files Browse the repository at this point in the history
Adds an info button to GSV window in Explore, Validate, and Gallery
  • Loading branch information
misaugstad authored Oct 15, 2022
2 parents 6b66daf + 7ede752 commit 4c9236b
Show file tree
Hide file tree
Showing 36 changed files with 716 additions and 291 deletions.
9 changes: 6 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ module.exports = function(grunt) {
'public/javascripts/common/UtilitiesMath.js',
'public/javascripts/common/UtilitiesPanomarker.js',
'public/javascripts/common/UtilitiesShape.js',
'public/javascripts/common/UtilitiesSidewalk.js'
'public/javascripts/common/UtilitiesSidewalk.js',
'public/javascripts/common/GSVInfoPopover.js'
],
dest: 'public/javascripts/SVLabel/build/SVLabel.js'
},
Expand Down Expand Up @@ -70,7 +71,8 @@ module.exports = function(grunt) {
'public/javascripts/SVValidate/src/util/*.js',
'public/javascripts/SVValidate/src/zoom/*.js',
'public/javascripts/common/Panomarker.js',
'public/javascripts/common/UtilitiesSidewalk.js'
'public/javascripts/common/UtilitiesSidewalk.js',
'public/javascripts/common/GSVInfoPopover.js'
],
dest: 'public/javascripts/SVValidate/build/SVValidate.js'
},
Expand All @@ -83,7 +85,8 @@ module.exports = function(grunt) {
'public/javascripts/Gallery/src/displays/*.js',
'public/javascripts/Gallery/src/modal/*.js',
'public/javascripts/Gallery/src/*.js',
'public/javascripts/common/Panomarker.js'
'public/javascripts/common/Panomarker.js',
'public/javascripts/common/GSVInfoPopover.js'
],
dest: 'public/javascripts/Gallery/build/Gallery.js'
}
Expand Down
26 changes: 16 additions & 10 deletions app/formats/json/LabelFormat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ object LabelFormat {
"severity" -> labelMetadata.severity,
"temporary" -> labelMetadata.temporary,
"description" -> labelMetadata.description,
"street_edge_id" -> labelMetadata.streetEdgeId,
"region_id" -> labelMetadata.regionId,
"user_validation" -> labelMetadata.userValidation.map(LabelValidationTable.validationOptions.get),
"tags" -> labelMetadata.tags
)
Expand All @@ -82,14 +84,16 @@ object LabelFormat {
"gsv_panorama_id" -> labelMetadata.gsvPanoramaId,
"tutorial" -> labelMetadata.tutorial,
"image_date" -> labelMetadata.imageDate,
"heading" -> labelMetadata.heading,
"pitch" -> labelMetadata.pitch,
"zoom" -> labelMetadata.zoom,
"heading" -> labelMetadata.headingPitchZoom._1,
"pitch" -> labelMetadata.headingPitchZoom._2,
"zoom" -> labelMetadata.headingPitchZoom._3,
"canvas_x" -> labelMetadata.canvasXY._1,
"canvas_y" -> labelMetadata.canvasXY._2,
"canvas_width" -> labelMetadata.canvasWidth,
"canvas_height" -> labelMetadata.canvasHeight,
"canvas_width" -> labelMetadata.canvasWidthHeight._1,
"canvas_height" -> labelMetadata.canvasWidthHeight._2,
"audit_task_id" -> labelMetadata.auditTaskId,
"street_edge_id" -> labelMetadata.streetEdgeId,
"region_id" -> labelMetadata.regionId,
"user_id" -> labelMetadata.userId,
"username" -> labelMetadata.username,
"timestamp" -> labelMetadata.timestamp,
Expand All @@ -113,13 +117,15 @@ object LabelFormat {
"gsv_panorama_id" -> labelMetadata.gsvPanoramaId,
"tutorial" -> labelMetadata.tutorial,
"image_date" -> labelMetadata.imageDate,
"heading" -> labelMetadata.heading,
"pitch" -> labelMetadata.pitch,
"zoom" -> labelMetadata.zoom,
"heading" -> labelMetadata.headingPitchZoom._1,
"pitch" -> labelMetadata.headingPitchZoom._2,
"zoom" -> labelMetadata.headingPitchZoom._3,
"canvas_x" -> labelMetadata.canvasXY._1,
"canvas_y" -> labelMetadata.canvasXY._2,
"canvas_width" -> labelMetadata.canvasWidth,
"canvas_height" -> labelMetadata.canvasHeight,
"canvas_width" -> labelMetadata.canvasWidthHeight._1,
"canvas_height" -> labelMetadata.canvasWidthHeight._2,
"street_edge_id" -> labelMetadata.streetEdgeId,
"region_id" -> labelMetadata.regionId,
"timestamp" -> labelMetadata.timestamp,
"label_type_key" -> labelMetadata.labelTypeKey,
"label_type_value" -> labelMetadata.labelTypeValue,
Expand Down
27 changes: 18 additions & 9 deletions app/models/audit/AuditTaskTable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import models.utils.MyPostgresDriver.simple._
import models.daos.slick.DBTableDefinitions.{DBUser, UserTable}
import models.label.{LabelTable, LabelTypeTable}
import models.street.StreetEdgePriorityTable
import models.region.RegionTable
import models.user.{UserRoleTable, UserStatTable}
import play.api.libs.json._
import play.api.Play.current
Expand All @@ -18,7 +19,7 @@ import scala.slick.lifted.ForeignKeyQuery
import scala.slick.jdbc.{GetResult, StaticQuery => Q}

case class AuditTask(auditTaskId: Int, amtAssignmentId: Option[Int], userId: String, streetEdgeId: Int, taskStart: Timestamp, taskEnd: Option[Timestamp], completed: Boolean, currentLat: Float, currentLng: Float, startPointReversed: Boolean)
case class NewTask(edgeId: Int, geom: LineString,
case class NewTask(edgeId: Int, geom: LineString, regionId: Int,
currentLng: Float, currentLat: Float, x1: Float, y1: Float, x2: Float, y2: Float,
startPointReversed: Boolean, // Did we start at x1,y1 instead of x2,y2?
taskStart: Timestamp,
Expand All @@ -35,6 +36,7 @@ case class NewTask(edgeId: Int, geom: LineString,
val linestring: geojson.LineString[geojson.LatLng] = geojson.LineString(latlngs)
val properties = Json.obj(
"street_edge_id" -> edgeId,
"region_id" -> regionId,
"current_lng" -> currentLng,
"current_lat" -> currentLat,
"x1" -> x1,
Expand Down Expand Up @@ -108,6 +110,7 @@ object AuditTaskTable {
implicit val newTaskConverter = GetResult[NewTask](r => {
val edgeId = r.nextInt
val geom = r.nextGeometry[LineString]
val regionId = r.nextInt
val currentLng = r.nextFloat
val currentLat = r.nextFloat
val x1 = r.nextFloat
Expand All @@ -119,7 +122,7 @@ object AuditTaskTable {
val completedByAnyUser = r.nextBoolean
val priority = r.nextDouble
val completed = r.nextBooleanOption.getOrElse(false)
NewTask(edgeId, geom, currentLng, currentLat, x1, y1, x2, y2, startPointReversed, taskStart, completedByAnyUser, priority, completed)
NewTask(edgeId, geom, regionId, currentLng, currentLat, x1, y1, x2, y2, startPointReversed, taskStart, completedByAnyUser, priority, completed)
})

val db = play.api.db.slick.DB
Expand All @@ -128,6 +131,7 @@ object AuditTaskTable {
val streetEdges = TableQuery[StreetEdgeTable]
val streetEdgePriorities = TableQuery[StreetEdgePriorityTable]
val users = TableQuery[UserTable]
val regions = TableQuery[StreetEdgeRegionTable]

val completedTasks = auditTasks.filter(_.completed)
val streetEdgesWithoutDeleted = streetEdges.filterNot(_.deleted)
Expand Down Expand Up @@ -370,9 +374,10 @@ object AuditTaskTable {
// Join with other queries to get completion count and priority for each of the street edges.
val edges = for {
se <- streetEdgesWithoutDeleted if se.streetEdgeId === streetEdgeId
re <- regions if se.streetEdgeId === re.streetEdgeId
scau <- streetCompletedByAnyUser if se.streetEdgeId === scau._1
sep <- streetEdgePriorities if scau._1 === sep.streetEdgeId
} yield (se.streetEdgeId, se.geom, se.x2, se.y2, se.x1, se.y1, se.x2, se.y2, false, timestamp, scau._2, sep.priority, userCompleted)
} yield (se.streetEdgeId, se.geom, re.regionId, se.x2, se.y2, se.x1, se.y1, se.x2, se.y2, false, timestamp, scau._2, sep.priority, userCompleted)

NewTask.tupled(edges.first)
}
Expand All @@ -390,15 +395,16 @@ object AuditTaskTable {
val possibleTasks = for {
sp <- streetEdgePriorities
se <- edgesInRegion if sp.streetEdgeId === se.streetEdgeId
re <- regions if se.streetEdgeId === re.streetEdgeId
sc <- streetCompletedByAnyUser if se.streetEdgeId === sc._1
} yield (se.streetEdgeId, se.geom, se.x2, se.y2, se.x1, se.y1, se.x2, se.y2, false, timestamp, sc._2, sp.priority, false)
} yield (se.streetEdgeId, se.geom, re.regionId, se.x2, se.y2, se.x1, se.y1, se.x2, se.y2, false, timestamp, sc._2, sp.priority, false)

// Get the priority of the highest priority task.
val highestPriority: Option[Double] = possibleTasks.map(_._12).max.run
val highestPriority: Option[Double] = possibleTasks.map(_._13).max.run

// Get list of tasks that have this priority.
val highestPriorityTasks: Option[List[NewTask]] = highestPriority.map { highPriority =>
possibleTasks.filter(_._12 === highPriority).list.map(NewTask.tupled)
possibleTasks.filter(_._13 === highPriority).list.map(NewTask.tupled)
}

// Choose one of the highest priority tasks at random.
Expand All @@ -414,9 +420,10 @@ object AuditTaskTable {
val newTask = for {
at <- auditTasks if at.auditTaskId === taskId
se <- streetEdges if at.streetEdgeId === se.streetEdgeId
re <- regions if se.streetEdgeId === re.streetEdgeId
sp <- streetEdgePriorities if se.streetEdgeId === sp.streetEdgeId
sc <- streetCompletedByAnyUser if sp.streetEdgeId === sc._1
} yield (se.streetEdgeId, se.geom, at.currentLng, at.currentLat, se.x1, se.y1, se.x2, se.y2, at.startPointReversed, timestamp, sc._2, sp.priority, false)
} yield (se.streetEdgeId, se.geom, re.regionId, at.currentLng, at.currentLat, se.x1, se.y1, se.x2, se.y2, at.startPointReversed, timestamp, sc._2, sp.priority, false)

newTask.list.map(NewTask.tupled).headOption
}
Expand All @@ -430,9 +437,10 @@ object AuditTaskTable {
val tasks = for {
ser <- nonDeletedStreetEdgeRegions if ser.regionId === regionId
se <- streetEdges if ser.streetEdgeId === se.streetEdgeId
re <- regions if se.streetEdgeId === re.streetEdgeId
sep <- streetEdgePriorities if se.streetEdgeId === sep.streetEdgeId
scau <- streetCompletedByAnyUser if sep.streetEdgeId === scau._1
} yield (se.streetEdgeId, se.geom, se.x2, se.y2, se.x1, se.y1, se.x2, se.y2, false, timestamp, scau._2, sep.priority, false)
} yield (se.streetEdgeId, se.geom, re.regionId, se.x2, se.y2, se.x1, se.y1, se.x2, se.y2, false, timestamp, scau._2, sep.priority, false)

tasks.list.map(NewTask.tupled(_))
}
Expand All @@ -450,10 +458,11 @@ object AuditTaskTable {
val tasks = for {
(ser, ucs) <- edgesInRegion.leftJoin(userCompletedStreets).on(_.streetEdgeId === _._1)
se <- streetEdges if ser.streetEdgeId === se.streetEdgeId
re <- regions if se.streetEdgeId === re.streetEdgeId
sep <- streetEdgePriorities if se.streetEdgeId === sep.streetEdgeId
scau <- streetCompletedByAnyUser if sep.streetEdgeId === scau._1
} yield (
se.streetEdgeId, se.geom, se.x2, se.y2, se.x1, se.y1, se.x2, se.y2, false, timestamp, scau._2, sep.priority, ucs._2.?.getOrElse(false))
se.streetEdgeId, se.geom, re.regionId, se.x2, se.y2, se.x1, se.y1, se.x2, se.y2, false, timestamp, scau._2, sep.priority, ucs._2.?.getOrElse(false))

tasks.list.map(NewTask.tupled(_))
}
Expand Down
Loading

0 comments on commit 4c9236b

Please sign in to comment.