예제 #1
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                }
                _axMap.ExtentsChanged -= OnMapExtentsChanged;
                _axMap.LayerRemoved   -= OnLayerRemoved;
                _axMap.LayerAdded     -= OnLayerAdded;
                _axMap = null;

                if (_sfGraticule != null)
                {
                    _sfGraticule.EditClear();
                }
                _sfGraticule = null;

                _geoProjection    = null;
                _graticuleExtents = null;
                _boundaryExtents  = null;
                _mapExtents       = null;
                _mapLayersHandler.OnLayerVisibilityChanged -= OnLayerVisibleChange;
                _mapLayersHandler.MapRedrawNeeded          -= OnRedrawNeeded;
                _mapLayersHandler.RemoveLayer("Mask");
                _mapLayersHandler.RemoveLayer(Name);
                _mapLayersHandler = null;
            }
        }
예제 #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="mapControl"></param>
        /// <param name="layersHandler"></param>
        public Graticule(AxMap mapControl, MapLayersHandler layersHandler)
        {
            Name                   = "Graticule";
            LabelFontSize          = 8;
            NumberOfGridlines      = 5;
            _axMap                 = mapControl;
            _axMap.ExtentsChanged += OnMapExtentsChanged;
            _axMap.LayerRemoved   += OnLayerRemoved;
            _axMap.LayerAdded     += OnLayerAdded;
            _geoProjection         = _axMap.GeoProjection;
            _mapLayersHandler      = layersHandler;
            _mapLayersHandler.OnLayerVisibilityChanged += OnLayerVisibleChange;
            _mapLayersHandler.MapRedrawNeeded          += OnRedrawNeeded;
            GraticuleTextHelper = new MapTextGraticuleHelper(_geoProjection, this);
            BorderColor         = new Utils().ColorByName(tkMapColor.Black);
            switch (global.CoordinateDisplay)
            {
            case CoordinateDisplayFormat.DegreeDecimal:
                CoordFormat = "D";
                break;

            case CoordinateDisplayFormat.DegreeMinute:
                CoordFormat = "DM";
                break;

            case CoordinateDisplayFormat.DegreeMinuteSecond:
                CoordFormat = "DMS";
                break;

            default:
                throw new Exception("Graticule: Invalid coordinate format");
            }
        }
예제 #3
0
        public void TransformToFourFigureGridReference()
        {
            // Source projection:
            var sourceProjection = new GeoProjection();

            sourceProjection.ImportFromEPSG(4326); // WGS84

            // Destination projection:
            var destProjection = new GeoProjection();

            destProjection.ImportFromEPSG(27700); // OSGB 1936 / British National Grid

            // Source coordinates:
            var x = -2.02903211116781;
            var y = 53.4040442788744;

            Assert.IsTrue(sourceProjection.StartTransform(destProjection), "Cannot start transform");
            sourceProjection.Transform(ref x, ref y);
            sourceProjection.StopTransform();

            Assert.AreEqual(398167.22598, x, 0.01);
            Assert.AreEqual(389691.93091, y, 0.01);

            var gridReference = ConvertToFourFigureGridReference(x, y);

            Assert.AreEqual("SJ981896", gridReference);
            Debug.WriteLine("gridReference: " + gridReference);
        }
예제 #4
0
        private static void GetPointsNoElevation(GeoCoordinate center, List <GeoCoordinate> geoCoordinates,
                                                 List <Vector2d> verticies, bool sort)
        {
            var length = geoCoordinates.Count;

            if (geoCoordinates[0] == geoCoordinates[length - 1])
            {
                length--;
            }

            for (int i = 0; i < length; i++)
            {
                // skip the same points in sequence
                if (i == 0 || geoCoordinates[i] != geoCoordinates[i - 1])
                {
                    var point = GeoProjection.ToMapCoordinate(center, geoCoordinates[i]);
                    verticies.Add(point);
                }
            }

            if (sort)
            {
                SortVertices(verticies);
            }
        }
