Maptitude - http://research.umbc.edu/~roswell/maptitude.html

I am sorry, in my previous posting I sent the macro with some commented lines that
I was using for testing.

Please, disregard the previous email, here is the correct version of the macro

Cheers,

Armando Scalise

================
Macro "shared_edges" (rh1,rh2)

// This macro computes the lenght of shared boundaries between two polygons
// It creates an array with all the lines in polygon 1 in a clockwise direction and
an array in counterclockwise direction
// It also creates an array of all lines in polygon 2, in clockwise direction
// It proceeds looking for lines in polygon 2 that matches start and end
coordinates in the counterclockwise OR the anticlockwuse lines array of polygon 2
// when a match is found, the length of that line is computed.
// it returns the lenght of the common boundary, or null if any of the input
parameters is null
// Written by Armando Scalise, [EMAIL PROTECTED]  Phone: +54 11 4432-2188
(Buenos Aires, Argentina)


        // check input parameters
        if rh1=null or rh2=null then Return(null)

        // Get Polygon points
        polys1=GetArea(rh2id(rh1))
        polys2=GetArea(rh2id(rh2))

        // Get First Polygon's borders clockwise
        last=  polys1[3][1]
        for i=1 to polys1[3].length do
               lines11=lines11+{{last,polys1[3][i]}}
               last=polys1[3][i]
        end

        // Get first polygon's  borders counter clockwise
        last=  polys1[3][polys1[3].length]
        for i=polys1[3].length to 1 step -1 do
               lines12=lines12+{{last,polys1[3][i]} }
               last=polys1[3][i]
        end

        // Get Second Polygon's  borders clockwise
        last=  polys2[3][1]
        for i=1 to polys2[3].length do
               lines2=lines2+{{last,polys2[3][i]}}
               last=polys2[3][i]
        end


        // Look for  matching borders
        totdist=0
        matches=null
        for i=1 to lines2.length do

               // check against clockwise coords.
               for j=1 to lines11.length do
                   if  lines2[i][1] =lines11[j][1] and lines2[i][2] =lines11[j][2]
then do
                          totdist=totdist+GetDistance(lines11[j][1],lines11[j][2])
                    end
              end

              // check against clockwise coords.
              for j=1 to lines12.length do
                   if  lines2[i][1] =lines12[j][1] and
lines2[i][2]=lines12[j][2]then do
                          totdist=totdist+GetDistance(lines12[j][1],lines12[j][2])
                    end
              end

        end

        Return(totdist)

endMacro


______________________________________________________________________
To unsubscribe, write to [EMAIL PROTECTED]

Reply via email to