public ErroneousTrack(ISession session, IntPtr handle, Error error, IPlaylist playlist = null) : base(session, handle) { _error = error; _playlist = playlist; _artists = new DelegateArray<IArtist>(() => 0, index => null); }
public static string[] GetFiles(string path) { var list = new IArray(); if (Native.API.is_readable(path)) { object h = Native.API.opendir(path); object p = Native.API.readdir(h); while ((bool)p) { var ps = (string)p; if (ps != ".") if (ps != "..") { string npath = Path.Combine(path, ps); if (Native.API.is_file(npath)) if (Native.API.is_readable(npath)) { list.Push(npath); } } p = Native.API.readdir(h); } Native.API.closedir(h); } return (string[])(object)list; }
public frmUpstreamCreateOwnerList(MainFrm _pMainFrm,IFeatureLayer _pParcelFeatLayer, IArray _pFeatArray) { pParcelFeatLayer = _pParcelFeatLayer; pFeatArray = _pFeatArray; pMainFrm = _pMainFrm; InitializeComponent(); }
protected virtual IArray VisitArray(IArray node) { for (int i = 0, c = node.Items.Count; i < c; i++) { var item = node.Items[i]; this.Visit(item); } return node; }
public frmBurstReport(MainFrm _pMainFrm, IFeatureLayer _pFeatLayerValves, IFeatureLayer _pFeatLayerWaterLines, IArray _pArrayValves, IFeature _pFeatureWaterLine) { pMainFrm = _pMainFrm; pFeatLayerValves = _pFeatLayerValves; pFeatLayerWaterLines = _pFeatLayerWaterLines; pArrayValves = _pArrayValves; pFeatureWaterLine = _pFeatureWaterLine; InitializeComponent(); }
/// <summary> /// Создание фрейма из "сырых" данных. /// </summary> /// <param name = "data">Данные.</param> /// <returns>Ethernet-фрейм, совпадающий с данными, указанными в <paramref name = "data" />.</returns> /// <remarks> /// Для корректного создания длина данных не должна быть меньше 14 байт. /// </remarks> /// <exception cref = "ArgumentNullException"><paramref name = "data" /> является <c>null</c>.</exception> /// <exception cref = "IncorrectPacketLengthException"><paramref name = "data" /> имеет неверную длину.</exception> public static EthernetFrame Parse(IArray <byte> data) { if (data == null) throw new ArgumentNullException ("data"); if (data.Length < 14) throw new IncorrectPacketLengthException (Strings.EthernetFrame); return new EthernetFrame (data); }
private void Print(string arrayName, IArray<double> array) { Console.WriteLine(arrayName + ":"); for (int i = 0; i < array.Size0; i++) { for (int j = 0; j < array.Size1; j++) { Console.Write(array[i,j] + " "); } Console.WriteLine(); } }
/// <summary> /// Инициализация ARP-пакета. /// </summary> /// <param name = "htype">Канальный уровень (тип).</param> /// <param name = "ptype">Сетевой уровень (тип).</param> /// <param name = "oper">Операция ARP.</param> /// <param name = "sha">Канальный адрес источника.</param> /// <param name = "spa">Сетевой адрес источника.</param> /// <param name = "tha">Канальный адрес назначения.</param> /// <param name = "tpa">Сетевой адрес назначения.</param> /// <exception cref = "ArgumentNullException"><paramref name = "sha" /> является <c>null</c>.</exception> /// <exception cref = "ArgumentNullException"><paramref name = "spa" /> является <c>null</c>.</exception> /// <exception cref = "ArgumentNullException"><paramref name = "tha" /> является <c>null</c>.</exception> /// <exception cref = "ArgumentNullException"><paramref name = "tpa" /> является <c>null</c>.</exception> /// <exception cref = "IncorrectFieldLengthException"><paramref name = "sha" /> имеет недопустимую длину.</exception> /// <exception cref = "IncorrectFieldLengthException"><paramref name = "spa" /> имеет недопустимую длину.</exception> /// <exception cref = "IncorrectFieldLengthException"><paramref name = "tha" /> имеет недопустимую длину.</exception> /// <exception cref = "IncorrectFieldLengthException"><paramref name = "tpa" /> имеет недопустимую длину.</exception> public ARPPacket(HardwareType htype, L3ProtocolType ptype, ARPOperation oper, IArray <byte> sha, IArray <byte> spa, IArray <byte> tha, IArray <byte> tpa) { var hlen = FieldLengthAttribute.GetLength (htype); var plen = FieldLengthAttribute.GetLength (ptype); if (sha == null) throw new ArgumentNullException ("sha"); if (spa == null) throw new ArgumentNullException ("spa"); if (tha == null) throw new ArgumentNullException ("tha"); if (tpa == null) throw new ArgumentNullException ("tpa"); if (sha.Length != hlen) throw new IncorrectFieldLengthException ("SHA", sha.Length, hlen); if (spa.Length != plen) throw new IncorrectFieldLengthException ("SPA", spa.Length, plen); if (tha.Length != hlen) throw new IncorrectFieldLengthException ("THA", sha.Length, hlen); if (tpa.Length != plen) throw new IncorrectFieldLengthException ("TPA", spa.Length, plen); this.Data = new Array <byte> (new byte[8 + sha.Length + spa.Length + tha.Length + tpa.Length]); this.HardwareType = htype; this.ProtocolType = ptype; this.HardwareLength = hlen; this.ProtocolLength = plen; this.Operation = oper; this.SenderHardwareAddress = sha; this.SenderProtocolAddress = spa; this.TargetHardwareAddress = tha; this.TargetProtocolAddress = tpa; }
public static int FindParameter(IArray netAttributeParams, string searchName) { if (netAttributeParams == null || searchName.Length <= 0) return -1; string compareName; INetworkAttributeParameter netAttributeParam; int count = netAttributeParams.Count; for (int i = 0; i < count; ++i) { netAttributeParam = netAttributeParams.get_Element(i) as INetworkAttributeParameter; if (netAttributeParam != null) { compareName = netAttributeParam.Name; if (String.Compare(searchName, compareName, true) == 0) return i; } } return -1; }
/// <summary> /// will not behave with unicode BOM mark /// </summary> /// <param name="content"></param> public Properties(string content) { IArray<int, string> a = IArray.Split(content, "\n"); IArray<string, string> i = new IArray<string, string>(); foreach (string v in a.ToArray()) { string z = v.Trim(); bool b = !z.StartsWith("#"); if (b) if (z.Length > 0) { IArray<int, string> x = IArray.Split(z, "="); //Native.Dump(z + " : " + x.Length, x); if (x.Length == 2) { //Native.Message("ok"); string key = x[0]; string val = x[1]; i[key] = val; } } } Items = i; }
//////////////////////////////////�����������ǰ���ý����С�� public static void ProfileSetJunctionFlag(AxMapControl ppAxMapControl, ref IArray pNetFlagArray, IPoint pPoint, IGeometricNetwork pGeoNetwork) { try { //�����ͼ��ѡ�� ppAxMapControl.ActiveView.FocusMap.ClearSelection(); INetElements pNetElements = pGeoNetwork.Network as INetElements; IPointToEID pPtToEID = new PointToEIDClass(); int pJunctionID = 0; int iUserClassID; int iUserID; int iUserSubID; IPoint pLocation; pPtToEID.SourceMap = ppAxMapControl.ActiveView.FocusMap; pPtToEID.GeometricNetwork = pGeoNetwork; pPtToEID.SnapTolerance = ppAxMapControl.ActiveView.Extent.Envelope.Width / 100; pPtToEID.GetNearestJunction(pPoint, out pJunctionID, out pLocation); if (pJunctionID == 0) { MessageBox.Show("û�в������ٽ��ĵ�"); } else { pNetElements.QueryIDs(pJunctionID, esriElementType.esriETJunction, out iUserClassID, out iUserID, out iUserSubID); INetFlag ipNetFlag = new JunctionFlagClass(); ipNetFlag.UserClassID = iUserClassID; ipNetFlag.UserID = iUserID; ipNetFlag.UserSubID = iUserSubID; IMarkerSymbol pMarkerSym = new SimpleMarkerSymbolClass(); IRgbColor pRGBColor = new RgbColorClass(); pRGBColor.Red = 255; pRGBColor.Green = 0; pRGBColor.Blue = 0; pMarkerSym.Color = pRGBColor; pMarkerSym.Size = 20; //���Ƹõ� IScreenDisplay pScreenDisplay = ppAxMapControl.ActiveView.ScreenDisplay; pScreenDisplay.StartDrawing(pScreenDisplay.hDC, 0); pScreenDisplay.SetSymbol(pMarkerSym as ISymbol); pScreenDisplay.DrawPoint(pLocation); pScreenDisplay.FinishDrawing(); if (pLocation != null) { pNetFlagArray.Add(ipNetFlag); } if (pNetFlagArray.Count == 2) { //�����ٽ�� ProfileFindPath(ppAxMapControl, pNetFlagArray, pGeoNetwork); } } } catch (Exception eX) { MessageBox.Show(eX.Message); } }
public static double Average(this IArray <double> self) { return(self.Sum() / self.Count); }
public static double Variance(this IArray <double> self) { var mean = self.Average(); return(self.Select(x => (x - mean).Sqr()).Average()); }
public static double StdDev(this IArray <double> self) { return(self.Variance().Sqrt()); }
public static IArray <Vector4> Truncate(this IArray <Vector4> self) { return(self.Select(MathOps.Truncate)); }
//////////////////////////////////////////////////////////////////////// // METHOD: PopulateAOIListUsingParent private bool PopulateAOIListUsingParent(IJTXJob2 pParentJob, ref IArray aoiList, int numCopies) { try { aoiList = new ArrayClass(); for (int i = 0; i < numCopies; i++) { aoiList.Add(pParentJob.AOIExtent); } } catch (Exception ex) { throw new Exception("Unable to create AOIs based on parent job's AOI: " + ex.Message); } return true; }
public IGPMessages Validate(IArray paramvalues, bool updateValues, IGPEnvironmentManager envMgr) { return null; }
public static IArray <int> Mul(this int self, IArray <int> vector) { return(vector.Select(x => self.Multiply(x))); }
public static IArray <int> Mul(this IArray <int> self, int scalar) { return(self.Select(x => x.Multiply(scalar))); }
public static IArray <int> Add(this int self, IArray <int> vector) { return(vector.Select(x => self.Add(x))); }
public static IArray <int> Add(this IArray <int> self, int scalar) { return(self.Select(x => x.Add(scalar))); }
public static IArray <Vector4> PartialSums(this IArray <Vector4> self) { return(self.Accumulate((x, y) => x + y)); }
public static Vector4 StdDev(this IArray <Vector4> self) { return(self.Variance().Sqrt()); }
/* Source: http://www.ibiblio.org/e-notes/webgl/models/ethanol.html * http://www.worldofmolecules.com/3D/dopamine_3d.htm */ /// <summary> /// This is a javascript application. /// </summary> /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param> public Application(IDefault page = null) { var prMatrix = new CanvasMatrix4(); var gl_viewportWidth = 500; var gl_viewportHeight = 500; var gl = new WebGLRenderingContext(); var canvas = gl.canvas.AttachToDocument(); #region AtResize Action AtResize = delegate { gl_viewportWidth = Native.window.Width; gl_viewportHeight = Native.window.Height; prMatrix = new CanvasMatrix4(); prMatrix.perspective(45f, (f)Native.window.aspect, 1f, 100f); canvas.style.SetLocation(0, 0, gl_viewportWidth, gl_viewportHeight); canvas.width = gl_viewportWidth; canvas.height = gl_viewportHeight; }; Native.window.onresize += e => { AtResize(); }; AtResize(); #endregion Native.document.body.style.overflow = IStyle.OverflowEnum.hidden; var h = 1f; var r1 = .5f; var r2 = .2f; #region requestPointerLock var __pointer_x = 0; var __pointer_y = 0; canvas.onmousedown += delegate { canvas.requestPointerLock(); }; canvas.onmousemove += e => { if (Native.Document.pointerLockElement == canvas) { __pointer_x += e.movementX; __pointer_y += e.movementY; } }; canvas.onmouseup += delegate { //Native.Document.exitPointerLock(); }; #endregion var prog = gl.createProgram( new GeometryVertexShader(), new GeometryFragmentShader() ); gl.linkProgram(prog); gl.useProgram(prog); var uniforms = prog.Uniforms(gl); var nPhi = 100; var nTheta = 50; var dPhi = 2 * Math.PI / nPhi; var dTheta = Math.PI / nTheta; var vertices = new IArray<float>(); var ind = new IArray<ushort>(); for (var j = 0; j <= nTheta; j++) { var Theta = j * dTheta; var cosTheta = Math.Cos(Theta); var sinTheta = Math.Sin(Theta); for (var i = 0; i <= nPhi; i++) { var Phi = i * dPhi; var cosPhi = Math.Cos(Phi); var sinPhi = Math.Sin(Phi); vertices.push((f)(cosPhi * sinTheta)); vertices.push((f)(-sinPhi * sinTheta)); vertices.push((f)(cosTheta)); } } for (var j = 0; j < nTheta; j++) for (var i = 0; i <= nPhi; i++) { ind.push((ushort)(j * (nPhi + 1) + i)); ind.push((ushort)((j + 1) * (nPhi + 1) + i)); } var posLocation = gl.getAttribLocation(prog, "aPos"); gl.enableVertexAttribArray((uint)posLocation); var posBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, posBuffer); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); gl.vertexAttribPointer((uint)posLocation, 3, gl.FLOAT, false, 0, 0); var indexBuffer = gl.createBuffer(); gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer); gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(ind.ToArray()), gl.STATIC_DRAW); //prMatrix.perspective(45, 1, .1, 100); gl.uniformMatrix4fv(gl.getUniformLocation(prog, "prMatrix"), false, new Float32Array(prMatrix.getAsArray())); var mvMatrix = new CanvasMatrix4(); var mvMatLoc = gl.getUniformLocation(prog, "mvMatrix"); gl.enable(gl.DEPTH_TEST); gl.depthFunc(gl.LEQUAL); gl.clearDepth(1.0f); gl.clearColor(0, 0, .8f, 1f); var xOffs = 0; var yOffs = 0; var drag = 0; var xRot = 0f; var yRot = 1f; var transl = -15.5f; #region drawScene Action drawScene = delegate { var rotMat = new CanvasMatrix4(); rotMat.makeIdentity(); #region draw Action<f, f, f, f, f, f, f> drawBall = (x, y, z, r, g, b, _scale) => { var scale = _scale * 1.4f; mvMatrix.makeIdentity(); mvMatrix.translate(x, y, z); mvMatrix.multRight(rotMat); mvMatrix.translate(0, 0, transl); gl.uniformMatrix4fv(mvMatLoc, false, new Float32Array(mvMatrix.getAsArray())); //var colorLoc = gl.getUniformLocation(prog, "color"); //var scaleLoc = gl.getUniformLocation(prog, "scale"); uniforms.color = new __vec3(r, g, b); uniforms.scale = scale; //gl.uniform1f(scaleLoc, scale); //gl.uniform3f(colorLoc, r, g, b); for (var i = 0; i < nTheta; i++) gl.drawElements(gl.TRIANGLE_STRIP, 2 * (nPhi + 1), gl.UNSIGNED_SHORT, 4 * (nPhi + 1) * i); }; Action<f, f, f, f> drawBall_white = (x, y, z, _scale) => drawBall(x, y, z, 1, 1, 1, _scale); Action<f, f, f, f> drawBall_red = (x, y, z, _scale) => drawBall(x, y, z, 1, 0, 0, _scale); Action<f, f, f, f> drawBall_blue = (x, y, z, _scale) => drawBall(x, y, z, 0, 0, 1, _scale); Action<f, f, f, f> drawBall_gray = (x, y, z, _scale) => drawBall(x, y, z, .3f, .3f, .3f, _scale); #endregion gl.viewport(0, 0, gl_viewportWidth, gl_viewportHeight); #region prMatrix gl.uniformMatrix4fv(gl.getUniformLocation(prog, "prMatrix"), false, new Float32Array(prMatrix.getAsArray())); #endregion gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); rotMat.rotate(xRot / 3, 1, 0, 0); rotMat.rotate(yRot / 3, 0, 1, 0); //yRot = 0; //xRot = 0; rotMat.rotate(__pointer_y * 1.0f, 1, 0, 0); rotMat.rotate(__pointer_x * 1.0f, 0, 1, 0); //__pointer_x = 0; //__pointer_y = 0; //http://en.wikipedia.org/wiki/Cyanogen #region C2N2 drawBall_blue(0, -3, 0, 1f); drawBall_gray(0, -1, 0, 1.2f); drawBall_gray(0, 1, 0, 1.2f); drawBall_blue(0, 3, 0, 1f); #endregion //#region C6H3 //drawBall_gray(2, -1, 0, 1.5f); //drawBall_gray(0, -2, 0, 1.5f); //drawBall_white(0, -3.5f, 0, 1f); //drawBall_gray(-2, -1, 0, 1.5f); //drawBall_gray(2, 1, 0, 1.5f); //drawBall_white(3 + 0.5f, 1.5f + 0.5f, 0, 1f); //drawBall_gray(0, 2, 0, 1.5f); //drawBall_white(0, 3.5f, 0, 1f); //drawBall_gray(-2, 1, 0, 1.5f); //#endregion //#region CH2-CH2 //drawBall_white(6, -1 + 1, -1.5f, 1f); //drawBall_gray(6, -1, 0, 1.5f); //drawBall_white(6, -1 + 1, 1.5f, 1f); //drawBall_white(4, -2 - 1, -1.5f, 1f); //drawBall_gray(4, -2, 0, 1.5f); //drawBall_white(4, -2 - 1, 1.5f, 1f); //#endregion //#region NH2 //drawBall_white(8, -2 - 1, -1.5f, 1f); //drawBall_blue(8, -2, 0, 1.5f); //drawBall_white(8, -2 - 1, 1.5f, 1f); //#endregion gl.flush(); }; #endregion #region mouse canvas.onmousedown += ev => { ev.preventDefault(); drag = 1; xOffs = ev.CursorX; yOffs = ev.CursorY; }; canvas.onmouseup += ev => { ev.preventDefault(); drag = 0; xOffs = ev.CursorX; yOffs = ev.CursorY; }; canvas.onmousemove += ev => { if (drag == 0) return; ev.preventDefault(); if (ev.shiftKey) { transl *= 1 + (ev.CursorY - yOffs) / 1000; yRot = -xOffs + ev.CursorX; } else { yRot = -xOffs + ev.CursorX; xRot = -yOffs + ev.CursorY; } xOffs = ev.CursorX; yOffs = ev.CursorY; drawScene(); }; #endregion #region onmousewheel canvas.onmousewheel += ev => { var del = 1.1f; if (ev.shiftKey) del = 1.01f; if (ev.WheelDirection > 0) transl *= del; else transl *= (1 / del); drawScene(); ev.PreventDefault(); }; #endregion #region IsDisposed var IsDisposed = false; this.Dispose = delegate { if (IsDisposed) return; IsDisposed = true; canvas.Orphanize(); }; #endregion #region requestFullscreen Native.Document.body.ondblclick += delegate { if (IsDisposed) return; // http://tutorialzine.com/2012/02/enhance-your-website-fullscreen-api/ Native.Document.body.requestFullscreen(); }; #endregion var c = 0; Native.window.onframe += delegate { if (IsDisposed) return; c++; xRot += 0.2f; yRot += 0.3f; drawScene(); }; //new IHTMLAnchor { "drag me to my.jsc-solutions.net" }.AttachToDocument().With( // dragme => // { // dragme.style.position = IStyle.PositionEnum.@fixed; // dragme.style.left = "1em"; // dragme.style.bottom = "1em"; // dragme.AllowToDragAsApplicationPackage(); // } //); }
public void UpdateMessages(IArray paramvalues, IGPEnvironmentManager pEnvMgr, IGPMessages Messages) { }
public static IArray <int> Sub(this IArray <int> self, int scalar) { return(self.Select(x => x.Subtract(scalar))); }
//////////////////////////////////////////////////////////////////////// // METHOD: GetNumberOfJobs private bool GetNumberOfJobs(IJTXJob2 pParentJob, ref IArray aoiList, out int numJobs) { bool AOIFromOverlap = false; bool AOIFromParent = false; numJobs = -1; // Then use defaults AOIFromOverlap = !string.IsNullOrEmpty(m_AOIOverlapFeatureClassName); AOIFromParent = m_paramUseParentAOI; numJobs = m_paramNumberChildJobs; if (AOIFromOverlap) { if (!PopulateAOIListUsingOverlapFeatureClass(pParentJob, ref aoiList)) { return false; } numJobs = aoiList.Count; } else if (AOIFromParent) { if (!PopulateAOIListUsingParent(pParentJob, ref aoiList, numJobs)) { return false; } } return true; }
public static IArray <int> Sub(this int self, IArray <int> vector) { return(vector.Select(x => self.Subtract(x))); }
public PacketMock(IArray <byte> data) { this.Data = data; }
public static Vector4 Average(this IArray <Vector4> self) { return(self.Sum() / self.Count); }
public static IArray <int> Div(this IArray <int> self, int scalar) { return(self.Select(x => x.Divide(scalar))); }
public static Vector4 Variance(this IArray <Vector4> self) { var mean = self.Average(); return(self.Select(x => (x - mean).Sqr()).Average()); }
public static double Sum(this IArray <double> self) { return(self.Aggregate(0.0, (x, y) => x + y)); }
public static long Sum(this IArray <long> self) { return(self.Aggregate(0L, (x, y) => x + y)); }
public void UpdateParameters(IArray paramvalues, IGPEnvironmentManager envMgr) { m_parameters = paramvalues; // Get the output geodatabase parameter var gpParam = m_parameters.get_Element(OutputFileGDB) as IGPParameter; IGPValue outputFileGDBValue = m_gpUtils.UnpackGPValue(gpParam); // Get the output parameters and pack them based on the path to the output geodatabase if (!(outputFileGDBValue.IsEmpty())) { gpParam = paramvalues.get_Element(OutputTimeZoneFeatureClass) as IGPParameter; var defcType = new DEFeatureClassTypeClass() as IGPDataType; m_gpUtils.PackGPValue(defcType.CreateValue(outputFileGDBValue.GetAsText() + "\\" + TimeZoneFCName), gpParam); gpParam = paramvalues.get_Element(OutputTimeZonesTable) as IGPParameter; var deTableType = new DETableTypeClass() as IGPDataType; m_gpUtils.PackGPValue(deTableType.CreateValue(outputFileGDBValue.GetAsText() + "\\" + TimeZonesTableName), gpParam); gpParam = paramvalues.get_Element(OutputStreetsFeatureClass) as IGPParameter; defcType = new DEFeatureClassTypeClass() as IGPDataType; m_gpUtils.PackGPValue(defcType.CreateValue(outputFileGDBValue.GetAsText() + "\\" + StreetsFCName), gpParam); } return; }
public static double Variance(this IArray <long> self) { var mean = self.Average(); return(self.Select(x => MathOps.Sqr(x - mean)).Average()); }
public void Execute(IArray paramvalues, ITrackCancel trackcancel, IGPEnvironmentManager envMgr, IGPMessages messages) { // Remember the original GP environment settings and temporarily override these settings var gpSettings = envMgr as IGeoProcessorSettings; bool origAddOutputsToMapSetting = gpSettings.AddOutputsToMap; bool origLogHistorySetting = gpSettings.LogHistory; gpSettings.AddOutputsToMap = false; gpSettings.LogHistory = false; // Create the Geoprocessor Geoprocessor gp = new Geoprocessor(); try { // Validate our values IGPMessages validateMessages = ((IGPFunction2)this).Validate(paramvalues, false, envMgr); if ((validateMessages as IGPMessage).IsError()) { messages.AddError(1, "Validate failed"); return; } // Unpack values IGPParameter gpParam = paramvalues.get_Element(InputMtdDSTTable) as IGPParameter; IGPValue inputMtdDSTTableValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputMtdCntryRefTable) as IGPParameter; IGPValue inputMtdCntryRefTableValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputMtdAreaTable) as IGPParameter; IGPValue inputMtdAreaTableValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputAdminBndyFeatureClasses) as IGPParameter; var inputAdminBndyFeatureClassesMultiValue = m_gpUtils.UnpackGPValue(gpParam) as IGPMultiValue; gpParam = paramvalues.get_Element(OutputFileGDB) as IGPParameter; IGPValue outputFileGDBValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputStreetsFeatureClass) as IGPParameter; IGPValue inputStreetsFeatureClassValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputTimeZoneIDBaseFieldName) as IGPParameter; IGPValue inputTimeZoneIDBaseFieldNameValue = m_gpUtils.UnpackGPValue(gpParam); bool processStreetsFC = (!(inputStreetsFeatureClassValue.IsEmpty())); string timeZoneIDBaseFieldName = ""; if (!(inputTimeZoneIDBaseFieldNameValue.IsEmpty())) timeZoneIDBaseFieldName = inputTimeZoneIDBaseFieldNameValue.GetAsText(); // Get the path to the output file GDB string outputFileGdbPath = outputFileGDBValue.GetAsText(); // Create the new file geodatabase AddMessage("Creating the file geodatabase...", messages, trackcancel); int lastBackslash = outputFileGdbPath.LastIndexOf("\\"); CreateFileGDB createFGDBTool = new CreateFileGDB(); createFGDBTool.out_folder_path = outputFileGdbPath.Remove(lastBackslash); createFGDBTool.out_name = outputFileGdbPath.Substring(lastBackslash + 1); gp.Execute(createFGDBTool, trackcancel); // Copy the MtdDST table to the file geodatabase and add the ADMIN_LVL and AREACODE fields to it AddMessage("Copying the MtdDST table to the file geodatabase...", messages, trackcancel); TableToTable importTableTool = new TableToTable(); string inputMtdDSTTablePath = inputMtdDSTTableValue.GetAsText(); importTableTool.in_rows = inputMtdDSTTablePath; importTableTool.out_path = outputFileGdbPath; importTableTool.out_name = "MtdDST"; importTableTool.field_mapping = "AREA_ID \"AREA_ID\" true true false 4 Long 0 0 ,First,#," + inputMtdDSTTablePath + ",AREA_ID,-1,-1;" + "TIME_ZONE \"TIME_ZONE\" true true false 4 Text 0 0 ,First,#," + inputMtdDSTTablePath + ",TIME_ZONE,-1,-1;" + "DST_EXIST \"DST_EXIST\" true true false 1 Text 0 0 ,First,#," + inputMtdDSTTablePath + ",DST_EXIST,-1,-1"; gp.Execute(importTableTool, trackcancel); string mtdDSTTablePath = outputFileGdbPath + "\\MtdDST"; AddField addFieldTool = new AddField(); addFieldTool.in_table = mtdDSTTablePath; addFieldTool.field_name = "ADMIN_LVL"; addFieldTool.field_type = "SHORT"; gp.Execute(addFieldTool, trackcancel); addFieldTool = new AddField(); addFieldTool.in_table = mtdDSTTablePath; addFieldTool.field_name = "AREACODE"; addFieldTool.field_type = "TEXT"; addFieldTool.field_length = 76; gp.Execute(addFieldTool, trackcancel); // Copy the MtdArea table to the file geodatabase and index the AREA_ID field AddMessage("Copying the MtdArea table to the file geodatabase...", messages, trackcancel); importTableTool = new TableToTable(); importTableTool.in_rows = inputMtdAreaTableValue.GetAsText(); importTableTool.out_path = outputFileGdbPath; importTableTool.out_name = "MtdArea"; gp.Execute(importTableTool, trackcancel); string mtdAreaTablePath = outputFileGdbPath + "\\MtdArea"; AddIndex addIndexTool = new AddIndex(); addIndexTool.in_table = mtdAreaTablePath; addIndexTool.fields = "AREA_ID"; addIndexTool.index_name = "AREA_ID"; gp.Execute(addIndexTool, trackcancel); // Calculate the ADMIN_LVL and AREACODE fields on the MtdDST table MakeTableView makeTableViewTool = new MakeTableView(); makeTableViewTool.in_table = mtdDSTTablePath; makeTableViewTool.out_view = "MtdDST_Layer"; gp.Execute(makeTableViewTool, trackcancel); AddJoin addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "MtdDST_Layer"; addJoinTool.in_field = "AREA_ID"; addJoinTool.join_table = mtdAreaTablePath; addJoinTool.join_field = "AREA_ID"; addJoinTool.join_type = "KEEP_COMMON"; gp.Execute(addJoinTool, trackcancel); AddMessage("Calculating the ADMIN_LVL field...", messages, trackcancel); CalculateField calcFieldTool = new CalculateField(); calcFieldTool.in_table = "MtdDST_Layer"; calcFieldTool.field = "MtdDST.ADMIN_LVL"; calcFieldTool.expression = "[MtdArea.ADMIN_LVL]"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); AddMessage("Calculating the AREACODE field...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "MtdDST_Layer"; calcFieldTool.field = "MtdDST.AREACODE"; calcFieldTool.code_block = "lvl = [MtdArea.ADMIN_LVL]\n" + "s = CStr([MtdArea.AREACODE_1])\n" + "If lvl >= 2 Then s = s & \".\" & CStr([MtdArea.AREACODE_2])\n" + "If lvl >= 3 Then s = s & \".\" & CStr([MtdArea.AREACODE_3])\n" + "If lvl >= 4 Then s = s & \".\" & CStr([MtdArea.AREACODE_4])\n" + "If lvl >= 5 Then s = s & \".\" & CStr([MtdArea.AREACODE_5])\n" + "If lvl >= 6 Then s = s & \".\" & CStr([MtdArea.AREACODE_6])\n" + "If lvl >= 7 Then s = s & \".\" & CStr([MtdArea.AREACODE_7])"; calcFieldTool.expression = "s"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); RemoveJoin removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "MtdDST_Layer"; removeJoinTool.join_name = "MtdArea"; gp.Execute(removeJoinTool, trackcancel); Delete deleteTool = new Delete(); deleteTool.in_data = "MtdDST_Layer"; gp.Execute(deleteTool, trackcancel); // Create the MtdDST# tables by admin levels and index the AREACODE field TableSelect tableSelectTool = null; for (int i = 1; i <= 7; i++) { string iAsString = Convert.ToString(i, System.Globalization.CultureInfo.InvariantCulture); AddMessage("Extracting level " + iAsString + " MtdDST rows...", messages, trackcancel); tableSelectTool = new TableSelect(); tableSelectTool.in_table = mtdDSTTablePath; tableSelectTool.out_table = mtdDSTTablePath + iAsString; tableSelectTool.where_clause = "ADMIN_LVL = " + iAsString; gp.Execute(tableSelectTool, trackcancel); addIndexTool = new AddIndex(); addIndexTool.in_table = mtdDSTTablePath + iAsString; addIndexTool.fields = "AREACODE"; addIndexTool.index_name = "AREACODE"; gp.Execute(addIndexTool, trackcancel); } deleteTool = new Delete(); deleteTool.in_data = mtdDSTTablePath; gp.Execute(deleteTool, trackcancel); // Copy the MtdCntryRef table to the file geodatabase (use Statistics tool to remove duplicate rows) AddMessage("Copying the MtdCntryRef table to the file geodatabase...", messages, trackcancel); string inputMtdCntryRefTablePath = inputMtdCntryRefTableValue.GetAsText(); string mtdCntryRefTablePath = outputFileGdbPath + "\\MtdCntryRef"; Statistics statsTool = new Statistics(); statsTool.in_table = inputMtdCntryRefTablePath; statsTool.out_table = mtdCntryRefTablePath; statsTool.statistics_fields = "ISO_CODE COUNT"; statsTool.case_field = "GOVT_CODE;ISO_CODE;DRIVING_SD;ADMINLEVEL"; gp.Execute(statsTool, trackcancel); DeleteField deleteFieldTool = new DeleteField(); deleteFieldTool.in_table = mtdCntryRefTablePath; deleteFieldTool.drop_field = "FREQUENCY;COUNT_ISO_CODE"; gp.Execute(deleteFieldTool, trackcancel); // Index the GOVT_CODE field addIndexTool = new AddIndex(); addIndexTool.in_table = mtdCntryRefTablePath; addIndexTool.fields = "GOVT_CODE"; addIndexTool.index_name = "GOVT_CODE"; gp.Execute(addIndexTool, trackcancel); // Extract the top level (country) records from the MtdArea table and index the AREACODE_1 field AddMessage("Extracting the top-level rows from the MtdArea table...", messages, trackcancel); string mtdTopAreaTablePath = outputFileGdbPath + "\\TopArea"; tableSelectTool = new TableSelect(); tableSelectTool.in_table = mtdAreaTablePath; tableSelectTool.out_table = mtdTopAreaTablePath; tableSelectTool.where_clause = "AREACODE_2 = 0 AND AREA_TYPE = 'B'"; gp.Execute(tableSelectTool, trackcancel); addIndexTool = new AddIndex(); addIndexTool.in_table = mtdTopAreaTablePath; addIndexTool.fields = "AREACODE_1"; addIndexTool.index_name = "AREACODE_1"; gp.Execute(addIndexTool, trackcancel); // Create and calculate the TOP_GOVT_CODE field on the MtdArea table addFieldTool = new AddField(); addFieldTool.in_table = mtdAreaTablePath; addFieldTool.field_name = "TOP_GOVT_CODE"; addFieldTool.field_type = "LONG"; gp.Execute(addFieldTool, trackcancel); makeTableViewTool = new MakeTableView(); makeTableViewTool.in_table = mtdAreaTablePath; makeTableViewTool.out_view = "MtdArea_Layer"; gp.Execute(makeTableViewTool, trackcancel); addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "MtdArea_Layer"; addJoinTool.in_field = "AREACODE_1"; addJoinTool.join_table = mtdTopAreaTablePath; addJoinTool.join_field = "AREACODE_1"; addJoinTool.join_type = "KEEP_COMMON"; gp.Execute(addJoinTool, trackcancel); AddMessage("Calculating the TOP_GOVT_CODE field...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "MtdArea_Layer"; calcFieldTool.field = "MtdArea.TOP_GOVT_CODE"; calcFieldTool.expression = "[TopArea.GOVT_CODE]"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "MtdArea_Layer"; removeJoinTool.join_name = "TopArea"; gp.Execute(removeJoinTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = mtdTopAreaTablePath; gp.Execute(deleteTool, trackcancel); // Create and calculate the ISO_CODE and DRIVING_SD string fields addFieldTool = new AddField(); addFieldTool.in_table = mtdAreaTablePath; addFieldTool.field_name = "ISO_CODE"; addFieldTool.field_type = "TEXT"; addFieldTool.field_length = 3; gp.Execute(addFieldTool, trackcancel); addFieldTool = new AddField(); addFieldTool.in_table = mtdAreaTablePath; addFieldTool.field_name = "DRIVING_SD"; addFieldTool.field_type = "TEXT"; addFieldTool.field_length = 1; gp.Execute(addFieldTool, trackcancel); addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "MtdArea_Layer"; addJoinTool.in_field = "TOP_GOVT_CODE"; addJoinTool.join_table = mtdCntryRefTablePath; addJoinTool.join_field = "GOVT_CODE"; addJoinTool.join_type = "KEEP_COMMON"; gp.Execute(addJoinTool, trackcancel); AddMessage("Calculating the ISO_CODE field...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "MtdArea_Layer"; calcFieldTool.field = "MtdArea.ISO_CODE"; calcFieldTool.expression = "[MtdCntryRef.ISO_CODE]"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); AddMessage("Calculating the DRIVING_SD field...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "MtdArea_Layer"; calcFieldTool.field = "MtdArea.DRIVING_SD"; calcFieldTool.expression = "[MtdCntryRef.DRIVING_SD]"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "MtdArea_Layer"; removeJoinTool.join_name = "MtdCntryRef"; gp.Execute(removeJoinTool, trackcancel); // Create and calculate the FullAREACODE# string fields and the UTCOffset and DST fields addFieldTool = new AddField(); addFieldTool.in_table = mtdAreaTablePath; addFieldTool.field_type = "SHORT"; addFieldTool.field_name = "UTCOffset"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_name = "DST"; gp.Execute(addFieldTool, trackcancel); string codeBlock = "lvl = [ADMIN_LVL]\ns = CStr([AREACODE_1])"; for (int i = 1; i <= 7; i++) { string iAsString = Convert.ToString(i, System.Globalization.CultureInfo.InvariantCulture); string iPlusOne = Convert.ToString(i+1, System.Globalization.CultureInfo.InvariantCulture); string fullAreaCodeFieldName = "FullAREACODE" + iAsString; addFieldTool = new AddField(); addFieldTool.in_table = mtdAreaTablePath; addFieldTool.field_name = fullAreaCodeFieldName; addFieldTool.field_type = "TEXT"; addFieldTool.field_length = 76; gp.Execute(addFieldTool, trackcancel); AddMessage("Calculating the FullAREACODE" + iAsString + " field...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = mtdAreaTablePath; calcFieldTool.field = fullAreaCodeFieldName; calcFieldTool.code_block = codeBlock; calcFieldTool.expression = "s"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); codeBlock = codeBlock + "\nIf lvl >= " + iPlusOne + " Then s = s & \".\" & CStr([AREACODE_" + iPlusOne + "])"; string dstJoinTableName = "MtdDST" + iAsString; string dstJoinTablePath = outputFileGdbPath + "\\" + dstJoinTableName; addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "MtdArea_Layer"; addJoinTool.in_field = fullAreaCodeFieldName; addJoinTool.join_table = dstJoinTablePath; addJoinTool.join_field = "AREACODE"; addJoinTool.join_type = "KEEP_COMMON"; gp.Execute(addJoinTool, trackcancel); AddMessage("Calculating the UTCOffset field (" + iAsString + " of 7)...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "MtdArea_Layer"; calcFieldTool.field = "MtdArea.UTCOffset"; calcFieldTool.code_block = "s = [MtdArea.UTCOffset]\n" + "joinValue = [" + dstJoinTableName + ".TIME_ZONE]\n" + "If Not IsNull(joinValue) Then\n" + " If Trim(joinValue) <> \"\" Then s = CInt(joinValue) * 6\n" + "End If"; calcFieldTool.expression = "s"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); AddMessage("Calculating the DST field (" + iAsString + " of 7)...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "MtdArea_Layer"; calcFieldTool.field = "MtdArea.DST"; calcFieldTool.code_block = "s = [MtdArea.DST]\n" + "joinValue = [" + dstJoinTableName + ".DST_EXIST]\n" + "If Not IsNull(joinValue) Then\n" + " Select Case Trim(joinValue)\n" + " Case \"Y\": s = 1\n Case \"N\": s = 0\n" + " End Select\n" + "End If"; calcFieldTool.expression = "s"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "MtdArea_Layer"; removeJoinTool.join_name = dstJoinTableName; gp.Execute(removeJoinTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = dstJoinTablePath; gp.Execute(deleteTool, trackcancel); } deleteTool = new Delete(); deleteTool.in_data = "MtdArea_Layer"; gp.Execute(deleteTool, trackcancel); // Create and calculate the sortable MSTIMEZONE field on the MtdArea table addFieldTool = new AddField(); addFieldTool.in_table = mtdAreaTablePath; addFieldTool.field_name = "SortableMSTIMEZONE"; addFieldTool.field_type = "TEXT"; addFieldTool.field_length = 60; gp.Execute(addFieldTool, trackcancel); AddMessage("Calculating the time zones...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = mtdAreaTablePath; calcFieldTool.field = "SortableMSTIMEZONE"; calcFieldTool.code_block = TimeZoneUtilities.MakeSortableMSTIMEZONECode("ISO_CODE"); calcFieldTool.expression = "z"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); // Extract the MtdArea rows to be used for generating the time zone polygons and index the AREA_ID field string mtdAreaForTZPolysTablePath = outputFileGdbPath + "\\MtdAreaForTZPolys"; tableSelectTool = new TableSelect(); tableSelectTool.in_table = mtdAreaTablePath; tableSelectTool.out_table = mtdAreaForTZPolysTablePath; tableSelectTool.where_clause = CreateWhereClauseForAdminLvlByCountry(outputFileGdbPath, "MtdCntryRef"); gp.Execute(tableSelectTool, trackcancel); addIndexTool = new AddIndex(); addIndexTool.in_table = mtdAreaForTZPolysTablePath; addIndexTool.fields = "AREA_ID"; addIndexTool.index_name = "AREA_ID"; gp.Execute(addIndexTool, trackcancel); // We no longer need the MtdCntryRef table anymore deleteTool = new Delete(); deleteTool.in_data = mtdCntryRefTablePath; gp.Execute(deleteTool, trackcancel); // Merge the AdminBndy feature classes together into one feature class int numAdminBndyFCs = inputAdminBndyFeatureClassesMultiValue.Count; string mergeToolInputs = ""; for (int i = 0; i < numAdminBndyFCs; i++) { mergeToolInputs = mergeToolInputs + inputAdminBndyFeatureClassesMultiValue.get_Value(i).GetAsText() + ";"; } mergeToolInputs = mergeToolInputs.Remove(mergeToolInputs.Length - 1); string adminBndyFCPath = outputFileGdbPath + "\\AdminBndy"; AddMessage("Merging the Administrative Boundary feature classes...", messages, trackcancel); Merge mergeTool = new Merge(); mergeTool.inputs = mergeToolInputs; mergeTool.output = adminBndyFCPath; gp.Execute(mergeTool, trackcancel); // Join the AdminBndy polygons to the MtdArea rows to be used for generating the time zone polygons MakeFeatureLayer makeFeatureLayerTool = new MakeFeatureLayer(); makeFeatureLayerTool.in_features = adminBndyFCPath; makeFeatureLayerTool.out_layer = "AdminBndy_Layer"; gp.Execute(makeFeatureLayerTool, trackcancel); addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "AdminBndy_Layer"; addJoinTool.in_field = "AREA_ID"; addJoinTool.join_table = mtdAreaForTZPolysTablePath; addJoinTool.join_field = "AREA_ID"; addJoinTool.join_type = "KEEP_COMMON"; gp.Execute(addJoinTool, trackcancel); FeatureClassToFeatureClass importFCTool = new FeatureClassToFeatureClass(); importFCTool.in_features = "AdminBndy_Layer"; importFCTool.out_path = outputFileGdbPath; importFCTool.out_name = "UndissolvedTZPolys"; importFCTool.field_mapping = "SortableMSTIMEZONE \"SortableMSTIMEZONE\" true true false 60 Text 0 0 ,First,#," + mtdAreaForTZPolysTablePath + ",MtdAreaForTZPolys.SortableMSTIMEZONE,-1,-1"; gp.Execute(importFCTool, trackcancel); string undissolvedTZPolysFCPath = outputFileGdbPath + "\\UndissolvedTZPolys"; removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "AdminBndy_Layer"; removeJoinTool.join_name = "MtdAreaForTZPolys"; gp.Execute(removeJoinTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = "AdminBndy_Layer"; gp.Execute(deleteTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = adminBndyFCPath; gp.Execute(deleteTool, trackcancel); deleteTool.in_data = mtdAreaForTZPolysTablePath; gp.Execute(deleteTool, trackcancel); // Dissolve the time zone polygons together AddMessage("Dissolving the time zones...", messages, trackcancel); string timeZoneFCPath = outputFileGdbPath + "\\" + TimeZoneFCName; Dissolve dissolveTool = new Dissolve(); dissolveTool.in_features = undissolvedTZPolysFCPath; dissolveTool.out_feature_class = timeZoneFCPath; dissolveTool.dissolve_field = "SortableMSTIMEZONE"; dissolveTool.multi_part = "MULTI_PART"; gp.Execute(dissolveTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = undissolvedTZPolysFCPath; gp.Execute(deleteTool, trackcancel); // Create and calculate the MSTIMEZONE field addFieldTool = new AddField(); addFieldTool.in_table = timeZoneFCPath; addFieldTool.field_name = "MSTIMEZONE"; addFieldTool.field_type = "TEXT"; addFieldTool.field_length = 50; gp.Execute(addFieldTool, trackcancel); AddMessage("Calculating the time zones...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = timeZoneFCPath; calcFieldTool.field = "MSTIMEZONE"; calcFieldTool.expression = "Mid([SortableMSTIMEZONE], 7)"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); // Delete the old sortable MSTIMEZONE field deleteFieldTool = new DeleteField(); deleteFieldTool.in_table = timeZoneFCPath; deleteFieldTool.drop_field = "SortableMSTIMEZONE"; gp.Execute(deleteFieldTool, trackcancel); if (processStreetsFC) { // Create the network dataset time zone table AddMessage("Creating the time zones table...", messages, trackcancel); importTableTool = new TableToTable(); importTableTool.in_rows = timeZoneFCPath; importTableTool.out_path = outputFileGdbPath; importTableTool.out_name = TimeZonesTableName; importTableTool.field_mapping = "MSTIMEZONE \"MSTIMEZONE\" true true false 50 Text 0 0 ,First,#," + timeZoneFCPath + ",MSTIMEZONE,-1,-1"; gp.Execute(importTableTool, trackcancel); // Separate the MtdArea table by driving side and index the AREA_ID field on each AddMessage("Extracting rows for the left-side driving areas...", messages, trackcancel); string drivingLTablePath = mtdAreaTablePath + "DrivingL"; string drivingRTablePath = mtdAreaTablePath + "DrivingR"; tableSelectTool = new TableSelect(); tableSelectTool.in_table = mtdAreaTablePath; tableSelectTool.out_table = drivingLTablePath; tableSelectTool.where_clause = "DRIVING_SD = 'L'"; gp.Execute(tableSelectTool, trackcancel); addIndexTool = new AddIndex(); addIndexTool.in_table = drivingLTablePath; addIndexTool.fields = "AREA_ID"; addIndexTool.index_name = "AREA_ID"; gp.Execute(addIndexTool, trackcancel); AddMessage("Extracting rows for the right-side driving areas...", messages, trackcancel); tableSelectTool = new TableSelect(); tableSelectTool.in_table = mtdAreaTablePath; tableSelectTool.out_table = drivingRTablePath; tableSelectTool.where_clause = "DRIVING_SD = 'R'"; gp.Execute(tableSelectTool, trackcancel); addIndexTool = new AddIndex(); addIndexTool.in_table = drivingRTablePath; addIndexTool.fields = "AREA_ID"; addIndexTool.index_name = "AREA_ID"; gp.Execute(addIndexTool, trackcancel); // Import the Streets feature class to the file geodatabase and // add the FT_TimeZoneID and TF_TimeZoneID fields AddMessage("Copying the Streets feature class to the geodatabase...", messages, trackcancel); importFCTool = new FeatureClassToFeatureClass(); importFCTool.in_features = inputStreetsFeatureClassValue.GetAsText(); importFCTool.out_path = outputFileGdbPath; importFCTool.out_name = StreetsFCName; gp.Execute(importFCTool, trackcancel); string pathToStreetsFC = outputFileGdbPath + "\\" + StreetsFCName; addFieldTool = new AddField(); addFieldTool.in_table = pathToStreetsFC; addFieldTool.field_name = "FT_" + timeZoneIDBaseFieldName; addFieldTool.field_type = "SHORT"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_name = "TF_" + timeZoneIDBaseFieldName; addFieldTool.field_type = "SHORT"; gp.Execute(addFieldTool, trackcancel); // Calculate the TimeZoneID fields makeFeatureLayerTool = new MakeFeatureLayer(); makeFeatureLayerTool.in_features = pathToStreetsFC; makeFeatureLayerTool.out_layer = "Streets_Layer"; gp.Execute(makeFeatureLayerTool, trackcancel); addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "Streets_Layer"; addJoinTool.in_field = "R_AREA_ID"; addJoinTool.join_table = drivingLTablePath; addJoinTool.join_field = "AREA_ID"; addJoinTool.join_type = "KEEP_COMMON"; gp.Execute(addJoinTool, trackcancel); AddMessage("Calculating the FT_" + timeZoneIDBaseFieldName + " field for left driving side roads...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "Streets_Layer"; calcFieldTool.field = StreetsFCName + ".FT_" + timeZoneIDBaseFieldName; calcFieldTool.code_block = TimeZoneUtilities.MakeTimeZoneIDCode(outputFileGdbPath, TimeZonesTableName, "MtdAreaDrivingL.SortableMSTIMEZONE"); calcFieldTool.expression = "tzID"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "Streets_Layer"; removeJoinTool.join_name = "MtdAreaDrivingL"; gp.Execute(removeJoinTool, trackcancel); addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "Streets_Layer"; addJoinTool.in_field = "L_AREA_ID"; addJoinTool.join_table = drivingRTablePath; addJoinTool.join_field = "AREA_ID"; addJoinTool.join_type = "KEEP_COMMON"; gp.Execute(addJoinTool, trackcancel); AddMessage("Calculating the FT_" + timeZoneIDBaseFieldName + " field for right driving side roads...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "Streets_Layer"; calcFieldTool.field = StreetsFCName + ".FT_" + timeZoneIDBaseFieldName; calcFieldTool.code_block = TimeZoneUtilities.MakeTimeZoneIDCode(outputFileGdbPath, TimeZonesTableName, "MtdAreaDrivingR.SortableMSTIMEZONE"); calcFieldTool.expression = "tzID"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "Streets_Layer"; removeJoinTool.join_name = "MtdAreaDrivingR"; gp.Execute(removeJoinTool, trackcancel); addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "Streets_Layer"; addJoinTool.in_field = "L_AREA_ID"; addJoinTool.join_table = drivingLTablePath; addJoinTool.join_field = "AREA_ID"; addJoinTool.join_type = "KEEP_COMMON"; gp.Execute(addJoinTool, trackcancel); AddMessage("Calculating the TF_" + timeZoneIDBaseFieldName + " field for left driving side roads...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "Streets_Layer"; calcFieldTool.field = StreetsFCName + ".TF_" + timeZoneIDBaseFieldName; calcFieldTool.code_block = TimeZoneUtilities.MakeTimeZoneIDCode(outputFileGdbPath, TimeZonesTableName, "MtdAreaDrivingL.SortableMSTIMEZONE"); calcFieldTool.expression = "tzID"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "Streets_Layer"; removeJoinTool.join_name = "MtdAreaDrivingL"; gp.Execute(removeJoinTool, trackcancel); addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "Streets_Layer"; addJoinTool.in_field = "R_AREA_ID"; addJoinTool.join_table = drivingRTablePath; addJoinTool.join_field = "AREA_ID"; addJoinTool.join_type = "KEEP_COMMON"; gp.Execute(addJoinTool, trackcancel); AddMessage("Calculating the TF_" + timeZoneIDBaseFieldName + " field for right driving side roads...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "Streets_Layer"; calcFieldTool.field = StreetsFCName + ".TF_" + timeZoneIDBaseFieldName; calcFieldTool.code_block = TimeZoneUtilities.MakeTimeZoneIDCode(outputFileGdbPath, TimeZonesTableName, "MtdAreaDrivingR.SortableMSTIMEZONE"); calcFieldTool.expression = "tzID"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "Streets_Layer"; removeJoinTool.join_name = "MtdAreaDrivingR"; gp.Execute(removeJoinTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = "Streets_Layer"; gp.Execute(deleteTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = drivingLTablePath; gp.Execute(deleteTool, trackcancel); deleteTool.in_data = drivingRTablePath; gp.Execute(deleteTool, trackcancel); } else { // Create a dummy TimeZones table and a dummy Streets feature class CreateTable createTableTool = new CreateTable(); createTableTool.out_path = outputFileGdbPath; createTableTool.out_name = TimeZonesTableName; gp.Execute(createTableTool, trackcancel); CreateFeatureclass createFCTool = new CreateFeatureclass(); createFCTool.out_path = outputFileGdbPath; createFCTool.out_name = StreetsFCName; createFCTool.geometry_type = "POLYLINE"; gp.Execute(createFCTool, trackcancel); } deleteTool = new Delete(); deleteTool.in_data = mtdAreaTablePath; gp.Execute(deleteTool, trackcancel); // Compact the output file geodatabase AddMessage("Compacting the output file geodatabase...", messages, trackcancel); Compact compactTool = new Compact(); compactTool.in_workspace = outputFileGdbPath; gp.Execute(compactTool, trackcancel); } catch (Exception e) { if (gp.MaxSeverity == 2) { object missing = System.Type.Missing; messages.AddError(1, gp.GetMessages(ref missing)); } messages.AddError(1, e.Message); messages.AddError(1, e.StackTrace); } finally { // Restore the original GP environment settings gpSettings.AddOutputsToMap = origAddOutputsToMapSetting; gpSettings.LogHistory = origLogHistorySetting; } GC.Collect(); return; }
//���ݶ���ߺͷ������鴴���߳����� public static void ProfileCreateGraph(AxMapControl ppAxMapControl, IPolyline pPolyline, IArray pSewerElevArray) { IZ pPolylineZ = pPolyline as IZ; IRasterLayer pRasterLyr = FindRasterLayer("Elevation", ppAxMapControl); //��ñ�����в�ֵ ISurface pSurface = GetSurface(pRasterLyr); //����Polyline z-ware; IZAware pZAwareLineZ = pPolyline as IZAware; pZAwareLineZ.ZAware = true; //'* work around for InterpolateFromSurface sometimes flipping polyline IPoint pPtOrigFrom = pPolyline.FromPoint; IPoint pPtOrigTo = pPolyline.ToPoint; //���Zֵ��������� pPolylineZ.InterpolateFromSurface(pSurface); if (pPolyline.FromPoint.X != pPtOrigFrom.X || pPolyline.FromPoint.Y != pPtOrigFrom.Y) pPolyline.ReverseOrientation(); //���Mֵ������ IMSegmentation pMSegmentation = pPolyline as IMSegmentation; IMAware pMAware = pPolyline as IMAware; pMAware.MAware = true; pMSegmentation.SetMsAsDistance(false); //������� ITable pTable = ProfileCreateTable(); int i = 0; if (pTable != null) { //��ͼ���б�ؼ���Ҫȷ���ñ�����ڣ����������ɾ���� IStandaloneTableCollection pStandAloneTabColl = ppAxMapControl.ActiveView.FocusMap as IStandaloneTableCollection; for (i = 0; i <= pStandAloneTabColl.StandaloneTableCount - 1; i++) { if (pStandAloneTabColl.get_StandaloneTable(i).Name == "xxprofiletable") pStandAloneTabColl.RemoveStandaloneTable(pStandAloneTabColl.get_StandaloneTable(i)); } //����һ���µĶ��������������ӵ���ͼ������ IStandaloneTable pStandAloneTab = new StandaloneTableClass(); pStandAloneTab.Table = pTable; pStandAloneTabColl = ppAxMapControl.ActiveView.FocusMap as IStandaloneTableCollection; pStandAloneTabColl.AddStandaloneTable(pStandAloneTab); pTable = pStandAloneTab as ITable; //Ϊ�����ֶ����ñ��� ITableFields pTableFields = pStandAloneTab as ITableFields; IFieldInfo pFieldInfo = pTableFields.get_FieldInfo(pTableFields.FindField("Z")); pFieldInfo.Alias = "Ground Elevation"; pFieldInfo = pTableFields.get_FieldInfo(pTableFields.FindField("SewerElev")); pFieldInfo.Alias = "Sewer Line Elevation"; //Ϊ�����һ�������� ICursor pCursor = pTable.Insert(true); IRowBuffer pRowBuff; // IPointCollection pPtCollection = pPolyline as IPointCollection; IEnumVertex pEnumVertex = pPtCollection.EnumVertices; pEnumVertex.Reset(); IPoint pPT; int iPartIndex; int iVertexIndex; i = 0; //��ӽڵ�XYZ���±���� pEnumVertex.Next(out pPT, out iPartIndex, out iVertexIndex); while (pPT != null) { pRowBuff = pTable.CreateRowBuffer(); pRowBuff.set_Value(pRowBuff.Fields.FindField("X"), pPT.X); pRowBuff.set_Value(pRowBuff.Fields.FindField("Y"), pPT.Y); pRowBuff.set_Value(pRowBuff.Fields.FindField("Z"), pPT.Z); pRowBuff.set_Value(pRowBuff.Fields.FindField("M"), pPT.M); pRowBuff.set_Value(pRowBuff.Fields.FindField("SewerElev"), Convert.ToDouble(pSewerElevArray.get_Element(i))); pCursor.InsertRow(pRowBuff); pEnumVertex.Next(out pPT, out iPartIndex, out iVertexIndex); i = i + 1; } pCursor.Flush(); pCursor = null; pCursor = pTable.Search(null, false); IQueryFilter pQueryFilter = new QueryFilterClass(); pQueryFilter.WhereClause = "SewerElev <> -99"; ICursor pCursorSewerElev = pTable.Search(pQueryFilter, false); pCursor = null; pCursor = pTable.Update(null, false); pRowBuff = pCursor.NextRow(); double m = 0; double Mmin = 0; double Mmax = 0; double deltaM = 0; double deltaSewerElev = 0; double sewerelev = 0; double newZ = 0; int j = 0; double minSewerElev = 0; double maxSewerElev = 0; IRow pRowSewerElev; while (pRowBuff != null) { if (Convert.ToDouble(pRowBuff.get_Value(pRowBuff.Fields.FindField("SewerElev"))) == -99) { m = Convert.ToDouble(pRowBuff.get_Value(pRowBuff.Fields.FindField("M"))); newZ = (((m - Mmin) / deltaM) * deltaSewerElev) + sewerelev; pRowBuff.set_Value(pRowBuff.Fields.FindField("SewerElev"), newZ); pCursor.UpdateRow(pRowBuff as IRow); } else { if (j == 0) { pRowSewerElev = pCursorSewerElev.NextRow(); minSewerElev = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("SewerElev"))); Mmin = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("M"))); pRowSewerElev = pCursorSewerElev.NextRow(); maxSewerElev = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("SewerElev"))); Mmax = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("M"))); } else { pRowSewerElev = pCursorSewerElev.NextRow(); if (pRowSewerElev != null) { minSewerElev = maxSewerElev; Mmin = Mmax; maxSewerElev = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("SewerElev"))); Mmax = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("M"))); } } deltaSewerElev = maxSewerElev - minSewerElev; deltaM = Mmax - Mmin; sewerelev = minSewerElev; j = j + 1; } pRowBuff = pCursor.NextRow() as IRowBuffer; } pCursor.Flush(); //�ӱ���д���ͼ�� m_SewerElevStructArray = new ArrayClass(); pCursor = null; pCursor = pTable.Search(null, false); pRowSewerElev = null; pRowSewerElev = pCursor.NextRow(); //ma //while (pRowSewerElev != null) //{ // clsProfileStruct pProfileDataStruct = new clsProfileStruct(); // pProfileDataStruct.M = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("M"))); // pProfileDataStruct.Z = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("Z"))); // pProfileDataStruct.dSewerElev = Convert.ToDouble(pRowSewerElev.get_Value(pRowSewerElev.Fields.FindField("Sewerelev"))); // m_SewerElevStructArray.Add(pProfileDataStruct); // pRowSewerElev = pCursor.NextRow(); //} //frmDrawProfile frmDrawProfile1 = new frmDrawProfile(m_SewerElevStructArray); //frmDrawProfile1.Show(); } }
public static IArray <int> Div(this int self, IArray <int> vector) { return(vector.Select(x => self.Divide(x))); }
public static Vector4 Sum(this IArray <Vector4> self) { return(self.Aggregate(Vector4.Zero, (x, y) => x + y)); }
public IGPMessages Validate(IArray paramvalues, bool updateValues, IGPEnvironmentManager envMgr) { // Initialize a copy of our parameters if (m_parameters == null) m_parameters = ParameterInfo; // Call UpdateParameters() (only call if updateValues is true) if (updateValues) UpdateParameters(paramvalues, envMgr); // Call InternalValidate (basic validation): // - Are all the required parameters supplied? // - Are the Values to the parameters the correct data type? IGPMessages validateMsgs = m_gpUtils.InternalValidate(m_parameters, paramvalues, updateValues, true, envMgr); // Call UpdateMessages() UpdateMessages(paramvalues, envMgr, validateMsgs); // Return the messages return validateMsgs; }
public static IArray <long> Add(this IArray <long> self, IArray <long> other) { return(self.Zip(other, MathOps.Add)); }
/// <summary> /// Trains the classifier /// </summary> private void TrainBinary(IArrayView<Example> binaryExamples, IArrayView<double> weights) { this.mistakes.Clear(); this.perceptronWeights.Clear(); this.confidenceRange = 0; // We need padding, since the first weight refers to the zeros vector this.mistakes.Add(default(Example)); this.perceptronWeights.Add(0); this.currentPerceptron = Arrays.New<double>(binaryExamples[0].Features.Count); // in each epoch for (int i = 0; i < this.Epochs; i++) // train on each example for (int e = 0; e < binaryExamples.Count; e++) this.DoTrainingStep(binaryExamples[e], weights[e]); }
public static IArray <long> Add(this IArray <long> self, long scalar) { return(self.Select(x => x.Add(scalar))); }
public static void ProfileFindPath(AxMapControl ppAxMapControl, IArray pNetFlagArray, IGeometricNetwork pGeoNetwork) { try { IEnumNetEID m_ipEnumNetEID_Junctions, m_ipEnumNetEID_Edges;//����������������Junctions��Edges IJunctionFlag[] pArrayJFlag = new IJunctionFlag[2]; pArrayJFlag[0] = pNetFlagArray.get_Element(0) as IJunctionFlag; pArrayJFlag[1] = pNetFlagArray.get_Element(1) as IJunctionFlag; ITraceFlowSolverGEN ipTraceFlowSolver = new TraceFlowSolverClass() as ITraceFlowSolverGEN; //get the inetsolver interface INetSolver ipNetSolver = ipTraceFlowSolver as INetSolver; ipNetSolver.SourceNetwork = pGeoNetwork.Network; ipTraceFlowSolver.PutJunctionOrigins(ref pArrayJFlag); ipTraceFlowSolver.TraceIndeterminateFlow = false; object[] totalCost = new object[1]; //ipTraceFlowSolver.FindSource(esriFlowMethod.esriFMUpstream,esriShortestPathObjFn.esriSPObjFnMinSum,out m_ipEnumNetEID_Junctions,out m_ipEnumNetEID_Edges,1,ref totalCost); ipTraceFlowSolver.FindPath(esriFlowMethod.esriFMConnected, esriShortestPathObjFn.esriSPObjFnMinMax, out m_ipEnumNetEID_Junctions, out m_ipEnumNetEID_Edges, 1, ref totalCost); //��������еĽ����Ԫ�� pNetFlagArray.RemoveAll(); //ma // SpatialHelperFunction.pathToPolyline(pGeoNetwork, ppAxMapControl.ActiveView, m_ipEnumNetEID_Edges); //ProfileGetRelatedSewerElevData(ppAxMapControl,pGeoNetwork,m_ipEnumNetEID_Edges, m_ipEnumNetEID_Junctions ); } catch (Exception eX) { MessageBox.Show(eX.Message); } }
public static IArray <long> Add(this long self, IArray <long> vector) { return(vector.Select(x => self.Add(x))); }
/// <summary> /// This is a javascript application. /// </summary> /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param> public Application(IDefault page = null) { var gl_viewportWidth = 500; var gl_viewportHeight = 500; var gl = new WebGLRenderingContext(); #region canvas var canvas = gl.canvas.AttachToDocument(); Native.document.body.style.overflow = IStyle.OverflowEnum.hidden; canvas.style.SetLocation(0, 0, gl_viewportWidth, gl_viewportHeight); canvas.width = gl_viewportWidth; canvas.height = gl_viewportHeight; #endregion var h = 1f; var r1 = .5f; var r2 = .2f; var nPhi = 500; var prog = gl.createProgram(); #region createShader Func<ScriptCoreLib.GLSL.Shader, WebGLShader> createShader = (src) => { var shader = gl.createShader(src); // verify if (gl.getShaderParameter(shader, gl.COMPILE_STATUS) == null) { Native.window.alert("error in SHADER:\n" + gl.getShaderInfoLog(shader)); throw new InvalidOperationException("shader failed"); } return shader; }; #endregion var vs = createShader(new GeometryVertexShader()); var fs = createShader(new GeometryFragmentShader()); gl.attachShader(prog, vs); gl.attachShader(prog, fs); gl.linkProgram(prog); gl.useProgram(prog); var pt = new IArray<float>(); var nt = new IArray<float>(); var Phi = 0.0; var dPhi = 2 * Math.PI / (nPhi - 1); var Nx = r1 - r2; var Ny = h; var N = (float)Math.Sqrt(Nx * Nx + Ny * Ny); Nx /= N; Ny /= N; for (var i = 0; i < nPhi; i++) { var cosPhi = Math.Cos(Phi); var sinPhi = Math.Sin(Phi); var cosPhi2 = Math.Cos(Phi + dPhi / 2); var sinPhi2 = Math.Sin(Phi + dPhi / 2); pt.push(-h / 2); pt.push((float)(cosPhi * r1)); pt.push((float)(sinPhi * r1)); // points nt.push(Nx); nt.push((float)(Ny * cosPhi)); nt.push((float)(Ny * sinPhi)); // normals pt.push(h / 2); pt.push((float)(cosPhi2 * r2)); pt.push((float)(sinPhi2 * r2)); // points nt.push(Nx); nt.push((float)(Ny * cosPhi2)); nt.push((float)(Ny * sinPhi2)); // normals Phi += dPhi; } var posLoc = gl.getAttribLocation(prog, "aPos"); gl.enableVertexAttribArray((uint)posLoc); gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer()); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(pt.ToArray()), gl.STATIC_DRAW); gl.vertexAttribPointer((uint)posLoc, 3, gl.FLOAT, false, 0, 0); var normLoc = gl.getAttribLocation(prog, "aNorm"); gl.enableVertexAttribArray((uint)normLoc); gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer()); gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(nt), gl.STATIC_DRAW); gl.vertexAttribPointer((uint)normLoc, 3, gl.FLOAT, false, 0, 0); var prMatrix = new CanvasMatrix4(); gl.uniformMatrix4fv(gl.getUniformLocation(prog, "prMatrix"), false, new Float32Array(prMatrix.getAsArray())); var mvMatrix = new CanvasMatrix4(); var rotMat = new CanvasMatrix4(); rotMat.makeIdentity(); rotMat.rotate(-40, 0, 1, 0); var mvMatLoc = gl.getUniformLocation(prog, "mvMatrix"); gl.enable(gl.DEPTH_TEST); gl.depthFunc(gl.LEQUAL); gl.clearDepth(1.0f); gl.clearColor(0, 0, .5f, 1); var xOffs = 0; var yOffs = 0; var drag = 0; var xRot = 0; var yRot = 0; var transl = -1.5f; Action drawScene = delegate { gl.uniformMatrix4fv(gl.getUniformLocation(prog, "prMatrix"), false, new Float32Array(prMatrix.getAsArray())); gl.viewport(0, 0, gl_viewportWidth, gl_viewportHeight); gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); rotMat.rotate(xRot / 5, 1, 0, 0); rotMat.rotate(yRot / 5, 0, 1, 0); yRot = 0; xRot = 0; mvMatrix.load(rotMat); mvMatrix.translate(0, 0, transl); gl.uniformMatrix4fv(mvMatLoc, false, new Float32Array(mvMatrix.getAsArray())); gl.drawArrays(gl.TRIANGLE_STRIP, 0, 2 * nPhi); gl.flush(); }; #region IsDisposed var IsDisposed = false; this.Dispose = delegate { if (IsDisposed) return; IsDisposed = true; canvas.Orphanize(); }; #endregion #region requestFullscreen Native.Document.body.ondblclick += delegate { if (IsDisposed) return; // http://tutorialzine.com/2012/02/enhance-your-website-fullscreen-api/ Native.Document.body.requestFullscreen(); }; #endregion var c = 0; Native.window.onframe += delegate { if (IsDisposed) return; c++; xRot += 2; yRot += 3; Native.document.title = "" + c; drawScene(); //animate(); }; #region AtResize Action AtResize = delegate { gl_viewportWidth = Native.window.Width; gl_viewportHeight = Native.window.Height; prMatrix = new CanvasMatrix4(); prMatrix.perspective(45f, (f)gl_viewportWidth / (f)gl_viewportHeight, 1f, 100f); canvas.style.SetLocation(0, 0, gl_viewportWidth, gl_viewportHeight); canvas.width = gl_viewportWidth; canvas.height = gl_viewportHeight; }; Native.window.onresize += e => { AtResize(); }; AtResize(); #endregion }
public static IArray <long> Mul(this IArray <long> self, IArray <long> other) { return(self.Zip(other, MathOps.Multiply)); }
private void RefreshMap(IActiveView ActiveView, IArray Layers) { try { for (int z = 0; z <= Layers.Count - 1; z++) { if (Layers.get_Element(z) != null) { IFeatureSelection pFeatSel = (IFeatureSelection)Layers.get_Element(z); pFeatSel.Clear();//refreshes the parcel explorer ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Layers.get_Element(z), ActiveView.Extent); ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, Layers.get_Element(z), ActiveView.Extent); } } } catch { } }
public static IArray <long> Mul(this IArray <long> self, long scalar) { return(self.Select(x => x.Multiply(scalar))); }
public void UpdateParameters(IArray paramvalues, IGPEnvironmentManager pEnvMgr) { IGPUtilities2 gpUtil = null; try { gpUtil = new GPUtilitiesClass(); IGPParameter targetDatasetParameter = paramvalues.get_Element(in_osmFeatureDataset) as IGPParameter; IDataElement dataElement = gpUtil.UnpackGPValue(targetDatasetParameter) as IDataElement; string osmDatasetPath = dataElement.CatalogPath; IGPParameter gppNetworkDataset = paramvalues.get_Element(out_NetworkDataset) as IGPParameter; IGPValue gpvNetworkDataset = gpUtil.UnpackGPValue(gppNetworkDataset); string ndsPath = gpvNetworkDataset.GetAsText(); string ndsDir = string.Empty; if (!string.IsNullOrEmpty(ndsPath)) ndsDir = System.IO.Path.GetDirectoryName(ndsPath); if (!ndsDir.Equals(osmDatasetPath)) { string ndsName = System.IO.Path.GetFileName(ndsPath); if (string.IsNullOrEmpty(ndsName)) ndsName = _defaultNetworkDatasetName; ndsName = System.IO.Path.GetFileName(osmDatasetPath) + "_" + ndsName; gpvNetworkDataset.SetAsText(System.IO.Path.Combine(osmDatasetPath, ndsName)); gpUtil.PackGPValue(gpvNetworkDataset, gppNetworkDataset); } } finally { if (gpUtil != null) ComReleaser.ReleaseCOMObject(gpUtil); } }
public static IArray <long> Mul(this long self, IArray <long> vector) { return(vector.Select(x => self.Multiply(x))); }
public void Execute(IArray paramvalues, ITrackCancel TrackCancel, IGPEnvironmentManager envMgr, IGPMessages message) { IAoInitialize aoInitialize = new AoInitializeClass(); esriLicenseStatus naStatus = esriLicenseStatus.esriLicenseUnavailable; IGPUtilities2 gpUtil = null; IDataset osmDataset = null; try { if (!aoInitialize.IsExtensionCheckedOut(esriLicenseExtensionCode.esriLicenseExtensionCodeNetwork)) naStatus = aoInitialize.CheckOutExtension(esriLicenseExtensionCode.esriLicenseExtensionCodeNetwork); gpUtil = new GPUtilitiesClass(); // OSM Dataset Param IGPParameter osmDatasetParam = paramvalues.get_Element(in_osmFeatureDataset) as IGPParameter; IDEDataset2 osmDEDataset = gpUtil.UnpackGPValue(osmDatasetParam) as IDEDataset2; if (osmDEDataset == null) { message.AddError(120048, string.Format(resourceManager.GetString("GPTools_NullPointerParameterType"), osmDatasetParam.Name)); return; } osmDataset = gpUtil.OpenDatasetFromLocation(((IDataElement)osmDEDataset).CatalogPath) as IDataset; // Network Config File Param IGPParameter osmNetConfigParam = paramvalues.get_Element(in_NetworkConfigurationFile) as IGPParameter; IGPValue osmNetConfigFile = gpUtil.UnpackGPValue(osmNetConfigParam) as IGPValue; if ((osmNetConfigFile == null) || (string.IsNullOrEmpty(osmNetConfigFile.GetAsText()))) { message.AddError(120048, string.Format(resourceManager.GetString("GPTools_NullPointerParameterType"), osmNetConfigParam.Name)); return; } // Target Network Dataset Param IGPParameter ndsParam = paramvalues.get_Element(out_NetworkDataset) as IGPParameter; IDataElement deNDS = gpUtil.UnpackGPValue(ndsParam) as IDataElement; if (deNDS == null) { message.AddError(120048, string.Format(resourceManager.GetString("GPTools_NullPointerParameterType"), ndsParam.Name)); return; } // Create Network Dataset using (NetworkDataset nd = new NetworkDataset(osmNetConfigFile.GetAsText(), osmDataset, deNDS.Name, message, TrackCancel)) { if (nd.CanCreateNetworkDataset()) nd.CreateNetworkDataset(); } } catch (UserCancelException ex) { message.AddWarning(ex.Message); } catch (Exception ex) { message.AddError(120008, ex.Message); #if DEBUG message.AddError(120008, ex.StackTrace); #endif } finally { if (osmDataset != null) ComReleaser.ReleaseCOMObject(osmDataset); if (naStatus == esriLicenseStatus.esriLicenseCheckedOut) aoInitialize.CheckInExtension(esriLicenseExtensionCode.esriLicenseExtensionCodeNetwork); if (gpUtil != null) ComReleaser.ReleaseCOMObject(gpUtil); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); } }
public static IArray <long> Sub(this IArray <long> self, IArray <long> other) { return(self.Zip(other, MathOps.Subtract)); }
//////////////////////////////////////////////////////////////////////// // METHOD: PopulateAOIListUsingOverlapFeatureClass private bool PopulateAOIListUsingOverlapFeatureClass(IJTXJob2 pParentJob, ref IArray aoiList) { try { // Make sure all the information exists to get the data workspace if (pParentJob.ActiveDatabase == null) { MessageBox.Show("Unable to proceed: Please set the data workspace for this job."); return false; } if (pParentJob.AOIExtent == null) { MessageBox.Show("Unable to proceed: Please assign the AOI for this job."); return false; } // Get the feature workspace from the current data workspace IJTXDatabase2 pJTXDB = (IJTXDatabase2)m_ipDatabase; string activeDBID = pParentJob.ActiveDatabase.DatabaseID; IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)pJTXDB.GetDataWorkspace(activeDBID, pParentJob.VersionExists() ? pParentJob.VersionName : ""); if (featureWorkspace == null) { MessageBox.Show("Unable to connect to Data Workspace"); return false; } IFeatureClass featureClass = null; try { featureClass = featureWorkspace.OpenFeatureClass(m_AOIOverlapFeatureClassName); } catch (Exception ex) { MessageBox.Show("Unable to connect to feature class to generate AOIs: " + m_AOIOverlapFeatureClassName + "\n Error: " + ex.ToString()); return false; } // Get all features that intersect the parent job's AOI // // Note: The parent job's AOI is shrunk very slightly so features that merely adjoin the parent's AOI // are *not* returned. Only features that have some part of their actual area intersecting the parent's // AOI are returned. ISpatialFilter spatialFilter = new SpatialFilterClass(); ITopologicalOperator topOp = (ITopologicalOperator)pParentJob.AOIExtent; IPolygon slightlySmallerExtent = (IPolygon)topOp.Buffer(-0.0001); spatialFilter.Geometry = slightlySmallerExtent; spatialFilter.GeometryField = featureClass.ShapeFieldName; spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; IFeatureCursor featureCursor = featureClass.Search(spatialFilter, false); aoiList = new ArrayClass(); IFeature feature = null; while ((feature = featureCursor.NextFeature()) != null) { aoiList.Add(feature.Shape); } // Explicitly release the cursor. Marshal.ReleaseComObject(featureCursor); } catch (Exception ex) { throw new Exception("Unable to create AOIs based on feature class: " + m_AOIOverlapFeatureClassName + ". " + ex.ToString()); } return true; }
public static IArray <long> Sub(this IArray <long> self, long scalar) { return(self.Select(x => x.Subtract(scalar))); }
public InstructionArrayReader(IArray<Instruction> Instructions) { this.Instructions = Instructions; }
public static IArray <long> Sub(this long self, IArray <long> vector) { return(vector.Select(x => self.Subtract(x))); }
public override bool Read() { var x = MySQL.API.mysql_fetch_array(queryResult, MySQL.API.FetchArrayResult.MYSQL_BOTH); var e = Expando.Of(x); //Console.WriteLine(e.TypeString); if (e.IsArray) { cursor = x; if (cursor != null) if (cursor.Length > 0) { return true; } } return false; /* if (__state == 0) { __state = 1; //cursor.moveToFirst(); __index = 0; // move to first } else { //cursor.moveToNext(); __index++; // move to next } return __index < cursor.Length; //!(cursor.isAfterLast()); * */ }
public static IArray <long> Div(this IArray <long> self, IArray <long> other) { return(self.Zip(other, MathOps.Divide)); }