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;
        }
Exemplo n.º 2
0
        // <summary>
        // Some operaions with GeoProjection object
        // </summary>
        public void GeoProjection(AxMap axMap1)
        {
            GeoProjection proj = new GeoProjection();

            // EPSG code
            proj.ImportFromEPSG(4326);  // WGS84

            // proj 4 string
            proj.ImportFromProj4("+proj=longlat +datum=WGS84 +no_defs");  // WGS84

            // autodetect the format
            string unknown_format = "4326";

            proj.ImportFromAutoDetect(unknown_format);

            // from file
            string filename = "some_name";

            proj.ReadFromFile(filename);

            // show the name of the loaded projection
            Debug.Print("Projection loaded: " + proj.Name);

            // show proj 4 representation
            Debug.Print("Proj4 representation: " + proj.ExportToProj4());

            // let's show the properties of the geographic projection
            string s = "";

            double[] arr = new double[5];
            for (int i = 0; i < 5; i++)
            {
                // extract the parameter in element of val arr
                proj.get_GeogCSParam((tkGeogCSParameter)i, ref arr[i]);

                // append the name of parameter and the value to the string
                s += (tkGeogCSParameter)i + ": " + arr[i] + Environment.NewLine;
            }
            MessageBox.Show("Parameters of geographic coordinate system: " + Environment.NewLine + s);
        }
Exemplo n.º 3
0
 public bool ImportFromAutoDetect(string proj)
 {
     return(_projection.ImportFromAutoDetect(proj));
 }