[Shapelib] ESRI ArcMap reading problem

Brian Peschel brianp at occinc.com
Wed Feb 9 09:53:07 PST 2005


I am having a problem with ESRI's ArcMap reading the shapes I create.  
It appears if ArcMap is taking the last point in a polygon and moving it 
to coord (0,0) causing a spike in the object displayed.  The shpDump 
program that is provided with the library isn't reporting any problems.  
I tried adding a call to SHPComputeExtents() but that didn't work 
either.  Any thoughts are this point would eb helpful.  Thanks!

Here is glimpse of the code:

    SHPGetInfo(shpHandle, NULL, &shapeType, NULL, NULL);

    // Allocate memory for the points
    padfX = static_cast<double *>(malloc(sizeof(double) * (geo.size() + 
1)));
    padfY = static_cast<double *>(malloc(sizeof(double) * (geo.size() + 
1)));

    // We never do multiple parts
    panParts[0] = 1;
    verticesCount = 0;
    for (VertexList::const_iterator iter = shape->begin(); iter != 
shape->end(); iter++)
    {
        convertPoint(coordTypeIn, coordTypeOut, zoneCode, *iter, 
convertedPoint);
        padfX[verticesCount] = (*iter).x();
        padfY[verticesCount] = (*iter).y();
        verticesCount++;
    }
    // Make sure the first and last point are identical if creating a 
polygon
    if (geo.type() == Geometric::POLYGON)
    {
        padfX[verticesCount] = padfX[0];
        padfY[verticesCount] = padfY[0];
        verticesCount++;
    }
    psObject = SHPCreateObject(shapeType, -1, 1, panParts, NULL, 
verticesCount, padfX, padfY, NULL, NULL );
// SHPRewindObject will reorder all the points and the first and last 
won't be the same
// anymore
//    SHPRewindObject(shpHandle, psObject); // Make sure the ring is in 
the correct direction
    SHPWriteObject(shpHandle, -1, psObject);
    SHPDestroyObject(psObject);

-- 
Brian Peschel
One Call Concepts, Inc
Systems Division




More information about the Shapelib mailing list