PCT gpx update
This commit is contained in:
5
files/db/update_v19_to_v20.sql
Normal file
5
files/db/update_v19_to_v20.sql
Normal 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
52275
geo/pct.gpx
File diff suppressed because it is too large
Load Diff
@@ -288,14 +288,14 @@ class GeoJson extends Geo {
|
||||
$fLengthOB = sqrt(pow($asPointO['lon'] - $asPointB['lon'], 2) + pow($asPointO['lat'] - $asPointB['lat'], 2));
|
||||
|
||||
$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
|
||||
//Law of Cosines: angle = arccos((OB² + AO² - AB²) / (2*OB*AO))
|
||||
$fLengthAB = sqrt(pow($asPointB['ele'] - $asPointA['ele'], 2) + pow($fLengthOA + $fLengthOB, 2));
|
||||
$fLengthAO = sqrt(pow($asPointO['ele'] - $asPointA['ele'], 2) + pow($fLengthOA, 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 ||
|
||||
$fAngleAOBElev <= (1 - self::MAX_DEVIATION_ELEV) * M_PI || $fAngleAOBElev >= (1 + self::MAX_DEVIATION_ELEV) * M_PI);
|
||||
|
||||
10
inc/Feed.php
10
inc/Feed.php
@@ -39,6 +39,10 @@ class Feed extends PhpObject {
|
||||
const FEED_TABLE = 'feeds';
|
||||
const MSG_TABLE = 'messages';
|
||||
|
||||
//Hide/Display values
|
||||
const MSG_HIDDEN = 0;
|
||||
const MSG_DISPLAYED = 1;
|
||||
|
||||
/**
|
||||
* Database Handle
|
||||
* @var Db
|
||||
@@ -111,6 +115,7 @@ class Feed extends PhpObject {
|
||||
}
|
||||
|
||||
public function getMessages($asConstraints=array()) {
|
||||
$sFeedIdCol = Db::getId(self::FEED_TABLE, true);
|
||||
$asInfo = array(
|
||||
'select' => array(
|
||||
Db::getId(self::MSG_TABLE), 'ref_msg_id', 'type', //ID
|
||||
@@ -120,8 +125,8 @@ class Feed extends PhpObject {
|
||||
),
|
||||
'from' => self::MSG_TABLE,
|
||||
'join' => array(self::FEED_TABLE => Db::getId(self::FEED_TABLE)),
|
||||
'constraint'=> array(Db::getId(self::FEED_TABLE, true) => $this->getFeedId()),
|
||||
'constOpe' => array(Db::getId(self::FEED_TABLE, true) => "="),
|
||||
'constraint'=> array($sFeedIdCol => $this->getFeedId(), 'display' => self::MSG_DISPLAYED),
|
||||
'constOpe' => array($sFeedIdCol => "=", 'display' => "="),
|
||||
'orderBy' => array('site_time'=>'ASC')
|
||||
);
|
||||
if(!empty($asConstraints)) $asInfo = array_merge($asInfo, $asConstraints);
|
||||
@@ -144,7 +149,6 @@ class Feed extends PhpObject {
|
||||
}
|
||||
|
||||
public function getLastMessageId($asConstraints=array()) {
|
||||
|
||||
$asMessages = $this->getMessages($asConstraints);
|
||||
return end($asMessages)[Db::getId(self::MSG_TABLE)] ?? 0;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ class Spot extends Main
|
||||
(
|
||||
'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::SPOT_TABLE => array('ref_spot_id', 'name', 'model'),
|
||||
Project::PROJ_TABLE => array('name', 'codename', 'active_from', 'active_to'),
|
||||
@@ -134,7 +134,8 @@ class Spot extends Main
|
||||
'weather_temp' => "DECIMAL(3,1)",
|
||||
'tile_size' => "SMALLINT UNSIGNED DEFAULT 256",
|
||||
'width' => "INT",
|
||||
'height' => "INT"
|
||||
'height' => "INT",
|
||||
'display' => "BOOLEAN DEFAULT ".Feed::MSG_DISPLAYED
|
||||
),
|
||||
'constraints' => array
|
||||
(
|
||||
@@ -456,7 +457,9 @@ class Spot extends Main
|
||||
case Feed::MSG_TABLE:
|
||||
$asConsArray['constraint'][$sTimeField] = $asActPeriod;
|
||||
$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;
|
||||
case Media::MEDIA_TABLE:
|
||||
$asConsArray['constraint'][$sTimeField] = $asActPeriod['to'];
|
||||
|
||||
Reference in New Issue
Block a user