Skip to content

Commit

Permalink
OGR input: add 2.5D support when USE_POINT_Z_M is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Jun 11, 2014
1 parent 40c22e0 commit 4630612
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion mapogr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ static void msOGRCloseConnection( void *conn_handle );
* does not include this new point.
**********************************************************************/
static void ogrPointsAddPoint(lineObj *line, double dX, double dY,
#ifdef USE_POINT_Z_M
double dZ,
#endif
int lineindex, rectObj *bounds)
{
/* Keep track of shape bounds */
Expand All @@ -100,7 +103,7 @@ static void ogrPointsAddPoint(lineObj *line, double dX, double dY,
line->point[line->numpoints].x = dX;
line->point[line->numpoints].y = dY;
#ifdef USE_POINT_Z_M
line->point[line->numpoints].z = 0.0;
line->point[line->numpoints].z = dZ;
line->point[line->numpoints].m = 0.0;
#endif
line->numpoints++;
Expand Down Expand Up @@ -208,16 +211,25 @@ static int ogrGeomPoints(OGRGeometryH hGeom, shapeObj *outshp)
* ------------------------------------------------------------------ */
if( eGType == wkbPoint ) {
ogrPointsAddPoint(line, OGR_G_GetX(hGeom, 0), OGR_G_GetY(hGeom, 0),
#ifdef USE_POINT_Z_M
OGR_G_GetZ(hGeom, 0),
#endif
outshp->numlines-1, &(outshp->bounds));
} else if( eGType == wkbLineString
|| eGType == wkbLinearRing ) {
for(i=0; i<numpoints; i++)
ogrPointsAddPoint(line, OGR_G_GetX(hGeom, i), OGR_G_GetY(hGeom, i),
#ifdef USE_POINT_Z_M
OGR_G_GetZ(hGeom, i),
#endif
outshp->numlines-1, &(outshp->bounds));
} else if( eGType == wkbMultiPoint ) {
for(i=0; i<numpoints; i++) {
OGRGeometryH hPoint = OGR_G_GetGeometryRef( hGeom, i );
ogrPointsAddPoint(line, OGR_G_GetX(hPoint, 0), OGR_G_GetY(hPoint, 0),
#ifdef USE_POINT_Z_M
OGR_G_GetZ(hPoint, 0),
#endif
outshp->numlines-1, &(outshp->bounds));
}
}
Expand Down Expand Up @@ -292,7 +304,11 @@ static int ogrGeomLine(OGRGeometryH hGeom, shapeObj *outshp,
OGR_G_GetPoints(hGeom,
&(line.point[0].x), sizeof(pointObj),
&(line.point[0].y), sizeof(pointObj),
#ifdef USE_POINT_Z_M
&(line.point[0].z), sizeof(pointObj));
#else
NULL, 0);
#endif
#endif

for(j=0; j<numpoints; j++) {
Expand Down Expand Up @@ -323,6 +339,9 @@ static int ogrGeomLine(OGRGeometryH hGeom, shapeObj *outshp,
line.point[line.numpoints-1].y != line.point[0].y ) ) {
line.point[line.numpoints].x = line.point[0].x;
line.point[line.numpoints].y = line.point[0].y;
#ifdef USE_POINT_Z_M
line.point[line.numpoints].z = line.point[0].z;
#endif
line.numpoints++;
}

Expand Down

0 comments on commit 4630612

Please sign in to comment.