예제 #5
0
        public void Reproject2280Test()
        {
            var sf = new Shapefile {
                GlobalCallback = this
            };
            const string filename = @"Issues/MWGIS-91/utah_north_arcs.shp"; // In NAD83 / Utah North (ft), EPSG:2280

            if (!sf.Open(filename))
            {
                Assert.Fail("Could not open shapefile: " + sf.ErrorMsg[sf.LastErrorCode]);
            }
            Assert.IsTrue(sf.NumShapes == 1, "Unexpected number of shapes in " + filename);
            Console.WriteLine(sf.GeoProjection.ProjectionName);
            Helper.PrintExtents(sf.Extents);

            var proj = new GeoProjection();

            proj.ImportFromEPSG(32612); // WGS 84 / UTM zone 12N
            var numShps       = 0;
            var reprojectedSf = sf.Reproject(proj, ref numShps);

            Assert.IsTrue(numShps > 0, "Nothing is reprojected. Error: " + sf.ErrorMsg[sf.LastErrorCode]);
            Assert.IsNotNull(reprojectedSf, "reprojectedSf == null. Error: " + sf.ErrorMsg[sf.LastErrorCode]);
            Assert.AreEqual(sf.NumShapes, reprojectedSf.NumShapes);
            Helper.PrintExtents(reprojectedSf.Extents);

            Helper.SaveAsShapefile(reprojectedSf, Path.Combine(Path.GetTempPath(), "Reproject2280Test.shp"));

            Assert.AreNotEqual(Math.Round(sf.Extents.xMin, MidpointRounding.AwayFromZero),
                               Math.Round(reprojectedSf.Extents.xMin, MidpointRounding.AwayFromZero), "xMin are the same, no projection has happened.");
        }
예제 #6
0
        public void CanReverseVertices()
        {
            // ARRANGE
            var center         = new GeoCoordinate(52.529814, 13.388015);
            var geoCoordinates = new List <GeoCoordinate>
            {
                new GeoCoordinate(52.5295083, 13.3889532),
                new GeoCoordinate(52.5291505, 13.3891865),
                new GeoCoordinate(52.5291244, 13.3891088),
                new GeoCoordinate(52.5291819, 13.389071),
                new GeoCoordinate(52.5291502, 13.3889361),
                new GeoCoordinate(52.529244, 13.3888741),
                new GeoCoordinate(52.5292772, 13.3890143),
                new GeoCoordinate(52.529354, 13.3889638),
                new GeoCoordinate(52.5293253, 13.3888356),
                new GeoCoordinate(52.5294599, 13.3887466),
            };

            // ACT & ASSERT
            var originalOrder = geoCoordinates.Select(g => GeoProjection.ToMapCoordinate(center, g)).ToArray();

            // direct order
            var points = new List <Vector2d>();

            PointUtils.GetClockwisePolygonPoints(center, geoCoordinates, points);
            Assert.IsTrue(points.SequenceEqual(originalOrder));

            // reversed
            geoCoordinates.Reverse();
            points.Clear();
            PointUtils.GetClockwisePolygonPoints(center, geoCoordinates, points);

            Assert.IsTrue(points.SequenceEqual(originalOrder));
        }
