public FormattedCoordinatesDto GetFormattedCoordinateDescription(CoordinateFormat format, double latitude, double longitude) { FormattedCoordinatesDto formattedCoordinatesDto; if (format == CoordinateFormat.DD) { formattedCoordinatesDto = FormatDD(latitude, longitude); } else if (format == CoordinateFormat.DDM) { formattedCoordinatesDto = FormatDDM(latitude, longitude); } else if (format == CoordinateFormat.DMS) { formattedCoordinatesDto = FormatDMS(latitude, longitude); } else if (format == CoordinateFormat.UTM) { formattedCoordinatesDto = FormatUTM(latitude, longitude); } else { formattedCoordinatesDto = new FormattedCoordinatesDto(); formattedCoordinatesDto.success = false; formattedCoordinatesDto.error = "Unknown format"; } return(formattedCoordinatesDto); }
/// <summary> /// Creates a new <see cref="ConfigurationCell"/> from serialization parameters. /// </summary> /// <param name="info">The <see cref="SerializationInfo"/> with populated with data.</param> /// <param name="context">The source <see cref="StreamingContext"/> for this deserialization.</param> protected ConfigurationCell(SerializationInfo info, StreamingContext context) : base(info, context) { // Deserialize configuration cell m_coordinateFormat = (CoordinateFormat)info.GetValue("coordinateFormat", typeof(CoordinateFormat)); m_statusFlags = info.GetUInt16("statusFlags"); }
public static Coordinate ParseCoordinate(string geoExpr, CoordinateFormat format = CoordinateFormat.LatitudeThenLongtitude) { var latLongMatches = decimalRegex.Matches(geoExpr); double firstValue = -1; double secondValue = -1; if (latLongMatches.Count > 1) { firstValue = double.Parse(latLongMatches[0].Value, CultureInfo.InvariantCulture); secondValue = double.Parse(latLongMatches[1].Value, CultureInfo.InvariantCulture); } latLongMatches = degreeRegex.Matches(geoExpr); if (latLongMatches.Count > 1) { firstValue = ParseGeoExpr(latLongMatches[0].Value); secondValue = ParseGeoExpr(latLongMatches[1].Value); } if (firstValue > 0 && secondValue > 0) { if (format == CoordinateFormat.LatitudeThenLongtitude) { return new Coordinate { Latitude = firstValue, Longtitude = secondValue }; } else { return new Coordinate { Latitude = secondValue, Longtitude = firstValue }; } } return null; }
/// <summary> /// Parse an ATCF DateTime formatted string and convert it to a .NET DateTime. (yyyymmddhh) /// </summary> /// <param name="ATCFDTFormatString">ATCF formatted string</param> /// <returns>The DateTime you selected.</returns> public static DateTime ParseATCFDateTime(string ATCFDTFormatString, CoordinateFormat AF = CoordinateFormat.HURDAT2) { try { switch (AF) { case CoordinateFormat.ATCF: return(ParseATCFDateTime_ATCF(ATCFDTFormatString)); case CoordinateFormat.HURDAT2: return(ParseATCFDateTime_HURDAT2(ATCFDTFormatString)); } return(new DateTime(240, 11, 16, 1, 33, 22)); // failure state (Pre-V3) } catch (FormatException err) { #if DEBUG Error.Throw("Error!", $"Attempted to convert an invalid HURDAT2-format DateTime.\n\n{err}", ErrorSeverity.Error, 345); return(new DateTime(240, 11, 16, 1, 33, 22)); // pre-v3 #else Error.Throw("Error!", "Attempted to convert an invalid HURDAT2-format DateTime.", ErrorSeverity.Error, 345); return(new DateTime(240, 11, 16, 1, 33, 22)); // pre-v3 #endif } }
/// <summary> /// Creates a new <see cref="ConfigurationCell"/> from specified parameters. /// </summary> /// <param name="parent">The reference to parent <see cref="ConfigurationFrame"/> of this <see cref="ConfigurationCell"/>.</param> /// <param name="idCode">The numeric ID code for this <see cref="ConfigurationCell"/>.</param> /// <param name="isVirtual">Assigns flag that determines if this <see cref="ConfigurationCell"/> is virtual.</param> public ConfigurationCell(ConfigurationFrame parent, ushort idCode, bool isVirtual) : base(parent, idCode, int.MaxValue, int.MaxValue, int.MaxValue) { m_signalReferences = new Dictionary<SignalType, string[]>(); m_analogDataFormat = DataFormat.FloatingPoint; m_frequencyDataFormat = DataFormat.FloatingPoint; m_phasorDataFormat = DataFormat.FloatingPoint; m_phasorCoordinateFormat = CoordinateFormat.Polar; m_isVirtual = isVirtual; }
/// <summary> /// Creates a new <see cref="ConfigurationCell"/> from specified parameters. /// </summary> /// <param name="parent">The reference to parent <see cref="ConfigurationFrame"/> of this <see cref="ConfigurationCell"/>.</param> /// <param name="idCode">The numeric ID code for this <see cref="ConfigurationCell"/>.</param> public ConfigurationCell(ConfigurationFrame parent, ushort idCode) : base(parent, idCode, int.MaxValue, int.MaxValue, int.MaxValue) { // Create a cached signal reference dictionary for generated signal references m_generatedSignalReferenceCache = new string[Enum.GetValues(typeof(SignalKind)).Length][]; m_analogDataFormat = DataFormat.FloatingPoint; m_frequencyDataFormat = DataFormat.FloatingPoint; m_phasorDataFormat = DataFormat.FloatingPoint; m_phasorCoordinateFormat = CoordinateFormat.Polar; }
/// <summary> /// Creates a new <see cref="ConfigurationCell"/> from serialization parameters. /// </summary> /// <param name="info">The <see cref="SerializationInfo"/> with populated with data.</param> /// <param name="context">The source <see cref="StreamingContext"/> for this deserialization.</param> protected ConfigurationCell(SerializationInfo info, StreamingContext context) : base(info, context) { // Create a cached signal reference dictionary for generated signal references m_generatedSignalReferenceCache = new string[Enum.GetValues(typeof(SignalKind)).Length][]; // Deserialize configuration cell m_lastReportTime = info.GetInt64("lastReportTime"); m_analogDataFormat = (DataFormat)info.GetValue("analogDataFormat", typeof(DataFormat)); m_frequencyDataFormat = (DataFormat)info.GetValue("frequencyDataFormat", typeof(DataFormat)); m_phasorDataFormat = (DataFormat)info.GetValue("phasorDataFormat", typeof(DataFormat)); m_phasorCoordinateFormat = (CoordinateFormat)info.GetValue("phasorCoordinateFormat", typeof(CoordinateFormat)); }
/// <summary> /// Returns a string that contains the latitude and longitude in the specified format /// </summary> /// <returns> /// A string that contains the latitude longitude and altitude, separated by a comma. /// </returns> public string ToString(CoordinateFormat coordinateFormat) { switch (coordinateFormat) { case CoordinateFormat.Decimal: return(this.ToString()); case CoordinateFormat.DMS: return(ConvertPositionToDMS()); default: throw new ArgumentOutOfRangeException(nameof(coordinateFormat)); } }
/// <summary> /// Creates a new instance of the <see cref="AnalogChannel"/>. /// </summary> public AnalogChannel() { m_phaseDesignation = char.MinValue; m_signalKind = SignalKind.Analog; m_coordinateFormat = CoordinateFormat.Polar; m_multipler = 0.04; m_adder = 0.0; m_nominalFrequency = 60.0D; m_minValue = -99999; m_maxValue = 99998; m_primaryRatio = 1.0; m_secondaryRatio = 1.0; m_scalingIdentifier = 'P'; }
/// <summary> /// Merge /// </summary> /// <param name="AtcfString"></param> /// <returns></returns> public static Coordinate FromString_ATCF(string AtcfString, CoordinateFormat AF = CoordinateFormat.ATCF) { Coordinate Coord = new Coordinate(); // convert to "real" format. string[] CoordinateComponents = AtcfString.Split(','); if (CoordinateComponents.Length > 2 || CoordinateComponents.Length == 0) { Error.Throw("Error!", "Cannot convert an invalid coordinate!", ErrorSeverity.Error, 243); return(null); // not successful - PRE 3.0 } string CoordinateComponents1 = CoordinateComponents[0]; string CoordinateComponents2 = CoordinateComponents[1]; string PreNumericalComponent1 = CoordinateComponents1.Substring(0, CoordinateComponents1.Length - 1); string PreNumericalComponent2 = CoordinateComponents2.Substring(0, CoordinateComponents2.Length - 1); string CardinalDirection1 = CoordinateComponents1.Substring(CoordinateComponents1.Length - 1); string CardinalDirection2 = CoordinateComponents2.Substring(CoordinateComponents2.Length - 1); double Coord1 = Convert.ToDouble(PreNumericalComponent1); double Coord2 = Convert.ToDouble(PreNumericalComponent2); // ATCF format does not include decimal points and uses 1 d.p. of precision... if (AF == CoordinateFormat.ATCF) { Coord1 /= 10.0; Coord2 /= 10.0; } CardinalDirection CD1 = (CardinalDirection)Enum.Parse(typeof(CardinalDirection), CardinalDirection1); CardinalDirection CD2 = (CardinalDirection)Enum.Parse(typeof(CardinalDirection), CardinalDirection2); // we can't even use the standard methods because ATCF has to be so f*****g special Coord.Coordinates = new Point(Coord2, Coord1); Coord.Directions.Add(CD2); Coord.Directions.Add(CD1); return(Coord); }
protected string LocationToString(MapPoint location, CoordinateFormat coordinateFormat) { switch (coordinateFormat) { case CoordinateFormat.DecimalDegrees: return(ConvertCoordinate.ToDecimalDegrees(location, 5)); case CoordinateFormat.DegreesDecimalMinutes: return(ConvertCoordinate.ToDegreesDecimalMinutes(location, 3)); case CoordinateFormat.Dms: return(ConvertCoordinate.ToDegreesMinutesSeconds(location, 1)); case CoordinateFormat.Mgrs: return(ConvertCoordinate.ToMgrs(location, MgrsConversionMode.Automatic, 5, true, true)); } return(null); }
public bool CorrectMinuteOrSecondIs60(CoordinateFormat latlongFormat) { switch (latlongFormat) { // nothing to do case CoordinateFormat.D: return(true); case CoordinateFormat.DM: { // check if min is 60 if (MinuteOrSecondIs60(DecimalMinutes, _round6) == 1) { Degrees += 1; Minutes = 0; } return(true); } case CoordinateFormat.DMS: { // check if sec is 60 if (MinuteOrSecondIs60(DecimalSeconds, _round4) == 1) { Minutes += 1; DecimalSeconds = 0; // cascades? if (Minutes == 60) { Degrees += 1; Minutes = 0; } } return(true); } default: return(false); } }
/// <summary> /// Convert a string to a coordinate. /// </summary> /// <param name="Str">The string you wish to convert to a coordinate.</param> /// <param name="CoordinateFormat"></param> /// <returns></returns> public static Coordinate FromString(string Str, CoordinateFormat CoordinateFormat) { try { switch (CoordinateFormat) { case CoordinateFormat.TrackMaker: return(FromString_TrackMaker(Str)); case CoordinateFormat.ATCF: return(FromString_ATCF(Str)); case CoordinateFormat.HURDAT2: return(FromString_ATCF(Str, CoordinateFormat.HURDAT2)); } } catch (ArgumentException err) { #if DEBUG Error.Throw("Error", $"An error has occurred.\nError converting from string to coordinate.\n\n{err}", ErrorSeverity.Error, 71); #else Error.Throw("Error", "An error has occurred.\nError converting from string to coordinate.", ErrorSeverity.Error, 71); #endif return(null); } catch (OverflowException err) { #if DEBUG Error.Throw("Error", $"An error has occurred.\nError converting from string to coordinate.\nA value was too small or large.\n\n{err}", ErrorSeverity.Error, 72); #else Error.Throw("Error", "An error has occurred.\nError converting from string to coordinate. A value was too small or large.", ErrorSeverity.Error, 72); #endif return(null); } // should not occur return(null); }
public static Coordinate ParseCoordinate(string geoExpr, CoordinateFormat format = CoordinateFormat.LatitudeThenLongtitude) { var latLongMatches = decimalRegex.Matches(geoExpr); double firstValue = -1; double secondValue = -1; if (latLongMatches.Count > 1) { firstValue = double.Parse(latLongMatches[0].Value, CultureInfo.InvariantCulture); secondValue = double.Parse(latLongMatches[1].Value, CultureInfo.InvariantCulture); } latLongMatches = degreeRegex.Matches(geoExpr); if (latLongMatches.Count > 1) { firstValue = ParseGeoExpr(latLongMatches[0].Value); secondValue = ParseGeoExpr(latLongMatches[1].Value); } if (firstValue > 0 && secondValue > 0) { if (format == CoordinateFormat.LatitudeThenLongtitude) { return(new Coordinate { Latitude = firstValue, Longtitude = secondValue }); } else { return(new Coordinate { Latitude = secondValue, Longtitude = firstValue }); } } return(null); }
private static string ConvertCoordinateToString(double p_dbCoordinate , CoordinateFormat p_gpsFormat, bool blnLatitude) { string strCoordinateAsString= ""; // Need to know if N/S E/W - use blnLatitude to distinguish between two types // switch (p_gpsFormat) { case CoordinateFormat.DecimalDegreesNumeric: strCoordinateAsString = p_dbCoordinate.ToString(); break; case CoordinateFormat.DecimalDegrees: // simply convert to String... strCoordinateAsString = Math.Abs(p_dbCoordinate ).ToString(); break; case CoordinateFormat.DegreesMinutesSeconds: // Degrees (°) Minutes (') Seconds (") //N 54 51 0.546000 //W 1 34 55.800000 //double Degrees to Degrees, Minutes & Seconds // F12 = 52.657570305556 // C12 =ABS(TRUNC(F12)) -> degrees // D12 =TRUNC((ABS(F12)-C12)*60) ->minutes //seconds = ((ABS(F12))*3600)-(D12*60)-(C12*3600) ->seconds double dbAbsValue = Math.Abs(p_dbCoordinate ); double dbDegrees =Math.Round(dbAbsValue); if (dbDegrees > dbAbsValue) { dbDegrees -= 1.0; } double dbMinutes = (dbAbsValue - dbDegrees)* 60; if ( dbMinutes < Math.Round((dbAbsValue - dbDegrees)* 60)) { dbMinutes = Math.Round(dbMinutes) -1; } else { dbMinutes = Math.Round(dbMinutes) -1; } double dbSecond = ((dbAbsValue - dbDegrees)*3600) - (dbMinutes*60) ; if (dbSecond > 60) { dbSecond-=60; dbMinutes++; } string strDegrees = dbDegrees.ToString(); string strMinutes = dbMinutes.ToString(); string strSecond = dbSecond.ToString(); strCoordinateAsString = strDegrees + " " + strMinutes + " " + strSecond; break; case CoordinateFormat.DegreesDecimalMinutes: //Degrees & Decimal Minutes //N 54 51.009100000 //W 1 34.930000000 //double Degrees to Degrees & double Minutes = //double minutes =ABS(F12-(TRUNC(F12)))*60 // double part of number * 60 - absoluted... // directional indiactors - >=IF(F12<0,"S","N") // =IF(F13<0,"W","E") break; default: //??? assume GPSCoordFormat.DecimalDegrees strCoordinateAsString = p_dbCoordinate.ToString(); break; } string strCompassID = ""; if (p_gpsFormat != CoordinateFormat.DecimalDegreesNumeric) { if ( blnLatitude) { //N or S if (p_dbCoordinate < 0) { strCompassID="S"; } else { strCompassID="N"; } } else { //E or W if (p_dbCoordinate < 0) { strCompassID="W"; } else { strCompassID="E"; } } } return strCompassID + strCoordinateAsString; }
protected string LocationToString(MapPoint location, CoordinateFormat coordinateFormat) { switch (coordinateFormat) { case CoordinateFormat.DecimalDegrees: return ConvertCoordinate.ToDecimalDegrees(location, 5); case CoordinateFormat.DegreesDecimalMinutes: return ConvertCoordinate.ToDegreesDecimalMinutes(location, 3); case CoordinateFormat.Dms: return ConvertCoordinate.ToDegreesMinutesSeconds(location, 1); case CoordinateFormat.Mgrs: return ConvertCoordinate.ToMgrs(location, MgrsConversionMode.Automatic, 5, true, true); } return null; }
public static void ReadMeshData(Stream stream, Pmo pmo, int MeshNumber = 0) { // Go to mesh position. if (MeshNumber == 0) { stream.Seek(pmo.PMO_StartPosition + pmo.header.MeshOffset0, SeekOrigin.Begin); } else { stream.Seek(pmo.PMO_StartPosition + pmo.header.MeshOffset1, SeekOrigin.Begin); } UInt16 VertCnt = 0xFFFF; while (VertCnt > 0) { MeshChunks meshChunk = new MeshChunks(); meshChunk.MeshNumber = MeshNumber; meshChunk.SectionInfo = Mapping.ReadObject <MeshSection>(stream); // Exit if Vertex Count is zero. if (meshChunk.SectionInfo.VertexCount <= 0) { break; } meshChunk.TextureID = meshChunk.SectionInfo.TextureID; VertexFlags flags = GetFlags(meshChunk.SectionInfo); bool isColorFlagRisen = flags.UniformDiffuseFlag; if (pmo.header.SkeletonOffset != 0) { meshChunk.SectionInfo_opt1 = Mapping.ReadObject <MeshSectionOptional1>(stream); } if (isColorFlagRisen) { meshChunk.SectionInfo_opt2 = Mapping.ReadObject <MeshSectionOptional2>(stream); } if (meshChunk.SectionInfo.TriangleStripCount > 0) { meshChunk.TriangleStripValues = new UInt16[meshChunk.SectionInfo.TriangleStripCount]; for (int i = 0; i < meshChunk.SectionInfo.TriangleStripCount; i++) { meshChunk.TriangleStripValues[i] = stream.ReadUInt16(); } } // Get Formats. CoordinateFormat TexCoordFormat = flags.TextureCoordinateFormat; CoordinateFormat VertexPositionFormat = flags.PositionFormat; CoordinateFormat WeightFormat = flags.WeightFormat; ColorFormat ColorFormat = flags.ColorFormat; UInt32 SkinningWeightsCount = flags.SkinningWeightsCount; BinaryReader r = new BinaryReader(stream); long positionAfterHeader = stream.Position; if (meshChunk.SectionInfo.TriangleStripCount > 0) { int vertInd = 0; for (int p = 0; p < meshChunk.SectionInfo.TriangleStripCount; p++) { for (int s = 0; s < (meshChunk.TriangleStripValues[p] - 2); s++) { if (s % 2 == 0) { meshChunk.Indices.Add(vertInd + s + 0); meshChunk.Indices.Add(vertInd + s + 1); meshChunk.Indices.Add(vertInd + s + 2); } else { meshChunk.Indices.Add(vertInd + s + 0); meshChunk.Indices.Add(vertInd + s + 2); meshChunk.Indices.Add(vertInd + s + 1); } } vertInd += meshChunk.TriangleStripValues[p]; } } else { if (flags.Primitive == PrimitiveType.PRIMITIVE_TRIANGLE_STRIP) { for (int s = 0; s < (meshChunk.SectionInfo.VertexCount - 2); s++) { if (s % 2 == 0) { meshChunk.Indices.Add(s + 0); meshChunk.Indices.Add(s + 1); meshChunk.Indices.Add(s + 2); } else { meshChunk.Indices.Add(s + 1); meshChunk.Indices.Add(s + 0); meshChunk.Indices.Add(s + 2); } } } } for (int v = 0; v < meshChunk.SectionInfo.VertexCount; v++) { long vertexStartPos = stream.Position; int vertexIncreaseAmount = 0; // Vertex Weights. if (pmo.header.SkeletonOffset != 0 && WeightFormat != CoordinateFormat.NO_VERTEX) { WeightData WeightList = new WeightData(); WeightList.weights = new List <float>(); WeightList.coordFormart = WeightFormat; for (int i = 0; i < (SkinningWeightsCount + 1); i++) { switch (WeightFormat) { case CoordinateFormat.NORMALIZED_8_BITS: WeightList.weights.Add(stream.ReadByte() / 128.0f); break; case CoordinateFormat.NORMALIZED_16_BITS: WeightList.weights.Add(stream.ReadUInt16() / 32768.0f); break; case CoordinateFormat.FLOAT_32_BITS: WeightList.weights.Add(stream.ReadFloat()); break; case CoordinateFormat.NO_VERTEX: break; } } meshChunk.jointWeights.Add(WeightList); } Vector2 currentTexCoord = new Vector2(0, 0); switch (TexCoordFormat) { case CoordinateFormat.NORMALIZED_8_BITS: currentTexCoord.X = stream.ReadByte() / 128.0f; currentTexCoord.Y = stream.ReadByte() / 128.0f; meshChunk.textureCoordinates.Add(currentTexCoord); break; case CoordinateFormat.NORMALIZED_16_BITS: vertexIncreaseAmount = ((0x2 - (Convert.ToInt32(stream.Position - vertexStartPos) & 0x1)) & 0x1); stream.Seek(vertexIncreaseAmount, SeekOrigin.Current); currentTexCoord.X = stream.ReadUInt16() / 32768.0f; currentTexCoord.Y = stream.ReadUInt16() / 32768.0f; meshChunk.textureCoordinates.Add(currentTexCoord); break; case CoordinateFormat.FLOAT_32_BITS: vertexIncreaseAmount = ((0x4 - (Convert.ToInt32(stream.Position - vertexStartPos) & 0x3)) & 0x3); stream.Seek(vertexIncreaseAmount, SeekOrigin.Current); currentTexCoord.X = stream.ReadFloat(); currentTexCoord.Y = stream.ReadFloat(); meshChunk.textureCoordinates.Add(currentTexCoord); break; case CoordinateFormat.NO_VERTEX: meshChunk.textureCoordinates.Add(currentTexCoord); break; } Vector4 col; if (isColorFlagRisen) { uint c = meshChunk.SectionInfo_opt2.DiffuseColor; col.X = c % 0x100; col.Y = (c >> 8) % 0x100; col.Z = (c >> 16) % 0x100; col.W = (c >> 24) % 0x100; meshChunk.colors.Add(col); } else { switch (ColorFormat) { case Pmo.ColorFormat.NO_COLOR: meshChunk.colors.Add(new Vector4(0xFF, 0xFF, 0xFF, 0xFF)); break; case Pmo.ColorFormat.BGR_5650_16BITS: stream.ReadUInt16(); break; case Pmo.ColorFormat.ABGR_5551_16BITS: stream.ReadUInt16(); break; case Pmo.ColorFormat.ABGR_4444_16BITS: stream.ReadUInt16(); break; case Pmo.ColorFormat.ABGR_8888_32BITS: vertexIncreaseAmount = ((0x4 - (Convert.ToInt32(stream.Position - vertexStartPos) & 0x3)) & 0x3); stream.Seek(vertexIncreaseAmount, SeekOrigin.Current); col.X = stream.ReadByte(); col.Y = stream.ReadByte(); col.Z = stream.ReadByte(); col.W = stream.ReadByte(); meshChunk.colors.Add(col); break; } } Vector3 currentVertex; // Handle triangles and triangle strips. switch (VertexPositionFormat) { case CoordinateFormat.NORMALIZED_8_BITS: currentVertex.X = r.ReadSByte() / 128.0f; currentVertex.Y = r.ReadSByte() / 128.0f; currentVertex.Z = r.ReadSByte() / 128.0f; meshChunk.vertices.Add(currentVertex); break; case CoordinateFormat.NORMALIZED_16_BITS: vertexIncreaseAmount = ((0x2 - (Convert.ToInt32(stream.Position - vertexStartPos) & 0x1)) & 0x1); stream.Seek(vertexIncreaseAmount, SeekOrigin.Current); currentVertex.X = (float)stream.ReadInt16() / 32768.0f; currentVertex.Y = (float)stream.ReadInt16() / 32768.0f; currentVertex.Z = (float)stream.ReadInt16() / 32768.0f; meshChunk.vertices.Add(currentVertex); break; case CoordinateFormat.FLOAT_32_BITS: vertexIncreaseAmount = ((0x4 - (Convert.ToInt32(stream.Position - vertexStartPos) & 0x3)) & 0x3); stream.Seek(vertexIncreaseAmount, SeekOrigin.Current); currentVertex.X = stream.ReadFloat(); currentVertex.Y = stream.ReadFloat(); currentVertex.Z = stream.ReadFloat(); meshChunk.vertices.Add(currentVertex); break; } stream.Seek(vertexStartPos + meshChunk.SectionInfo.VertexSize, SeekOrigin.Begin); if (flags.Primitive == PrimitiveType.PRIMITIVE_TRIANGLE) { meshChunk.Indices.Add(v); } } VertCnt = meshChunk.SectionInfo.VertexCount; pmo.Meshes.Add(meshChunk); // Find position of next data chunk. stream.Seek(positionAfterHeader + (meshChunk.SectionInfo.VertexCount * meshChunk.SectionInfo.VertexSize), SeekOrigin.Begin); stream.Seek(stream.Position % 4, SeekOrigin.Current); } }
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { UITableViewCell cell = null; string cellIdentifier; cellIdentifier = GetCellName(indexPath); if (indexPath.Section == coordinatsSection) { SettingsCoordinatesTableCell settingsCoordinatesTableCell = tableView.DequeueReusableCell(cellIdentifier) as SettingsCoordinatesTableCell; settingsCoordinatesTableCell.BackgroundColor = ColorHelper.FromType(ColorType.SecondarySystemGroupedBackground); settingsCoordinatesTableCell.LabInfo.TextColor = ColorHelper.FromType(ColorType.Label); settingsCoordinatesTableCell.LabInfo.Text = LangUtil.Get("SettingsViewController.Coordinates.Info"); settingsCoordinatesTableCell.LabInfo.Font = FontConst.fontSmall; string coordinateButtonText = ""; CoordinateFormat coordinateFormat = UserUtil.Current.format; if (coordinateFormat == CoordinateFormat.DD) { coordinateButtonText = LangUtil.Get("SettingsViewController.Coordinates.DD"); } else if (coordinateFormat == CoordinateFormat.DDM) { coordinateButtonText = LangUtil.Get("SettingsViewController.Coordinates.DDM"); } else if (coordinateFormat == CoordinateFormat.DMS) { coordinateButtonText = LangUtil.Get("SettingsViewController.Coordinates.DMS"); } else if (coordinateFormat == CoordinateFormat.UTM) { coordinateButtonText = LangUtil.Get("SettingsViewController.Coordinates.UTM"); } else { coordinateButtonText = LangUtil.Get("SettingsViewController.Coordinates.DDM"); } settingsCoordinatesTableCell.LabValue.TextColor = ColorHelper.FromType(ColorType.Label); settingsCoordinatesTableCell.LabValue.Text = coordinateButtonText; settingsCoordinatesTableCell.LabValue.Font = FontConst.fontMediumRegular; settingsCoordinatesTableCell.BackgroundColor = ColorHelper.FromType(ColorType.SecondarySystemGroupedBackground); cell = settingsCoordinatesTableCell; } else if (indexPath.Section == locationSection) { // Location LocationServiceAccess locationServiceAccess = AppDelegate.current.locationManager.GetLocationServiceAccess(); SettingsLocationTableCell settingsLocationTableCell = tableView.DequeueReusableCell(cellIdentifier) as SettingsLocationTableCell; settingsLocationTableCell.LabInfo.Text = LangUtil.Get("SettingsViewController.Location.Info"); settingsLocationTableCell.LabLeft.Text = LangUtil.Get("SettingsViewController.Location.Text"); if (locationServiceAccess == LocationServiceAccess.always) { settingsLocationTableCell.LabRight.Text = LangUtil.Get("SettingsViewController.Location.Always"); } else if (locationServiceAccess == LocationServiceAccess.onlyWhenInUse) { settingsLocationTableCell.LabRight.Text = LangUtil.Get("SettingsViewController.Location.OnlyWhenInUse"); } else if (locationServiceAccess == LocationServiceAccess.notAllowed) { settingsLocationTableCell.LabRight.Text = LangUtil.Get("SettingsViewController.Location.NotAllowed"); } else { settingsLocationTableCell.LabRight.Text = LangUtil.Get("SettingsViewController.Location.Unset"); } // if (locationServiceAccess == LocationServiceAccess.always) if (locationServiceAccess == LocationServiceAccess.onlyWhenInUse) { settingsLocationTableCell.LabInfo.TextColor = ColorHelper.FromType(ColorType.Label); settingsLocationTableCell.LabInfo.Font = FontConst.fontSmall; settingsLocationTableCell.LabLeft.TextColor = ColorHelper.FromType(ColorType.Label); settingsLocationTableCell.LabLeft.Font = FontConst.fontMediumRegular; settingsLocationTableCell.LabRight.TextColor = ColorHelper.FromType(ColorType.Label); settingsLocationTableCell.LabRight.Font = FontConst.fontMediumRegular; settingsLocationTableCell.BackgroundColor = ColorHelper.FromType(ColorType.SecondarySystemGroupedBackground); } else { settingsLocationTableCell.LabInfo.TextColor = ColorHelper.FromType(ColorType.LightText); settingsLocationTableCell.LabInfo.Font = FontConst.fontSmall; settingsLocationTableCell.LabLeft.TextColor = ColorHelper.FromType(ColorType.LightText); settingsLocationTableCell.LabLeft.Font = FontConst.fontMediumRegular; settingsLocationTableCell.LabRight.TextColor = ColorHelper.FromType(ColorType.LightText); settingsLocationTableCell.LabRight.Font = FontConst.fontMediumRegular; settingsLocationTableCell.BackgroundColor = ColorHelper.FromType(ColorType.RedBackground); } cell = settingsLocationTableCell; } else if (indexPath.Section == concentSection) { SettingsTopInfoTableCell settingsTopInfoTableCell = tableView.DequeueReusableCell(cellIdentifier) as SettingsTopInfoTableCell; settingsTopInfoTableCell.BackgroundColor = UIColor.Clear; settingsTopInfoTableCell.LabInfo.TextColor = ColorHelper.FromType(ColorType.Label); settingsTopInfoTableCell.LabInfo.Font = FontConst.fontLarge; if (indexPath.Section == concentSection) { // settingsInfoTableCell.AccessibilityLabel = LangUtil.Get("SettingsViewController.Concent.Accessibility.Label"); // settingsInfoTableCell.AccessibilityHint = LangUtil.Get("SettingsViewController.Concent.Accessibility.Hint"); if (UserUtil.Current.consentAgreed == ConsentAgreed.True) { settingsTopInfoTableCell.BackgroundColor = ColorHelper.FromType(ColorType.SecondarySystemGroupedBackground); settingsTopInfoTableCell.LabInfo.TextColor = ColorHelper.FromType(ColorType.Label); } else { settingsTopInfoTableCell.BackgroundColor = ColorHelper.FromType(ColorType.RedBackground); settingsTopInfoTableCell.LabInfo.TextColor = ColorHelper.FromType(ColorType.LightText); } } string text = ""; if (indexPath.Section == informationSection) { if (indexPath.Row == 0) { text = LangUtil.Get("SettingsViewController.Information.Text"); } else if (indexPath.Row == 1) { text = LangUtil.Get("SettingsViewController.Information.Text2"); } } else if (indexPath.Section == concentSection) { text = LangUtil.Get("SettingsViewController.Concent.Text"); } settingsTopInfoTableCell.LabInfo.Text = text; cell = settingsTopInfoTableCell; } else if (indexPath.Section == informationSection) { SettingsInfoTableCell settingsInfoTableCell = tableView.DequeueReusableCell(cellIdentifier) as SettingsInfoTableCell; settingsInfoTableCell.BackgroundColor = ColorHelper.FromType(ColorType.SecondarySystemGroupedBackground); settingsInfoTableCell.LabLabel.TextColor = ColorHelper.FromType(ColorType.Label); settingsInfoTableCell.LabLabel.Font = FontConst.fontLarge; if (indexPath.Section == concentSection) { // settingsInfoTableCell.AccessibilityLabel = LangUtil.Get("SettingsViewController.Concent.Accessibility.Label"); // settingsInfoTableCell.AccessibilityHint = LangUtil.Get("SettingsViewController.Concent.Accessibility.Hint"); if (UserUtil.Current.consentAgreed == ConsentAgreed.True) { settingsInfoTableCell.BackgroundColor = UIColor.Clear; settingsInfoTableCell.LabLabel.TextColor = ColorHelper.FromType(ColorType.Label); } else { settingsInfoTableCell.BackgroundColor = ColorHelper.FromType(ColorType.RedBackground); settingsInfoTableCell.LabLabel.TextColor = ColorHelper.FromType(ColorType.LightText); } } string text = ""; if (indexPath.Section == informationSection) { if (indexPath.Row == 0) { text = LangUtil.Get("SettingsViewController.Information.Text"); } else if (indexPath.Row == 1) { text = LangUtil.Get("SettingsViewController.Information.Text2"); } } else if (indexPath.Section == concentSection) { text = LangUtil.Get("SettingsViewController.Concent.Text"); } settingsInfoTableCell.LabLabel.Text = text; cell = settingsInfoTableCell; } int lineThickness = 1; CGRect bottomLineframe = new CGRect(0, cell.Frame.Height - lineThickness, tableView.Bounds.Size.Width, lineThickness); UIView bottomLine = new UIView(bottomLineframe); bottomLine.BackgroundColor = ColorHelper.FromType(ColorType.Separator); CGRect topLineframe = new CGRect(0, 0, tableView.Bounds.Size.Width, lineThickness); UIView topLine = new UIView(topLineframe); topLine.BackgroundColor = ColorHelper.FromType(ColorType.Separator); cell.AddSubview(bottomLine); cell.AddSubview(topLine); return(cell); }
public static Point Trans(CoordinateFormat inFormat, CoordinateFormat outFormat, Point point) { // int == out -> return if (inFormat == outFormat) return point; // direct transformations if (inFormat == CoordinateFormat.PTV_Geodecimal && outFormat == CoordinateFormat.WGS84) return Geodecimal_2_WGS84(point); if (inFormat == CoordinateFormat.WGS84 && outFormat == CoordinateFormat.PTV_Geodecimal) return WGS84_2_Geodecimal(point); if (inFormat == CoordinateFormat.PTV_Mercator && outFormat == CoordinateFormat.PTV_SmartUnits) return Mercator_2_SmartUnits(point); if (inFormat == CoordinateFormat.PTV_SmartUnits && outFormat == CoordinateFormat.PTV_Mercator) return SmartUnits_2_Mercator(point); if (inFormat == CoordinateFormat.PTV_Mercator && outFormat == CoordinateFormat.PTV_Geodecimal) return Mercator_2_GeoDecimal(point); if (inFormat == CoordinateFormat.PTV_Geodecimal && outFormat == CoordinateFormat.PTV_Mercator) return GeoDecimal_2_Mercator(point); // transitive transformations if (inFormat == CoordinateFormat.PTV_SmartUnits) { return Trans(CoordinateFormat.PTV_Mercator, outFormat, SmartUnits_2_Mercator(point)); } if (outFormat == CoordinateFormat.PTV_SmartUnits) { return Mercator_2_SmartUnits( Trans(inFormat, CoordinateFormat.PTV_Mercator, point)); } if (inFormat == CoordinateFormat.WGS84) { return Trans(CoordinateFormat.PTV_Geodecimal, outFormat, WGS84_2_Geodecimal(point)); } if (outFormat == CoordinateFormat.WGS84) { return Geodecimal_2_WGS84( Trans(inFormat, CoordinateFormat.PTV_Geodecimal, point)); } if (inFormat == CoordinateFormat.PTV_Geodecimal && outFormat == CoordinateFormat.PTV_Mercator) { return GeoDecimal_2_Mercator(point); } if (inFormat == CoordinateFormat.PTV_Mercator && outFormat == CoordinateFormat.PTV_Geodecimal) { return Mercator_2_GeoDecimal(point); } throw new NotImplementedException(string.Format("transformation not implemented for {0} to {1}", inFormat.ToString(), outFormat.ToString())); }
public static int GetVertexSize(CoordinateFormat TexCoordFormat, CoordinateFormat VertexPositionFormat, CoordinateFormat WeightFormat, ColorFormat ColorFormat, int numWeights = 0) { int vertexSize = 0; switch (TexCoordFormat) { case CoordinateFormat.NORMALIZED_8_BITS: vertexSize += 2; break; case CoordinateFormat.NORMALIZED_16_BITS: vertexSize += 4; break; case CoordinateFormat.FLOAT_32_BITS: vertexSize += 8; break; } switch (VertexPositionFormat) { case CoordinateFormat.NORMALIZED_8_BITS: vertexSize += 3; break; case CoordinateFormat.NORMALIZED_16_BITS: vertexSize += 6; break; case CoordinateFormat.FLOAT_32_BITS: vertexSize += 12; break; } switch (WeightFormat) { case CoordinateFormat.NORMALIZED_8_BITS: vertexSize += (numWeights + 1); break; case CoordinateFormat.NORMALIZED_16_BITS: vertexSize += (numWeights + 1) * 2; break; case CoordinateFormat.FLOAT_32_BITS: vertexSize += (numWeights + 1) * 4; break; } switch (ColorFormat) { case ColorFormat.BGR_5650_16BITS: vertexSize += 2; break; case ColorFormat.ABGR_5551_16BITS: vertexSize += 2; break; case ColorFormat.ABGR_4444_16BITS: vertexSize += 2; break; case ColorFormat.ABGR_8888_32BITS: vertexSize += 4; break; } return(vertexSize); }
/// <summary> /// Helper function to concanetate two split coordinates before throwing them into the parser. (Wish this was more compact) /// </summary> /// <param name="Str1">The X position of the coordinate.</param> /// <param name="Str2">The Y position of the coordinate.</param> /// <returns></returns> public static Coordinate FromSplitCoordinate(string Str1, string Str2, CoordinateFormat CF = CoordinateFormat.ATCF) { return(FromString($"{Str1},{Str2}", CF)); }
public string GetLongitude(CoordinateFormat p_gpsFormat) { return(ConvertCoordinateToString(m_dbGPSLongitude, p_gpsFormat, false)); }
/// <summary> /// Checks if an ATCF file is valid. /// </summary> /// <param name="PathToDirectory"></param> /// <returns></returns> // Iris: genericised input validation public static bool Export_CheckDirectoryValidForImport(string PathToDirectory, CoordinateFormat AgencyFormat = CoordinateFormat.ATCF) { if (!Directory.Exists(PathToDirectory)) { Error.Throw("Error", "Import error: can't import nonexistent folder!", ErrorSeverity.Error, 282); return(false); } List <string> FilesInDirectory = Directory.EnumerateFiles(PathToDirectory).ToList(); if (FilesInDirectory.Count == 0) { Error.Throw("Error", "Import error: can't import empty folder!", ErrorSeverity.Error, 277); return(false); } foreach (string FileInDirectory in FilesInDirectory) { // check 1: file extension if (!FileInDirectory.Contains(".dat")) { Error.Throw("Error", "Import error: This directory has files that are not in the ATCF BestTrack format. Please remove these files from the folder before continuing.", ErrorSeverity.Error, 279); return(false); } else { // check 2: file size. A reasonable estimation for the minimum size of one of these files is 200 bytes - a valid line should be 224 bytes, but some could be smaller, so 200 bytes DirectoryInfo DI = new DirectoryInfo(PathToDirectory); List <FileInfo> FI = DI.EnumerateFiles().ToList(); foreach (FileInfo FIn in FI) { if (FIn.Length < 200) { Error.Throw("Error", "Import error: This directory has files that are not in the ATCF BestTrack format. Please remove these files from the folder before continuing.", ErrorSeverity.Error, 280); return(false); } } // check 3: file data. Should defeat everyone without technical knowledge and everyone who is not intentionally attempting to insert invalid data. using (BinaryReader BR = new BinaryReader(new FileStream(FileInDirectory, FileMode.Open))) { int FirstCommaIndex = 2; int SecondCommaIndex = 6; if (AgencyFormat == CoordinateFormat.HURDAT2) { FirstCommaIndex = 8; SecondCommaIndex = 28; } long BytesRemaining = BR.BaseStream.Length - BR.BaseStream.Position; if (BytesRemaining < SecondCommaIndex) { Error.Throw("Error", "Invalid HURDAT2 format file - error verifying file format (stage 3)", ErrorSeverity.Error, 328); return(false); } byte[] Bytes = BR.ReadBytes(SecondCommaIndex + 1); Debug.Assert(Bytes.Length == (SecondCommaIndex + 1)); if (Bytes[FirstCommaIndex] == 0x2C && Bytes[SecondCommaIndex] == 0x2C) { BR.Close(); return(true); } else { BR.Close(); Error.Throw("Error", "Import error: This directory has files that are not in the ATCF BestTrack format. Please remove these files from the folder before continuing.", ErrorSeverity.Error, 281); return(false); } } } } // for now return(false); }
public string GetLatitude(CoordinateFormat p_gpsFormat) { return(ConvertCoordinateToString(m_dbGPSLatitude, p_gpsFormat, true)); }
/// <summary> /// Creates a new <see cref="ConfigurationCell"/> from serialization parameters. /// </summary> /// <param name="info">The <see cref="SerializationInfo"/> with populated with data.</param> /// <param name="context">The source <see cref="StreamingContext"/> for this deserialization.</param> protected ConfigurationCell(SerializationInfo info, StreamingContext context) : base(info, context) { // Deserialize configuration cell m_lastReportTime = info.GetInt64("lastReportTime"); m_signalReferences = (Dictionary<SignalType, string[]>)info.GetValue("signalReferences", typeof(Dictionary<SignalType, string[]>)); m_analogDataFormat = (DataFormat)info.GetValue("analogDataFormat", typeof(DataFormat)); m_frequencyDataFormat = (DataFormat)info.GetValue("frequencyDataFormat", typeof(DataFormat)); m_phasorDataFormat = (DataFormat)info.GetValue("phasorDataFormat", typeof(DataFormat)); m_phasorCoordinateFormat = (CoordinateFormat)info.GetValue("phasorCoordinateFormat", typeof(CoordinateFormat)); m_isVirtual = info.GetBoolean("isVirtual"); }
public string GetLatitude(CoordinateFormat p_gpsFormat) { return ConvertCoordinateToString(m_dbGPSLatitude,p_gpsFormat,true); }
public static PlainPoint Trans(CoordinateFormat inFormat, CoordinateFormat outFormat, PlainPoint point) { // int == out -> return if (inFormat == outFormat) { return(point); } // direct transformations if (inFormat == CoordinateFormat.Ptv_Geodecimal && outFormat == CoordinateFormat.Wgs84) { return(Geodecimal_2_WGS84(point)); } if (inFormat == CoordinateFormat.Wgs84 && outFormat == CoordinateFormat.Ptv_Geodecimal) { return(WGS84_2_Geodecimal(point)); } if (inFormat == CoordinateFormat.Ptv_Mercator && outFormat == CoordinateFormat.Ptv_SmartUnits) { return(Mercator_2_SmartUnits(point)); } if (inFormat == CoordinateFormat.Ptv_SmartUnits && outFormat == CoordinateFormat.Ptv_Mercator) { return(SmartUnits_2_Mercator(point)); } if (inFormat == CoordinateFormat.Ptv_Mercator && outFormat == CoordinateFormat.Wgs84) { return(SphereMercator_2_Wgs(point, Ptv_Radius)); } if (inFormat == CoordinateFormat.Wgs84 && outFormat == CoordinateFormat.Ptv_Mercator) { return(Wgs_2_SphereMercator(point, Ptv_Radius)); } if (inFormat == CoordinateFormat.Web_Mercator && outFormat == CoordinateFormat.Wgs84) { return(SphereMercator_2_Wgs(point, Google_Radius)); } if (inFormat == CoordinateFormat.Wgs84 && outFormat == CoordinateFormat.Web_Mercator) { return(Wgs_2_SphereMercator(point, Google_Radius)); } if (inFormat == CoordinateFormat.Ptv_Mercator && outFormat == CoordinateFormat.Web_Mercator) { return(Ptv_2_Google(point)); } if (inFormat == CoordinateFormat.Web_Mercator && outFormat == CoordinateFormat.Ptv_Mercator) { return(Google_2_Ptv(point)); } // transitive transformations if (inFormat == CoordinateFormat.Ptv_SmartUnits) { return(Trans(CoordinateFormat.Ptv_Mercator, outFormat, SmartUnits_2_Mercator(point))); } if (outFormat == CoordinateFormat.Ptv_SmartUnits) { return(Mercator_2_SmartUnits(Trans(inFormat, CoordinateFormat.Ptv_Mercator, point))); } if (inFormat == CoordinateFormat.Ptv_Geodecimal) { return(Trans(CoordinateFormat.Wgs84, outFormat, Geodecimal_2_WGS84(point))); } if (outFormat == CoordinateFormat.Ptv_Geodecimal) { return(WGS84_2_Geodecimal(Trans(inFormat, CoordinateFormat.Wgs84, point))); } // this should not happen throw new NotImplementedException(string.Format("transformation not implemented for {0} to {1}", inFormat.ToString(), outFormat.ToString())); }
/// <summary> /// Manual insertion of all facility level details into List, which is in turn bound to GridView /// </summary> private void populateDetails(int facilityReportId) { FACILITYDETAIL_DETAIL fac = Facility.GetFacilityDetails(facilityReportId).First(); FACILITYDETAIL_COMPETENTAUTHORITYPARTY authority = Facility.GetFacilityCompetentAuthority(facilityReportId).First(); List <FacilityDetailElement> elements = new List <FacilityDetailElement>(); elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "FacilityDetailsTitle"), String.Empty, true)); elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "ParentCompanyName"), ConfidentialFormat.Format(fac.ParentCompanyName, fac.ConfidentialIndicator))); // Take "Valid" string from FACILITY_DETAIL_DETAIL elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "Coords"), CoordinateFormat.Format(fac.Coordinates, "VALID"))); //NUTS is voluntary. Only add if reported. if (!string.IsNullOrEmpty(fac.NUTSRegionSourceCode)) { //Add both reported and geo-coded value - if they differ. if (fac.NUTSRegionSourceCode != fac.NUTSRegionLevel2Code) { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "NUTSMap"), LOVResources.NutsRegionName(fac.NUTSRegionLevel2Code))); elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "NUTSReported"), LOVResources.NutsRegionName(fac.NUTSRegionSourceCode))); } else { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "NUTS"), LOVResources.NutsRegionName(fac.NUTSRegionLevel2Code))); } } //Add both reported and geo-coded value - if they differ. if (fac.RiverBasinDistrictSourceCode != fac.RiverBasinDistrictCode) { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "RBDMap"), LOVResources.RiverBasinDistrictName(fac.RiverBasinDistrictCode))); elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "RBDReported"), LOVResources.RiverBasinDistrictName(fac.RiverBasinDistrictSourceCode))); } else { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "RBD"), LOVResources.RiverBasinDistrictName(fac.RiverBasinDistrictCode))); } //NACE code reported on sub-activity level, except for EPER where some is reported on Activity level //string naceCode = !String.IsNullOrEmpty(fac.NACESubActivityCode) ? fac.NACESubActivityCode : fac.NACEActivityCode; string naceCode = !String.IsNullOrEmpty(fac.NACEActivityCode) ? fac.NACEActivityCode : fac.NACESectorCode; elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "NACE"), LOVResources.NaceActivityName(naceCode))); //Production volume is voluntary. Only add if reported. if (fac.ProductionVolumeQuantity != null) { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "ProductionV"), String.Format("{0} {1} {2}", fac.ProductionVolumeProductName, NumberFormat.Format(fac.ProductionVolumeQuantity), LOVResources.UnitName(fac.ProductionVolumeUnitCode)))); } //No. of IPPC installations is voluntary. Only add if reported. if (fac.TotalIPPCInstallationQuantity != null) { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "IPPC"), NumberFormat.Format(fac.TotalIPPCInstallationQuantity))); } //No. of emplyees is voluntary. Only add if reported. if (fac.TotalEmployeeQuantity != null) { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "Employ"), NumberFormat.Format(fac.TotalEmployeeQuantity))); } //Operating hours is voluntary. Only add if reported. if (fac.OperatingHours != null) { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "OperationHours"), String.Format("{0}", fac.OperatingHours))); } //Website is voluntary. Only add if reported. if (!string.IsNullOrEmpty(fac.WebsiteCommunication)) { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "WebSite"), String.Format("{0}", fac.WebsiteCommunication))); } if (fac.ConfidentialIndicatorCode != null) { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Pollutant", "ConfidentialityReason"), LOVResources.ConfidentialityReason(fac.ConfidentialIndicatorCode))); } elements.Add(new FacilityDetailElement( Resources.GetGlobal("Common", "NationalID") + ":", FacilityDetailsFormat.FormatNationalId(fac))); // This is not the most elegant way to obtain a spacing spacing elements.Add(new FacilityDetailElement(String.Empty, String.Empty)); string updatedDateString = authority.CALastUpdate == null ? Resources.GetGlobal("Facility", "LastUpdatedUnknown") : authority.CALastUpdate.Format(); elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "CompetentA"), String.Format(Resources.GetGlobal("Facility", "LastUpdated"), updatedDateString), true)); elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "Name"), String.Format(authority.CAName))); if (authority.CAAddress != null) { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "Address"), AddressFormat.Format(authority.CAAddress, authority.CACity, authority.CAPostalCode, false))); } if (authority.CATelephoneCommunication != null) { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "Phone"), String.Format(authority.CATelephoneCommunication))); } if (authority.CAFaxCommunication != null) { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "Fax"), String.Format(authority.CAFaxCommunication))); } elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "Email"), String.Format(authority.CAEmailCommunication))); if (authority.CAContactPersonName != null) { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "CPerson"), String.Format(authority.CAContactPersonName))); } // data binding facilityreportDetails.DataSource = elements; facilityreportDetails.DataBind(); }
private const int SMART_OFFSET = 20015087; // 1/2 Earth-circumference(PI*MERCATOR_RADIUS); public static Point Trans(CoordinateFormat inFormat, CoordinateFormat outFormat, double x, double y) { return Trans(inFormat, outFormat, new Point(x, y)); }
public string GetLongitude(CoordinateFormat p_gpsFormat) { return ConvertCoordinateToString(m_dbGPSLongitude,p_gpsFormat,false); }
/// <summary> /// Creates a new <see cref="ConfigurationCell"/> from specified parameters. /// </summary> /// <param name="parent">The reference to parent <see cref="ConfigurationFrame"/> of this <see cref="ConfigurationCell"/>.</param> /// <param name="idCode">The numeric ID code for this <see cref="ConfigurationCell"/>.</param> public ConfigurationCell(ConfigurationFrame parent, ushort idCode) : base(parent, idCode, int.MaxValue, int.MaxValue, int.MaxValue) { // Create a cached signal reference dictionary for generated signal references m_generatedSignalReferenceCache = new string[Enum.GetValues(typeof(SignalKind)).Length][]; m_generatedMeasurementMetadataCache = new MeasurementMetadata[Enum.GetValues(typeof(SignalKind)).Length][]; m_analogDataFormat = DataFormat.FloatingPoint; m_frequencyDataFormat = DataFormat.FloatingPoint; m_phasorDataFormat = DataFormat.FloatingPoint; m_phasorCoordinateFormat = CoordinateFormat.Polar; }
static private string ConvertCoordinateToString(double p_dbCoordinate, CoordinateFormat p_gpsFormat, bool blnLatitude) { string strCoordinateAsString = ""; // Need to know if N/S E/W - use blnLatitude to distinguish between two types // switch (p_gpsFormat) { case CoordinateFormat.DecimalDegreesNumeric: strCoordinateAsString = p_dbCoordinate.ToString(); break; case CoordinateFormat.DecimalDegrees: // simply convert to String... strCoordinateAsString = Math.Abs(p_dbCoordinate).ToString(); break; case CoordinateFormat.DegreesMinutesSeconds: // Degrees (°) Minutes (') Seconds (") //N 54 51 0.546000 //W 1 34 55.800000 //double Degrees to Degrees, Minutes & Seconds // F12 = 52.657570305556 // C12 =ABS(TRUNC(F12)) -> degrees // D12 =TRUNC((ABS(F12)-C12)*60) ->minutes //seconds = ((ABS(F12))*3600)-(D12*60)-(C12*3600) ->seconds double dbAbsValue = Math.Abs(p_dbCoordinate); double dbDegrees = Math.Round(dbAbsValue); if (dbDegrees > dbAbsValue) { dbDegrees -= 1.0; } double dbMinutes = (dbAbsValue - dbDegrees) * 60; if (dbMinutes < Math.Round((dbAbsValue - dbDegrees) * 60)) { dbMinutes = Math.Round(dbMinutes) - 1; } else { dbMinutes = Math.Round(dbMinutes) - 1; } double dbSecond = ((dbAbsValue - dbDegrees) * 3600) - (dbMinutes * 60); if (dbSecond > 60) { dbSecond -= 60; dbMinutes++; } string strDegrees = dbDegrees.ToString(); string strMinutes = dbMinutes.ToString(); string strSecond = dbSecond.ToString(); strCoordinateAsString = strDegrees + " " + strMinutes + " " + strSecond; break; case CoordinateFormat.DegreesDecimalMinutes: //Degrees & Decimal Minutes //N 54 51.009100000 //W 1 34.930000000 //double Degrees to Degrees & double Minutes = //double minutes =ABS(F12-(TRUNC(F12)))*60 // double part of number * 60 - absoluted... // directional indiactors - >=IF(F12<0,"S","N") // =IF(F13<0,"W","E") break; default: //??? assume GPSCoordFormat.DecimalDegrees strCoordinateAsString = p_dbCoordinate.ToString(); break; } string strCompassID = ""; if (p_gpsFormat != CoordinateFormat.DecimalDegreesNumeric) { if (blnLatitude) { //N or S if (p_dbCoordinate < 0) { strCompassID = "S"; } else { strCompassID = "N"; } } else { //E or W if (p_dbCoordinate < 0) { strCompassID = "W"; } else { strCompassID = "E"; } } } return(strCompassID + strCoordinateAsString); }
/// <summary> /// Initializes <see cref="PhasorDataConcentratorBase"/>. /// </summary> public override void Initialize() { base.Initialize(); const string errorMessage = "{0} is missing from Settings - Example: IDCode=235; dataChannel={{Port=0; Clients=localhost:8800}}"; Dictionary<string, string> settings = Settings; string setting, dataChannel, commandChannel; // Load required parameters if (!settings.TryGetValue("IDCode", out setting)) throw new ArgumentException(string.Format(errorMessage, "IDCode")); m_idCode = ushort.Parse(setting); settings.TryGetValue("dataChannel", out dataChannel); settings.TryGetValue("commandChannel", out commandChannel); // Data channel and/or command channel must be defined if (string.IsNullOrEmpty(dataChannel) && string.IsNullOrEmpty(commandChannel)) throw new InvalidOperationException("A data channel or command channel must be defined for a concentrator."); // Load optional parameters if (settings.TryGetValue("autoPublishConfigFrame", out setting)) m_autoPublishConfigurationFrame = setting.ParseBoolean(); else m_autoPublishConfigurationFrame = string.IsNullOrEmpty(commandChannel); if (settings.TryGetValue("autoStartDataChannel", out setting)) m_autoStartDataChannel = setting.ParseBoolean(); else m_autoStartDataChannel = true; if (settings.TryGetValue("nominalFrequency", out setting)) m_nominalFrequency = (LineFrequency)int.Parse(setting); else m_nominalFrequency = LineFrequency.Hz60; if (settings.TryGetValue("dataFormat", out setting)) m_dataFormat = (DataFormat)Enum.Parse(typeof(DataFormat), setting, true); else m_dataFormat = DataFormat.FloatingPoint; if (settings.TryGetValue("coordinateFormat", out setting)) m_coordinateFormat = (CoordinateFormat)Enum.Parse(typeof(CoordinateFormat), setting, true); else m_coordinateFormat = CoordinateFormat.Polar; if (settings.TryGetValue("currentScalingValue", out setting)) { if (!uint.TryParse(setting, out m_currentScalingValue)) m_currentScalingValue = unchecked((uint)int.Parse(setting)); } else { m_currentScalingValue = 2423U; } if (settings.TryGetValue("voltageScalingValue", out setting)) { if (!uint.TryParse(setting, out m_voltageScalingValue)) m_voltageScalingValue = unchecked((uint)int.Parse(setting)); } else { m_voltageScalingValue = 2725785U; } if (settings.TryGetValue("analogScalingValue", out setting)) { if (!uint.TryParse(setting, out m_analogScalingValue)) m_analogScalingValue = unchecked((uint)int.Parse(setting)); } else { m_analogScalingValue = 1373291U; } if (settings.TryGetValue("digitalMaskValue", out setting)) { if (!uint.TryParse(setting, out m_digitalMaskValue)) m_digitalMaskValue = unchecked((uint)int.Parse(setting)); } else { m_digitalMaskValue = Word.MakeDoubleWord(0xFFFF, 0x0000); } if (settings.TryGetValue("processDataValidFlag", out setting)) m_processDataValidFlag = setting.ParseBoolean(); else m_processDataValidFlag = true; if (settings.TryGetValue("addPhaseLabelSuffix", out setting)) m_addPhaseLabelSuffix = setting.ParseBoolean(); else m_addPhaseLabelSuffix = true; if (settings.TryGetValue("replaceWithSpaceChar", out setting)) { if (!string.IsNullOrWhiteSpace(setting) && setting.Length > 0) m_replaceWithSpaceChar = setting[0]; else m_replaceWithSpaceChar = Char.MinValue; } else { m_replaceWithSpaceChar = Char.MinValue; } if (settings.TryGetValue("useAdjustedValue", out setting)) m_useAdjustedValue = Boolean.Parse(setting); else m_useAdjustedValue = true; // Initialize data channel if defined if (!string.IsNullOrEmpty(dataChannel)) this.DataChannel = new UdpServer(dataChannel); else this.DataChannel = null; // Initialize command channel if defined if (!string.IsNullOrEmpty(commandChannel)) this.CommandChannel = new TcpServer(commandChannel); else this.CommandChannel = null; // Create the configuration frame UpdateConfiguration(); // Register with the statistics engine StatisticsEngine.Register(this, "OutputStream", "OS"); StatisticsEngine.Calculated += (sender, args) => ResetLatencyCounters(); StatisticsEngine.Calculated += (sender, args) => ResetMeasurementsPerSecondCounters(); }
private void RowSelected(NSIndexPath indexPath) { CoordinateFormat format = settingsCoordinateFormatTableViewSource.coordinateRows[indexPath.Row].CoordinateFormat; UserUtil.Current.format = format; }
/// <summary> /// Creates a new <see cref="ConfigurationCell"/> from serialization parameters. /// </summary> /// <param name="info">The <see cref="SerializationInfo"/> with populated with data.</param> /// <param name="context">The source <see cref="StreamingContext"/> for this deserialization.</param> protected ConfigurationCell(SerializationInfo info, StreamingContext context) : base(info, context) { // Create a cached signal reference dictionary for generated signal references m_generatedSignalReferenceCache = new string[Enum.GetValues(typeof(SignalKind)).Length][]; m_generatedMeasurementMetadataCache = new MeasurementMetadata[Enum.GetValues(typeof(SignalKind)).Length][]; // Deserialize configuration cell m_lastReportTime = info.GetInt64("lastReportTime"); m_analogDataFormat = (DataFormat)info.GetValue("analogDataFormat", typeof(DataFormat)); m_frequencyDataFormat = (DataFormat)info.GetValue("frequencyDataFormat", typeof(DataFormat)); m_phasorDataFormat = (DataFormat)info.GetValue("phasorDataFormat", typeof(DataFormat)); m_phasorCoordinateFormat = (CoordinateFormat)info.GetValue("phasorCoordinateFormat", typeof(CoordinateFormat)); }