public static string FormatSpatialReference(ISpatialReference sr) { try { if (sr == null) { return(""); } StringBuilder builder = new StringBuilder(); if (sr is UnknownCoordinateSystemClass) { builder.Append("UnknownCoordinateSystem"); } else { if (sr.Name == "Unknown") { builder.Append("UnknownCoordinateSystem"); } else { IGeographicCoordinateSystem system2; if (sr is IProjectedCoordinateSystem) { Exception exception; IProjectedCoordinateSystem system = sr as IProjectedCoordinateSystem; builder.Append("投影坐标系:\n"); builder.Append(" Name:").Append(system.Name).Append("\n"); builder.Append(" Alias:").Append(system.Alias).Append("\n"); builder.Append(" Abbreviation:").Append(system.Abbreviation).Append("\n"); builder.Append(" Remarks:").Append(system.Remarks).Append("\n"); builder.Append("投影:").Append(system.Projection.Name).Append("\n"); builder.Append("投影参数:\n"); builder.Append(" False_Easting:").Append(system.FalseEasting).Append("\n"); builder.Append(" False_Northing:").Append(system.FalseNorthing).Append("\n"); builder.Append(" Central_Meridian:").Append(system.get_CentralMeridian(true)).Append("\n"); try { builder.Append(" Scale_Factor:").Append(system.ScaleFactor).Append("\n"); } catch { } builder.Append(" Latitude_Of_Origin:0\n"); builder.Append("Linear Unit:").Append(system.CoordinateUnit.Name).Append("(").Append(system.CoordinateUnit.MetersPerUnit).Append(")\n"); builder.Append("Geographic Coordinate System:\n"); system2 = system.GeographicCoordinateSystem; builder.Append(" Name:").Append(system2.Name).Append("\n"); builder.Append(" Alias:").Append(system2.Alias).Append("\n"); builder.Append(" Abbreviation:").Append(system2.Abbreviation).Append("\n"); builder.Append(" Remarks:").Append(system2.Remarks).Append("\n"); builder.Append(" Angular Unit:").Append(system2.CoordinateUnit.Name).Append("(").Append(system2.CoordinateUnit.RadiansPerUnit).Append(")\n"); builder.Append(" Prime Meridian:").Append(system2.PrimeMeridian.Name).Append("(").Append(system2.PrimeMeridian.Longitude).Append(")\n"); builder.Append(" Datum:").Append(system2.Datum.Name).Append("\n"); builder.Append(" Spheroid:").Append(system2.Datum.Spheroid.Name).Append("\n"); builder.Append(" Semimajor Axis:").Append(system2.Datum.Spheroid.SemiMajorAxis).Append("\n"); builder.Append(" Semiminor Axis:").Append(system2.Datum.Spheroid.SemiMinorAxis).Append("\n"); builder.Append(" Inverse Flattening:").Append((double)(1.0 / system2.Datum.Spheroid.Flattening)).Append("\n"); builder.Append("X/Y Domain:\n"); try { double num = 0.0; double num2 = 0.0; double num3 = 0.0; double num4 = 0.0; double num5 = 0.0; sr.GetDomain(out num, out num3, out num2, out num4); sr.GetFalseOriginAndUnits(out num, out num2, out num5); builder.Append(" Min X:").Append(num).Append("\n"); builder.Append(" Min Y:").Append(num2).Append("\n"); builder.Append(" Max X:").Append(num3).Append("\n"); builder.Append(" Max Y:").Append(num4).Append("\n"); builder.Append(" XYScale:").Append(num5).Append("\n"); builder.Append("\n"); } catch (Exception exception1) { exception = exception1; } builder.Append("Z Domain:\n"); try { double num6; double num7; double num8 = 0.0; sr.GetZDomain(out num6, out num7); sr.GetZFalseOriginAndUnits(out num6, out num8); builder.Append(" Min Z:").Append(num6).Append("\n"); builder.Append(" Max Z:").Append(num7).Append("\n"); builder.Append(" ZScale:").Append(num8).Append("\n"); builder.Append("\n"); } catch (Exception exception2) { exception = exception2; } try { double num9; double num10; builder.Append("M Domain:\n"); double num11 = 0.0; sr.GetMDomain(out num9, out num10); sr.GetMFalseOriginAndUnits(out num9, out num11); builder.Append(" Min M:").Append(num9).Append("\n"); builder.Append(" Max M:").Append(num10).Append("\n"); builder.Append(" MScale:").Append(num11).Append("\n"); } catch (Exception exception3) { exception = exception3; } } else if (sr is IGeographicCoordinateSystem) { builder.Append("Geographic Coordinate System:\n"); system2 = sr as IGeographicCoordinateSystem; builder.Append(" Name:").Append(system2.Name).Append("\n"); builder.Append(" Alias:").Append(system2.Alias).Append("\n"); builder.Append(" Abbreviation:").Append(system2.Abbreviation).Append("\n"); builder.Append(" Remarks:").Append(system2.Remarks).Append("\n"); builder.Append(" Angular Unit:").Append(system2.CoordinateUnit.Name).Append("(").Append(system2.CoordinateUnit.RadiansPerUnit).Append(")\n"); builder.Append(" Prime Meridian:").Append(system2.PrimeMeridian.Name).Append("(").Append(system2.PrimeMeridian.Longitude).Append(")\n"); builder.Append(" Datum:").Append(system2.Datum.Name).Append("\n"); builder.Append(" Spheroid:").Append(system2.Datum.Spheroid.Name).Append("\n"); builder.Append(" Semimajor Axis:").Append(system2.Datum.Spheroid.SemiMajorAxis).Append("\n"); builder.Append(" Semiminor Axis:").Append(system2.Datum.Spheroid.SemiMinorAxis).Append("\n"); builder.Append(" Inverse Flattening:").Append((double)(1.0 / system2.Datum.Spheroid.Flattening)).Append("\n"); } } } return(builder.ToString()); } catch (Exception ex) { return(""); } }
public static string FormatSpatialReference(ISpatialReference sr) { try { if (sr == null) { return ""; } StringBuilder builder = new StringBuilder(); if (sr is UnknownCoordinateSystemClass) { builder.Append("UnknownCoordinateSystem"); } else { if (sr.Name == "Unknown") { builder.Append("UnknownCoordinateSystem"); } else { IGeographicCoordinateSystem system2; if (sr is IProjectedCoordinateSystem) { Exception exception; IProjectedCoordinateSystem system = sr as IProjectedCoordinateSystem; builder.Append("投影坐标系:\n"); builder.Append(" Name:").Append(system.Name).Append("\n"); builder.Append(" Alias:").Append(system.Alias).Append("\n"); builder.Append(" Abbreviation:").Append(system.Abbreviation).Append("\n"); builder.Append(" Remarks:").Append(system.Remarks).Append("\n"); builder.Append("投影:").Append(system.Projection.Name).Append("\n"); builder.Append("投影参数:\n"); builder.Append(" False_Easting:").Append(system.FalseEasting).Append("\n"); builder.Append(" False_Northing:").Append(system.FalseNorthing).Append("\n"); builder.Append(" Central_Meridian:").Append(system.get_CentralMeridian(true)).Append("\n"); try { builder.Append(" Scale_Factor:").Append(system.ScaleFactor).Append("\n"); } catch { } builder.Append(" Latitude_Of_Origin:0\n"); builder.Append("Linear Unit:").Append(system.CoordinateUnit.Name).Append("(").Append(system.CoordinateUnit.MetersPerUnit).Append(")\n"); builder.Append("Geographic Coordinate System:\n"); system2 = system.GeographicCoordinateSystem; builder.Append(" Name:").Append(system2.Name).Append("\n"); builder.Append(" Alias:").Append(system2.Alias).Append("\n"); builder.Append(" Abbreviation:").Append(system2.Abbreviation).Append("\n"); builder.Append(" Remarks:").Append(system2.Remarks).Append("\n"); builder.Append(" Angular Unit:").Append(system2.CoordinateUnit.Name).Append("(").Append(system2.CoordinateUnit.RadiansPerUnit).Append(")\n"); builder.Append(" Prime Meridian:").Append(system2.PrimeMeridian.Name).Append("(").Append(system2.PrimeMeridian.Longitude).Append(")\n"); builder.Append(" Datum:").Append(system2.Datum.Name).Append("\n"); builder.Append(" Spheroid:").Append(system2.Datum.Spheroid.Name).Append("\n"); builder.Append(" Semimajor Axis:").Append(system2.Datum.Spheroid.SemiMajorAxis).Append("\n"); builder.Append(" Semiminor Axis:").Append(system2.Datum.Spheroid.SemiMinorAxis).Append("\n"); builder.Append(" Inverse Flattening:").Append((double)(1.0 / system2.Datum.Spheroid.Flattening)).Append("\n"); builder.Append("X/Y Domain:\n"); try { double num = 0.0; double num2 = 0.0; double num3 = 0.0; double num4 = 0.0; double num5 = 0.0; sr.GetDomain(out num, out num3, out num2, out num4); sr.GetFalseOriginAndUnits(out num, out num2, out num5); builder.Append(" Min X:").Append(num).Append("\n"); builder.Append(" Min Y:").Append(num2).Append("\n"); builder.Append(" Max X:").Append(num3).Append("\n"); builder.Append(" Max Y:").Append(num4).Append("\n"); builder.Append(" XYScale:").Append(num5).Append("\n"); builder.Append("\n"); } catch (Exception exception1) { exception = exception1; } builder.Append("Z Domain:\n"); try { double num6; double num7; double num8 = 0.0; sr.GetZDomain(out num6, out num7); sr.GetZFalseOriginAndUnits(out num6, out num8); builder.Append(" Min Z:").Append(num6).Append("\n"); builder.Append(" Max Z:").Append(num7).Append("\n"); builder.Append(" ZScale:").Append(num8).Append("\n"); builder.Append("\n"); } catch (Exception exception2) { exception = exception2; } try { double num9; double num10; builder.Append("M Domain:\n"); double num11 = 0.0; sr.GetMDomain(out num9, out num10); sr.GetMFalseOriginAndUnits(out num9, out num11); builder.Append(" Min M:").Append(num9).Append("\n"); builder.Append(" Max M:").Append(num10).Append("\n"); builder.Append(" MScale:").Append(num11).Append("\n"); } catch (Exception exception3) { exception = exception3; } } else if (sr is IGeographicCoordinateSystem) { builder.Append("Geographic Coordinate System:\n"); system2 = sr as IGeographicCoordinateSystem; builder.Append(" Name:").Append(system2.Name).Append("\n"); builder.Append(" Alias:").Append(system2.Alias).Append("\n"); builder.Append(" Abbreviation:").Append(system2.Abbreviation).Append("\n"); builder.Append(" Remarks:").Append(system2.Remarks).Append("\n"); builder.Append(" Angular Unit:").Append(system2.CoordinateUnit.Name).Append("(").Append(system2.CoordinateUnit.RadiansPerUnit).Append(")\n"); builder.Append(" Prime Meridian:").Append(system2.PrimeMeridian.Name).Append("(").Append(system2.PrimeMeridian.Longitude).Append(")\n"); builder.Append(" Datum:").Append(system2.Datum.Name).Append("\n"); builder.Append(" Spheroid:").Append(system2.Datum.Spheroid.Name).Append("\n"); builder.Append(" Semimajor Axis:").Append(system2.Datum.Spheroid.SemiMajorAxis).Append("\n"); builder.Append(" Semiminor Axis:").Append(system2.Datum.Spheroid.SemiMinorAxis).Append("\n"); builder.Append(" Inverse Flattening:").Append((double)(1.0 / system2.Datum.Spheroid.Flattening)).Append("\n"); } } } return builder.ToString(); } catch (Exception ex) { return ""; } }
private static bool GetCoincident([NotNull] SegmentProxy segment, [NotNull] SegmentProxy hull, bool is3D, out NearSegment hullStartNear, out NearSegment hullEndNear) { hullStartNear = NearSegment.NotNear; // TODO hullEndNear = NearSegment.NotNear; // TODO IPolyline segLine = segment.GetPolyline(false); IPolyline hullLine = hull.GetPolyline(false); if (!((IRelationalOperator)segLine).Equals(hullLine)) { return(false); } var coincident = true; Pnt segmentStart = segment.GetStart(is3D); Pnt segmentEnd = segment.GetEnd(is3D); Pnt hullStart = hull.GetStart(is3D); Pnt hullEnd = hull.GetEnd(is3D); double distFromSegFromHull; { double dx = segmentStart.X - hullStart.X; double dy = segmentStart.Y - hullStart.Y; distFromSegFromHull = dx * dx + dy * dy; } double distFromSegToHull; { double dx = segmentStart.X - hullEnd.X; double dy = segmentStart.Y - hullEnd.Y; distFromSegToHull = dx * dx + dy * dy; } bool isInverse = (distFromSegFromHull > distFromSegToHull); Pnt hullMatchSegFrom; Pnt hullMatchSegTo; if (!isInverse) { hullMatchSegFrom = hullStart; hullMatchSegTo = hullEnd; } else { hullMatchSegFrom = hullEnd; hullMatchSegTo = hullStart; } if (is3D) { double zPrecision = 0; ISpatialReference spatialReference = segment.SpatialReference; if (spatialReference != null && spatialReference.HasZPrecision()) { double falseZ; double zUnits; spatialReference.GetZFalseOriginAndUnits(out falseZ, out zUnits); zPrecision = 1 / zUnits; } if (Math.Abs(hullMatchSegFrom[2] - segmentStart[2]) > zPrecision || Math.Abs(hullMatchSegTo[2] - segmentStart[2]) > zPrecision) { coincident = false; } } if (coincident) { if (!isInverse) { hullStartNear = NearSegment.NearStart; hullEndNear = NearSegment.NearEnd; } else { hullStartNear = NearSegment.NearEnd; hullEndNear = NearSegment.NearStart; } } return(coincident); }