예제 #7
0
        /// <summary>
        /// Creates a new instance of the test grid form
        /// </summary>
        public TestGridForm1()
        {
            InitializeComponent();

            axMap1.Measuring.MeasuringType = tkMeasuringType.MeasureArea;

            GeoProjection pr = new GeoProjection();

            pr.SetGoogleMercator();
            Debug.Print(pr.ExportToWKT());
            axMap1.ShowVersionNumber = true;

            GridHelper.Initialize(axMap1, this);
            MapHelper.Initialize(axMap1, this);

            axMap1.TileProvider    = tkTileProvider.OpenStreetMap;
            axMap1.ShowRedrawTime  = true;
            axMap1.ScalebarVisible = true;

            cboScalebarUnits.SetEnum(typeof(tkScalebarUnits));
            cboColoring.SetEnum(typeof(ColoringType));
            cboColoringScheme.SetEnum(typeof(PredefinedColorScheme));
            cboProxyFormat.SetEnum(typeof(tkGridProxyFormat));
            cboProxyMode.SetEnum(typeof(tkGridProxyMode));
            cboCountry.SetEnum(typeof(tkKnownExtents));
            cboCoordinates.SetEnum(typeof(tkCoordinatesDisplay));
            cboZoomBehavior.SetEnum(typeof(tkZoomBehavior));

            cboActiveProxyMode.Items.Add("Proxy");
            cboActiveProxyMode.Items.Add("Direct rendering");

            InitGlobalSettings();

            cboProxyFormat.SelectedIndexChanged += (s, e) => UpdateGlobalSettings();
            cboProxyMode.SelectedIndexChanged   += (s, e) => UpdateGlobalSettings();
            udMaxSizeWoProxy.ValueChanged       += (s, e) => UpdateGlobalSettings();

            InitListbox();

            this.axMap1.PreviewKeyDown += delegate(object sender, PreviewKeyDownEventArgs e)
            {
                switch (e.KeyCode)
                {
                case Keys.Left:
                case Keys.Right:
                case Keys.Up:
                case Keys.Down:
                    e.IsInputKey = true;
                    return;
                }
            };

            axMap1.LayerRemoved += (s, e) => AxMap1LayersChanged(s, new EventArgs());
            axMap1.LayerAdded   += (s, e) => AxMap1LayersChanged(s, new EventArgs());

            axMap1.ScalebarVisible   = false;
            axMap1.ShowVersionNumber = false;
            axMap1.ShowRedrawTime    = false;
        }
예제 #8
0
 internal SpatialReference(GeoProjection projection)
 {
     if (projection == null)
     {
         throw new NullReferenceException("Internal reference is null");
     }
     _projection = projection;
 }
 public FishingGroundMappingHandler(GeoProjection geoProjection = null)
 {
     _geoProjection.SetWgs84();
     if (geoProjection != null)
     {
         _geoProjection = geoProjection;
     }
 }
        private Rectangle2d GetMapRectangleFromWay(Way way)
        {
            var relativeNullPoint = _tileController.CurrentTile.RelativeNullPoint;
            var somePoint         = GeoProjection.ToMapCoordinate(relativeNullPoint, way.Coordinates[0]);

            // NOTE change this code if it does matter
            return(new Rectangle2d(somePoint.X, somePoint.Y, 10, 10));
        }
예제 #11
0
        public void ProjectionStrings()
        {
            var utils = new Utils {
                GlobalCallback = this
            };
            var gp = new GeoProjection {
                GlobalCallback = this
            };

            // get NAD83 name
            var utilProjection = utils.GetNAD83ProjectionName(tkNad83Projection.Nad83_Alabama_East);

            gp.ImportFromEPSG((int)tkNad83Projection.Nad83_Alabama_East);
            var importProjection = gp.Name;

            Assert.AreEqual(utilProjection, importProjection);

            // get WGS84 name
            utilProjection = utils.GetWGS84ProjectionName(tkWgs84Projection.Wgs84_BLM_14N_ftUS);
            gp.ImportFromEPSG((int)tkWgs84Projection.Wgs84_BLM_14N_ftUS);
            importProjection = gp.Name;
            Assert.AreEqual(utilProjection, importProjection);

            // get NAD83 name by ID
            utilProjection = utils.GetProjectionNameByID((int)tkNad83Projection.Nad83_Alabama_East);
            gp.ImportFromEPSG((int)tkNad83Projection.Nad83_Alabama_East);
            importProjection = gp.Name;
            Assert.AreEqual(utilProjection, importProjection);

            // get WGS84 name by ID
            utilProjection = utils.GetProjectionNameByID((int)tkWgs84Projection.Wgs84_BLM_14N_ftUS);
            gp.ImportFromEPSG((int)tkWgs84Projection.Wgs84_BLM_14N_ftUS);
            importProjection = gp.Name;
            Assert.AreEqual(utilProjection, importProjection);

            // get obscure names by ID
            utilProjection = utils.GetProjectionNameByID(2402);
            gp.ImportFromEPSG(2402);
            importProjection = gp.Name;
            Assert.AreEqual(utilProjection, importProjection);

            // get obscure names by ID
            utilProjection = utils.GetProjectionNameByID(20005);
            gp.ImportFromEPSG(20005);
            importProjection = gp.Name;
            Assert.AreEqual(utilProjection, importProjection);

            // verify error
            utilProjection = utils.GetProjectionNameByID(100);
            Assert.IsTrue(utilProjection.Length == 0);
            // should return Index Out-of-bounds error
            var errorMsg = utils.ErrorMsg[utils.LastErrorCode];

            Console.WriteLine(errorMsg);
            Assert.AreEqual("Index Out of Bounds", errorMsg);
        }
