PCT gpx update

This commit is contained in:
2022-09-14 15:04:58 +02:00
parent c4d9db0032
commit 9055fc02f3
5 changed files with 43759 additions and 8544 deletions

View File

@@ -0,0 +1,5 @@
ALTER TABLE messages MODIFY ref_msg_id VARCHAR(15) NOT NULL;
ALTER TABLE messages ADD display BOOLEAN DEFAULT 1 AFTER weather_temp;
UPDATE messages SET display = 0 WHERE id_message = 197;
UPDATE messages SET display = 0 WHERE id_message = 216;

52275
geo/pct.gpx

File diff suppressed because it is too large Load Diff

View File

@@ -288,14 +288,14 @@ class GeoJson extends Geo {
$fLengthOB = sqrt(pow($asPointO['lon'] - $asPointB['lon'], 2) + pow($asPointO['lat'] - $asPointB['lat'], 2)); $fLengthOB = sqrt(pow($asPointO['lon'] - $asPointB['lon'], 2) + pow($asPointO['lat'] - $asPointB['lat'], 2));
$fVectorOAxOB = $fVectorOA['lon'] * $fVectorOB['lon'] + $fVectorOA['lat'] * $fVectorOB['lat']; $fVectorOAxOB = $fVectorOA['lon'] * $fVectorOB['lon'] + $fVectorOA['lat'] * $fVectorOB['lat'];
$fAngleAOB = acos($fVectorOAxOB/($fLengthOA * $fLengthOB)); $fAngleAOB = ($fLengthOA != 0 && $fLengthOB != 0) ? acos($fVectorOAxOB/($fLengthOA * $fLengthOB)) : 0;
//Elevation Check //Elevation Check
//Law of Cosines: angle = arccos((OB² + AO² - AB²) / (2*OB*AO)) //Law of Cosines: angle = arccos((OB² + AO² - AB²) / (2*OB*AO))
$fLengthAB = sqrt(pow($asPointB['ele'] - $asPointA['ele'], 2) + pow($fLengthOA + $fLengthOB, 2)); $fLengthAB = sqrt(pow($asPointB['ele'] - $asPointA['ele'], 2) + pow($fLengthOA + $fLengthOB, 2));
$fLengthAO = sqrt(pow($asPointO['ele'] - $asPointA['ele'], 2) + pow($fLengthOA, 2)); $fLengthAO = sqrt(pow($asPointO['ele'] - $asPointA['ele'], 2) + pow($fLengthOA, 2));
$fLengthOB = sqrt(pow($asPointB['ele'] - $asPointO['ele'], 2) + pow($fLengthOB, 2)); $fLengthOB = sqrt(pow($asPointB['ele'] - $asPointO['ele'], 2) + pow($fLengthOB, 2));
$fAngleAOBElev = acos((pow($fLengthOB, 2) + pow($fLengthAO, 2) - pow($fLengthAB, 2)) / (2 * $fLengthOB * $fLengthAO)); $fAngleAOBElev = ($fLengthOB != 0 && $fLengthAO != 0) ? (acos((pow($fLengthOB, 2) + pow($fLengthAO, 2) - pow($fLengthAB, 2)) / (2 * $fLengthOB * $fLengthAO))) : 0;
return ($fAngleAOB <= (1 - self::MAX_DEVIATION_FLAT) * M_PI || $fAngleAOB >= (1 + self::MAX_DEVIATION_FLAT) * M_PI || return ($fAngleAOB <= (1 - self::MAX_DEVIATION_FLAT) * M_PI || $fAngleAOB >= (1 + self::MAX_DEVIATION_FLAT) * M_PI ||
$fAngleAOBElev <= (1 - self::MAX_DEVIATION_ELEV) * M_PI || $fAngleAOBElev >= (1 + self::MAX_DEVIATION_ELEV) * M_PI); $fAngleAOBElev <= (1 - self::MAX_DEVIATION_ELEV) * M_PI || $fAngleAOBElev >= (1 + self::MAX_DEVIATION_ELEV) * M_PI);

View File

@@ -39,6 +39,10 @@ class Feed extends PhpObject {
const FEED_TABLE = 'feeds'; const FEED_TABLE = 'feeds';
const MSG_TABLE = 'messages'; const MSG_TABLE = 'messages';
//Hide/Display values
const MSG_HIDDEN = 0;
const MSG_DISPLAYED = 1;
/** /**
* Database Handle * Database Handle
* @var Db * @var Db
@@ -111,6 +115,7 @@ class Feed extends PhpObject {
} }
public function getMessages($asConstraints=array()) { public function getMessages($asConstraints=array()) {
$sFeedIdCol = Db::getId(self::FEED_TABLE, true);
$asInfo = array( $asInfo = array(
'select' => array( 'select' => array(
Db::getId(self::MSG_TABLE), 'ref_msg_id', 'type', //ID Db::getId(self::MSG_TABLE), 'ref_msg_id', 'type', //ID
@@ -120,8 +125,8 @@ class Feed extends PhpObject {
), ),
'from' => self::MSG_TABLE, 'from' => self::MSG_TABLE,
'join' => array(self::FEED_TABLE => Db::getId(self::FEED_TABLE)), 'join' => array(self::FEED_TABLE => Db::getId(self::FEED_TABLE)),
'constraint'=> array(Db::getId(self::FEED_TABLE, true) => $this->getFeedId()), 'constraint'=> array($sFeedIdCol => $this->getFeedId(), 'display' => self::MSG_DISPLAYED),
'constOpe' => array(Db::getId(self::FEED_TABLE, true) => "="), 'constOpe' => array($sFeedIdCol => "=", 'display' => "="),
'orderBy' => array('site_time'=>'ASC') 'orderBy' => array('site_time'=>'ASC')
); );
if(!empty($asConstraints)) $asInfo = array_merge($asInfo, $asConstraints); if(!empty($asConstraints)) $asInfo = array_merge($asInfo, $asConstraints);
@@ -144,7 +149,6 @@ class Feed extends PhpObject {
} }
public function getLastMessageId($asConstraints=array()) { public function getLastMessageId($asConstraints=array()) {
$asMessages = $this->getMessages($asConstraints); $asMessages = $this->getMessages($asConstraints);
return end($asMessages)[Db::getId(self::MSG_TABLE)] ?? 0; return end($asMessages)[Db::getId(self::MSG_TABLE)] ?? 0;
} }

View File

@@ -82,7 +82,7 @@ class Spot extends Main
( (
'tables' => array 'tables' => array
( (
Feed::MSG_TABLE => array('ref_msg_id', Db::getId(Feed::FEED_TABLE), 'type', 'latitude', 'longitude', 'iso_time', 'site_time', 'timezone', 'unix_time', 'content', 'battery_state', 'posted_on', 'weather_icon', 'weather_cond', 'weather_temp'), Feed::MSG_TABLE => array('ref_msg_id', Db::getId(Feed::FEED_TABLE), 'type', 'latitude', 'longitude', 'iso_time', 'site_time', 'timezone', 'unix_time', 'content', 'battery_state', 'posted_on', 'weather_icon', 'weather_cond', 'weather_temp', 'display'),
Feed::FEED_TABLE => array('ref_feed_id', Db::getId(Feed::SPOT_TABLE), Db::getId(Project::PROJ_TABLE), 'name', 'description', 'status', 'last_update'), Feed::FEED_TABLE => array('ref_feed_id', Db::getId(Feed::SPOT_TABLE), Db::getId(Project::PROJ_TABLE), 'name', 'description', 'status', 'last_update'),
Feed::SPOT_TABLE => array('ref_spot_id', 'name', 'model'), Feed::SPOT_TABLE => array('ref_spot_id', 'name', 'model'),
Project::PROJ_TABLE => array('name', 'codename', 'active_from', 'active_to'), Project::PROJ_TABLE => array('name', 'codename', 'active_from', 'active_to'),
@@ -134,7 +134,8 @@ class Spot extends Main
'weather_temp' => "DECIMAL(3,1)", 'weather_temp' => "DECIMAL(3,1)",
'tile_size' => "SMALLINT UNSIGNED DEFAULT 256", 'tile_size' => "SMALLINT UNSIGNED DEFAULT 256",
'width' => "INT", 'width' => "INT",
'height' => "INT" 'height' => "INT",
'display' => "BOOLEAN DEFAULT ".Feed::MSG_DISPLAYED
), ),
'constraints' => array 'constraints' => array
( (
@@ -456,7 +457,9 @@ class Spot extends Main
case Feed::MSG_TABLE: case Feed::MSG_TABLE:
$asConsArray['constraint'][$sTimeField] = $asActPeriod; $asConsArray['constraint'][$sTimeField] = $asActPeriod;
$asConsArray['constOpe'][$sTimeField] = "BETWEEN"; $asConsArray['constOpe'][$sTimeField] = "BETWEEN";
$sConsSql .= " AND ".$sTimeField." BETWEEN '".$asActPeriod['from']."' AND '".$asActPeriod['to']."'"; $asConsArray['constraint']['display'] = Feed::MSG_DISPLAYED;
$asConsArray['constOpe']['display'] = "=";
$sConsSql .= " AND ".$sTimeField." BETWEEN '".$asActPeriod['from']."' AND '".$asActPeriod['to']."' AND display = ".Feed::MSG_DISPLAYED;
break; break;
case Media::MEDIA_TABLE: case Media::MEDIA_TABLE:
$asConsArray['constraint'][$sTimeField] = $asActPeriod['to']; $asConsArray['constraint'][$sTimeField] = $asActPeriod['to'];