DownloadPizza
03/19/2020, 4:42 PMobject Parks : Table("p_parks") {
val id = varchar("p_id", 45)
val longitude = double("longitude")
val latitude = double("latitude")
override val primaryKey = PrimaryKey(id)
}
and im trying to select them by distance to a coordinate c
with latitude lat
and longitude lon
, but i dont want to filter them by smth like "less than 10km away" but i want the 10 nearest. Is there any way to do this without selecting all?Emil Kantis
03/19/2020, 5:53 PMDownloadPizza
03/19/2020, 7:24 PMEmil Kantis
03/19/2020, 7:36 PMORDER BY sqrt(pow(longitude - X, 2) + pow(latitude - Y, 2)) ASC
where X
and Y
should be the point you want to be the center of your query? There's some info here on running native SQL: https://github.com/JetBrains/Exposed/wiki/FAQ . might be useful 🙂ORDER BY
would run into issues when querying around the international date line, and around the north and south poles though 😁DownloadPizza
03/19/2020, 8:48 PMthan_
03/20/2020, 10:05 AM