How calculate polygon dimensions

4574
8
08-18-2014 11:09 PM
NajdALHanahnah
New Contributor III

Dear All

 

There is a way to calculate polygon dimensions (Side) , if i ma working on ArcObject (Java or .NET) any suggestions  ...

especially with complex polygon

 

 

dim1.png

 

Thanks

0 Kudos
8 Replies
DanPatterson_Retired
MVP Emeritus

I think the term is "perimeter" that you are looking for.  Did you do a search using    arcobjects perimeter  first?

0 Kudos
NajdALHanahnah
New Contributor III

Dear Mr.Dan

I am not looking for perimeter  i am looking for dimensions for each side ...

see what i meant >>>

dim1.png

0 Kudos
nicogis
MVP Frequent Contributor

you can see code in this link : IPolygon4.ExteriorRingBag Property (ArcObjects .NET 10 SDK)

in this code when you loop on points you can get distance from point(i) to point(i+1) ...

0 Kudos
nicogis
MVP Frequent Contributor

... if your polygons are composed from only lines ...

0 Kudos
RiyasDeen
Occasional Contributor III

Below my suggestion, never implemented this scenario personally before just a possible solution

  • Cast your polygon to ISegmentCollection
  • Iterate through each segment
  • Use ReturnTurnDirection ArcObjects 10 .NET SDK Help‌ on your segments
  • If No Turn returned ArcObjects 10 .NET SDK Help then sum your segment length
  • Whenever there is a turn break your summation and restart
  • At the end you loop you would have got your dimensions.
NajdALHanahnah
New Contributor III

Thanks Riyas for your post ,  i saw what you put and really interesting idea , but how i can do that in coding level , if

you have any idea plz help me ...thanks 

0 Kudos
RiyasDeen
Occasional Contributor III

Hi Najd,

Try below code.

Note: Even if there is a suttle change in direction between segments (i.e. not exactly 180 degree), it'll be treated as change and gets counted as different section.

Do post back if this worked.

                        ISegmentCollection segments = (ISegmentCollection)lta.Shape;

                        List<double> dimensions = new List<double>();

                        if (segments != null)

                        {

                            double length = 0;

                            for (int idx = 0; idx < segments.SegmentCount; idx++)

                            {

                                ISegment currentSegemnt = segments.get_Segment(idx);

                               

                                if (idx + 1 < segments.SegmentCount)

                                {

                                    ISegment otherSegment = segments.get_Segment(idx + 1);

                                    if (currentSegemnt.ReturnTurnDirection(otherSegment) != 1)

                                    {

                                        dimensions.Add(length);

                                        length = 0;

                                    }

                                }

                                else

                                {

                                    dimensions.Add(length);

                                }

                            }

                        }

0 Kudos
NajdALHanahnah
New Contributor III

Hi Riyas

Thanks for your post , really appropriate that m, let me test it today and i will give you the feedback ...

thanks

0 Kudos