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

Larry,

I am including a Macro that could replace the "get_common_boundaries_length" macro
in your program.

I have checked it under a number of different polygon layouts and it seems to be
working  fine.  please, let me know of any problem you might find specially with
some intrincated polygon arrays.

It code is easily understood, and  since it does not make use of GISDK spatial
analysis functions (except for GetArea()) it should be very efficient.

It works with all polygon sizes






=========================================

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(rh1))

        polys1=GetArea(83)
        polys2=GetArea(85)

        // 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


        // Check matching lines
        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

        ShowMessage(r2s(totdist)        )
        Return(totdist)

endMacro


______________________________________________________________________
To unsubscribe, write to [EMAIL PROTECTED]

Reply via email to