Skip to content

Commit

Permalink
Fix attr names also for geoobjects (#51)
Browse files Browse the repository at this point in the history
* replace "-" in CityGML-Attributenames with "_" for import in Revit

* make property dict writable

* replace characters that are not allowd as fieldnames in extensible storage
  • Loading branch information
Hutsimbl authored Jul 13, 2022
1 parent 4a8d331 commit f7887e9
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
2 changes: 1 addition & 1 deletion BIMGISInteropLibs/OGR/GeoObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class GeoObject

//private List<List<C2BSegment>> segments { get; set; }

public Dictionary<string, string> Properties { get => properties; }
public Dictionary<string, string> Properties { get => properties; set => properties=value; }
private Dictionary<string, string> properties { get; set; }

public GeoObject(string usageType, string gmlID, OSGeo.OGR.wkbGeometryType geomType, OSGeo.OGR.Geometry geom ,Dictionary<string, string> properties)
Expand Down
7 changes: 0 additions & 7 deletions City2RVT/Builder/GeoObjectBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,6 @@ group geoObject by geoObject.UsageType into usageGroup
Entity ent = new Entity(currentSchema);
foreach(KeyValuePair<string, string> prop in GeoObj.Properties)
{
//is needed because some attribute are using the | symbol for long attribute names
if (prop.Key.Contains("|"))
{
string firstPart = prop.Key.Split('|')[0];
ent.Set<string>(firstPart, prop.Value);
continue;
}
ent.Set<string>(prop.Key, prop.Value);
}

Expand Down
38 changes: 38 additions & 0 deletions City2RVT/GUI/NAS2BIM/Cmd_ReadALKIS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,44 @@ public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref str
var GeoObjs = ogrReader.getGeoObjectsForLayer(layer, dialog.SpatialFilter);
Log.Information(string.Format("Total of {0} features in layer {1}", GeoObjs.Count, layerName));
var fieldList = ogrReader.getFieldNamesForLayer(layer);

for (int i=0; i<fieldList.Count; i++)
{
if (fieldList[i].Contains("|"))
{
fieldList[i] = fieldList[i].Replace('|', '_');
}
else if (fieldList[i].Contains("-"))
{
fieldList[i] = fieldList[i].Replace('-', '_');
}
}


foreach (var GeoObj in GeoObjs)
{
Dictionary<string, string> newPropDict = new Dictionary<string, string>();

foreach(KeyValuePair<string,string> entry in GeoObj.Properties)
{
if (entry.Key.Contains("|"))
{
var newKey = entry.Key.Replace('|', '_');
newPropDict[newKey] = entry.Value;
}
else if (entry.Key.Contains("-"))
{
var newKey = entry.Key.Replace('-', '_');
newPropDict[newKey] = entry.Value;
}
else
{
newPropDict[entry.Key] = entry.Value;
}
}
GeoObj.Properties = newPropDict;
}

GeoObjBuilder.buildGeoObjectsFromList(GeoObjs, dialog.Drape, fieldList);
Log.Information(string.Format("Finished importing layer {0}", layerName));
}
Expand Down

0 comments on commit f7887e9

Please sign in to comment.