Monday, November 24, 2014

Fixing Android Studio cannot resolve symbol R errors after an SDK update

Recently I updated an installation of the Android Studio beta to the latest Android SDK version on a workstation. Subsequently after the upgrade, the Android source project in the Studio will show error messages as shown in the screenshot below and all the R symbols in the editor would be highlighted in red when a new activity is added to the project. The console would be complaining about numerous unresolved resources e.g. "No resource found that matches the givent name 'android:TextAppearance.Material.Body2'".


The solution is to change the project settings to build using the latest Android SDK, as described below.

  1. In the Android Studio IDE, select File | Project Structure.

    The Project Structure dialog box appears.

  2. If not selected, choose the Project app module.
  3. Under the Properties tab, in the Compile Sdk Version field, choose the latest SDK .e.g API 21: Android 5.0 (Lollipop).


  4. In the Build Tools Version field, choose the latest version, e.g. 21.1.1.
  5. Click OK.

    The project is refreshed and the error messages no longer appear.

Monday, November 17, 2014

Trainsity Vancouver Windows Phone App

Find your way around metropolitan Vancouver's SkyTrain network using the high resolution vector maps of the Canada, Expo, and Millennium lines on a Windows Phone. The maps have small file size footprints but with many levels of zoom, and they can be viewed offline without any Internet connection. Users can click the train station labels to open the external Bing Maps app where they can use all the functions of the external app to visualize the surrounding area including querying for directions. This app has its own directions function for finding the best path from one train station to another.

On a Windows Phone handset, the app will display tiles of train lines, which when tapped will open up a detail view of the metro transit map, as shown below.

Tapping the station labels will bring up an option menu where users can choose to display the station location in Bing Maps.

If you want to find how long it takes to travel from one station to another, and the best route to take, simply swipe to the Route page. Then type in the From station and To station. As you enter the values, a drop down list will appear and a station can be selected from the list. Finally tap the Execute icon.
 
Tapping the more details link will display the recommended route to take.


 Click the button below to download the app from the Windows Phone store.

Monday, November 10, 2014

SVG template for creating Android Material Design product icons

Android Material Design has some guidelines for developers and designers to create product icons that reflect brand identity, as described in detail on this site http://www.google.com/design/spec/style/icons.html#icons-product-icons. As part of these guidelines, product icons can be based on certain keyline shapes in order to "maintain a consistent visual proportion across related product icons."

These keyline shapes include:

  • square
  • circle
  • vertical rectangle
  • horizontal rectangle. 

I did not find any downloadable resources of the keyline shapes to base the creation of new Android icons, so I created my own template in SVG format, at 4 times 48 pixels size, i.e. 192 pixels. The template looks as shown in the screenshot of Inkscape below.


Each keyline shape is placed on a separate layer.

Simply toggle on the desired keyline shape e.g. Horizontal rectangle in order to use it as a guide in creating new icons.


The SVG template can be downloaded from this site https://www.dropbox.com/s/3fhijfrf3zipnjm/mat_dgn_icon_template.svg?dl=0 if you want to use it.

Monday, November 3, 2014

Convert MultiLineString geometries to LineString using SpatiaLite SQL

Recently I made a mistake in creating a linear feature as a multi-line string instead of a plain line string geometry in SpatiaLite. I really did not want to digitize the features again so I decided to use SQL statements to convert the existing multi-line string geometries to line strings.

The following simple example shows how to do the conversion from a multi-line string table roads to a new line string table newroads. The basic steps involve (1) creating a new table, (2) populate the new table, (3) updating the new table with the line string geometry, (4) fixing the spatial metadata.
The table roads with the incorrect Multi-Line String geometry

Create a new table

  1. In SpatiaLite, type in the following SQL statement to create a new empty table newroads from the roads table. Execute the statement.

    CREATE TABLE newroads AS SELECT * FROM roads LIMIT 0

    A blank table is created with the same structure as the roads table.

Populate the new table with the textual attribute values
  1. In SpatiaLite, type in the following SQL statement to copy the rows (without the geometry field) from the original roads table into the new table newroads.

    INSERT INTO newroads(pkuid,name)SELECT pkuid,name FROM roads 
  2. Execute the SQL statement.

    All the rows are copied into the new table newroads.

    A simple query of the new table newroads show that all fields are populated with the exception of the geometry field, which remains as null.



Update the geometry field
  1. In SpatiaLite, type in the following SQL statement to form the SQL update statements to populate the geometry field.

    SELECT
    'UPDATE newroads SET Geometry='||'ST_GeomFromText('''||
    AsText(Geometry)||
    ''', 4326) WHERE pkuid='||
    pkuid||';' FROM roads


    Note: 4326 is the coordinate system reference used for the roads feature.
  2. Execute the statement.

    The update SQL statements are generated.

  3. In SpatiaLite GUI, click the grey area above and left of the resultant rows, as shown above.

    All the resultant rows are selected.
  4. Mouse right click on the selected rows.

    A pop up menu appears.

  5. Choose Copy.

    The resultant rows are copied to the OS Clipboard.
  6. In a text editor, paste the rows into a new file, e.g. demorun.sql.


  7. Change all occurrences of the string "MULTILINESTRING" to "LINESTRING".
  8. Change all occurrences of the string "((" to "(".
  9. Change all occurrences of the string "))" to ")".

    The statements should now look like the following example.

    UPDATE newroads SET Geometry=ST_GeomFromText('LINESTRING(-123.013367 49.328037, -122.980708 49.353917, -122.981324 49.386576, -122.975779 49.409992)', 4326) WHERE pkuid=1;
  10. Save the changes.
  11. In SpatiaLite, click the Execute SQL script button as shown below.



    The SQL Script Windows appears.

  12. Select the newly created SQL script file, e.g. demorun.sql. Click Open.

    The geometry field in newroads is updated.



Fix the spatial metadata
  1. In SpatiaLite GUI, mouse right click on the geometry field of the new table newroads.

    A pop up menu appears.

  2. Choose Recover geometry column.

    The Recover geometry column dialog box appears.
  3. In the SRID field, type in the coordinate system SRID value e.g. 4326.
  4. In the Dims field, choose the appropriate dimension of the geometry field, e.g. XY.
  5. In the Geometry Type list, choose LINESTRING.
  6. Click OK.

    The geometry field is recovered.



Related Posts with Thumbnails