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 built an IPointCollection and can display it, but I would like to display multiple copies in different locations. Is there a way to center a point collection on another IPoint?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

Would ITransform2D (or 3D) work for you?

http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/ITransform2D_Interface/002m000003w3000000/

You can use whatever point you wanted to in the original point collection (centroid, endpoints, midpoints) and calculate the dx and dy needed to move. Or just construct an line from the two points and use MoveVector.

share|improve this answer
    
+1 this is the way to go. –  George Jul 23 '11 at 16:30
add comment

You're gonna have to modify the coordinates of each point.
You can write a method that accepts an IPointCollection, an IPoint and produces a shifted IPointCollection which would be the original IPointCollection but with all the coordinates shifted.
Doing this in a separate method is important to avoid accidentally modifying the original IPointCollection.
The tricky part is how to shift the points. You can assume that you'll make the first point in the IPointCollection be the IPoint passed to the method and apply the same shift to all the other points.
There are other options, like assuming that the input IPoint would be the new center of the IPointCollection. Do this by calculating the centroid of the IPointCollection and calculating the shift between it and the input IPoint then applying this shift to all the other points.

share|improve this answer
add comment

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.