@@ -428,3 +428,108 @@ int ShapeHelper::GetContentLength(IShape* shp)
428428 return ShapeUtility::get_ContentLength (shpType, numPoints, numParts);
429429}
430430
431+
432+ // *************************************************************
433+ // DebugDump()
434+ // *************************************************************
435+ void ShapeHelper::DebugDump (IShape* shp)
436+ {
437+ long numPoints, numParts;
438+ ShpfileType shpType;
439+
440+ shp->get_NumPoints (&numPoints);
441+ shp->get_NumParts (&numParts);
442+ shp->get_ShapeType (&shpType);
443+
444+ if (numParts > 1 ) {
445+ ::OutputDebugStringA (" Not support NumParts > 1" );
446+ return ;
447+ }
448+
449+ if (numPoints <= 10 || numPoints > 15 )
450+ return ;
451+
452+ HRESULT hr;
453+ IPoint* pnt = nullptr ;
454+ CString sOutput ;
455+ double x, y, z, m;
456+ switch (shpType)
457+ {
458+ case SHP_NULLSHAPE :
459+ ::OutputDebugStringA (" ShapeHelper::DebugDump(): NULLSHAPE" );
460+ break ;
461+
462+ case SHP_POINT :
463+ case SHP_POINTZ :
464+ hr = shp->get_Point (0 , &pnt);
465+ if (FAILED (hr)) {
466+ CString sError ;
467+ sError .AppendFormat (" ShapeHelper::DebugDump() Failed in get_Point(1, ..)\r\n " );
468+ ::OutputDebugStringA (sError .GetBuffer());
469+ return ;
470+ }
471+ pnt->get_X (&x);
472+ pnt->get_Y (&y);
473+
474+ if (shpType == SHP_POINT )
475+ sOutput .AppendFormat (" Point N: %f E: %f\r\n " , y, x);
476+ else {
477+ pnt->get_Z (&z);
478+ pnt->get_M (&m);
479+ sOutput .AppendFormat (" Point N: %f E: %f Z: %f M: %f\r\n " , y, x, z, m);
480+ }
481+ break ;
482+
483+
484+ case SHP_POLYLINE :
485+ case SHP_POLYLINEZ :
486+ for (int i = 0 ; i < numPoints; i++) {
487+ hr = shp->get_Point (i, &pnt);
488+ if (FAILED (hr)) {
489+ CString sError ;
490+ sError .AppendFormat (" ShapeHelper::DebugDump() Failed in get_Point(%d, ..)\r\n " , i);
491+ ::OutputDebugStringA (sError .GetBuffer());
492+ return ;
493+ }
494+ pnt->get_X (&x);
495+ pnt->get_Y (&y);
496+ if (shpType == SHP_POLYLINE )
497+ sOutput .AppendFormat (" Point# %d X: %f Y: %f\r\n " , i, x, y);
498+ else {
499+ pnt->get_Z (&z);
500+ pnt->get_M (&m);
501+ sOutput .AppendFormat (" Point# %d N: %f E: %f Z: %f M: %f\r\n " , i, y, x, z, m);
502+ }
503+ }
504+ break ;
505+
506+ case SHP_POLYGON :
507+ case SHP_POLYGONZ :
508+ for (int i = 0 ; i < numPoints; i++) {
509+ hr = shp->get_Point (i, &pnt);
510+ if (FAILED (hr)) {
511+ CString sError ;
512+ sError .AppendFormat (" ShapeHelper::DebugDump() Failed in get_Point(%d, ..)\r\n " , i);
513+ ::OutputDebugStringA (sError .GetBuffer());
514+ return ;
515+ }
516+ pnt->get_X (&x);
517+ pnt->get_Y (&y);
518+ if (shpType == SHP_POLYGON )
519+ sOutput .AppendFormat (" Point# %d X: %f Y: %f\r\n " , i, x, y);
520+ else {
521+ pnt->get_Z (&z);
522+ pnt->get_M (&m);
523+ sOutput .AppendFormat (" Point# %d N: %f E: %f Z: %f M: %f\r\n " , i, y, x, z, m);
524+ }
525+ }
526+ break ;
527+
528+ default :
529+ ::OutputDebugStringA (" ShapeHelper::DebugDump(): Shape Type: Unknown" );
530+ break ;
531+ }
532+ sOutput .Append (" \r\n " );
533+ ::OutputDebugStringA (sOutput .GetBuffer());
534+ }
535+
0 commit comments