Showing posts with label KML. Show all posts
Showing posts with label KML. Show all posts

Monday, April 18, 2016

Testing Location based Apps on Android Emulator

Things have changed for the good with Emulator 2.0. I think this is the first time I might end up spending more development time on the emulator than on the device.

In this post, I'll be explaining two approaches of how to effectively test location-based apps using the emulator:

1. Testing a single location for the app

From the Extended Controls > Location you can send specific Latitude, Longitude & Altitude to the device. Here's a GIF which shows how we can send Latitude and Longitude and that gets detected by the application

2. Testing multiple locations using KML

For the demo I'm using a KML file from here: https://developers.google.com/kml/documentation/kml_tut#paths which specifies multiple locations in the Placemark section (To learn more about KML, here's a tutorial: https://developers.google.com/kml/documentation/kml_tut)
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
    <name>Paths</name>
    <description>Examples of paths. Note that the tessellate tag is by default
      set to 0. If you want to create tessellated lines, they must be authored
      (or edited) directly in KML.</description>
    <Style id="yellowLineGreenPoly">
      <LineStyle>
        <color>7f00ffff</color>
        <width>4</width>
      </LineStyle>
      <PolyStyle>
        <color>7f00ff00</color>
      </PolyStyle>
    </Style>
    <Placemark>
      <name>Absolute Extruded</name>
      <description>Transparent green wall with yellow outlines</description>
      <styleUrl>#yellowLineGreenPoly</styleUrl>
      <LineString>
        <extrude>1</extrude>
        <tessellate>1</tessellate>
        <altitudeMode>absolute</altitudeMode>
        <coordinates> -112.2550785337791,36.07954952145647,2357
          -112.2549277039738,36.08117083492122,2357
          -112.2552505069063,36.08260761307279,2357
          -112.2564540158376,36.08395660588506,2357
          -112.2580238976449,36.08511401044813,2357
          -112.2595218489022,36.08584355239394,2357
          -112.2608216347552,36.08612634548589,2357 
          -112.2633204928495,36.08621519860091,2357
          -112.2644963846444,36.08627897945274,2357
          -112.2656969554589,36.08649599090644,2357 
        </coordinates>
      </LineString>
    </Placemark>
  </Document>
</kml>

Steps

  • Select and Load KML file: From the Extended Controls > Location click on Load GPX/XML 
  • The above step would load locations from KML file in the table 
  • Select the speed at which you want to change the location, for example, Speed 2x would change location every 2 seconds
Here's the pictorial representation of the above steps :

Here's a GIF image showing how it iterates through locations in the table and updates the Latitude & Longitude on the emulator