-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
#24 test issue #232
- Loading branch information
Showing
23 changed files
with
453 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
208 changes: 208 additions & 0 deletions
208
example-wmstest/src/main/java/mil/emp3/examples/wmstest/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.