Skip to content

Commit

Permalink
Merge pull request #25 from missioncommand/#24-test-issue-#232
Browse files Browse the repository at this point in the history
#24 test issue #232
  • Loading branch information
rsupnekar authored Jun 30, 2017
2 parents 1c26ed8 + 575d452 commit d15aefb
Show file tree
Hide file tree
Showing 23 changed files with 453 additions and 5 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
ext {
version_emp3Android = "2.4.0"
version_emp3Android = "2.7.0"
}

repositories {
Expand All @@ -15,7 +15,7 @@ buildscript {
}

dependencies {
classpath "com.android.tools.build:gradle:2.3.0"
classpath 'com.android.tools.build:gradle:2.3.3'
classpath "mil.army.missioncommand:emp3-gradle-plugin:${version_emp3Android}"
classpath "org.ajoberstar:grgit:1.7.0"
}
Expand Down
4 changes: 3 additions & 1 deletion example-cameraandwms/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<resources>
<string name="app_name">Camera And WMS</string>
<string name="UrlDefault">http://neowms.sci.gsfc.nasa.gov/wms/wms</string>
<string name="UrlDefault">https://neo.sci.gsfc.nasa.gov/wms/wms</string>
<string name="VersionDefault">1.3.0</string>
<string name="TileFormatDefault">image/png</string>
<string name="TransparentDefault">true</string>
Expand All @@ -16,6 +16,8 @@
<string name="TiltDown">Down</string>
<string name="rollCCW">Roll CCW</string>
<string name="rollCW">Roll CW</string>
<string name="Loop">Loop</string>
<string name="Stop">Stop</string>

<!-- from joystick interface -->
<string name="window_icon">Window icon</string>
Expand Down
1 change: 1 addition & 0 deletions example-wmstest/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
14 changes: 14 additions & 0 deletions example-wmstest/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apply plugin: 'emp.android-app'

dependencies {
compile ("mil.army.missioncommand:emp3-android-sdk-view:$version_emp3Android") { transitive = true }
compile (group: 'mil.army.missioncommand', name: 'emp3-android-sdk-core', version: "$version_emp3Android", ext: 'aar') { transitive = true }

// Compile in the map engines rather than load it from the APK
compile ("mil.army.missioncommand:emp3-android-worldwind:$version_emp3Android@aar") { transitive = true }
compile (group: 'mil.army.missioncommand', name: 'mil-sym-android-renderer', ext: 'aar') { transitive = true }

compile ("com.android.support:appcompat-v7")
}

android.defaultConfig.applicationId "mil.emp3.examples.wmstest"
25 changes: 25 additions & 0 deletions example-wmstest/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /home/rajendra.supnekar@rgi-corp.local/Android/Sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
24 changes: 24 additions & 0 deletions example-wmstest/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="mil.emp3.examples.wmstest">

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
package mil.emp3.examples.wmstest;

import android.content.res.Resources;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;

import org.cmapi.primitives.IGeoAltitudeMode;

import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import mil.emp3.api.WMS;
import mil.emp3.api.enums.WMSVersionEnum;
import mil.emp3.api.events.MapStateChangeEvent;
import mil.emp3.api.events.MapUserInteractionEvent;
import mil.emp3.api.exceptions.EMP_Exception;
import mil.emp3.api.interfaces.ICamera;
import mil.emp3.api.interfaces.IMap;
import mil.emp3.api.interfaces.IMapService;
import mil.emp3.api.listeners.IMapInteractionEventListener;
import mil.emp3.api.listeners.IMapStateChangeEventListener;

public class MainActivity extends AppCompatActivity {

private final static String TAG = MainActivity.class.getSimpleName();
private WMS wmsService = null;
private IMap map = null;
private Spinner selectedLayers;
private Spinner versionText;
private Spinner tileFormatText;
private Spinner transparentText;
private EditText delayText;
ArrayList<String> layers = new ArrayList<>();
String layer;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i(TAG, "Setting custom activity");
setContentView(R.layout.activity_main);
ArrayAdapter<CharSequence> versionAdapter = ArrayAdapter.createFromResource(this,
R.array.wms_versions, android.R.layout.simple_spinner_item);
versionText = (Spinner)findViewById(R.id.VersionText);
versionText.setAdapter(versionAdapter);
ArrayAdapter<CharSequence> tileAdapter = ArrayAdapter.createFromResource(this,
R.array.image_formats, android.R.layout.simple_spinner_item);
tileFormatText = (Spinner)findViewById(R.id.TileFormatText);
tileFormatText.setAdapter(tileAdapter);
ArrayAdapter<CharSequence> booleanAdapter = ArrayAdapter.createFromResource(this,
R.array.boolean_values, android.R.layout.simple_spinner_item);
transparentText = (Spinner)findViewById(R.id.TransparentText);
transparentText.setAdapter(booleanAdapter);
// Cancel button exits the app
Button cancelButton = (Button) findViewById(R.id.CancelButton);
if (cancelButton != null) {
cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
} else {
Log.e(TAG, "Cancel Button not found");
}
/*
Instantiate a camera and set the location and angle
The altitude here is set initially to 1000 km
*/

final mil.emp3.api.Camera camera = new mil.emp3.api.Camera();
camera.setName("Main Cam");
camera.setAltitudeMode(IGeoAltitudeMode.AltitudeMode.ABSOLUTE);
camera.setAltitude(1e6);
camera.setHeading(0.0);
camera.setLatitude(40.0);
camera.setLongitude(-100.0);
camera.setRoll(0.0);
camera.setTilt(0.0);

map = (IMap) findViewById(R.id.map);
try {
map.addMapStateChangeEventListener(new IMapStateChangeEventListener() {
@Override
public void onEvent(MapStateChangeEvent mapStateChangeEvent) {
Log.d(TAG, "mapStateChangeEvent " + mapStateChangeEvent.getNewState());
switch (mapStateChangeEvent.getNewState()) {
case MAP_READY:
try {
map.setCamera(camera, false);
} catch (EMP_Exception empe) {
empe.printStackTrace();
}
break;
}
}
});
} catch (EMP_Exception e) {
Log.e(TAG, "addMapStateChangeEventListener", e);
}
try {
map.addMapInteractionEventListener(new IMapInteractionEventListener() {
@Override
public void onEvent(MapUserInteractionEvent mapUserInteractionEvent) {
Log.d(TAG, "mapUserInteractionEvent " + mapUserInteractionEvent.getPoint().x);
}
});
} catch (EMP_Exception e) {
Log.e(TAG, "addMapInteractionEventListener", e);
}

Button loopButton = (Button) findViewById(R.id.LoopButton);
if (loopButton != null) {
loopButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

Runnable remove = new Runnable() {
@Override
public void run() {
try

{
delayText = (EditText) findViewById(R.id.DelayText);
String delayStr = delayText.getText().toString();
final int delay = Integer.parseInt(delayStr);
for (int i = 0; i < 5; i++) {
map.removeMapService(wmsService);
Thread.sleep(delay);
map.addMapService(wmsService);
Thread.sleep(delay);
}
} catch (
Exception e)

{
e.printStackTrace();
}
}
};
Thread thread = new Thread(remove);
thread.start();
}
});
}

Button removeButton = (Button) findViewById(R.id.RemoveButton);
if (removeButton != null) {
removeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
map.removeMapService(wmsService);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

// Pressing OK sets the WMS server
// Only one WMS layer is displayed at a time
// Changing the server parameters replaces any
// previous server

Button okButton = (Button) findViewById(R.id.OKButton);
if (okButton != null)

{
okButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
if (wmsService == null) {
EditText urlText = (EditText) findViewById(R.id.UrlText);
EditText layerName = (EditText) findViewById(R.id.LayerText);
String url = urlText.getText().toString();
String version = versionText.getSelectedItem().toString();
WMSVersionEnum wmsVersion = WMSVersionEnum.valueOf(version);
String tileFormat = tileFormatText.getSelectedItem().toString();
boolean transparent = (transparentText.getSelectedItem().toString()).equals("true");
layer = layerName.getText().toString();
layers.add(layer);
wmsService = new WMS(url,
wmsVersion,
"image/png", // tile format
transparent,
layers);
wmsService.setLayerResolution(1.0);
}
map.addMapService(wmsService);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}
}

Loading

0 comments on commit d15aefb

Please sign in to comment.