[Mapserver-dev] Label centroid alog

Steve Lime steve.lime at dnr.state.mn.us
Tue May 13 14:08:39 EDT 2003


I'll look at the bug and the patch and apply if all looks good.

>>> Vincent Schut <schut at sarvision.com> 05/13/03 05:47AM >>>
Hello dear developers,

you might have noticed my label problem posted on the users list 
(http://mapserver.gis.umn.edu/data2/wilma/mapserver-users/0305/msg00016.html).
I just tried this patch and it solves my problem. Thought I'd just let
you 
know that... 
Could (or is this already?) this be applied to cvs? To me it really is
a 
bug-fix :-) Thanks!

Regards,
Vincent Schut.

On Monday 05 May 2003 23:06, John Newton wrote:
> The labeling centroid algorithm has sometime given me incorrect
results and
> I believe I see the reason why.  The point1 and point2 pointers can
> sometimes point to the same object, thereby rendering incorrect
length
> calculations (namely zero length).
>
> Here is my suggested change to the code.  Basically I remove the use
of
> point1 and point2 for determining length and max_len, and get the
length
> using the diff in x, not length(), since the y values are equal.
>
> -john
>
>
> --- \mapserver\mapserver-3.7-dev\mapprimitive.c 2003-02-26
> 12:18:22.000000000 -0800
> +++ mapprimitive.c      2003-05-05 13:41:44.000000000 -0700
> @@ -950,16 +923,13 @@
>         }
>        }
>      } while(wrong_order);
> -
> +
>      /* Great, now find longest span */
> -    point1->y = point2->y = y;
> -    for(i=0; i < nfound; i += 2) {
> -      point1->x = xintersect[i];
> -      point2->x = xintersect[i+1];
> -      len = length(*point1, *point2);
> +    for(i=0; i < nfound; i +=2) {
> +      len = fabs(xintersect[i] - xintersect[i+1]);
>        if(len > max_len) {
>         max_len = len;
> -       lp->x = (point1->x + point2->x)/2;
> +       lp->x = (xintersect[i] + xintersect[i+1])/2;
>         lp->y = y;
>        }
>      }
> _______________________________________________
> Mapserver-dev mailing list
> Mapserver-dev at lists.gis.umn.edu 
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-dev 

-- 
______________________________________
Vincent Schut
Sarvision B.V.
Wageningen, The Netherlands
www.sarvision.com 
_______________________________________________
Mapserver-dev mailing list
Mapserver-dev at lists.gis.umn.edu 
http://lists.gis.umn.edu/mailman/listinfo/mapserver-dev



More information about the mapserver-dev mailing list