/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA) { // Get the Rhino Units to properly scale the lat/lon data into Rhino units double unitScale = CommonGHProcessors.GetRhinoUnitScale(Rhino.RhinoDoc.ActiveDoc); List <OSMPointData> outPoints = new List <OSMPointData>(); List <OSMPoint> osmPoints = new List <OSMPoint>(); LINE.Geometry.Interval2d latlon = new LINE.Geometry.Interval2d(); string dataStream = string.Empty; Interval latDomain = new Interval(); Interval lonDomain = new Interval(); string path = null; DA.GetData(0, ref path); if (path != null && System.IO.File.Exists(path)) { ElkLib.NodePreProcess(path, unitScale, out dataStream, out osmPoints, out latlon); foreach (OSMPoint op in osmPoints) { OSMPointData od = new OSMPointData(op); outPoints.Add(od); } } lonDomain = new Interval(latlon.UMin, latlon.UMax); latDomain = new Interval(latlon.VMin, latlon.VMax); // Output the data DA.SetDataList(0, outPoints); DA.SetData(1, path); DA.SetData(2, lonDomain); DA.SetData(3, latDomain); }
public static Dictionary <string, double> DeconstructLocation(LINE.Geometry.Interval2d location) { return(new Dictionary <string, double> { { "west", location.UMin }, { "east", location.UMax }, { "south", location.VMin }, { "north", location.VMax } }); }
private void okButton_Click(object sender, RoutedEventArgs e) { // Get the lat and long domain latMin = Convert.ToDouble(minLatTextBox.Text); latMax = Convert.ToDouble(maxLatTextBox.Text); lonMin = Convert.ToDouble(minLonTextBox.Text); lonMax = Convert.ToDouble(maxLonTextBox.Text); LINE.Geometry.Interval2d topoDomain = new LINE.Geometry.Interval2d(lonMin, lonMax, latMin, latMax); // output parameters string filePath = fileTextBox.Text; if (filePath != null && System.IO.File.Exists(filePath)) { List <List <LINE.Geometry.Point3d> > pts = ElkLib.ProcessTopoFile(filePath, unitScale, topoDomain); List <XYZ> points = new List <XYZ>(); for (int i = 0; i < pts.Count; i++) { List <LINE.Geometry.Point3d> rowPoints = pts[i]; for (int j = 0; j < rowPoints.Count; j++) { XYZ revPoint = new XYZ(rowPoints[j].X, rowPoints[j].Y, rowPoints[j].Z); points.Add(revPoint); } } using (Transaction trans = new Transaction(doc, "Elk Create Topography")) { trans.Start(); if (points.Count > 2) { TopographySurface topo = TopographySurface.Create(doc, points); } trans.Commit(); } } Close(); }
public static Dictionary <string, object> Location(string filePath) { List <OSMPoint> osmPoints = new List <OSMPoint>(); LINE.Geometry.Interval2d latlon = new LINE.Geometry.Interval2d(); string dataStream = string.Empty; // Get the Revit Units for scale double scale = 1.0; string exception = null; try { scale = Elk.DynamoCommon.GetRevitUnitScale(); } catch (Exception ex) { exception = ex.Message; } if (exception == null) { exception = scale.ToString(); } string path = filePath; if (path != null && System.IO.File.Exists(path)) { ElkLib.NodePreProcess(path, scale, out dataStream, out osmPoints, out latlon); } return(new Dictionary <string, object> { { "OSM", osmPoints }, { "XML", path }, { "Loc", latlon } //{"test", exception} }); }
/// <summary> /// Construct a location of latitude/longitude for the Elk topography component. /// </summary> /// <param name="west">Western longitude parameter (Min)</param> /// <param name="east">Eastern longitude parameter (Max)</param> /// <param name="south">Southern latitude parameter (Min)</param> /// <param name="north">Northern latitude parameter (Max)</param> /// <returns name="location">The location's 2 dimneional domain (latitude/longitude)</returns> /// <search>location,construct,elk,topography</search> public static LINE.Geometry.Interval2d ConstructLocation(double west, double east, double south, double north) { LINE.Geometry.Interval2d loc = new LINE.Geometry.Interval2d(west, east, south, north); return(loc); }
public static Dictionary <string, object> CreateTopo(string filePath, LINE.Geometry.Interval2d location = null) { // Get the file information List <string> fileInfo = Elk.Common.ElkLib.TopoFileInfo(filePath); // output parameters List <List <Point> > topoPoints = null; List <NurbsCurve> curves = null; NurbsSurface ns = null; // try to get the scale double scale = 1.0; try { scale = Elk.DynamoCommon.GetRevitUnitScale(); } catch { } if (filePath != null && System.IO.File.Exists(filePath) && location != null) { List <List <LINE.Geometry.Point3d> > pts = ElkLib.ProcessTopoFile(filePath, scale, location); Point[][] surfPoints = new Point[pts.Count][]; topoPoints = new List <List <Point> >(); curves = new List <NurbsCurve>(); for (int i = 0; i < pts.Count; i++) { List <LINE.Geometry.Point3d> rowPoints = pts[i]; List <Point> crvPts = new List <Point>(); for (int j = 0; j < rowPoints.Count; j++) { Point dynPoint = Point.ByCoordinates(rowPoints[j].X, rowPoints[j].Y, rowPoints[j].Z); crvPts.Add(dynPoint); } surfPoints[i] = crvPts.ToArray(); topoPoints.Add(crvPts); NurbsCurve nc = NurbsCurve.ByPoints(crvPts, 3); //PolyCurve pc = PolyCurve.ByPoints(crvPts, false); curves.Add(nc); } try { ns = NurbsSurface.ByPoints(surfPoints, 3, 3); } catch { ns = null; } return(new Dictionary <string, object> { { "Info", fileInfo }, { "Points", topoPoints }, { "Curves", curves }, { "Surface", ns } }); } else { return(new Dictionary <string, object> { { "Info", fileInfo }, { "Points", null }, { "Curves", null }, { "Surface", null } }); } }