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();
}
}
}
}