Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have some polylines - roads. They meet in an intersection like on the picture:

enter image description here

I want to find out which roads meets Road A - endpoint to endpoint - and i want to know the clockwise order of the result. Thus, the example in the picture should return in the order:

{ROAD C, ROAD D, ROAD B}

Using IFeatureClass.Search() with a ISpatialFilter only returns the features ordered by OBJECTID (The road names illustrate the order og OBJECTID).

Do I have to do the math myself, or is there some smart esri woodoo that I can do?

share|improve this question

2 Answers 2

As you have discovered the order of polylines is dictated by the row order returned in the cursor so you will have to do some post processing. This is how I would do it:

  1. For each polyline identify which end is intersecting road A (i.e. from or to end)
  2. Cast polyline into IPointcollection and depending on the orientation get the next vertex along its length.
  3. You now have 2 points, convert these into an ILine object
  4. Use this new ILine object in the IConstructAngle.ConstructLine method, note this uses radians, at which point my brain blows up as I never understand radians :)
  5. Store the angles, object ID in a dictionary, sort and report as required
share|improve this answer

You have completed the first step. You have to process these features (those you retreive in the initial spatial query) further to locate a common end node. Find the end-node of the source line then compare ot to each end node of each line in your cursor using IPoint:x,y,z. A simple loop will do.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.