ThinkGeo.com    |     Documentation    |     Premium Support

Shape you provided does not pass our simple validation

 I am trying to do a simple routing between three points. I get this error when I run my application:


Unhandled Exception: System.InvalidOperationException: The shape you provided does not pass our simple validation.The shape you provided does not pass our simple validation.


 


I have performed these checks on my data with success:


feature.isValid() and feature.GetShape().Lines.Count>0


 


Here is my code (I can upload my shape/routing files if necessary, but need to know where to upload them):



using System;


using System.Collections.Generic;


using System.Linq;


using System.Text;


using ThinkGeo.MapSuite.Core;


using ThinkGeo.MapSuite.Routing;


using System.Collections.ObjectModel;


 


namespace Routing


{


    class Program


    {


        static void Main(string[] args)


        {


            string shapeFile = @"C:\navteq\rich_rds_project.shp";


            


            string routingFile = @"C:\navteq\rich_rds_project.rtg";


            string indexFile = @"C:\navteq\rich_rds_project.idx";


 


            ShapeFileFeatureSource featureSource = new ShapeFileFeatureSource(shapeFile);


            


            //featureSource.Open();


            //Collection<Feature> allFeats =  featureSource.GetAllFeatures(ReturningColumnsType.AllColumns);


            //Collection<Feature> goodFeats = new Collection<Feature>();


 


            //foreach (Feature f in allFeats)


            //{


            //    MultilineShape line = f.GetShape() as MultilineShape;


            //    if (line.Lines.Count>0)


            //    {


            //        //Console.WriteLine("good feature - " + f.GetWellKnownText());


            //        goodFeats.Add(f);


            //    }


            //    else


            //    {


            //        Console.WriteLine("bad feature - " + f.GetWellKnownText());


            //    }


                    


            //}


            


            


            featureSource.IndexPathFileName = indexFile;


 


            //Console.WriteLine("Generating routing index");


            //ShapeFileFeatureSource.BuildIndexFile(shapeFile, indexFile, BuildIndexMode.Rebuild);


 


            //GenerateRoutableShapeFile(shapeFile, shapeFileRoutable, OverwriteMode.Overwrite); 


 


            //RtgRoutingSource.GenerateRoutingData(routingFile, featureSource, BuildRoutingDataMode.Rebuild,


            //    GeographyUnit.Feet, DistanceUnit.Feet); //Generate routing indexes


 


 


            RtgRoutingSource routingSource = new RtgRoutingSource(routingFile);


            RoutingEngine routingEngine = new RoutingEngine(routingSource, featureSource);


 


            //routingEngine.GeographyUnit = GeographyUnit.Feet;


 


            try


            {


 


                featureSource.Open();


 


 


                Collection<PointShape> stopList = new Collection<PointShape>();


 


                Feature feat2 = featureSource.GetFeatureById("50056", ReturningColumnsType.AllColumns);


                Feature feat3 = featureSource.GetFeatureById("45319", ReturningColumnsType.AllColumns);


                Feature feat4 = featureSource.GetFeatureById("17290", ReturningColumnsType.AllColumns);


 


                PointShape startPoint = feat2.GetShape().GetCenterPoint();


                


                routingEngine = new RoutingEngine(routingSource, new AStarRoutingAlgorithm(), featureSource);


 


                Console.WriteLine("Adding stops");


                stopList.Add(feat2.GetShape().GetCenterPoint());


                stopList.Add(feat3.GetShape().GetCenterPoint());


                stopList.Add(feat4.GetShape().GetCenterPoint());


                


                routingEngine.GeographyUnit = GeographyUnit.Feet;


 


                TspRoutingResult routingResult = routingEngine.GetRouteViaVisitStops(startPoint, stopList);


 


                Console.WriteLine("distance - " + routingResult.Distance);


                


            }


            finally


            {


                routingSource.Close();


                featureSource.Close();


                


 


            }


             


        }


    }


}


 



Ashley, 
  
 Thanks for your post and interests in MapSuite components. 
  
 Could you send us the shape file you are using against (rich_rds_project.shp)? if you want, you could either upload it to the discussion forum or send it our support(support@thinkgeo.com) and asked to forward to James or Yale, attached with this post link. 
  
 Any more questions please feel free to let me know. 
  
 Thanks. 
  
 Yale 


Ashley, 
  
 I got the different error that’s “Your input index is out of bound” when test your data, the reason is that you need to use Routable shp file instead of the original one,             string shapeFile = @“C:\navteq\rich_rds_Project.routable.shp”; 
  
 Thanks, 
  
 James

Strange. I do not get that particular error. I changed my code to use the routable shape file instead, and still get the "cannot pass simple validation" error. 
  


Here is the stack trace if it is helpful: 
  
 Unhandled Exception: System.InvalidOperationException: The shape you provided does not pass our simple validation.The shape you provided does not pass our simple validation. 
    at ThinkGeo.MapSuite.Core.x6d719af406ea4c2c.xff365c684fff1baa(BaseShape x873d 
 2ddd87022b07) 
    at ThinkGeo.MapSuite.Core.BaseShape.GetWellKnownText() 
    at ThinkGeo.MapSuite.Routing.RoutingEngine.xba37e7b3171bb466(Feature x714631e538918209, PointShape xcb09bd0cee4909a3, PointShape xa2da454aa40879d2) 
    at ThinkGeo.MapSuite.Routing.RoutingEngine.GetRoute(PointShape startPoint, PointShape endPoint) 
    at ThinkGeo.MapSuite.Routing.RoutingEngine.GetRouteViaVisitStopsCore(PointShape startPoint, IEnumerable`1 visitStops, Int32 Iterations) 
    at ThinkGeo.MapSuite.Routing.RoutingEngine.GetRouteViaVisitStops(PointShape startPoint, IEnumerable`1 visitStops) 
    at Routing.Program.Main(String[] args) in C:\MAPCOM\SVN\AshleyG\Routing\Routing\Program.cs:line 101

Ashley,


That is very strange. I checked the shape file you provided and did not find anything wrong. Can you take a try on your environment the following code snippet to see if the exception will be thrown when executing this code snippet?
 

string shapeFile = @"..\rich_rds_project\rich_rds_Project.shp";
ShapeFileFeatureLayer shapeFileFeatureLayer = new ShapeFileFeatureLayer(shapeFile, ShapeFileReadWriteMode.ReadOnly);
shapeFileFeatureLayer.Open();
Collection<Feature> allFeatures = shapeFileFeatureLayer.QueryTools.GetAllFeatures(ReturningColumnsType.AllColumns);
foreach (Feature feature in allFeatures)
{
     string wkt = feature.GetWellKnownText();
}

 
 
Any more questions please feel free to let me know. 



Thanks. 



Yale

Hi Yale, 
  
 I ran this snippet. No exceptions were thrown. Any other ideas? 
  
 Thanks, 
 Ashley

Ashley,


Which version of MapSuiteRouting.dll you are using? I used 4.5.137 to test and get that result but couldn't recreate your problem. Could you get the latest version of dll and try it again. We have fixed a similar problem at 4.5.47.0, you can look at gis.thinkgeo.com/Support/Dis...fault.aspx to verify if it's the same problem with you.


Thanks,

James



I downloaded the latest development build, and that did the trick, thanks!

Ashley, 
  
 Thanks for letting us know your status. 
  
 Any more questions please feel free to let me know. 
  
 Thanks. 
  
 Yale