zoneminder/web/includes/Zone.php

67 lines
1.9 KiB
PHP
Raw Normal View History

2020-05-01 17:20:42 +00:00
<?php
namespace ZM;
require_once('database.php');
require_once('Object.php');
2024-01-28 21:52:16 +00:00
require_once('Monitor.php');
2020-05-01 17:20:42 +00:00
class Zone extends ZM_Object {
protected static $table = 'Zones';
protected $defaults = array(
'Id' => null,
'MonitorId' => null,
'Name' => '',
'Type' => 'Active',
'Units' => 'Pixels',
'NumCoords' => '4',
'Coords' => '',
'Area' => '0',
'AlarmRGB' => 0xff0000,
'CheckMethod' => 'Blobs',
'MinPixelThreshold' => 25,
'MaxPixelThreshold' => null,
'MinAlarmPixels' => null,
'MaxAlarmPixels' => null,
'FilterX' => 3,
'FilterY' => 3,
'MinFilterPixels' => null,
'MaxFilterPixels' => null,
'MinBlobPixels' => null,
'MaxBlobPixels' => null,
'MinBlobs' => 1,
'MaxBlobs' => null,
'OverloadFrames' => 0,
'ExtendAlarmFrames' => 0,
2020-05-01 17:20:42 +00:00
);
public static function find( $parameters = array(), $options = array() ) {
return ZM_Object::_find(self::class, $parameters, $options);
2020-05-01 17:20:42 +00:00
}
public static function find_one( $parameters = array(), $options = array() ) {
return ZM_Object::_find_one(self::class, $parameters, $options);
2020-05-01 17:20:42 +00:00
}
2024-01-28 21:52:16 +00:00
public function Monitor() {
2024-01-28 21:52:16 +00:00
if (isset($this->{'MonitorId'})) {
$Monitor = Monitor::find_one(array('Id'=>$this->{'MonitorId'}));
if ( $Monitor )
return $Monitor;
}
return new Monitor();
}
2020-05-01 17:20:42 +00:00
public function Points() {
return coordsToPoints($this->Coords());
}
public function AreaCoords() {
return preg_replace('/\s+/', ',', $this->Coords());
}
public function svg_polygon() {
2022-08-30 17:36:07 +00:00
return '<polygon points="'.$this->AreaCoords().'" class="'.$this->Type().'" data-mid="'.$this->MonitorId().'" data-zid="'.$this->Id().'"><title>'.$this->Name().'</title></polygon>';
}
2020-05-01 17:20:42 +00:00
} # end class Zone
?>