[Solved]Issue with changeset 78884

Topics: SharpMap Project, SharpMap v0.9 / v1.x, SharpMap v2.0, WinForms Controls
Oct 25, 2010 at 8:06 PM

Hi Felix,

I found one issue with changeset 78884 . as per this changeset the drag feature is added for the map in panorquery mode. but the problem is that if the markers are added to map and map is in panorquery mode and now if you drag the map, the map is dragged  but not the markers.

Ideally the marker position should also be changed relative to the map on response to drag.

Thanks,

Vivek Kumar

Oct 26, 2010 at 8:08 AM

Hi Felix,

Did you got this issue?

Coordinator
Oct 26, 2010 at 8:26 AM
Edited Oct 26, 2010 at 9:10 AM

Vivek,

it works in the winformsamples project, so probably you have to add sharpmap.extensions project to your solution file as well.

There is an issue with the coordinate transformation though (ProjNET, I cannot fix that!), so you might get better results if you
transform your data to EPSG:3758 before you use it. (it is faster anyway)

cheers FObermaier

Oct 26, 2010 at 9:37 AM

Hi Felix,

I am using  sharpmap.extensions still the issue is same.

thanks,

Vivek 

 

 

Coordinator
Oct 26, 2010 at 9:57 AM
Edited Jun 22, 2011 at 12:11 PM

Vivek,

to avoid on-the-fly coordinate transformation change your AddMarkers code to something like this:

 

            //Get data from excel
            var xlsPath = string.Format(XlsConnectionString, System.IO.Directory.GetCurrentDirectory(), "GeoData\\Cities.xls");
            var ds = new System.Data.DataSet("XLS");
            using (var cn = new System.Data.OleDb.OleDbConnection(xlsPath))
            {
                cn.Open();
                using (var da = new System.Data.OleDb.OleDbDataAdapter(new System.Data.OleDb.OleDbCommand("SELECT * FROM [Cities$]", cn)))
                    da.Fill(ds);
            }

            //The SRS for this datasource is EPSG:4326, therefore we need to transfrom it to OSM projection
            var ctf = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory();
            var cf = new ProjNet.CoordinateSystems.CoordinateSystemFactory();
            var epsg4326 = cf.CreateFromWkt("GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]");
            var epsg3857 = cf.CreateFromWkt("PROJCS[\"Popular Visualisation CRS / Mercator\", GEOGCS[\"Popular Visualisation CRS\", DATUM[\"Popular Visualisation Datum\", SPHEROID[\"Popular Visualisation Sphere\", 6378137, 0, AUTHORITY[\"EPSG\",\"7059\"]], TOWGS84[0, 0, 0, 0, 0, 0, 0], AUTHORITY[\"EPSG\",\"6055\"]],PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\", \"8901\"]], UNIT[\"degree\", 0.0174532925199433, AUTHORITY[\"EPSG\", \"9102\"]], AXIS[\"E\", EAST], AXIS[\"N\", NORTH], AUTHORITY[\"EPSG\",\"4055\"]], PROJECTION[\"Mercator\"], PARAMETER[\"False_Easting\", 0], PARAMETER[\"False_Northing\", 0], PARAMETER[\"Central_Meridian\", 0], PARAMETER[\"Latitude_of_origin\", 0], UNIT[\"metre\", 1, AUTHORITY[\"EPSG\", \"9001\"]], AXIS[\"East\", EAST], AXIS[\"North\", NORTH], AUTHORITY[\"EPSG\",\"3857\"]]");
            var ct = ctf.CreateFromCoordinateSystems(epsg4326, epsg3857);
            foreach (System.Data.DataRow row in ds.Tables[0].Rows)
            {
                if (row["X"] == DBNull.Value || row["Y"] == DBNull.Value) continue;
                double[] coords = new double[] { Convert.ToDouble(row["X"]), Convert.ToDouble(row["Y"])};
                coords = ct.MathTransform.Transform(coords);
                row["X"] = coords[0];
                row["Y"] = coords[1];
            }

            //Add Rotation Column
            ds.Tables[0].Columns.Add("Rotation", typeof (float));
            foreach (System.Data.DataRow row in ds.Tables[0].Rows)
                row["Rotation"] = -angle;

            //Set up provider
            var xlsProvider = new SharpMap.Data.Providers.DataTablePoint(ds.Tables[0], "OID", "X", "Y");
            var xlsLayer = new SharpMap.Layers.VectorLayer("XLS", xlsProvider);
            xlsLayer.Style.Symbol = SharpMap.Styles.VectorStyle.DefaultSymbol;
            
            //Add layer to map
            map.Layers.Add(xlsLayer);
            var xlsLabelLayer = new SharpMap.Layers.LabelLayer("XLSLabel");
            xlsLabelLayer.DataSource = xlsProvider;
            xlsLabelLayer.LabelColumn = "Name";
            xlsLabelLayer.PriorityColumn = "Population";
            xlsLabelLayer.Style.CollisionBuffer = new System.Drawing.SizeF(2f, 2f);
            xlsLabelLayer.Style.CollisionDetection = true;
            xlsLabelLayer.LabelFilter = SharpMap.Rendering.LabelCollisionDetection.ThoroughCollisionDetection;
            map.Layers.Add(xlsLabelLayer);

 

Please not the CoordinateTransformation properties for xlsLayer and xlsLabelLayer are no longer needed.

cheers FObermaier

Oct 26, 2010 at 8:04 PM

Hi Felix,

Thanks for the wonderful code!!!!!!

It's worked like a charm.

You rock !!!!!!

Cheers,

Vivek Kumar

Oct 27, 2010 at 8:35 AM

Hi Felix,

I just a sent a detail mail to you.

Thanks,

Vivek Kumar