ThinkGeo.com    |     Documentation    |     Premium Support

TAB files points not showing

I’m trying to display points from a TAB file but they are not showing, I have gone though some samples and see nothing different in the code but the point are still not showing.

i can’t find the problem in the code

MapView Map = FindViewById(Resource.Id.MapView);
Map.CurrentExtent = new RectangleShape(-131.6518984375, 36.49099609375, -71.6226015625, 5.94900390625);
Map.MapUnit = GeographyUnit.DecimalDegree;
Map.SetBackgroundColor(Color.Aqua);

             //loading map
            TabFeatureLayer.BuildIndexFile(System.IO.Path.Combine(targetDirectory, "Morelos.TAB"));
            TabFeatureLayer ftl = new TabFeatureLayer(System.IO.Path.Combine(targetDirectory, "Morelos.TAB"), TabFileReadWriteMode.ReadOnly);
            
            ftl.Name = "Mexico";
            ftl.IsVisible = true;
            ZoomLevelSet zl = new ZoomLevelSet();
            zl.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
            zl.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            ftl.ZoomLevelSet = zl;

            //trying to load points 
            TabFeatureLayer.BuildIndexFile(System.IO.Path.Combine(targetDirectory, "Infraestructura01.TAB"));
            TabFeatureLayer ftl2 = new TabFeatureLayer(System.IO.Path.Combine(targetDirectory, "Infraestructura01.TAB"), TabFileReadWriteMode.ReadOnly);
            ftl2.RequireIndex = true;
           
            ftl2.Transparency = 120f;
            ftl2.Name = "Infraestructura";
            ZoomLevelSet zl2 = new ZoomLevelSet();
            ftl2.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(GetGeoImageFromImageId(Resource.Drawable.public_facility));
            ftl2.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            ftl2.FeatureSource.Projection = GetWgs84ToMercatorProjection();

            LayerOverlay ol = new LayerOverlay();
            ol.Layers.Add("Mexico", ftl);

            LayerOverlay ol2 = new LayerOverlay();
            ol2.TileType = TileType.SingleTile;
            ol2.Layers.Add("infra", ftl2);
            
            Map.Overlays.Add("Mexico", ol);
            Map.Overlays.Add("infra", ol2);


            ftl.Open();
            Map.CurrentExtent = ftl.GetBoundingBox();
            Map.Refresh();

Hi, I’m digging into your code and found something unsure.

  1. The map’s GeographyUnit to decimal degree, while the ft12’s projection set by GetWgs84ToMercatorProjection(); I assume that you set the ExternalProj4ProjectionString to Mercator. The external projection should sync with the Geography Unit you set on the map. For example, if the FeatureSource’s data is WGS84, while we want to display it as Mercator projection; first of all, we need to set map’s GeographyUnit to Decimal Degree, then create a projection with WGS84 as internal proj4 and Mercator as external proj4. Hope it makes sense. I guess this is the major issue.

  2. I cannot find the definition of GetGeoImageFromImageId method. So please set a breakpoint here, just make sure it returns a valid image.

  3. The TabFeatureLayer is building index dynamically in your code everytime. I recommend to pre-build the index, just keep the app light-weight. If there are any records broken, that might make the app crash or some weird behavior.

Please try my items above and feel free to let us know if you have further questions. Also if it still not work for you, please pack a demo so that I could dig more with your project.

Thanks,
Howard

Hi Howard,

Thanks for the help, but i still could not solve the problem.

Could you take a look at the problem to see if you can find a solution.


(i can’t upload to the project to this page)

Hi Diego,

I have tested your sample, and refined code. The GetWgs84ToMercatorProjection() function have issue, and the tight code are as follows:
private ManagedProj4Projection GetWgs84ToMercatorProjection()
{
ManagedProj4Projection wgs84ToMercatorProjection = new ManagedProj4Projection();
wgs84ToMercatorProjection.InternalProjectionParametersString = ManagedProj4Projection.GetSphericalMercatorParametersString();
wgs84ToMercatorProjection.ExternalProjectionParametersString = ManagedProj4Projection.GetWgs84ParametersString();
return wgs84ToMercatorProjection;
}

I have fixed your sample code, and you can test it.

Please download here: https://ap.thinkgeo.com:5001/sharing/prJepNVjD

Thanks

Hi Don,

Thank you very much, the points are actually being projected in the map now!
The only problem now is that they are being projected in the wrong place, do you know why that may be?

Thanks for the help.

Hi Diego,

I don’t know your data projection information, so I can’t convert to right projection.

Please show me more information about your data projection.

Thanks