{"id":2142,"date":"2010-12-30T14:28:22","date_gmt":"2010-12-30T19:28:22","guid":{"rendered":"http:\/\/www.gubatron.com\/blog\/?p=2142"},"modified":"2010-12-30T14:28:22","modified_gmt":"2010-12-30T19:28:22","slug":"how-to-convert-android-gps-coordinates-into-xy-coordinates","status":"publish","type":"post","link":"https:\/\/www.gubatron.com\/blog\/how-to-convert-android-gps-coordinates-into-xy-coordinates\/","title":{"rendered":"How to convert Android GPS coordinates into X,Y coordinates."},"content":{"rendered":"<p>Without further math bullshit about all the conversion systems, when you have a bunch of Android GPS coordinates (which are compatible with Google Earth and Google Maps), and you want to draw them on a finite 2D plane, here&#8217;s what worked for me.<\/p>\n<p>[java]<br \/>\nint x =  (int) ((PLANE_WIDTH\/360.0) * (180 + lon));<br \/>\nint y =  (int) ((PLANE_HEIGHT\/180.0) * (90 &#8211; lat));<br \/>\n[\/java] <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Without further math bullshit about all the conversion systems, when you have a bunch of Android GPS coordinates (which are compatible with Google Earth and Google Maps), and you want to draw them on a finite 2D plane, here&#8217;s what worked for me. [java] int x = (int) ((PLANE_WIDTH\/360.0) * (180 + lon)); int y [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","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_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[5,15],"tags":[],"class_list":["post-2142","post","type-post","status-publish","format-standard","hentry","category-android","category-code"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5Unzf-yy","jetpack-related-posts":[{"id":3078,"url":"https:\/\/www.gubatron.com\/blog\/how-to-obtain-the-coordinates-of-the-jtable-cell-a-mouse-is-hovering-over-useful-for-tooltips-within-cell-renderers\/","url_meta":{"origin":2142,"position":0},"title":"How to obtain the coordinates of the JTable cell a mouse is hovering over, useful for tooltips within cell renderers.","author":"gubatron","date":"June 19, 2013","format":false,"excerpt":"public String getToolTipText(MouseEvent event) { \/* * This is a Java Swing lesson on how to obtain the coordinates of the current cell * as you hover with the mouse on a JTable. * * You cannot use the renderer component, since it seems that once the table is done\u2026","rel":"","context":"In \"cell rectangles\"","block_context":{"text":"cell rectangles","link":"https:\/\/www.gubatron.com\/blog\/tag\/cell-rectangles\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2063,"url":"https:\/\/www.gubatron.com\/blog\/android-programming-how-to-obtain-the-wifis-corresponding-networkinterface\/","url_meta":{"origin":2142,"position":1},"title":"Android: How to obtain the WiFi&#8217;s corresponding NetworkInterface","author":"gubatron","date":"September 19, 2010","format":false,"excerpt":"Let's say for some odd reason in the world you do need to get the corresponding NetworkInterface object of the Wifi on your android, in my case I needed to have my WiFi device send multicast packets, and I wanted my MulticastSocket to only send packets through the WiFi device\u2026","rel":"","context":"In &quot;Android&quot;","block_context":{"text":"Android","link":"https:\/\/www.gubatron.com\/blog\/category\/android\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2887,"url":"https:\/\/www.gubatron.com\/blog\/android-changing-textview-alpha-transparency-across-different-target-sdks\/","url_meta":{"origin":2142,"position":2},"title":"Android: Changing TextView alpha transparency across different target SDKs","author":"gubatron","date":"November 30, 2012","format":false,"excerpt":"Sometimes you may need to make a TextView (label) look a little transparent to make emphasis on other parts of your UI. The .setAlpha() function on TextView is not supported after later in the SDK. Here's a static workaround you can place on some sort of UIUtils class you may\u2026","rel":"","context":"In \"Android\"","block_context":{"text":"Android","link":"https:\/\/www.gubatron.com\/blog\/tag\/android\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2047,"url":"https:\/\/www.gubatron.com\/blog\/map-function-in-java\/","url_meta":{"origin":2142,"position":3},"title":"Map function in Java","author":"gubatron","date":"August 31, 2010","format":false,"excerpt":"I read on some email signature something along the lines of: \"If I had a dollar for every for(int i=0; i < size; i++) { ... } I've written I'd be rich\" After coding on Android and learning about some of the tips for performance, like \"With an ArrayList, a\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1928,"url":"https:\/\/www.gubatron.com\/blog\/droid-vs-nexus-1-who-can-calculate-md5-faster\/","url_meta":{"origin":2142,"position":4},"title":"Droid vs Nexus 1: Who can calculate MD5 faster?","author":"gubatron","date":"May 21, 2010","format":false,"excerpt":"Nexus 1 indeed. 17 files get their MD5 calculated on the Droid and 17 files get their MD5 hash calculated on the Nexus 1 Nexus 1 pwns. Here's the code in case you're curious. [java] public void onClick(View v) { _logTextView.setText(\"MD5 Benchmark on \" + Build.DEVICE + \"nn\"); if (GlobalVariables.APP_CONTEXT\u2026","rel":"","context":"In &quot;Android&quot;","block_context":{"text":"Android","link":"https:\/\/www.gubatron.com\/blog\/category\/android\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1114,"url":"https:\/\/www.gubatron.com\/blog\/using-a-linear-array-as-a-bidimensional-matrix\/","url_meta":{"origin":2142,"position":5},"title":"Using a linear array as a bidimensional matrix","author":"gubatron","date":"January 27, 2009","format":false,"excerpt":"Often times I find the need to use a list or linear array as if it was a table. Everytime I need to do so, I always end up coding functions to convert a (x,y) coordinate to the real index n in the array. Let me illustrate, with an example.\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/2142","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/comments?post=2142"}],"version-history":[{"count":0,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/2142\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/media?parent=2142"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/categories?post=2142"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/tags?post=2142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}