Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bit-wise comparison, comment and NULL check #61

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions contrib/shpgeo.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,19 +276,19 @@ SHPObject *SHPReadOGisWKB(WKBStreamObj *stream_obj)
const int thisDim = SHPDimension(nSHPType);

// SHPObject *psCShape;
if (thisDim && SHPD_AREA)
if (thisDim & SHPD_AREA)
{
/* psCShape = */ SHPReadOGisPolygon(stream_obj);
}
else
{
if (thisDim && SHPD_LINE)
if (thisDim & SHPD_LINE)
{
/* psCShape = */ SHPReadOGisLine(stream_obj);
}
else
{
if (thisDim && SHPD_POINT)
if (thisDim & SHPD_POINT)
{
/* psCShape = */ SHPReadOGisPoint(stream_obj);
}
Expand All @@ -306,8 +306,8 @@ SHPObject *SHPReadOGisWKB(WKBStreamObj *stream_obj)
* **************************************************************************/
int SHPWriteOGisWKB(WKBStreamObj *stream_obj, SHPObject *psCShape)
{
/* OGis WKB can handle either byte order, but if I get to choose I'd
/* rather have it predicatable system-to-system */
/* OGis WKB can handle either byte order, but if I get to choose I'd */
/* rather have it predicatable system-to-system */

if (stream_obj)
{
Expand All @@ -320,8 +320,8 @@ int SHPWriteOGisWKB(WKBStreamObj *stream_obj, SHPObject *psCShape)
}

/* object size needs to be 9 bytes for the wrapper, and for each polygon */
/* another 9 bytes all plus twice the total number of vertices */
/* times the sizeof (double) and just pad with 10 more chars for fun */
/* another 9 bytes all plus twice the total number of vertices */
/* times the sizeof (double) and just pad with 10 more chars for fun */
stream_obj->wStream =
calloc(1, (9 * (psCShape->nParts + 1)) +
(sizeof(double) * 2 * psCShape->nVertices) + 10);
Expand Down Expand Up @@ -359,19 +359,19 @@ int SHPWriteOGisWKB(WKBStreamObj *stream_obj, SHPObject *psCShape)

const int thisDim = SHPDimension(psCShape->nSHPType);

if (thisDim && SHPD_AREA)
if (thisDim & SHPD_AREA)
{
SHPWriteOGisPolygon(stream_obj, psCShape);
}
else
{
if (thisDim && SHPD_LINE)
if (thisDim & SHPD_LINE)
{
SHPWriteOGisLine(stream_obj, psCShape);
}
else
{
if (thisDim && SHPD_POINT)
if (thisDim & SHPD_POINT)
{
SHPWriteOGisPoint(stream_obj, psCShape);
}
Expand Down Expand Up @@ -778,7 +778,7 @@ PT *SHPPointsinPoly_2d(SHPObject *psCShape)
double rLenMax = 0;

SHPObject *psO;
while (psO = SHPUnCompound(psCShape, &cRing))
while ((psO = SHPUnCompound(psCShape, &cRing)) != NULL)
{
double *CLx = calloc(4, sizeof(double));
double *CLy = calloc(4, sizeof(double));
Expand Down Expand Up @@ -1115,7 +1115,7 @@ double SHPArea_2d(SHPObject *psCShape)
* **************************************************************************/
double SHPLength_2d(SHPObject *psCShape)
{
if (!(SHPDimension(psCShape->nSHPType) && (SHPD_AREA || SHPD_LINE)))
if (!(SHPDimension(psCShape->nSHPType) & (SHPD_AREA | SHPD_LINE)))
return -1.0;

double Length = 0;
Expand Down