I'm trying to choose two streets and if they intersect to have the map zoom in on the intersection between them i saw the sample file called ServicesEditionSample_StreetIntersection_CS_100121 on thinkgeo wiki but it give me this error " The shape you provided does not pass our simple validation.There are no points in the shape" how can i solve this issue, or if i could find the intersection in another way.
I don't have your data but I think that what is happening is that you are passing an invalid MultiLineShape or a LineShape into the function to find the intersection point. From reading the error description, it appears that you have a MultilineShape that does not have any points which is not logical and that causes the function to give an error. Since your data does not seem to be very clean and seems to contain invalid shapes, I suggest you check for the validity of the shape before passing it to the function. Each shape class has a Validate function. See the code below:
ShapeValidationResult shapeValidationResult = multilineShape.Validate(ShapeValidationMode.Simple); if (shapeValidationResult.IsValid == true) { //Do the Intersection function }
I saw the street intersection project on thinkgeo wiki and im trying to adapt it to my solution but there is a line Map.Image = bitmap; the method Image is not available on the desktop edition could u tell me if there is an equivelant to it?
You have to be aware that the sample in the Code Community is in the Services Edition using MapSuiteCore.dll and not any version specific dll. If you are in the Descktop Edition you need to get rid of the DrawImage function and instead use the Desktop specific LayerOverlays. See the code below where I have Street Intersection working with the Desktop Edition. Notice that I commented out the Services edition with mapEngine lines. And do not use DrawImage function.
//mapEngine..CurrentExtent = new RectangleShape(-97.7402, 30.2793, -97.7284, 30.2738); winformsMap1.CurrentExtent = new RectangleShape(-97.7402, 30.2793, -97.7284, 30.2738); //mapEngine.BackgroundFillBrush = new GeoSolidBrush(GeoColor.StandardColors.LightGoldenrodYellow); winformsMap1.BackColor = Color.LightGoldenrodYellow;
//Gets the features according to the street name. streetLayer.Open(); Collection<Feature> features1 = streetLayer.FeatureSource.GetFeaturesByColumnValue("FENAME", "Red River"); //"Speedway"); Collection<Feature> features2 = streetLayer.FeatureSource.GetFeaturesByColumnValue("FENAME", "15th"); //"Martin Luther King Jr"); streetLayer.Close();
//InMemoryFeatureLayer for displaying the street candidates and the intersection point. InMemoryFeatureLayer intersectionInMemoryFeatureLayer = new InMemoryFeatureLayer(); intersectionInMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.LightPink, 3, true); intersectionInMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimplePointStyle(PointSymbolType.Circle, GeoColor.StandardColors.Red, 12); intersectionInMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
//Adds the street candidates feature and the intersection point feature to the InMemoryFeatureLayer intersectionInMemoryFeatureLayer.Open(); intersectionInMemoryFeatureLayer.EditTools.BeginTransaction();
Collection<MultilineShape> multiLineShapes1 = new Collection<MultilineShape>(); Collection<MultilineShape> multiLineShapes2 = new Collection<MultilineShape>();
foreach (Feature feature1 in features1) { MultilineShape multiLineShape = feature1.GetShape() as MultilineShape; multiLineShapes1.Add(multiLineShape); intersectionInMemoryFeatureLayer.EditTools.Add(new Feature(multiLineShape)); } foreach (Feature feature2 in features2) { MultilineShape multiLineShape = feature2.GetShape() as MultilineShape; multiLineShapes2.Add(multiLineShape); intersectionInMemoryFeatureLayer.EditTools.Add(new Feature(multiLineShape)); }
//Gets the intersection point (or points if this is the case) intersectionInMemoryFeatureLayer.EditTools.Add(new Feature(GetIntersectionPoints(multiLineShapes1, multiLineShapes2, 50, DistanceUnit.Meter, GeographyUnit.DecimalDegree))); intersectionInMemoryFeatureLayer.EditTools.CommitTransaction(); intersectionInMemoryFeatureLayer.Close();
//mapEngine.StaticLayers.Add("StreetLayer", streetLayer); LayerOverlay staticOverlay = new LayerOverlay(); staticOverlay.Layers.Add("StreetLayer",streetLayer); winformsMap1.Overlays.Add(staticOverlay);
//mapEngine.DynamicLayers.Add("Intersection", intersectionInMemoryFeatureLayer); LayerOverlay dynamicOverlay = new LayerOverlay(); dynamicOverlay.Layers.Add("Intersection", intersectionInMemoryFeatureLayer); winformsMap1.Overlays.Add(dynamicOverlay);
Thanks alot its working fine now i just need to see my shape file why it doesn’t pass the validation ill do some testing to figure out why its behaving in this way but thanks alot
I am glad I could help you continue with your task. I let you know that if you keep having problems with the validation of your shapefile for doing the intersection, you can provide it to us and we can take a look. I just let you know that. Thank you.
I have it working with your data as you can see in the screen capture below. As you can see in the code, I simply had to change some parameters and it works fine with your Riyadh data. Instead of using "ST_NAME" column in the GetFeaturesByColumnValue, I use "FEAT_ID" because I am not familiar with Arabic.
Maybe you have it already working fine like this in most situations. If it is not working in some cases, can you point us out to a particular case where this is not working to see if the problem comes from our code or from some bad data that you have? Thank you.
Could this feature be emplimented by using ST_NAME and find the intersection or it could only be by FEAT_ID because i need the code to be something like this
Val Could it be because my dbf file is in arabic the error keeps popping up when asking or the feature by its name and when asking by a number its working fine?
Do you get the error "The shape you provided does not pass our simple validation. There are no points in the shape"? If this is the case, give me the FEAT_ID of the features you are trying to do the intersection on. If this is a different error, please, be more descriptive. We already provided you help for the Arabic encoding in the post "Map Encoding" gis.thinkgeo.com/Support/Discussion...fault.aspx. I don't know Arabic but I would believe that if we solve your problem in that post you should be fine with GetFeaturesByColumnValue using street name. Thank you.