[mapserver-commits] r8796 - sandbox/graphics
svn at osgeo.org
svn at osgeo.org
Sat Mar 14 05:20:21 EDT 2009
Author: tbonfort
Date: 2009-03-14 05:20:19 -0400 (Sat, 14 Mar 2009)
New Revision: 8796
Modified:
sandbox/graphics/mapprimitive.c
sandbox/graphics/mapprimitive.h
Log:
more formatting reverts
Modified: sandbox/graphics/mapprimitive.c
===================================================================
--- sandbox/graphics/mapprimitive.c 2009-03-14 09:09:55 UTC (rev 8795)
+++ sandbox/graphics/mapprimitive.c 2009-03-14 09:20:19 UTC (rev 8796)
@@ -15,7 +15,7 @@
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
- * The above copyright notice and this permission notice shall be included in
+ * The above copyright notice and this permission notice shall be included in
* all copies of this Software or works derived from this Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
@@ -46,7 +46,7 @@
#endif
#define NEARZERO (1.0e-30) /* 1/INFINITY */
-void msPrintShape(shapeObj *p)
+void msPrintShape(shapeObj *p)
{
int i,j;
@@ -91,7 +91,7 @@
shape->type = MS_SHAPE_NULL;
shape->bounds.minx = shape->bounds.miny = -1;
shape->bounds.maxx = shape->bounds.maxy = -1;
-
+
/* attribute component */
shape->values = NULL;
shape->numvalues = 0;
@@ -128,7 +128,7 @@
to->index = from->index;
to->tileindex = from->tileindex;
- if(from->values) {
+ if(from->values) {
to->values = (char **)malloc(sizeof(char *)*from->numvalues);
for(i=0; i<from->numvalues; i++)
to->values[i] = strdup(from->values[i]);
@@ -152,7 +152,7 @@
if(shape->values) msFreeCharArray(shape->values, shape->numvalues);
if(shape->text) free(shape->text);
-
+
#ifdef USE_GEOS
msGEOSFreeGeometry(shape);
#endif
@@ -177,8 +177,8 @@
free( shape->line[line].point );
if( line < shape->numlines - 1 ) {
- memmove( shape->line + line,
- shape->line + line + 1,
+ memmove( shape->line + line,
+ shape->line + line + 1,
sizeof(lineObj) * (shape->numlines - line - 1) );
}
shape->numlines--;
@@ -193,7 +193,7 @@
shape->bounds.minx = shape->bounds.maxx = shape->line[0].point[0].x;
shape->bounds.miny = shape->bounds.maxy = shape->line[0].point[0].y;
-
+
for( i=0; i<shape->numlines; i++ ) {
for( j=0; j<shape->line[i].numpoints; j++ ) {
shape->bounds.minx = MS_MIN(shape->bounds.minx, shape->line[i].point[j].x);
@@ -205,9 +205,9 @@
}
/* checks to see if ring r is an outer ring of shape */
-static int isOuterRing(shapeObj *shape, int r)
+static int isOuterRing(shapeObj *shape, int r)
{
- int i, status=MS_TRUE;
+ int i, status=MS_TRUE;
int result1, result2;
if(shape->numlines == 1) return(MS_TRUE);
@@ -235,10 +235,10 @@
}
/*
-** Returns a list of outer rings for shape (the list has one entry for each ring,
+** Returns a list of outer rings for shape (the list has one entry for each ring,
** MS_TRUE for outer rings).
*/
-int *msGetOuterList(shapeObj *shape)
+int *msGetOuterList(shapeObj *shape)
{
int i;
int *list;
@@ -255,7 +255,7 @@
/*
** Returns a list of inner rings for ring r in shape (given a list of outer rings).
*/
-int *msGetInnerList(shapeObj *shape, int r, int *outerlist)
+int *msGetInnerList(shapeObj *shape, int r, int *outerlist)
{
int i;
int *list;
@@ -280,15 +280,15 @@
** Add point to a line object.
**
** Note that reallocating the point array larger for each point can
-** be pretty inefficient, so use this function sparingly. Mostly
-** geometries creators should create their own working lineObj and
+** be pretty inefficient, so use this function sparingly. Mostly
+** geometries creators should create their own working lineObj and
** then call msAddLine() to add it to a shape.
*/
int msAddPointToLine(lineObj *line, pointObj *point )
{
line->numpoints += 1;
-
+
line->point = (pointObj *) realloc(line->point, sizeof(pointObj) * line->numpoints);
line->point[line->numpoints-1] = *point;
@@ -305,7 +305,7 @@
msSetError(MS_MEMERR, NULL, "msAddLine()");
return(MS_FAILURE);
}
-
+
memcpy( lineCopy.point, new_line->point, sizeof(pointObj) * new_line->numpoints );
return msAddLineDirectly( p, &lineCopy );
@@ -313,7 +313,7 @@
/*
** Same as msAddLine(), except that this version "seizes" the points
-** array from the passed in line and uses it instead of copying it.
+** array from the passed in line and uses it instead of copying it.
*/
int msAddLineDirectly(shapeObj *p, lineObj *new_line)
{
@@ -331,7 +331,7 @@
/* Copy the new line onto the end of the extended line array */
c= p->numlines;
- p->line[c].numpoints = new_line->numpoints;
+ p->line[c].numpoints = new_line->numpoints;
p->line[c].point = new_line->point;
/* strip points reference off the passed in lineObj */
@@ -357,7 +357,7 @@
lineObj line={0,NULL};
line.point = (pointObj *)malloc(sizeof(pointObj)*5);
-
+
line.point[0].x = rect.minx;
line.point[0].y = rect.miny;
line.point[1].x = rect.minx;
@@ -368,9 +368,9 @@
line.point[3].y = rect.miny;
line.point[4].x = line.point[0].x;
line.point[4].y = line.point[0].y;
-
+
line.numpoints = 5;
-
+
msAddLine(poly, &line);
if(poly->numlines == 1) { /* poly was empty to begin with */
poly->type = MS_SHAPE_POLYGON;
@@ -456,7 +456,7 @@
/*
** Routine for clipping a polyline, stored in a shapeObj struct, to a
-** rectangle. Uses clipLine() function to create a new shapeObj.
+** rectangle. Uses clipLine() function to create a new shapeObj.
*/
void msClipPolylineRect(shapeObj *shape, rectObj rect)
{
@@ -472,7 +472,7 @@
/*
** Don't do any clip processing of shapes completely within the
- ** clip rectangle based on a comparison of bounds. We could do
+ ** clip rectangle based on a comparison of bounds. We could do
** something similar for completely outside, but that rarely occurs
** since the spatial query at the layer read level has generally already
** discarded all shapes completely outside the rect.
@@ -506,7 +506,7 @@
} else { /* add just the last point */
line.point[line.numpoints].x = x2;
line.point[line.numpoints].y = y2;
- line.numpoints++;
+ line.numpoints++;
}
if((x2 != shape->line[i].point[j].x) || (y2 != shape->line[i].point[j].y)) {
@@ -524,7 +524,7 @@
free(line.point);
line.numpoints = 0; /* new line */
}
-
+
for (i=0; i<shape->numlines; i++) free(shape->line[i].point);
free(shape->line);
@@ -546,13 +546,13 @@
lineObj line={0,NULL};
msInitShape(&tmp);
-
+
if(shape->numlines == 0) /* nothing to clip */
return;
/*
** Don't do any clip processing of shapes completely within the
- ** clip rectangle based on a comparison of bounds. We could do
+ ** clip rectangle based on a comparison of bounds. We could do
** something similar for completely outside, but that rarely occurs
** since the spatial query at the layer read level has generally already
** discarded all shapes completely outside the rect.
@@ -571,12 +571,12 @@
line.numpoints = 0;
for (i = 0; i < shape->line[j].numpoints-1; i++) {
-
+
x1 = shape->line[j].point[i].x;
y1 = shape->line[j].point[i].y;
x2 = shape->line[j].point[i+1].x;
y2 = shape->line[j].point[i+1].y;
-
+
deltax = x2-x1;
if (deltax == 0) { /* bump off of the vertical */
deltax = (x1 > rect.minx) ? -NEARZERO : NEARZERO ;
@@ -585,7 +585,7 @@
if (deltay == 0) { /* bump off of the horizontal */
deltay = (y1 > rect.miny) ? -NEARZERO : NEARZERO ;
}
-
+
if (deltax > 0) { /* points to right */
xin = rect.minx;
xout = rect.maxx;
@@ -600,10 +600,10 @@
yin = rect.maxy;
yout = rect.miny;
}
-
+
tinx = (xin - x1)/deltax;
tiny = (yin - y1)/deltay;
-
+
if (tinx < tiny) { /* hits x first */
tin1 = tinx;
tin2 = tiny;
@@ -611,7 +611,7 @@
tin1 = tiny;
tin2 = tinx;
}
-
+
if (1 >= tin1) {
if (0 < tin1) {
line.point[line.numpoints].x = xin;
@@ -621,9 +621,9 @@
if (1 >= tin2) {
toutx = (xout - x1)/deltax;
touty = (yout - y1)/deltay;
-
+
tout = (toutx < touty) ? toutx : touty ;
-
+
if (0 < tin2 || 0 < tout) {
if (tin2 <= tout) {
if (0 < tin2) {
@@ -677,7 +677,7 @@
free(line.point);
} /* next line */
-
+
for (i=0; i<shape->numlines; i++) free(shape->line[i].point);
free(shape->line);
@@ -695,8 +695,8 @@
double x=0, y=0;
if ( msCheckParentPointer(layer->map,"map")==MS_FAILURE )
return;
+
-
if(layer->transform == MS_TRUE) return; /* nothing to do */
if(layer->units == MS_PERCENTAGES) {
@@ -750,7 +750,7 @@
/*
** offsets a shape relative to an image position
*/
-void msOffsetShapeRelativeTo(shapeObj *shape, layerObj *layer)
+void msOffsetShapeRelativeTo(shapeObj *shape, layerObj *layer)
{
int i, j;
double x=0, y=0;
@@ -758,8 +758,8 @@
if(layer->transform == MS_TRUE) return; /* nothing to do */
if ( msCheckParentPointer(layer->map,"map")==MS_FAILURE )
return;
+
-
if(layer->units == MS_PERCENTAGES) {
for (i=0; i<shape->numlines; i++) {
for (j=0; j<shape->line[i].numpoints; j++) {
@@ -859,7 +859,7 @@
if(shape->type == MS_SHAPE_LINE || shape->type == MS_SHAPE_POLYGON) { /* remove co-linear vertices */
- for(i=0; i<shape->numlines; i++) { /* for each part */
+ for(i=0; i<shape->numlines; i++) { /* for each part */
for(j=0; j < shape->line[i].numpoints; j++ ) {
shape->line[i].point[j].x = MS_IMAGE2MAP_X(shape->line[i].point[j].x, extent.minx, cellsize);
shape->line[i].point[j].y = MS_IMAGE2MAP_Y(shape->line[i].point[j].y, extent.maxy, cellsize);
@@ -882,7 +882,7 @@
** Not a generic intersection test, we KNOW the lines aren't parallel or coincident. To be used with the next
** buffering code only. See code in mapsearch.c for a boolean test for intersection.
*/
-static pointObj generateLineIntersection(pointObj a, pointObj b, pointObj c, pointObj d)
+static pointObj generateLineIntersection(pointObj a, pointObj b, pointObj c, pointObj d)
{
pointObj p;
double r;
@@ -890,8 +890,8 @@
if(b.x == c.x && b.y == c.y) return(b);
- numerator = ((a.y-c.y)*(d.x-c.x) - (a.x-c.x)*(d.y-c.y));
- denominator = ((b.x-a.x)*(d.y-c.y) - (b.y-a.y)*(d.x-c.x));
+ numerator = ((a.y-c.y)*(d.x-c.x) - (a.x-c.x)*(d.y-c.y));
+ denominator = ((b.x-a.x)*(d.y-c.y) - (b.y-a.y)*(d.x-c.x));
r = numerator/denominator;
@@ -907,13 +907,13 @@
pointObj a;
lineObj inside, outside;
double angle;
- double dx, dy;
+ double dx, dy;
for (i = 0; i < p->numlines; i++) {
inside.point = (pointObj *)malloc(sizeof(pointObj)*p->line[i].numpoints);
outside.point = (pointObj *)malloc(sizeof(pointObj)*p->line[i].numpoints);
- inside.numpoints = outside.numpoints = p->line[i].numpoints;
+ inside.numpoints = outside.numpoints = p->line[i].numpoints;
angle = asin(MS_ABS(p->line[i].point[1].x - p->line[i].point[0].x)/sqrt((pow((p->line[i].point[1].x - p->line[i].point[0].x),2.0) + pow((p->line[i].point[1].y - p->line[i].point[0].y),2.0))));
if(p->line[i].point[0].x < p->line[i].point[1].x)
@@ -929,7 +929,7 @@
inside.point[1].x = p->line[i].point[1].x + dx;
inside.point[0].y = p->line[i].point[0].y + dy;
inside.point[1].y = p->line[i].point[1].y + dy;
-
+
outside.point[0].x = p->line[i].point[0].x - dx;
outside.point[1].x = p->line[i].point[1].x - dx;
outside.point[0].y = p->line[i].point[0].y - dy;
@@ -951,7 +951,7 @@
inside.point[j].x = p->line[i].point[j].x + dx;
a.y = p->line[i].point[j-1].y + dy;
inside.point[j].y = p->line[i].point[j].y + dy;
- inside.point[j-1] = generateLineIntersection(inside.point[j-2], inside.point[j-1], a, inside.point[j]);
+ inside.point[j-1] = generateLineIntersection(inside.point[j-2], inside.point[j-1], a, inside.point[j]);
a.x = p->line[i].point[j-1].x - dx;
outside.point[j].x = p->line[i].point[j].x - dx;
@@ -968,7 +968,7 @@
free(inside.point);
free(outside.point);
}
-
+
return;
}
@@ -983,7 +983,7 @@
return (MS_ABS(s/2));
}
-double msGetPolygonArea(shapeObj *p)
+double msGetPolygonArea(shapeObj *p)
{
int i;
double area=0;
@@ -1001,7 +1001,7 @@
/*
** Computes the center of gravity for a polygon based on it's largest outer ring only.
*/
-static int getPolygonCenterOfGravity(shapeObj *p, pointObj *lp)
+static int getPolygonCenterOfGravity(shapeObj *p, pointObj *lp)
{
int i, j;
double area=0;
@@ -1058,7 +1058,7 @@
lp->x = cent_weight_x / total_len;
lp->y = cent_weight_y / total_len;
-
+
return(MS_SUCCESS);
}
@@ -1095,7 +1095,7 @@
lp->y = cp.y;
break;
case 1: /* centroid */
- if(getPolygonCentroid(p, lp, &miny, &maxy) != MS_SUCCESS) return(MS_FAILURE);
+ if(getPolygonCentroid(p, lp, &miny, &maxy) != MS_SUCCESS) return(MS_FAILURE);
break;
case 2: /* center of gravity */
if(getPolygonCenterOfGravity(p, lp) != MS_SUCCESS) return(MS_FAILURE);
@@ -1137,16 +1137,16 @@
y = lp->y;
- /* need to find a y that won't intersect any vertices exactly */
+ /* need to find a y that won't intersect any vertices exactly */
max = y - 1; /* first initializing min, max to be any 2 pnts on either side of y */
min = y + 1;
for(j=0; j<p->numlines; j++) {
if((min < y) && (max >= y)) break;
for(i=0; i < p->line[j].numpoints; i++) {
if((min < y) && (max >= y)) break;
- if(p->line[j].point[i].y < y)
+ if(p->line[j].point[i].y < y)
min = p->line[j].point[i].y;
- if(p->line[j].point[i].y >= y)
+ if(p->line[j].point[i].y >= y)
max = p->line[j].point[i].y;
}
}
@@ -1161,33 +1161,33 @@
}
}
- if(min == max)
+ if(min == max)
return (MS_FAILURE);
- else
- y = (max + min)/2.0;
-
+ else
+ y = (max + min)/2.0;
+
nfound = 0;
for(j=0; j<p->numlines; j++) { /* for each line */
-
+
point1 = &( p->line[j].point[p->line[j].numpoints-1] );
for(i=0; i < p->line[j].numpoints; i++) {
point2 = &( p->line[j].point[i] );
-
+
if(EDGE_CHECK(point1->y, y, point2->y) == CLIP_MIDDLE) {
-
+
if(point1->y == point2->y)
continue; /* ignore horizontal edges */
- else
+ else
slope = (point2->x - point1->x) / (point2->y - point1->y);
-
+
x = point1->x + (y - point1->y)*slope;
intersect[nfound++] = x;
} /* end checking this edge */
-
+
point1 = point2; /* next edge */
}
} /* finished line */
-
+
/* sort the intersections */
do {
wrong_order = 0;
@@ -1198,7 +1198,7 @@
}
}
} while(wrong_order);
-
+
/* find longest span */
for(i=0; i < nfound; i += 2) {
len = fabs(intersect[i] - intersect[i+1]);
@@ -1211,16 +1211,16 @@
} else { /* center vertically, fix x */
x = lp->x;
- /* need to find a x that won't intersect any vertices exactly */
+ /* need to find a x that won't intersect any vertices exactly */
max = x - 1; /* first initializing min, max to be any 2 pnts on either side of x */
min = x + 1;
for(j=0; j<p->numlines; j++) {
if((min < x) && (max >= x)) break;
for(i=0; i < p->line[j].numpoints; i++) {
if((min < x) && (max >= x)) break;
- if(p->line[j].point[i].x < x)
+ if(p->line[j].point[i].x < x)
min = p->line[j].point[i].x;
- if(p->line[j].point[i].x >= x)
+ if(p->line[j].point[i].x >= x)
max = p->line[j].point[i].x;
}
}
@@ -1235,20 +1235,20 @@
}
}
- if(min == max)
+ if(min == max)
return (MS_FAILURE);
- else
+ else
x = (max + min)/2.0;
-
+
nfound = 0;
for(j=0; j<p->numlines; j++) { /* for each line */
-
+
point1 = &( p->line[j].point[p->line[j].numpoints-1] );
for(i=0; i < p->line[j].numpoints; i++) {
point2 = &( p->line[j].point[i] );
-
+
if(EDGE_CHECK(point1->x, x, point2->x) == CLIP_MIDDLE) {
-
+
if(point1->x == point2->x)
continue; /* ignore vertical edges */
else if(point1->y == point2->y)
@@ -1260,11 +1260,11 @@
intersect[nfound++] = y;
} /* end checking this edge */
-
+
point1 = point2; /* next edge */
}
} /* finished line */
-
+
/* sort the intersections */
do {
wrong_order = 0;
@@ -1275,11 +1275,11 @@
}
}
} while(wrong_order);
-
+
/* find longest span */
for(i=0; i < nfound; i += 2) {
len = fabs(intersect[i] - intersect[i+1]);
- if(len > max_len) {
+ if(len > max_len) {
max_len = len;
lp->y = (intersect[i] + intersect[i+1])/2;
// lp->x = x;
@@ -1306,7 +1306,7 @@
int segment_index, line_index, temp_segment_index;
int i, j;
double theta;
-
+
temp_segment_index = segment_index = line_index = 0;
total_length = 0;
@@ -1347,19 +1347,19 @@
lp->x = (p->line[i].point[j].x + p->line[i].point[j-1].x)/2.0;
lp->y = (p->line[i].point[j].y + p->line[i].point[j-1].y)/2.0;
-
+
theta = asin(MS_ABS(p->line[i].point[j].x - p->line[i].point[j-1].x)/sqrt((pow((p->line[i].point[j].x - p->line[i].point[j-1].x),2.0) + pow((p->line[i].point[j].y - p->line[i].point[j-1].y),2.0))));
if(p->line[i].point[j-1].x < p->line[i].point[j].x) { /* i.e. to the left */
if(p->line[i].point[j-1].y < p->line[i].point[j].y) /* i.e. below */
*angle = -(90.0 - MS_RAD_TO_DEG*theta);
else
- *angle = (90.0 - MS_RAD_TO_DEG*theta);
+ *angle = (90.0 - MS_RAD_TO_DEG*theta);
} else {
if(p->line[i].point[j-1].y < p->line[i].point[j].y) /* i.e. below */
*angle = (90.0 - MS_RAD_TO_DEG*theta);
else
- *angle = -(90.0 - MS_RAD_TO_DEG*theta);
+ *angle = -(90.0 - MS_RAD_TO_DEG*theta);
}
return(MS_SUCCESS);
@@ -1379,7 +1379,7 @@
int segment_index, line_index;
int numchars;
-
+
int i,j,k, inc, final_j;
double direction;
rectObj bbox;
@@ -1387,7 +1387,7 @@
double *offsets;
double size, t;
double cx, cy; /* centre of a character, x & y values. */
-
+
double theta;
double dx, dy, w, cos_t, sin_t;
@@ -1404,7 +1404,7 @@
offsets = NULL;
- /* assume success */
+ /* assume success */
*status = MS_SUCCESS;
#ifndef GD_HAS_FTEX_XSHOW
@@ -1412,30 +1412,30 @@
#else
numchars = msGetNumGlyphs(string);
-
+
/* skip the label and use the normal algorithm if it has fewer than 2 characters */
if(numchars < 2)
goto FAILURE;
segment_index = line_index = 0;
total_length = max_line_length = 0.0;
-
+
/* determine longest line segment */
segment_lengths = (double **) malloc(sizeof(double *) * p->numlines);
for(i=0; i<p->numlines; i++) {
-
- segment_lengths[i] = (double*) malloc(sizeof(double) * p->line[i].numpoints);
+
+ segment_lengths[i] = (double*) malloc(sizeof(double) * p->line[i].numpoints);
line_length = 0;
-
+
for (j=1; j<p->line[i].numpoints; j++) {
segment_length = sqrt( pow((p->line[i].point[j].x - p->line[i].point[j-1].x), 2.0) +
pow((p->line[i].point[j].y - p->line[i].point[j-1].y), 2.0) );
line_length += segment_length;
- segment_lengths[i][j-1] = segment_length;
+ segment_lengths[i][j-1] = segment_length;
}
total_length += line_length;
-
+
if(line_length > max_line_length) {
line_index = i;
max_line_length = line_length;
@@ -1443,7 +1443,7 @@
}
i = line_index;
-
+
if (((min_length != -1) && (total_length < min_length))) { /* too short */
*status = MS_FAILURE;
goto FAILURE;
@@ -1456,7 +1456,7 @@
if(p->line[i].numpoints == 2) /* use the regular angled text algorithm */
goto FAILURE;
-
+
/* determine the total length of the text */
if (msGetLabelSize(img,string, label, &bbox, fontset, scalefactor, MS_FALSE, &offsets) == MS_FAILURE) {
*status = MS_FAILURE;
@@ -1469,19 +1469,19 @@
font = msLookupHashTable(&(fontset->fonts), label->font);
if(!font) {
- if(label->font)
+ if(label->font)
msSetError(MS_TTFERR, "Requested font (%s) not found.", "msPolylineLabelPath()", label->font);
else
msSetError(MS_TTFERR, "Requested font (NULL) not found.", "msPolylineLabelPath()");
*status = MS_FAILURE;
goto FAILURE;
}
-
+
text_length = letterspacing * (bbox.maxx - bbox.minx);
- /*
+ /*
** if the text length is way longer than the line, skip adding the
- ** label if it isn't forced (long extrapolated labels tend to be ugly)
+ ** label if it isn't forced (long extrapolated labels tend to be ugly)
*/
if ( text_length > 1.5 * max_line_length && label->force == MS_FALSE ) {
*status = MS_FAILURE;
@@ -1495,7 +1495,7 @@
labelpath->angles = (double *) malloc(sizeof(double) * (labelpath->path.numpoints));
msInitShape(&(labelpath->bounds));
- /*
+ /*
** The bounds will have two points for each character plus an endpoint:
** the UL corners of each bbox will be tied together and the LL corners
** will be tied together.
@@ -1507,7 +1507,7 @@
text_start_length = (max_line_length - text_length) / 2.0;
/* the text is longer than the line: extrapolate the first and last segments */
- if(text_start_length < 0.0) {
+ if(text_start_length < 0.0) {
j = 0;
final_j = p->line[i].numpoints - 1;
fwd_line_length = rev_line_length = 0;
@@ -1520,7 +1520,7 @@
j--;
- /* determine the last segment */
+ /* determine the last segment */
rev_line_length = 0;
final_j = p->line[i].numpoints - 1;
while(rev_line_length < text_start_length) {
@@ -1532,8 +1532,8 @@
if(final_j == 0)
final_j = 1;
-
- /* determine if the line is mostly left to right or right to left,
+
+ /* determine if the line is mostly left to right or right to left,
see bug 1620 discussion by Steve Woodbridge */
direction = 0;
k = j;
@@ -1542,7 +1542,7 @@
k++;
}
- if(direction > 0) {
+ if(direction > 0) {
inc = 1; /* j is already correct */
/* length of the segment containing the starting point */
@@ -1556,22 +1556,22 @@
/* length of the segment containing the starting point */
segment_length = segment_lengths[i][j-1];
- t = 1 - (rev_line_length - text_start_length) / segment_length;
+ t = 1 - (rev_line_length - text_start_length) / segment_length;
}
-
+
distance_along_segment = t * segment_length; /* starting point */
-
+
theta = 0;
k = 0;
w = 0;
while ( k < labelpath->path.numpoints ) {
int m;
double x,y;
-
+
x = t * (p->line[i].point[j+inc].x - p->line[i].point[j].x) + p->line[i].point[j].x;
y = t * (p->line[i].point[j+inc].y - p->line[i].point[j].y) + p->line[i].point[j].y;
- /*
+ /*
** This used to be a series of if-then-else's, but that fails for short (length < 4)
** labels. There may be small speed-ups possible here. (bug 1921)
**
@@ -1580,68 +1580,68 @@
if ( k == 0) {
labelpath->path.point[k].x += (kernel[0] + kernel[1]) * x;
labelpath->path.point[k].y += (kernel[0] + kernel[1]) * y;
- }
+ }
if ( k == 1) {
labelpath->path.point[k].x += kernel[0] * x;
labelpath->path.point[k].y += kernel[0] * y;
- }
+ }
if ( k == labelpath->path.numpoints - 2) {
labelpath->path.point[k].x += kernel[4] * x;
- labelpath->path.point[k].y += kernel[4] * y;
- }
+ labelpath->path.point[k].y += kernel[4] * y;
+ }
if ( k == labelpath->path.numpoints - 1) {
labelpath->path.point[k].x += (kernel[3] + kernel[4]) * x;
labelpath->path.point[k].y += (kernel[3] + kernel[4]) * y;
}
-
+
for(m = 0; m < kernel_size; m++) {
if(m + k - 2 < 0 || m + k - 2 > labelpath->path.numpoints - 1)
continue;
labelpath->path.point[k+m-2].x += kernel[m]*x;
labelpath->path.point[k+m-2].y += kernel[m]*y;
}
-
+
w = letterspacing*offsets[k];
-
+
/* add the character's width to the distance along the line */
distance_along_segment += w;
- /* if we still have segments left and we've past the current segment, move to the next one */
- if(inc == 1 && j < p->line[i].numpoints - 2) {
+ /* if we still have segments left and we've past the current segment, move to the next one */
+ if(inc == 1 && j < p->line[i].numpoints - 2) {
while ( j < p->line[i].numpoints - 2 && distance_along_segment > segment_lengths[i][j] ) {
- distance_along_segment -= segment_lengths[i][j];
+ distance_along_segment -= segment_lengths[i][j];
j += inc; /* move to next segment */
}
segment_length = segment_lengths[i][j];
-
+
} else if( inc == -1 && j > 1 ) {
while ( j > 1 && distance_along_segment > segment_lengths[i][j-1] ) {
distance_along_segment -= segment_lengths[i][j-1];
j += inc; /* move to next segment */
}
-
+
segment_length = segment_lengths[i][j-1];
}
-
+
/* Recalculate interpolation parameter */
t = distance_along_segment / segment_length;
-
+
k++;
}
-
+
/* pre-calc the character's centre y value. Used for rotation adjustment. */
cy = -size / 2.0;
labelpath->path.point[0].x /= kernel_normal;
labelpath->path.point[0].y /= kernel_normal;
-
+
/* Average the points and calculate each angle */
for (k = 1; k <= labelpath->path.numpoints; k++) {
- if ( k < labelpath->path.numpoints ) {
+ if ( k < labelpath->path.numpoints ) {
labelpath->path.point[k].x /= kernel_normal;
labelpath->path.point[k].y /= kernel_normal;
dx = labelpath->path.point[k].x - labelpath->path.point[k-1].x;
@@ -1660,23 +1660,23 @@
*status = MS_FAILURE;
goto FAILURE;
}
-
+
/* msDebug("s: %c (x,y): (%0.2f,%0.2f) t: %0.2f\n", string[k-1], labelpath->path.point[k-1].x, labelpath->path.point[k-1].y, theta); */
labelpath->angles[k-1] = theta;
-
+
/* Move the previous point so that when the character is rotated and
placed it is centred on the line */
cos_t = cos(theta);
sin_t = sin(theta);
-
+
w = letterspacing*offsets[k-1];
cx = 0; /* Center the character vertically only */
dx = - (cx * cos_t + cy * sin_t);
dy = - (cy * cos_t - cx * sin_t);
-
+
labelpath->path.point[k-1].x += dx;
labelpath->path.point[k-1].y += dy;
@@ -1691,7 +1691,7 @@
bbox.maxy += label->buffer;
bbox.minx -= label->buffer;
bbox.miny -= label->buffer;
-
+
if ( k < labelpath->path.numpoints ) {
/* Transform the bbox too. We take the UL and LL corners and rotate
then translate them. */
@@ -1703,12 +1703,12 @@
bounds.point[bounds.numpoints - k - 1].y = (bbox.miny * cos_t - bbox.minx * sin_t) + labelpath->path.point[k-1].y;
} else {
-
+
/* This is the last character in the string so we take the UR and LR
corners of the bbox */
bounds.point[k-1].x = (bbox.maxx * cos_t + bbox.maxy * sin_t) + labelpath->path.point[k-1].x;
bounds.point[k-1].y = (bbox.maxy * cos_t - bbox.maxx * sin_t) + labelpath->path.point[k-1].y;
-
+
bounds.point[bounds.numpoints - k - 1].x = (bbox.maxx * cos_t + bbox.miny * sin_t) + labelpath->path.point[k-1].x;
bounds.point[bounds.numpoints - k - 1].y = (bbox.miny * cos_t - bbox.maxx * sin_t) + labelpath->path.point[k-1].y;
}
@@ -1718,13 +1718,13 @@
/* Close the bounds */
bounds.point[bounds.numpoints - 1].x = bounds.point[0].x;
bounds.point[bounds.numpoints - 1].y = bounds.point[0].y;
-
+
/* Convert the bounds to a shape and store them in the labelpath */
if ( msAddLineDirectly(&(labelpath->bounds), &bounds) == MS_FAILURE ) {
*status = MS_FAILURE;
goto FAILURE;
}
-
+
msComputeBounds(&(labelpath->bounds));
if ( segment_lengths ) {
@@ -1732,9 +1732,9 @@
free(segment_lengths[i]);
free(segment_lengths);
}
-
+
free(offsets);
-
+
return labelpath;
#endif
@@ -1744,15 +1744,15 @@
free(segment_lengths[i]);
free(segment_lengths);
}
-
+
if ( offsets )
free(offsets);
-
+
if ( labelpath ) {
msFreeLabelPathObj(labelpath);
labelpath = NULL;
}
-
+
return NULL;
}
@@ -1760,12 +1760,12 @@
Pretty printing of primitive objects
======================================================================== */
-void msRectToFormattedString(rectObj *rect, char *format, char *buffer, int buffer_length)
+void msRectToFormattedString(rectObj *rect, char *format, char *buffer, int buffer_length)
{
snprintf(buffer, buffer_length, format, rect->minx, rect->miny, rect->maxx, rect->maxy);
}
-void msPointToFormattedString(pointObj *point, const char *format, char *buffer, int buffer_length)
+void msPointToFormattedString(pointObj *point, const char *format, char *buffer, int buffer_length)
{
#ifdef USE_POINT_Z_M
snprintf(buffer, buffer_length, format, point->x, point->y, point->z, point->m);
Modified: sandbox/graphics/mapprimitive.h
===================================================================
--- sandbox/graphics/mapprimitive.h 2009-03-14 09:09:55 UTC (rev 8795)
+++ sandbox/graphics/mapprimitive.h 2009-03-14 09:20:19 UTC (rev 8796)
@@ -15,7 +15,7 @@
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
- * The above copyright notice and this permission notice shall be included in
+ * The above copyright notice and this permission notice shall be included in
* all copies of this Software or works derived from this Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
@@ -46,8 +46,8 @@
double x;
double y;
#ifdef USE_POINT_Z_M
- double z;
- double m;
+ double z;
+ double m;
#endif
} pointObj;
@@ -86,7 +86,7 @@
int tileindex;
int classindex;
char *text;
-
+
} shapeObj;
typedef lineObj multipointObj;
@@ -105,7 +105,7 @@
#ifndef SWIG
typedef struct {
int need_geotransform;
- double rotation_angle;
+ double rotation_angle;
double geotransform[6]; /* Pixel/line to georef. */
double invgeotransform[6]; /* georef to pixel/line */
} geotransformObj;
More information about the mapserver-commits
mailing list