Skip to content

Tschie/preplanned map #405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 64 commits into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
87664fd
download preplanned map sample
JonLavi Jun 28, 2019
348e199
refactoring
JonLavi Jul 2, 2019
6be1fd7
add ref to update parameters
JonLavi Jul 15, 2019
99beb85
method/enum name for update option
JonLavi Jul 16, 2019
e8ec679
method/enum name for update option
JonLavi Jul 16, 2019
bde5514
syntax
JonLavi Jul 16, 2019
7faeaa0
update runtime version, imports
JonLavi Jul 16, 2019
1e84a01
inner class to private
JonLavi Jul 17, 2019
c46cd60
add auth manager to handle OAuth challenge
JonLavi Jul 18, 2019
0df9efa
rebase to split dev branch
JonLavi Jul 18, 2019
3981033
mark portal as requires authentication
JonLavi Jul 19, 2019
1fca445
update README.md
JonLavi Jul 19, 2019
2ca56ec
add screenshot alt text
JonLavi Jul 19, 2019
b6d8093
update README.md
JonLavi Jul 19, 2019
b86a26e
update README.md
JonLavi Jul 19, 2019
f95a334
Merge branch 'download-preplanned-map-100-6' of github.com:Esri/arcgi…
JonLavi Jul 19, 2019
f36f1ae
update README.md for scheduled updates workflow
JonLavi Jul 22, 2019
3563dd7
update link to guide
JonLavi Jul 22, 2019
6e39b46
update README.md
JonLavi Jul 23, 2019
ef763a8
update use case
JonLavi Jul 23, 2019
fcfd895
improve 'how it works'
JonLavi Jul 23, 2019
8133e81
add preview of area of interest
JonLavi Jul 23, 2019
715a8db
improve drawing area of interest
JonLavi Jul 24, 2019
b6a3668
update use case wording, references in additional information
JonLavi Jul 24, 2019
e870890
fix deleting temp files, add button 'return to web map'
JonLavi Jul 24, 2019
c38d6e6
add numbering to list view
JonLavi Jul 24, 2019
db1a61f
zoom to area on select, refactoring
JonLavi Jul 25, 2019
af91b9e
update listener adding/removing
JonLavi Jul 25, 2019
894e6da
refactoring
JonLavi Jul 25, 2019
143919f
disable/enable showWebMapButton approprately
JonLavi Jul 25, 2019
d0dd8a3
add README.metadata.json
JonLavi Jul 26, 2019
00ecc61
fix function naming
JonLavi Jul 26, 2019
ede10fc
add confirmation popup when deleting
JonLavi Jul 26, 2019
0a18d9e
refactoring, use commons library to delete
JonLavi Jul 26, 2019
98cf949
fix commons-io dependency
JonLavi Jul 26, 2019
f211e0e
'show web map' button width
JonLavi Jul 26, 2019
5e2d63e
reorder imports
JonLavi Jul 26, 2019
cfb1396
improve viewpoint change, button updates
JonLavi Jul 26, 2019
4e36b22
smaller UI
JonLavi Jul 29, 2019
476920c
refactoring and comments
JonLavi Jul 29, 2019
1c4d497
javadoc comments and formatting
JonLavi Jul 29, 2019
58b1fa1
remove stray q file
JonLavi Jul 29, 2019
c603abc
address review corrections
JonLavi Jul 29, 2019
a5285fd
review changes and refactoring
JonLavi Jul 30, 2019
dd82287
refactoring
JonLavi Jul 30, 2019
23a9759
whitespace
JonLavi Jul 30, 2019
3dc75bb
web map -> online map
JonLavi Jul 30, 2019
3a26be6
further information -> additional information
JonLavi Aug 1, 2019
17d9e01
mmpk to class member
JonLavi Aug 2, 2019
eaf0920
change button text
JonLavi Aug 8, 2019
74320f1
selecting view online map pans to selected area
JonLavi Aug 8, 2019
7c3e233
formatting
JonLavi Aug 8, 2019
a741ce9
update README.md
JonLavi Aug 8, 2019
a1f5fff
copyright statements
JonLavi Aug 8, 2019
aa31ee7
remove commented code
JonLavi Aug 8, 2019
69fed73
try to simplify a bit
tschie Aug 9, 2019
ab29115
simplify sample
tschie Aug 13, 2019
1fca844
don't hide graphics overlay on download
tschie Aug 15, 2019
6994505
add snippet
tschie Aug 15, 2019
0e93886
update How to use the sample section
tschie Aug 15, 2019
2a98d9d
Update DownloadPreplannedMap.png
tschie Aug 15, 2019
98faa95
Slim up the use case
tschie Aug 15, 2019
6ca9bbc
remove fxml comments
tschie Aug 15, 2019
61f194b
remove redirect from for new sample
tschie Aug 15, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions map/download-preplanned-map/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Download a preplanned map area

Take a map offline using a preplanned map area.

![Download Preplanned Map Sample](DownloadPreplannedMap.png)

## Use case

When using the preplanned workflow, the author of the web map can set up offline packages for a map area ahead of time, which can then be distributed to end-users to view on their devices. Because the resources for the area are packaged once and can be downloaded many times by different users, this approach is faster and more scalable for large organizations when compared to an on-demand workflow (where each end-user requests a specific area that is then generated and delivered by a service). For example, this workflow could be used by survey workers operating in remote areas where network connectivity is not available. The workers could download preplanned mobile areas to their individual devices ahead of time and perform their work normally while disconnected.

