[mapserver-commits] r10593 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Tue Oct 12 10:42:55 EDT 2010
Author: warmerdam
Date: 2010-10-12 07:42:55 -0700 (Tue, 12 Oct 2010)
New Revision: 10593
Modified:
trunk/mapserver/mapshape.c
Log:
fix writing z/m shapes, error out in msSHPCreate for Z/M types if not enabled (#3564)
Modified: trunk/mapserver/mapshape.c
===================================================================
--- trunk/mapserver/mapshape.c 2010-10-12 14:42:29 UTC (rev 10592)
+++ trunk/mapserver/mapshape.c 2010-10-12 14:42:55 UTC (rev 10593)
@@ -434,6 +434,23 @@
ms_int32 i32;
double dValue;
+#ifndef USE_POINT_Z_M
+ if( nShapeType == SHP_POLYGONZ
+ || nShapeType == SHP_POLYGONM
+ || nShapeType == SHP_ARCZ
+ || nShapeType == SHP_ARCM
+ || nShapeType == SHP_POINTZ
+ || nShapeType == SHP_POINTM
+ || nShapeType == SHP_MULTIPOINTZ
+ || nShapeType == SHP_MULTIPOINTM )
+ {
+ msSetError( MS_SHPERR,
+ "Attempt to create M/Z shapefile but without having enabled Z/M support.",
+ "msSHPCreate()" );
+ return NULL;
+ }
+#endif
+
/* -------------------------------------------------------------------- */
/* Establish the byte order on this system. */
/* -------------------------------------------------------------------- */
@@ -748,14 +765,15 @@
}
}
+ nRecordSize = 44 + 4*t_nParts + 16 * t_nPoints;
#ifdef USE_POINT_Z_M
/* -------------------------------------------------------------------- */
- /* Polygon. Arc with Z */
+ /* measured shape : polygon and arc. */
/* -------------------------------------------------------------------- */
- if (psSHP->nShapeType == SHP_POLYGONZ || psSHP->nShapeType == SHP_ARCZ) {
- dfMMin = shape->line[0].point[0].z;
- dfMMax = shape->line[shape->numlines-1].point[shape->line[shape->numlines-1].numpoints-1].z;
-
+ if(psSHP->nShapeType == SHP_POLYGONM || psSHP->nShapeType == SHP_ARCM) {
+ dfMMin = shape->line[0].point[0].m;
+ dfMMax = shape->line[shape->numlines-1].point[shape->line[shape->numlines-1].numpoints-1].m;
+
nRecordSize = 44 + 4*t_nParts + 8 + (t_nPoints* 16);
ByteCopy( &(dfMMin), pabyRec + nRecordSize, 8 );
@@ -768,21 +786,21 @@
for( i = 0; i < shape->numlines; i++ ) {
for( j = 0; j < shape->line[i].numpoints; j++ ) {
- ByteCopy( &(shape->line[i].point[j].z), pabyRec + nRecordSize, 8 );
+ ByteCopy( &(shape->line[i].point[j].m), pabyRec + nRecordSize, 8 );
if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
nRecordSize += 8;
}
}
- } else
- nRecordSize = 44 + 4*t_nParts + 16 * t_nPoints;
-
+ }
+
/* -------------------------------------------------------------------- */
- /* measured shape : polygon and arc. */
+ /* Polygon. Arc with Z */
/* -------------------------------------------------------------------- */
- if(psSHP->nShapeType == SHP_POLYGONM || psSHP->nShapeType == SHP_ARCM) {
- dfMMin = shape->line[0].point[0].m;
- dfMMax = shape->line[shape->numlines-1].point[shape->line[shape->numlines-1].numpoints-1].m;
-
+ if (psSHP->nShapeType == SHP_POLYGONZ || psSHP->nShapeType == SHP_ARCZ
+ || psSHP->nShapeType == SHP_POLYGONM || psSHP->nShapeType == SHP_ARCM) {
+ dfMMin = shape->line[0].point[0].z;
+ dfMMax = shape->line[shape->numlines-1].point[shape->line[shape->numlines-1].numpoints-1].z;
+
nRecordSize = 44 + 4*t_nParts + 8 + (t_nPoints* 16);
ByteCopy( &(dfMMin), pabyRec + nRecordSize, 8 );
@@ -795,15 +813,13 @@
for( i = 0; i < shape->numlines; i++ ) {
for( j = 0; j < shape->line[i].numpoints; j++ ) {
- ByteCopy( &(shape->line[i].point[j].m), pabyRec + nRecordSize, 8 );
+ ByteCopy( &(shape->line[i].point[j].z), pabyRec + nRecordSize, 8 );
if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
nRecordSize += 8;
}
}
}
- else
-#endif /* USE_POINT_Z_M */
- nRecordSize = 44 + 4*t_nParts + 16 * t_nPoints;
+#endif /* def USE_POINT_Z_M */
}
/* -------------------------------------------------------------------- */
@@ -831,13 +847,13 @@
}
}
+ nRecordSize = 40 + 16 * t_nPoints;
+
#ifdef USE_POINT_Z_M
- if (psSHP->nShapeType == SHP_MULTIPOINTZ) {
- nRecordSize = 48 + 16 * t_nPoints;
+ if (psSHP->nShapeType == SHP_MULTIPOINTM) {
+ dfMMin = shape->line[0].point[0].m;
+ dfMMax = shape->line[0].point[shape->line[0].numpoints-1].m;
- dfMMin = shape->line[0].point[0].z;
- dfMMax = shape->line[0].point[shape->line[0].numpoints-1].z;
-
ByteCopy( &(dfMMin), pabyRec + nRecordSize, 8 );
if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
nRecordSize += 8;
@@ -847,19 +863,16 @@
nRecordSize += 8;
for( i = 0; i < shape->line[0].numpoints; i++ ) {
- ByteCopy( &(shape->line[0].point[i].z), pabyRec + nRecordSize, 8 );
+ ByteCopy( &(shape->line[0].point[i].m), pabyRec + nRecordSize, 8 );
if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
nRecordSize += 8;
}
- } else
- nRecordSize = 40 + 16 * t_nPoints;
+ }
- if (psSHP->nShapeType == SHP_MULTIPOINTM) {
- nRecordSize = 48 + 16 * t_nPoints;
+ if (psSHP->nShapeType == SHP_MULTIPOINTZ) {
+ dfMMin = shape->line[0].point[0].z;
+ dfMMax = shape->line[0].point[shape->line[0].numpoints-1].z;
- dfMMin = shape->line[0].point[0].m;
- dfMMax = shape->line[0].point[shape->line[0].numpoints-1].m;
-
ByteCopy( &(dfMMin), pabyRec + nRecordSize, 8 );
if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
nRecordSize += 8;
@@ -869,13 +882,12 @@
nRecordSize += 8;
for( i = 0; i < shape->line[0].numpoints; i++ ) {
- ByteCopy( &(shape->line[0].point[i].m), pabyRec + nRecordSize, 8 );
+ ByteCopy( &(shape->line[0].point[i].z), pabyRec + nRecordSize, 8 );
if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
nRecordSize += 8;
}
- } else
+ }
#endif /* USE_POINT_Z_M */
- nRecordSize = 40 + 16 * t_nPoints;
}
/* -------------------------------------------------------------------- */
@@ -891,26 +903,20 @@
SwapWord( 8, pabyRec + 20 );
}
+ nRecordSize = 20;
+
#ifdef USE_POINT_Z_M
- if (psSHP->nShapeType == SHP_POINTZ) {
- nRecordSize = 28;
-
- ByteCopy( &(shape->line[0].point[0].z), pabyRec + nRecordSize, 8 );
+ if (psSHP->nShapeType == SHP_POINTM) {
+ ByteCopy( &(shape->line[0].point[0].m), pabyRec + nRecordSize, 8 );
if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
nRecordSize += 8;
- } else
- nRecordSize = 20;
+ }
- if (psSHP->nShapeType == SHP_POINTM) {
- nRecordSize = 28;
-
- ByteCopy( &(shape->line[0].point[0].m), pabyRec + nRecordSize, 8 );
+ if (psSHP->nShapeType == SHP_POINTZ) {
+ ByteCopy( &(shape->line[0].point[0].z), pabyRec + nRecordSize, 8 );
if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
nRecordSize += 8;
- } else
- nRecordSize = 20;
-#else
- nRecordSize = 20;
+ }
#endif /* USE_POINT_Z_M */
}
More information about the mapserver-commits
mailing list