MCPcopy Index your code
hub / github.com/MapServer/MapServer / msProjectRectAsPolygon

Function msProjectRectAsPolygon

mapproject.c:756–868  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

754/************************************************************************/
755
756static int
757msProjectRectAsPolygon(projectionObj *in, projectionObj *out,
758 rectObj *rect)
759{
760#ifdef USE_PROJ
761 shapeObj polygonObj;
762 lineObj ring;
763// pointObj ringPoints[NUMBER_OF_SAMPLE_POINTS*4+4];
764 pointObj *ringPoints;
765 int ix, iy;
766
767 double dx, dy;
768
769 ringPoints = (pointObj*) calloc(sizeof(pointObj),NUMBER_OF_SAMPLE_POINTS*4+4);
770 ring.point = ringPoints;
771 ring.numpoints = 0;
772
773 msInitShape( &polygonObj );
774 polygonObj.type = MS_SHAPE_POLYGON;
775
776/* -------------------------------------------------------------------- */
777/* Build polygon as steps around the source rectangle. */
778/* -------------------------------------------------------------------- */
779 dx = (rect->maxx - rect->minx)/NUMBER_OF_SAMPLE_POINTS;
780 dy = (rect->maxy - rect->miny)/NUMBER_OF_SAMPLE_POINTS;
781
782 /* sample along top */
783 if(dx != 0) {
784 for(ix = 0; ix <= NUMBER_OF_SAMPLE_POINTS; ix++ )
785 {
786 ringPoints[ring.numpoints].x = rect->minx + ix * dx;
787 ringPoints[ring.numpoints++].y = rect->miny;
788 }
789 }
790
791 /* sample on along right side */
792 if(dy != 0) {
793 for(iy = 1; iy <= NUMBER_OF_SAMPLE_POINTS; iy++ )
794 {
795 ringPoints[ring.numpoints].x = rect->maxx;
796 ringPoints[ring.numpoints++].y = rect->miny + iy * dy;
797 }
798 }
799
800 /* sample along bottom */
801 if(dx != 0) {
802 for(ix = NUMBER_OF_SAMPLE_POINTS-1; ix >= 0; ix-- )
803 {
804 ringPoints[ring.numpoints].x = rect->minx + ix * dx;
805 ringPoints[ring.numpoints++].y = rect->maxy;
806 }
807 }
808
809 /* sample on along left side */
810 if(dy != 0) {
811 for(iy = NUMBER_OF_SAMPLE_POINTS-1; iy >= 0; iy-- )
812 {
813 ringPoints[ring.numpoints].x = rect->minx;

Callers 1

msProjectRectFunction · 0.85

Calls 6

msInitShapeFunction · 0.85
msAddLineDirectlyFunction · 0.85
msProjectShapeLineFunction · 0.85
msFreeShapeFunction · 0.85
msProjectRectGridFunction · 0.85
msSetErrorFunction · 0.85

Tested by

no test coverage detected