[Shapelib] Problem using shapelib

David A Allen David.A1 at bigpond.com
Wed Jun 16 20:22:09 EDT 2004


Brian

I have encountered this type of problem in ArcView and found that there
is a function there that can remake a shapefile from a shapefile - this
rectified the problem I had but is hardly a production solution.

Regard David Allen

_______________________
David Allen - Research PhD Candidate specializing in
electrical conductivity imaging of groundwater.
National Centre for Groundwater Management
University of Technology - Sydney
Email       David.A1 at bigpond.com
mobile      0418 964 097
phone/fax +61 2 63323895 (ring before sending any fax)
70 Morrisset St Bathurst NSW 2795 Australia.


-----Original Message-----
From: shapelib-bounces at lists.maptools.org
[mailto:shapelib-bounces at lists.maptools.org] On Behalf Of Brian Peschel
Sent: Tuesday, 15 June 2004 1:46 AM
To: shapelib at lists.maptools.org
Subject: [Shapelib] Problem using shapelib


I am having problems with ArcView and shapefiles I am creating with 
shapelib (linux RH 8.0)

I am creating the shape files
    shpHandle = SHPCreate(tname.c_str(), SHPT_POLYGON);

and then adding the points
    SHPGetInfo(shpHandle, NULL, &shapeType, NULL, NULL);
    panParts[0] = 1;
    // Loop and add each point
        padfX[verticesCount] = convertedPoint.x();
        padfY[verticesCount] = convertedPoint.y();
        verticesCount++;
    // end loop
    psObject = SHPCreateObject(shapeType, -1, 1, panParts, NULL, 
verticesCount, padfX, padfY, NULL, NULL );

I then add the first point again since it is a polygon the first and 
last point apparently need to be the same (I have also tried not 
rewritting the final point). 
        padfX[verticesCount] = padfX[0];
        padfY[verticesCount] = padfY[0];
        verticesCount++;

This is a single ring polygon.  If I call SHPRewindObject it reorders my

points and the first/last point are no longer the same (so I am not 
calling it).  I then write and destroy the objects.

    psObject = SHPCreateObject(shapeType, -1, 1, panParts, NULL, 
verticesCount, padfX, padfY, NULL, NULL );
    SHPWriteObject(shpHandle, -1, psObject);
    SHPDestroyObject(psObject);

If I load these files into ArcView, they appear to be okay until you use

them when the last point gets dropped off.  If you use this shapechecker

(http://www.geocities.com/SiliconValley/Haven/2295/useful.html scroll 
down to 'Shapefile Checker' - first hit in google 
http://www.google.com/search?hl=en&ie=UTF-8&q=shapefile+checker&btnG=Goo
gle+Search 
) in debug mode you can see it is confused about the last point (and 
complains about the record size).

I am really lost at this point.  Any thoughts would be helpful.  Thanks 
in advance.
Brian
_______________________________________________
Shapelib mailing list
Shapelib at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/shapelib



More information about the Shapelib mailing list