Monday, August 13, 2018

How to find the cause of a lint error while generating a signed Android APK

Sometimes when generating a signed APK of an Android App from Android Studio, I would encounter a cryptic lint error message:

Lint found fatal errors while assembling a release target.

To proceed, either fix the issues identified by lint, or modify your build script as follows:
...
android {
    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }
}
...




The message suggests to disable the lint checking but it would probably not be to your benefit to ignore the error.

After some digging around, I found that lint checking outputs a report which you can read to identify the source of the problem. The report can be found in the application's source build directory e.g. /your/Android/app/build/reports/ and named as lint-results-release-fatal.html




If you open up the report in a browser, the cause of the lint error can be easily seen. In this example, the reason for the compilation error is a missing language translation.
 

Monday, May 21, 2018

Perform a 2D geo-registration of a LiDAR LAS file to a GeoTiff image with Cloud Compare

Recently I received LiDAR LAS point clouds generated without using accurate GPS positioning. As a result, the data is not placed at the correct geographic location in the world. To rectify this, I used Cloud Compare to so-called geo-register the point clouds to the world using GeoTiff images as reference.

The following illustrates how it was done:

Load the GeoTiff image as reference
  1. Start Cloud Compare.


  2. Select File | Open.

    The Open file(s) dialog box appears.

  3. Browse and select the reference GeoTiff raster file, e.g. autzen.tif. Click Open.

    The Result type prompt appears.

  4. Click No to load as a texture map instead of converting to a point cloud.

    The Global shift/scale dialog box appears.

  5. Accept the defaults. Click Yes.

    The GeoTiff image is loaded.
Load the LAS file
  1. Select File | Open.


  2. Browse and choose the LAS file, e.g. autzen.las. Click Open.

    The Open LAS File dialog box appears.
  3. Click Apply.

    The Global shift/scale dialog box appears.

  4. Click Yes to accept the defaults.

    The LAS file is loaded.
 Setup the display
  1. In the vertical tool bar on the left, click the Set Current View Mode icon
    and choose Orthographic projection.

    Note: we do not want the perspective projection display to mislead us as to the location of the features
  2. Optional. Select Edit | Colors | Height Ramp. Click OK in the Gradient color dialog box to display the point cloud with a height color gradient for better visualization.


Perform the rectification
  1.  In the DB Tree pane, select the point cloud to rectify, e.g. autzen.las.
  2. In the top tool bar, click the Translate/Rotate icon .

    The Translate/Rotate widget appears in the top right corner.
  3. In the Rotation field, select Z. Toggle off Tz.

    Note: we only want to move horizontally in the 2D plane.
  4. Look for matching features in the point cloud and the GeoTiff image.



  5. To translate the point cloud, press down the mouse right button and drag the point cloud to the new location. To rotate the point cloud, press down the mouse left button and rotate the point cloud.

    Note 1: To toggle the display of the point cloud, toggle on/off the Visible property in the Properties pane on the left.
    Note 2: To zoom in/out/pane around, pause the Translate/Rotate widget by clicking the widget's Pause icon.
  6. In the Translate/Rotate widget, click the Tick icon to save the changes.

    The point cloud is rectified.


Monday, May 14, 2018

Use PDAL to apply a vertical datum geoid correction to a LAS file

PDAL can be used to apply a vertical datum correction to LAS files, e.g. to convert LiDAR data in ellipsoidal heights to mean sea level using a geoid such as the EGM2008. PDAL uses geoids in gtx format and can be downloaded from http://download.osgeo.org/proj/vdatum/

The following steps show how to perform a vertical datum correction with the reprojection filter of PDAL:
  1. Optional. Download an appropriate geoid file e.g. egm08_25.gtx for EGM2008 from http://download.osgeo.org/proj/vdatum/ and place it in a folder e.g. D:\Temp\PDAL\
  2. Open up the OSGeo4W Shell.
  3. In the Command Prompt, type in the following command:

    D:\> pdal translate -i input.las -o output.laz reprojection --filters.reprojection.in_srs="EPSG:32610+4326" --filters.reprojection.out_srs="+init=EPSG:32610 +geoidgrids=D:/Temp/PDAL/egm08_25.gtx" --writers.las.compression="true" --writers.las.a_srs="EPSG:32610+3855" -v 4

    where
    --filters.reprojection.in_srs specifies the source coordinate reference system EPSG:32610 or UTM 10 North  and the source vertical datum of EPSG:4326 which is the WGS84 Ellipsoid

    --filters.reprojection.out_srs specifies the destination coordinate reference system EPSG:32610 (the same as the input) and the EGM2008 grid file to apply

    --writers.las.a_srs tells PDAL to write the destination coordinate reference system of EPSG:32610 and vertical datum EPSG:3855 (which is the EGM2008 datum) to the output file.


  4. Press RETURN.

    Processing messages appear. The input las file is reprojected to the EGM2008 vertical datum.

  5. Optional. Overlay the input and output LAS files in a viewer and observe the vertical offset in a profile as shown below.

