Skip to content

Commit

Permalink
Merge branch 'release/0.12.0' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
philipbelesky committed Aug 18, 2021
2 parents 4c8246c + f966c9e commit 9329231
Show file tree
Hide file tree
Showing 20 changed files with 10,173 additions and 4,813 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.12.0] - 2021-08-18
### Added
- New 'extension' examples file to show how to easily bake/filter/legend the Caribou outputs
- A boundary output for the parsing components to easily see the extents of the OSM files

### Fixed
- A crash that could occur when clicking the header rows of the *Specify Features* pop-up. Thanks Clarke for reporting this!

## [0.11.0] - 2021-08-08
### Added
- Live reporting of progress parsing files (below the component)
Expand Down
3 changes: 3 additions & 0 deletions Caribou.Tests/Cases/singapore-left.osm
Git LFS file not shown
3 changes: 3 additions & 0 deletions Caribou.Tests/Cases/singapore-right.osm
Git LFS file not shown
3 changes: 3 additions & 0 deletions Caribou.Tests/Cases/singapore-top-no-overlap.osm
Git LFS file not shown
2 changes: 1 addition & 1 deletion Caribou/Caribou.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net45</TargetFramework>
<VersionPrefix>0.11.0</VersionPrefix>
<VersionPrefix>0.12.0</VersionPrefix>
<VersionSuffix>beta</VersionSuffix>
<Title>Caribou</Title>
<Description>Description of Caribou</Description>
Expand Down
7 changes: 7 additions & 0 deletions Caribou/Components/BaseFindComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ protected override void RegisterInputParams(GH_InputParamManager pManager)
pManager.AddTextParameter("OSM Features", "OF", "A list of features and subfeatures to extract from the OSM file, in a 'key=value' format separated by newlines or commas", GH_ParamAccess.list);
}

protected void AddCommonOutputParams(GH_OutputParamManager pManager)
{
pManager.AddTextParameter("Tags", "T", "The metadata attached to each particular node", GH_ParamAccess.tree);
pManager.AddTextParameter("Report", "R", ReportDescription, GH_ParamAccess.tree);
pManager.AddRectangleParameter("Bounds", "B", "The boundary extends of the OSM file(s)", GH_ParamAccess.list);
}

public override GH_Exposure Exposure => GH_Exposure.primary;
}
}
10 changes: 6 additions & 4 deletions Caribou/Components/BaseLoadAndParseWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.Xml.Linq;
using System.Xml.XPath;
using System.Linq;
using Rhino;

/// <summary>
/// Shared logic for doing the 'work' of each parsing component.
Expand All @@ -31,6 +32,7 @@ public abstract class BaseLoadAndParseWorker : WorkerInstance
protected RequestHandler result;
protected GH_Structure<GH_String> itemTags;
protected GH_Structure<GH_String> itemMetaDatas;
protected List<Rectangle3d> boundaries;

public BaseLoadAndParseWorker(GH_Component parent)
: base(parent) // Pass parent component back to base class so state (e.g. remarks) can bubble up
Expand All @@ -49,7 +51,7 @@ public void ExtractCoordsForComponentType(Action<string, double> reportProgress)
public override void DoWork(Action<string, double> reportProgress, Action done)
{
logger.Reset();
logger.indexOfDebugOutput = 3;
logger.indexOfDebugOutput = 4; // Dynamic nature of class params requires manually specifying debug log output index
string typeName = Enum.GetName(typeof(OSMGeometryType), this.WorkerType());

result = new RequestHandler(providedFilePaths, requestedMetaData, this.WorkerType(), reportProgress, Id);
Expand All @@ -69,6 +71,7 @@ public override void DoWork(Action<string, double> reportProgress, Action done)
return;

this.GetTreeForComponentType(); // Form tree structure for Rhino geo
boundaries = GetOSMBoundaries.GetBoundariesFromResult(result);
logger.NoteTiming("Output geometry");
if (this.CancellationToken.IsCancellationRequested)
return;
Expand Down Expand Up @@ -125,18 +128,17 @@ protected override void WorkerSetData(IGH_DataAccess da)
{
if (this.CancellationToken.IsCancellationRequested)
return;

this.OutputTreeForComponentType(da); // Set component-specific outputs

if (this.CancellationToken.IsCancellationRequested)
return;

da.SetDataTree(1, this.itemTags);

if (this.CancellationToken.IsCancellationRequested)
return;

da.SetDataTree(2, this.itemMetaDatas);

da.SetDataList(3, this.boundaries);
}
}
}
3 changes: 1 addition & 2 deletions Caribou/Components/FindBuildingsComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ public FindBuildingsComponent()
protected override void CaribouRegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddSurfaceParameter("Buildings", "B", "Buildings as extrusions from associated way geometries", GH_ParamAccess.tree);
pManager.AddTextParameter("Tags", "T", "The metadata attached to each particular node", GH_ParamAccess.tree);
pManager.AddTextParameter("Report", "R", ReportDescription, GH_ParamAccess.tree);
AddCommonOutputParams(pManager);
}

