reset password

LMMPAA Code Analysis

Conventions

THINGS TO DO

THINGS TO ASK

AndroidManifest.xml

Current minSdkVersion is 11 (Android 3.0 Honeycomb), which has almost 0 market share now. Can we raise minSdkVersion to 14 (Android 4.0 Ice Cream Sandwich)?

MainActivity

onCreate()

handleIntent(): right now it only deals with search.

LoadViewTask().execute()

startMainActivity()

LoadViewTask

loadConfig(): retrieve config from http://pub.lmmp.nasa.gov/lmmpmobile/config-1.0.json. Currently the Android app has four hard-coded basemap layers. Shall we get the basemap layers from config instead?

loadBookmarks(): retrieve bookmarks from the bookmarks URL in config.

loadInitialLayerData()

Initialize a LayerParser. LayerParser combines web service access and an XML SAX parser. At the very least web service access should be split into WebSeviceClient. We probably also want to rewrite the parser using either XmlPullParser (recommended by Google) or XStream (presumably easier to use). Another bad design is that LayerParser is used to hold all the layer data (WMSLayers and WMSServiceLayers). We'd want to split the data into some singleton data holders and leave parsers to be just parsers.

Parse an XML file retrieved from the byproducttypeurl in config - http://pub.lmmp.nasa.gov/LMMP/rest/dbxml/layers?proj=IAU2000:30100&visOnly=true&sort=ProductType%2Ctitle. This would retrieve a fairly large (866KB) XML file layers.xml which contains a number of layers. Retrieving this file takes a long time (probably because it's dynamically generated), which contributes significantly to the initial loading time. After parsing the XML file, a Map of WMSLayer is created, where the map key is the layer title. What exactly are these "layers"?

From all the layers, the layer "LRO LROC DEM, Tycho Crater, Grayscale" (hard-coded in MainActivity as layerMostLevels) is selected to create a WMSSeviceLayer.

The constructor of WMSServiceLayer first retrieve an XML file from WMSLayer.getEndPoint() + "?request=GetTileServer", i.e. http://onmoon.lmmp.nasa.gov/sites/wms.cgi?request=GetTileService. The XML file is again fairly large (394KB), and takes a long time to retrieve. This file contains a number of <TiledGroup>. One of the TiledGroup is selected based the WMSLayer's layer name in <LayerService>, or <LayerTitle> if there's no layer name in <LayerService>. In the case of the layer "LRO LROC DEM, Tycho Crater, Grayscale", the TiledGroup selected is "Tycho Crater DEM Grayscale, LMMP". The constructor then does a little bit more work (setTileInfo() and super.init()) so it can be used by ESRI's MapView as a TiledServiceLayer. There's something odd in buildTileInfo() though: if a layer is the first base map, then instead of using its own TiledGroup, buildTileInfo() uses "LRO LROC DEM, Tycho Crater, Grayscale"'s TiledGroup to calculate the tile information. Why?

The previous step is then repeated four times (i.e. loadBasemapData()) to create four WMSServiceLayer for the four layers in basemapList. The difference is that the EndPoint for these fours layers are http://moons.lmmp.nasa.gov/wms.cgi, which is significantly faster than http://onmoon.lmmp.nasa.gov/sites/wms.cgi. There's an obvious optimization here: since they all have the same EndPoint, instead of retrieving the same XML file four times, we can do it once, then pick four <TiledGroup> out of it.

startMainActivity()

This method is executed after LoadViewTask is completed (in onPostExecute()). It creates various GUI components, including the MapView, and adds the basemap layers to the MapView. There's not too much to say here, except that we may want to change the GUI at some point. For example, I don't like displaying all the bookmarks in a popup dialog box.

This page has been viewed 3782 times.