Э
Size: a a a
E
E
return
в руби блоках.KR
#<RoutePoint:0x00007ff888f8bbe0
id: 30,
address_title: "Магнитогорск, Челябинская обл., Россия",
longitude: 59.0623067,
latitude: 53.3927214,
order_id: 38,
created_at: Wed, 13 Jan 2021 12:23:55 UTC +00:00,
updated_at: Wed, 13 Jan 2021 12:23:55 UTC +00:00>
User.last.work_area
User Load (171.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT $1 [["LIMIT", 1]]
=> #<RGeo::Geographic::SphericalPolygonImpl:0x4ba0 "POLYGON ((-84.39731626974567 33.75570358345219, -84.33139830099567 33.86524376001825, -84.25243406759724 33.770545357734925, -84.39731626974567 33.75570358345219))">
ch
v
ch
K
KR
class RoutePoint < ApplicationRecord
belongs_to :order
def self.g_within_polygon
# polygon = Geo.polygon(points)
polygon = User.last.work_area
self.where("ST_Contains(:polygon, ST_SetSRID(ST_MakePoint(longitude, latitude), #{Geo::SRID}))", polygon: Geo.to_wkt(polygon))
end
# points = [
# [-84.39731626974567, 33.75570358345219],
# [-84.33139830099567, 33.86524376001825],
# [-84.25243406759724, 33.770545357734925],
# [-84.39731626974567, 33.75570358345219]
# ]
# coords = Geo.pairs_to_points(points)
# User.last.update(work_area: Geo.polygon(coords))
end
O