internal static PolarGeoCoordinate Convert(PolarGeoCoordinate source, CoordinateSystems destination) { PolarGeoCoordinate retVal; if (source.CoordinateSystem == CoordinateSystems.OSGB36 && destination == CoordinateSystems.WGS84) { retVal = Convert( source, EllipseParameter.GetEllipseParameters(EllipseParameter.Ellipses.Airy1830), HelmertTransform.GetTransform(HelmertTransform.HelmertTransformType.OSGB36toWGS84), EllipseParameter.GetEllipseParameters(EllipseParameter.Ellipses.WGS84) ); } else if (source.CoordinateSystem == CoordinateSystems.WGS84 && destination == CoordinateSystems.OSGB36) { retVal = Convert( source, EllipseParameter.GetEllipseParameters(EllipseParameter.Ellipses.WGS84), HelmertTransform.GetTransform(HelmertTransform.HelmertTransformType.WGS84toOSGB36), EllipseParameter.GetEllipseParameters(EllipseParameter.Ellipses.Airy1830) ); } else { throw new NotImplementedException("Requested source and destination are not currently supported"); } retVal.AlignSigFigs(source); return(retVal); }
internal static PolarGeoCoordinate Convert(PolarGeoCoordinate source, CoordinateSystems destination) { PolarGeoCoordinate retVal; if (source.CoordinateSystem == CoordinateSystems.OSGB36 && destination == CoordinateSystems.WGS84) { retVal = Convert( source, EllipseParameter.GetEllipseParameters(EllipseParameter.Ellipses.Airy1830), HelmertTransform.GetTransform(HelmertTransform.HelmertTransformType.OSGB36toWGS84), EllipseParameter.GetEllipseParameters(EllipseParameter.Ellipses.WGS84)); } else if (source.CoordinateSystem == CoordinateSystems.WGS84 && destination == CoordinateSystems.OSGB36) { retVal = Convert( source, EllipseParameter.GetEllipseParameters(EllipseParameter.Ellipses.WGS84), HelmertTransform.GetTransform(HelmertTransform.HelmertTransformType.WGS84toOSGB36), EllipseParameter.GetEllipseParameters(EllipseParameter.Ellipses.Airy1830)); } else { throw new NotImplementedException("Requested source and destination are not currently supported"); } retVal.AlignSigFigs(source); return retVal; }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] CoordinateSystems coordinateSystems) { if (id != coordinateSystems.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(coordinateSystems); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CoordinateSystemsExists(coordinateSystems.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(coordinateSystems)); }
public static PolarGeoCoordinate ChangeCoordinateSystem( PolarGeoCoordinate original, CoordinateSystems destination) { PolarGeoCoordinate retVal = Converter.Convert(original, destination); return(retVal); }
public PolarGeoCoordinate(double lat, double lon, double height, AngleUnit units, CoordinateSystems coordinateSystem) { Lat = lat; Lon = lon; Height = height; Units = units; CoordinateSystem = coordinateSystem; }
public PolarGeoCoordinate( double lat, double lon, double height, AngleUnit units, CoordinateSystems coordinateSystem) { this.Lat = lat; this.Lon = lon; this.Height = height; this.Units = units; this.CoordinateSystem = coordinateSystem; }
public void Reset() { _Map.Reset(); _SyncContext.Send(d => { Model = new Model3DGroup(); CoordinateSystems.Clear(); }, null); }
private void ActivateCoordinateSystem(CoordinateSystems coordinateSystem) { if (coordinateSystem == _activeCoordinateSystem) { return; } _activeCoordinateSystem = coordinateSystem; CoordinateSystemChanged?.Invoke(_activeCoordinateSystem); }
private HelmertTransform(double _tx, double _ty, double _tz, double _rx, double _ry, double _rz, double _s, CoordinateSystems _outputCoordinateSystem) { tx = _tx; ty = _ty; tz = _tz; rx = _rx; ry = _ry; rz = _rz; s = _s; outputCoordinateSystem = _outputCoordinateSystem; }
public async Task <IActionResult> Create([Bind("Id,Name")] CoordinateSystems coordinateSystems) { if (ModelState.IsValid) { _context.Add(coordinateSystems); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(coordinateSystems)); }
public string GetSelectedCoordinateSystemName() { if (CoordinateSystemId.HasValue) { CoordinateSystemViewModel coordinateSystem = CoordinateSystems.FirstOrDefault(m => m.Id == CoordinateSystemId.Value); if (coordinateSystem != null) { return(coordinateSystem.Name); } return(""); } return(""); }
private static CoordinateSystem AddOrUpdateCS(string gCode, string data) { CoordinateSystem cs = CoordinateSystems.Where(x => x.Code == gCode).FirstOrDefault(); if (cs == null) { CoordinateSystems.Add(cs = new CoordinateSystem(gCode, data)); } else { cs.Parse(data); } return(cs); }
private HelmertTransform( double _tx, double _ty, double _tz, double _rx, double _ry, double _rz, double _s, CoordinateSystems _outputCoordinateSystem) { this.tx = _tx; this.ty = _ty; this.tz = _tz; this.rx = _rx; this.ry = _ry; this.rz = _rz; this.s = _s; this.outputCoordinateSystem = _outputCoordinateSystem; }
/// <summary> /// /// </summary> /// <param name="a">Use This To : represent X | Rho</param> /// <param name="b">Use This To : represent Y | Theta</param> public Point(double a, double b, CoordinateSystems system = CoordinateSystems.Cartesian) { switch (system) { case CoordinateSystems.Cartesian: this.a = a; this.b = b; break; case CoordinateSystems.Polar: this.a = a * Math.Cos(b); this.b = a * Math.Sin(b); break; default: throw new ArgumentOutOfRangeException(nameof(system), system, "You Must Use Available coord System"); } this.a = a; this.b = b; }
public static PolarGeoCoordinate ChangeCoordinateSystem( PolarGeoCoordinate original, CoordinateSystems destination) { PolarGeoCoordinate retVal = Converter.Convert(original, destination); return retVal; }
// City Specific public static City Factory(int cellLength) { City city = new City(); Stopwatch stopwatch = new Stopwatch(); Progress progress; #region LoadLayerModels&CensusData Console.WriteLine(">Extracting Shapefile data & build city map<"); stopwatch.Restart(); city.LandUse = Layer <LandUseModel> .Deserialize(NYCConst.LandUse_Layer); city.CensusTract = Layer <CensusTractModel> .Deserialize(NYCConst.CensusTracts_Layer); city.TaxiZone = Layer <TaxiZoneModel> .Deserialize(NYCConst.TaxiZones_Layer); int index = 0; List <CensusTractModel> toremove = new List <CensusTractModel>(); foreach (var tract in city.CensusTract) { if (city.removed.Contains(tract.boro_ct201)) { toremove.Add(tract); } else { tract.Object_ID = index++; } } foreach (var rem in toremove) { city.CensusTract.Remove(rem); } Dictionary <string, CensusData> censusDatas = JsonConvert.DeserializeObject <CensusData[]>(File.ReadAllText(NYCConst.CensusData)) .ToDictionary(p => p.id); Dictionary <string, RatingData> ratingDatas = JsonConvert.DeserializeObject <RatingData[]>(File.ReadAllText(NYCConst.PlacesData)) .ToDictionary(p => p.id); Dictionary <string, float> attraction = JsonConvert.DeserializeObject <Dictionary <string, float> >(File.ReadAllText(Path.Combine(NYCConst.Base_Dir, "Attraction.json"))); Console.WriteLine("Execution Time: {0} Seconds\n", (float)stopwatch.ElapsedMilliseconds / 1000); #endregion #region BuildDataTable // Create Data lookup table by LandUse Console.WriteLine(">Computing City Data<"); stopwatch.Restart(); progress = new Progress(1000, city.CensusTract.Count); progress.Start(); foreach (var tract in city.CensusTract) { var censusData = censusDatas[tract.boro_ct201]; var ratingData = ratingDatas[tract.boro_ct201]; var landTier = LandUseModel.AssessLandTierV3(city.LandUse.Interects(tract, 0.20f), censusData.Population, tract.ntaname); //calculate distance to the closest predefined city center var attr = attraction[tract.boro_ct201]; city.DataLookup[tract.Object_ID] = new RegionData(tract.Object_ID, tract.Latitude, tract.Longitude, tract.Geometry.Area, tract.Length, censusData, ratingData, attr, landTier.ToString()); progress.inc(); } progress.Stop(); foreach (LandUseModel.LandTier type in Enum.GetValues(typeof(LandUseModel.LandTier))) { Console.WriteLine("{0}: {1}", type, city.DataLookup.Where(i => i.Value.LandUse == type.ToString()).Count()); } Console.WriteLine("Execution Time: {0} Seconds\n", (float)stopwatch.ElapsedMilliseconds / 1000); #endregion #region Lattice Console.WriteLine(">Computing Lattice<"); stopwatch.Restart(); var minX = city.CensusTract.Min(z => z.Geometry.Coordinates.Min(c => c.X)); var minY = city.CensusTract.Min(z => z.Geometry.Coordinates.Min(c => c.Y)); var maxX = city.CensusTract.Max(z => z.Geometry.Coordinates.Max(c => c.X)); var maxY = city.CensusTract.Max(z => z.Geometry.Coordinates.Max(c => c.Y)); var min = CoordinateSystems.Convert(CoordinateSystems.COORSYSTEM.NAD83, CoordinateSystems.COORSYSTEM.WGS84, minY, minX); var max = CoordinateSystems.Convert(CoordinateSystems.COORSYSTEM.NAD83, CoordinateSystems.COORSYSTEM.WGS84, maxY, maxX); city.Lattice = new GeoLattice(min[1], min[0], max[1], max[0], cellLength); Console.WriteLine("Min Coordinates: {0},{1}", min[1], min[0]); Console.WriteLine("Max Coordinates: {0},{1}", max[1], max[0]); Console.WriteLine("Lattice Dimentions: Rows {0}, Columns {1}, Size {2}.", city.Lattice.Rows, city.Lattice.Columns, city.Lattice.Size); Console.WriteLine("Execution Time: {0} Seconds\n", (float)stopwatch.ElapsedMilliseconds / 1000); #endregion #region Mapping Console.WriteLine(">Maping Lattice cells to layers<"); stopwatch.Restart(); progress = new Progress(1000, city.Lattice.Size); progress.Start(); if (File.Exists(Path.Combine(NYCConst.Base_Dir, "PrimaryLookupFile.json"))) { var text = File.ReadAllText(Path.Combine(NYCConst.Base_Dir, "PrimaryLookupFile.json")); city.PrimaryLookup = JsonConvert.DeserializeObject <Dictionary <int, int> >(text); } else { city.Lattice.ForEachCell((i, j, cell) => { ShapeModel shape = city.CensusTract.Contains(cell.Center.x, cell.Center.y); if (shape != null) { city.PrimaryLookup.Add(cell.ID, shape.Object_ID); } progress.inc(); }); } progress.Stop(); Console.WriteLine("Map size: {0}", city.PrimaryLookup.Count()); Console.WriteLine("Distinct # of Objects: {0}", city.PrimaryLookup.Values.Distinct().Count()); Console.WriteLine("Execution Time: {0} Seconds\n", (float)stopwatch.ElapsedMilliseconds / 1000); #endregion #region BuildAdjacencyMatrix Console.WriteLine(">Building Adjacency Matrix<"); progress = new Progress(1000, city.Count * city.Count); progress.Start(); Parallel.ForEach(city.CensusTract, t1 => { foreach (var t2 in city.CensusTract) { Tuple <int, int> idx = null; if (t1.Object_ID <= t2.Object_ID) { idx = new Tuple <int, int>(t1.Object_ID, t2.Object_ID); } else { idx = new Tuple <int, int>(t2.Object_ID, t1.Object_ID); } lock (city.AdjacencyMatrix) { if (!city.AdjacencyMatrix.Keys.Contains(idx.ToString())) { var dist = t1.Geometry.Centroid.Distance(t2.Geometry.Centroid); city.AdjacencyMatrix.Add(idx.ToString(), new Edge() { SenderID = t1.Object_ID, ReceiverID = t2.Object_ID, Distance = dist }); } } progress.inc(); } }); progress.Stop(); #endregion #region SaveToFile Console.WriteLine(">Saving Data<"); stopwatch.Restart(); string latticefile = Path.Combine(NYCConst.Base_Dir, string.Format(@"Lattice-{0}.json", cellLength)); string primarylookupfile = Path.Combine(NYCConst.Base_Dir, City.PrimaryLookupFile + ".json"); string datalookupfile = Path.Combine(NYCConst.Base_Dir, City.DataLookupFile + ".json"); string adjacencymatrixfile = Path.Combine(NYCConst.Base_Dir, City.AdjacencyMatrixFile + ".json"); city.Lattice.Save(latticefile); File.WriteAllText(primarylookupfile, JsonConvert.SerializeObject(city.PrimaryLookup)); File.WriteAllText(datalookupfile, JsonConvert.SerializeObject(city.DataLookup)); File.WriteAllText(adjacencymatrixfile, JsonConvert.SerializeObject(city.AdjacencyMatrix)); File.WriteAllText(NYCConst.NYCConfigFile, JsonConvert.SerializeObject(new Dictionary <string, string> { { City.LatticeFile, latticefile }, { City.PrimaryLookupFile, primarylookupfile }, { City.DataLookupFile, datalookupfile }, { City.AdjacencyMatrixFile, adjacencymatrixfile } })); Console.WriteLine("Execution Time: {0} Seconds\n", (float)stopwatch.ElapsedMilliseconds / 1000); #endregion return(city); }
// gets transform between raster's native projection and the map projection private void GetTransform(CoordinateSystems.ICoordinateSystem mapProjection) { if (mapProjection == null || _projection == "") { _transform = null; return; } CoordinateSystemFactory cFac = new CoordinateSystemFactory(); // get our two projections ICoordinateSystem srcCoord = cFac.CreateFromWkt(_projection); ICoordinateSystem tgtCoord = mapProjection; // raster and map are in same projection, no need to transform if (srcCoord.WKT == tgtCoord.WKT) { _transform = null; return; } // create transform _transform = new CoordinateTransformationFactory().CreateFromCoordinateSystems(srcCoord, tgtCoord); }
/// <summary> /// Add a new user-defined coordinate system to this model, if it does not /// already exist within it /// </summary> /// <param name="cSystem">The user-defined coordinate system to be added.</param> /// <returns>True if the coordinate system could be added, /// false if it already existed within the model.</returns> public bool Add(UserCoordinateSystemReference cSystem) { return(CoordinateSystems.TryAdd(cSystem)); }
public void Render() { bool showPointCloud = false; bool showKeyFrameTrajectory = false; bool showFrameTrajectory = false; bool onlyNew = true; _SyncContext.Send(d => { showPointCloud = ShowPointCloud; showKeyFrameTrajectory = ShowKeyFrameTrajectory; showFrameTrajectory = ShowFrameTrajectory; onlyNew = !(showPointCloud && Model != null && (Model as Model3DGroup).Children.Count == 0); }, null); if (_Map.HasFrames() || _Map.HasKeyFrames()) { List <Vector3> pointsKeyFrame = new List <Vector3>(); List <Vector3> pointsFrame = new List <Vector3>(); if (showKeyFrameTrajectory) { pointsKeyFrame = _Map.GetTrajectory(TrajectoryType.Optimazation); } if (showFrameTrajectory) { pointsFrame = _Map.GetTrajectory(TrajectoryType.PreOptimazation); } List <GeometryModel3D> pointClouds = new List <GeometryModel3D>(); if (showPointCloud) { pointClouds = _Map.GetPointCloud(onlyNew); } _SyncContext.Post(d => { TrajectoryKeyFrame = new Point3DCollection(pointsKeyFrame.SelectMany(c => new List <Point3D>() { new Point3D(c.X, c.Y, c.Z), new Point3D(c.X, c.Y, c.Z) })); if (TrajectoryKeyFrame.Count > 0) { TrajectoryKeyFrame.RemoveAt(0); } TrajectoryFrame = new Point3DCollection(pointsFrame.SelectMany(c => new List <Point3D>() { new Point3D(c.X, c.Y, c.Z), new Point3D(c.X, c.Y, c.Z) })); if (TrajectoryFrame.Count > 0) { TrajectoryFrame.RemoveAt(0); } CameraPosition = new MatrixTransform3D(_Map.LastTransformation().Matrix3D); if (Model == null || !showPointCloud) { Model = new Model3DGroup(); } foreach (GeometryModel3D pointCloud in pointClouds) { (Model as Model3DGroup).Children.Add(pointCloud); } if (ShowKeyFrameOrientations) { foreach (Visual3D visual3D in _Map.GetKeyFrameOrientations(CoordinateSystems.Count != 0)) { CoordinateSystems.Add(visual3D); } } else { CoordinateSystems.Clear(); } }, null); } else { _SyncContext.Post(d => { if (TrajectoryFrame != null && TrajectoryFrame.Count > 0) { TrajectoryFrame = new Point3DCollection(); } if (TrajectoryKeyFrame != null && TrajectoryKeyFrame.Count > 0) { TrajectoryKeyFrame = new Point3DCollection(); } }, null); } }