jbox area

Richard Greenwood richard.greenwood at GMAIL.COM
Tue Nov 30 06:27:55 PST 2004


On Mon, 29 Nov 2004 10:42:49 -0500, Arnold, Micheal B.
<micheal.arnold at nscorp.com> wrote:
>
>
>
> For some reason, the area that I am getting back for polygons using jbox
> seems to be off.  The segment length and total length seem to be fine, but
> the area is off by a factor of about 5.  Does anybody have any ideas or
> suggestions?  Below are the measure_handler functions I am using.
>
>
>
> Thanks for the help!
>
>
>
> Mike Arnold
>
> micheal.arnold at nscorp.com
>
>
>
> function measure_handler(name, s, t, n, a)
>
> {
>
>                 // c = 1 / 72dpi / 12inches_per_foot *
> 1.0003state_plane_scale_factor
>
>                 var c = 0.0011577546296296;                // constant
>
>                 var f = [scale] * c;                   // scale factor
>
>                 if ((s>0) || (t>0))
>
>                 {
>
>                                 if (n < 3)
>
>                                 {
>
>                                                 defaultStatus = "This
> segment = " + distFormat(s*f) + ", Total = " + distFormat(t*f) + ", Number
> of vertices = " + n ;
>
>                                 }
>
>                                 else
>
>                                 {
>
>                                                 defaultStatus = "This
> segment = " + distFormat(s*f) + ", Total = " + distFormat(t*f) + ", Number
> of vertices = " + n + ", Area = " + distFormat(a*f) ;
>
>                                 }
>
>                 }
>
> }
>
>
>
> function roundFeet(x)
>
> {
>
>                 var fpp = ([maxx] - [minx]) / [mapwidth]; // resolution
> (feet per pixel)
>
>                 if (fpp < 4)  return (Math.round(x));
>
> if (fpp < 8)  return (Math.round(x/5)*5);
>
> if (fpp < 17) return (Math.round(x/10)*10);
>
> if (fpp < 40) return (Math.round(x/25)*25);
>
> if (fpp < 80) return (Math.round(x/50)*50);
>
> return (Math.round(x/100)*100);
>
> }
>
>
>
> function distFormat(x)
>
> {
>
> var d;
>
> if (x > 7920) return ((Math.round(x/5280*10)/10) + " miles");
>
> d = roundFeet(x);
>
> if (d > 2640)
>
> return (d + " ft (" + (Math.round(x/5280*10)/10) + ")mile");
>
> return (d + " ft");
>
> }



jBox returns an area in screen pixels. You must convert it to sq feet,
sq meters, sq miles, or whatever you like. I wrote the above functions
to convert to sq feet and/or acres for a state plane coordinate system
in US Survey Feet. You need to modify them for your coordinate system,
resloution setting (if not 72), and desired output units.

Regards,
--
Richard Greenwood
richard.greenwood at gmail.com
www.greenwoodmap.com



More information about the MapServer-users mailing list