ThinkGeo.com    |     Documentation    |     Premium Support

Rotating features

Hi Guys,


Can anyone tell me how i can rotate features on mu feature layers? I'm currently having trouble getting them to rotate at all.


This is where my code is currently but it's not having any effect on the features on the layer


 


     foreach (Overlay Overlay in this.winformsMap1.Overlays)

            {



                if (Overlay is LayerOverlay)

                {

                    LayerOverlay LayerOverlay = (LayerOverlay)Overlay;





                    foreach (Layer Layer in LayerOverlay.Layers)

                    {



                        if (Layer is InMemoryFeatureLayer)

                        {

                            InMemoryFeatureLayer featurelayer = (InMemoryFeatureLayer)Layer;



                            foreach (Feature feature in featurelayer.InternalFeatures)

                            { 

                            

                              BaseShape Shape = feature.GetShape();



                              Shape.Rotate(new PointShape(7.56345, 50.4173111), 34);

                            

                            }



                        }



                    }



                }



            }


 


thanks 


Aaron



Aaron,


To avoid misunderstand your requirements. I ask your two questions and answer by myself:
1.     Do you want to show a rotated layer on the map?
If the answer is Yes, We provide a HowDoI sample to Show how to use RotationProjection for a FeatureLayer, after install you can find the HowDoI sample at installation folder, and sample name is “UseRotationProjectionForAFeatureLayer” under “Projection” category.
2.     Do you want to rotate feature itself so it becomes a new feature? 
If the answer is Yes. Feature is a struct not object, so you need to create a new Feature, I modify a little bit of your code:
foreach (Overlay Overlay in this.winformsMap1.Overlays)
            {
                if (Overlay is LayerOverlay)
                {
                    LayerOverlay LayerOverlay = (LayerOverlay)Overlay;
                    foreach (Layer Layer in LayerOverlay.Layers)
                    {
                        if (Layer is InMemoryFeatureLayer)
                        {
                            InMemoryFeatureLayer featurelayer = (InMemoryFeatureLayer)Layer;
                            Collection<Feature> newFeatures = new Collection<Feature>();
                            foreach (Feature feature in featurelayer.InternalFeatures)
                            {
                                BaseShape Shape = feature.GetShape();
                                Shape.Rotate(new PointShape(7.56345, 50.4173111), 34);

                                Feature newFeature = new Feature(Shape,feature.ColumnValues);
                                newFeatures.Add(newFeature);
                            }

                            featurelayer.InternalFeatures.Clear();
                            foreach (Feature feature in newFeatures)
                            {
                                featurelayer.InternalFeatures.Add(feature.Id, feature);
                            }
                        }
                    }
                }
            }

3.     My requirement is neither 1 or 2.
 
If your requirement is the third one please let me know.
Thanks,
James