public override Guid ComponentGuid => new Guid("d6b1b021-2b5d-4fa6-9cf2-eb368dd632a1");
Expand Down
3 changes: 1 addition & 2 deletions Caribou/Components/FindNodesComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ public FindNodesComponent()
protected override void CaribouRegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddPointParameter("Nodes", "N", "Nodes; e.g. points that describe a location of interest", GH_ParamAccess.tree);
pManager.AddTextParameter("Tags", "T", "The metadata attached to each particular node", GH_ParamAccess.tree);
pManager.AddTextParameter("Report", "R", ReportDescription, GH_ParamAccess.tree);
AddCommonOutputParams(pManager);
}

public override Guid ComponentGuid => new Guid("912176ea-061e-2b5b-9642-8417372d6371");
Expand Down
3 changes: 1 addition & 2 deletions Caribou/Components/FindWaysComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ public FindWaysComponent()
protected override void CaribouRegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddCurveParameter("Ways", "W", "Ways; e.g. nodes linked in a linear order via a Polyline", GH_ParamAccess.tree);
pManager.AddTextParameter("Tags", "T", "The metadata attached to each particular node", GH_ParamAccess.tree);
pManager.AddTextParameter("Report", "R", ReportDescription, GH_ParamAccess.tree);
AddCommonOutputParams(pManager);
}

public override Guid ComponentGuid => new Guid("f677053e-0416-433b-9a8e-ce3124998b7d");
Expand Down
2 changes: 1 addition & 1 deletion Caribou/Forms/SpecifyFeaturesForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class SpecifyFeaturesForm : Form
private readonly int windowHeight = 633; // Need to be large enough to show buttom row
private readonly int buttonHeight = 40;
private readonly int buttonWidth = 200;
private readonly int padding = 10;
private readonly int padding = 0;
private readonly TreeGridItemCollection providedState;
private readonly CheckBox obscureFeaturesCheckbox; // Need to track so we can manually set state
public bool hideObscureFeatures;
Expand Down
17 changes: 8 additions & 9 deletions Caribou/Forms/TableStrip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private void CellClickHandler(object sender, GridCellMouseEventArgs e)

private void HeaderClickHandler(object sender, EventArgs e)
{
// TODO: sorting
// TODO: implement sorting (and change the Sortable properties on GridColumn())
}

private string FlipCheckbox(TreeGridItem item) // to string, flip, and back again
Expand Down Expand Up @@ -87,7 +87,7 @@ private TreeGridView GetLayout()
//Binding = Binding.Property<OSMSelectableFeature, string>(r => r.Name)
},
Resizable = false,
Sortable = true,
Sortable = false,
AutoSize = false,
Width = 165, // Don't autosize; hides the arrow buttons on macOS
};
Expand All @@ -102,8 +102,7 @@ private TreeGridView GetLayout()
},
Width = 55,
Resizable = false,
Sortable = true,
// Editable = true,
Sortable = false,
};
featureSelect.Columns.Add(checkColumn);

