AndroidTacticalAssaultKit-CIV icon indicating copy to clipboard operation
AndroidTacticalAssaultKit-CIV copied to clipboard

tileUpdate Entry in custom XML map sources is unused

Open jamesjiro opened this issue 4 years ago • 4 comments
trafficstars

ATAK doesn't appear to be using the tileUpdate entry for custom XML map sources. MobacMapSourceFactory supports parsing the tileUpdate entry as a refreshInterval, but I don't see this being used to download new tiles from a map source. What would be required to add this functionality to ATAK? Could it be implemented as a plugin?

jamesjiro avatar Sep 27 '21 23:09 jamesjiro

@jamesjiro With ATAK 4.4, the tileUpdate-as-refreshInterval should be functional (please see below example; you may need to turn on continuous rendering [this is a bug, should be automatically refreshing]). We know this is not a valid interpretation of the MOBAC schema, but it was a quick path to get some kind of refresh ability out.

We spent some time looking into implementing per the schema during the 4.4 development cycle, but were unable to find servers that provided the appropriate response and did not have time to stand up our own test environment. We would welcome any patch that implements this feature into core.

This functionality could indeed be implemented as a plugin. Unfortunately, MobacMapSource instantiation is one of the few things that is not pluggable -- if it was, this would be a much simpler exercise. At a minimum, your the plugin would do the following:

  • Implement a custom DatasetDescriptorSpi that functions similar to the MobacMapSourceLayerInfoSpi, with correct handling for the <tileUpdate> tag, with a higher priority than MobacMapSourceLayerInfoSpi.
  • Copy and modify MobacTileReader such that it is either directly implemented or relies on a TileClient with whatever implementation modifications are required to support <tileUpdate>. Take special note of the field, version. The renderer tracks the value of TileReader.getTileVersion(...), using that as a trigger to refresh a tile's texture. We use a single version across the entire dataset -- trading complexity for update imprecision. You could also implement an entirely new TileReader from scratch if so desired.
  • Create a TileReaderSpi for the new TileReader implementation with a priority higher than MobacTileReader.SPI
  • Register your custom SPIs in the plugin's onCreate.
  • Per the note above, you may need to enable continuous rendering for this all to work, pending further upstream diagnosis. As a workaround, you may have the plugin invoke MapView.getMapView().getRenderer3().getRenderContext().setContinuousRenderEnabled(true) in your plugin's onCreate to enable on the user's behalf.
<?xml version="1.0" encoding="UTF-8"?>
<customMapSource>
    <name>Random Image</name>
    <minZoom>0</minZoom>
    <maxZoom>2</maxZoom>
    <tileType>png</tileType>
    <tileUpdate>15000</tileUpdate>
    <url>https://picsum.photos/256</url>
    <backgroundColor>#000000</backgroundColor>
</customMapSource>

takdeveloper avatar Sep 30 '21 02:09 takdeveloper

@takdeveloper Thank you very much. I will try to use the tileUpdate-as-refresh functionality. I'm currently having issues running the development APK distributed in the SDK release for version 4.4.0.0. After installing the ATAK APK and going through the permissions prompts, the application is exiting to the home screen. When I try restarting the application it immediately exits. I'm running the Android Emulator (version 30.8.4) with a Pixel C tablet and Pixel 5 phone with both Android 11.0 and Android 10.0. I'm also seeing this behavior outside of the emulator on a Samsung Galaxy Tab Active2 with Android 9.0 installed.

jamesjiro avatar Sep 30 '21 21:09 jamesjiro

@jamesjiro The issue with the 4.4 SDK has been diagnosed; identifying the cause now.

takdeveloper avatar Oct 04 '21 13:10 takdeveloper

@takdeveloper I have tested the build produced by PR #128. The tileUpdate appears to be working as described. I have noticed that expired tiles seem to flicker in and out of the map view. This continues even after I disconnect my local tile server. My plugin currently adds the map source XML in the same way as the Imagery class. I have also enabled continuous rendering in the onCreate method of my MapComponent class.

jamesjiro avatar Oct 07 '21 17:10 jamesjiro