{"id":321,"date":"2014-02-01T14:24:39","date_gmt":"2014-02-01T12:24:39","guid":{"rendered":"http:\/\/log.or.cz\/?p=321"},"modified":"2015-11-13T19:44:06","modified_gmt":"2015-11-13T17:44:06","slug":"gps-souradnice-ceskych-mest-a-obci","status":"publish","type":"post","link":"https:\/\/log.or.cz\/?p=321","title":{"rendered":"GPS sou\u00c5\u2122adnice \u00c4\u008desk\u00c3\u00bdch m\u00c4\u203ast a obc\u00c3\u00ad"},"content":{"rendered":"<p>Pro zobrazov\u00c3\u00a1n\u00c3\u00ad <a href=\"http:\/\/log.or.cz\/?p=314\">poloh dopad\u00c5\u00af meteosond<\/a> na IRC jsem pot\u00c5\u2122eboval v jednoduch\u00c3\u00a9m CSV form\u00c3\u00a1tu seznam sou\u00c5\u2122adnic \u00c4\u008desk\u00c3\u00bdch m\u00c4\u203ast, ale uk\u00c3\u00a1zalo se, \u00c5\u00bee je p\u00c5\u2122ekvapiv\u00c4\u203a obt\u00c3\u00ad\u00c5\u00ben\u00c3\u00a9 n\u00c4\u203aco takov\u00c3\u00a9ho z\u00c3\u00adskat. Sice existuje <a href=\"http:\/\/astro.arms.cz\/sourad.htm\">tabulka na jednom astronomick\u00c3\u00a9m webu<\/a>, v\u00c3\u00bdb\u00c4\u203ar tam zahrnut\u00c3\u00bdch obc\u00c3\u00ad je ale docela divn\u00c3\u00bd, n\u00c4\u203akde je m\u00c3\u00adsto obce jen jej\u00c3\u00ad \u00c4\u008d\u00c3\u00a1st, atd.<\/p>\n<p>Nakonec jsem zvolil postup &#8220;ud\u00c4\u203alej si s\u00c3\u00a1m&#8221;, a to kombinac\u00c3\u00ad <a href=\"http:\/\/cs.wikipedia.org\/wiki\/Seznam_obc%C3%AD_s_roz%C5%A1%C3%AD%C5%99enou_p%C5%AFsobnost%C3%AD\">seznamu na Wikipedii<\/a>, <a href=\"https:\/\/developers.google.com\/maps\/documentation\/geocoding\/\">Google Geocoding API<\/a> a trochy XPath.<\/p>\n<p>Seznam rozumn\u00c3\u00a9 podmno\u00c5\u00beiny m\u00c4\u203ast mohu z\u00c3\u00adskat t\u00c5\u2122eba pomoc\u00c3\u00ad:<\/p>\n<pre>\r\ncurl 'http:\/\/cs.wikipedia.org\/w\/index.php?title=Seznam_obc%C3%AD_s_roz%C5%A1%C3%AD%C5%99enou_p%C5%AFsobnost%C3%AD&action=edit' |\r\n  sed -ne 's\/^# \\[\\[\\([^]|]*|\\)*\\([^]]*\\)\\]\\].*\/\\2\/p' | sort\r\n<\/pre>\n<p>M\u00c3\u00a1m-li zase jm\u00c3\u00a9no obce, jej\u00c3\u00ad sou\u00c5\u2122adnice mohu z\u00c3\u00adskat t\u00c3\u00admto zakl\u00c3\u00adnadlem:<\/p>\n<pre>\r\nm=A\u00c5\u00a1; curl -s 'http:\/\/maps.googleapis.com\/maps\/api\/geocode\/xml?address='\"${m\/\/ \/+},+CZ\"'&sensor=false' |\r\n  xmllint --xpath '\/\/location[lat or lng]\/\/text()' -\r\n<\/pre>\n<p>(D\u00c5\u00afle\u00c5\u00beit\u00c3\u00bd trik je to ,CZ, jinak bude Google zn\u00c3\u00a1t spoustu Kol\u00c3\u00adn\u00c5\u00af a A\u00c5\u00a1 bude znamenat Americk\u00c3\u00a1 Samoa. Alternativn\u00c4\u203a si m\u00c5\u00af\u00c5\u00beete z v\u00c3\u00bdsledk\u00c5\u00af vyfiltrovat ty \u00c4\u008desk\u00c3\u00a9 pomoc\u00c3\u00ad XPath <code>\/\/result[address_component\/short_name\/text()=\"CZ\"]\/geometry\/location[lat or lng]\/\/text()<\/code>.)<\/p>\n<p>Te\u00c4\u008f u\u00c5\u00be to pro vygenerov\u00c3\u00a1n\u00c3\u00ad jednoduch\u00c3\u00a9ho CSV sta\u00c4\u008d\u00c3\u00ad spojit dohromady:<\/p>\n<pre>\r\ncurl 'http:\/\/cs.wikipedia.org\/w\/index.php?title=Seznam_obc%C3%AD_s_roz%C5%A1%C3%AD%C5%99enou_p%C5%AFsobnost%C3%AD&action=edit' |\r\n  sed -ne 's\/^# \\[\\[\\([^]|]*|\\)*\\([^]]*\\)\\]\\].*\/\\2\/p' | sort |\r\n  while read m; do\r\n    echo -n $m\r\n    curl -s 'http:\/\/maps.googleapis.com\/maps\/api\/geocode\/xml?address='\"${m\/\/ \/+},+CZ\"'&sensor=false' |\r\n      xmllint --xpath '\/\/location[lat or lng]\/\/text()' - |\r\n      tr -s '\\n' ' ' | tr ' ' ','\r\n    echo\r\n    sleep 0.1\r\n  done | sed 's\/,$\/\/'\r\n<\/pre>\n<p>R\u00c3\u00a1di byste <a href=\"http:\/\/pasky.or.cz\/cp\/towncoords.csv\">hotov\u00c3\u00a9 CSV<\/a>?<\/p>\n<p><b>Bonus:<\/b> Podobn\u00c4\u203a vygenerovan\u00c3\u00a9 <a href=\"http:\/\/pasky.or.cz\/cp\/towncoords-castiprahy.csv\">CSV s pra\u00c5\u00besk\u00c3\u00bdmi \u00c4\u008d\u00c3\u00a1stmi (katastr\u00c3\u00a1ln\u00c3\u00admi \u00c3\u00bazem\u00c3\u00admi)<\/a>.<\/p>\n<p><b>Bonus 2:<\/b> A je\u00c5\u00a1t\u00c4\u203a <a href=\"http:\/\/pasky.or.cz\/cp\/towncoords-trans.csv\">CSV s obcemi s p\u00c5\u2122enesenou p\u00c5\u00afsobnost\u00c3\u00ad<\/a> (dal\u00c5\u00a1\u00c3\u00ad velk\u00c3\u00a9 obce a m\u00c4\u203asta)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pro zobrazov\u00c3\u00a1n\u00c3\u00ad poloh dopad\u00c5\u00af meteosond na IRC jsem pot\u00c5\u2122eboval v jednoduch\u00c3\u00a9m CSV form\u00c3\u00a1tu seznam sou\u00c5\u2122adnic \u00c4\u008desk\u00c3\u00bdch m\u00c4\u203ast, ale uk\u00c3\u00a1zalo se, \u00c5\u00bee je p\u00c5\u2122ekvapiv\u00c4\u203a obt\u00c3\u00ad\u00c5\u00ben\u00c3\u00a9 n\u00c4\u203aco takov\u00c3\u00a9ho z\u00c3\u00adskat. Sice existuje tabulka na jednom astronomick\u00c3\u00a9m webu, v\u00c3\u00bdb\u00c4\u203ar tam zahrnut\u00c3\u00bdch obc\u00c3\u00ad je ale docela divn\u00c3\u00bd, n\u00c4\u203akde je m\u00c3\u00adsto obce jen jej\u00c3\u00ad \u00c4\u008d\u00c3\u00a1st, atd. Nakonec jsem zvolil postup &#8220;ud\u00c4\u203alej [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[120,118,122,128,117,91],"class_list":["post-321","post","type-post","status-publish","format-standard","hentry","category-linux","tag-bash","tag-curl","tag-geo","tag-google","tag-sonde","tag-wiki"],"_links":{"self":[{"href":"https:\/\/log.or.cz\/index.php?rest_route=\/wp\/v2\/posts\/321","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/log.or.cz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/log.or.cz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/log.or.cz\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/log.or.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=321"}],"version-history":[{"count":7,"href":"https:\/\/log.or.cz\/index.php?rest_route=\/wp\/v2\/posts\/321\/revisions"}],"predecessor-version":[{"id":375,"href":"https:\/\/log.or.cz\/index.php?rest_route=\/wp\/v2\/posts\/321\/revisions\/375"}],"wp:attachment":[{"href":"https:\/\/log.or.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=321"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/log.or.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=321"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/log.or.cz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=321"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}