Commit 2d9f1e39 authored by Nick Whitelegg's avatar Nick Whitelegg
Browse files

v0.1.3: Remove flicker and clarify that International mode must be used in Northern Ireland

parent 01237db3
......@@ -17,6 +17,7 @@
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
<excludeFolder url="file://$MODULE_DIR$/build" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
......
......@@ -86,26 +86,17 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/build-info" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-resources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/multi-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/split-apk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/splits-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
......
......@@ -8,8 +8,8 @@ android {
applicationId "freemap.hikar"
minSdkVersion 16
targetSdkVersion 22
versionCode 3
versionName "0.1.2"
versionCode 5
versionName "0.1.3"
}
buildTypes {
release {
......
......@@ -227,7 +227,7 @@ public class Hikar extends AppCompatActivity implements SensorInput.SensorInputR
break;
case R.id.about:
DialogUtils.showDialog(this, "Hikar v0.1.2, (c) Nick Whitelegg 2013-18. " +
DialogUtils.showDialog(this, "Hikar v0.1.3, (c) Nick Whitelegg 2013-18. " +
"Licensed under the GPL, v3. Uses OpenStreetMap data, " +
"copyright 2004-18 OpenStreetMap contributors, Open Database License. " +
"Also uses Ordnance Survey LandForm PANORAMA height data, Crown Copyright.");
......@@ -392,7 +392,7 @@ public class Hikar extends AppCompatActivity implements SensorInput.SensorInputR
}
}
public void receiveSensorInput(float[] glR) {
public void receiveSensorInput(float[] glR, float bearingRadians) {
float[] orientation = new float[3];
float magNorth = field == null ? 0.0f : field.getDeclination(),
......
......@@ -354,6 +354,7 @@ public class OpenGLView extends GLSurfaceView {
public void setOrientMtx(float[] orientMtx) {
this.modelviewMtx = orientMtx.clone();
requestRender();
}
public void setRenderData(DownloadDataTask.ReceivedData data) {
......@@ -369,6 +370,7 @@ public class OpenGLView extends GLSurfaceView {
public void setCameraLocation(Point unprojected) {
if (trans != null) {
cameraPos = trans.lonLatToDisplay(unprojected);
requestRender();
}
}
......@@ -419,6 +421,7 @@ public class OpenGLView extends GLSurfaceView {
setEGLContextClientVersion(2);
renderer = new DataRenderer(handler);
setRenderer(renderer);
setRenderMode(RENDERMODE_WHEN_DIRTY);
}
......
package freemap.hikar;
import android.hardware.SensorManager;
......@@ -16,9 +15,11 @@ public class SensorInput implements SensorEventListener {
Sensor accelerometer, magneticField;
float[] accelValues, magValues;
float k; // smoothing factor, low-pass filter
float[] prevOrientation = new float[3];
float angleChangeThreshold = (float)(2.0f * (Math.PI/180.0f));
public interface SensorInputReceiver {
public void receiveSensorInput(float[] rotMtx);
public void receiveSensorInput(float[] rotMtx, float bearingRadians);
}
public SensorInput(SensorInputReceiver receiver) {
......@@ -66,6 +67,7 @@ public class SensorInput implements SensorEventListener {
public void onSensorChanged(SensorEvent ev) {
float[] R = new float[16], I = new float[16], glR = new float[16];
float[] orientation = new float[3];
float orientAdj = 0.0f;
switch (ev.sensor.getType()) {
case Sensor.TYPE_ACCELEROMETER:
for (int i = 0; i < 3; i++)
......@@ -81,19 +83,24 @@ public class SensorInput implements SensorEventListener {
if (accelValues != null && magValues != null && ctx != null) {
SensorManager.getRotationMatrix(R, I, accelValues, magValues);
SensorManager.getOrientation(R, orientation);
WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
switch (wm.getDefaultDisplay().getRotation()) {
case Surface.ROTATION_90:
SensorManager.remapCoordinateSystem(R, SensorManager.AXIS_Y, SensorManager.AXIS_MINUS_X, glR);
orientAdj = (float)(0.5*Math.PI);
break;
case Surface.ROTATION_180:
SensorManager.remapCoordinateSystem(R, SensorManager.AXIS_MINUS_X, SensorManager.AXIS_MINUS_Y, glR);
orientAdj = (float)Math.PI;
break;
case Surface.ROTATION_270:
SensorManager.remapCoordinateSystem(R, SensorManager.AXIS_MINUS_Y, SensorManager.AXIS_X, glR);
orientAdj = (float)(-0.5*Math.PI);
break;
case Surface.ROTATION_0:
......@@ -102,8 +109,25 @@ public class SensorInput implements SensorEventListener {
}
boolean doReceiveSensorInput = false;
for(int i = 0; i<3; i++) {
if(Math.abs(orientation[i] - prevOrientation[i]) >= angleChangeThreshold) {
doReceiveSensorInput = true;
break;
}
}
receiver.receiveSensorInput(glR);
if(doReceiveSensorInput) {
float realBearing = orientation[0] + orientAdj;
realBearing = (float)(realBearing > Math.PI ? realBearing - Math.PI*2:
(realBearing < -Math.PI ? realBearing + Math.PI*2: realBearing));
receiver.receiveSensorInput(glR, realBearing);
System.arraycopy(orientation, 0, prevOrientation, 0, 3);
}
}
}
}
\ No newline at end of file
}
......@@ -2,7 +2,7 @@
<resources>
<string-array name="demKeys">
<item>UK Mode</item>
<item>GB Mode</item>
<item>International Mode</item>
</string-array>
......
......@@ -11,15 +11,15 @@
<string name="ok">OK</string>
<string name="cancel">Cancel</string>
<string name="selectmode">Select your mode</string>
<string name="uk">UK mode</string>
<string name="uk">GB mode</string>
<string name="international">International mode</string>
<string name="modesExplanation">UK mode uses Ordnance Survey LandForm PANORAMA height data
<string name="modesExplanation">GB mode (UK excl. NI) uses OS LandForm PANORAMA height data
and OSGB grid references for retrieving data tiles. International mode (which also works in
the UK) uses NASA SRTM height data and microdegrees. Note in practice
GB) uses NASA SRTM height data and microdegrees. Note in practice
that the default server will only provide data in England and Wales currently; however International mode is setup
to be able to talk to servers providing international data, when these servers become available.</string>
<string name="displayProjectionsExplanation">Display projection is the projection the data is displayed in.
This is OSGB in UK mode and Google Spherical Mercator for international mode; however you can edit this
This is OSGB in GB mode and Google Spherical Mercator for international mode; however you can edit this
manually (e.g. to a projection used by a particular country or region)</string>
<string name="displayProjection">Display projection</string>
<string name="start">Start!</string>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment