Skip to content

Commit

Permalink
🐛 fix latitude and longitude inverted
Browse files Browse the repository at this point in the history
  • Loading branch information
Alban Rahier committed Nov 4, 2022
1 parent b653057 commit 9d6e6f7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ func (c *Controller) GetGeoPoint(ctx *gin.Context) {
ctx.AbortWithError(http.StatusForbidden, errors.New("geopoint is not enabled yet")).SetType(gin.ErrorTypePublic)
return
}
geopoint.Latitude = geopoint.Location.X
geopoint.Longitude = geopoint.Location.Y
geopoint.Latitude = geopoint.Location.Y
geopoint.Longitude = geopoint.Location.X

ctx.JSON(http.StatusOK, geopoint)
}
Expand Down Expand Up @@ -369,7 +369,7 @@ func (c *Controller) CreateGeoPoint(ctx *gin.Context) {
bindGeo, _ := ctx.MustGet("bindGeo").(geopoint.BindGeoPoint)
geoPoint, _ := ctx.MustGet("geoPoint").(geopoint.GeoPoint)

dbGeoPoint := geopoint.DbGeoPoint{GeoPoint: &geoPoint, Location: postgis.PointS{SRID: geopoint.WGS84, X: geoPoint.Latitude, Y: geoPoint.Longitude}}
dbGeoPoint := geopoint.DbGeoPoint{GeoPoint: &geoPoint, Location: postgis.PointS{SRID: geopoint.WGS84, X: geoPoint.Longitude, Y: geoPoint.Latitude}}
stmt, err := c.Db.PrepareNamed("INSERT INTO geopoints (title, user_id, location, amplitudes, picture, sound, created_on) VALUES (:title,:user_id,GeomFromEWKB(:location),:amplitudes,:picture,:sound,:created_on) RETURNING id")
if err != nil {
ctx.AbortWithError(http.StatusInternalServerError, fmt.Errorf("could not prepare geopoint creation: %s", err))
Expand Down

0 comments on commit 9d6e6f7

Please sign in to comment.