public static string GuessGeoType(this IFeature f) { var pts = f.GeoData; if (pts.Count == 0) { return(VectorLayer.GEOTYPE_UNKNOWN); } else if (pts.Count == 1) { return(VectorLayer.GEOTYPE_POINT); } else { double area = f.Area(); double length = f.Length(); if (area < AREA_THRESHOLD * length * length / 16) { return(VectorLayer.GEOTYPE_LINEAR); } else { return(VectorLayer.GEOTYPE_REGION); } } }
public void UpdateFeature() { IFeature f = this.Feature; f["unitType"] = this.UnitType.ToString(); f["layerName"] = this.LayerName; f["buildType"] = this.Type.ToString(); f["struct"] = this.Structure.ToString(); f["mixOffic"] = this.MixOfficePercent.ToString(); f["mixIndu"] = this.MixIndustryPercent.ToString(); f["mixEdu"] = this.MixEducationPercent.ToString(); f["mixHotel"] = this.MixHotelPercent.ToString(); f["mixGreen"] = this.MixGreenFieldPercent.ToString(); f["mixOther"] = this.MixOtherPercent.ToString(); f["mixRetai"] = this.MixRetailPercent.ToString(); f["mixResi"] = this.MixResidencialPercent.ToString(); f["area"] = f.Area() == this.Area ? string.Empty : this.Area.ToString("0.##"); f["far"] = this.FAR.ToString(); f["levels"] = this.Levels.ToString(); f["perResi"] = this.PerCapitaResidencial.ToString(); f["perOffic"] = this.PerCapitaOffice.ToString(); f["perIndu"] = this.PerCapitaIndustry.ToString(); f["pop"] = this.Populations.ToString(); f["escType"] = this.EnergySavingCoefficient.EnergyType.ToString(); f["escValue"] = this.EnergySavingCoefficient.TempValue.ToString(); f["green"] = this.GreenField.ToString(); }
public static void Attach(IFeature f, bool createNew = false) { if (createNew) { var cu = new ComputationUnit(f); cu.Area = f.Area(); f.Data[KEY] = cu; } else { f.Data[KEY] = new ComputationUnit(f); } }
public ComputationUnit(IFeature f) { Feature = f; //this.UnitType = f["unitType"] == "Parcel" ? ComputationUnitType.Parcel : ComputationUnitType.Building; this.LayerName = f["layerName"]; if (this.LayerName.Contains("YD-")) // 用地图层 { this.UnitType = ComputationUnitType.Parcel; } else if (this.LayerName.Contains("JZ-")) // 建筑图层 { this.UnitType = ComputationUnitType.Building; } else // 其他图层 { this.UnitType = ComputationUnitType.Other; } f["unitType"] = this.UnitType.ToString(); this.FAR = f["far"].TryParseToDouble(); this.Levels = f["levels"].TryParseToInt32(); this.Type = string.IsNullOrEmpty(f["buildType"]) ? GetDefaultType(this.LayerName, this.FAR, this.Levels) : f["buildType"].ParseToEnum <BuildingType>(); this.Structure = string.IsNullOrEmpty(f["struct"]) ? StructuralType.Concrete : f["struct"].ParseToEnum <StructuralType>(); this.MixOfficePercent = f["mixOffic"].TryParseToDouble(); this.MixIndustryPercent = f["mixIndu"].TryParseToDouble(); this.MixEducationPercent = f["mixEdu"].TryParseToDouble(); this.MixHotelPercent = f["mixHotel"].TryParseToDouble(); this.MixGreenFieldPercent = f["mixGreen"].TryParseToDouble(); this.MixOtherPercent = f["mixOther"].TryParseToDouble(); this.MixRetailPercent = f["mixRetai"].TryParseToDouble(); this.MixResidencialPercent = f["mixResi"].TryParseToDouble(); this.Area = string.IsNullOrEmpty(f["area"]) ? f.Area() : f["area"].TryParseToDouble(); this.PerCapitaResidencial = CheckPerCapitaResidencial(f["perResi"].TryParseToDouble()); this.PerCapitaOffice = CheckPerCapitaOffice(f["perOffic"].TryParseToDouble()); this.PerCapitaIndustry = CheckPerCapitaIndustry(f["perIndu"].TryParseToDouble()); this.Populations = IsEmptyPopulation(f["pop"]) ? UpdatePopulation() : f["pop"].TryParseToDouble(); EnergySavingType tmpType = (EnergySavingType)Enum.Parse(typeof(EnergySavingType), f["escType"]); double tmpValue = f["escValue"].TryParseToDouble(); this.EnergySavingCoefficient = new EnergySavingRatio(tmpType, tmpValue); this.GreenField = string.IsNullOrEmpty(f["green"]) ? GetDefaultGreenType(this.Type) : f["green"].ParseToEnum <GreenFieldType>(); this.Position = new PointString(f.GeoData).Centroid(); UpdateResult(); }
/// <summary> /// Calculates the area of a part, without taking into consideration any other aspects of the polygon. /// </summary> /// <param name="polygon">A MapWinGIS.Shape POLYGON, POLYGONZ, or POLYGONM</param> /// <param name="PartIndex">The integer index of the part to obtain the area of. /// This value will be ignored if the shape only has one part, and the function /// will calculate the area of the entire shape.</param> /// <returns>A double value that is equal to the area of the part.</returns> /// <remarks>Coded by Ted Dunsford 6/23/2006, derived from Angela's Area algorithm /// Code reference http://astronomy.swin.edu.au/~pbourke/geometry/polyarea/ /// Cached in MapWinGeoProc\clsUtils\Documentation\ /// I don't think that we ever want to return a negative area from this function, /// even if the part is a hole, because it is being calculated outside of the /// context of any other parts. Only the collective Area function should worry about /// ascribing a sign value to the individual part areas. ///</remarks> public static double AreaOfPart(IFeature polygon, int PartIndex) { return polygon.Area(); }
/// <summary> /// Calculates the area of a part, without taking into consideration any other aspects of the polygon. /// </summary> /// <param name="polygon">A MapWinGIS.Shape POLYGON, POLYGONZ, or POLYGONM</param> /// <param name="PartIndex">The integer index of the part to obtain the area of. /// This value will be ignored if the shape only has one part, and the function /// will calculate the area of the entire shape.</param> /// <returns>A double value that is equal to the area of the part.</returns> /// <remarks>Coded by Ted Dunsford 6/23/2006, derived from Angela's Area algorithm /// Code reference http://astronomy.swin.edu.au/~pbourke/geometry/polyarea/ /// Cached in MapWinGeoProc\clsUtils\Documentation\ /// I don't think that we ever want to return a negative area from this function, /// even if the part is a hole, because it is being calculated outside of the /// context of any other parts. Only the collective Area function should worry about /// ascribing a sign value to the individual part areas. ///</remarks> public static double AreaOfPart(IFeature polygon, int PartIndex) { return(polygon.Area()); }