Changeset 2053
- Timestamp:
- 11/22/05 13:29:41 (6 years ago)
- Location:
- trunk
- Files:
-
- 6 modified
-
CHANGES (modified) (1 diff)
-
doc/postgis.xml (modified) (1 diff)
-
lwgeom/liblwgeom.h (modified) (1 diff)
-
lwgeom/lwgeom_api.c (modified) (11 diffs)
-
regress/regress_expected (modified) (1 diff)
-
regress/regress.sql (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/CHANGES
r2040 r2053 36 36 - Fixed memory alignment problems 37 37 - Speedup of serializer functions 38 - Bug fix in force_4d, force_3dm and force_3dz functions 38 39 39 40 PostGIS 1.0.4 -
trunk/doc/postgis.xml
r2041 r2053 5017 5017 <para>Fixed a small bug in the getPoint4d_p() low-level function</para> 5018 5018 <para>Speedup of serializer functions</para> 5019 <para>Fixed a bug in force_3dm(), force_3dz() and force_4d()</para> 5019 5020 </sect2> 5020 5021 -
trunk/lwgeom/liblwgeom.h
r2037 r2053 270 270 // copies a point from the point array into the parameter point 271 271 // will set point's z=0 (or NaN) if pa is 2d 272 // will set point's m=0 (or NaN (if pa is 3d or 2d272 // will set point's m=0 (or NaN) if pa is 3d or 2d 273 273 // NOTE: point is a real POINT3D *not* a pointer 274 274 extern POINT4D getPoint4d(const POINTARRAY *pa, int n); -
trunk/lwgeom/lwgeom_api.c
r2020 r2053 8 8 #include "liblwgeom.h" 9 9 #include "wktparse.h" 10 11 /* 12 * Lower this to reduce integrity checks 13 */ 14 #define PARANOIA_LEVEL 1 10 15 11 16 //#define PGIS_DEBUG 1 … … 428 433 429 434 // copies a point from the point array into the parameter point 430 // will set point's z= 0 (or NaN)if pa is 2d431 // will set point's m= 0 (or NaN(if pa is 3d or 2d435 // will set point's z=NO_Z_VALUE if pa is 2d 436 // will set point's m=NO_M_VALUE if pa is 3d or 2d 432 437 // NOTE: this will modify the point4d pointed to by 'point'. 433 438 int 434 getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point) 435 { 436 int size; 437 439 getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *op) 440 { 441 uchar *ptr; 442 int zmflag; 443 444 #if PARANOIA_LEVEL > 0 438 445 if ( ! pa ) return 0; 439 446 … … 443 450 return 0; //error 444 451 } 445 446 memset(point, 0, sizeof(POINT4D)); 447 size = pointArray_ptsize(pa); 448 memcpy(point, getPoint_internal(pa, n), size); 452 #endif 453 454 /* Get a pointer to nth point offset and zmflag */ 455 ptr=getPoint_internal(pa, n); 456 zmflag=TYPE_GETZM(pa->dims); 457 458 switch (zmflag) 459 { 460 case 0: // 2d 461 memcpy(op, ptr, sizeof(POINT2D)); 462 op->m=NO_M_VALUE; 463 op->z=NO_Z_VALUE; 464 break; 465 466 case 3: // ZM 467 memcpy(op, ptr, sizeof(POINT4D)); 468 break; 469 470 case 2: // Z 471 memcpy(op, ptr, sizeof(POINT3DZ)); 472 op->m=NO_M_VALUE; 473 break; 474 475 case 1: // M 476 memcpy(op, ptr, sizeof(POINT3DM)); 477 op->m=op->z; // we use Z as temporary storage 478 op->z=NO_Z_VALUE; 479 break; 480 481 default: 482 lwerror("Unkown ZM flag ??"); 483 } 484 449 485 return 1; 486 450 487 } 451 488 … … 480 517 getPoint3dz_p(const POINTARRAY *pa, int n, POINT3DZ *op) 481 518 { 482 int size; 483 519 uchar *ptr; 520 521 #if PARANOIA_LEVEL > 0 484 522 if ( ! pa ) return 0; 523 524 if ( (n<0) || (n>=pa->npoints)) 525 { 526 lwnotice("%d out of numpoint range (%d)", n, pa->npoints); 527 return 0; //error 528 } 529 #endif 485 530 486 531 #ifdef PGIS_DEBUG … … 489 534 #endif 490 535 491 if ( (n<0) || (n>=pa->npoints)) 492 { 493 lwnotice("%d out of numpoint range (%d)", n, pa->npoints); 494 return 0; //error 495 } 496 497 /* initialize point */ 498 memset(op, 0, sizeof(POINT3DZ)); 499 500 /* copy */ 501 size = pointArray_ptsize(pa); 502 #ifdef PGIS_DEBUG 503 lwnotice("getPoint3dz_p: point size: %d", size); 504 #endif 505 memcpy(op, getPoint_internal(pa, n), size); 536 /* Get a pointer to nth point offset */ 537 ptr=getPoint_internal(pa, n); 538 539 /* 540 * if input POINTARRAY has the Z, it is always 541 * at third position so make a single copy 542 */ 543 if ( TYPE_HASZ(pa->dims) ) 544 { 545 memcpy(op, ptr, sizeof(POINT3DZ)); 546 } 547 548 /* 549 * Otherwise copy the 2d part and initialize 550 * Z to NO_Z_VALUE 551 */ 552 else 553 { 554 memcpy(op, ptr, sizeof(POINT2D)); 555 op->z=NO_Z_VALUE; 556 } 557 506 558 return 1; 507 559 … … 509 561 510 562 // copies a point from the point array into the parameter point 511 // will set point's m=NO_ Z_VALUE if pa has no M563 // will set point's m=NO_M_VALUE if pa has no M 512 564 // NOTE: this will modify the point3dm pointed to by 'point'. 513 565 int 514 566 getPoint3dm_p(const POINTARRAY *pa, int n, POINT3DM *op) 515 567 { 516 int size; 517 568 uchar *ptr; 569 int zmflag; 570 571 #if PARANOIA_LEVEL > 0 518 572 if ( ! pa ) return 0; 573 574 if ( (n<0) || (n>=pa->npoints)) 575 { 576 lwerror("%d out of numpoint range (%d)", n, pa->npoints); 577 return 0; //error 578 } 579 #endif 519 580 520 581 #ifdef PGIS_DEBUG … … 523 584 #endif 524 585 525 if ( (n<0) || (n>=pa->npoints)) 526 { 527 lwerror("%d out of numpoint range (%d)", n, pa->npoints); 528 return 0; //error 529 } 530 531 /* initialize point */ 532 memset(op, 0, sizeof(POINT3DM)); 533 534 /* copy */ 535 size = pointArray_ptsize(pa); 536 #ifdef PGIS_DEBUG 537 lwnotice("getPoint3dz_p: point size: %d", size); 538 #endif 539 memcpy(op, getPoint_internal(pa, n), size); 586 587 /* Get a pointer to nth point offset and zmflag */ 588 ptr=getPoint_internal(pa, n); 589 zmflag=TYPE_GETZM(pa->dims); 590 591 /* 592 * if input POINTARRAY has the M and NO Z, 593 * we can issue a single memcpy 594 */ 595 if ( zmflag == 1 ) 596 { 597 memcpy(op, ptr, sizeof(POINT3DM)); 598 return 1; 599 } 600 601 /* 602 * Otherwise copy the 2d part and 603 * initialize M to NO_M_VALUE 604 */ 605 memcpy(op, ptr, sizeof(POINT2D)); 606 607 /* 608 * Then, if input has Z skip it and 609 * copy next double, otherwise initialize 610 * M to NO_M_VALUE 611 */ 612 if ( zmflag == 3 ) 613 { 614 ptr+=sizeof(POINT3DZ); 615 memcpy(&(op->m), ptr, sizeof(double)); 616 } 617 else 618 { 619 op->m=NO_M_VALUE; 620 } 621 540 622 return 1; 541 623 } … … 549 631 { 550 632 POINT2D result; 551 int size; 552 553 if ( (n<0) || (n>=pa->npoints)) 554 { 555 return result; //error 556 } 557 558 size = pointArray_ptsize(pa); 559 560 // this does x,y 561 memcpy(&result.x, &pa->serialized_pointlist[size*n],sizeof(double)*2 ); 633 getPoint2d_p(pa, n, &result); 562 634 return result; 563 635 } … … 569 641 getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point) 570 642 { 571 int size; 572 643 #if PARANOIA_LEVEL > 0 573 644 if ( ! pa ) return 0; 574 645 575 if ( (n<0) || (n>=pa->npoints)) 576 { 577 lwerror("getPoint2d_p: point offset out of range"); 578 return 0; //error 579 } 580 581 size = pointArray_ptsize(pa); 582 583 // this does x,y 584 memcpy(point, &pa->serialized_pointlist[size*n],sizeof(double)*2 ); 585 return 1; 646 if ( (n<0) || (n>=pa->npoints)) 647 { 648 lwerror("getPoint2d_p: point offset out of range"); 649 return 0; //error 650 } 651 #endif 652 653 // this does x,y 654 memcpy(point, getPoint_internal(pa, n), sizeof(POINT2D)); 655 return 1; 586 656 } 587 657 … … 594 664 int size; 595 665 666 #if PARANOIA_LEVEL > 0 596 667 if ( pa == NULL ) { 597 668 lwerror("getPoint got NULL pointarray"); … … 603 674 return NULL; //error 604 675 } 676 #endif 605 677 606 678 size = pointArray_ptsize(pa); -
trunk/regress/regress_expected
r2026 r2053 144 144 142|SRID=5;MULTILINESTRING((2 2,3 3)) 145 145 143|SRID=6;MULTIPOLYGON(((0 0,1 0,1 1,0 1,0 0))) 146 144|POINTM(1 2 0) 147 145|POINT(1 2 0) 148 146|POINT(1 2 0 3) 149 147|POINT(1 2 3 0) 146 150 144|LINESTRING(-5 -5,0 0,1 1,4 4) -
trunk/regress/regress.sql
r2026 r2053 239 239 select '143', asewkt(multi(setsrid('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))'::geometry, 6))); 240 240 241 select '144', asewkt(force_3dm('POINT(1 2 3)')); 242 select '145', asewkt(force_3dz('POINTM(1 2 3)')); 243 select '146', asewkt(force_4d('POINTM(1 2 3)')); 244 select '147', asewkt(force_4d('POINT(1 2 3)')); 245 241 246 select '144', asewkt(linemerge('GEOMETRYCOLLECTION(LINESTRING(0 0, 1 1), LINESTRING(4 4, 1 1), LINESTRING(-5 -5, 0 0))'::geometry));
