# Name: GenerateCPs_Pro_standalone_fs.py
# Description: Build calibration point features in an existing feature service.
# Requires: ArcGIS Location Referencing
# Import arcpy module
import arcpy
# Check out license
arcpy.CheckOutExtension("LocationReferencing"
# Local variables:
in_polyline_features = r"C:\Data\SourceData.gdb\LRS\SourceRoutes"
route_id_field = "RouteID"
from_date_field = "FromDate"
to_date_field = "ToDate"
in_calibration_point_feature_class = r"https://yourdomain.com/server/rest/services/FeatureServiceName/FeatureServer/1"
calibration_direction = "MEASURE_DIRECTION"
calibration_method = "GEOMETRY_LENGTH"
# Input LRS route network is in feature service. Signing in portal is required to access the feature service.
arcpy.SignInToPortal('https://yourdomain.com/portal', 'username', 'password')
# Map the calibration point layer from the feature service. Here, 5 corresponds to the calibration point layer.
lrs_network = r"https://yourdomain.com/server/rest/services/FeatureServiceName/FeatureServer/1"
# Execute the tool
arcpy.locref.GenerateCalibrationPoints(in_calibration_point_feature_class)
# Process: Generate Calibration Points
arcpy.locref.GenerateCalibrationPoints(in_polyline_features, route_id_field, from_date_field,
to_date_field, in_calibration_point_feature_class,
lrs_network, calibration_direction, calibration_method)
## Check in license
arcpy.CheckInExtension('LocationReferencing')