Coordinate and Attribute's

Topics: SharpMap Project
Jan 8, 2010 at 4:36 AM

When i try to get features data of a point by mouse clicking on it, sharpmap does not return the correct

 Attribute as well as Coordinates ,

This will be appreciate if  some body solve this Problem or share some other peace of Code ,

I am using  the following Code

thnx in Advance

 

Code :

 int screenToleranceX = 1, screenToleranceY = 1;

            System.Drawing.Point screenLowerLeft = new System.Drawing.Point(e.X - screenToleranceX, e.Y - screenToleranceY);

            System.Drawing.Point screenTopRight = new System.Drawing.Point(e.X + screenToleranceX, e.Y + screenToleranceY);

            SharpMap.Geometries.Point worldBottomLeft = myMap.ImageToWorld(screenLowerLeft);

            SharpMap.Geometries.Point worldTopRight = myMap.ImageToWorld(screenTopRight);

            SharpMap.Geometries.BoundingBox worldQueryBox = new SharpMap.Geometries.BoundingBox(worldBottomLeft, worldTopRight);

            SharpMap.Data.FeatureDataSet fds = new SharpMap.Data.FeatureDataSet();

            ((SharpMap.Layers.VectorLayer)myMap.Layers[0]).DataSource.Open();

            ((SharpMap.Layers.VectorLayer)myMap.Layers[0]).DataSource.ExecuteIntersectionQuery(worldQueryBox, fds);

            ((SharpMap.Layers.VectorLayer)myMap.Layers[0]).DataSource.Close();

             int num = fds.Tables[0].Columns.Count;           

            string str1 = fds.Tables[0].Columns[0].ColumnName;

            string str2 = fds.Tables[0].Columns[1].ColumnName;

             DataTable dt = fds.Tables[0];

            if (dt.Rows.Count > 0)

            {

                Object[] obj = dt.Rows[0].ItemArray;

                getname = (Convert.ToString(obj[0]));

//Alert.Show(getname + " X:" + worldBottomLeft.X.ToString() + " Y: " + worldBottomLeft.Y.ToString());

         }

Coordinator
Jan 8, 2010 at 7:02 PM

Hi rajendra see http://sharpmap.codeplex.com/wikipage?title=Do%20true%20intersection%20testing%20using%20NetTopologySuite&referringTitle=How%20to...

Jan 11, 2010 at 5:20 AM
johndiss wrote:

Hi rajendra see http://sharpmap.codeplex.com/wikipage?title=Do%20true%20intersection%20testing%20using%20NetTopologySuite&referringTitle=How%20to...

Jan 11, 2010 at 5:21 AM
johndiss wrote:

Hi rajendra see http://sharpmap.codeplex.com/wikipage?title=Do%20true%20intersection%20testing%20using%20NetTopologySuite&referringTitle=How%20to...

 Thnks Johndiss  for your Response

 

If you check my Last Line which is “worldBottomLeft.X and worldBottomLeft.Y”

is not returning Proper X and Y coordinates , when I clicked  click in the Map with out Moving the mouse pointer  It is showing the wrong Coordinates with a large difference

Please suggest some other options or provide the related Code

 

Thnx

Rajendra

Coordinator
Jan 11, 2010 at 10:23 AM

Hi Rajendra, please can you give an example of what values you expect and what you receive?

I would say that you may be testing a geometry that you do not expect. This is due to the fact that certain providers only check that the features' bounding box intersects, not the feature itself; i.e dt.Rows[0] is not what you think it is hence the link above.

hth jd

Jan 11, 2010 at 11:32 AM
Hi Johndiss,
 
When I clicked Upper right Corner of Grid Name (086_084 ) it is showing 378014.390243902,2970897.80487805 and Return the grid Name 085_086 which is wrong
and when i zoom out/Zoom in  it is showing some other
 
For your reference i have attached One sample shape file and Code , Please guide me
 
 
 
Thnx and regards
Rajendra
 
 


 
On Mon, Jan 11, 2010 at 4:53 PM, johndiss <notifications@codeplex.com> wrote:

From: johndiss

Hi Rajendra, please can you give an example of what values you expect and what you receive?

I would say that you may be testing a geometry that you do not expect. This is due to the fact that certain providers only check that the features' bounding box intersects, not the feature itself; i.e dt.Rows[0] is not what you think it is hence the link above.

hth jd

Read the full discussion online.

To add a post to this discussion, reply to this email (SharpMap@discussions.codeplex.com)

To start a new discussion for this project, email SharpMap@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com