88 "github.com/photoprism/photoprism/internal/auth/acl"
99 "github.com/photoprism/photoprism/internal/photoprism/get"
1010 "github.com/photoprism/photoprism/internal/service/hub/places"
11+ "github.com/photoprism/photoprism/pkg/clean"
1112 "github.com/photoprism/photoprism/pkg/txt"
1213)
1314
@@ -19,12 +20,13 @@ import (
1920// @Id GetPlacesReverse
2021// @Tags Places
2122// @Produce json
22- // @Param lat query string true "Latitude"
23- // @Param lng query string true "Longitude"
24- // @Success 200 {object} places.Location
25- // @Failure 400 {object} gin.H "Missing latitude or longitude"
26- // @Failure 401 {object} i18n.Response
27- // @Failure 500 {object} gin.H "Geocoding service error"
23+ // @Param lat query string true "Latitude"
24+ // @Param lng query string true "Longitude"
25+ // @Param locale query string false "Locale"
26+ // @Success 200 {object} places.Location
27+ // @Failure 400 {object} gin.H "Missing latitude or longitude"
28+ // @Failure 401 {object} i18n.Response
29+ // @Failure 500 {object} gin.H "Geocoding service error"
2830// @Router /api/v1/places/reverse [get]
2931func GetPlacesReverse (router * gin.RouterGroup ) {
3032 handler := func (c * gin.Context ) {
@@ -44,7 +46,7 @@ func GetPlacesReverse(router *gin.RouterGroup) {
4446 return
4547 }
4648
47- // Get latitude and longitude from query parameters.
49+ // Get latitude, longitude, and locale from query parameters.
4850 var lat , lng string
4951
5052 if lat = txt .Numeric (c .Query ("lat" )); lat == "" {
@@ -61,14 +63,19 @@ func GetPlacesReverse(router *gin.RouterGroup) {
6163 return
6264 }
6365
64- result , err := places . LatLng ( txt . Float64 ( lat ), txt . Float64 ( lng ))
66+ locale := clean . WebLocale ( c . Query ( "locale" ), conf . PlacesLocale ( ))
6567
68+ // Perform service request.
69+ result , err := places .LatLng (txt .Float64 (lat ), txt .Float64 (lng ), locale )
70+
71+ // Return error if request was not successful.
6672 if err != nil {
6773 log .Errorf ("places: failed to resolve location at lat %s, lng %s" , lat , lng )
6874 c .AbortWithStatusJSON (http .StatusInternalServerError , gin.H {"error" : err })
6975 return
7076 }
7177
78+ // Return location details.
7279 c .JSON (http .StatusOK , result )
7380 }
7481
0 commit comments