예제 #12
0
        private void CreateShape(string path, DataTable dataTable)
        {
            Shapefile myShapefile;

            try
            {
                myShapefile = new Shapefile();
                string fileName     = Path.GetFileNameWithoutExtension(txtBox_excel.Text);
                string shapeilePath = Path.GetDirectoryName(path) + "\\" + fileName + ".shp";

                Directory.CreateDirectory(Path.GetDirectoryName(shapeilePath));

                myShapefile.CreateNew(shapeilePath, ShpfileType.SHP_POINT);
                //Create new field
                MapWinGIS.Field myField = new Field();
                //Set the field properties
                myField.Name  = "ID";
                myField.Type  = FieldType.INTEGER_FIELD;
                myField.Width = 10;
                //Add the filed for the shapefile table
                int intFieldIndex = 1;
                myShapefile.EditInsertField(myField, ref intFieldIndex, null);
                int myCounter    = 0;
                int myShapeIndex = 0;

                //First Create header
                CreateHeader(dataTable.Columns, myShapefile);
                for (int i = 0; i < dataTable.Rows.Count; i++)
                {
                    MapWinGIS.Shape myShape = new Shape();
                    myShape.Create(ShpfileType.SHP_POINT);
                    MapWinGIS.Point myPoint = new MapWinGIS.Point();
                    myPoint.x = Convert.ToDouble(dataTable.Rows[i][x_Index]);
                    myPoint.y = Convert.ToDouble(dataTable.Rows[i][y_Index]);
                    object fld_Value    = dataTable.Rows[i][0];
                    int    myPointIndex = 0;
                    myShape.InsertPoint(myPoint, ref myPointIndex);
                    myShapefile.EditInsertShape(myShape, ref myShapeIndex);
                    myShapefile.EditCellValue(0, myShapeIndex, fld_Value);
                    CreatePointData(dataTable, myShapefile, myShapeIndex, i);
                    myShapeIndex++;
                    myCounter++;
                }
                GeoProjection proj = new GeoProjection();
                // EPSG code
                proj.ImportFromEPSG(4326);  // WGS84

                myShapefile.GeoProjection = proj;
                myShapefile.StopEditingShapes(true, true, null);
                myShapefile.Close();
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #13
0
        /// <summary>
        /// Displays a single projection string
        /// </summary>
        /// <param name="item">Listview item</param>
        /// <param name="projection">String to display</param>
        private void UpdateDialectString(ListViewItem item, string projection)
        {
            MapWinGIS.GeoProjection projTest = new GeoProjection();
            string projType = projTest.ImportFromProj4(projection) ? "proj4" : "WKT";

            projTest = null;

            item.SubItems.Add(projType);
            item.SubItems.Add(projection);
        }
예제 #14
0
        public void CanConvertToMap()
        {
            // ACT
            var mapCoordinate = GeoProjection.ToMapCoordinate(_center, _target);

            // ASSERT
            Assert.AreEqual(-7114, Math.Truncate(mapCoordinate.X));
            Assert.AreEqual(5902, Math.Truncate(mapCoordinate.Y));
            Assert.AreEqual(9244, Math.Truncate(Distance(new Vector2d(0, 0), mapCoordinate)));
        }
예제 #15
0
        void IObserver <GeoCoordinate> .OnNext(GeoCoordinate value)
        {
            if (RelativeNullPoint == default(GeoCoordinate))
            {
                RelativeNullPoint = value;
            }
            _currentPosition = value;

            (this as IPositionObserver <Vector2d>).OnNext(GeoProjection.ToMapCoordinate(RelativeNullPoint, value));
        }
예제 #16
0
        /// <summary> Deletes way from element source. </summary>
        private void DeleteElement(long id, Rectangle2d rectangle)
        {
            EnsureElementSource(rectangle.BottomLeft);

            var nullPoint   = _tileController.CurrentTile.RelativeNullPoint;
            var boundingBox = new BoundingBox(
                GeoProjection.ToGeoCoordinate(nullPoint, rectangle.BottomLeft),
                GeoProjection.ToGeoCoordinate(nullPoint, rectangle.TopRight));

            _elementSourceEditor.Delete <Way>(id, boundingBox);
        }
 protected virtual void Dispose(bool disposing)
 {
     if (!_disposed)
     {
         if (disposing)
         {
         }
         _geoProjection = null;
         _disposed      = true;
     }
 }
예제 #18
0
        public bool CreateLayer(string layerName, GeometryType geometryType, ISpatialReference projection = null, string creationOptions = "")
        {
            var           shpType = GeometryHelper.GeometryType2ShpType(geometryType);
            GeoProjection gp      = null;

            if (projection != null)
            {
                gp = projection.GetInternal();
            }
            return(_datasource.CreateLayer(layerName, shpType, gp, creationOptions));
        }
예제 #19
0
        /// <summary> Gets margin for bounding box of desired size. </summary>
        private static long GetMargin(float size)
        {
            var start = new Vector2d();
            // (h * cos(45), h * sin(45))
            var end       = new Vector2d((float)(size * 0.52532198881), (float)(size * 0.85090352453));
            var geoCenter = new GeoCoordinate(52, 13);

            var point1 = GeoProjection.ToGeoCoordinate(geoCenter, start);
            var point2 = GeoProjection.ToGeoCoordinate(geoCenter, end);

            return((long)(((point2.Longitude - point1.Longitude) + (point2.Latitude - point1.Latitude)) * MapConsts.ScaleFactor));
        }
예제 #20
0
        public void CanConvertToGeo()
        {
            // ARRANGE
            var mapCoordinate = GeoProjection.ToMapCoordinate(_center, _target);

            // ACT
            var geoCoordinate = GeoProjection.ToGeoCoordinate(_center, mapCoordinate);

            // ASSERT
            Assert.True(Math.Abs(52.582922 - geoCoordinate.Latitude) < Percision);
            Assert.True(Math.Abs(13.282957 - geoCoordinate.Longitude) < Percision);
        }
 private Way CreateWay(List <Vector2d> points)
 {
     return(new Way()
     {
         Tags = new Dictionary <string, string>()
         {
             { "barrier", "yes" }
         }.ToTags(),
         Points = points.Select(p => GeoProjection
                                .ToGeoCoordinate(TestHelper.BerlinTestFilePoint, p))
                  .ToList()
     });
 }
예제 #22
0
 private double GetDistance(Element element)
 {
     if (element is Node)
     {
         return(GeoProjection.Distance((element as Node).Coordinate, _position));
     }
     if (element is Way)
     {
         return((element as Way).Coordinates.Min(geoCoordinate =>
                                                 GeoProjection.Distance(geoCoordinate, _position)));
     }
     return((element as Relation).Members.Min(member => GetDistance(member.Member)));
 }
예제 #23
0
        public void CreateLayerSQLiteTest()
        {
            var ogrDatasource = new OgrDatasource();

            try
            {
                var result = ogrDatasource.Open2(@"sqlite\onepoint.sqlite", true);
                Assert.IsTrue(result, "Cannot open SQLite file: " + ogrDatasource.GdalLastErrorMsg);
                var settings = new GlobalSettings {
                    OgrLayerForceUpdateMode = true
                };

                var capability = ogrDatasource.TestCapability(tkOgrDSCapability.odcCreateLayer);
                Debug.WriteLine("odcCreateLayer: " + capability);
                Assert.IsTrue(capability, "Cannot create layer");

                var originalLayerCount = ogrDatasource.LayerCount;

                var projection = new GeoProjection();
                Assert.IsTrue(projection.SetWgs84(), "Cannot set projection");

                var layerCreated = ogrDatasource.CreateLayer("Test", ShpfileType.SHP_POINT, projection, "OVERWRITE=YES");
                Assert.IsTrue(layerCreated, "Cannot create layer");
                Debug.WriteLine(ogrDatasource.GdalLastErrorMsg);

                Assert.AreEqual(originalLayerCount + 1, ogrDatasource.LayerCount, "New layer isn't created");
                Debug.WriteLine("GetLayerName: " + ogrDatasource.GetLayerName(ogrDatasource.LayerCount - 1));

                var firstLayer = ogrDatasource.GetLayer(0);
                Assert.IsNotNull(firstLayer, $"Could not get first layer: {ogrDatasource.GdalLastErrorMsg}");

                // Get layer:
                var newLayer = ogrDatasource.GetLayer(ogrDatasource.LayerCount - 1, true);
                // var newLayer = ogrDatasource.GetLayerByName("test", true);
                Assert.IsNotNull(newLayer, $"Could not get new layer: {ogrDatasource.GdalLastErrorMsg}");
                // Add field:
                var numFeatures = newLayer.FeatureCount[true];
                Debug.WriteLine("numFeatures: " + numFeatures);

                TestSQLiteLayers(ogrDatasource);
            }
            finally
            {
                if (ogrDatasource.LayerCount > 1)
                {
                    ogrDatasource.DeleteLayer(ogrDatasource.LayerCount);
                }
                ogrDatasource.Close();
            }
        }
예제 #24
0
        /// <summary> Adds node model to to element source and scene. </summary>
        private void AddNodeModel(long id, Vector2d point, TagCollection tags)
        {
            EnsureElementSource(point);
            var nullPoint = _tileController.CurrentTile.RelativeNullPoint;

            var node = new Node()
            {
                Id         = id,
                Tags       = tags,
                Coordinate = GeoProjection.ToGeoCoordinate(nullPoint, point)
            };

            _elementSourceEditor.Add(node);
            node.Accept(new NodeVisitor(_tileController.CurrentTile, _modelLoader, _objectPool));
        }
예제 #25
0
        private void MenuForm_Load(object sender, EventArgs e)
        {
            GeoProjection proj = new GeoProjection();

            proj.ImportFromEPSG(3857);

            _shape = new Shapefile();
            _shape.Open(@"E:\POSTE DE TRAVAIL\PROJETS PARTAGES\PROJET DE STAGE\USA_P\usa.shp");

            _shape   = _shape.Reproject(proj, 1);
            _idshape = axMap1.AddLayer(_shape, true);


            PointIco(@"E:\POSTE DE TRAVAIL\PROJETS PARTAGES\PROJET DE STAGE\ICON");
        }
예제 #26
0
        /// <summary> Adds way model to element source and scene. </summary>
        private void AddWayModel(long id, List <Vector2d> footprint, TagCollection tags)
        {
            EnsureElementSource(footprint.First());
            var nullPoint = _tileController.CurrentTile.RelativeNullPoint;

            var way = new Way()
            {
                Id          = id,
                Tags        = tags,
                Coordinates = footprint.Select(p => GeoProjection.ToGeoCoordinate(nullPoint, p)).ToList()
            };

            _elementSourceEditor.Add(way);
            way.Accept(new WayVisitor(_tileController.CurrentTile, _modelLoader, _objectPool));
        }
예제 #27
0
        /// <summary> Gets circle from given list of geo coordinates. </summary>
        public static void GetCircle(GeoCoordinate relativeNullPoint, List <GeoCoordinate> points,
                                     out double radius, out Vector2d center)
        {
            var minLat = points.Min(a => a.Latitude);
            var maxLat = points.Max(a => a.Latitude);

            var minLon = points.Min(a => a.Longitude);
            var maxLon = points.Max(a => a.Longitude);

            var centerLat = (minLat + (maxLat - minLat) / 2);
            var centerLon = (minLon + (maxLon - minLon) / 2);

            center = GeoProjection.ToMapCoordinate(relativeNullPoint, new GeoCoordinate(centerLat, centerLon));
            radius = (float)((maxLat - minLat) * ConvertionCoefficient) / 2;
        }
예제 #28
0
        /// <summary>
        /// Shows information about selected projection
        /// </summary>
        /// <param name="projection"></param>
        public void ShowProjection(CoordinateSystem projection)
        {
            if (projection == null)
            {
                throw new NullReferenceException("Geoprojection wasn't passed");
            }

            txtName.Text = projection.Name;
            txtCode.Text = projection.Code.ToString();

            m_proj = new MapWinGIS.GeoProjection();
            if (!m_proj.ImportFromEPSG(projection.Code))
            {
                // usupported projection
            }
            else
            {
                projectionTextBox1.ShowProjection(m_proj.ExportToWKT());

                projectionMap1.DrawCoordinateSystem(projection);
                projectionMap1.ZoomToCoordinateSystem(projection);

                txtProj4.Text = m_proj.ExportToProj4();

                txtAreaName.Text = projection.AreaName;
                txtRemarks.Text  = projection.Remarks;
                txtScope.Text    = projection.Scope;
            }

            // showing dialects
            if (m_coordinateSystem != null)
            {
                m_database.ReadDialects(m_coordinateSystem);

                for (int i = 0; i < m_coordinateSystem.Dialects.Count; i++)
                {
                    string       s    = m_coordinateSystem.Dialects[i];
                    ListViewItem item = this.listView1.Items.Add(i.ToString());
                    this.UpdateDialectString(item, s);
                }
                m_index = m_coordinateSystem.Dialects.Count;

                if (listView1.Items.Count > 0)
                {
                    listView1.Items[0].Selected = true;
                }
            }
        }
예제 #29
0
        /// <summary> Creates tile. </summary>
        /// <param name="relativeNullPoint">Relative null point.</param>
        /// <param name="mapCenter">Center of map.</param>
        /// <param name="renderMode">Render mode.</param>
        /// <param name="canvas">Map canvas.</param>
        /// <param name="width">Tile width in meters.</param>
        /// <param name="height">Tile height in meters.</param>
        public Tile(GeoCoordinate relativeNullPoint, Vector2d mapCenter, RenderMode renderMode,
                    Canvas canvas, double width, double height)
        {
            RelativeNullPoint = relativeNullPoint;
            MapCenter         = mapCenter;
            RenderMode        = renderMode;
            Canvas            = canvas;

            var geoCenter = GeoProjection.ToGeoCoordinate(relativeNullPoint, mapCenter);

            BoundingBox = BoundingBox.Create(geoCenter, width, height);

            Rectangle = new Rectangle2d(MapCenter.X - width / 2, MapCenter.Y - height / 2, width, height);

            Registry = new TileRegistry(renderMode);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (App.Map.NumLayers > 0)
            {
                MessageHelper.Info("Can't change projection when there are layers on the map.");
                return;
            }

            var gp = new GeoProjection();

            if (optDefinition.Checked)
            {
                if (string.IsNullOrWhiteSpace(txtDefinition.Text))
                {
                    MessageHelper.Info("Projection string is empty");
                    return;
                }

                if (!gp.ImportFromAutoDetect(txtDefinition.Text))
                {
                    MessageHelper.Info("Failed to identify projection");
                    return;
                }
            }

            if (optEmpty.Checked)
            {
                // do nothing it's empty all right
            }

            if (optWellKnown.Checked)
            {
                if (cboWellKnown.SelectedIndex == 0)
                {
                    gp.SetWgs84();
                }

                if (cboWellKnown.SelectedIndex == 1)
                {
                    gp.SetGoogleMercator();
                }
            }

            App.Map.GeoProjection = gp;
            App.Map.Redraw();
            DialogResult = DialogResult.OK;
        }