{"id":359027,"date":"2024-05-21T00:23:57","date_gmt":"2024-05-21T00:23:57","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=359027"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-21T00:23:57","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=359027","title":{"rendered":"<span>\u0416\u0438\u043b\u044c\u0435 \u0432 500\u043c \u043e\u0442 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u044b\u0445 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u043e\u0432 \u0432 \u041c\u043e\u0441\u043a\u0432\u0435. \u0418\u043b\u0438 \u043a\u0430\u043a \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u043d\u0430 \u041b\u0435\u043d\u0442\u0430.\u0440\u0443 \u0438\u0437\u0431\u0435\u0433\u0430\u0435\u0442 \u0425\u0430\u0431\u0440 \u0438 \u0434\u0435\u0437\u0438\u043d\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u044f\u0442\u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u0436\u0438\u0432\u0435\u0448\u044c \u0442\u0430\u043c \u0433\u0434\u0435 \u0443 \u0442\u0435\u0431\u044f \u0432\u0445\u043e\u0434 \u0432 <a href=\"https:\/\/habr.com\/ru\/articles\/770044\/\" rel=\"noopener noreferrer nofollow\">\u043c\u0435\u0442\u0440\u043e \u0432 15 \u043c\u0438\u043d\u0443\u0442\u0430\u0445 \u0445\u043e\u0434\u044c\u0431\u044b<\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/761600\/\" rel=\"noopener noreferrer nofollow\">\u0441 \u043a\u043e\u043c\u0444\u043e\u0440\u0442\u043e\u043c \u0436\u0438\u0437\u043d\u0438 \u043d\u0435\u043f\u043b\u043e\u0445\u043e<\/a>. \u041d\u043e \u043a\u0443\u0448\u0430\u0442\u044c \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0432\u0441\u0435\u0433\u0434\u0430, \u0430 \u043d\u0430 \u0440\u0430\u0431\u043e\u0447\u0435\u0439 \u043d\u0435\u0434\u0435\u043b\u0435 \u0443\u0436 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u044f \u0435\u0445\u0430\u0442\u044c \u0432 \u0441\u0443\u043f\u0435\u0440\u043c\u0430\u0440\u043a\u0435\u0442 \u0447\u0442\u043e\u0431\u044b \u0441\u0432\u0430\u0440\u0438\u0442\u044c \u0433\u0440\u0435\u0447\u043d\u0435\u0432\u0443\u044e \u043a\u0430\u0448\u0443 \u0438 \u0432\u0437\u044f\u0442\u044c \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043d\u0430 \u0437\u0430\u0432\u0442\u0440\u0430\u043a. \u041c\u0430\u0433\u0430\u0437\u0438\u043d\u044b \u0448\u0430\u0433\u043e\u0432\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u0435\u0441\u0442\u044c \u0432\u0435\u0437\u0434\u0435, \u043d\u043e \u043c\u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u0435, \u0442\u0438\u043f\u0430 \u041f\u044f\u0442\u0451\u0440\u043e\u0447\u043a\u0438, \u0414\u0438\u043a\u0441\u0438, \u041c\u0430\u0433\u043d\u0438\u0442\u0430, \u041f\u0435\u0440\u0435\u043a\u0440\u0451\u0441\u0442\u043a\u0430, \u041c\u0430\u0433\u043d\u043e\u043b\u0438\u0438, \u0410\u0442\u0430\u043a \u0438\u043b\u0438 \u041b\u0435\u043d\u0442\u044b.<\/p>\n<p>\u0416\u0438\u0437\u043d\u044c \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u0444\u0430\u043a\u0442\u043e\u0440\u0443 \u0432 \u0421\u0435\u0440\u0435\u0431\u0440\u044f\u043d\u043e\u043c \u0431\u043e\u0440\u0443( \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u0435\u0439  \u0432 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043e\u0442 \u043d\u0435\u0431\u043b\u0430\u0433\u043e\u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0445 \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432) \u043e\u0442\u043f\u0430\u0434\u0430\u0435\u0442 \u0441\u0440\u0430\u0437\u0443 &#8212; \u0442\u0430\u043c \u0438 \u0434\u043e \u043c\u0435\u0442\u0440\u043e \u043d\u0435 \u0431\u043b\u0438\u0437\u043a\u043e! \u041d\u0430\u0439\u0434\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430 \u0434\u043b\u044f \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u043e\u0439 \u0436\u0438\u0437\u043d\u0438 \u0438 \u043f\u043e\u0445\u043e\u0434\u0430 \u0432 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u044b\u0439 \u043c\u0430\u0433\u0430\u0437\u0438\u043d.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/1cf\/a4e\/040\/1cfa4e0406fa480640979b9c5b27e437.jpg\" width=\"1331\" height=\"1080\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1cf\/a4e\/040\/1cfa4e0406fa480640979b9c5b27e437.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u042d\u0442\u043e \u043a\u0430\u043a \u0432 \u0434\u0438\u043b\u0435\u043c\u0435 \u0447\u0442\u043e \u043f\u0435\u0440\u0432\u0435\u0435: \u043a\u0443\u0440\u0438\u0446\u0430 \u0438\u043b\u0438 \u044f\u0439\u0446\u043e, \u0442\u0430\u043a \u0436\u0435 \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u044b\u0439\/\u0436\u0438\u043b\u043e\u0439 \u0440\u0430\u0439\u043e\u043d. \u041a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u044b \u0442\u043e\u0440\u0433\u043e\u0432\u044b\u0445 \u0441\u0435\u0442\u0435\u0439 \u0442\u0440\u0430\u0442\u044f\u0442 \u0434\u0435\u043d\u044c\u0433\u0438 \u043d\u0430 \u0433\u0435\u043e\u0430\u043d\u0430\u043b\u0438\u0437 \u0433\u0434\u0435 \u0438\u043c \u043b\u0443\u0447\u0448\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u044b\u0439 \u043c\u0430\u0433\u0430\u0437\u0438\u043d. \u0422\u0430\u043a \u0447\u0442\u043e \u0432 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u0432\u0438\u0434\u0435 \u043c\u044b \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0438\u0445 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0443 \u0438 \u043d\u0430\u0439\u0434\u0435\u043c \u0433\u0434\u0435 \u0436\u0438\u0432\u0443\u0442 \u043c\u043e\u0438 \u0441\u043e\u0441\u0435\u0434\u0438. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043d\u0443\u0436\u043d\u0430 \u0434\u0440\u0443\u0433\u0430\u044f \u0433\u0440\u0443\u043f\u043f\u0430 \u0441\u043e\u0441\u0435\u0434\u0435\u0439, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0438\u0441\u043a\u0430\u0442\u044c \u043e\u043a\u0440\u0435\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0410\u0437\u0431\u0443\u043a\u0438 \u0412\u043a\u0443\u0441\u0430 \u0438 \u0431\u044b\u0432\u0448\u0435\u0433\u043e \u0415\u043b\u0438\u0441\u0435\u0435\u0432\u0441\u043a\u043e\u0433\u043e.<\/p>\n<p>\u041f\u0440\u043e \u0442\u043e \u043a\u0430\u043a \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u0434\u043b\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430 \u0438 \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u0447\u0435\u0441\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/articles\/778970\/\" rel=\"noopener noreferrer nofollow\">\u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0432 \u044d\u0442\u043e\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<p>\u0414\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0431\u0443\u0434\u0443 \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u0435\u043e\u0434\u0430\u043d\u043d\u044b\u0435 OSM, \u0438 \u0432\u043e\u0442 \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u043e\u0432 \u0431\u0435\u0437 &#171;\u0447\u0435\u0440\u043d\u043e\u0439 \u043c\u0430\u0433\u0438\u0438&#187; \u043c\u043d\u0435 \u043d\u0435 \u0443\u0434\u0430\u0441\u0442\u0441\u044f \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u043d\u043e \u043e\u043f\u0435\u0447\u0430\u0442\u043e\u043a, \u0440\u0430\u0437\u043d\u044b\u0445 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0439 \u0438 \u0440\u0430\u0437\u043d\u043e\u0448\u0451\u0440\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0432 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445. \u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0441\u0430 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u043e\u0435 \u0437\u0430\u043a\u043b\u0438\u043d\u0430\u043d\u0438\u0435:<\/p>\n<pre><code class=\"sql\">create temporary table supermarket_entrance as    select id, centre, tags      from geometry_global_view      where (tags@>'shop=>supermarket' or tags@>'shop=>convenience') and      (tags->'brand' in ('\u041f\u044f\u0442\u0451\u0440\u043e\u0447\u043a\u0430','\u0412\u043a\u0443\u0441\u0412\u0438\u043b\u043b','\u0414\u0438\u043a\u0441\u0438','\u041c\u0430\u0433\u043d\u0438\u0442',                                '\u041f\u0435\u0440\u0435\u043a\u0440\u0451\u0441\u0442\u043e\u043a','\u041c\u0430\u0433\u043d\u043e\u043b\u0438\u044f','\u041f\u0435\u0440\u0435\u043a\u0440\u0435\u0441\u0442\u043e\u043a',                                '\u041b\u0435\u043d\u0442\u0430','Eurospar','\u0410\u0448\u0430\u043d','\u0421\u0443\u043f\u0435\u0440 \u041b\u0435\u043d\u0442\u0430',                                '\u0410\u0442\u0430\u043a','\u0421\u0443\u043f\u0435\u0440\u041b\u0435\u043d\u0442\u0430','\u041e\u2019\u041a\u0415\u0419','Spar',                                '\u041f\u0435\u0440\u0435\u043a\u0440\u0435\u0441\u0442\u043e\u043a \u042d\u043a\u0441\u043f\u0440\u0435\u0441\u0441','SPAR',                                'METRO Cash &amp; Carry','EuroSPAR','\u0410\u0422\u0410\u041a',                                '\u0410\u0448\u0430\u043d \u0421\u0438\u0442\u0438','\u041c\u0438\u043d\u0438 \u041b\u0435\u043d\u0442\u0430','EUROSPAR',                                '\u041c\u0438\u043d\u0438\u041b\u0435\u043d\u0442\u0430','METRO','Auchan','\u0441\u0443\u043f\u0435\u0440 \u041b\u0435\u043d\u0442\u0430')      or tags@>'brand:wikipedia=>ru:Auchan');<\/code><\/pre>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a \u0430\u043d\u0430\u043b\u0438\u0437\u0443 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/articles\/770044\/\" rel=\"noopener noreferrer nofollow\">\u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a>. \u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0437 \u0433\u0435\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043c\u0430\u0432\u0437\u043e\u043b\u0435\u0439 \u043d\u0430 \u041a\u0440\u0430\u0441\u043d\u043e\u0439 \u043f\u043b\u043e\u0449\u0430\u0434\u0438 \u0438 \u041a\u0440\u0435\u043c\u043b\u0435\u0432\u0441\u043a\u0438\u0435 \u0431\u0430\u0448\u043d\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044e \u0444\u0438\u043b\u044c\u0442\u0440:<code>not(b.tags?'tomb') and not(b.tags?'man_made')<\/code> \u0438 \u043d\u0430\u0439\u0434\u0443 \u0436\u0438\u043b\u044b\u0435 \u0437\u0434\u0430\u043d\u0438\u044f \u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0445 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u043e\u0432:<\/p>\n<pre><code class=\"sql\">explain create table living_building_near as select m.id supermarket_entrance_id,st_x(m.centre) supermarket_entrance_x,st_y(m.centre) supermarket_entrance_y,        array_agg((b.id,b.type,st_x(b.centre),st_y(b.centre))::building_info) buildings   from supermarket_entrance m inner join geometry_global_view b on     b.tags?'building' and     not(b.tags?'amenity') and     not(b.tags?'shop') and     not(b.tags?'tomb') and     not(b.tags?'man_made') and     b.tags->'building' not in --\u0432 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u043d\u0438\u0436\u0435 \u0437\u0434\u0430\u043d\u0438\u044f\u0445 \u043d\u0435 \u0436\u0438\u0432\u0443\u0442 \u043d\u0430 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0439 \u043e\u0441\u043d\u043e\u0432\u0435         ('service','garages','industrial','retail','office','roof','commercial','garage','kiosk','warehouse','church',         'parking','public','shed','hangar','train_station','guardhouse','transportation','terrace','greenhouse','bridge',         'government','chapel','gazebo','civic','ruins','supermarket','sports_centre','semidetached_house','toilets',         'sports_hall','clinic','farm_auxiliary','stable','grandstand','bunker','gatehouse','store','temple','ventilation_kiosk',         'carport','cowshed','barracks','shop','cabin','barn','cathedral','wall','townhouse','manufacture','shelter',         'fire_station','stadium','stands','sport_hall','theatre','storage_tank','checkpoint','houseboat','abandoned','dovecote',         'mosque','museum','military','container','observatory','lift','tent','factory','sport','mall','riding_hall','depot',         'prison','gate','triumphal_arch','water_works','public_building','pavilion','bank','institute','works','collapsed',         'car_repair','crossing_box','fuel','tree_house','presbytery','yesq','farm','outbuilding','police','porch','sauna',         'monastery','cinema','tower','boathouse','library','transformer_tower','heat_exchange_station','ice_rink','entrance','construction','transformer'         ) and      ST_DWithin(b.geom::geography,m.centre::geography,500)    group by 1,2,3; -- create table living_building_near as select m.id supermarket_entrance_id,st_x(m.centre) supermarket_entrance_x,st_y(m.centre) supermarket_entrance_y,array_agg((b.id,b.type,st_x(b.centre),st_y(b.centre))::building_info) buildings from supermarket_entrance m inner join geometry_global_view b on b.tags?'_lb' and ST_DWithin(b.geom::geography,m.centre::geography,500) group by 1,2,3;<\/code><\/pre>\n<p>\u041f\u043e\u0441\u0447\u0438\u0442\u0430\u044e \u043f\u0435\u0448\u0435\u0445\u043e\u0434\u043d\u044b\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043e\u0442 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430 \u0434\u043e \u0434\u043e\u043c\u043e\u0432 \u0432 \u0440\u0430\u0434\u0438\u0443\u0441\u0435 500\u043c. \u0427\u0442\u043e\u0431\u044b \u0443\u0447\u0435\u0441\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0438 \u043a\u043e\u0433\u0434\u0430 \u0434\u043e\u043c \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u043a\u0443 \u0438\u043b\u0438 \u0430\u0432\u0442\u043e\u0441\u0442\u0440\u0430\u0434\u0443 \u0431\u0435\u0437 \u043f\u043e\u0434\u0437\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430, \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0440\u0430\u0441\u0447\u0435\u0442 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f.<\/p>\n<details class=\"spoiler\">\n<summary>GraphHopper 8 \u043a\u0430\u043a \u0434\u0432\u0438\u0436\u043e\u043a \u0440\u0430\u0441\u0447\u0435\u0442\u0430 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u0438 Java \u043a\u043e\u0434 \u0434\u043b\u044f \u043d\u0435\u0433\u043e.<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"sql\">create table supermarket_distance(                 entrance_id bigint,                 building_id bigint,                 building_type table_reference,                 distance smallint,                 primary key(entrance_id,building_id,building_type) );<\/code><\/pre>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441 \u0440\u0430\u0441\u0447\u0435\u0442\u043e\u043c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 &#8212; \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u0441\u0435\u0440\u0432\u0438\u0441 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439 \u043a\u0430\u043a REST \u0447\u0435\u0440\u0435\u0437 TCP \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f round trip \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u043a \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443  <strong>\u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Graphhopper \u043a\u0430\u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0431\u0435\u0437 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043f\u043e HTTP<\/strong>:<\/p>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"java\">package com.github.isuhorukov.routing;  import com.graphhopper.GHRequest; import com.graphhopper.GHResponse; import com.graphhopper.GraphHopper; import com.graphhopper.ResponsePath; import com.graphhopper.config.CHProfile; import com.graphhopper.config.Profile; import org.postgresql.jdbc.PgArray; import org.postgresql.util.PGobject;  import java.sql.*; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors;  public class Routing {      public static final int MAX_DISTANCE = 500;      public static void main(String[] args) throws Exception {         GraphHopper hopper = getGraphHopper();         try (Connection connection = DriverManager.getConnection(                 System.getenv(\"jdbc_url\"), System.getenv(\"user\"), System.getenv(\"password\"))) {             connection.setAutoCommit(false);             try {                 var distances = calculateDistances(connection, hopper);                 saveDistance(connection, distances);             } catch (SQLException e) {                 connection.rollback();                 throw e;             }         }     }      private static GraphHopper getGraphHopper() {         var hopper = new GraphHopper();         hopper.setOSMFile(System.getenv(\"osm_file\"));         hopper.setGraphHopperLocation(\"route\");         hopper.getCHPreparationHandler().setCHProfiles(new CHProfile(\"foot\"));         hopper.setProfiles(new Profile(\"foot\").setVehicle(\"foot\"));         hopper.importOrLoad();         return hopper;     }      private static List&lt;Distance> calculateDistances(Connection connection, GraphHopper hopper) throws SQLException {         List&lt;Distance> distances = new ArrayList&lt;>();         try (Statement supermarketQuery = connection.createStatement()){             int step=0;             try (ResultSet livingBuilding = supermarketQuery.executeQuery(\"select * from living_building_near\")){                 while (livingBuilding.next()){                     long supermarketEntranceId = livingBuilding.getLong(\"supermarket_entrance_id\");                     double supermarketEntranceX = livingBuilding.getDouble(\"supermarket_entrance_x\");                     double supermarketEntranceY = livingBuilding.getDouble(\"supermarket_entrance_y\");                     PgArray buildingsArray = (PgArray) livingBuilding.getArray(\"buildings\");                     List&lt;Building> buildings = mapBuildings(buildingsArray);                     System.out.println(step++);                     distances.addAll(buildings.stream().map(building -> {                         short distance = calculateDistances(hopper, building, supermarketEntranceY, supermarketEntranceX);                         return new Distance(supermarketEntranceId,building.buildingId, building.buildingType, distance);                     }).collect(Collectors.toList()));                 }             }         }         return distances;     }      private static void saveDistance(Connection connection, List&lt;Distance> distances) throws SQLException {         try (PreparedStatement insert = connection.prepareStatement(                 \"insert into supermarket_distance(entrance_id,building_id,building_type,distance) \" +                         \"values (?,?,?::table_reference,?)\")){             distances.forEach(distance -> {                 if(distance.distance> MAX_DISTANCE) return;                 try {                     insert.setLong(1, distance.supermarketEntranceId);                     insert.setLong(2, distance.buildingId);                     insert.setString(3, distance.buildingType);                     insert.setShort(4, distance.distance);                     insert.addBatch();                 } catch (SQLException e) {                     throw new RuntimeException(e);                 }             });             insert.executeBatch();             connection.commit();         }     }      private static List&lt;Building> mapBuildings(PgArray buildingsArray) throws SQLException {         return getPgObjects(buildingsArray).stream().map(pGobject -> {             String value = pGobject.getValue();             if(value==null || value.length()&lt;=2){                 throw new IllegalArgumentException();             }             String[] parts = value.substring(1, value.length() - 1).split(\",\");             long buildingId = Long.parseLong(parts[0]);             String buildingType = parts[1];             double buildingX = Double.parseDouble(parts[2]);             double buildingY = Double.parseDouble(parts[3]);             return new Building(buildingId, buildingType, buildingX, buildingY);         }).collect(Collectors.toList());     }      private static List&lt;PGobject> getPgObjects(PgArray buildingsArray) throws SQLException {         Object[] array = (Object[]) buildingsArray.getArray();         buildingsArray.free();         return Arrays.stream(array).map(object -> (PGobject) object).collect(Collectors.toList());     }      private static short calculateDistances(GraphHopper hopper,                                       Building building, double supermarketEntranceY, double supermarketEntranceX) {         GHRequest request = new GHRequest(supermarketEntranceY, supermarketEntranceX, building.buildingY, building.buildingX);         request.setProfile(\"foot\");         GHResponse route = hopper.route(request);         if(route.hasErrors()){             return Short.MAX_VALUE;         }         ResponsePath bestRoute = route.getBest();         return (short) Math.round(bestRoute.getDistance());     }      private static class Building{         long buildingId;         String buildingType;         double buildingX;         double buildingY;         public Building(long buildingId, String buildingType, double buildingX, double buildingY) {             this.buildingId = buildingId;             this.buildingType = buildingType;             this.buildingX = buildingX;             this.buildingY = buildingY;         }     }      private static class Distance{         long supermarketEntranceId;         long buildingId;         String buildingType;         short distance;         public Distance(long supermarketEntranceId, long buildingId, String buildingType, short distance) {             this.supermarketEntranceId = supermarketEntranceId;             this.buildingId = buildingId;             this.buildingType = buildingType;             this.distance = distance;         }     } }<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/b03\/3a1\/8c2\/b033a18c2cfdf04878f9ba1e3aadb6e0.jpg\" alt=\"\u041a\u0430\u0440\u0442\u0430 \u0434\u043e\u043c\u043e\u0432 \u0432 500\u043c \u0443 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u044b\u0445 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u043e\u0432 \u0448\u0430\u0433\u043e\u0432\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u0432 \u041c\u043e\u0441\u043a\u0432\u0435\" title=\"\u041a\u0430\u0440\u0442\u0430 \u0434\u043e\u043c\u043e\u0432 \u0432 500\u043c \u0443 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u044b\u0445 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u043e\u0432 \u0448\u0430\u0433\u043e\u0432\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u0432 \u041c\u043e\u0441\u043a\u0432\u0435\" width=\"1167\" height=\"881\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b03\/3a1\/8c2\/b033a18c2cfdf04878f9ba1e3aadb6e0.jpg\" data-blurred=\"true\"\/><\/p>\n<div><figcaption>\u041a\u0430\u0440\u0442\u0430 \u0434\u043e\u043c\u043e\u0432 \u0432 500\u043c \u0443 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u044b\u0445 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u043e\u0432 \u0448\u0430\u0433\u043e\u0432\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u0432 \u041c\u043e\u0441\u043a\u0432\u0435<\/figcaption><\/div>\n<\/figure>\n<p>\u0412\u044b\u0433\u0440\u0443\u0436\u0430\u044e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0432 GeoJSON \u0444\u0430\u0439\u043b \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e \u0435\u0433\u043e \u043d\u0430 GitHub:<\/p>\n<pre><code class=\"bash\">\\copy (select json_build_object('type', 'FeatureCollection','features', json_agg(json_build_object('type', 'Feature','geometry', st_AsGeoJSON(centre)::json))) from (select distinct centre from supermarket_distance s inner join geometry_global_view b on b.id=s.building_id and b.type=s.building_type) buildings ) to '~\/moscow_supermarket_footpath.json';<\/code><\/pre>\n<h2>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043d\u0430\u0445\u043e\u0434\u043a\u0438<\/h2>\n<p>\u041f\u043e\u0434\u044a\u0435\u0437\u0434\u044b \u0432 \u0436\u0438\u043b\u044b\u0445 \u0434\u043e\u043c\u0430\u0445 \u0432 \u041c\u043e\u0441\u043a\u0432\u0435 \u0447\u0430\u0441\u0442\u043e \u043d\u0435 \u0440\u0430\u0437\u043c\u0435\u0447\u0435\u043d\u044b \u043d\u0430 OpenStreetMap.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5ea\/565\/508\/5ea565508b3be60819836ba88ad9e7ff.png\" alt=\"\u0417\u0435\u043b\u0435\u043d\u044b\u0435 \u0434\u043e\u043c\u0430 - \u043f\u043e\u0434\u044a\u0435\u0437\u0434 \u0443\u043a\u0430\u0437\u0430\u043d, &quot;\u0446\u0432\u0435\u0442-\u0440\u0443\u043c\u044f\u043d\u0435\u0446&quot; (#DE5D83) \u043f\u043e\u0434\u044a\u0435\u0437\u0434\u044b \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u044b. \u0418 \u044d\u0442\u043e \u0435\u0449\u0435 \u043d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438 \u043f\u043e\u0434\u044a\u0435\u0437\u0434\u043e\u0432 \u0434\u043b\u044f \u0441\u0442\u043e\u043b\u0438\u0446\u044b\" title=\"\u0417\u0435\u043b\u0435\u043d\u044b\u0435 \u0434\u043e\u043c\u0430 - \u043f\u043e\u0434\u044a\u0435\u0437\u0434 \u0443\u043a\u0430\u0437\u0430\u043d, &quot;\u0446\u0432\u0435\u0442-\u0440\u0443\u043c\u044f\u043d\u0435\u0446&quot; (#DE5D83) \u043f\u043e\u0434\u044a\u0435\u0437\u0434\u044b \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u044b. \u0418 \u044d\u0442\u043e \u0435\u0449\u0435 \u043d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438 \u043f\u043e\u0434\u044a\u0435\u0437\u0434\u043e\u0432 \u0434\u043b\u044f \u0441\u0442\u043e\u043b\u0438\u0446\u044b\" width=\"1704\" height=\"882\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5ea\/565\/508\/5ea565508b3be60819836ba88ad9e7ff.png\"\/><\/p>\n<div><figcaption>\u0417\u0435\u043b\u0435\u043d\u044b\u0435 \u0434\u043e\u043c\u0430 &#8212; \u043f\u043e\u0434\u044a\u0435\u0437\u0434 \u0443\u043a\u0430\u0437\u0430\u043d, &#171;\u0446\u0432\u0435\u0442-\u0440\u0443\u043c\u044f\u043d\u0435\u0446&#187; (#DE5D83) \u043f\u043e\u0434\u044a\u0435\u0437\u0434\u044b \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u044b. \u0418 \u044d\u0442\u043e \u0435\u0449\u0435 \u043d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438 \u043f\u043e\u0434\u044a\u0435\u0437\u0434\u043e\u0432 \u0434\u043b\u044f \u0441\u0442\u043e\u043b\u0438\u0446\u044b<\/figcaption><\/div>\n<\/figure>\n<p>\u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0448\u0435\u0445\u043e\u0434\u043d\u043e\u0439 \u0434\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u0438 \u043a \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0443, \u043d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u043c\u0435\u0442\u0438\u0442\u044c \u043f\u043e\u0434\u044a\u0435\u0437\u0434\u044b \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0418 \u0443\u0436\u0435 \u0432\u043d\u0435\u0441 \u0441\u0432\u043e\u044e \u043f\u043e\u0441\u0438\u043b\u044c\u043d\u0443\u044e \u043f\u043e\u043c\u043e\u0449\u044c \u0432 \u0433\u0435\u043e\u0434\u0430\u043d\u043d\u044b\u0435 \u041c\u043e\u0441\u043a\u0432\u044b \u043f\u043e \u043f\u043e\u0434\u044a\u0435\u0437\u0434\u0430\u043c \u0432 \u0436\u0438\u043b\u044b\u0445 \u0434\u043e\u043c\u0430\u0445. \u041f\u043e\u043e\u0431\u0449\u0430\u043b\u0441\u044f c \u043c\u0435\u0441\u0442\u043d\u044b\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u043c\u044d\u043f\u043f\u0435\u0440\u043e\u0432 \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u0438 \u0443\u043c\u043d\u044b\u0435 \u043b\u044e\u0434\u0438 <a href=\"https:\/\/osm.cupivan.ru\/entrance\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u0434\u0441\u043a\u0430\u0437\u0430\u043b\u0438 \u0441\u0430\u0439\u0442<\/a>, \u0433\u0434\u0435 <em>\u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0435 \u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u0439\u0442\u0438 \u0434\u043e\u043c\u0430 \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u043f\u043e\u0434\u044a\u0435\u0437\u0434\u044b \u0438 <\/em><a href=\"https:\/\/wiki.openstreetmap.org\/wiki\/RU:Tag:entrance%3Dstaircase\" rel=\"noopener noreferrer nofollow\"><em>\u0440\u0430\u0437\u043c\u0435\u0442\u0438\u0442\u044c \u0438\u0445<\/em><\/a> \u0432 OpenStreetMap.<\/p>\n<p>\u0412 \u041c\u043e\u0441\u043a\u0432\u0435 \u0434\u043b\u044f \u0437\u0434\u0430\u043d\u0438\u0439 \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0435\u0433\u043e \u0442\u0438\u043f\u0435. \u041a\u0430\u043a \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438 \u0432 \u043a\u043e\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043a \u043a\u0430\u0440\u0442\u0435 \u0441\u0430\u043c\u043e \u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0443\u0447\u0442\u0435\u043d\u043e \u043a\u0430\u043a \u0436\u0438\u043b\u043e\u0435. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0438\u043f \u0437\u0434\u0430\u043d\u0438\u044f \u043d\u0430 building=retail \u0438 \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u0430\u0440\u0442\u0443. \u042f \u043c\u043e\u0433\u0443 \u043d\u0430\u0439\u0442\u0438 \u0432\u0441\u0435 \u0442\u0430\u043a\u0438\u0435 \u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a, \u0447\u0442\u043e\u0431\u044b \u043b\u044e\u0434\u0438 \u0436\u0438\u0432\u0443\u0449\u0438\u0435 \u0432 \u044d\u0442\u043e\u043c \u0440\u0430\u0439\u043e\u043d\u0435 \u043f\u0435\u0440\u0435\u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b\u0438 \u0438 \u0435\u0441\u043b\u0438 \u0437\u0434\u0430\u043d\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438\/\u043c\u0430\u0433\u0430\u0437\u0438\u043d\u043e\u043c, \u043e\u0431\u043d\u043e\u0432\u0438\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 OSM.<\/p>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 OpenStreetMap \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0438 \u043f\u043e \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u043c\u0438. \u041d\u0435 \u043d\u0430\u0434\u043e \u0431\u044b\u0442\u044c data science \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u043e\u043c \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043e\u0442 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u043e\u0432 \u0434\u043e \u0434\u043e\u043c\u043e\u0432.<\/p>\n<h2>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0433\u0435\u043e\u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438<\/h2>\n<p>\u0413\u043e\u0442\u043e\u0432\u0443\u044e \u043a\u0430\u0440\u0442\u0443 \u0436\u0438\u043b\u044b\u0445 \u0434\u043e\u043c\u043e\u0432 \u041c\u043e\u0441\u043a\u0432\u044b \u0432 500\u043c \u043e\u0442 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u044b\u0445 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u043e\u0432 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u043d\u0430 <a href=\"https:\/\/gist.github.com\/igor-suhorukov\/bd88b47d16bb8f15ad92f91c89fa272c\" rel=\"noopener noreferrer nofollow\">GitHub Gist<\/a>. \u0413\u0434\u0435 \u0442\u043e\u0447\u043a\u0438 \u043d\u0430 \u043a\u0430\u0440\u0442\u0435 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442 \u0446\u0435\u043d\u0442\u0440\u044b \u0436\u0438\u043b\u044b\u0445 \u0437\u0434\u0430\u043d\u0438\u0439 \u0432 \u0448\u0430\u0433\u043e\u0432\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u043e\u0442 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u043e\u0432. <\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043d\u0430 \u0437\u0434\u043e\u0440\u043e\u0432\u044c\u0435, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u043c\u0435\u0441\u0442\u0430 \u0436\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0443\u0447\u0435\u0441\u0442\u044c \u0438 \u0442\u043e\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0439\u0442\u0438 \u0432\u0435\u0447\u0435\u0440\u043e\u043c \u0432 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0439 \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u044b\u0439 \u043c\u0430\u0433\u0430\u0437\u0438\u043d \u0443 \u0434\u043e\u043c\u0430. <\/p>\n<h2>\u0421\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c \u0438\u043b\u0438 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u0435\u0441\u0441\u0430<\/h2>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0430\u0440\u0443 \u0441\u043b\u043e\u0432 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0436\u0443\u0440\u043d\u0430\u043b\u0438\u0441\u0442\u044b \u0438\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0437\u0430\u043a\u0430\u0437\u0430\u043b \u043e\u0447\u0435\u0440\u043d\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u0440\u043e \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c\u0438 \u0433\u0435\u043e \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438\u043b\u0438 \u044d\u0442\u043e \u0440\u0435\u0437\u044e\u043c\u0435 \u043e\u0442 ChatGPT.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u043c\u043d\u0438\u0442\u0435 \u043c\u0435\u043c: \u0423\u0447\u0435\u043d\u044b\u0435 \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u043b\u0435\u0447\u0438\u0442\u044c \u0440\u0430\u043a?<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0a6\/9be\/796\/0a69be796e8424b839f5879c7a9c316e.png\" width=\"921\" height=\"880\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0a6\/9be\/796\/0a69be796e8424b839f5879c7a9c316e.png\"\/><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0441\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u0442\u0430\u043a \u0436\u0435. \u041b\u0435\u043d\u0442\u0430 \u0440\u0443 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b\u0430 \u0441\u0442\u0430\u0442\u044c\u044e \u043f\u0440\u043e \u0442\u043e \u0447\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u043d\u0435 \u0443\u0434\u043e\u0431\u043d\u043e. \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0438\u043b\u0438 \u0432 \u044d\u0442\u043e\u043c \u0435\u0441\u0442\u044c \u0446\u0435\u043b\u044c \u043e\u0431\u0435\u0441\u0446\u0435\u043d\u0438\u0442\u044c \u043c\u043e\u0439 \u0442\u0440\u0443\u0434? \u041e\u0441\u0442\u0430\u0432\u043b\u044e \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/443\/822\/dc8\/443822dc8010d3cd486ff5145ca352c2.png\" width=\"930\" height=\"892\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/443\/822\/dc8\/443822dc8010d3cd486ff5145ca352c2.png\"\/><\/figure>\n<p>\u0418 \u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u0441\u0441\u044b\u043b\u043a\u0430 \u0432\u0435\u0434\u0435\u0442 \u0441\u0440\u0430\u0437\u0443 \u043d\u0430 Github, \u0438\u0437\u0431\u0435\u0433\u0430\u044f \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043d\u0430 \u0425\u0430\u0431\u0440\u0435&#8230; \u0421\u0440\u0430\u0432\u043d\u0438\u0442\u0435 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0438 \u043d\u043e\u0432\u043e\u0441\u0442\u044c!)<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/771184\/\"> https:\/\/habr.com\/ru\/articles\/771184\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u044f\u0442\u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u0436\u0438\u0432\u0435\u0448\u044c \u0442\u0430\u043c \u0433\u0434\u0435 \u0443 \u0442\u0435\u0431\u044f \u0432\u0445\u043e\u0434 \u0432 <a href=\"https:\/\/habr.com\/ru\/articles\/770044\/\" rel=\"noopener noreferrer nofollow\">\u043c\u0435\u0442\u0440\u043e \u0432 15 \u043c\u0438\u043d\u0443\u0442\u0430\u0445 \u0445\u043e\u0434\u044c\u0431\u044b<\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/761600\/\" rel=\"noopener noreferrer nofollow\">\u0441 \u043a\u043e\u043c\u0444\u043e\u0440\u0442\u043e\u043c \u0436\u0438\u0437\u043d\u0438 \u043d\u0435\u043f\u043b\u043e\u0445\u043e<\/a>. \u041d\u043e \u043a\u0443\u0448\u0430\u0442\u044c \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0432\u0441\u0435\u0433\u0434\u0430, \u0430 \u043d\u0430 \u0440\u0430\u0431\u043e\u0447\u0435\u0439 \u043d\u0435\u0434\u0435\u043b\u0435 \u0443\u0436 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u044f \u0435\u0445\u0430\u0442\u044c \u0432 \u0441\u0443\u043f\u0435\u0440\u043c\u0430\u0440\u043a\u0435\u0442 \u0447\u0442\u043e\u0431\u044b \u0441\u0432\u0430\u0440\u0438\u0442\u044c \u0433\u0440\u0435\u0447\u043d\u0435\u0432\u0443\u044e \u043a\u0430\u0448\u0443 \u0438 \u0432\u0437\u044f\u0442\u044c \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043d\u0430 \u0437\u0430\u0432\u0442\u0440\u0430\u043a. \u041c\u0430\u0433\u0430\u0437\u0438\u043d\u044b \u0448\u0430\u0433\u043e\u0432\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u0435\u0441\u0442\u044c \u0432\u0435\u0437\u0434\u0435, \u043d\u043e \u043c\u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u0435, \u0442\u0438\u043f\u0430 \u041f\u044f\u0442\u0451\u0440\u043e\u0447\u043a\u0438, \u0414\u0438\u043a\u0441\u0438, \u041c\u0430\u0433\u043d\u0438\u0442\u0430, \u041f\u0435\u0440\u0435\u043a\u0440\u0451\u0441\u0442\u043a\u0430, \u041c\u0430\u0433\u043d\u043e\u043b\u0438\u0438, \u0410\u0442\u0430\u043a \u0438\u043b\u0438 \u041b\u0435\u043d\u0442\u044b.<\/p>\n<p>\u0416\u0438\u0437\u043d\u044c \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u0444\u0430\u043a\u0442\u043e\u0440\u0443 \u0432 \u0421\u0435\u0440\u0435\u0431\u0440\u044f\u043d\u043e\u043c \u0431\u043e\u0440\u0443( \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u0435\u0439  \u0432 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043e\u0442 \u043d\u0435\u0431\u043b\u0430\u0433\u043e\u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0445 \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432) \u043e\u0442\u043f\u0430\u0434\u0430\u0435\u0442 \u0441\u0440\u0430\u0437\u0443 &#8212; \u0442\u0430\u043c \u0438 \u0434\u043e \u043c\u0435\u0442\u0440\u043e \u043d\u0435 \u0431\u043b\u0438\u0437\u043a\u043e! \u041d\u0430\u0439\u0434\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430 \u0434\u043b\u044f \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u043e\u0439 \u0436\u0438\u0437\u043d\u0438 \u0438 \u043f\u043e\u0445\u043e\u0434\u0430 \u0432 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u044b\u0439 \u043c\u0430\u0433\u0430\u0437\u0438\u043d.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u042d\u0442\u043e \u043a\u0430\u043a \u0432 \u0434\u0438\u043b\u0435\u043c\u0435 \u0447\u0442\u043e \u043f\u0435\u0440\u0432\u0435\u0435: \u043a\u0443\u0440\u0438\u0446\u0430 \u0438\u043b\u0438 \u044f\u0439\u0446\u043e, \u0442\u0430\u043a \u0436\u0435 \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u044b\u0439\/\u0436\u0438\u043b\u043e\u0439 \u0440\u0430\u0439\u043e\u043d. \u041a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u044b \u0442\u043e\u0440\u0433\u043e\u0432\u044b\u0445 \u0441\u0435\u0442\u0435\u0439 \u0442\u0440\u0430\u0442\u044f\u0442 \u0434\u0435\u043d\u044c\u0433\u0438 \u043d\u0430 \u0433\u0435\u043e\u0430\u043d\u0430\u043b\u0438\u0437 \u0433\u0434\u0435 \u0438\u043c \u043b\u0443\u0447\u0448\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u044b\u0439 \u043c\u0430\u0433\u0430\u0437\u0438\u043d. \u0422\u0430\u043a \u0447\u0442\u043e \u0432 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u0432\u0438\u0434\u0435 \u043c\u044b \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0438\u0445 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0443 \u0438 \u043d\u0430\u0439\u0434\u0435\u043c \u0433\u0434\u0435 \u0436\u0438\u0432\u0443\u0442 \u043c\u043e\u0438 \u0441\u043e\u0441\u0435\u0434\u0438. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043d\u0443\u0436\u043d\u0430 \u0434\u0440\u0443\u0433\u0430\u044f \u0433\u0440\u0443\u043f\u043f\u0430 \u0441\u043e\u0441\u0435\u0434\u0435\u0439, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0438\u0441\u043a\u0430\u0442\u044c \u043e\u043a\u0440\u0435\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0410\u0437\u0431\u0443\u043a\u0438 \u0412\u043a\u0443\u0441\u0430 \u0438 \u0431\u044b\u0432\u0448\u0435\u0433\u043e \u0415\u043b\u0438\u0441\u0435\u0435\u0432\u0441\u043a\u043e\u0433\u043e.<\/p>\n<p>\u041f\u0440\u043e \u0442\u043e \u043a\u0430\u043a \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u0434\u043b\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430 \u0438 \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u0447\u0435\u0441\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/articles\/778970\/\" rel=\"noopener noreferrer nofollow\">\u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0432 \u044d\u0442\u043e\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<p>\u0414\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0431\u0443\u0434\u0443 \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u0435\u043e\u0434\u0430\u043d\u043d\u044b\u0435 OSM, \u0438 \u0432\u043e\u0442 \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u043e\u0432 \u0431\u0435\u0437 &#171;\u0447\u0435\u0440\u043d\u043e\u0439 \u043c\u0430\u0433\u0438\u0438&#187; \u043c\u043d\u0435 \u043d\u0435 \u0443\u0434\u0430\u0441\u0442\u0441\u044f \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u043d\u043e \u043e\u043f\u0435\u0447\u0430\u0442\u043e\u043a, \u0440\u0430\u0437\u043d\u044b\u0445 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0439 \u0438 \u0440\u0430\u0437\u043d\u043e\u0448\u0451\u0440\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0432 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445. \u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0441\u0430 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u043e\u0435 \u0437\u0430\u043a\u043b\u0438\u043d\u0430\u043d\u0438\u0435:<\/p>\n<pre><code class=\"sql\">create temporary table supermarket_entrance as    select id, centre, tags      from geometry_global_view      where (tags@>'shop=>supermarket' or tags@>'shop=>convenience') and      (tags->'brand' in ('\u041f\u044f\u0442\u0451\u0440\u043e\u0447\u043a\u0430','\u0412\u043a\u0443\u0441\u0412\u0438\u043b\u043b','\u0414\u0438\u043a\u0441\u0438','\u041c\u0430\u0433\u043d\u0438\u0442',                                '\u041f\u0435\u0440\u0435\u043a\u0440\u0451\u0441\u0442\u043e\u043a','\u041c\u0430\u0433\u043d\u043e\u043b\u0438\u044f','\u041f\u0435\u0440\u0435\u043a\u0440\u0435\u0441\u0442\u043e\u043a',                                '\u041b\u0435\u043d\u0442\u0430','Eurospar','\u0410\u0448\u0430\u043d','\u0421\u0443\u043f\u0435\u0440 \u041b\u0435\u043d\u0442\u0430',                                '\u0410\u0442\u0430\u043a','\u0421\u0443\u043f\u0435\u0440\u041b\u0435\u043d\u0442\u0430','\u041e\u2019\u041a\u0415\u0419','Spar',                                '\u041f\u0435\u0440\u0435\u043a\u0440\u0435\u0441\u0442\u043e\u043a \u042d\u043a\u0441\u043f\u0440\u0435\u0441\u0441','SPAR',                                'METRO Cash &amp; Carry','EuroSPAR','\u0410\u0422\u0410\u041a',                                '\u0410\u0448\u0430\u043d \u0421\u0438\u0442\u0438','\u041c\u0438\u043d\u0438 \u041b\u0435\u043d\u0442\u0430','EUROSPAR',                                '\u041c\u0438\u043d\u0438\u041b\u0435\u043d\u0442\u0430','METRO','Auchan','\u0441\u0443\u043f\u0435\u0440 \u041b\u0435\u043d\u0442\u0430')      or tags@>'brand:wikipedia=>ru:Auchan');<\/code><\/pre>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a \u0430\u043d\u0430\u043b\u0438\u0437\u0443 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/articles\/770044\/\" rel=\"noopener noreferrer nofollow\">\u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a>. \u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0437 \u0433\u0435\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043c\u0430\u0432\u0437\u043e\u043b\u0435\u0439 \u043d\u0430 \u041a\u0440\u0430\u0441\u043d\u043e\u0439 \u043f\u043b\u043e\u0449\u0430\u0434\u0438 \u0438 \u041a\u0440\u0435\u043c\u043b\u0435\u0432\u0441\u043a\u0438\u0435 \u0431\u0430\u0448\u043d\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044e \u0444\u0438\u043b\u044c\u0442\u0440:<code>not(b.tags?'tomb') and not(b.tags?'man_made')<\/code> \u0438 \u043d\u0430\u0439\u0434\u0443 \u0436\u0438\u043b\u044b\u0435 \u0437\u0434\u0430\u043d\u0438\u044f \u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0445 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u043e\u0432:<\/p>\n<pre><code class=\"sql\">explain create table living_building_near as select m.id supermarket_entrance_id,st_x(m.centre) supermarket_entrance_x,st_y(m.centre) supermarket_entrance_y,        array_agg((b.id,b.type,st_x(b.centre),st_y(b.centre))::building_info) buildings   from supermarket_entrance m inner join geometry_global_view b on     b.tags?'building' and     not(b.tags?'amenity') and     not(b.tags?'shop') and     not(b.tags?'tomb') and     not(b.tags?'man_made') and     b.tags->'building' not in --\u0432 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u043d\u0438\u0436\u0435 \u0437\u0434\u0430\u043d\u0438\u044f\u0445 \u043d\u0435 \u0436\u0438\u0432\u0443\u0442 \u043d\u0430 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0439 \u043e\u0441\u043d\u043e\u0432\u0435         ('service','garages','industrial','retail','office','roof','commercial','garage','kiosk','warehouse','church',         'parking','public','shed','hangar','train_station','guardhouse','transportation','terrace','greenhouse','bridge',         'government','chapel','gazebo','civic','ruins','supermarket','sports_centre','semidetached_house','toilets',         'sports_hall','clinic','farm_auxiliary','stable','grandstand','bunker','gatehouse','store','temple','ventilation_kiosk',         'carport','cowshed','barracks','shop','cabin','barn','cathedral','wall','townhouse','manufacture','shelter',         'fire_station','stadium','stands','sport_hall','theatre','storage_tank','checkpoint','houseboat','abandoned','dovecote',         'mosque','museum','military','container','observatory','lift','tent','factory','sport','mall','riding_hall','depot',         'prison','gate','triumphal_arch','water_works','public_building','pavilion','bank','institute','works','collapsed',         'car_repair','crossing_box','fuel','tree_house','presbytery','yesq','farm','outbuilding','police','porch','sauna',         'monastery','cinema','tower','boathouse','library','transformer_tower','heat_exchange_station','ice_rink','entrance','construction','transformer'         ) and      ST_DWithin(b.geom::geography,m.centre::geography,500)    group by 1,2,3; -- create table living_building_near as select m.id supermarket_entrance_id,st_x(m.centre) supermarket_entrance_x,st_y(m.centre) supermarket_entrance_y,array_agg((b.id,b.type,st_x(b.centre),st_y(b.centre))::building_info) buildings from supermarket_entrance m inner join geometry_global_view b on b.tags?'_lb' and ST_DWithin(b.geom::geography,m.centre::geography,500) group by 1,2,3;<\/code><\/pre>\n<p>\u041f\u043e\u0441\u0447\u0438\u0442\u0430\u044e \u043f\u0435\u0448\u0435\u0445\u043e\u0434\u043d\u044b\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043e\u0442 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430 \u0434\u043e \u0434\u043e\u043c\u043e\u0432 \u0432 \u0440\u0430\u0434\u0438\u0443\u0441\u0435 500\u043c. \u0427\u0442\u043e\u0431\u044b \u0443\u0447\u0435\u0441\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0438 \u043a\u043e\u0433\u0434\u0430 \u0434\u043e\u043c \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u043a\u0443 \u0438\u043b\u0438 \u0430\u0432\u0442\u043e\u0441\u0442\u0440\u0430\u0434\u0443 \u0431\u0435\u0437 \u043f\u043e\u0434\u0437\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430, \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0440\u0430\u0441\u0447\u0435\u0442 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f.<\/p>\n<details class=\"spoiler\">\n<summary>GraphHopper 8 \u043a\u0430\u043a \u0434\u0432\u0438\u0436\u043e\u043a \u0440\u0430\u0441\u0447\u0435\u0442\u0430 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u0438 Java \u043a\u043e\u0434 \u0434\u043b\u044f \u043d\u0435\u0433\u043e.<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"sql\">create table supermarket_distance(                 entrance_id bigint,                 building_id bigint,                 building_type table_reference,                 distance smallint,                 primary key(entrance_id,building_id,building_type) );<\/code><\/pre>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441 \u0440\u0430\u0441\u0447\u0435\u0442\u043e\u043c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 &#8212; \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u0441\u0435\u0440\u0432\u0438\u0441 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439 \u043a\u0430\u043a REST \u0447\u0435\u0440\u0435\u0437 TCP \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f round trip \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u043a \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443  <strong>\u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Graphhopper \u043a\u0430\u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0431\u0435\u0437 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043f\u043e HTTP<\/strong>:<\/p>\n<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"java\">package com.github.isuhorukov.routing;  import com.graphhopper.GHRequest; import com.graphhopper.GHResponse; import com.graphhopper.GraphHopper; import com.graphhopper.ResponsePath; import com.graphhopper.config.CHProfile; import com.graphhopper.config.Profile; import org.postgresql.jdbc.PgArray; import org.postgresql.util.PGobject;  import java.sql.*; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors;  public class Routing {      public static final int MAX_DISTANCE = 500;      public static void main(String[] args) throws Exception {         GraphHopper hopper = getGraphHopper();         try (Connection connection = DriverManager.getConnection(                 System.getenv(\"jdbc_url\"), System.getenv(\"user\"), System.getenv(\"password\"))) {             connection.setAutoCommit(false);             try {                 var distances = calculateDistances(connection, hopper);                 saveDistance(connection, distances);             } catch (SQLException e) {                 connection.rollback();                 throw e;             }         }     }      private static GraphHopper getGraphHopper() {         var hopper = new GraphHopper();         hopper.setOSMFile(System.getenv(\"osm_file\"));         hopper.setGraphHopperLocation(\"route\");         hopper.getCHPreparationHandler().setCHProfiles(new CHProfile(\"foot\"));         hopper.setProfiles(new Profile(\"foot\").setVehicle(\"foot\"));         hopper.importOrLoad();         return hopper;     }      private static List&lt;Distance> calculateDistances(Connection connection, GraphHopper hopper) throws SQLException {         List&lt;Distance> distances = new ArrayList&lt;>();         try (Statement supermarketQuery = connection.createStatement()){             int step=0;             try (ResultSet livingBuilding = supermarketQuery.executeQuery(\"select * from living_building_near\")){                 while (livingBuilding.next()){                     long supermarketEntranceId = livingBuilding.getLong(\"supermarket_entrance_id\");                     double supermarketEntranceX = livingBuilding.getDouble(\"supermarket_entrance_x\");                     double supermarketEntranceY = livingBuilding.getDouble(\"supermarket_entrance_y\");                     PgArray buildingsArray = (PgArray) livingBuilding.getArray(\"buildings\");                     List&lt;Building> buildings = mapBuildings(buildingsArray);                     System.out.println(step++);                     distances.addAll(buildings.stream().map(building -> {                         short distance = calculateDistances(hopper, building, supermarketEntranceY, supermarketEntranceX);                         return new Distance(supermarketEntranceId,building.buildingId, building.buildingType, distance);                     }).collect(Collectors.toList()));                 }             }         }         return distances;     }      private static void saveDistance(Connection connection, List&lt;Distance> distances) throws SQLException {         try (PreparedStatement insert = connection.prepareStatement(                 \"insert into supermarket_distance(entrance_id,building_id,building_type,distance) \" +                         \"values (?,?,?::table_reference,?)\")){             distances.forEach(distance -> {                 if(distance.distance> MAX_DISTANCE) return;                 try {                     insert.setLong(1, distance.supermarketEntranceId);                     insert.setLong(2, distance.buildingId);                     insert.setString(3, distance.buildingType);                     insert.setShort(4, distance.distance);                     insert.addBatch();                 } catch (SQLException e) {                     throw new RuntimeException(e);                 }             });             insert.executeBatch();             connection.commit();         }     }      private static List&lt;Building> mapBuildings(PgArray buildingsArray) throws SQLException {         return getPgObjects(buildingsArray).stream().map(pGobject -> {             String value = pGobject.getValue();             if(value==null || value.length()&lt;=2){                 throw new IllegalArgumentException();             }             String[] parts = value.substring(1, value.length() - 1).split(\",\");             long buildingId = Long.parseLong(parts[0]);             String<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-359027","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/359027","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=359027"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/359027\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=359027"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=359027"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=359027"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}