This project has moved and is read-only. For the latest updates, please go here.

getting featureset for mapinfo files

Topics: Data Access, SharpMap v0.9 / v1.x
May 26, 2011 at 1:32 AM
Edited May 26, 2011 at 1:37 AM

hi guys,

I need to access the feature data within mapinfo files using sharpmap, I have pulled down the source and am working with the web examples in MapInfo.aspx.cs

I have modified teh App_C0de/MapHelper.cs to return the following class

public static MapWithLayers InitializeMapOgr(Size size){...}
public class MapWithLayers
    public MapWithLayers()
        Layers = new List();

    public List Layers { get; set; }

    public Map Map { get; set; }
I did this because I could not figure out how to access the DataSource on a Map.Layer
Map map = new Map(size);
map.Layers[0].DataSource //DataSource not available on ILayer
So in the MapInfo.aspx.cs I have the following method (slightly modified from original)
 protected void imgMap_Click(object sender, ImageClickEventArgs e)
        SharpMap.Geometries.Point p = myMap.Map.ImageToWorld(new PointF(e.X, e.Y));
        FeatureDataSet ds = new FeatureDataSet();

        var boundingBox = p.GetBoundingBox();
        // The data set will contain the features which have a bounding box 
        // which intersects the point's bounding box.
        myMap.Layers[0].DataSource.ExecuteIntersectionQuery(boundingBox, ds);

        // You can now bind ds.Tables[0] to a datagrid, etc.

        //Set center of the map to where the client clicked
        myMap.Map.Center = myMap.Map.ImageToWorld(new System.Drawing.Point(e.X, e.Y));
        //Set zoom value if any of the zoom tools were selected
        if (rblMapTools.SelectedValue == "0") //Zoom in
            myMap.Map.Zoom = myMap.Map.Zoom*0.5;
        else if (rblMapTools.SelectedValue == "1") //Zoom out
            myMap.Map.Zoom = myMap.Map.Zoom*2;
        //Create the map
When I inspect ds it is always empty and has no data, I am using the example mapinfo tab files that come with the source.

Is there something I'm doing wrong to not get the features returned?

By features I assume it should return the country name and popdens?

May 26, 2011 at 4:22 AM

got it working, turns out i needed to pass the point p itself rather than getting a boundingbox