public Polygon(ShapePolygon shapePolygon, int partIndex, double offset, string nameOffset) { this.Points = shapePolygon.Parts[partIndex]; this.OffsetPoints = Polygon.GetEnlargedPolygon(this.Points.ToList(), offset).ToArray(); if (this.OffsetPoints.Count() == 0) { throw new InvalidOperationException("Polygon has no area."); } this.createBoundingBox(); this.id = Polygon.globalId; Polygon.globalId++; bool hasMetadata = shapePolygon.GetMetadataNames().Count() > 2; if (hasMetadata) { this.Center = new Vector3( double.Parse(shapePolygon.GetMetadata("schwerp_x").Replace(',', '.'), CultureInfo.InvariantCulture), 0.0d, double.Parse(shapePolygon.GetMetadata("schwerp_y").Replace(',', '.'), CultureInfo.InvariantCulture)); this.address = Regex.Replace((shapePolygon.GetMetadata("strasse").Replace("STRA▀E", "Straße").ToLower()), @"(^\w)|(\s\w)", m => m.Value.ToUpper()) + " " + shapePolygon.GetMetadata("hausnr"); this.Name = nameOffset + this.id.ToString().PadLeft(8, '0') + "-" + shapePolygon.GetMetadata("uuid"); } else { this.Center = new Vector3( (this.BoundingBox.Left + this.BoundingBox.Right) / 2.0d, 0.0d, (this.BoundingBox.Top + this.BoundingBox.Bottom) / 2.0d); this.address = ""; this.Name = nameOffset + this.id.ToString().PadLeft(8, '0'); } this.ContainsPoints = false; }