ThinkGeo.com    |     Documentation    |     Premium Support

Need some help with this projection

 Hi,


I have a shapefile that has been  converted from DXF AutoCad.   I have some trouble to understand how to load an overlay from this file.  I think that my issue is because of the projection that this file using:   Minnesota, Whashington County, NAD83 County coordinates, US Feet.


if you could show me how to load my layers  from both DXF and / or The shape file and of course how to use the right projection.


 


thanks a lot in advance.


 


jm.


 


 



Hello Jean-marie, 
  
 Based on your data, I found out the projection string should be: 
  
 +proj=lcc +datum=NAD83 +lon_0=-94d15 +lat_1=47d3 +lat_2=45d37 +lat_0=45 +x_0=800000 +y_0=100000 +to_meter=0.3048006096012192  +no_defs 
  
 so you can create a shape file feature layer, and a projection with internal string as above to show your map. 
  
 Let us know if you have queries. 
  
 Regards, 
  
 Gary

Hi Gary, 
  
 is this what you mean?   I tried and it didn’t work at all.  Could you give me an example? 
  
  
  
 
 Proj4Projection proj4_NAD83 = new Proj4Projection();
            proj4_NAD83.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
            proj4_NAD83.InternalProjectionParametersString = “+proj=lcc +datum=NAD83 +lon_0=-94d15 +lat_1=47d3 +lat_2=45d37 +lat_0=45 +x_0=800000 +y_0=100000 +to_meter=0.3048006096012192 +no_defs”;
            proj4_NAD83.Open();
 
 
  
 
 ShapeFileFeatureLayer _shapeFile;
            ShapeFileFeatureLayer.BuildIndexFile(Server.MapPath("~/App_Data/WoodburySite_pt.shp"), BuildIndexMode.DoNotRebuild);
            _shapeFile = new ShapeFileFeatureLayer(Server.MapPath("~/App_Data/WoodburySite_pt.shp"), ShapeFileReadWriteMode.ReadOnly);
            _shapeFile.Name = “CAD”;
            FeatureCache featureCache_DataSource = new FeatureCache();
            _shapeFile.FeatureSource.GeoCache = featureCache_DataSource;
            _shapeFile.FeatureSource.GeoCache.IsActive = true;
            _shapeFile.FeatureSource.Projection = proj4_NAD83;

            layerOverlay = (LayerOverlay)map.CustomOverlays[“CAD”];
            InMemoryFeatureLayer _layer_CAD = (InMemoryFeatureLayer)layerOverlay.Layers[“CADLayer”];

            _layer_CAD.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.FromArgb(100, GeoColor.StandardColors.RoyalBlue);
            _layer_CAD.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.Color = GeoColor.StandardColors.Blue;
            _layer_CAD.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.OuterPen = new GeoPen(GeoColor.FromArgb(200, GeoColor.StandardColors.Red), 5);
            _layer_CAD.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.SymbolPen = new GeoPen(GeoColor.FromArgb(255, GeoColor.StandardColors.Green), 8);
            _layer_CAD.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            _layer_CAD.Open();
            _layer_CAD.FeatureSource.Open();
            _shapeFile.FeatureSource.Open();
            _layer_CAD.FeatureSource.BeginTransaction();
            foreach (Feature _f in _shapeFile.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns))
            {
                _layer_CAD.FeatureSource.AddFeature(_f);
            }
            _layer_CAD.FeatureSource.CommitTransaction();
            _shapeFile.FeatureSource.Close();

            string _layer_CAD_Bb = _layer_CAD.GetBoundingBox().GetWellKnownText();

 
 
  
  
 <div id=“Map3” class=“MapZ”>
            @{
                Html.ThinkGeo().Map(“Map3”, System.Web.UI.WebControls.Unit.Percentage(100), System.Web.UI.WebControls.Unit.Percentage(100))
                .MapBackground(new BackgroundLayer(new GeoSolidBrush(GeoColor.StandardColors.White)))
                //.CurrentExtent(-20037508.34, -20037508.34, 20037508.34, 20037508.34)
                .MapUnit(GeographyUnit.Meter)
                .MapTools(mapTools =>
            {
                mapTools.OverlaySwitcherMapTool().Enabled(true);
                mapTools.MouseCoordinateMapTool().Enabled(false);
                mapTools.PanZoomBarMapTool().Enabled(false);
                mapTools.LoadingImageMapTool().Enabled(false);
                mapTools.TouchMapTool().Enabled(true);
                mapTools.MouseMapTool().Enabled(true);
                mapTools.KeyboardMapTool().Enabled(false);
                mapTools.ScaleLineMapTool().Enabled(false);
                mapTools.PanZoomMapTool().IsGlobeButtonEnabled(false).Enabled(true);
            })
            .MarkerOverlay(overlay =>
            {

                overlay.Name(“MarkerOverlay”)
                    .IsBaseOverlay(false)
                    .Columns(col => col.Add(new FeatureSourceColumn(“LocationType”, “INTEGER”, 32)))
                        .ZoomLevelSet(zoomlevelSet =>
                        {
                            MarkerClassBreak classBreak0 = new MarkerClassBreak(0);
                            MarkerClassBreak classBreak1 = new MarkerClassBreak(1);
                            classBreak1.DefaultMarkerStyle.WebImage = new ThinkGeo.MapSuite.MvcEdition.WebImage(@"/App_Themes/img/Places/High Detail/48x48/Places - High Detail Headquarters.png", 48, 48);
                            classBreak1.DefaultMarkerStyle.WebImage.ImageOffsetX = 0;
                            classBreak1.DefaultMarkerStyle.WebImage.ImageOffsetX = 0;
                            MarkerClassBreak classBreak2 = new MarkerClassBreak(2);
                            classBreak2.DefaultMarkerStyle.WebImage = new ThinkGeo.MapSuite.MvcEdition.WebImage(@"/App_Themes/img/Places/High Detail/32x32/Places - High Detail Office Building 1.png", 32, 32);
                            classBreak2.DefaultMarkerStyle.WebImage.ImageOffsetX = 0;
                            classBreak2.DefaultMarkerStyle.WebImage.ImageOffsetY = 0;
                            MarkerClassBreak classBreak3 = new MarkerClassBreak(3);
                            classBreak3.DefaultMarkerStyle.WebImage = new ThinkGeo.MapSuite.MvcEdition.WebImage(@"/App_Themes/img/Places/High Detail/24x24/Places - High Detail Industrial 2.png", 24, 24);
                            classBreak3.DefaultMarkerStyle.WebImage.ImageOffsetX = 0;
                            classBreak3.DefaultMarkerStyle.WebImage.ImageOffsetY = 0;

                            ClassBreakMarkerStyle classBreakStyle = new ClassBreakMarkerStyle(“LocationType”);
                            classBreakStyle.ClassBreaks.Add(classBreak0);
                            classBreakStyle.ClassBreaks.Add(classBreak1);
                            classBreakStyle.ClassBreaks.Add(classBreak2);
                            classBreakStyle.ClassBreaks.Add(classBreak3);
                            classBreakStyle.ColumnName = “LocationType”;

                            zoomlevelSet.ZoomLevel01.CustomMarkerStyle = classBreakStyle;
                            zoomlevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                        });

            })
            .DynamicOverlay(overlay =>
            {
            })
            .StaticOverlay(overlay =>
            {
            })
            .HighlightOverlay(overlay =>
            {
            })
            .CustomOverlays(overlays =>
            {
                overlays.WmsOverlay(“WMS Overlay”)
                                 .WebImageFormat(WebImageFormat.Jpeg)
                                 .Parameters(paras =>
                                 {
                                     paras.Add(“LAYERS”, “WorldMapKitRL_SPHMCT_Simplified”);
                                     paras.Add(“STYLES”, “DEFAULT”);
                                     paras.Add(“SRS”, “EPSG:900913”);
                                 })
                              .ServerUris(uris =>
                              {
                                  for (int x = 0; x <= 7; x++)
                                  {
                                      uris.Add(new Uri(“GEOWMS.USAC.MMM.COM:80/WmsHandler.axd”));
                                      uris.Add(new Uri(“GEOWMS.USAC.MMM.COM:81/WmsHandler.axd”));
                                      uris.Add(new Uri(“GEOWMS.USAC.MMM.COM:82/WmsHandler.axd”));
                                      uris.Add(new Uri(“GEOWMS.USAC.MMM.COM:83/WmsHandler.axd”));
                                      uris.Add(new Uri(“GEOWMS.USAC.MMM.COM:85/WmsHandler.axd”));
                                      uris.Add(new Uri(“GEOWMS.USAC.MMM.COM:86/WmsHandler.axd”));
                                  }
                              })
                              .TileType(TileType.MultipleTile).TileHeight(256).TileWidth(256)
                              .TransitionEffect(TransitionEffect.Stretching)
                              .WrapDateline(WrapDatelineMode.WrapDateline)
                              .IsBaseOverlay(true);


                InMemoryFeatureLayer PrimaryDesignCenterLayer = new InMemoryFeatureLayer();
                InMemoryFeatureLayer SecondaryDesignCenterLayer = new InMemoryFeatureLayer();
                InMemoryFeatureLayer ProductionPlant = new InMemoryFeatureLayer();

                overlays
                .LayerOverlay(“PDC”).Name(“PDC”)
                .WrapDateline(WrapDatelineMode.WrapDateline)
                    .Layer(“PrimaryDesignCenterLayer”, PrimaryDesignCenterLayer).Name(“PrimaryDesignCenterLayer”).IsVisible(true).IsBaseOverlay(false)
                    .TileType(TileType.MultipleTile).TransitionEffect(TransitionEffect.Stretching);

                overlays
                .LayerOverlay(“SDC”).Name(“SDC”)
                .WrapDateline(WrapDatelineMode.WrapDateline)
                    .Layer(“SecondaryDesignCenterLayer”, SecondaryDesignCenterLayer).Name(“SecondaryDesignCenterLayer”).IsVisible(true).IsBaseOverlay(false)
                    .TileType(TileType.MultipleTile).TransitionEffect(TransitionEffect.Stretching);

                overlays
                .LayerOverlay(“PDP”).Name(“PDP”)
                .WrapDateline(WrapDatelineMode.WrapDateline)
                    .Layer(“ProductionPlant”, ProductionPlant).Name(“ProductionPlant”).IsVisible(true).IsBaseOverlay(false)
                    .TileType(TileType.MultipleTile).TransitionEffect(TransitionEffect.Stretching);


                InMemoryFeatureLayer CADLayer = new InMemoryFeatureLayer();
                
                overlays
               .LayerOverlay(“CAD”).Name(“CAD”)
               .WrapDateline(WrapDatelineMode.WrapDateline)
                   .Layer(“CADLayer”, CADLayer).Name(“CADLayer”).IsVisible(true).IsBaseOverlay(false)
                   .TileType(TileType.MultipleTile).TransitionEffect(TransitionEffect.Stretching);
                

            })
            .Render();
            }
        </div>


