ThinkGeo.com    |     Documentation    |     Premium Support

Shapefile displaying offset over Google and Bing maps

Hi ThinkGeo,

We are having issues with a specific projections in ThinkGeo WebForms displaying offset. The projection is EPSG:32026 - NAD27 / Oregon North. The curious thing about this issues is we have many other shapefiles and projections that have worked just fine with our current set up of code. Only this one appears to display offset. I have also converted this shapefile in QGIS to the WGS84 projection and when I run it through our code it works just fine.

Is there something we are missing?

Our test environment and sample shapefiles:

using System;
using ThinkGeo.MapSuite.WebForms;
using ThinkGeo.MapSuite.Drawing;
using ThinkGeo.MapSuite.Layers;
using ThinkGeo.MapSuite.Shapes;
using ThinkGeo.MapSuite.Styles;
using ThinkGeo.MapSuite;
using System.IO;
using System.Web.UI;

namespace Test
{
public partial class TestForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string strFile = @“C:”; //Local File Path for testing
string strFileName = “StreetSample.shp”; //“StreetSampleWGS84.shp”
try
{
if (!Page.IsPostBack)
{
//Determines if the file exists.
if (File.Exists(strFile + strFileName))
lblExists.Text = “File Exists”;
else
lblExists.Text = “File Does Not Exist”;

                Map1.MapBackground = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"));
                string applicationID = "BING KEY HERE";

                //Bing Maps
                BingMapsOverlay mobjBingsOverlay = new BingMapsOverlay("ROADS", applicationID);
                mobjBingsOverlay.MapStyle = BingMapsStyle.Road;
                mobjBingsOverlay.Name = "Roads";

                Map1.CustomOverlays.Add(mobjBingsOverlay);

                //Google Maps
                //GoogleOverlay mobjGoogleOverlay = new GoogleOverlay();
                //mobjGoogleOverlay.GoogleMapType = GoogleMapType.Hybrid;
                //mobjGoogleOverlay.Name = "Roads";

                //Map1.CustomOverlays.Add(mobjGoogleOverlay); 

                Map1.MapUnit = GeographyUnit.Feet;

                LayerOverlay objOverlay = new LayerOverlay();     

                ShapeFileFeatureLayer objAllRoads = new ShapeFileFeatureLayer(strFile + strFileName);
                ShapeFileFeatureLayer.BuildIndexFile(strFile + strFileName);
                objAllRoads.Name = "All Roads";

                string strFILE = strFile + strFileName;
                string strPRJ = strFILE.ToUpper().Replace(".SHP", ".PRJ");
                string strProjection = null;
                strProjection = File.ReadAllText(strPRJ);
                Proj4Projection mobjProjectionJUR = new Proj4Projection();
                mobjProjectionJUR.InternalProjectionParametersString = Proj4Projection.ConvertPrjToProj4(strProjection);
                mobjProjectionJUR.ExternalProjectionParametersString = Proj4Projection.GetBingMapParametersString();
                //mobjProjectionJUR.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();

                LineStyle objLine;
                TextStyle objText;
                string strLabel1 = "STREET_CAT";                    
                // ### ZoomLevel 19-20 (Close Up) ###
                ZoomLevel objZoom1 = objAllRoads.ZoomLevelSet.ZoomLevel19;
                objZoom1.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                objText = GetHaloLabelRender(9.5F, strLabel1, GeoColor.StandardColors.Gray);
                SetStandardRoadLabel(ref objText, 5);
                objLine = LineStyles.LocalRoad1;
                objZoom1.CustomStyles.Add(objText);
                objZoom1.CustomStyles.Add(objLine);
                objAllRoads.ZoomLevelSet.CustomZoomLevels.Add(objZoom1);

                // ### ZoomLevel 17-19 ###
                ZoomLevel objZoom2 = objAllRoads.ZoomLevelSet.ZoomLevel17;
                objZoom2.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level18;
                objText = GetHaloLabelRender(8.5F, strLabel1, GeoColor.StandardColors.Gray);
                SetStandardRoadLabel(ref objText, 80);
                objLine = LineStyles.LocalRoad2;
                objZoom2.CustomStyles.Add(objText);
                objZoom2.CustomStyles.Add(objLine);
                objAllRoads.ZoomLevelSet.CustomZoomLevels.Add(objZoom2);

                // ### ZoomLevel 16-16 ###
                ZoomLevel objZoom3 = objAllRoads.ZoomLevelSet.ZoomLevel16;
                objZoom3.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level16;
                objText = GetHaloLabelRender(7.5F, strLabel1, GeoColor.StandardColors.Gray);
                SetStandardRoadLabel(ref objText, 70);
                objLine = LineStyles.LocalRoad3;
                objZoom3.CustomStyles.Add(objText);
                objZoom3.CustomStyles.Add(objLine);
                objAllRoads.ZoomLevelSet.CustomZoomLevels.Add(objZoom3);

                // ### ZoomLevel 14-15 ###
                ZoomLevel objZoom4 = objAllRoads.ZoomLevelSet.ZoomLevel14;
                objZoom4.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level15;
                objText = GetHaloLabelRender(6.5F, strLabel1, GeoColor.StandardColors.Gray);
                SetStandardRoadLabel(ref objText, 125);
                objZoom4.CustomStyles.Add(objText);
                objLine = LineStyles.LocalRoad4;
                objZoom4.CustomStyles.Add(objLine);
                objAllRoads.ZoomLevelSet.CustomZoomLevels.Add(objZoom4);

                // ### ZoomLevel 1-13 ###
                ZoomLevel objZoom5 = objAllRoads.ZoomLevelSet.ZoomLevel01;
                objZoom5.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level13;
                objLine = new LineStyle(new GeoPen(GeoColor.StandardColors.Gray, 0.5F));
                objZoom5.CustomStyles.Add(objLine);
                objAllRoads.ZoomLevelSet.CustomZoomLevels.Add(objZoom5);

                objAllRoads.FeatureSource.Projection = mobjProjectionJUR;
                objOverlay.Layers.Add(objAllRoads);
                Map1.CustomOverlays.Add(objOverlay);

                objAllRoads.Open();
                Map1.CurrentExtent = objAllRoads.GetBoundingBox();
                objAllRoads.Close(); 
            }
        }
        catch (Exception ex)
        {
            lblSuccess.Text = ex.Message;
        }
    }

    private TextStyle GetHaloLabelRender(float FontWidth, string strRenderField, GeoColor TextColor, bool blnOnTop = false, int intAlpha = 255)
    {
        if (blnOnTop == true)
            return TextStyles.CreateSimpleTextStyle(strRenderField, "Arial", FontWidth, DrawingFontStyles.Bold, TextColor, GeoColor.StandardColors.White, 3, 10, 10);
        else
            return TextStyles.CreateSimpleTextStyle(strRenderField, "Arial", FontWidth, DrawingFontStyles.Bold, TextColor, GeoColor.StandardColors.White, 3, -10, -10);
    }

    private void SetStandardRoadLabel(ref TextStyle objTextStyle, int intGridSize)
    {
        {
            objTextStyle.DuplicateRule = LabelDuplicateRule.OneDuplicateLabelPerQuadrant;
            objTextStyle.OverlappingRule = LabelOverlappingRule.NoOverlapping;
            objTextStyle.BestPlacement = true;
            objTextStyle.GridSize = intGridSize;
            objTextStyle.TextLineSegmentRatio = double.MaxValue;
            objTextStyle.SuppressPartialLabels = true; 
        }
    }
}

}

Thank you,
Neil
SampleShapefiles.zip (17.9 KB)

Hi Neil,

Thanks to let us know it, we had watched the mismatch result.

It looks that’s because the projection logic cannot parse some special projection correct for example the epsg 32026. But the conversion between 4326 and 3857 is correct, I tested the StreetSampleWGS84 file and it match base map after conversion just like you mentioned.

Because some calculation result is provided by 3rd part library, I am not sure whether we can solve it quickly, any update I will let you know.

Regards,

Ethan

Hi Neil,

Today our developer research it further, it looks it’s more difficult to locate the problem and solve it than we thought, we will update the status if we found get good news on it.

For now I think you should want to convert the data to 4326 or 3857 by 3rd part utility and then render it.

We will keep work on the projection conversion issue about 32026.

Regards,

Ethan

Hi Ethan,

Thank you for the update and suggestion.

Regards,

Neil

Hi Neil,

Thanks to let us knows this issue, we will keep work on it.

Regards,

Ethan