Expand All @@ -112,7 +111,7 @@ private TreeGridView GetLayout()
HeaderText = "Nodes Count",
DataCell = new TextBoxCell(2),
Resizable = false,
Sortable = true,
Sortable = false,
Width = 85,
};
featureSelect.Columns.Add(nodeColumn);
Expand All @@ -122,7 +121,7 @@ private TreeGridView GetLayout()
HeaderText = "Ways Count",
DataCell = new TextBoxCell(3),
Resizable = false,
Sortable = true,
Sortable = false,
Width = 85,
};
featureSelect.Columns.Add(wayColumn);
Expand All @@ -132,7 +131,7 @@ private TreeGridView GetLayout()
HeaderText = "K:V Format",
DataCell = new TextBoxCell(4),
Resizable = false,
Sortable = true,
Sortable = false,
AutoSize = true,
};
featureSelect.Columns.Add(keyValueColumn);
Expand All @@ -142,7 +141,7 @@ private TreeGridView GetLayout()
HeaderText = "Wiki Info",
DataCell = new TextBoxCell(5),
Resizable = false,
Sortable = true,
Sortable = false,
AutoSize = true,
};
featureSelect.Columns.Add(linkColumn);
Expand All @@ -152,7 +151,7 @@ private TreeGridView GetLayout()
HeaderText = "Description",
DataCell = new TextBoxCell(6),
Resizable = false,
Sortable = true,
Sortable = false,
};
featureSelect.Columns.Add(descriptionColumn);

Expand Down
1 change: 1 addition & 0 deletions Caribou/Models/RequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class RequestHandler
public ParseRequest RequestedMetaData;
public Coord MinBounds;
public Coord MaxBounds;
public List<Tuple<Coord, Coord>> AllBounds;

public Dictionary<OSMMetaData, List<FoundItem>> FoundData; // The collected items per request
public List<string> FoundItemIds; // Used to track for duplicate ways/nodes across files
Expand Down
29 changes: 29 additions & 0 deletions Caribou/Processing/GetOSMBoundaries.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace Caribou.Processing
{
using System;
using System.Collections.Generic;
using Caribou.Data;
using Rhino;
using Rhino.Geometry;

public static class GetOSMBoundaries
{
public static List<Rectangle3d> GetBoundariesFromResult(RequestHandler result)
{
var unitScale = RhinoMath.UnitScale(UnitSystem.Meters, RhinoDoc.ActiveDoc.ModelUnitSystem);
Coord lengthPerDegree = TranslateToXYManually.GetDegreesPerAxis(result.MinBounds, result.MaxBounds, unitScale);

var boundaries = new List<Rectangle3d>();
for (var i = 0; i < result.AllBounds.Count; i++)
{
var lowerCoord = result.AllBounds[i].Item1;
var upperCoord = result.AllBounds[i].Item2;
var lowerLeft = TranslateToXYManually.GetPointFromLatLong(lowerCoord, lengthPerDegree, result.MinBounds);
var upperRight = TranslateToXYManually.GetPointFromLatLong(upperCoord, lengthPerDegree, result.MinBounds);
var boundary = new Rectangle3d(Plane.WorldXY, lowerLeft, upperRight);
boundaries.Add(boundary);
}
return boundaries;
}
}
}
19 changes: 13 additions & 6 deletions Caribou/Processing/ParseViaLinq.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,40 +74,47 @@ public static void GetBounds(ref RequestHandler result)
double? currentMinLon = null;
double? currentMaxLat = null;
double? currentMaxLon = null;
result.AllBounds = new List<Tuple<Coord, Coord>>();

foreach (string providedXML in result.XmlPaths)
{
var xml = XDocument.Parse(providedXML);
var boundsElement = (from el in xml.Descendants("bounds") select el).First();
CheckBounds(boundsElement, ref currentMinLat, ref currentMinLon, ref currentMaxLat, ref currentMaxLon);
var minLat = Convert.ToDouble(boundsElement.Attributes("minlat").First().Value);
var minLon = Convert.ToDouble(boundsElement.Attributes("minlon").First().Value);
var maxLat = Convert.ToDouble(boundsElement.Attributes("maxlat").First().Value);
var maxLon = Convert.ToDouble(boundsElement.Attributes("maxlon").First().Value);
var bounds = new Tuple<Coord, Coord>(new Coord(minLat, minLon), new Coord(maxLat, maxLon));
result.AllBounds.Add(bounds);
CheckBounds(bounds, ref currentMinLat, ref currentMinLon, ref currentMaxLat, ref currentMaxLon);
}

result.MinBounds = new Coord(currentMinLat.Value, currentMinLon.Value);
result.MaxBounds = new Coord(currentMaxLat.Value, currentMaxLon.Value);
}