## How to use the sample

**NOTE:** Downloading Tiles for offline use requires authentication with the web map's server. To use this sample, you will require an [ArcGIS Online](www.arcgis.com) account.

Select a map area, then click "Download Preplanned Area" to take it offline. When viewing a downloaded map area, click 'Show Online Map' to return to the online map. Click "Delete All Downloaded Areas" to remove any downloaded map areas.

## How it works

1. Open the `Map` from a `PortalItem` and display it.
2. Create an `OfflineMapTask` from the portal item.
3. Get the `PreplannedMapArea`s from the task, and then load them.
4. To download a selected map area, create the default `DownloadPreplannedOfflineMapParameters` from the task using the selected preplanned map area.
5. Set the update mode of the preplanned map area.
6. Use the parameters and a download path to create a `DownloadPreplannedOfflineMapJob` from the task.
7. Start the job. Once it has completed, get the `DownloadPreplannedOfflineMapResult`.
8. Get the `Map` from the result and display it in the `MapView`.

## Relevant API

* DownloadPreplannedOfflineMapJob
* DownloadPreplannedOfflineMapParameters
* DownloadPreplannedOfflineMapResult
* OfflineMapTask
* PreplannedMapArea

## About the data

The [Naperville stormwater network map](https://arcgisruntime.maps.arcgis.com/home/item.html?id=acc027394bc84c2fb04d1ed317aac674) is based on ArcGIS Solutions for Stormwater and provides a realistic depiction of a theoretical stormwater network.

## Additional information

`PreplannedUpdateMode` can be used to set the way the preplanned map area receives updates in several ways:

* `NO_UPDATES` - No updates will be performed.
* `SYNC_WITH_FEATURE_SERVICES` - Changes, including local edits, will be synced directly with the underlying feature services.
* `DOWNLOAD_SCHEDULED_UPDATES` - Scheduled, read-only updates will be downloaded from the online map area and applied to the local mobile geodatabases.

See [Take a map offline - preplanned](https://developers.arcgis.com/java/latest/guide/take-map-offline-preplanned.htm) to learn about preplanned workflows, including how to define preplanned areas in ArcGIS Online. Alternatively, visit [Take a map offline - on demand](https://developers.arcgis.com/java/latest/guide/take-map-offline-ondemand.htm) or refer to the sample 'Generate Offline Map' to learn about the on-demand workflow and see how the workflows differ.

## Tags

map area, offline, preplanned, pre-planned
29 changes: 29 additions & 0 deletions map/download-preplanned-map/README.metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"category": "Map",
"description": "Take a map offline using a preplanned map area.",
"ignore": false,
"images": [
"DownloadPreplannedMap.png"
],
"keywords": [
"map area",
"offline",
"preplanned",
"pre-planned"
],
"redirect_from": "/java/latest/sample-code/download-preplanned-map.htm",
"relevant_apis": [
"DownloadPreplannedOfflineMapJob",
"DownloadPreplannedOfflineMapParameters",
"DownloadPreplannedOfflineMapResult",
"OfflineMapTask",
"PreplannedMapArea"
],
"snippets": [
"src/main/java/com/esri/samples/download_preplanned_map/DownloadPreplannedMapController.java",
"src/main/java/com/esri/samples/download_preplanned_map/DownloadPreplannedMapSample.java",
"src/main/java/com/esri/samples/download_preplanned_map/PreplannedMapAreaListCell.java",
"src/main/resources/download_preplanned_map.fxml"
],
"title": "Download a Preplanned Map Area"
}
75 changes: 75 additions & 0 deletions map/download-preplanned-map/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
plugins {
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.5'
}

group = 'com.esri.samples'

ext {
arcgisVersion = '100.6.0-2490'
}

javafx {
version = "11.0.1"
modules = [ 'javafx.controls', 'javafx.fxml' ]
}

compileJava.options.encoding = 'UTF-8'

repositories {
jcenter()
maven {
url 'https://esri.bintray.com/arcgis'
}
maven {
url 'http://olympus.esri.com/artifactory/arcgisruntime-repo'
}
}

configurations {
natives
}

dependencies {
compile "com.esri.arcgisruntime:arcgis-java:$arcgisVersion"
natives "com.esri.arcgisruntime:arcgis-java-jnilibs:$arcgisVersion"
natives "com.esri.arcgisruntime:arcgis-java-resources:$arcgisVersion"
compile 'commons-io:commons-io:2.4'
}

task copyNatives(type: Copy) {
description = "Copies the arcgis native libraries into the project build directory for development."
group = "build"
configurations.natives.asFileTree.each {
from(zipTree(it))
}
// store native libraries in a common location shared with other samples
into "${System.properties.getProperty("user.home")}/.arcgis/$arcgisVersion"
}

run {
dependsOn copyNatives
mainClassName = 'com.esri.samples.download_preplanned_map.DownloadPreplannedMapLauncher'
}

jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes("Main-Class": "$mainClassName")
}
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
}

task productionZip(type: Zip) {
group = 'distribution'
from copyNatives
from jar.destinationDir
into (project.name)
baseName = project.name
}

wrapper {
gradleVersion = '5.0'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
172 changes: 172 additions & 0 deletions map/download-preplanned-map/gradlew
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
#!/usr/bin/env sh

##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn () {
echo "$*"
}

die () {
echo
echo "$*"
echo
exit 1
}

# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi

# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option

if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi

# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi

exec "$JAVACMD" "$@"
Loading