Hi Jean-Marie,


I setup a sample that reads the .prj file for the shapefile directly and determines the InternalParametersString (the projection that your shapfile starts in) below. When I run this I am seeing the points displayed in South Dakota.
.CustomOverlays(overlays =>
  {
    overlays.GoogleOverlay(GoogleMapType.Hybrid);
  
  //Shapefile Code
        Proj4Projection proj4_NAD83 = new Proj4Projection();

        string prjFileText = System.IO.File.ReadAllText(Server.MapPath(@"~/App_Data/WoodburySite_pt.prj"));
  
        String Proj4ParametersString = Proj4Projection.ConvertPrjToProj4(prjFileText);
        proj4_NAD83.InternalProjectionParametersString = Proj4ParametersString;
        //proj4_NAD83.InternalProjectionParametersString = "+proj=lcc +datum=NAD83 +lon_0=-94d15 +lat_1=47d3 +lat_2=45d37 +lat_0=45 +x_0=800000 +y_0=100000 +to_meter=0.3048006096012192 +no_defs";
        proj4_NAD83.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
            
        proj4_NAD83.Open();

        ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(Server.MapPath(@"~/App_Data/WoodburySite_pt.shp"));
        worldLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.City5;
        worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
        worldLayer.FeatureSource.Projection = proj4_NAD83;

                        
         overlays
             .LayerOverlay("WorldOverlay",false,TileType.MultipleTile)
             .Layer(worldLayer);
{})  
 Can you double check that you have the correct information in your .prj file for this specific shapfile? It would seem that our Reprojection is working but that shapefile's prj information might be incorrect.



I was able to display the Shape files generated from AutoCAd the nice thing is that the prj string for the generated file is also created at by Autocad! 
  
 still think that if we could use dxf… 
  
 thanks again. 
  
 jm

Jean, 
  
 Thanks for your feedback, if you have any questions please let us know. 
  
 Regards, 
 Edgar