private static void CheckBounds(XElement element, ref double? currentMinLat, ref double? currentMinLon,
private static void CheckBounds(Tuple<Coord, Coord> bounds, ref double? currentMinLat, ref double? currentMinLon,
ref double? currentMaxLat, ref double? currentMaxLon)
{
var boundsMinLat = Convert.ToDouble(element.Attributes("minlat").First().Value);
var boundsMinLat = bounds.Item1.Latitude;
if (!currentMinLat.HasValue || boundsMinLat < currentMinLat)
{
currentMinLat = boundsMinLat;
}

var boundsMinLon = Convert.ToDouble(element.Attributes("minlon").First().Value);
var boundsMinLon = bounds.Item1.Longitude;
if (!currentMinLon.HasValue || boundsMinLon < currentMinLon)
{
currentMinLon = boundsMinLon;
}

var boundsMaxLat = Convert.ToDouble(element.Attributes("maxlat").First().Value);
var boundsMaxLat = bounds.Item2.Latitude;
if (!currentMaxLat.HasValue || boundsMaxLat > currentMaxLat)
{
currentMaxLat = boundsMaxLat;
}

var boundsMaxLon = Convert.ToDouble(element.Attributes("maxlon").First().Value);
var boundsMaxLon = bounds.Item2.Longitude;
if (!currentMaxLon.HasValue || boundsMaxLon > currentMaxLon)
{
currentMaxLon = boundsMaxLon;
Expand Down
22 changes: 15 additions & 7 deletions Caribou/Processing/ParseViaXMLReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ public static void GetBounds(ref RequestHandler result, bool readPathAsContents
double? currentMinLon = null;
double? currentMaxLat = null;
double? currentMaxLon = null;
result.AllBounds = new List<Tuple<Coord, Coord>>();

foreach (string xmlPath in result.XmlPaths)
{
Expand All @@ -186,7 +187,14 @@ public static void GetBounds(ref RequestHandler result, bool readPathAsContents
{
if (reader.Name == "bounds")
{
CheckBounds(reader, ref currentMinLat, ref currentMinLon, ref currentMaxLat, ref currentMaxLon);
var minLat = Convert.ToDouble(reader.GetAttribute("minlat"));
var minLon = Convert.ToDouble(reader.GetAttribute("minlon"));
var maxLat = Convert.ToDouble(reader.GetAttribute("maxlat"));
var maxLon = Convert.ToDouble(reader.GetAttribute("maxlon"));
var bounds = new Tuple<Coord, Coord>(new Coord(minLat, minLon), new Coord(maxLat, maxLon));
result.AllBounds.Add(bounds);

CheckBounds(bounds, ref currentMinLat, ref currentMinLon, ref currentMaxLat, ref currentMaxLon);
break;
}
}
Expand All @@ -197,28 +205,28 @@ public static void GetBounds(ref RequestHandler result, bool readPathAsContents
result.MaxBounds = new Coord(currentMaxLat.Value, currentMaxLon.Value);
}

public static void CheckBounds(XmlReader reader, ref double? currentMinLat, ref double? currentMinLon,
ref double? currentMaxLat, ref double? currentMaxLon)
public static void CheckBounds(Tuple<Coord, Coord> bounds,
ref double? currentMinLat, ref double? currentMinLon, ref double? currentMaxLat, ref double? currentMaxLon)
{
var boundsMinLat = Convert.ToDouble(reader.GetAttribute("minlat"));
var boundsMinLat = bounds.Item1.Latitude;
if (!currentMinLat.HasValue || boundsMinLat < currentMinLat)
{
currentMinLat = boundsMinLat;
}

var boundsMinLon = Convert.ToDouble(reader.GetAttribute("minlon"));
var boundsMinLon = bounds.Item1.Longitude;
if (!currentMinLon.HasValue || boundsMinLon < currentMinLon)
{
currentMinLon = boundsMinLon;
}

var boundsMaxLat = Convert.ToDouble(reader.GetAttribute("maxlat"));
var boundsMaxLat = bounds.Item2.Latitude;
if (!currentMaxLat.HasValue || boundsMaxLat > currentMaxLat)
{
currentMaxLat = boundsMaxLat;
}

var boundsMaxLon = Convert.ToDouble(reader.GetAttribute("maxlon"));
var boundsMaxLon = bounds.Item2.Longitude;
if (!currentMaxLon.HasValue || boundsMaxLon > currentMaxLon)
{
currentMaxLon = boundsMaxLon;
Expand Down
2 changes: 1 addition & 1 deletion Caribou/bin/Release/net45/manifest.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Caribou
version: 0.11.0
version: 0.12.0
authors:
- Philip Belesky
keywords:
Expand Down
Loading

0 comments on commit 9329231

Please sign in to comment.