コード例 #1
0
        /// <summary>
        /// Determines the area and length details for the specified features
        /// </summary>
        private void DetermineAreaAndLengthDetailsFor(IList <Feature> features, out string areaString, out string lengthString)
        {
            var length = 0.0;
            var area   = 0.0;

            foreach (var feature in features)
            {
                foreach (FeatureGeometryFieldDescriptor field in feature.TableDescriptor.FieldDescriptors.Descriptors(FeatureFieldDescriptorType.Geometry))
                {
                    var geometry = feature[field.Name];
                    if (geometry != null)
                    {
                        switch (field.FieldType.PhysicalType)
                        {
                        case FeaturePhysicalFieldType.Curve:
                        case FeaturePhysicalFieldType.MultiCurve:
                            ICurveGeometry curveGeometry = geometry as ICurveGeometry;
                            length += curveGeometry.LineLength(LinearLineLengthType.Meter);
                            break;

                        case FeaturePhysicalFieldType.Polygon:
                        case FeaturePhysicalFieldType.MultiPolygon:
                            IPolygonGeometry polygonGeometry = geometry as IPolygonGeometry;
                            area += polygonGeometry.Area(SurfaceAreaType.MeterSquared);
                            break;
                        }
                    }
                }
            }

            // Interpret the area in m2, but let the unitSystem determine the actual locale's settings
            areaString = UnitSystem.Convert(area, "m2").ToString();

            // Interpret the length in m, but let the unitSystem determine the display units
            lengthString = UnitSystem.Convert(length, "m").ToString();
        }
コード例 #2
0
 /// <summary>
 /// Transforms the area to a human readable string, making use of the active unit system
 /// </summary>
 protected static String AreaInMetersToString(double area)
 {
     return(UnitSystem.Convert(area, "m2").ToString());
 }
コード例 #3
0
 /// <summary>
 /// Transforms the length to a human readable string, making use of the active unit system
 /// </summary>
 protected static String LengthInMetersToString(double length)
 {
     return(UnitSystem.Convert(length, "m").ToString());
 }
コード例 #4
0
 /// <summary>
 /// Raises that the area to be displayed has changed. Interprets the specified
 /// area as an area in m2.
 /// </summary>
 protected void RaiseAreaChanged(double area)
 {
     RaiseAreaChanged(UnitSystem.Convert(area, "m2").ToString());
 }