{"id":810,"date":"2010-10-20T15:11:01","date_gmt":"2010-10-20T13:11:01","guid":{"rendered":"http:\/\/sickel.net\/blogg\/?p=810"},"modified":"2011-05-30T06:52:40","modified_gmt":"2011-05-30T04:52:40","slug":"generation-of-dynamic-kml-files","status":"publish","type":"post","link":"http:\/\/sickel.net\/blogg\/?p=810","title":{"rendered":"Generation of dynamic kml files"},"content":{"rendered":"<p>I have a number of geographical datasets in a database that I would like to <a href=\"http:\/\/sickel.net\/blogg\/?p=817\">visualize as kml-files<\/a>. For google earth to behave correctly, it is not just enough that the &#8220;Content-Type&#8221; is correctly set. The file must end with a .kml.<\/p>\n<p>Again, mod_rewrite to the rescue. The following line in my .htaccess file:<\/p>\n<pre>\r\nRewriteRule dataset-(.*).kml$ \/mobilweb\/kml.php?fileid=$1\r\n<\/pre>\n<p>I.e, when I make an url that ends with fileid-<something>.kml, that is internally forwarded to the apacheserver that runs kml.php?fileid=<\/something><something> and returns the result as the abovementioned kml-file. Google earth then opens the file and displays it just fine. (of cource given that the kml is correctly made&#8230;) I can also add some more info in the kml-name by using a more advanced .htaccess E.g.<\/p>\n<pre>\r\nRewriteRule dataset(.*)-(.*).kml$ \/mobilweb\/kml.php?fileid=$2&color=$1 \r\n<\/pre>\n<p>Here I specify a colorcode just followint the keyword dataset, the id comes after the hyphen. Of cource, I must sanitize the id and color codes correctly in the script and also handle it correctly if they are invalid or missing.<\/something><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have a number of geographical datasets in a database that I would like to visualize as kml-files. For google earth to behave correctly, it is not just enough that the &#8220;Content-Type&#8221; is correctly set. The file must end with &hellip; <a href=\"http:\/\/sickel.net\/blogg\/?p=810\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1,23],"tags":[],"class_list":["post-810","post","type-post","status-publish","format-standard","hentry","category-div","category-kml"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pnVtD-d4","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"http:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/posts\/810","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/sickel.net\/blogg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=810"}],"version-history":[{"count":4,"href":"http:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/posts\/810\/revisions"}],"predecessor-version":[{"id":1033,"href":"http:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/posts\/810\/revisions\/1033"}],"wp:attachment":[{"href":"http:\/\/sickel.net\/blogg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=810"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/sickel.net\/blogg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=810"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/sickel.net\/blogg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=810"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}