// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
require({cache:{"url:esri/dijit/ElevationProfile/templates/ElevationProfile.html":'\x3cdiv role\x3d"presentation" class\x3d"${baseClass}" data-dojo-attach-point\x3d"containerNode"\x3e\r\n    \x3cdiv data-dojo-attach-point\x3d"_chartNode" class\x3d"${baseClass}ChartNode"\x3e\x3c/div\x3e\r\n    \x3cdiv data-dojo-attach-point\x3d"_sourceNode" class\x3d"${baseClass}SourceLabel ${baseClass}Label"\x3e\x3c/div\x3e\r\n\t\x3cdiv data-dojo-attach-point\x3d"_directionButton" class\x3d"${baseClass}DirectionButton"\x3e\r\n\t\t\x3cspan data-dojo-attach-point\x3d"_directionButtonLabel" class\x3d"${baseClass}DirectionForward"\x3e\x3c/span\x3e\r\n\t\x3c/div\x3e    \r\n\t\x3cdiv data-dojo-attach-point\x3d"_elevationInfo" class\x3d"${baseClass}InfoNode"\x3e\r\n\t\t\x3cspan data-dojo-attach-point\x3d"_elevationInfoText" class\x3d"${baseClass}InfoText"\x3eText\x3c/span\x3e\r\n\t\x3c/div\x3e\r\n\x3c/div\x3e'}});
define("esri/dijit/ElevationProfile","dojo/on dojo/aspect dojo/_base/declare dojo/_base/lang dojo/_base/Deferred dojo/_base/array dojo/number dojo/dom-geometry dojo/dom-style dojo/dom-class dojo/query dojo/_base/Color dojo/colors dojo/fx/easing dijit/_WidgetBase dijit/_OnDijitClickMixin dijit/_TemplatedMixin dijit/_WidgetsInTemplateMixin dijit/registry dijit/Dialog dijit/Toolbar dijit/ToolbarSeparator dijit/layout/ContentPane dijit/form/Button dijit/form/ToggleButton ../config ../sniff ../request ./Measurement ../toolbars/draw ../tasks/Geoprocessor ../geometry/Polyline ../geometry/normalizeUtils ../symbols/SimpleLineSymbol ../symbols/SimpleMarkerSymbol ../graphic ../tasks/FeatureSet ../tasks/LinearUnit ../geometry/geodesicUtils ../geometry/webMercatorUtils ../units ./util/busyIndicator ./ElevationProfile/ProfileChart ./ElevationProfile/UnitsConversion dojo/i18n!./ElevationProfile/nls/strings dojo/text!./ElevationProfile/templates/ElevationProfile.html xstyle/css!./ElevationProfile/css/ElevationProfile.css".split(" "),
function(q,r,t,d,h,k,f,H,I,l,J,K,L,M,u,v,w,x,m,N,O,P,Q,R,S,T,U,y,V,W,z,X,A,Y,Z,B,C,aa,n,p,c,D,E,F,e,G){return t([u,v,w,x],{declaredClass:"esri.dijit.ElevationProfile",baseClass:"esriElevationProfile",templateString:G,_samplingPointCount:199,_profileResults:null,_currentGeometry:null,_map:null,_measureTool:null,_drawToolbar:null,_profileService:null,_profileServiceUrl:null,_profileTaskUrl:null,_scalebarUnits:null,_profileChart:null,_chartOptions:null,_busyIndicator:null,_profileDirection:"forward",
constructor:function(a,b){a.hasOwnProperty("map")&&(this._map=a.map);a.hasOwnProperty("profileTaskUrl")&&(this._profileTaskUrl=a.profileTaskUrl);a.hasOwnProperty("scalebarUnits")&&(this._scalebarUnits=a.scalebarUnits);a.hasOwnProperty("chartOptions")?this._chartOptions=a.chartOptions:this._chartOptions={};a.hasOwnProperty("profileDirection")&&(this._profileDirection=a.profileDirection);this._profileServiceUrl=d.replace("{_profileTaskUrl}/Profile",this)},postCreate:function(){this.inherited(arguments);
null!==m.getEnclosingWidget(this.domNode)&&this.own(r.after(m.getEnclosingWidget(this.domNode),"resize",d.hitch(this,this.resize),!0));var a={target:this._chartNode,imageUrl:this._chartOptions.hasOwnProperty("busyIndicatorImageUrl")?this._chartOptions.busyIndicatorImageUrl:void 0,backgroundColor:this._chartOptions.hasOwnProperty("busyIndicatorBackgroundColor")?this._chartOptions.busyIndicatorBackgroundColor:void 0,backgroundOpacity:this._chartOptions.hasOwnProperty("busyIndicatorBackgroundOpacity")?
this._chartOptions.busyIndicatorBackgroundOpacity:void 0,fadeDuration:this._chartOptions.hasOwnProperty("busyIndicatorFadeDuration")?this._chartOptions.busyIndicatorFadeDuration:void 0};this._busyIndicator=D.create(a);this._chartOptions.hasOwnProperty("sourceTextColor")&&(this._sourceNode.style.color=this._chartOptions.sourceTextColor);this._setDisabledDirectionButton(!0);if(void 0===this._profileDirection||null===this._profileDirection)this._profileDirection="forward",this._setProfileDirection(this._profileDirection)},
startup:function(){this.inherited(arguments);if(this._map&&this._profileTaskUrl&&this._scalebarUnits)if(this._map.loaded)this._initUI();else this._map.on("load",d.hitch(this,this._initUI));else this.emit("error",Error(e.errors.MissingConstructorParameters)),this.destroy()},_initListeners:function(){this.own(q(this._directionButton,"click",d.hitch(this,this._directionButtonClicked)))},_initUI:function(){this._initListeners();this._initProfileService().then(d.hitch(this,function(){var a=this._getElevationDistanceUnits(this._scalebarUnits),
b=(new F).getAbbrLabel(a.elevationUnits);this._profileChart=new E({map:this._map,elevationUnits:a.elevationUnits,distanceUnits:a.distanceUnits,chartOptions:this._chartOptions},this._chartNode);this._profileChart.on("aggregate-elevation-values",d.hitch(this,function(a){this._elevationInfoText.innerHTML=d.replace("{0}\x3cbr /\x3e{1} {8}\x3cbr /\x3e{2}\x3cbr /\x3e{3} {8}\x3cbr /\x3e{4}\x3cbr /\x3e{5} {8}\x3cbr /\x3e{6}\x3cbr /\x3e{7} {8}",[e.buttons.aggregateElevationGainForward,f.format(a.aggregateElevationGainForward,
{places:2}),e.buttons.aggregateElevationLossForward,f.format(a.aggregateElevationLossForward,{places:2}),e.buttons.aggregateElevationGainReverse,f.format(a.aggregateElevationGainReverse,{places:2}),e.buttons.aggregateElevationLossReverse,f.format(a.aggregateElevationLossReverse,{places:2}),b]);this.emit("elevation-values",a)}));this._profileChart.startup();this.emit("load");this._createTooltip()}),d.hitch(this,function(){this.emit("error",Error(e.errors.InvalidConfiguration));this.destroy()}))},_initProfileService:function(){var a=
new h;this._profileServiceUrl?y({url:this._profileServiceUrl,content:{f:"json"},callbackParamName:"callback"}).then(d.hitch(this,function(b){this._profileService=new z(this._profileServiceUrl);this._profileService.setNormalization(!1);this._profileService.setOutSpatialReference(this._map.spatialReference);a.resolve()}),d.hitch(this,function(b){a.reject(b)})):a.reject(Error(e.errors.InvalidConfiguration));return a.promise},_directionButtonClicked:function(a){this._profileDirection="forward"===this._profileDirection?
"reverse":"forward";this._setProfileDirection(this._profileDirection);this._createTooltip();this._currentGeometry&&(this._currentGeometry.paths[0].reverse(),this._updateProfile(this._currentGeometry))},_setProfileDirection:function(a){this._profileDirection=(a="forward"===a)?"forward":"reverse";l.toggle(this._directionButtonLabel,"esriElevationProfileDirectionReverse",!a);l.toggle(this._directionButtonLabel,"esriElevationProfileDirectionForward",a)},_setProfileGeometryAttr:function(a){a&&(this._set("_currentGeometry",
a),"reverse"===this._profileDirection&&this._currentGeometry.paths[0].reverse(),this._updateProfile(a))},_getProfileDirectionAttr:function(){return this._profileDirection},_setProfileDirectionAttr:function(a){this._set("_profileDirection",a);this._setProfileDirection(a);this._currentGeometry&&(this._currentGeometry.paths[0].reverse(),this._updateProfile(this._currentGeometry),this.emit("profile-direction-changed"))},_updateProfile:function(a){a?(this._busyIndicator.show(),this._getProfile(a).then(d.hitch(this,
function(a){this._busyIndicator.hide();this._setDisabledDirectionButton(!1);this._profileChart.update(a);this.emit("update-profile",a)}),d.hitch(this,function(a){this._busyIndicator.hide();this._setDisabledDirectionButton(!0);this.emit("error",a)}))):this.emit("error",Error(e.errors.NullGeometry))},_setTitleAttr:function(a){this._profileChart.set("Title",a);this.emit("title-changed")},clearProfile:function(){this._profileChart.clear();this._setDisabledDirectionButton(!0);this._setProfileDirection("forward");
this.emit("clear-profile")},_setMeasureUnitsAttr:function(a){a=this._getElevationDistanceUnits(a);this._profileChart.set("DisplayUnits",{elevationUnits:a.elevationUnits,distanceUnits:a.distanceUnits});this._profileChart.refresh()},_getElevationDistanceUnits:function(a){var b;switch(a){case c.NAUTICAL_MILES:a=c.FEET;b=c.NAUTICAL_MILES;break;case c.MILES:a=c.FEET;b=c.MILES;break;case c.YARDS:a=c.FEET;b=c.YARDS;break;case c.FEET:b=a=c.FEET;break;case c.KILOMETERS:a=c.METERS;b=c.KILOMETERS;break;case c.METERS:b=
a=c.METERS;break;default:a=this._profileChart.elevationUnits,b=this._profileChart.distanceUnits}return{elevationUnits:a,distanceUnits:b}},_hasZsAndMs:function(a){return a&&"polyline"===a.type?4===a.paths[0][0].length:!1},_normalizeGeometry:function(a){var b=new h;A.normalizeCentralMeridian([a]).then(function(a){b.resolve(a[0])},function(){b.reject(Error(e.errors.UnableToNormalizeGeometry))});return b.promise},_densifyGeometry:function(a){a=a.spatialReference.isWebMercator?p.webMercatorToGeographic(a):
a;return n.geodesicDensify(a,1E6)},_getProfile:function(a){var b=new h;if(this._hasZsAndMs(a))b.resolve({geometry:a,elevations:[],distances:[],samplingDistance:f});else{var g=a.spatialReference.isWebMercator()?p.webMercatorToGeographic(a):a,f=n.geodesicLengths([g],c.METERS)[0]/this._samplingPointCount;a=new B(a,null,{OID:1});g=new C;g.features=[a];g.fields=[{name:"OID",type:"esriFieldTypeObjectID",alias:"OID"}];this._profileService.execute({InputLineFeatures:g,ProfileIDField:"OID",DEMResolution:"FINEST",
MaximumSampleDistance:f,MaximumSampleDistanceUnits:"Meters",returnZ:!0,returnM:!0}).then(d.hitch(this,function(a){if(0<a.length)if(a=a[0].value,0<a.features.length){a=a.features[0];this._sourceNode.innerHTML=d.replace("{0}: {1}",[e.chart.demResolution,a.attributes.DEMResolution]);a=a.geometry;var c=[],g=[];0<a.paths.length?(k.forEach(a.paths,function(a,b){k.forEach(a,function(a,d){var e={x:3<a.length?a[3]:d*f,y:2<a.length?a[2]:0,pathIdx:b,pointIdx:d};c.push(e);g.push(e.x)},this)},this),b.resolve({geometry:a,
elevations:c,distances:g,samplingDistance:f})):b.reject(Error(this.strings.errors.UnableToProcessResults))}else b.reject(Error(this.strings.errors.UnableToProcessResults));else b.reject(Error(this.strings.errors.UnableToProcessResults))}),b.reject)}return b.promise},_createTooltip:function(){var a;a=e.buttons;a=d.replace("{directionLabel}: {direction} \n{profileTitle}",{directionLabel:e.display.directionLabel,direction:"forward"===this._profileDirection?a.profileForward:a.profileReverse,profileTitle:a.flipProfileTitle});
this._directionButton.setAttribute("title",a)},_setDisabledDirectionButton:function(a){this._directionButton.style.pointerEvents=a?"none":"auto";this._elevationInfo.style.visibility=a?"hidden":"visible"},resize:function(){this.inherited(arguments);this._profileChart&&this._profileChart.resize()},destroy:function(){this.inherited(arguments);this._profileChart&&this._profileChart.destroy()}})});