public static SqlBinary IconTile(SqlBinary image, SqlInt32 zoom, SqlDouble Lon, SqlDouble Lat, SqlInt32 xTile, SqlInt32 yTile, SqlDouble scale) { SqlBinary result = null; using (Icon2TileRendering paster = new Icon2TileRendering()) { using (MemoryStream ms = new MemoryStream()) { ms.Write(image.Value, 0, image.Length); SetBeginPosition(ms); paster.PasteFromStreamScaledImageToTile((int)zoom, (double)Lon, (double)Lat, (int)xTile, (int)yTile, (double)scale, ms); result = paster.GetBytes(); } } return result; }
public AllDistanceMetrics(String f, String t, Double h, Double jac, Double jaro, Double jarow, Double lev, Double levllow, Double levhigh, Double levnorm, Double overlap, Double ratcliff, Double diceIndex, Double diceDistance, Double tanimoto) { fromString = new SqlString(f); toString = new SqlString(t); Hamming_Distance = new SqlDouble(h); Jaccard_Distance = new SqlDouble(jac); Jaro_Distance = new SqlDouble(jaro); Jaro_Winkler_Distance = new SqlDouble(jarow); Levenshtein_Distance = new SqlDouble(lev); Levenshtein_Distance_Lower_Bound = new SqlDouble(levllow); Levenshtein_Distance_Upper_Bound = new SqlDouble(levhigh); Normalized_Levenshtein_Distance = new SqlDouble(levnorm); Overlap_Coefficient = new SqlDouble(overlap); Ratcliff_Obershelp_Similarity = new SqlDouble(ratcliff); Sorensen_Dice_Index = new SqlDouble(diceIndex); Sorensen_Dice_Distance = new SqlDouble(diceDistance); Tanimoto_Coefficient = new SqlDouble(tanimoto); }
public static SqlGeometry GetImageBound(SqlDouble Longitude, SqlDouble Latitude, SqlInt32 Width, SqlInt32 Height, SqlDouble Zoom, SqlInt32 PixelYOffset) { long cpX, cpY, LeftTopX, LeftTopY, RightBottomX, RightBottomY; long halfWidth = ((long) Width) >> 1; long halfHeight = ((long) Height) >> 1; double dZoom = (double) Zoom; // получить центральный пиксел по коорд cpX = (long) FromLongitudeToXPixel(Longitude, Zoom); cpY = (long) (FromLatitudeToYPixel(Latitude, Zoom) + PixelYOffset); LeftTopX = cpX - halfWidth; LeftTopY = cpY - halfHeight; RightBottomX = cpX + halfWidth; RightBottomY = cpY + halfHeight; double Lat1, Lon1, Lat2, Lon2; Lat1 = FromYPixelToLat(LeftTopY, dZoom); Lon1 = FromXPixelToLon(LeftTopX, dZoom); Lat2 = FromYPixelToLat(RightBottomY, dZoom); Lon2 = FromXPixelToLon(RightBottomX, dZoom); // var geomBuilder = new SqlGeometryBuilder(); geomBuilder.SetSrid((0)); geomBuilder.BeginGeometry(OpenGisGeometryType.Polygon); geomBuilder.BeginFigure(Lon1, Lat1); geomBuilder.AddLine(Lon1, Lat2); geomBuilder.AddLine(Lon2, Lat2); geomBuilder.AddLine(Lon2, Lat1); geomBuilder.AddLine(Lon1, Lat1); geomBuilder.EndFigure(); geomBuilder.EndGeometry(); return geomBuilder.ConstructedGeometry; }
public void Accumulate(SqlDouble Value) { if(Value.IsNull == false) { _sum += Value.Value; } }
public void Accumulate(SqlDouble input) { if (input.IsNull != true) { doubleList.Add(input.Value); } }
public static object Box(SqlDouble a) { if (a.IsNull) return null; else return a.Value; }
public static void String_Distances_Filler(object distances, out SqlString fromString, out SqlString toString, out SqlDouble Hamming_Distance, out SqlDouble Jaccard_Distance, out SqlDouble Jaro_Distance, out SqlDouble Jaro_Winkler_Distance, out SqlDouble Levenshtein_Distance, out SqlDouble Levenshtein_Distance_Lower_Bound, out SqlDouble Levenshtein_Distance_Upper_Bound, out SqlDouble Normalized_Levenshtein_Distance, out SqlDouble Overlap_Coefficient, out SqlDouble Ratcliff_Obershelp_Similarity, out SqlDouble Sorensen_Dice_Index, out SqlDouble Sorensen_Dice_Distance, out SqlDouble Tanimoto_Coefficient) { AllDistanceMetrics adm = (AllDistanceMetrics)distances; fromString = adm.fromString; toString = adm.toString; Hamming_Distance = adm.Hamming_Distance; Jaccard_Distance = adm.Jaccard_Distance; Jaro_Distance = adm.Jaro_Distance; Jaro_Winkler_Distance = adm.Jaro_Winkler_Distance; Levenshtein_Distance = adm.Levenshtein_Distance; Levenshtein_Distance_Lower_Bound = adm.Levenshtein_Distance_Lower_Bound; Levenshtein_Distance_Upper_Bound = adm.Levenshtein_Distance_Upper_Bound; Normalized_Levenshtein_Distance = adm.Normalized_Levenshtein_Distance; Overlap_Coefficient = adm.Overlap_Coefficient; Ratcliff_Obershelp_Similarity = adm.Ratcliff_Obershelp_Similarity; Sorensen_Dice_Index = adm.Sorensen_Dice_Index; Sorensen_Dice_Distance = adm.Sorensen_Dice_Distance; Tanimoto_Coefficient = adm.Tanimoto_Coefficient; }
public void Accumulate(SqlDouble Value) { if (Value.IsNull == false) { _list.Add(Value.Value); } }
public void Create() { SqlDouble Test = new SqlDouble(34.87); Assert.Equal(34.87D, Test.Value); Test = new SqlDouble(-9000.6543); Assert.Equal(-9000.6543D, Test.Value); }
public void Create () { SqlDouble Test = new SqlDouble ((double) 34.87); Assert.AreEqual (34.87D, Test.Value, "#A01"); Test = new SqlDouble (-9000.6543); Assert.AreEqual (-9000.6543D, Test.Value, "#A02"); }
public void Create() { SqlDouble Test= new SqlDouble ((double)34.87); AssertEquals ("#A01", 34.87D, Test.Value); Test = new SqlDouble (-9000.6543); AssertEquals ("#A02", -9000.6543D, Test.Value); }
public static SqlInt64 FromLatitudeToYPixel(SqlDouble Latitude, SqlDouble zoomLevel) { var pixelGlobeSize = PixelTileSize*Math.Pow(2.0, (double) zoomLevel); var f = Math.Min(Math.Max(Math.Sin((double) (Latitude*RadiansToDegreesRatio)), -0.9999d), 0.9999d); var y = Math.Round(Convert.ToSingle(pixelGlobeSize/2d) + .5d*Math.Log((1d + f)/(1d - f))*-(pixelGlobeSize/(2d*Math.PI))); return Convert.ToInt64(y); }
public void Properties () { SqlDouble Test5443 = new SqlDouble (5443e12); SqlDouble Test1 = new SqlDouble (1); Assert.IsTrue (SqlDouble.Null.IsNull, "#C01"); Assert.AreEqual (5443e12, Test5443.Value, "#C02"); Assert.AreEqual ((double) 1, Test1.Value, "#C03"); }
public void Properties() { SqlDouble Test5443 = new SqlDouble(5443e12); SqlDouble Test1 = new SqlDouble(1); Assert.True(SqlDouble.Null.IsNull); Assert.Equal(5443e12, Test5443.Value); Assert.Equal(1, Test1.Value); }
public void Properties() { SqlDouble Test5443 = new SqlDouble (5443e12); SqlDouble Test1 = new SqlDouble (1); Assert ("#C01", SqlDouble.Null.IsNull); AssertEquals ("#C02", 5443e12, Test5443.Value); AssertEquals ("#C03", (double)1, Test1.Value); }
public void Accumulate(SqlDouble Value) { // normalise value, divide by 100 Value = System.Data.SqlTypes.SqlDouble.Divide(Value, new SqlDouble(100)); // -x var negated = System.Data.SqlTypes.SqlDouble.Multiply(new SqlDouble(-1),Value); // 1-x var oneMinus = System.Data.SqlTypes.SqlDouble.Add(new SqlDouble(1), negated); complementProduct = System.Data.SqlTypes.SqlDouble.Multiply(complementProduct, oneMinus); }
public void Accumulate(SqlDouble Value) { // normalise value, divide by 100 Value = System.Data.SqlTypes.SqlDouble.Divide(Value, new SqlDouble(100)); // -x var negated = System.Data.SqlTypes.SqlDouble.Multiply(new SqlDouble(-1), Value); // 1-x var oneMinus = System.Data.SqlTypes.SqlDouble.Add(new SqlDouble(1), negated); complementProduct = System.Data.SqlTypes.SqlDouble.Multiply(complementProduct, oneMinus); }
public void Accumulate(SqlDouble FirstValue, SqlDouble SecondValue) { // Put your code here if (FirstValue.IsNull != true && SecondValue.IsNull != true) { this.firstList.Add(FirstValue.Value); this.sumOfFirst += Convert.ToDecimal(FirstValue.Value); this.secondList.Add(SecondValue.Value); this.sumOfSecond += Convert.ToDecimal(SecondValue.Value); } }
/// <summary> /// Builds multipoligon by each polygon inside geometry collection /// </summary> public static void BuildMultipolygonSimplified(SqlGeometryBuilder builder, SqlGeometry shape, SqlDouble shortestDistance) { builder.BeginGeometry(OpenGisGeometryType.MultiPolygon); var polygonCount = shape.STNumGeometries(); for (int i = 1; i <= polygonCount; i++) { BuildPolygonSimplified(builder, shape.STGeometryN(i), shortestDistance); } // End the geometry builder.EndGeometry(); }
public static void GetEventData_FillRow(object source, out SqlInt32 seriesID, out SqlString characteristic, out DateTime time, out SqlDouble value) { DataPoint dataPoint = source as DataPoint; if ((object)dataPoint == null) throw new InvalidOperationException("FillRow source is not a DataPoint"); seriesID = dataPoint.SeriesID; characteristic = dataPoint.Characteristic; time = dataPoint.Time; value = ToSqlDouble(dataPoint.Value); }
public void Accumulate(SqlDouble FirstValue, SqlDouble SecondValue) { // Put your code here if (FirstValue.IsNull != true && SecondValue.IsNull != true) { this.sumOfSquaresOfFirst += Convert.ToDecimal(FirstValue.Value) * Convert.ToDecimal(FirstValue.Value); this.sumOfSquaresOfSecond += Convert.ToDecimal(SecondValue.Value) * Convert.ToDecimal(SecondValue.Value); this.sumOfFirst += Convert.ToDecimal(FirstValue.Value); this.sumOfSecond += Convert.ToDecimal(SecondValue.Value); this.coProduct += Convert.ToDecimal(FirstValue.Value) * Convert.ToDecimal(SecondValue.Value); this.numberOfRecords++; } }
public static SqlString FormatCurrency(SqlDouble Amount, SqlString culture) { string _culture; if (culture.IsNull == true) { _culture = CultureInfo.CurrentCulture.Name; } else { _culture = culture.Value; } try { CultureInfo ci = new CultureInfo(_culture); return new SqlString(Amount.Value.ToString("C", ci)); } catch (CultureNotFoundException) { return new SqlString("Invalid culture '" + culture.Value + "'"); } }
public void Accumulate(SqlDouble value, SqlInt16 percentile) { // Put your code here if (value.IsNull != true) { doubleList.Add(value.Value); } if (percentile.IsNull != true) { if (percentile.Value > 100) { this.percentile = 100; } else { this.percentile = percentile.Value; } } }
public static SqlGeometry ExcludeShortLine(SqlGeometry shape, SqlDouble shortestDistance) { // Begin the geometry SqlGeometryBuilder _builder = new SqlGeometryBuilder(); _builder.SetSrid(0); if (shape == null) return null; switch (GetOpenGisGeometryType(shape)) { case OpenGisGeometryType.GeometryCollection: return CreateMultiPolygonFromGeometryCollectionWithExcludingLineString(shape); case OpenGisGeometryType.LineString: case OpenGisGeometryType.MultiLineString: // _builder.Dispose(); //EndGeometry(); return shape; case OpenGisGeometryType.MultiPolygon: BuildMultipolygonSimplified(_builder, shape, shortestDistance); break; case OpenGisGeometryType.Polygon: BuildPolygonSimplified(_builder, shape, shortestDistance); break; default: return shape; } // Return the constructed geometry var resultGeometry = _builder.ConstructedGeometry; if (resultGeometry.STIsValid()) return resultGeometry; else { return CreateMultiPolygonFromGeometryCollectionWithExcludingLineString(resultGeometry.MakeValid()); } }
// <summary> /// Calculates the product of the previous values and the value received /// </summary> /// <param name="number">Value to include</param> public void Accumulate(System.Data.SqlTypes.SqlDouble number) { if (this.ValueCount == 0) { // if this is the first value received this.Product = number; } else if (this.Product.IsNull) { //if the calculated value is null, stay that way } else if (number.IsNull) { //if the value is null the result is null this.Product = System.Data.SqlTypes.SqlDouble.Null; } else { //multiply the values this.Product = System.Data.SqlTypes.SqlDouble.Multiply(this.Product, number); } this.ValueCount++; }
public void Accumulate(SqlDouble FirstValue) { // Put your code here if (FirstValue.IsNull != true) { int n1 = this.n; this.n++; decimal delta = Convert.ToDecimal(FirstValue.Value) - this.mean; decimal delta_n = delta / Convert.ToDecimal(this.n); decimal delta_n2 = delta_n * delta_n; decimal term1 = delta * delta_n * Convert.ToDecimal(n1); this.mean += delta_n; if (n1 > 0) { this.m4 += term1 * delta_n2 * ( Convert.ToDecimal(n*n) - Convert.ToDecimal(3 * this.n) + Convert.ToDecimal(3) ) + Convert.ToDecimal(6) * delta_n2 * this.m2 - Convert.ToDecimal(4) * delta_n * this.m3; this.m3 += term1 * delta_n * Convert.ToDecimal(n - 2) - Convert.ToDecimal(3) * delta_n * this.m2; this.m2 += this.m2 + term1; } } }
public SqlDouble Adjust(SqlDouble value) { if (SqlDbType.Float != SqlDbType) ThrowInvalidType(); return value; }
/// <summary> /// Purpose: Select method. This method will Select one existing row from the database, based on the Primary Key. /// </summary> /// <returns>DataTable object if succeeded, otherwise an Exception is thrown. </returns> /// <remarks> /// Properties needed for this method: /// <UL> /// <LI>NPayrollID</LI> /// <LI>NEmployeeID</LI> /// </UL> /// Properties set after a succesful call of this method: /// <UL> /// <LI>ErrorCode</LI> /// <LI>NPayrollID</LI> /// <LI>NEmployeeID</LI> /// <LI>NNormalOT</LI> /// <LI>NPublicHolidayOT</LI> /// <LI>NOffDayOT</LI> /// <LI>NPartTimeWorkHours</LI> /// <LI>NALEntitlementHours</LI> /// <LI>NPHEntitlementHours</LI> /// <LI>MServiceReimbursements</LI> /// <LI>NTotalLateness</LI> /// <LI>NUnpaidAL</LI> /// <LI>NUnpaidTO</LI> /// <LI>NUnpaidMedical</LI> /// <LI>MCommission</LI> /// <LI>MCommissionLatenessPenalty</LI> /// </UL> /// Will fill all properties corresponding with a field in the table with the value of the row selected. /// </remarks> public override DataTable SelectOne() { SqlCommand cmdToExecute = new SqlCommand(); cmdToExecute.CommandText = "dbo.[sp_tblPayrollEntries_SelectOne]"; cmdToExecute.CommandType = CommandType.StoredProcedure; DataTable toReturn = new DataTable("tblPayrollEntries"); SqlDataAdapter adapter = new SqlDataAdapter(cmdToExecute); // Use base class' connection object cmdToExecute.Connection = _mainConnection; try { cmdToExecute.Parameters.Add(new SqlParameter("@inPayrollID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, _nPayrollID)); cmdToExecute.Parameters.Add(new SqlParameter("@inEmployeeID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, _nEmployeeID)); cmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, _errorCode)); if(_mainConnectionIsCreatedLocal) { // Open connection. _mainConnection.Open(); } else { if(_mainConnectionProvider.IsTransactionPending) { cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction; } } // Execute query. adapter.Fill(toReturn); _errorCode = (SqlInt32)cmdToExecute.Parameters["@iErrorCode"].Value; if(_errorCode != (int)LLBLError.AllOk) { // Throw error. throw new Exception("Stored Procedure 'sp_tblPayrollEntries_SelectOne' reported the ErrorCode: " + _errorCode); } if(toReturn.Rows.Count > 0) { _nPayrollID = (Int32)toReturn.Rows[0]["nPayrollID"]; _nEmployeeID = (Int32)toReturn.Rows[0]["nEmployeeID"]; _nNormalOT = toReturn.Rows[0]["nNormalOT"] == System.DBNull.Value ? SqlDouble.Null : (double)toReturn.Rows[0]["nNormalOT"]; _nPublicHolidayOT = toReturn.Rows[0]["nPublicHolidayOT"] == System.DBNull.Value ? SqlDouble.Null : (double)toReturn.Rows[0]["nPublicHolidayOT"]; _nOffDayOT = toReturn.Rows[0]["nOffDayOT"] == System.DBNull.Value ? SqlDouble.Null : (double)toReturn.Rows[0]["nOffDayOT"]; _nPartTimeWorkHours = toReturn.Rows[0]["nPartTimeWorkHours"] == System.DBNull.Value ? SqlDouble.Null : (double)toReturn.Rows[0]["nPartTimeWorkHours"]; _nALEntitlementHours = toReturn.Rows[0]["nALEntitlementHours"] == System.DBNull.Value ? SqlDouble.Null : (double)toReturn.Rows[0]["nALEntitlementHours"]; _nPHEntitlementHours = toReturn.Rows[0]["nPHEntitlementHours"] == System.DBNull.Value ? SqlDouble.Null : (double)toReturn.Rows[0]["nPHEntitlementHours"]; _mServiceReimbursements = toReturn.Rows[0]["mServiceReimbursements"] == System.DBNull.Value ? SqlMoney.Null : (Decimal)toReturn.Rows[0]["mServiceReimbursements"]; _nTotalLateness = toReturn.Rows[0]["nTotalLateness"] == System.DBNull.Value ? SqlDouble.Null : (double)toReturn.Rows[0]["nTotalLateness"]; _nUnpaidAL = toReturn.Rows[0]["nUnpaidAL"] == System.DBNull.Value ? SqlDouble.Null : (double)toReturn.Rows[0]["nUnpaidAL"]; _nUnpaidTO = toReturn.Rows[0]["nUnpaidTO"] == System.DBNull.Value ? SqlDouble.Null : (double)toReturn.Rows[0]["nUnpaidTO"]; _nUnpaidMedical = toReturn.Rows[0]["nUnpaidMedical"] == System.DBNull.Value ? SqlDouble.Null : (double)toReturn.Rows[0]["nUnpaidMedical"]; _mCommission = toReturn.Rows[0]["mCommission"] == System.DBNull.Value ? SqlMoney.Null : (Decimal)toReturn.Rows[0]["mCommission"]; _mCommissionLatenessPenalty = toReturn.Rows[0]["mCommissionLatenessPenalty"] == System.DBNull.Value ? SqlMoney.Null : (Decimal)toReturn.Rows[0]["mCommissionLatenessPenalty"]; } return toReturn; } catch(Exception ex) { // some error occured. Bubble it to caller and encapsulate Exception object throw new Exception("TblPayrollEntries::SelectOne::Error occured.", ex); } finally { if(_mainConnectionIsCreatedLocal) { // Close connection. _mainConnection.Close(); } cmdToExecute.Dispose(); adapter.Dispose(); } }
public void SqlDoubleToSqlByte() { SqlDouble TestDouble64 = new SqlDouble(64); SqlDouble TestDouble900 = new SqlDouble(900); Assert.AreEqual((byte)64, ((SqlByte)TestDouble64).Value, "SqlDecimalToByte" + Error); try { SqlByte test = (SqlByte)TestDouble900; Assert.Fail("SqlDoubleToByte 2" + Error); } catch (Exception e) { Assert.AreEqual(typeof(OverflowException), e.GetType(), "OverflowException"); } }
public void SqlDoubleToSqlInt64 () { SqlDouble TestDouble64 = new SqlDouble (64); SqlDouble TestDouble900 = new SqlDouble (90000); Assert.AreEqual ((long) 64, ((SqlInt64) TestDouble64).Value, "#Z01"); Assert.AreEqual (SqlInt64.Null, ((SqlInt64) SqlDouble.Null), "#Z02"); try { SqlInt64 test = (SqlInt64) SqlDouble.MaxValue; Assert.Fail ("#Z03"); } catch (OverflowException e) { Assert.AreEqual (typeof (OverflowException), e.GetType (), "#Z04"); } }
public void Init() { complementProduct = new SqlDouble(1); }
public void Merge(IndependentProject Group) { complementProduct = System.Data.SqlTypes.SqlDouble.Multiply(complementProduct, Group.complementProduct); }
public static void FillRow(object inputObject, out SqlInt32 fileId, out SqlString ctn, out SqlString platform, out SqlString platformId, out SqlDouble frequency, out DateTime timeStamp) { var row = (Row) inputObject; fileId = row.FileId; ctn = row.Collar.Ctn; platform = row.Collar.Platform; platformId = row.Collar.PlatformId; frequency = row.Collar.Frequency; timeStamp = row.Collar.TimeStamp; }
public void Accumulate(SqlDouble Value) { if (start) { min = Value; max = Value; start = false; } else { if (Value < min) min = Value; if (Value > max) max = Value; result = max - min; } }