-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show Line of Sight Between Geoelements (#217)
- Loading branch information
1 parent
107d0d0
commit 3a3dcaa
Showing
26 changed files
with
862 additions
and
0 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
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,35 @@ | ||
# Show line of sight between geoelements | ||
|
||
Show a line of sight between two moving objects. | ||
|
||
![Image of Show Line of Sight Between Geoelements](show-line-of-sight-between-geoelements.png) | ||
|
||
## Use case | ||
|
||
A line of sight between geoelements (i.e. observer and target) will not remain constant whilst one or both are on the move. | ||
|
||
A line of sight is therefore useful in cases where visibility between two geoelements requires monitoring over a period of time in a partially obstructed field of view (such as buildings in a city). | ||
|
||
## How to use the sample | ||
|
||
A line of sight will display between a point on the Empire State Building (observer) and a taxi (target). The taxi will drive around a block and the line of sight should automatically update. The taxi will be highlighted and blinking when it is visible. A red segment on the line means the view between observer and target is obstructed, whereas cyan means the view is unobstructed. You can change the observer height with the slider to see how it affects the target's visibility. | ||
|
||
## How it works | ||
|
||
1. Instantiate an `AnalysisOverlay` and add it to the `SceneView`'s analysis overlays collection. | ||
2. Instantiate a `GeoElementLineOfSight`, passing in observer and target `GeoElement`s (features or graphics). Add the line of sight to the analysis overlay's analysis collection. | ||
3. To get the target visibility when it changes, react to the target visibility changing on the `GeoElementLineOfSight` instance. | ||
|
||
## Relevant API | ||
|
||
* AnalysisOverlay | ||
* GeoElementLineOfSight | ||
* LineOfSight.TargetVisibility | ||
|
||
## Additional information | ||
|
||
This sample uses the GeoViewCompose Toolkit module to be able to implement a Composable SceneView. | ||
|
||
## Tags | ||
|
||
3D, geoviewcompose, line of sight, visibility, visibility analysis |
33 changes: 33 additions & 0 deletions
33
show-line-of-sight-between-geoelements/README.metadata.json
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,33 @@ | ||
{ | ||
"category": "Analysis", | ||
"description": "Show a line of sight between two moving objects.", | ||
"formal_name": "ShowLineOfSightBetweenGeoelements", | ||
"ignore": false, | ||
"images": [ | ||
"show-line-of-sight-between-geoelements.png" | ||
], | ||
"keywords": [ | ||
"3D", | ||
"geoviewcompose", | ||
"line of sight", | ||
"visibility", | ||
"visibility analysis", | ||
"AnalysisOverlay", | ||
"GeoElementLineOfSight", | ||
"LineOfSight.TargetVisibility" | ||
], | ||
"language": "kotlin", | ||
"redirect_from": "", | ||
"relevant_apis": [ | ||
"AnalysisOverlay", | ||
"GeoElementLineOfSight", | ||
"LineOfSight.TargetVisibility" | ||
], | ||
"snippets": [ | ||
"src/main/java/com/esri/arcgismaps/sample/showlineofsightbetweengeoelements/components/SceneViewModel.kt", | ||
"src/main/java/com/esri/arcgismaps/sample/showlineofsightbetweengeoelements/screens/MainScreen.kt", | ||
"src/main/java/com/esri/arcgismaps/sample/showlineofsightbetweengeoelements/DownloadActivity.kt", | ||
"src/main/java/com/esri/arcgismaps/sample/showlineofsightbetweengeoelements/MainActivity.kt" | ||
], | ||
"title": "Show line of sight between geoelements" | ||
} |
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,54 @@ | ||
plugins { | ||
id("com.android.application") | ||
id("org.jetbrains.kotlin.android") | ||
} | ||
|
||
android { | ||
compileSdk = libs.versions.compileSdk.get().toInt() | ||
|
||
defaultConfig { | ||
applicationId = "com.esri.arcgismaps.sample.showlineofsightbetweengeoelements" | ||
minSdk = libs.versions.minSdk.get().toInt() | ||
targetSdk = libs.versions.targetSdk.get().toInt() | ||
versionCode = libs.versions.versionCode.get().toInt() | ||
versionName = libs.versions.versionName.get() | ||
buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") | ||
} | ||
} | ||
|
||
buildFeatures { | ||
compose = true | ||
buildConfig = true | ||
} | ||
|
||
composeOptions { | ||
kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExt.get() | ||
} | ||
|
||
namespace = "com.esri.arcgismaps.sample.showlineofsightbetweengeoelements" | ||
} | ||
|
||
dependencies { | ||
// lib dependencies from rootProject build.gradle.kts | ||
implementation(libs.androidx.core.ktx) | ||
implementation(libs.androidx.lifecycle.runtime.ktx) | ||
implementation(libs.androidx.lifecycle.viewmodel.compose) | ||
implementation(libs.androidx.activity.compose) | ||
// Jetpack Compose Bill of Materials | ||
implementation(platform(libs.androidx.compose.bom)) | ||
// Jetpack Compose dependencies | ||
implementation(libs.androidx.compose.ui) | ||
implementation(libs.androidx.compose.material3) | ||
implementation(libs.androidx.compose.ui.tooling) | ||
implementation(libs.androidx.compose.ui.tooling.preview) | ||
implementation(project(":samples-lib")) | ||
// Toolkit dependencies | ||
implementation(platform(libs.arcgis.maps.kotlin.toolkit.bom)) | ||
implementation(libs.arcgis.maps.kotlin.toolkit.geoview.compose) | ||
} |
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,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle.kts. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# 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 |
Binary file added
BIN
+276 KB
show-line-of-sight-between-geoelements/show-line-of-sight-between-geoelements.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions
27
show-line-of-sight-between-geoelements/src/main/AndroidManifest.xml
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,27 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity | ||
android:exported="true" | ||
android:name=".DownloadActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:exported="true" | ||
android:name=".MainActivity"> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
20 changes: 20 additions & 0 deletions
20
...ain/java/com/esri/arcgismaps/sample/showlineofsightbetweengeoelements/DownloadActivity.kt
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,20 @@ | ||
package com.esri.arcgismaps.sample.showlineofsightbetweengeoelements | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import com.esri.arcgismaps.sample.sampleslib.DownloaderActivity | ||
|
||
class DownloadActivity : DownloaderActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
downloadAndStartSample( | ||
Intent(this, MainActivity::class.java), | ||
// get the app name of the sample | ||
getString(R.string.app_name), | ||
listOf( | ||
"https://www.arcgis.com/home/item.html?id=3af5cfec0fd24dac8d88aea679027cb9" | ||
) | ||
|
||
) | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...rc/main/java/com/esri/arcgismaps/sample/showlineofsightbetweengeoelements/MainActivity.kt
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,55 @@ | ||
/* Copyright 2024 Esri | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package com.esri.arcgismaps.sample.showlineofsightbetweengeoelements | ||
|
||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.runtime.Composable | ||
import com.arcgismaps.ApiKey | ||
import com.arcgismaps.ArcGISEnvironment | ||
import com.esri.arcgismaps.sample.sampleslib.theme.SampleAppTheme | ||
import com.esri.arcgismaps.sample.showlineofsightbetweengeoelements.screens.MainScreen | ||
|
||
class MainActivity : ComponentActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
// authentication with an API key or named user is | ||
// required to access basemaps and other location services | ||
ArcGISEnvironment.apiKey = ApiKey.create(BuildConfig.API_KEY) | ||
|
||
setContent { | ||
SampleAppTheme { | ||
SampleApp() | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
private fun SampleApp() { | ||
Surface( | ||
color = MaterialTheme.colorScheme.background | ||
) { | ||
MainScreen( | ||
sampleName = getString(R.string.app_name) | ||
) | ||
} | ||
} | ||
} |
Oops, something went wrong.