Changeset 13041 for OpenSceneGraph/trunk/src/osgPlugins/shp/ESRIShape.cpp
 Timestamp:
 03/21/12 18:36:20 (4 years ago)
 Files:

 1 modified
Legend:
 Unmodified
 Added
 Removed

OpenSceneGraph/trunk/src/osgPlugins/shp/ESRIShape.cpp
r12539 r13041 3 3 #include <stdio.h> 4 4 #include <io.h> 5 5 6 6 namespace esri 7 7 { 8 8 int read(int fd, void * buf, size_t nbytes) { return _read(fd, buf, static_cast<unsigned int>(nbytes)); } 9 9 } 10 10 11 11 #else 12 12 #include <unistd.h> … … 17 17 } 18 18 19 #endif 19 #endif 20 20 21 21 #include "ESRIShape.h" … … 52 52 { 53 53 int nbytes = 0; 54 if( (nbytes = esri::read( fd, &val, sizeof(T))) <= 0 ) 54 if( (nbytes = esri::read( fd, &val, sizeof(T))) <= 0 ) 55 55 return false; 56 56 … … 129 129 } 130 130 131 RecordHeader::RecordHeader(): 132 recordNumber(1), 133 contentLength(0) 131 RecordHeader::RecordHeader(): 132 recordNumber(1), 133 contentLength(0) 134 134 { 135 135 } … … 150 150 151 151 152 NullRecord::NullRecord(): 153 shapeType(ShapeTypeNullShape) 152 NullRecord::NullRecord(): 153 shapeType(ShapeTypeNullShape) 154 154 {} 155 155 … … 189 189 190 190 ShapeObject::ShapeObject(ShapeType s): 191 shapeType(s) 191 shapeType(s) 192 192 {} 193 193 … … 197 197 198 198 199 Point::Point(): 200 ShapeObject(ShapeTypePoint), 199 Point::Point(): 200 ShapeObject(ShapeTypePoint), 201 201 x(0.0), 202 y(0.0) 202 y(0.0) 203 203 {} 204 204 205 Point::Point(const Point &p): 206 ShapeObject(ShapeTypePoint), 207 x(p.x), 208 y(p.y) 205 Point::Point(const Point &p): 206 ShapeObject(ShapeTypePoint), 207 x(p.x), 208 y(p.y) 209 209 {} 210 210 … … 241 241 } 242 242 243 MultiPoint::MultiPoint(): 244 ShapeObject(ShapeTypeMultiPoint), 245 numPoints(0), 246 points(0L) 243 MultiPoint::MultiPoint(): 244 ShapeObject(ShapeTypeMultiPoint), 245 numPoints(0), 246 points(0L) 247 247 {} 248 248 249 MultiPoint::MultiPoint( const struct MultiPoint &mpoint ): ShapeObject(ShapeTypeMultiPoint), 249 MultiPoint::MultiPoint( const struct MultiPoint &mpoint ): ShapeObject(ShapeTypeMultiPoint), 250 250 bbox(mpoint.bbox), 251 251 numPoints(mpoint.numPoints) … … 266 266 if( rh.read(fd) == false ) 267 267 return false; 268 268 269 269 SAFE_DELETE_ARRAY( points ); 270 270 … … 281 281 if( readVal<Integer>(fd, numPoints, LittleEndian ) == false ) 282 282 return false; 283 283 284 284 points = new struct Point[numPoints]; 285 285 for( Integer i = 0; i < numPoints; i++ ) … … 300 300 301 301 302 PolyLine::PolyLine(): 303 ShapeObject(ShapeTypePolyLine), 304 numParts(0), 305 numPoints(0), 306 parts(0L), 302 PolyLine::PolyLine(): 303 ShapeObject(ShapeTypePolyLine), 304 numParts(0), 305 numPoints(0), 306 parts(0L), 307 307 points(0L) {} 308 308 309 309 PolyLine::PolyLine( const PolyLine &p ): 310 ShapeObject(ShapeTypePolyLine), 310 ShapeObject(ShapeTypePolyLine), 311 311 numParts(p.numParts), 312 312 numPoints(p.numPoints) … … 322 322 } 323 323 324 PolyLine::~PolyLine() 324 PolyLine::~PolyLine() 325 325 { 326 326 delete [] parts; … … 371 371 372 372 373 Polygon::Polygon(): 374 ShapeObject(ShapeTypePolygon), 375 numParts(0), 376 numPoints(0), 377 parts(0L), 373 Polygon::Polygon(): 374 ShapeObject(ShapeTypePolygon), 375 numParts(0), 376 numPoints(0), 377 parts(0L), 378 378 points(0L) {} 379 379 380 380 Polygon::Polygon( const Polygon &p ): 381 ShapeObject(ShapeTypePolygon), 381 ShapeObject(ShapeTypePolygon), 382 382 numParts(p.numParts), 383 383 numPoints(p.numPoints) … … 443 443 ////////////////////////////////////////////////////////////////////// 444 444 445 PointM::PointM(): 446 ShapeObject(ShapeTypePointM), 445 PointM::PointM(): 446 ShapeObject(ShapeTypePointM), 447 447 x(0.0), 448 y(0.0), 449 m(0.0) 448 y(0.0), 449 m(0.0) 450 450 {} 451 451 452 PointM::PointM(const PointM &p): 453 ShapeObject(ShapeTypePointM), 454 x(p.x), 455 y(p.y), 456 m(p.m) 452 PointM::PointM(const PointM &p): 453 ShapeObject(ShapeTypePointM), 454 x(p.x), 455 y(p.y), 456 m(p.m) 457 457 {} 458 458 … … 490 490 491 491 492 MultiPointM::MultiPointM(): 493 ShapeObject(ShapeTypeMultiPointM), 494 numPoints(0), 492 MultiPointM::MultiPointM(): 493 ShapeObject(ShapeTypeMultiPointM), 494 numPoints(0), 495 495 points(0L), 496 496 mArray(0L) 497 497 {} 498 498 499 MultiPointM::MultiPointM( const struct MultiPointM &mpointm ): 500 ShapeObject(ShapeTypeMultiPointM), 499 MultiPointM::MultiPointM( const struct MultiPointM &mpointm ): 500 ShapeObject(ShapeTypeMultiPointM), 501 501 bbox(mpointm.bbox), 502 502 numPoints(mpointm.numPoints), … … 539 539 if( readVal<Integer>(fd, numPoints, LittleEndian ) == false ) 540 540 return false; 541 541 542 542 points = new struct Point[numPoints]; 543 543 Integer i; … … 572 572 } 573 573 574 PolyLineM::PolyLineM(): 575 ShapeObject(ShapeTypePolyLineM), 576 numParts(0), 577 numPoints(0), 578 parts(0L), 574 PolyLineM::PolyLineM(): 575 ShapeObject(ShapeTypePolyLineM), 576 numParts(0), 577 numPoints(0), 578 parts(0L), 579 579 points(0L), 580 mArray(0L) 580 mArray(0L) 581 581 {} 582 582 583 PolyLineM::PolyLineM(const PolyLineM &p): 584 ShapeObject(ShapeTypePolyLineM), 585 numParts(p.numParts), 586 numPoints(p.numPoints), 587 parts(0L), 583 PolyLineM::PolyLineM(const PolyLineM &p): 584 ShapeObject(ShapeTypePolyLineM), 585 numParts(p.numParts), 586 numPoints(p.numPoints), 587 parts(0L), 588 588 points(0L), 589 mArray(0L) 589 mArray(0L) 590 590 { 591 591 parts = new Integer[numParts]; … … 669 669 670 670 671 PolygonM::PolygonM(): 672 ShapeObject(ShapeTypePolygonM), 673 numParts(0), 674 numPoints(0), 675 parts(0L), 671 PolygonM::PolygonM(): 672 ShapeObject(ShapeTypePolygonM), 673 numParts(0), 674 numPoints(0), 675 parts(0L), 676 676 points(0L) , 677 677 mArray(0L) 678 678 {} 679 679 680 PolygonM::PolygonM(const PolygonM &p): 681 ShapeObject(ShapeTypePolygonM), 682 numParts(p.numParts), 683 numPoints(p.numPoints), 684 parts(0L), 680 PolygonM::PolygonM(const PolygonM &p): 681 ShapeObject(ShapeTypePolygonM), 682 numParts(p.numParts), 683 numPoints(p.numPoints), 684 parts(0L), 685 685 points(0L) , 686 686 mArray(0L) … … 770 770 ////////////////////////////////////////////////////////////////////// 771 771 772 PointZ::PointZ(): 773 ShapeObject(ShapeTypePointZ), 772 PointZ::PointZ(): 773 ShapeObject(ShapeTypePointZ), 774 774 x(0.0), 775 y(0.0), 775 y(0.0), 776 776 z(0.0), 777 m(0.0) 777 m(0.0) 778 778 {} 779 779 780 PointZ::PointZ(const PointZ &p): 781 ShapeObject(ShapeTypePointZ), 782 x(p.x), 783 y(p.y), 780 PointZ::PointZ(const PointZ &p): 781 ShapeObject(ShapeTypePointZ), 782 x(p.x), 783 y(p.y), 784 784 z(p.z), 785 m(p.m) 785 m(p.m) 786 786 {} 787 787 … … 823 823 } 824 824 825 MultiPointZ::MultiPointZ(): 826 ShapeObject(ShapeTypeMultiPointZ), 827 numPoints(0), 825 MultiPointZ::MultiPointZ(): 826 ShapeObject(ShapeTypeMultiPointZ), 827 numPoints(0), 828 828 points(0L), 829 829 zArray(0L), … … 831 831 {} 832 832 833 MultiPointZ::MultiPointZ( const struct MultiPointZ &mpointm ): 834 ShapeObject(ShapeTypeMultiPointZ), 833 MultiPointZ::MultiPointZ( const struct MultiPointZ &mpointm ): 834 ShapeObject(ShapeTypeMultiPointZ), 835 835 bbox(mpointm.bbox), 836 836 numPoints(mpointm.numPoints), … … 878 878 if( readVal<Integer>(fd, numPoints, LittleEndian ) == false ) 879 879 return false; 880 880 881 881 points = new struct Point[numPoints]; 882 882 Integer i; … … 923 923 924 924 925 PolyLineZ::PolyLineZ(): 926 ShapeObject(ShapeTypePolyLineZ), 927 numParts(0), 928 numPoints(0), 929 parts(0L), 925 PolyLineZ::PolyLineZ(): 926 ShapeObject(ShapeTypePolyLineZ), 927 numParts(0), 928 numPoints(0), 929 parts(0L), 930 930 points(0L), 931 931 zArray(0L) , 932 mArray(0L) 932 mArray(0L) 933 933 {} 934 934 935 PolyLineZ::PolyLineZ(const PolyLineZ &p): 936 ShapeObject(ShapeTypePolyLineZ), 937 numParts(p.numParts), 938 numPoints(p.numPoints), 939 parts(0L), 935 PolyLineZ::PolyLineZ(const PolyLineZ &p): 936 ShapeObject(ShapeTypePolyLineZ), 937 numParts(p.numParts), 938 numPoints(p.numPoints), 939 parts(0L), 940 940 points(0L), 941 941 zArray(0L) , 942 mArray(0L) 942 mArray(0L) 943 943 { 944 944 parts = new Integer[numParts]; … … 1027 1027 1028 1028 if( rh.contentLength != Z ) 1029 { 1029 { 1030 1030 mRange.read(fd); 1031 1031 mArray = new Double[numPoints]; … … 1041 1041 1042 1042 1043 PolygonZ::PolygonZ(): 1044 ShapeObject(ShapeTypePolygonZ), 1045 numParts(0), 1046 numPoints(0), 1047 parts(0L), 1043 PolygonZ::PolygonZ(): 1044 ShapeObject(ShapeTypePolygonZ), 1045 numParts(0), 1046 numPoints(0), 1047 parts(0L), 1048 1048 points(0L), 1049 1049 zArray(0L), … … 1051 1051 {} 1052 1052 1053 PolygonZ::PolygonZ(const PolygonZ &p): 1054 ShapeObject(ShapeTypePolygonZ), 1055 numParts(p.numParts), 1056 numPoints(p.numPoints), 1057 parts(0L), 1053 PolygonZ::PolygonZ(const PolygonZ &p): 1054 ShapeObject(ShapeTypePolygonZ), 1055 numParts(p.numParts), 1056 numPoints(p.numPoints), 1057 parts(0L), 1058 1058 points(0L) , 1059 1059 mArray(0L) … … 1065 1065 1066 1066 points = new Point[numPoints]; 1067 zArray = new Double[numPoints]; // jcm 1067 zArray = new Double[numPoints]; // jcm 1068 1068 mArray = new Double[numPoints]; 1069 1069 for( i = 0; i < numPoints; i++ ) 1070 1070 { 1071 1071 points[i] = p.points[i]; 1072 zArray[i] = p.zArray[i]; // jcm 1072 zArray[i] = p.zArray[i]; // jcm 1073 1073 // MArray seems to be missing sometimes 1074 if(p.mArray) 1074 if(p.mArray) 1075 1075 mArray[i] = p.mArray[i]; 1076 1076 } … … 1090 1090 if( rh.read(fd) == false ) 1091 1091 return false; 1092 1092 1093 1093 SAFE_DELETE_ARRAY( parts ); 1094 1094 SAFE_DELETE_ARRAY( points );