{"id":309462,"date":"2020-09-04T09:00:53","date_gmt":"2020-09-04T09:00:53","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=309462"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2020-09-04T09:00:53","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=309462","title":{"rendered":"PostGis. \u041a\u0430\u043a \u043d\u0430\u0439\u0442\u0438 \u043e\u0448\u0438\u0431\u043a\u0443 \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435?"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/517784\/\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/static3.depositphotos.com\/1003288\/159\/i\/450\/depositphotos_1591111-stock-photo-elephant-and-earth.jpg\" alt=\"image\" \/><\/div>\n<p>  \u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c! \u042f \u2014 \u0412\u0438\u043a\u0442\u043e\u0440, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432 Gems development. \u0415\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u043e \u043d\u0430\u0448\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0440\u0430\u0437\u043d\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430. \u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Postgis \u0432 \u0421\u0423\u0411\u0414 Postgresql \u043c\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043e\u0448\u0438\u0431\u043a\u043e\u0439:<\/p>\n<p>  <code>XX000: GEOSIntersects: TopologyException: side location conflict at 10398.659 3844.9200000000001<\/code><br \/>  <a name=\"habracut\"><\/a><br \/>  \u0417\u0430\u043f\u0440\u043e\u0441, \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0449\u0438\u0439 \u043a \u043e\u0448\u0438\u0431\u043a\u0435, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"sql\">select q1.key,st_asGeoJson(geoloc)     from usahalinsk.V_GEO_OOPT q1          where ST_Intersects(geoloc,                 ST_GeomFromGeoJSON('{&quot;type&quot;:&quot;Polygon&quot;,&quot;coordinates&quot;:                     [[[11165.15,2087.5],[11112,2066.6],[11127.6,2022.5],                     [11122.6,2020.7],                     [11122.25,2021.2],[11107.07,2015.7],                     [11121,1947],[11123.48,1922.99],[11128.42,1874.4],                     [11131.5,1875],[11140.96,1876.81],[11160.73,1880.59],                     [11201.04,1888.3],[11194.2,1908],[11221.93,1916.57],                     [11223.3,1917],[11165.15,2087.5]]]}'))  <\/code><\/pre>\n<p>  \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043e\u0442\u0447\u0451\u0442\u044b \u043f\u043e \u0434\u0430\u043d\u043d\u044b\u043c \u0438 \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u043e \u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044e \u0443\u0441\u043b\u0443\u0433. \u041c\u043d\u043e\u0433\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u043d\u0430\u043c\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a: \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0441\u0445\u0435\u043c\u044b \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0437\u0435\u043c\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0447\u0430\u0441\u0442\u043a\u0430, \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0433\u0440\u0430\u0434\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043b\u0430\u043d\u0430 \u0437\u0435\u043c\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0447\u0430\u0441\u0442\u043a\u0430 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u044d\u0442\u043e\u0439.<\/p>\n<p>  \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0434\u0435\u043b\u043e \u0432 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0438. \u0427\u0430\u0441\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 \u0432\u044b\u0434\u0430\u0435\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0438\u043c\u0435\u044e\u0442 \u0441\u0430\u043c\u043e\u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0434\u0443\u0431\u043b\u0438 \u0442\u043e\u0447\u0435\u043a. \u041f\u0440\u0438\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u0432 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043d\u0438\u0436\u0435. (\u0413\u0440\u0430\u043d\u0438\u0446\u0430 \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u0430 \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u0435\u0442 \u0441\u0430\u043c\u0430 \u0441\u0435\u0431\u044f \u0438 \u0432 \u043b\u0438\u043d\u0438\u0438 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0434\u0432\u0435 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b)<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/i.piccy.info\/i9\/2075f214214dba4b0f7f6c407d083e63\/1599191291\/9989\/1394878\/error_geo.png\" \/><\/div>\n<p>  \u041c\u044b \u043f\u0440\u043e\u0432\u0435\u043b\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0440\u0430\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u043f\u043e\u0438\u0441\u043a\u0443 \u043f\u0440\u0438\u0447\u0438\u043d \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u0445\u043e\u0442\u0438\u043c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0431 \u044d\u0442\u043e\u043c.<br \/>  \u0412 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c Postgis 2.4 \u0438 Postgresql 9.6. \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u043a \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435. \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u0443\u044e \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u044e \u043d\u0430 \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0441\u0442\u044c \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u043c, \u0447\u0442\u043e \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/i.piccy.info\/i9\/259fcc284e64b35adb2f0ae899f4d4b8\/1599191577\/21312\/1394878\/check1.png\" \/><\/div>\n<p>  \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u0434\u0435\u043b\u043e \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 (\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438) usahalinsk.V_GEO_OOPT \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u0438\u0449\u0435\u043c \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044c \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u0443, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u043e\u0436\u0435.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/i.piccy.info\/i9\/20cfd30f406400a5270ef29fff06bc57\/1599191635\/12589\/1394878\/check2.png\" \/><\/div>\n<p>  \u041d\u043e \u0438 \u0437\u0434\u0435\u0441\u044c \u043e\u0448\u0438\u0431\u043e\u043a \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u043c. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u043d\u0435 \u043f\u043e\u043f\u0430\u043b\u0438 \u0432\u043e\u043e\u0431\u0449\u0435. \u0415\u0441\u043b\u0438 \u0431\u044b \u043e\u043d\u0438 \u0431\u044b\u043b\u0438, \u0442\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0448\u0430\u043b\u0430\u0441\u044c \u0431\u044b \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0447\u0435\u0440\u0435\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u044e Postgis st_makeValid.<\/p>\n<p>  \u041d\u043e \u043e\u0448\u0438\u0431\u043e\u043a \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043d\u0435\u0442, \u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f. \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0435\u0433\u043e \u043f\u043b\u0430\u043d.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/i.piccy.info\/i9\/c20ed535785c8dc9043e62fdd2434cdf\/1599193080\/34554\/1394878\/check3_500.jpg\" \/><\/div>\n<p>  <i>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0442\u0440\u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0434\u043b\u044f \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0438 (\u0434\u043b\u044f \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u043e\u0432, \u043b\u0438\u043d\u0438\u0439 \u0438 \u0442\u043e\u0447\u0435\u043a), \u043d\u043e \u0434\u043b\u044f \u043a\u0440\u0430\u0442\u043a\u043e\u0441\u0442\u0438 \u0431\u0443\u0434\u0435\u043c \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u043e\u043b\u0435\u043c geoloc \u2013 \u0432 \u043d\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u044f \u0438 \u043e\u043d\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435.<\/i><\/p>\n<p>  \u041d\u0430\u0448\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 usahalinsk.V_GEO_OOPT \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u043a\u0430\u043a \u0432\u044b\u0431\u043e\u0440\u043a\u0430 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 usahalinsk.d_geometry \u0438 \u043f\u043e \u043f\u043e\u043b\u044e \u0441 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0435\u0439 \u0441\u043e\u0437\u0434\u0430\u043d \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441.<\/p>\n<p>  \u0417\u043d\u0430\u0447\u0438\u0442, \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438\u0434\u0435\u0442 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438 \u0433\u0434\u0435-\u0442\u043e \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u044f \u0432 \u043d\u0430\u0448\u0443 \u0432\u044b\u0431\u043e\u0440\u043a\u0443, \u0435\u0441\u0442\u044c \u043d\u0435\u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043f\u0430\u043b\u0438 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441, \u0442.\u043a. \u043e\u043d \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d \u043f\u043e \u0432\u0441\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441:<\/p>\n<pre><code class=\"sql\">DROP INDEX usahalinsk.d_geometry_cs1_all_sx;<\/code><\/pre>\n<p>  \u0418 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/i.piccy.info\/i9\/b9cc85a58ed1e166afbd8281b51297f9\/1599191885\/18593\/1394878\/check4.png\" \/><\/div>\n<p>  \u041e\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0441\u044f \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a. \u041f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u043c, \u0447\u0442\u043e \u0434\u0435\u043b\u043e \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435. \u041c\u043e\u0436\u043d\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441, \u043d\u043e \u0441 \u0443\u0441\u043b\u043e\u0432\u0438\u0435\u043c \u043d\u0430 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u0443\u044e \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u044e:<\/p>\n<pre><code class=\"sql\">CREATE INDEX d_geometry_cs1_all_sx   ON usahalinsk.d_geometry   USING gist(geoloc)   where st_isvalid(geoloc)=true; <\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043b\u0430\u043d. <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/i.piccy.info\/i9\/8d7b30181d46bc1e690fdab844f4cfbd\/1599191936\/33887\/1394878\/check5.png\" \/><\/div>\n<p>  \u0417\u0430\u043f\u0440\u043e\u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0441\u044f \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a, \u0438\u043d\u0434\u0435\u043a\u0441 \u0432 \u043f\u043b\u0430\u043d\u0435 \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f. \u0418\u0437 \u043c\u0438\u043d\u0443\u0441\u043e\u0432 \u0442\u0430\u043a\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u043c\u0435\u0434\u043b\u0435\u043d\u0438\u0435 \u0432\u0441\u0442\u0430\u0432\u043a\u0438\/\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f, \u0442.\u043a. \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c\u0441\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430. <\/p>\n<p>  \u0412\u0435\u0440\u043d\u0435\u043c \u044d\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043d\u0430\u0437\u0430\u0434 \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u043d\u0430\u0439\u0442\u0438 \u0438\u0437-\u0437\u0430 \u043a\u0430\u043a\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u043d\u0430\u0448 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c\u0441\u044f.<\/p>\n<pre><code class=\"sql\">DROP INDEX usahalinsk.d_geometry_cs1_all_sx;   CREATE INDEX d_geometry_cs1_all_sx   ON usahalinsk.d_geometry   USING gist   (geoloc); <\/code><\/pre>\n<p>  \u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043c\u0435\u0441\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0438:<\/p>\n<p>  <code>XX000: GEOSIntersects: TopologyException: side location conflict at 10398.659 3844.9200000000001<\/code><\/p>\n<p>  \u041d\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u0438\u0449\u0435\u043c \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 IsValidReason, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0434\u0430\u0435\u0442 \u043f\u0440\u0438\u0447\u0438\u043d\u0443 \u043e\u0448\u0438\u0431\u043a\u0438, \u0442\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0433\u043e \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043c.<\/p>\n<pre><code class=\"sql\">select key,ST_IsValidReason(geoloc) from usahalinsk.d_geometry      where st_isvalid(geoloc)!=true         and ST_AsText(geoloc) like '%3844.9200000000001%';          select key,ST_IsValidReason(geoloc) from usahalinsk.d_geometry      where st_isvalid(geoloc)!=true         and ST_IsValidReason(geoloc) like '%3844.9200000000001%'; <\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u043a\u0440\u0438\u043f\u0442. \u0411\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u0442\u044c \u0435\u0433\u043e \u0441 \u0438\u0441\u043a\u043e\u043c\u043e\u0439 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043e\u0439. \u0412 \u0445\u043e\u0434\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043b\u043e\u0432\u0438\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0438\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435. \u0415\u0441\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0435 \u043d\u0430\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b, \u0437\u043d\u0430\u0447\u0438\u0442 \u044d\u0442\u043e \u043d\u0430\u0448\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u0430\u044f \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u044f.<\/p>\n<pre><code class=\"sql\">do $$ declare     tKey bigint;     rec record;     error_text text;     --\u0422\u0435\u0441\u0442 \u043e\u0448\u0438\u0431\u043a\u0438     error_info text:='GEOSIntersects: TopologyException: side location conflict at 10398.659 3844.9200000000001'; begin     --\u041f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435     for rec in(select key from usahalinsk.d_geometry)     loop         begin             select key into tKey             from (select * from usahalinsk.d_geometry q1                                  --\u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u043e \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443                         where q1.key=rec.key                             and ST_Intersects(geoloc,                                     --\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u0430\u044f \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u044f                                     ST_GeomFromGeoJSON('{&quot;type&quot;:&quot;Polygon&quot;,&quot;coordinates&quot;:[[[11165.15,2087.5],                                     [11112,2066.6],[11127.6,2022.5],[11122.6,2020.7],                                     [11122.25,2021.2],[11107.07,2015.7],[11121,1947],                                                    [11123.48,1922.99],[11128.42,1874.4], [11131.5,1875],[11140.96,1876.81],                                    [11160.73,1880.59],[11201.04,1888.3], [11194.2,1908],[11221.93,1916.57],[11223.3,1917],                                     [11165.15,2087.5]]]}'))) geoQ;                 exception when others then                 --\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443 \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u0435\u0441\u0442\u044c               GET STACKED DIAGNOSTICS error_text = MESSAGE_TEXT;             --\u0415\u0441\u043b\u0438 \u0435\u0451 \u0442\u0435\u0441\u0442 \u0440\u0430\u0432\u0435\u043d \u0438\u0441\u043a\u043e\u043c\u043e\u043c\u0443, \u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043a\u043b\u044e\u0447               if error_text=error_info then                 raise info '%',rec.key;                 end if;                           end;     end loop; end$$; <\/code><\/pre>\n<p>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0440\u0438 \u043a\u043b\u044e\u0447\u0430 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043b\u0435\u0433\u043a\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c:<\/p>\n<pre><code class=\"sql\">update usahalinsk.d_geometry  set cs1_geometry_polygone=st_collectionextract(st_makevalid(geoloc),3) where key in( 1000010001988961, 1000010001989399, 1000010004293508); <\/code><\/pre>\n<p>  \u041e\u0442\u0432\u0435\u0447\u0443 \u043d\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0449\u0438\u0439 \u0432\u043e\u043f\u0440\u043e\u0441: <i>\u00ab\u043f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0432\u0441\u044e \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u0443\u044e \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u044e \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0438\u0441\u043a\u0430\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u043e\u0447\u043d\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u044b?\u00bb<\/i>. <\/p>\n<p>  \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u044e\u0442 \u043a \u043d\u0430\u043c \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0438\u0437 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 (\u0432 \u0442.\u0447. \u0438\u0437 \u0420\u043e\u0441\u0440\u0435\u0435\u0441\u0442\u0440\u0430) \u0438 \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 (\u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043e\u043d\u043e \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u0430\u0436\u0435\u043d\u0438\u0435\u043c) \u0432\u0441\u0435\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u043e\u043b\u0443\u0447\u0438\u0432 \u043d\u0443\u0436\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438, \u043c\u044b \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043a\u0430\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u043d\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0438 \u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0438\u0445 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c.<\/p>\n<p>  \u0422\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u0440\u0438\u0447\u0438\u043d\u044b \u043e\u0448\u0438\u0431\u043a\u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u0432 \u0446\u0435\u043b\u043e\u0435 \u0440\u0430\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u043d\u0446\u0435.<\/p>\n<p>  \u0411\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0437\u0430\u0434\u0430\u0447\u0438: \u043a\u0430\u043a \u0431\u044b\u0442\u044c, \u0435\u0441\u043b\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u0441 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043e\u0439, \u0430 \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439? \u041a\u0430\u043a \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u0432\u0442\u043e\u0440\u043e\u0439. \u0418 \u043e\u0442\u043b\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u0410 \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u0432\u044b \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0435\u0442\u0435\u0441\u044c \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c\u0438 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0438 \u0438 \u043a\u0430\u043a \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445?<\/p><\/div>\n<p> \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\/post\/517784\/\"> https:\/\/habr.com\/ru\/post\/517784\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/517784\/\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/static3.depositphotos.com\/1003288\/159\/i\/450\/depositphotos_1591111-stock-photo-elephant-and-earth.jpg\" alt=\"image\" \/><\/div>\n<p>  \u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c! \u042f \u2014 \u0412\u0438\u043a\u0442\u043e\u0440, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432 Gems development. \u0415\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u043e \u043d\u0430\u0448\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0440\u0430\u0437\u043d\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430. \u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Postgis \u0432 \u0421\u0423\u0411\u0414 Postgresql \u043c\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043e\u0448\u0438\u0431\u043a\u043e\u0439:<\/p>\n<p>  <code>XX000: GEOSIntersects: TopologyException: side location conflict at 10398.659 3844.9200000000001<\/code>  <\/p>\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-309462","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/309462","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=309462"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/309462\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=309462"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=309462"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=309462"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}