Skip to content

Commit

Permalink
Merge pull request #3035 from ProjectSidewalk/develop
Browse files Browse the repository at this point in the history
v7.8.3
  • Loading branch information
misaugstad authored Sep 20, 2022
2 parents 38c0f67 + a389a7a commit 48c06ec
Show file tree
Hide file tree
Showing 12 changed files with 250 additions and 257 deletions.
314 changes: 153 additions & 161 deletions app/controllers/ProjectSidewalkAPIController.scala

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions app/controllers/TaskController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@ class TaskController @Inject() (implicit val env: Environment[User, SessionAuthe
labId
case None =>
// Get the timestamp for a new label being added to db, log an error if there is a problem w/ timestamp.
val timeCreated: Option[Timestamp] = label.timeCreated match {
case Some(time) => Some(new Timestamp(time))
val timeCreated: Timestamp = label.timeCreated match {
case Some(time) => new Timestamp(time)
case None =>
Logger.error("No timestamp given for a new label")
None
Logger.error("No timestamp given for a new label, using current time instead.")
new Timestamp(Instant.now.toEpochMilli)
}

var calculatedStreetEdgeId: Int = streetEdgeId;
Expand Down
34 changes: 27 additions & 7 deletions app/controllers/helper/ShapefilesCreatorHelper.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package controllers.helper;

import java.io.*;
import java.sql.Timestamp;
import java.util.*;
import java.util.zip.*;
import org.geotools.data.*;
Expand All @@ -12,7 +13,6 @@
import org.geotools.feature.simple.SimpleFeatureBuilder;
import org.geotools.geometry.jts.JTSFactoryFinder;
import org.locationtech.jts.geom.GeometryFactory;
import scala.Option;
import scala.runtime.AbstractFunction0;

import models.attribute.GlobalAttributeForAPI;
Expand Down Expand Up @@ -255,7 +255,7 @@ public static void createStreetShapefile(String outputFile, List<StreetAttribute
+ "streetId:Integer," // StreetId
+ "osmWayId:Integer," // osmWayId
+ "score:Double," // street score
+ "audited:Boolean," // boolean representing whether the street is audited
+ "auditCount:Integer," // boolean representing whether the street is audited
+ "sigRamp:Double," // curb ramp significance score
+ "sigNoRamp:Double," // no Curb ramp significance score
+ "sigObs:Double," // obstacle significance score
Expand Down Expand Up @@ -286,7 +286,7 @@ public static void createStreetShapefile(String outputFile, List<StreetAttribute
featureBuilder.add(s.streetID());
featureBuilder.add(s.osmID());
featureBuilder.add(s.score());
featureBuilder.add(s.audited());
featureBuilder.add(s.auditCount());
featureBuilder.add(s.significanceScores()[0]);
featureBuilder.add(s.significanceScores()[1]);
featureBuilder.add(s.significanceScores()[2]);
Expand All @@ -295,8 +295,18 @@ public static void createStreetShapefile(String outputFile, List<StreetAttribute
featureBuilder.add(s.attributeScores()[1]);
featureBuilder.add(s.attributeScores()[2]);
featureBuilder.add(s.attributeScores()[3]);
featureBuilder.add(s.avgImageDate());
featureBuilder.add(s.avgLabelDate());
featureBuilder.add(s.avgImageDate().getOrElse(new AbstractFunction0<Timestamp>() {
@Override
public Timestamp apply() {
return null;
}
}));
featureBuilder.add(s.avgLabelDate().getOrElse(new AbstractFunction0<Timestamp>() {
@Override
public Timestamp apply() {
return null;
}
}));

SimpleFeature feature = featureBuilder.buildFeature(null);
features.add(feature);
Expand Down Expand Up @@ -358,8 +368,18 @@ public static void createNeighborhoodShapefile(String outputFile, List<Neighborh
featureBuilder.add(n.attributeScores()[1]);
featureBuilder.add(n.attributeScores()[2]);
featureBuilder.add(n.attributeScores()[3]);
featureBuilder.add(n.avgImageDate());
featureBuilder.add(n.avgLabelDate());
featureBuilder.add(n.avgImageDate().getOrElse(new AbstractFunction0<Timestamp>() {
@Override
public Timestamp apply() {
return null;
}
}));
featureBuilder.add(n.avgLabelDate().getOrElse(new AbstractFunction0<Timestamp>() {
@Override
public Timestamp apply() {
return null;
}
}));

SimpleFeature feature = featureBuilder.buildFeature(null);
features.add(feature);
Expand Down
2 changes: 1 addition & 1 deletion app/formats/json/LabelFormat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ object LabelFormat {
(__ \ "panorama_lng").write[Float] and
(__ \ "deleted").write[Boolean] and
(__ \ "temporary_label_id").writeNullable[Int] and
(__ \ "time_created").writeNullable[Timestamp] and
(__ \ "time_created").write[Timestamp] and
(__ \ "tutorial").write[Boolean] and
(__ \ "street_edge_id").write[Int] and
(__ \ "agree_count").write[Int] and
Expand Down
9 changes: 3 additions & 6 deletions app/models/attribute/GlobalAttributeTable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ object GlobalAttributeTable {
| SUM(label.disagree_count) AS disagree_count,
| SUM(label.notsure_count) AS notsure_count,
| TO_TIMESTAMP(AVG(extract(epoch from label.time_created))) AS avg_label_date,
| COUNT(label.time_created) AS label_count
| COUNT(label.label_id) AS label_count
|FROM global_attribute
|INNER JOIN global_attribute_user_attribute ON global_attribute.global_attribute_id = global_attribute_user_attribute.global_attribute_id
|INNER JOIN user_attribute_label ON global_attribute_user_attribute.user_attribute_id = user_attribute_label.user_attribute_id
Expand All @@ -247,8 +247,8 @@ object GlobalAttributeTable {
| label_type.label_type,
| global_attribute.lat,
| global_attribute.lng,
| label.severity,
| label.temporary,
| global_attribute.severity,
| global_attribute.temporary,
| validation_counts.agree_count,
| validation_counts.disagree_count,
| validation_counts.notsure_count,
Expand All @@ -262,9 +262,6 @@ object GlobalAttributeTable {
|FROM global_attribute
|INNER JOIN label_type ON global_attribute.label_type_id = label_type.label_type_id
|INNER JOIN region ON global_attribute.region_id = region.region_id
|INNER JOIN global_attribute_user_attribute ON global_attribute.global_attribute_id = global_attribute_user_attribute.global_attribute_id
|INNER JOIN user_attribute_label ON global_attribute_user_attribute.user_attribute_id = user_attribute_label.user_attribute_id
|INNER JOIN label ON user_attribute_label.label_id = label.label_id
|INNER JOIN osm_way_street_edge ON global_attribute.street_edge_id = osm_way_street_edge.street_edge_id
|INNER JOIN ($validationCounts) validation_counts ON global_attribute.global_attribute_id = validation_counts.global_attribute_id
|INNER JOIN ($imageDates) image_dates ON global_attribute.global_attribute_id = image_dates.global_attribute_id
Expand Down
34 changes: 17 additions & 17 deletions app/models/label/LabelTable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import scala.slick.lifted.ForeignKeyQuery

case class Label(labelId: Int, auditTaskId: Int, missionId: Int, gsvPanoramaId: String, labelTypeId: Int,
photographerHeading: Float, photographerPitch: Float, panoramaLat: Float, panoramaLng: Float,
deleted: Boolean, temporaryLabelId: Option[Int], timeCreated: Option[Timestamp], tutorial: Boolean,
deleted: Boolean, temporaryLabelId: Option[Int], timeCreated: Timestamp, tutorial: Boolean,
streetEdgeId: Int, agreeCount: Int, disagreeCount: Int, notsureCount: Int, correct: Option[Boolean],
severity: Option[Int], temporary: Boolean, description: Option[String])

Expand All @@ -50,7 +50,7 @@ class LabelTable(tag: slick.lifted.Tag) extends Table[Label](tag, Some("sidewalk
def panoramaLng = column[Float]("panorama_lng", O.NotNull)
def deleted = column[Boolean]("deleted", O.NotNull)
def temporaryLabelId = column[Option[Int]]("temporary_label_id", O.Nullable)
def timeCreated = column[Option[Timestamp]]("time_created", O.Nullable)
def timeCreated = column[Timestamp]("time_created", O.NotNull)
def tutorial = column[Boolean]("tutorial", O.NotNull)
def streetEdgeId = column[Int]("street_edge_id", O.NotNull)
def agreeCount = column[Int]("agree_count", O.NotNull)
Expand Down Expand Up @@ -145,7 +145,7 @@ object LabelTable {

case class LabelMetadata(labelId: Int, gsvPanoramaId: String, tutorial: Boolean, imageDate: String, heading: Float,
pitch: Float, zoom: Int, canvasXY: (Int, Int), canvasWidth: Int, canvasHeight: Int,
auditTaskId: Int, userId: String, username: String, timestamp: Option[java.sql.Timestamp],
auditTaskId: Int, userId: String, username: String, timestamp: java.sql.Timestamp,
labelTypeKey: String, labelTypeValue: String, severity: Option[Int], temporary: Boolean,
description: Option[String], userValidation: Option[Int], validations: Map[String, Int],
tags: List[String])
Expand All @@ -156,17 +156,16 @@ object LabelTable {

// NOTE: canvas_x and canvas_y are null when the label is not visible when validation occurs.
case class LabelValidationMetadata(labelId: Int, labelType: String, gsvPanoramaId: String, imageDate: String,
timestamp: Option[java.sql.Timestamp], heading: Float, pitch: Float, zoom: Int,
timestamp: java.sql.Timestamp, heading: Float, pitch: Float, zoom: Int,
canvasX: Int, canvasY: Int, canvasWidth: Int, canvasHeight: Int,
severity: Option[Int], temporary: Boolean, description: Option[String],
userValidation: Option[Int], tags: List[String]) extends BasicLabelMetadata

case class LabelValidationMetadataWithoutTags(labelId: Int, labelType: String, gsvPanoramaId: String,
imageDate: String, timestamp: Option[java.sql.Timestamp],
heading: Float, pitch: Float, zoom: Int, canvasX: Int, canvasY: Int,
canvasWidth: Int, canvasHeight: Int, severity: Option[Int],
temporary: Boolean, description: Option[String],
userValidation: Option[Int]) extends BasicLabelMetadata
imageDate: String, timestamp: java.sql.Timestamp, heading: Float,
pitch: Float, zoom: Int, canvasX: Int, canvasY: Int, canvasWidth: Int,
canvasHeight: Int, severity: Option[Int], temporary: Boolean,
description: Option[String], userValidation: Option[Int]) extends BasicLabelMetadata

case class ResumeLabelMetadata(labelData: Label, labelType: String, pointData: LabelPoint, svImageWidth: Int,
svImageHeight: Int, tagIds: List[Int])
Expand All @@ -179,7 +178,7 @@ object LabelTable {
implicit val labelMetadataWithValidationConverter = GetResult[LabelMetadata](r =>
LabelMetadata(
r.nextInt, r.nextString, r.nextBoolean, r.nextString, r.nextFloat, r.nextFloat, r.nextInt, (r.nextInt, r.nextInt),
r.nextInt, r.nextInt, r.nextInt, r.nextString, r.nextString, r.nextTimestampOption, r.nextString, r.nextString,
r.nextInt, r.nextInt, r.nextInt, r.nextString, r.nextString, r.nextTimestamp, r.nextString, r.nextString,
r.nextIntOption, r.nextBoolean, r.nextStringOption, r.nextIntOption,
r.nextString.split(',').map(x => x.split(':')).map { y => (y(0), y(1).toInt) }.toMap,
r.nextStringOption.map(tags => tags.split(",").toList).getOrElse(List())
Expand All @@ -188,16 +187,17 @@ object LabelTable {

implicit val labelValidationMetadataWithoutTagsConverter = GetResult[LabelValidationMetadataWithoutTags](r =>
LabelValidationMetadataWithoutTags(
r.nextInt, r.nextString, r.nextString, r.nextString, r.nextTimestampOption, r.nextFloat, r.nextFloat, r.nextInt,
r.nextInt, r.nextInt, r.nextInt, r.nextInt, r.nextIntOption, r.nextBoolean, r.nextStringOption, r.nextIntOption
r.nextInt, r.nextString, r.nextString, r.nextString, r.nextTimestamp, r.nextFloat,
r.nextFloat, r.nextInt, r.nextInt, r.nextInt, r.nextInt, r.nextInt, r.nextIntOption, r.nextBoolean,
r.nextStringOption, r.nextIntOption
)
)

implicit val labelValidationMetadataConverter = GetResult[LabelValidationMetadata](r =>
LabelValidationMetadata(
r.nextInt, r.nextString, r.nextString, r.nextString, r.nextTimestampOption, r.nextFloat, r.nextFloat, r.nextInt,
r.nextInt, r.nextInt, r.nextInt, r.nextInt, r.nextIntOption, r.nextBoolean, r.nextStringOption,
r.nextIntOption, r.nextStringOption.map(tags => tags.split(",").toList).getOrElse(List())
r.nextInt, r.nextString, r.nextString, r.nextString, r.nextTimestamp, r.nextFloat, r.nextFloat, r.nextInt,
r.nextInt, r.nextInt, r.nextInt, r.nextInt, r.nextIntOption, r.nextBoolean, r.nextStringOption, r.nextIntOption,
r.nextStringOption.map(tags => tags.split(",").toList).getOrElse(List())
)
)

Expand All @@ -210,8 +210,8 @@ object LabelTable {
implicit val resumeLabelMetadataConverter = GetResult[ResumeLabelMetadata](r =>
ResumeLabelMetadata(
Label(r.nextInt, r.nextInt, r.nextInt, r.nextString, r.nextInt, r.nextFloat, r.nextFloat, r.nextFloat,
r.nextFloat, r.nextBoolean, r.nextIntOption, r.nextTimestampOption, r.nextBoolean, r.nextInt, r.nextInt,
r.nextInt, r.nextInt, r.nextBooleanOption, r.nextIntOption, r.nextBoolean, r.nextStringOption),
r.nextFloat, r.nextBoolean, r.nextIntOption, r.nextTimestamp, r.nextBoolean, r.nextInt, r.nextInt, r.nextInt,
r.nextInt, r.nextBooleanOption, r.nextIntOption, r.nextBoolean, r.nextStringOption),
r.nextString,
LabelPoint(r.nextInt, r.nextInt, r.nextInt, r.nextInt, r.nextInt, r.nextInt, r.nextFloat, r.nextFloat, r.nextInt,
r.nextInt, r.nextInt, r.nextFloat, r.nextFloat, r.nextFloatOption, r.nextFloatOption, r.nextGeometryOption[Point], r.nextStringOption),
Expand Down
4 changes: 2 additions & 2 deletions app/models/street/OsmWayStreetEdgeTable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ object OsmWayStreetEdgeTable {
* @return a list of (streetEdge, OsmWayStreetEdge) pairs where each list element represents a
* streetEdge and its corresponding OsmWayStreetEdge.
*/
def selectOsmWayIdsForStreets(streetEdges: List[StreetEdgeInformation]): List[(StreetEdgeInformation, OsmWayStreetEdge)] = db.withSession { implicit session =>
val streetEdgeIds: List[Int] = streetEdges.map(_.streetEdge.streetEdgeId)
def selectOsmWayIdsForStreets(streetEdges: List[StreetEdgeInfo]): List[(StreetEdgeInfo, OsmWayStreetEdge)] = db.withSession { implicit session =>
val streetEdgeIds: List[Int] = streetEdges.map(_.street.streetEdgeId)
val streetEdgesWithOsmIds = for {
_osm <- osmStreetTable if _osm.streetEdgeId inSetBind streetEdgeIds
} yield (
Expand Down
Loading

0 comments on commit 48c06ec

Please sign in to comment.