-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca0272a
commit 32492dc
Showing
14 changed files
with
123 additions
and
9 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
34 changes: 31 additions & 3 deletions
34
docs/upgrading-dictionary-styles-from-a-previous-version.md
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 |
---|---|---|
@@ -1,14 +1,42 @@ | ||
# Upgrading dictionary styles from a previous version | ||
|
||
## Versions | ||
This toolkit defines how to create a dictionary of version `3.0.0`. [A previous version of the toolkit](https://github.com/Esri/dictionary-renderer-toolkit/tree/release/2.0.0), documented version `2.0.0` and we recommend upgrading dictionary styles to the `3.0.0` specification for full compatibility with the web styles and the ArcGIS API for JavaScript. | ||
We recommend dictionaries versions of `3.0.0` or `4.0.0` for full compatibility with the web styles and the ArcGIS Maps SDK for JavaScript. Both dictionary versions are fully compatible with those specification. Version `4.0.0` has additional functionality for supporting native data types without converting the values to strings. See [Working with different field types](docs/working-with-different-field-types.md) for additional details. | ||
|
||
## Upgrading the style | ||
Version `2.0.0` dictionaries cannot be shared as web styles and are not compatible with the ArcGIS Maps SDK for JavaScript. It is highly recommended to upgrade these dictionaries. | ||
|
||
|
||
| Dictionary Version | Version Notes | ArcGIS Pro | ArcGIS Runtime SDK | ArcGIS Maps SDK for JavaScript | Branch | | ||
| ------------------ | ----- | ---------- | ------------------ | ------------- |------------------ | | ||
|4.0.0 | Support for native data types | Pro 3.2 or higher | 200.2 or higher | 4.27 or higher | master | | ||
|3.0.0 | Usage of $feature and $config to be more Arcade compliant | Pro 3.0 or higher | 100.7 or higher | 4.13 or higher | [release/3.0.0](https://github.com/Esri/dictionary-renderer-toolkit/tree/release/3.0.0)| | ||
|2.0.0 | Initial version |Pro 2.4 | 100.6 | NA | [release/2.0.0](https://github.com/Esri/dictionary-renderer-toolkit/tree/release/2.0.0)| | ||
|
||
## Upgrading 3.0.0 to 4.0.0 | ||
Upgrading the dictionary to version `4.0.0` is optional but does offer more control over the functionality of the operators used in the script because the native data types are preserved. | ||
|
||
1. The first change is that the value of key `dictionary_version` in the `meta` table must be changed from `3.0.0` to `4.0.0`. | ||
|
||
2. Depending on the operators used in the script it may be necessary to make adjustments in the script. Comparison operators, like == and !=, always consider different data types as not equal. If these are used in the script they will need to be adjusted. | ||
|
||
An example of this can be seen in the [Park Amenities](../dictionary_examples/Park_Amenities) dictionary. | ||
In the script, icons are shown for the different amenities by checking if the attribute value does not equal zero. The != operator is used for this comparison. To upgrade to `4.0.0` it is necessary to remove the single quotes or the comparison will fail and symbols will unexpectedly draw. | ||
|
||
In `3.0.0` the script would be | ||
`if ($feature.TENNIS != '0')` which is an explicit string comparison. | ||
|
||
In `4.0.0` the script would be | ||
`if ($feature.TENNIS != 0)` which is a number comparison. | ||
|
||
If you are working with a custom dictionary that is based on the Joint Military Symbology or NATO Joint Military Symbology specifications the best way to identify changes that are needed in the script is to compare your custom script to the `4.0.0` versions of the dictionaries available from ArcGIS Online. The `4.0.0` script is more robust for different database schemes; however, the logic of the military specifications requires the symbol ID codes to be considered as string. Modifications were made to ensure the database is properly converted to what the script requires. | ||
|
||
|
||
## Upgrading 2.0.0 to 3.0.0 | ||
|
||
Upgrading the dictionary requires two steps and are typically done with manual edits of the SQLite database: | ||
|
||
1. The first change that must be made is that the Arcade script value stored in the style `meta` table key `dictionary_script` must be updated to reflect input parameters being passed in using `$feature` and `$config`. Previously, field values were passed in as `$fieldname` and a configuration values were passed in as `$configurationentryname`. In `3.0.0` dictionaries, all feature values are passed in via a `$feature` feature object and configuration values are passed in with a `$config` dictionary. So, the above example would be passed in now as `$feature.fieldname` and `$config.configurationentryname`. For the mil2525d dictionary, an example of this change would be `$sidc` changing to `$feature.sidc` and `$frame` changing to `$config.frame`. | ||
|
||
1. The final change is that the value of key `dictionary_version` in the `meta` table must be changed from `2.0.0` to `3.0.0`. | ||
|
||
Once the above steps are complete and your SQLite database is saved, your dictionary is upgraded. | ||
Once the above steps are complete and your SQLite database is saved, your dictionary is upgraded. |
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,63 @@ | ||
# Working with different field types | ||
|
||
Before version `4.0.0`, the values for all attribute fields used in the dictionary were converted to string values regardless of the field type. In version `4.0.0` of the dictionary, Arcade will receive the native data type of the attribute field which will give more control over the functionality of the operators used in the script. Honoring the native data types ensures that numbers, dates, and times are not impacted by localization and formatting changes the way string values are. | ||
|
||
The `3.0.0` version of the dictionary is still supported. For dictionaries that consume string values or use Arcade operators that require strings there is no need to upgrade the dictionary. For steps for upgrading `3.0.0` dictionaries see [Upgrading dictionary styles from a previous version](docs/upgrading-dictionary-styles-from-a-previous-version.md). | ||
|
||
## Numeric field example | ||
|
||
The results for numeric data types may be different for some Arcade operators depending on if the values are received as the true numeric type or converted to string. For additional information see the [implicit casting rules](https://developers.arcgis.com/arcade/guide/type-casting/#implicit-casting) from Arcade. | ||
|
||
An example of this can be seen in the [Park Amenities](../dictionary_examples/Park_Amenities) dictionary with the configuration to show the count for the number of sport facilities. | ||
|
||
In the script, there is a configuration option to show a count for the number of sport fields and courts available for the public at each park. The count is derived by adding together the values in multiple numeric attribute fields. | ||
|
||
``` | ||
// Show sport facility count | ||
if (_show_sportfacilitycount) { | ||
var count = $feature.SOCCFOOT + $feature.BASKETBALL + $feature.BASEBALL + $feature.SOFTBALL + $feature.TENNIS; | ||
keys += ';sport_count_label'; | ||
keys += ';po:sport_facility_count|TextString|'; | ||
keys += 'Sport facilities: ' + count; | ||
``` | ||
|
||
If numeric data values are converted to strings in the script and then used by the + operator, adding the values for the different sports facilities will result in the values being concatenated because the operator arguments are strings. | ||
|
||
![sport facility string](images/sportfacilitystring.PNG) | ||
|
||
|
||
However, when the numeric data type is maintained as a number the values are summed. See [arithmetic statements](https://developers.arcgis.com/arcade/guide/type-casting/#arithmetic-statements) for details about the + operator and other arithmetic operators. | ||
|
||
![sport facility numeric](images/sportfacilitynumeric.PNG) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
## Date field example | ||
|
||
With a 3.0.0 dictionary, ArcGISPro will format date/time as a string like this (as seen in the Attribute Table). | ||
|
||
10/13/2023 10:12:00 PM | ||
|
||
This format doesn't convert easily to a date/time value in Arcade. As a result, it can be difficult to incorporate date/time fields in the script for anything more than labels. | ||
|
||
A 4.0.0 dictionary will receive native date fields, which can be used with the [date functions](https://developers.arcgis.com/arcade/function-reference/date_functions/) Arcade operators directly. | ||
|
||
An example of this can be seen with the [Service Calls](../dictionary_examples/Service_Calls) dictionary where the DateDiff operator is used to flag calls with a long wait time between when a call is received and when the call is dispatched. | ||
|
||
The data has two date fields, one for when the call is received and one for when the call is dispatched. The differences between these two fields can be compared in the identified units. Calls that are dispatched more than 4 hours after they are received are flagged with an additional icon. | ||
|
||
``` | ||
if (DateDiff($feature.DispatchTime, $feature.CallTime, 'hours')>4){ | ||
keys += ';WARNING'; | ||
``` | ||
|
||
![service call date comp](images/servicecalldatecomp.png) | ||
|
||
If you need a string representation of the date/time, Arcade has more options to format the value to accommodate the rendering needs. See [text_functions](https://developers.arcgis.com/arcade/function-reference/text_functions/#text) for details. | ||
|
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