public static void PubliserLeveranse(string id, NinRavenDb arkiv, IUserDatabase userDb) { Log.i("DDL", "Publiser dataleveranse #" + id); var dataDelivery = arkiv.HentDataleveranse(id); switch (dataDelivery.Publisering) { case Status.Gjeldende: throw new Exception("Leveransen er allerede gjeldende."); case Status.Utgått: throw new Exception("Leveransen er utgått og kan ikke publiseres."); } var dataDeliveryMsSql = new Dataleveranse(dataDelivery); MapProjection.ConvertGeometry(dataDeliveryMsSql); var userInstitution = userDb.GetUserInstitution(dataDelivery.Username); foreach (var natureArea in dataDeliveryMsSql.Metadata.NatureAreas) { natureArea.Institution = userInstitution; } SqlServer.DeleteDataDelivery(dataDeliveryMsSql.Metadata.UniqueId.LocalId); SqlServer.LagreDataleveranse(dataDeliveryMsSql); MarkerSistGjeldendeLeveranseSomUtgått(arkiv, dataDelivery); dataDelivery.Publisering = Status.Gjeldende; arkiv.LagreDataleveranse(dataDelivery); arkiv.SaveChanges(); }
/// <summary> /// Builds a projector with the given parameters. /// </summary> /// <param name="projection">The projection.</param> /// <param name="mapSize">Size of the map.</param> /// <returns></returns> public static MapProjector BuildProjector(MapProjection projection, float[] mapSize) { var mapRatio = projection == MapProjection.Default ? ControlCoordinatesProjector.PreferredRatio : MercatorProjector.PreferredRatio; var normalizedW = mapSize[0] / mapRatio[0]; var normalizedH = mapSize[1] / mapRatio[1]; float ox = 0f, oy = 0f; if (normalizedW < normalizedH) { var h = mapSize[0] * mapRatio[1] / mapRatio[0]; oy = (float)(mapSize[1] - h) * 0.5f; mapSize[1] = h; } else { var w = mapSize[1] * mapRatio[0] / mapRatio[1]; ox = (float)(mapSize[0] - w) * 0.5f; mapSize[0] = w; } return (projection == MapProjection.Default ? new ControlCoordinatesProjector(mapSize[0], mapSize[1], ox, oy) : new MercatorProjector(mapSize[0], mapSize[1], ox, oy)); }
public static Grid ImportGrid(int sourceEpsgCode, RutenettType rutenettType, string fullPath) { var grid = Grid2.FromShapeFile(fullPath, rutenettType, sourceEpsgCode); Grid importGrid = new Grid(rutenettType); if (sourceEpsgCode != Config.Settings.Map.SpatialReferenceSystemIdentifier) { MapProjection reproject = new MapProjection(Config.Settings.Map.SpatialReferenceSystemIdentifier); foreach (var cell in grid.Cells) { if (!reproject.IsInsideBounds(cell.Geometry)) { continue; // TODO: What do we do? } cell.Geometry = reproject.Reproject(cell.Geometry); importGrid.Cells.Add(cell); } } else { importGrid.Cells.AddRange(grid.Cells); } return(importGrid); }
public override void Execute() { Types.RavenDb.Dataleveranse dataleveranse; using (var streamReader = File.OpenText(dataFile)) { var fileContent = streamReader.ReadToEnd(); XDocument dataDeliveryXml = XDocument.Parse(fileContent); dataleveranse = DataleveranseXmlGreier.ParseDataDelivery(dataDeliveryXml); } //DataleveranseXmlGreier.ValidateDataDeliveryContent(dataDelivery); var dataDeliveryMsSql = new Dataleveranse(dataleveranse); MapProjection.ConvertGeometry(dataDeliveryMsSql); foreach (var natureArea in dataDeliveryMsSql.Metadata.NatureAreas) { natureArea.Institution = "Institution"; } dataDeliveryMsSql.Id = "1"; dataDeliveryMsSql.Created = DateTime.Now; SqlServer.DeleteDataDelivery(dataDeliveryMsSql.Metadata.UniqueId.LocalId); SqlServer.LagreDataleveranse(dataDeliveryMsSql); }
/// <summary> /// Projects a geometry using the given transformation. /// </summary> /// <param name="coordinateTransform">The transformation to use.</param> /// <returns>A projected point object.</returns> public override Geometry Project(ICoordinateTransformation coordinateTransform) { if (coordinateTransform == null) { throw new ArgumentNullException("coordinateTransform"); } if (!(coordinateTransform.MathTransform is Geotools.CoordinateTransformations.MapProjection)) { throw new ArgumentException("transform must be a MapProjection."); } int sourceSRID = int.Parse(coordinateTransform.SourceCS.AuthorityCode); int targetSRID = int.Parse(coordinateTransform.TargetCS.AuthorityCode); MapProjection projection = (MapProjection)coordinateTransform.MathTransform; int newSRID = GetNewSRID(coordinateTransform); double x = 0.0; double y = 0.0; Coordinate external = _geometryFactory.PrecisionModel.ToExternal(new Coordinate(this._coordinate)); if (this.GetSRID() == sourceSRID) { projection.MetersToDegrees(external.X, external.Y, out x, out y); } else if (this.GetSRID() == targetSRID) { projection.DegreesToMeters(external.X, external.Y, out x, out y); } Coordinate projectedCoordinate = _geometryFactory.PrecisionModel.ToInternal(new Coordinate(x, y)); return(new Point(projectedCoordinate, this.PrecisionModel, newSRID)); } // public override IGeometry Project(OGC.CoordinateTransformations.CT_Coordinat
public WorldFileImage(BitmapSource bitmap, Matrix transform, MapProjection projection) { Bitmap = bitmap; Transform = transform; Projection = projection; if (transform.M12 != 0 || transform.M21 != 0) { Rotation = (Math.Atan2(transform.M12, transform.M11) + Math.Atan2(transform.M21, -transform.M22)) * 90d / Math.PI; // effective unrotated transform transform.M11 = Math.Sqrt(transform.M11 * transform.M11 + transform.M12 * transform.M12); transform.M22 = -Math.Sqrt(transform.M22 * transform.M22 + transform.M21 * transform.M21); transform.M12 = 0; transform.M21 = 0; } var rect = new Rect( transform.Transform(new Point()), transform.Transform(new Point(bitmap.PixelWidth, bitmap.PixelHeight))); BoundingBox = projection != null ? projection.RectToBoundingBox(rect) : new BoundingBox { West = rect.X, East = rect.X + rect.Width, South = rect.Y, North = rect.Y + rect.Height }; }
public static async Task <WorldFileImage> ReadWorldFileImage(string imagePath, string worldFilePath, string projFilePath = null) { BitmapSource bitmap; using (var stream = File.OpenRead(imagePath)) { #if WINDOWS_UWP bitmap = await ImageLoader.LoadImageAsync(stream.AsRandomAccessStream()); #else bitmap = await ImageLoader.LoadImageAsync(stream); #endif } var transform = ReadWorldFile(worldFilePath); MapProjection projection = null; if (projFilePath != null && File.Exists(projFilePath)) { projection = new GeoApiProjection { WKT = File.ReadAllText(projFilePath) }; } return(new WorldFileImage(bitmap, transform, projection)); }
private static SqlGeometry CreateMetadataArea(string fylke, int targetSrs) { SqlGeometry metadataArea = new SqlGeometry(); const int metadatapolygonEpsg = 3857; const string metadatapolygon = "POLYGON((1102527.6959853824 9005963.546616036, 1237056.8657672927 9005963.546616036, 1237056.8657672927 9137740.98337968, 1102527.6959853824 9137740.98337968, 1102527.6959853824 9005963.546616036))"; if (metadatapolygon.Length == 0) { var path = FileLocator.FindFileInTree(@"Data\area\fylker.txt"); var areas = AreaCollection.FromGeoJson(File.ReadAllText(path), 4326); foreach (var area in areas) { if (area.Name.Equals(fylke)) { metadataArea = area.Geometry; } } } else { metadataArea = SqlGeometry.Parse(metadatapolygon); metadataArea.STSrid = metadatapolygonEpsg; metadataArea = MapProjection.Reproject(metadataArea, targetSrs); } return(metadataArea); }
private SqlGeometry GeometryFromWkb(string wellKnownText, int srid) { var x = new MapProjection(norge.Srid).ReprojectFromWkt(wellKnownText, srid); SqlGeometry geometry = SqlGeometry.STGeomFromText(new SqlChars(x), norge.Srid); return(geometry); }
internal void setProjection(MapProjection p) { if (projection == p) { return; } projection = p; }
public void setProjection(MapProjection p) { if (projection == p) { return; } projection = p; resetMap(); }
private void SetMapProjection(MapProjection mapProjection) { if (this.mapProjection != mapProjection) { this.mapProjection = mapProjection; this.map.MapProjection = mapProjection; this.NotifyPropertyChanged(nameof(IsGlobeProjection)); } }
public static GridLayer FromXml(XDocument gridXml) { var gridLayer = (GridLayer)ParseXml(gridXml); if (gridXml.Root.Name.LocalName.Equals("OmraadeKart")) { foreach (var gridLayerCell in gridLayer.Cells) { MapProjection.ConvertGeometry((GridLayerCellCustom)gridLayerCell); } } return(gridLayer); }
protected override string GetCrsParam(MapProjection projection) { switch (projection.CrsId) { case "AUTO2:97001": return(string.Format(CultureInfo.InvariantCulture, "CRS=AUTO2:7CS01,1,{0},{1}", projection.Center.Longitude, projection.Center.Latitude)); case "AUTO2:97002": return(string.Format(CultureInfo.InvariantCulture, "CRS=AUTO2:7CS02,1,{0},{1}", projection.Center.Longitude, projection.Center.Latitude)); default: return(base.GetCrsParam(projection)); } }
public void TestProjCordinate() { Coordinate C1 = new Coordinate(61.0, 5.0); ProjCoordinate P1 = MapProjection.ToEquiProjectedCoordinate(C1); Coordinate C2 = MapProjection.FromEquiCoordinate(P1); double d = C1.LatitudeDeg - C2.LatitudeDeg; double d2 = C1.LongitudeDeg - C2.LongitudeDeg; Assert.IsFalse(d > 0.1 && d < -0.1, "Coordinate C1 != C2"); Assert.IsFalse(d2 > 0.1 && d2 < -0.1, "Coordinate C1 != C2"); //Assert.AreEqual(C1.Latitude, C2.Latitude, "Coordinate C1 != C2"); //Assert.AreEqual(C1.Longitude, C2.Longitude, "Coordinate C1 != C2"); }
public override string GetStepParameters() { var parameters = new List <string>(); parameters.Add(Name != null ? Name.ToStepValue() : "$"); parameters.Add(Description != null ? Description.ToStepValue() : "$"); parameters.Add(GeodeticDatum != null ? GeodeticDatum.ToStepValue() : "$"); parameters.Add(VerticalDatum != null ? VerticalDatum.ToStepValue() : "$"); parameters.Add(MapProjection != null ? MapProjection.ToStepValue() : "$"); parameters.Add(MapZone != null ? MapZone.ToStepValue() : "$"); parameters.Add(MapUnit != null ? MapUnit.ToStepValue() : "$"); return(string.Join(", ", parameters.ToArray())); }
public IActionResult ResultsMap(ResultsFilter filter) { var subjects = _api.GetSubjects(); filter.qualifications = !string.IsNullOrWhiteSpace(filter.qualifications) ? filter.qualifications : string.Join(",", Enum.GetNames(typeof(QualificationOption))); FilteredList <Subject> filteredSubjects; if (filter.SelectedSubjects.Count > 0) { filteredSubjects = new FilteredList <Subject>( subjects.Where(subject => filter.SelectedSubjects.Contains(subject.Id)).ToList(), subjects.Count ); } else { filteredSubjects = new FilteredList <Subject>(subjects, subjects.Count); } var mapsEnabled = _featureFlags.Maps; PaginatedList <Course> courses; var queryFilter = filter.ToQueryFilter(); var viewModel = new ResultsViewModel { Subjects = filteredSubjects, FilterModel = filter, MapsEnabled = mapsEnabled }; queryFilter.pageSize = 0; courses = _api.GetCourses(queryFilter); var courseGroups = GroupByProvider(courses); IMapProjection <CourseGroup> mapProjection = new MapProjection <CourseGroup>(courseGroups, filter.Coordinates, 400, filter.zoomlevel); viewModel.Map = new MapViewModel { CourseGroups = mapProjection.Markers, MyLocation = filter.Coordinates, Map = mapProjection, }; viewModel.Courses = courses; return(View(viewModel)); }
public virtual MapProjection GetProjection(string crsId) { MapProjection projection = null; switch (crsId) { case WorldMercatorProjection.DefaultCrsId: projection = new WorldMercatorProjection(); break; case WebMercatorProjection.DefaultCrsId: projection = new WebMercatorProjection(); break; case EquirectangularProjection.DefaultCrsId: projection = new EquirectangularProjection(); break; case OrthographicProjection.DefaultCrsId: projection = new OrthographicProjection(); break; case AutoEquirectangularProjection.DefaultCrsId: projection = new AutoEquirectangularProjection(); break; case GnomonicProjection.DefaultCrsId: projection = new GnomonicProjection(); break; case StereographicProjection.DefaultCrsId: projection = new StereographicProjection(); break; case "EPSG:97003": // proprietary CRS ID projection = new AzimuthalEquidistantProjection(crsId); break; default: break; } return(projection); }
/// <summary> /// Applies the projection to the coordinates. /// </summary> /// <param name="geometry">The geometry object to apply the filter to.</param> public void Filter(Geometry geometry) { /*if (geometry is Polygon) * { * Polygon polygon = (Polygon)geometry; * Filter(polygon.Shell); * foreach(LinearRing linearring in polygon.Holes) * { * Filter(linearring); * } * }*/ if (geometry is LinearRing || geometry is LineString || geometry is Point) { int sourceSRID = int.Parse(_coordinateTransform.SourceCS.AuthorityCode); int targetSRID = int.Parse(_coordinateTransform.TargetCS.AuthorityCode); MapProjection projection = (MapProjection)_coordinateTransform.MathTransform; Coordinates projectedCoordinates = new Coordinates(); double x = 0.0; double y = 0.0; Coordinate coordinate; for (int i = 0; i < geometry.GetCoordinates().Count; i++) { coordinate = geometry.GetCoordinates()[i]; if (geometry.GetSRID() == sourceSRID) { projection.MetersToDegrees(coordinate.X, coordinate.Y, out x, out y); } else if (geometry.GetSRID() == targetSRID) { projection.DegreesToMeters(coordinate.X, coordinate.Y, out x, out y); } coordinate.X = x; coordinate.Y = y; } } /*else * { * throw new NotSupportedException(geometry.GetType().Name); * }*/ }
private IEnumerator Setup() { SetupComplete = false; Map = FindObjectOfType <MapTileManager>(); while (!Map.SetupComplete) { yield return(null); } var proj = Map.Metadata.UtmProjection; Projection = new MapProjection(proj.Zone, proj.North); var point = Map.Metadata.Position - Map.Metadata.AnchorOffset; Origin = new UtmCoord(point.X, point.Y); SetupComplete = true; }
public override void Reset() { GPSLocation = new FsmVector3 { UseVariable = true }; mapProjection = MapProjection.EquidistantCylindrical; minLongitude = -180f; maxLongitude = 180f; minLatitude = -90f; maxLatitude = 90f; minX = 0f; minY = 0f; width = 1f; height = 1f; normalized = true; projectedX = null; projectedY = null; everyFrame = false; }
public override void Reset() { GPSLocation = new FsmVector3 { UseVariable = true }; mapProjection = MapProjection.EquidistantCylindrical; minLongitude = -180f; maxLongitude = 180f; minLatitude = -90f; maxLatitude = 90f; minX = 0; minY = 0; width = 1; height = 1; normalized = true; projectedX = null; projectedY = null; everyFrame = false; }
/// <summary> /// Projects a geometry using the given transformation. /// </summary> /// <param name="coordinateTransform">The transformation to use.</param> /// <returns>A projected line string object.</returns> public override Geometry Project(ICoordinateTransformation coordinateTransform) { if (coordinateTransform == null) { throw new ArgumentNullException("coordinateTransform"); } if (!(coordinateTransform.MathTransform is Geotools.CoordinateTransformations.MapProjection)) { throw new ArgumentException("coordinateTransform must be a MapProjection."); } int sourceSRID = int.Parse(coordinateTransform.SourceCS.AuthorityCode); int targetSRID = int.Parse(coordinateTransform.TargetCS.AuthorityCode); MapProjection projection = (MapProjection)coordinateTransform.MathTransform; int newSRID = GetNewSRID(coordinateTransform); Coordinates projectedCoordinates = new Coordinates(); double x = 0.0; double y = 0.0; Coordinate projectedCoordinate; Coordinate external; Coordinate coordinate; for (int i = 0; i < _points.Count; i++) { coordinate = _points[i]; external = _geometryFactory.PrecisionModel.ToExternal(coordinate); if (this._SRID == sourceSRID) { projection.MetersToDegrees(external.X, external.Y, out x, out y); } else if (this._SRID == targetSRID) { projection.DegreesToMeters(external.X, external.Y, out x, out y); } projectedCoordinate = _geometryFactory.PrecisionModel.ToInternal(new Coordinate(x, y)); projectedCoordinates.Add(projectedCoordinate); } return(new LineString(projectedCoordinates, this.PrecisionModel, newSRID)); }
public IActionResult GetExpiredMetadatasByNatureAreaLocalId(string localId) { var metadatas = SqlServer.GetMetadatasByNatureAreaLocalIds(new List <string> { localId }, false); var dataDeliveriesWithNatureArea = new List <Dataleveranse>(); if (metadatas.Count == 1) { var dataDeliveries = ninRavenDb.HentDataleveranserGjeldendeOgUtgåtte(metadatas[0].UniqueId.LocalId); foreach (var dataDelivery in dataDeliveries) { foreach (var natureArea in dataDelivery.Metadata.NatureAreas) { if (!natureArea.UniqueId.LocalId.Equals(new Guid(localId))) { continue; } dataDelivery.Metadata.NatureAreas.Clear(); var natureAreaExport = new Nin.Types.RavenDb.NatureAreaExport(natureArea); AddCodeHierarchyInfo(natureAreaExport.Parameters); dataDelivery.Metadata.NatureAreas.Add(natureAreaExport); MapProjection.ConvertGeometry(dataDelivery, metadatas[0].GetAreaEpsgCode()); natureAreaExport.Areas = SqlServer.GetAreaLinkInfos(natureAreaExport.Area, natureAreaExport.AreaEpsgCode); dataDeliveriesWithNatureArea.Add(dataDelivery); break; } } } var metadatasJson = JsonConvert.SerializeObject(dataDeliveriesWithNatureArea, jsonSerializerSettings); var contentResult = new NinJsonResult(metadatasJson); return(contentResult); }
public override MapProjection GetProjection(string crsId) { MapProjection projection = null; var str = crsId.StartsWith("EPSG:") ? crsId.Substring(5) : crsId.StartsWith("AUTO2:") ? crsId.Substring(6) : null; if (int.TryParse(str, out int code)) { if (CoordinateSystemWkts.TryGetValue(code, out string wkt)) { projection = new GeoApiProjection(wkt); } else { switch (code) { case WorldMercator: projection = new WorldMercatorProjection(); break; case WebMercator: projection = new WebMercatorProjection(); break; case AutoUtm: projection = new AutoUtmProjection(); break; case int c when c >= Ed50UtmFirst && c <= Ed50UtmLast: projection = new Ed50UtmProjection(code % 100); break; case int c when c >= Etrs89UtmFirst && c <= Etrs89UtmLast: projection = new Etrs89UtmProjection(code % 100); break; case int c when c >= Wgs84UtmNorthFirst && c <= Wgs84UtmNorthLast: projection = new Wgs84UtmProjection(code % 100, true); break; case int c when c >= Wgs84UtmSouthFirst && c <= Wgs84UtmSouthLast: projection = new Wgs84UtmProjection(code % 100, false); break; case Wgs84UpsNorth: projection = new UpsNorthProjection(); break; case Wgs84UpsSouth: projection = new UpsSouthProjection(); break; default: break; } } } return(projection ?? base.GetProjection(crsId)); }
public void setProjection(MapProjection p) { if(projection == p) return; projection = p; resetMap(); }
public ExcelGenerator(Naturetypekodetre allCodes) { naturtypeKodetre = allCodes; reproject = new MapProjection(Config.Settings.Export.ExcelSpatialReferenceSystemIdentifier); }
public MapVisulizer() { InitializeComponent(); _player = new Player(); CenterMarker.SetValue(Canvas.TopProperty, (backgr.Height - CenterMarker.Height) / 2); CenterMarker.SetValue(Canvas.LeftProperty, (backgr.Width - CenterMarker.Width) / 2); _game = GameManager.Instance.CreateGame(_player, "TestGame"); _game.IsNetworkEnabled = false; _game.StartGameLoop(); Group group = new Group(); GameManager.Instance.GameData.InitAllData(); Position pos = new Position(60.25, 5.25); BaseUnit unitMain = GameManager.Instance.GameData.CreateUnit(_player, group, "arleighburke", "Arleigh Burke", pos, true); unitMain.MovementOrder.AddWaypoint(new Waypoint(new Position(60.5, 5.5))); unitMain.ActualSpeedKph = 40.0; unitMain.MoveToNewCoordinate(1.0); unitMain.Position.BearingDeg = .0; //pos = new Position(61.5, 5.5); BaseUnit unitFollow = GameManager.Instance.GameData.CreateUnit(_player, group, "arleighburke", "Hood", pos, true); BaseUnit unitFollow2 = GameManager.Instance.GameData.CreateUnit(_player, group, "arleighburke", "Hood", pos, true); MovementFormationOrder order = new MovementFormationOrder(unitMain, 326000, -326000, 0); MovementFormationOrder order2 = new MovementFormationOrder(unitMain, -326000, 326000, 0); Waypoint waypoint = order.GetActiveWaypoint(); Waypoint waypoint2 = order2.GetActiveWaypoint(); unitFollow.Position = waypoint.Position.Clone(); unitFollow2.Position = waypoint2.Position.Clone(); double distanceM = MapHelper.CalculateDistanceM(unitMain.Position.Coordinate, unitFollow.Position.Coordinate); ProjCoordinate min = MapProjection.ToEquiProjectedCoordinate(new Coordinate(61.0, 6.0)); ProjCoordinate max = MapProjection.ToEquiProjectedCoordinate(new Coordinate(62.0, 5)); Coordinate CenterCoordinate = MapHelper.CalculateMidpoint(new Coordinate(62.0, 5.0), new Coordinate(62.0, 6.0)); RotateTransform rt = new RotateTransform(); rt.Angle = (double)unitMain.Position.BearingDeg; rt.CenterX = mainShip.Width / 2; rt.CenterY = mainShip.Height / 2; double testX = MapHelper.LongitudeToXvalue(unitMain.Position.Coordinate.LongitudeDeg, 1); double testY = MapHelper.LatitudeToYvalue(unitMain.Position.Coordinate.LatitudeDeg, 1); testX = ((512 - 10) / 2) + testX; testY = ((512 - 10) / 2) + testY; mainShip.SetValue(Canvas.LeftProperty, testX); mainShip.SetValue(Canvas.TopProperty, testY); mainShip.RenderTransform = rt; rt.Angle = (double)waypoint.Position.BearingDeg; folowingShip.SetValue(Canvas.LeftProperty, ((512 - 10) / 2) + MapHelper.LongitudeToXvalue(waypoint.Position.Coordinate, 1)); folowingShip.SetValue(Canvas.TopProperty, ((512 - 10) / 2) + MapHelper.LatitudeToYvalue(waypoint.Position.Coordinate, 1)); folowingShip.RenderTransform = rt; rt.Angle = (double)waypoint2.Position.BearingDeg; folowingShip2.SetValue(Canvas.LeftProperty, ((512 - 10) / 2) + MapHelper.LongitudeToXvalue(waypoint2.Position.Coordinate, 1)); folowingShip2.SetValue(Canvas.TopProperty, ((512 - 10) / 2) + MapHelper.LatitudeToYvalue(waypoint2.Position.Coordinate, 1)); folowingShip2.RenderTransform = rt; }
/// <summary> /// Example of how to plot a mesh file. A mesh contains bottom levels in each node. /// </summary> public static void MeshTest(bool makeBmp) { DHI.Chart.Map.Chart.Init(); // Load mesh data string pathName = Path.Combine(UnitTestHelper.TestDataRoot, @"oresund.mesh"); MeshFile meshFile = MeshFile.ReadMesh(pathName); // FemGridData is data for the bottom levels, a value in each element node, used for coloring FemGridData data = new FemGridData(); data.CreateNodesAndElements(meshFile.NumberOfNodes, meshFile.NumberOfElements, meshFile.X, meshFile.Y, meshFile.Z.ToFloatArray(), meshFile.ElementTable); // Create chart DHI.Chart.Map.Chart chart = new DHI.Chart.Map.Chart(); // Add overlay that plots the bottom levels FemGridOverlay overlay = new FemGridOverlay(); overlay.SetGridData(data); overlay.EnableNiceValue = true; overlay.CreateAutoScaledRainbowPalette(); overlay.EnableIsoline = true; overlay.ColoringType = MapOverlay.EColoringType.ContinuousColoring; overlay.SetFeathering(true, 0.5f); overlay.EnableIsolineLabel = true; chart.AddOverlay(overlay); // Grab map projection of meshfile MapProjection mapProj = new MapProjection(meshFile.ProjectionString); double lonOrigin, latOrigin, eastOrigin, northOrigin; mapProj.GetOrigin(out lonOrigin, out latOrigin); mapProj.Geo2Proj(lonOrigin, latOrigin, out eastOrigin, out northOrigin); double convergence = mapProj.GetConvergence(lonOrigin, latOrigin); // Overlay adding geographical lines // Mesh is drawn in map projection coordinates GeoGridOverlay ggOverlay = new GeoGridOverlay(); ggOverlay.ReferenceProjection = meshFile.ProjectionString; ggOverlay.DisplayProjection = meshFile.ProjectionString; // Origin for mesh data is the origin of the projection ggOverlay.SetGeoOrigin(lonOrigin, latOrigin); ggOverlay.SetOrigin(eastOrigin, northOrigin); // Mesh overlay draws in map projection coordinates, so north-Y rotation is the convergence (which is zero) ggOverlay.SetNYCRotation(convergence); ggOverlay.EnableLonLatGrid = true; ggOverlay.EnableMapProjGrid = true; // DataValid must be set after changing in GeoGridOverlay ggOverlay.DataValid = true; chart.AddOverlay(ggOverlay); // Select rectangle to plot, by default the full data area MzRectangle wrect = new MzRectangle(); data.GetDataArea(wrect); // Here you may limit the area to be plotted //wrect.X0 = wrect.X0 + 20000; //wrect.Y0 = wrect.Y0 + 20000; //wrect.X1 = wrect.X0 + 30000; //wrect.Y1 = wrect.Y0 + 30000; chart.SetDataArea(wrect); chart.SetView(wrect); //chart.GetActiveCoordinateSystem().SetDrawAxis(true, true); //chart.GetActiveCoordinateSystem().EnableBorder(true); //chart.DrawGrid = true; //chart.DrawTitle = true; // Draw to bitmap double ratio = wrect.Width / (double)wrect.Height; Bitmap bmp = new Bitmap(((int)(ratio * 1024)) + 10, 1024); chart.Draw(bmp); chart.Dispose(); if (makeBmp) { string pngFilepath = Path.Combine(UnitTestHelper.TestDataRoot, @"oresundMesh.png"); bmp.Save(pngFilepath); System.Diagnostics.Process.Start(pngFilepath); } }
public string HentOmraadeForMatrikkelenhet(int kommuneNr, int gaardsnr, int bruksNr, int festNr, int seksjonsNr) { var wktFlate = "POLYGON EMPTY"; if (kommuneNr == 0 || gaardsnr == 0 || bruksNr == 0) { return(wktFlate); } var matrikkelNummer = new Matrikkelnummer { gaardsnummer = gaardsnr, bruksnummer = bruksNr, kommunenummer = kommuneNr.ToString(), festenummer = festNr, seksjonsnummer = seksjonsNr }; var matrikkelKontekst = new MatrikkelKontekst { klientnavn = "NiN-portal", klientversjon = "1.0", spraak = "", systemversjon = "1.1", koordinatsystem = new KoordinatsystemKode { erGyldig = true, kodeverdi = "22", kodebeskrivelse = "test" } }; OmraadeListe omraadeListe = matrikkelKartKlient.HentOmraadeForMatrikkelenhet(matrikkelNummer, matrikkelKontekst); var csc = new MapProjection(Config.Settings.Map.SpatialReferenceSystemIdentifier); var flate = new StringBuilder(); switch (omraadeListe.Count) { case 0: flate.Append("POLYGON EMPTY"); break; case 1: flate.Append("POLYGON "); flate.Append(BuildPolygonWkt(omraadeListe[0])); break; default: if (omraadeListe.Count > 1) // ex: 1103-56/1956 { flate.Append("MULTIPOLYGON ("); foreach (Omraade omraade in omraadeListe) { flate.Append(BuildPolygonWkt(omraade)); flate.Append(","); } flate.Remove(flate.Length - 1, 1); // remove last "," flate.Append(")"); } break; } // Convert to display-koordinat system wktFlate = csc.ReprojectFromWkt(flate.ToString(), 32632); return(wktFlate); }
internal void setProjection(MapProjection p) { if (projection == p) return; projection = p; }