Skip to content

Commit 00784c4

Browse files
D-R-Smithjenmerritt
authored andcommitted
Add sample for custom dynamic entity data source (#799)
1 parent 14aff50 commit 00784c4

File tree

12 files changed

+9311
-0
lines changed

12 files changed

+9311
-0
lines changed
551 KB
Loading
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Add custom dynamic entity data source
2+
3+
Create a custom dynamic entity data source and display it using a dynamic entity layer.
4+
5+
![AddCustomDynamicEntityDataSource](AddCustomDynamicEntityDataSource.png)
6+
7+
## Use case
8+
9+
Developers can create a custom `DynamicEntityDataSource` to be able to visualize data from a variety of different feeds as dynamic
10+
entities using a `DynamicEntityLayer`. An example of this is in a mobile situational awareness app, where a custom
11+
`DynamicEntityDataSource` can be used to connect to peer-to-peer feeds in order to visualize real-time location tracks from
12+
teammates in the field.
13+
14+
## How to use the sample
15+
16+
Run the sample to view the map and the dynamic entity layer displaying the latest observation from the custom data source.
17+
18+
## How it works
19+
20+
Configure the custom data source:
21+
22+
1. Create a custom data source implementation of a `DynamicEntityDataSource`.
23+
2. Override `onLoadAsync()` to specify the `DynamicEntityDataSourceInfo` for a given unique entity ID field and a list of `Field` objects matching the fields in the data source.
24+
3. Override `onConnectAsync()` to begin processing observations from the custom data source.
25+
4. Loop through the observations and deserialize each observation into a `Geometry` object and a `Map<String, Object>` containing the attributes.
26+
5. Use `DynamicEntityDataSource.addObservation(geometry, attributes)` to add each observation to the custom data source.
27+
28+
Configure the map view:
29+
30+
1. Create a `DynamicEntityLayer` using the custom data source implementation.
31+
2. Update values in the layer's `TrackDisplayProperties` to customize the layer's appearance.
32+
3. Set up the layer's `LabelDefinitions` to display labels for each dynamic entity.
33+
34+
## Relevant API
35+
36+
* DynamicEntity
37+
* DynamicEntityDataSource
38+
* DynamicEntityLayer
39+
* LabelDefinition
40+
* TrackDisplayProperties
41+
42+
## About the data
43+
44+
This sample uses a [.json file containing observations of marine vessels in the Pacific North West](https://www.arcgis.com/home/item.html?id=a8a942c228af4fac96baa78ad60f511f)
45+
hosted on ArcGIS Online.
46+
47+
## Additional information
48+
49+
In this sample, we iterate through features in a GeoJSON file to mimic messages coming from a real-time feed. You can
50+
create a custom dynamic entity data source to process any data that contains observations which can be translated into
51+
`Geometry` objects with associated `Map<String, Object>` attributes.
52+
53+
## Tags
54+
55+
data, dynamic, entity, label, labeling, live, real-time, stream, track
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"category": "Real time",
3+
"description": "Create a custom dynamic entity data source and display it using a dynamic entity layer.",
4+
"ignore": false,
5+
"images": [
6+
"AddCustomDynamicEntityDataSource.png"
7+
],
8+
"keywords": [
9+
"data",
10+
"dynamic",
11+
"entity",
12+
"label",
13+
"labeling",
14+
"live",
15+
"real-time",
16+
"stream",
17+
"track",
18+
"DynamicEntity",
19+
"DynamicEntityDataSource",
20+
"DynamicEntityLayer",
21+
"LabelDefinition",
22+
"TrackDisplayProperties"
23+
],
24+
"redirect_from":"",
25+
"relevant_apis": [
26+
"DynamicEntity",
27+
"DynamicEntityDataSource",
28+
"DynamicEntityLayer",
29+
"LabelDefinition",
30+
"TrackDisplayProperties"
31+
],
32+
"snippets": [
33+
"src/main/java/com/esri/samples/add_custom_dynamic_entity_data_source/AddCustomDynamicEntityDataSourceSample.java",
34+
"src/main/java/com/esri/samples/add_custom_dynamic_entity_data_source/SimulatedDataSource.java"
35+
],
36+
"title": "Add custom dynamic entity data source"
37+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
plugins {
2+
id 'application'
3+
id 'org.openjfx.javafxplugin' // version is defined in settings.gradle
4+
}
5+
6+
group = 'com.esri.samples'
7+
8+
ext {
9+
arcgisVersion = '200.2.0-3955'
10+
}
11+
12+
javafx {
13+
version = "17.0.7"
14+
modules = [ 'javafx.controls', 'javafx.graphics', 'javafx.fxml', 'javafx.web', 'javafx.media' ]
15+
}
16+
17+
application {
18+
mainModule = "com.esri.samples.add_custom_dynamic_entity_data_source"
19+
mainClass = "com.esri.samples.add_custom_dynamic_entity_data_source.AddCustomDynamicEntityDataSourceSample"
20+
}
21+
22+
compileJava.options.encoding = 'UTF-8'
23+
24+
repositories {
25+
mavenCentral()
26+
maven {
27+
url 'https://esri.jfrog.io/artifactory/arcgis'
28+
}
29+
maven {
30+
url 'https://olympus.esri.com/artifactory/arcgisruntime-repo'
31+
}
32+
}
33+
34+
configurations {
35+
natives
36+
}
37+
38+
dependencies {
39+
implementation "com.esri.arcgisruntime:arcgis-java:$arcgisVersion"
40+
natives "com.esri.arcgisruntime:arcgis-java-jnilibs:$arcgisVersion"
41+
natives "com.esri.arcgisruntime:arcgis-java-resources:$arcgisVersion"
42+
// handle SLF4J http://www.slf4j.org/codes.html#StaticLoggerBinder
43+
implementation 'org.slf4j:slf4j-nop:2.0.7'
44+
implementation 'com.google.code.gson:gson:2.10.1'
45+
}
46+
47+
task createGradlePropertiesAndWriteApiKey {
48+
description = "Creates a new gradle.properties file with an empty API key variable in the user home ./gradle folder, if the file doesn't already exist."
49+
group = "build"
50+
def propertiesFile = new File("${System.properties.getProperty("user.home")}/.gradle/gradle.properties")
51+
if (!propertiesFile.exists()) {
52+
print("Go to " + new URL("https://developers.arcgis.com/dashboard") + " to get an API key.")
53+
print(" Add your API key to ${System.properties.getProperty("user.home")}\\.gradle\\gradle.properties.")
54+
propertiesFile.write("apiKey = ")
55+
}
56+
}
57+
58+
task copyNatives(type: Copy) {
59+
description = "Copies the arcgis native libraries into the project build directory for development."
60+
group = "build"
61+
configurations.natives.asFileTree.each {
62+
from(zipTree(it))
63+
}
64+
// store native libraries in a common location shared with other samples
65+
into "${System.properties.getProperty("user.home")}/.arcgis/$arcgisVersion"
66+
}
67+
68+
run {
69+
doFirst {
70+
// sets the API key from the gradle.properties file as a Java system property
71+
systemProperty 'apiKey', apiKey
72+
}
73+
dependsOn copyNatives
74+
}
75+
76+
task productionZip(type: Zip) {
77+
group = 'distribution'
78+
from copyNatives
79+
from jar.destinationDirectory
80+
into (project.name)
81+
archiveBaseName = project.name
82+
}
83+
84+
if (rootProject == project) {
85+
// the wrapper task is only used if this project is the root project i.e. not a subproject
86+
wrapper {
87+
gradleVersion = '8.1.1'
88+
}
89+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)