Skip to content

Commit

Permalink
Merge pull request #3454 from ProjectSidewalk/3437-GeoJSON-API-file-d…
Browse files Browse the repository at this point in the history
…ownload

3437 geo json api file download
  • Loading branch information
misaugstad authored Jan 23, 2024
2 parents 6008a0e + a32afaf commit f7c4bcd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
10 changes: 6 additions & 4 deletions app/controllers/ProjectSidewalkAPIController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,11 @@ class ProjectSidewalkAPIController @Inject()(implicit val env: Environment[User,
* @param lng2
* @param severity
* @param filetype
* @param inline
* @return
*/
def getAccessAttributesWithLabelsV2(lat1: Option[Double], lng1: Option[Double], lat2: Option[Double], lng2: Option[Double],
severity: Option[String], filetype: Option[String]) = UserAwareAction.async { implicit request =>
severity: Option[String], filetype: Option[String], inline: Option[Boolean]) = UserAwareAction.async { implicit request =>
apiLogging(request.remoteAddress, request.identity, request.toString)

val cityMapParams: MapParams = ConfigTable.getCityMapParams
Expand Down Expand Up @@ -186,7 +187,7 @@ class ProjectSidewalkAPIController @Inject()(implicit val env: Environment[User,
writer.print("]}")
writer.close()

Future.successful(Ok.sendFile(content = attributesJsonFile, inline = true, onClose = () => attributesJsonFile.delete()))
Future.successful(Ok.sendFile(content = attributesJsonFile, inline = inline.getOrElse(false), onClose = () => attributesJsonFile.delete()))
}
}

Expand All @@ -199,10 +200,11 @@ class ProjectSidewalkAPIController @Inject()(implicit val env: Environment[User,
* @param lng2
* @param severity
* @param filetype
* @param inline
* @return
*/
def getAccessAttributesV2(lat1: Option[Double], lng1: Option[Double], lat2: Option[Double], lng2: Option[Double],
severity: Option[String], filetype: Option[String]) = UserAwareAction.async { implicit request =>
severity: Option[String], filetype: Option[String], inline: Option[Boolean]) = UserAwareAction.async { implicit request =>
apiLogging(request.remoteAddress, request.identity, request.toString)

val cityMapParams: MapParams = ConfigTable.getCityMapParams
Expand Down Expand Up @@ -247,7 +249,7 @@ class ProjectSidewalkAPIController @Inject()(implicit val env: Environment[User,
writer.print("]}")
writer.close()

Future.successful(Ok.sendFile(content = attributesJsonFile, inline = true, onClose = () => attributesJsonFile.delete()))
Future.successful(Ok.sendFile(content = attributesJsonFile, inline = inline.getOrElse(false), onClose = () => attributesJsonFile.delete()))
}
}

Expand Down
4 changes: 2 additions & 2 deletions conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ POST /userapi/logWebpageActivity @controllers.UserCo
PUT /userapi/setUserOrg/:orgId @controllers.UserProfileController.setUserOrg(orgId: Int)

# Access Feature and Access Score APIs
GET /v2/access/attributes @controllers.ProjectSidewalkAPIController.getAccessAttributesV2(lat1: Option[Double], lng1: Option[Double], lat2: Option[Double], lng2: Option[Double], severity: Option[String], filetype: Option[String])
GET /v2/access/attributesWithLabels @controllers.ProjectSidewalkAPIController.getAccessAttributesWithLabelsV2(lat1: Option[Double], lng1: Option[Double], lat2: Option[Double], lng2: Option[Double], severity: Option[String], filetype: Option[String])
GET /v2/access/attributes @controllers.ProjectSidewalkAPIController.getAccessAttributesV2(lat1: Option[Double], lng1: Option[Double], lat2: Option[Double], lng2: Option[Double], severity: Option[String], filetype: Option[String], inline: Option[Boolean])
GET /v2/access/attributesWithLabels @controllers.ProjectSidewalkAPIController.getAccessAttributesWithLabelsV2(lat1: Option[Double], lng1: Option[Double], lat2: Option[Double], lng2: Option[Double], severity: Option[String], filetype: Option[String], inline: Option[Boolean])
GET /v2/access/score/streets @controllers.ProjectSidewalkAPIController.getAccessScoreStreetsV2(lat1: Option[Double], lng1: Option[Double], lat2: Option[Double], lng2: Option[Double], filetype: Option[String])
GET /v2/access/score/neighborhoods @controllers.ProjectSidewalkAPIController.getAccessScoreNeighborhoodsV2(lat1: Option[Double], lng1: Option[Double], lat2: Option[Double], lng2: Option[Double], filetype: Option[String])
GET /v2/userStats @controllers.ProjectSidewalkAPIController.getUsersAPIStats(filetype: Option[String])
Expand Down
8 changes: 5 additions & 3 deletions public/javascripts/developer.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,16 @@ function Developer () {
var regionsURLCSV = `/v2/access/score/neighborhoods?lat1=${data.region.lat1}&lng1=${data.region.lng1}&lat2=${data.region.lat2}&lng2=${data.region.lng2}&filetype=csv`;
var regionsURLShapeFile = `/v2/access/score/neighborhoods?lat1=${data.region.lat1}&lng1=${data.region.lng1}&lat2=${data.region.lat2}&lng2=${data.region.lng2}&filetype=shapefile`;

var inline = '&inline=true';

// Fill in example URLs in HTML.
$('#attributes-link').attr('href', attributesURL);
$('#attributes-link').attr('href', attributesURL + inline);
$('#attributes-code').html(attributesURL);
$('#attributes-link-CSV').attr('href', attributesURLCSV);
$('#attributes-code-CSV').html(attributesURLCSV);
$('#attributes-link-severity').attr('href', attributesURLSeverity);
$('#attributes-link-severity').attr('href', attributesURLSeverity + inline);
$('#attributes-code-severity').html(attributesURLSeverity);
$('#attributes-with-labels-link').attr('href', attributeWithLabelsURL);
$('#attributes-with-labels-link').attr('href', attributeWithLabelsURL + inline);
$('#attributes-with-labels-code').html(attributeWithLabelsURL);
$('#streets-link').attr('href', streetsURL);
$('#streets-code').html(streetsURL);
Expand Down

0 comments on commit f7c4bcd

Please sign in to comment.