TransWikia.com

Returning null during using SpatiaLite transformation command in Android Studio

Geographic Information Systems Asked by user168505 on November 30, 2020

I am using Spatialite version as following:
SPATIALITE_VERSION: 5.0.0-beta1
PROJ4_VERSION: Rel. 6.1.1
I am running the SpatiaLite transform function in the android studio and it returns a null value during running. I did this command in SpatiaLite GUI and the result was correct. I did another SpatiaLite command in the Android Studio and there was no error.
I think the Transform function of SpatiaLite is not recognized in the Android Studio.
This is one part of the code that gets a null value in Android Studio:
String query="select
AsText(Transform(Makepoint(37.253453454,38.253453454,4326),32632));"
complete function that I used from spatialite tutorial is as follows:

              public String doSimpleTransform() {
              StringBuilder sb = new StringBuilder();
              sb.append("Coordinate transformation...n");
              String query="select                                  
        AsText(Transform(Makepoint(37.253453454,38.253453454,4326),32632));";
         sb.append("Execute query: ").append(query).append("n");
              try {
         Stmt stmt = db.prepare(query);
         if (stmt.step()) {
             String pointStr = stmt.column_string(0);
            sb.append(pointStr).append("...n");
                          }
            stmt.close();
            } catch (Exception e) {
           e.printStackTrace();
           }
          sb.append("Done...n");
         return sb.toString();
           }

This is a command in Spatialite-GUI that return correct value:
SELECT AsText(Transform(Makepoint(37.253453454,38.253453454,4326),32632))

One Answer

I changed the code and add new parameter using transform.Using the following code solved the error: query="SELECT AsText ( ST_Transform( MakePoint( 37.253453454 ,38.253453454, 4326 ) , 32632, NULL,(SELECT srtext FROM spatial_ref_sys WHERE srid = 4326),(SELECT srtext FROM spatial_ref_sys WHERE srid = 32632)));";

Answered by user168505 on November 30, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP