Skip to content

Commit

Permalink
Merge pull request #3538 from ProjectSidewalk/develop
Browse files Browse the repository at this point in the history
v7.19.3
  • Loading branch information
misaugstad authored Apr 15, 2024
2 parents 6e31239 + 3eb6c1f commit f3cd1c3
Show file tree
Hide file tree
Showing 24 changed files with 99 additions and 61 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ On Windows, we recommend [Windows Powershell](https://docs.microsoft.com/en-us/p
root@[container-id]:/home#
```

1. In a separate terminal, run the command below.

```
docker exec -it projectsidewalk-db psql -c "CREATE ROLE saugstad SUPERUSER LOGIN ENCRYPTED PASSWORD 'sidewalk';" -U postgres -d postgres
```

1. Run `make import-dump db=<database_user>` (needs to be the same thing you set for `DATABASE_USER`) from the root project directory outside the Docker shell (from a new Ubuntu terminal). This may take a while depending on the size of the dump. Don't panic if this step fails :) and consult the [Docker Troubleshooting wiki](https://github.com/ProjectSidewalk/SidewalkWebpage/wiki/Docker-Troubleshooting). Check the output carefully. If it looks like there are errors, do not skip to the next step, check the wiki and ask Mikey if you don't find solutions in there.
1. Run `npm start` from inside the Docker shell (the terminal where you ran `make dev`). If this is your first time running the command, *everything* will need to be compiled. So, it may take 5+ minutes initially, but will be orders of magnitude faster in the future (~10 secs).

Expand Down
10 changes: 6 additions & 4 deletions app/controllers/helper/ShapefilesCreatorHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ public static void createRawLabelShapeFile(String outputFile, APIBBox bbox) thro
+ "descriptn:String," // Label Description
+ "labelDate:String," // Label date
+ "streetId:Integer," // Street edge ID of the nearest street
+ "osmWayId:String," // OSM way ID of the nearest street
+ "neighborhd:String," // Neighborhood Name
+ "correct:String," // Whether the label was validated as correct
+ "nAgree:Integer," // Agree validations
Expand Down Expand Up @@ -355,7 +356,7 @@ public static void createRawLabelShapeFile(String outputFile, APIBBox bbox) thro

// Convert the labels into a "feature".
for (LabelAllMetadata l: labels) {
featureBuilder.add(geometryFactory.createPoint(new Coordinate(l.geom().lat(), l.geom().lng())));
featureBuilder.add(geometryFactory.createPoint(new Coordinate(l.geom().lng(), l.geom().lat())));
featureBuilder.add(l.labelId());
featureBuilder.add(l.userId());
featureBuilder.add(l.panoId());
Expand All @@ -370,13 +371,14 @@ public static void createRawLabelShapeFile(String outputFile, APIBBox bbox) thro
}));
featureBuilder.add(l.timeCreated());
featureBuilder.add(l.streetEdgeId());
featureBuilder.add(String.valueOf(l.osmStreetId()));
featureBuilder.add(l.neighborhoodName());
featureBuilder.add(l.correcStr().getOrElse(new AbstractFunction0<String>() {
@Override public String apply() { return null; }
}));
featureBuilder.add(l.agreeDisagreeNotsureCount()._1());
featureBuilder.add(l.agreeDisagreeNotsureCount()._2());
featureBuilder.add(l.agreeDisagreeNotsureCount()._3());
featureBuilder.add(l.validationInfo().agreeCount());
featureBuilder.add(l.validationInfo().disagreeCount());
featureBuilder.add(l.validationInfo().notSureCount());
featureBuilder.add("[" + l.validations().mkString(",") + "]");
featureBuilder.add(l.auditTaskId());
featureBuilder.add(l.missionId());
Expand Down
13 changes: 7 additions & 6 deletions app/formats/json/APIFormats.scala
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,12 @@ object APIFormats {
"description" -> l.description,
"time_created" -> l.timeCreated,
"street_edge_id" -> l.streetEdgeId,
"osm_street_id" -> l.osmStreetId,
"neighborhood" -> l.neighborhoodName,
"correct" -> l.correct,
"agree_count" -> l.agreeDisagreeNotsureCount._1,
"disagree_count" -> l.agreeDisagreeNotsureCount._2,
"notsure_count" -> l.agreeDisagreeNotsureCount._3,
"correct" -> l.validationInfo.correct,
"agree_count" -> l.validationInfo.agreeCount,
"disagree_count" -> l.validationInfo.disagreeCount,
"notsure_count" -> l.validationInfo.notSureCount,
"validations" -> l.validations.map(v => Json.obj(
"user_id" -> v._1,
"validation" -> LabelValidationTable.validationOptions.get(v._2)
Expand Down Expand Up @@ -245,8 +246,8 @@ object APIFormats {
def rawLabelMetadataToCSVRow(l: LabelAllMetadata): String = {
s"${l.labelId},${l.geom.lat},${l.geom.lng},${l.userId},${l.panoId},${l.labelType},${l.severity.getOrElse("NA")}," +
s""""[${l.tags.mkString(",")}]",${l.temporary},"${l.description.getOrElse("NA")}",${l.timeCreated},""" +
s"${l.streetEdgeId},${l.neighborhoodName},${l.correct.getOrElse("NA")},${l.agreeDisagreeNotsureCount._1}," +
s"${l.agreeDisagreeNotsureCount._2},${l.agreeDisagreeNotsureCount._3}," +
s"${l.streetEdgeId},${l.osmStreetId},${l.neighborhoodName},${l.validationInfo.correct.getOrElse("NA")}," +
s"${l.validationInfo.agreeCount},${l.validationInfo.disagreeCount},${l.validationInfo.notSureCount}," +
s""""[${l.validations.map(v => s"{user_id: ${v._1}, validation: ${LabelValidationTable.validationOptions(v._2)}")}]",""" +
s"${l.auditTaskId},${l.missionId},${l.imageCaptureDate},${l.pov.heading},${l.pov.pitch},${l.pov.zoom}," +
s"${l.canvasXY.x},${l.canvasXY.y},${LabelPointTable.canvasWidth},${LabelPointTable.canvasHeight}," +
Expand Down
31 changes: 16 additions & 15 deletions app/models/label/LabelTable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ case class Label(labelId: Int, auditTaskId: Int, missionId: Int, userId: String,
streetEdgeId: Int, agreeCount: Int, disagreeCount: Int, notsureCount: Int, correct: Option[Boolean],
severity: Option[Int], temporary: Boolean, description: Option[String], tags: List[String])

case class LabelValidationInfo(agreeCount: Int, disagreeCount: Int, notSureCount: Int, correct: Option[Boolean])
case class POV(heading: Double, pitch: Double, zoom: Int)
case class Dimensions(width: Int, height: Int)
case class LocationXY(x: Int, y: Int)
Expand Down Expand Up @@ -207,10 +208,9 @@ object LabelTable {

case class LabelAllMetadata(labelId: Int, userId: String, panoId: String, labelType: String, severity: Option[Int],
tags: List[String], temporary: Boolean, description: Option[String], geom: LatLng,
timeCreated: Timestamp, streetEdgeId: Int, neighborhoodName: String,
agreeDisagreeNotsureCount: (Int, Int, Int), correct: Option[Boolean],
validations: List[(String, Int)], auditTaskId: Int, missionId: Int,
imageCaptureDate: String, pov: POV, canvasXY: LocationXY,
timeCreated: Timestamp, streetEdgeId: Int, osmStreetId: Long, neighborhoodName: String,
validationInfo: LabelValidationInfo, validations: List[(String, Int)], auditTaskId: Int,
missionId: Int, imageCaptureDate: String, pov: POV, canvasXY: LocationXY,
panoLocation: (LocationXY, Option[Dimensions]), cameraHeadingPitch: (Double, Double)) extends BatchableAPIType {
val gsvUrl = s"""https://maps.googleapis.com/maps/api/streetview?
|size=${LabelPointTable.canvasWidth}x${LabelPointTable.canvasHeight}
Expand All @@ -225,21 +225,21 @@ object LabelTable {
// These make the fields easier to access from Java when making Shapefiles (Booleans and Option types are an issue).
val panoWidth: Option[Int] = panoLocation._2.map(_.width)
val panoHeight: Option[Int] = panoLocation._2.map(_.height)
val correcStr: Option[String] = correct.map(_.toString)
val correcStr: Option[String] = validationInfo.correct.map(_.toString)
}
object LabelAllMetadata {
val csvHeader: String = {
"Label ID,Latitude,Longitude,User ID,Panorama ID,Label Type,Severity,Tags,Temporary,Description,Label Date," +
"Street ID,Neighborhood Name,Correct,Agree Count,Disagree Count,Not Sure Count,Validations,Task ID," +
"Mission ID,Image Capture Date,Heading,Pitch,Zoom,Canvas X,Canvas Y,Canvas Width,Canvas Height,GSV URL," +
"Panorama X,Panorama Y,Panorama Width,Panorama Height,Panorama Heading,Panorama Pitch"
"Street ID,OSM Street ID,Neighborhood Name,Correct,Agree Count,Disagree Count,Not Sure Count,Validations," +
"Task ID,Mission ID,Image Capture Date,Heading,Pitch,Zoom,Canvas X,Canvas Y,Canvas Width,Canvas Height," +
"GSV URL,Panorama X,Panorama Y,Panorama Width,Panorama Height,Panorama Heading,Panorama Pitch"
}
}
implicit val labelAllMetadataConverter = GetResult[LabelAllMetadata](r => LabelAllMetadata(
r.nextInt, r.nextString, r.nextString, r.nextString, r.nextIntOption,
r.nextStringOption.map(tags => tags.split(",").filter(_.nonEmpty).toList).getOrElse(List()), r.nextBoolean,
r.nextStringOption, LatLng(r.nextDouble, r.nextDouble), r.nextTimestamp, r.nextInt, r.nextString,
(r.nextInt, r.nextInt, r.nextInt), r.nextBooleanOption,
r.nextStringOption, LatLng(r.nextDouble, r.nextDouble), r.nextTimestamp, r.nextInt, r.nextLong, r.nextString,
LabelValidationInfo(r.nextInt, r.nextInt, r.nextInt, r.nextBooleanOption),
r.nextStringOption.map(_.split(",").map(v => (v.split(":")(0), v.split(":")(1).toInt)).toList).getOrElse(List()),
r.nextInt, r.nextInt, r.nextString, POV(r.nextDouble, r.nextDouble, r.nextInt), LocationXY(r.nextInt, r.nextInt),
(LocationXY(r.nextInt, r.nextInt), r.nextIntOption.flatMap(w => r.nextIntOption.map(h => Dimensions(w, h)))),
Expand Down Expand Up @@ -1074,14 +1074,15 @@ object LabelTable {
val labelsQuery = Q.queryNA[LabelAllMetadata](
s"""SELECT label.label_id, label.user_id, label.gsv_panorama_id, label_type.label_type, label.severity,
| array_to_string(label.tags, ','), label.temporary, label.description, label_point.lat, label_point.lng,
| label.time_created, label.street_edge_id, region.name, label.agree_count, label.disagree_count,
| label.notsure_count, label.correct, vals.validations, audit_task.audit_task_id, label.mission_id,
| gsv_data.capture_date, label_point.heading, label_point.pitch, label_point.zoom, label_point.canvas_x,
| label_point.canvas_y, label_point.pano_x, label_point.pano_y, gsv_data.width, gsv_data.height,
| gsv_data.camera_heading, gsv_data.camera_pitch
| label.time_created, label.street_edge_id, osm_way_street_edge.osm_way_id, region.name,
| label.agree_count, label.disagree_count, label.notsure_count, label.correct, vals.validations,
| audit_task.audit_task_id, label.mission_id, gsv_data.capture_date, label_point.heading,
| label_point.pitch, label_point.zoom, label_point.canvas_x, label_point.canvas_y, label_point.pano_x,
| label_point.pano_y, gsv_data.width, gsv_data.height, gsv_data.camera_heading, gsv_data.camera_pitch
|FROM label
|INNER JOIN label_type ON label.label_type_id = label_type.label_type_id
|INNER JOIN label_point ON label.label_id = label_point.label_id
|INNER JOIN osm_way_street_edge ON label.street_edge_id = osm_way_street_edge.street_edge_id
|INNER JOIN street_edge_region ON label.street_edge_id = street_edge_region.street_edge_id
|INNER JOIN region ON street_edge_region.region_id = region.region_id
|INNER JOIN audit_task ON label.audit_task_id = audit_task.audit_task_id
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import play.PlayScala

name := """sidewalk-webpage"""

version := "7.19.2"
version := "7.19.3"

scalaVersion := "2.10.7"

Expand Down
2 changes: 1 addition & 1 deletion conf/cityparams.conf
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ city-params {
burnaby = "private"
teaneck-nj = "public"
walla-walla-wa = "private"
st-louis-mo = "public"
st-louis-mo = "private"
}
launch-date {
newberg-or = "2019-01-31"
Expand Down
21 changes: 21 additions & 0 deletions conf/evolutions/default/223.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# --- !Ups
UPDATE tag SET tag = 'debris / pooled water' WHERE tag = 'pooled water';

UPDATE label SET tags = ARRAY_REPLACE(tags, 'pooled water', 'debris / pooled water');

UPDATE label_history SET tags = ARRAY_REPLACE(tags, 'pooled water', 'debris / pooled water');

UPDATE label_validation
SET old_tags = ARRAY_REPLACE(old_tags, 'pooled water', 'debris / pooled water'),
new_tags = ARRAY_REPLACE(new_tags, 'pooled water', 'debris / pooled water');

# --- !Downs
UPDATE label_validation
SET old_tags = ARRAY_REPLACE(old_tags, 'debris / pooled water', 'pooled water'),
new_tags = ARRAY_REPLACE(new_tags, 'debris / pooled water', 'pooled water');

UPDATE label_history SET tags = ARRAY_REPLACE(tags, 'debris / pooled water', 'pooled water');

UPDATE label SET tags = ARRAY_REPLACE(tags, 'debris / pooled water', 'pooled water');

UPDATE tag SET tag = 'pooled water' WHERE tag = 'debris / pooled water';
5 changes: 5 additions & 0 deletions conf/evolutions/default/224.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# --- !Ups
INSERT INTO version VALUES ('7.19.3', now(), 'Fixes validating through Gallery and LabelMap.');

# --- !Downs
DELETE FROM version WHERE version_id = '7.19.3';
7 changes: 0 additions & 7 deletions db/fix-auto-inc.sql

This file was deleted.

20 changes: 13 additions & 7 deletions db/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ psql -v ON_ERROR_STOP=1 -U postgres -d postgres <<-EOSQL
AND pid <> pg_backend_pid();
DROP DATABASE IF EXISTS "sidewalk";
DROP SCHEMA IF EXISTS sidewalk;
DROP USER IF EXISTS sidewalk;
CREATE USER sidewalk WITH PASSWORD 'sidewalk';
Expand All @@ -17,14 +16,21 @@ psql -v ON_ERROR_STOP=1 -U postgres -d postgres <<-EOSQL
ALTER USER sidewalk SUPERUSER;
GRANT ALL PRIVILEGES ON DATABASE sidewalk TO sidewalk;
CREATE SCHEMA sidewalk;
GRANT ALL ON ALL TABLES IN SCHEMA sidewalk TO sidewalk;
ALTER DEFAULT PRIVILEGES IN SCHEMA sidewalk GRANT ALL ON TABLES TO sidewalk;
ALTER DEFAULT PRIVILEGES IN SCHEMA sidewalk GRANT ALL ON SEQUENCES TO sidewalk;
CREATE USER saugstad;
GRANT sidewalk TO saugstad;
CREATE USER sidewalk_init;
GRANT sidewalk TO sidewalk_init;
EOSQL

psql -U sidewalk -d sidewalk -a -f /opt/schema.sql
psql -U sidewalk -d sidewalk -a -f /opt/fix-auto-inc.sql
psql -v ON_ERROR_STOP=1 -U sidewalk -d sidewalk <<-EOSQL
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public;
COMMENT ON EXTENSION postgis IS 'PostGIS geometry, geography, and raster spatial types and functions';
EOSQL

pg_restore -U sidewalk -Fc -d sidewalk /opt/sidewalk_init_dump

# Remove any password authentication on databases. This should be used for dev environment only.
sed -i -e 's/host all all all scram-sha-256/host all all all trust/' /var/lib/postgresql/data/pg_hba.conf
7 changes: 6 additions & 1 deletion public/javascripts/Admin/src/Admin.GSVLabelView.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ function AdminGSVLabelView(admin, source) {
label_id: self.panorama.label.labelId,
label_type: self.panorama.label.label_type,
validation_result: self.resultOptions[action],
old_severity: self.panorama.label.oldSeverity,
new_severity: self.panorama.label.newSeverity,
old_tags: self.panorama.label.oldTags,
new_tags: self.panorama.label.newTags,
canvas_x: labelCanvasX,
canvas_y: labelCanvasY,
heading: userPov.heading,
Expand Down Expand Up @@ -421,7 +425,8 @@ function AdminGSVLabelView(admin, source) {

var adminPanoramaLabel = AdminPanoramaLabel(labelMetadata['label_id'], labelMetadata['label_type_key'],
labelMetadata['canvas_x'], labelMetadata['canvas_y'], util.EXPLORE_CANVAS_WIDTH, util.EXPLORE_CANVAS_HEIGHT,
labelMetadata['heading'], labelMetadata['pitch'], labelMetadata['zoom'], labelMetadata['street_edge_id']);
labelMetadata['heading'], labelMetadata['pitch'], labelMetadata['zoom'], labelMetadata['street_edge_id'],
labelMetadata['severity'], labelMetadata['tags']);
self.panorama.setLabel(adminPanoramaLabel);

self.validationCounts['Agree'] = labelMetadata['num_agree']
Expand Down
8 changes: 7 additions & 1 deletion public/javascripts/Admin/src/Admin.Panorama.Label.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
* @param pitch
* @param zoom
* @param streetEdgeId
* @param severity
* @param tags
* @returns {{className: string}}
* @constructor
*/
function AdminPanoramaLabel(labelId, labelType, canvasX, canvasY, originalCanvasWidth, originalCanvasHeight,
heading, pitch, zoom, streetEdgeId) {
heading, pitch, zoom, streetEdgeId, severity, tags) {
var self = { className: "AdminPanoramaLabel" };

/**
Expand All @@ -31,6 +33,10 @@ function AdminPanoramaLabel(labelId, labelType, canvasX, canvasY, originalCanvas
self.pitch = pitch;
self.zoom = zoom;
self.streetEdgeId = streetEdgeId;
self.oldSeverity = severity;
self.newSeverity = severity;
self.oldTags = tags;
self.newTags = tags;
return this;
}

Expand Down
4 changes: 4 additions & 0 deletions public/javascripts/Gallery/src/validation/ValidationMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ function ValidationMenu(refCard, gsvImage, cardProperties, modal, onExpandedView
label_id: currCardProperties.label_id,
label_type: currCardProperties.label_type,
validation_result: resultOptions[action],
old_severity: currCardProperties.severity,
new_severity: currCardProperties.severity,
old_tags: currCardProperties.tags,
new_tags: currCardProperties.tags,
canvas_height: gsvImage.height(),
canvas_width: gsvImage.width(),
start_timestamp: validationTimestamp,
Expand Down
4 changes: 2 additions & 2 deletions public/javascripts/common/UtilitiesSidewalk.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ function UtilitiesMisc (JSON) {
keyChar: 'R',
text: i18next.t('center-ui.context-menu.tag.surface-problem')
},
'pooled water': {
'debris / pooled water': {
keyChar: 'D',
text: i18next.t('center-ui.context-menu.tag.pooled-water')
text: i18next.t('center-ui.context-menu.tag.debris-pooled-water')
},
'parallel lines': {
keyChar: 'J',
Expand Down
2 changes: 1 addition & 1 deletion public/locales/de/audit.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"not-enough-landing-space": "nicht genug P<tag-underline>l</tag-underline>atz",
"not-level-with-street": "nicht auf dem selben Ni<tag-underline>v</tag-underline>eau wie Strasse",
"surface-problem": "Obe<tag-underline>r</tag-underline>flächenproblem",
"pooled-water": "Wasserpfütze (<tag-underline>d</tag-underline>)",
"debris-pooled-water": "Schmutz/Wasserpfütze (<tag-underline>d</tag-underline>)",
"parallel-lines": "parallele Linien (<tag-underline>j</tag-underline>)",
"alternate-route-present": "<tag-underline>a</tag-underline>lternative Route vorhanden",
"no-alternate-route": "keine a<tag-underline>l</tag-underline>ternative Route vorhanden",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/de/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"not enough landing space": "nicht genug Platz",
"not level with street": "nicht auf dem selben Niveau wie Strasse",
"surface problem": "Oberflächenproblem",
"pooled water": "Wasserpfütze",
"debris / pooled water": "Schmutz/Wasserpfütze",
"parallel lines": "parallele Linien",
"alternate route present": "alternative Route vorhanden",
"no alternate route": "keine alternative Route vorhanden",
Expand Down
Loading

0 comments on commit f3cd1c3

Please sign in to comment.