Monday, May 7, 2018

Using PDAL to perform simple translation transformations on LAS files

Sometimes for whatever reason you may want to apply a simple linear translation (dx, dy, dz) transformation shift on a LiDAR las file. PDAL has a transformation filter that you can use to perform the shifting, but you have to pass in the translation amounts as part of a 4x4 homogeneous transformation matrix.

A 4x4 transformation matrix that performs translations has the following form:
[1 0 0 dx]
[0 1 0 dy]
[0 0 1 dz]
[0 0 0 1]

So to use PDAL to perform a simple translation, just replace the dx, dy, dz with the translation amounts and pass the matrix to the PDAL transformation filter.

The following example command performs a vertical shift of +5.0 to the input las file.
C:> pdal translate -i input.las -o output.laz -f transformation   --filters.transformation.matrix="1 0 0 0 0 1 0 0 0 0 1 5.0 0 0 0 1"  --writers.las.compression="true" -v 4


The following screen shot shows a profile of the input and output las files with the output las file visibly shifted 5.0 above the input las file.


Monday, April 30, 2018

Better point cloud visualization in Cloud Compare with Eye Dome Lighting shading

Typically, LiDAR point clouds are displayed as a mass of colored points without perception of depth in a viewer. This can be hard to visualize objects or find your orientation in the point cloud. CloudCompare has a shading filter called the Eye Dome Lighting or EDL for short that can be used to apply a sort of depth outline around objects in the point cloud.

To use the EDL shader, do the following:
  1. In CloudCompare, load a point cloud file.

    The point cloud is displayed.
  2. Optional. To color the cloud, select the menu option Edit | Colors | Height Ramp.

    The Gradient color dialog box appears.


  3. Accept the default settings and click OK.

    The cloud is displayed with a default height ramp from blue (lowest) to red (highest).
  4. Now improve the display by applying the EDL Shader. In the menu, select Display | Shaders and Filters | E.D.L. (Shader).

    The shading is applied to the point cloud.

Monday, March 26, 2018

Resolving Maven "trustAnchors parameter must be non-empty" error

I encountered this Maven error on a new Ubuntu 18.04 system while trying to perform a mvn build on a Google AppEngine project. A screenshot of the error message is shown below.


It seems to be complaining about some "java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty" error.

After trying out some suggestions about regenerating Java security certificates, which didn't work, I managed to resolve the problem by creating a Maven  settings.xml file under a hidden folder .m2 underneath the user's home directory.

An example settings.xml file is shown below.

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0                            http://maven.apache.org/xsd/settings-1.0.0.xsd">
   <localRepository>/home/yourname/.m2/repository</localRepository>
   <interactiveMode />
   <usePluginRegistry />
   <offline />
   <pluginGroups />
   <servers />
   <mirrors />
   <proxies>
      <!-- 
               <proxy>
      <id>default</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>proxy-host</host>
      <port>8080</port>
      <username>user</username>
      <password>password123</password>
      <nonProxyHosts>localhost,127.0.0.1</nonProxyHosts>
    </proxy> -->
   </proxies>
   <activeProfiles>
      <!--make the profile active all the time -->
      <activeProfile>securecentral</activeProfile>
   </activeProfiles>
   <profiles>
      <profile>
         <id>securecentral</id>
         <!--Override the repository (and pluginRepository) "central" from the
                     Maven Super POM -->
         <repositories>
            <repository>
               <id>central</id>
               <url>http://repo1.maven.apache.org/maven2/</url>
               <releases>
                  <enabled>true</enabled>
               </releases>
            </repository>
         </repositories>
         <pluginRepositories>
            <pluginRepository>
               <id>central</id>
               <url>http://repo1.maven.apache.org/maven2/</url>
               <releases>
                  <enabled>true</enabled>
               </releases>
            </pluginRepository>
         </pluginRepositories>
      </profile>
   </profiles>
</settings>
Change the localRepository tag from /home/yourname/.m2/repository to correct location of your Maven repository.

Then place this the settings.xml file in the following location /home/your_user_id/.m2/

Now when running Maven build commands, the error messages no longer appear.


Wednesday, March 7, 2018

Fixing "Cannot resolve symbol Theme" error in Android Studio

If you have ever encountered unusual "cannot resolve symbol" messages with regards to Android resource XML files (an example is the screenshot below), which cannot be resolved by running Android Studio's Build | Clean Project or Build | Rebuild Project menu commands, then fixing the issue is very simple.


To resolve the problem, click on the Sync Project with Gradle Files icon in Android Studio, as shown in the screenshot below, or select Tools | Android | Sync Project with Gradle Files

Processing files will appear and at the end of it, the error messages no longer appear, as shown below.
Related Posts with Thumbnails