ThinkGeo.com    |     Documentation    |     Premium Support

Topology validation

Hi All,


With version 6 of Mapsuite, we are now finding that some of our shapefiles cant be opened due to the validation check which is now run. Can this be turned off? Assuming it cant, we need to be able to ideally clean files automatically when they are opened. ArcGIS, Mapinfo, QGIS all allow for topology errors, which can be fixed if the user is doing anything which requires a clean set of geometries etc. If we cant turn this requirement off, or automate the cleaning, it could create problems for us because relatively un-skilled GIS users will not be able to open their files, and will also not know how to clean them.


I have played around with the topology validation sample and get similar errors to if I were looking at the data in another GIS application.


thanks


Phil



Hi Phil, 
  
 You can use the following code to turn it off,  
  
 BaseShape.GeometryLibrary = GeometryLibrary.Managed; 
  
 Hope it helps, 
  
 Edgar

Hi, 
  
 Can you please confirm where this code is to be added in my code. I have pasted my code below: 
  
 public layType AddCustomFeatureLayer(WpfMap wpfMap1, string location, string LayerName, string OverlayName,GeoColor fill, GeoColor outline) 
         { 
             layType layerType = new layType(); 
             try 
             { 
                 ShapeFileFeatureLayer customLayer = new ShapeFileFeatureLayer(@location); 
                 customLayer.Name = LayerName; 
           
                 if (System.IO.File.Exists(@location.Replace(“shp”, “idx”)) == false) //check if index exists 
                 { 
                     customLayer.RequireIndex = false; 
                     customLayer.Open(); 
                     //ThinkGeo.MapSuite.Core.RectangleShape rect = customLayer.GetBoundingBox(); //get the extent of the current layer 
                     if (customLayer.UsingSpatialIndex == false) 
                     { 
                         customLayer.Close(); 
                         ShapeFileFeatureSource.BuildIndexFile(@location, BuildIndexMode.Rebuild); 
                     } 
                 } 
                 customLayer.RequireIndex = true; 
  
  
                 //reproject the statesLayer to Spherical Mercator to match the base map’s projection. 
                 Proj4Projection proj4 = new Proj4Projection(); 
  
                 string prjFileText = System.IO.File.ReadAllText(@location.Replace(“shp”, “prj”)); //get the text of the .prj file. 
                 proj4.InternalProjectionParametersString = Proj4Projection.ConvertPrjToProj4(prjFileText); //set the internal projection.  The new ConvertPrjToProj4 methid is the key to this process. 
                 proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString(); //set the external projection.  In this case, it’s Spherical Mercator (which google/bing, etc all use). 
  
                 //Proj4Projection proj_EEZs = new Proj4Projection(); 
                 //proj_EEZs.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326); 
                 //proj_EEZs.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString(); 
                 customLayer.FeatureSource.Projection = proj4; // proj_EEZs; 
                 //customLayer.FeatureSource.Projection = proj_EEZs; // proj_EEZs; 
                 //customLayer.WrappingMode = WrappingMode.WrapDateline; 
                 //customLayer.WrappingExtent = new RectangleShape(WrapExtentMinX, WrapExtentMaxY, WrapExtentMaxX, WrapExtentMinY); //new RectangleShape(17897271, -1367305, 19514067, -2411741); 
  
  
  
                 //customLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.FromArgb(100, GeoColor.SimpleColors.Green)); 
                 customLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(AreaStyles.CreateSimpleAreaStyle(fill, outline)); 
                 customLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; 
  
                 LayerOverlay staticOverlay = new LayerOverlay(); 
                 staticOverlay.WrappingMode = WrappingMode.WrapDateline; 
                 staticOverlay.WrappingExtent = new RectangleShape(WrapExtentMinX, WrapExtentMaxY, WrapExtentMaxX, WrapExtentMinY); //new RectangleShape(17897271, -1367305, 19514067, -2411741); 
                 staticOverlay.Name = OverlayName; 
                 staticOverlay.Layers.Add(LayerName, customLayer); 
                 staticOverlay.Layers.MoveToTop(OverlayName); 
               
                 wpfMap1.Overlays.Add(staticOverlay); 
  
  
                 //wpfMap1.CurrentExtent = rect;//GetFullExtentSingleLayer(customLayer);// GetFullExtent(staticOverlay.Layers); 
                 //   wpfMap1.CurrentExtent = GetFullExtentSingleLayer(customLayer); 
                 if (wpfMap1.Overlays.Count == 1) 
                 { 
                     ZoomToLayer(wpfMap1, LayerName); 
                 } 
  
                 ShapeFileType shapefiletype = new ShapeFileType(); 
  
                 if (customLayer.IsOpen == false) 
                 { 
                     customLayer.Open(); 
                 } 
  
  
                 shapefiletype = customLayer.GetShapeFileType(); 
  
                  
  
  
                 switch (shapefiletype.ToString()) 
                 { 
                     case “Point”: 
                         layerType = layType.Point; 
                         break; 
                     case “PointM”: 
                         layerType = layType.Point; 
                         break; 
                     case “PointZ”: 
                         layerType = layType.Point; 
                         break; 
                     case “Line”: 
                         layerType = layType.Line; 
                         break; 
                     case “Polyline”: 
                         layerType = layType.Line; 
                         break; 
                     case “PolylineM”: 
                         layerType = layType.Line; 
                         break; 
                     case “PolylineZ”: 
                         layerType = layType.Line; 
                         break; 
                     case “Polygon”: 
                         layerType = layType.Polygon; ; 
                         break; 
                     case “PolygonM”: 
                         layerType = layType.Polygon; ; 
                         break; 
                     case “PolygonZ”: 
                         layerType = layType.Polygon; ; 
                         break; 
                     case “Multipoint”: 
                         layerType = layType.Point; 
                         break; 
                     case “MultipointM”: 
                         layerType = layType.Point; 
                         break; 
                     case “MultipointZ”: 
                         layerType = layType.Point; 
                         break; 
                     case “Multiline”: 
                         layerType = layType.Line; 
                         break; 
                     case “Multipolygon”: 
                         layerType = layType.Polygon; 
                         break; 
                 } 
  
                 // customLayer.Close(); 
                 wpfMap1.Refresh(); 
             }

Hi Bimal, 
  
 Just add it to the beginning of the app, It can work as managed mode all the time. 
  
 Regards, 
  
 Edgar