slackbuilds_ponce/system/ZoneMinder/fix_zone_area_calc.patch

36 lines
1.1 KiB
Diff
Raw Normal View History

--- web/skins/classic/views/js/zone.js 2019-01-23 00:24:26.094085919 -0500
+++ web/skins/classic/views/js/zone.js.new 2019-01-23 00:25:13.871710907 -0500
@@ -347,6 +347,7 @@
zone['Points'][index].x = x;
var Point = $('zonePoly').points.getItem(index);
Point.x = x;
+ updateArea();
}
function updateY( index ) {
@@ -359,6 +360,7 @@
zone['Points'][index].y = y;
var Point = $('zonePoly').points.getItem(index);
Point.y = y;
+ updateArea();
}
function saveChanges( element ) {
@@ -697,11 +699,12 @@
var n_coords = coords.length;
var float_area = 0.0;
- for ( i = 0, j = n_coords-1; i < n_coords; j = i++ ) {
- var trap_area = ( ( coords[i].x - coords[j].x ) * ( coords[i].y + coords[j].y ) ) / 2;
- float_area += trap_area;
- //printf( "%.2f (%.2f)\n", float_area, trap_area );
+ for ( i = 0; i < n_coords-1; i++ ) {
+ var trap_area = (coords[i].x*coords[i+1].y - coords[i+1].x*coords[i].y) / 2;
+ float_area += trap_area;
}
+ float_area += (coords[n_coords-1].x*coords[0].y - coords[0].x*coords[n_coords-1].y) / 2;
+
return Math.round( Math.abs( float_area ) );
}