描述
Creates a checksum value from a list of values determined by an organization or specification requirements.
讨论
The checksum value is used to ensure the integrity of the data based on the Cyclic Redundancy Check 32Q (CRC32Q) logic. The checksum value originates when the data is digitized and is used to verify the data's validity as it is transferred to the aeronautical information service. The value generated by this function must match the expected result so the data can be considered reliable and uncorrupted. If the checksum value does not match the value in the data, the data is considered corrupted.
For Aeronautical Information Exchange Model (AIXM) data, the checksum value includes the latitude and longitude. However, the values included in the checksum can vary by organization and specification.
语法
GenerateCheckSum (input_string)
参数 | 说明 | 数据类型 |
input_string | The concatenated list of values from various fields for which the checksum will be generated. For example, the input string 0103039.3381E522942.8704N contains the concatenated value for the LAT_TXT and LONG_TXT fields. (默认值为 None) | String |
返回值
数据类型 | 说明 |
String | The concatenated list of values specified in the script as part of the checksum values. For example, if the latitude and longitude values are part of the checksum, they are returned as part of the string. |
代码示例
GenerateCheckSum example
This sample script generates checksum for a shapefile with ADHP points and reports whether they match the value in the database.
# Name: GenerateCheckSumExample.py
# Description: Generates the checksum values for ADHP features and prints
# report indicating whether they match the database value.
# Author: Esri
# Date: June 2014
# Import arcpyproduction and aviation modules
import arcpy
import arcpyproduction
# Check out Aviation license
arcpy.CheckOutExtension("Aeronautical")
# Define variables
worksp = "c:/data/ADHP_EC_CRC.shp"
fields = ['LAT_TXT','LONG_TXT', 'CRC_TXT', 'FID']
crcFld = 'CRC_TXT'
# For each row, print the CRC_TXT value
with arcpy.da.SearchCursor(worksp, fields) as cursor:
for row in cursor:
val = str(row[0] + row[1])
# print val
crcFldValue = str(row[2]).upper()
checksum = arcpyproduction.aviation.charting.GenerateCheckSum(val)
if (checksum.upper() == crcFldValue):
print("Checksum for feature {} matches".format(row[3]))
else:
print("Checksum for feature {} does not match.\n Db= {} || Calculated value = {}"
.format(row[3], row[2], checksum.upper()))
# Check in Aviation license
arcpy.CheckInExtension("Aeronautical")