require_once 'Predict/Time.php'; // Set to true to profile $profile = true; // Example check at the top of your application for enabling profiling if ($profile && extension_loaded('xhprof')) { $xproflib = './xhprof_lib'; include_once $xproflib . '/utils/xhprof_lib.php'; include_once $xproflib . '/utils/xhprof_runs.php'; xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY); function stop_xhprof_profiling() { $xhprofData = xhprof_disable(); $xhprofNameSpace = 'predict'; $xhprofRuns = new XHProfRuns_Default(); $xhprofRunID = $xhprofRuns->save_run($xhprofData, $xhprofNameSpace); } register_shutdown_function('stop_xhprof_profiling'); } $start = microtime(true); $predict = new Predict(); $qth = new Predict_QTH(); $qth->lat = 37.655; $qth->lon = -122.407; $qth->alt = 0; $tleFile = file('examples/iss.tle'); $tle = new Predict_TLE($tleFile[0], $tleFile[1], $tleFile[2]); $sat = new Predict_Sat($tle); $now = Predict_Time::get_current_daynum(); $results = $predict->get_passes($sat, $qth, $now, 10); echo "Execution time: " . number_format((microtime(true) - $start) * 1000, 2) . "ms\n"; exit;
* passes of the International Space Station. Please read the inline comments * for details. * * Run this from the root checkout, not from examples, or the include paths * will not work. */ date_default_timezone_set('America/Los_Angeles'); require_once 'Predict.php'; require_once 'Predict/Sat.php'; require_once 'Predict/QTH.php'; require_once 'Predict/Time.php'; require_once 'Predict/TLE.php'; // Track execution time of this script $start = microtime(true); // The observer or groundstation is called QTH in ham radio terms $predict = new Predict(); $qth = new Predict_QTH(); $qth->alt = 0; // Altitude in meters // South San Francisco, example west of the meridian $qth->lat = 37.655; // Latitude North $qth->lon = -122.407; // Longitude East // Munich, example east of the meridian // $qth->lat = 48.1505; // Lat North // $qth->lon = 11.5809; // Lon East // The iss.tle file is the first 3 lines of // http://celestrak.com/NORAD/elements/stations.txt // Make sure you update this content, it goes out of date within a day or two $tleFile = file('examples/iss.tle');
<?php set_include_path('backbone:components:content:scripts:styles:images:model:render'); require_once('Page.php'); require_once('Template.php'); require_once('Predict.php'); require_once('Item.php'); $page = new Page(0, "OrderUp - Prediction_test"); $tmpl = new Template(); $page->run(); $suggested_item_objects = array(); $suggested_items = isset($_GET['item']) ? Predict::similar(Item::getByName($_GET['item'])) : -1; $tmpl->suggested_items = $suggested_items; if($suggested_items != -1) { foreach($suggested_items as $si) { array_push($suggested_item_objects, array(Item::getByID(intval($si['itemid'])), $si['similarity'])); } } $tmpl->suggested_item_objects = $suggested_item_objects; $html = $tmpl->build('prediction_test.html'); $css = $tmpl->build('reporting.css'); $js = $tmpl->build('prediction_test.js'); $appContent = array( 'html' => $html,
public function recommend($item) { if( !($item instanceof Item) ) { if( is_integer($item) ) { $item = Item::getByID($item); } else { return false; } } //get similarity array for the item $similar = Predict::similar($item); if( $similar ) { foreach( $similar as $arr ) { $id = $arr['itemid']; $similarity = $arr['similarity']; $arr['recommendation'] = $similarity + Predict::compare($item, $id); } } if( usort($similar, array(Predict, 'sortSimilarities')) ) { return $similar; } else { return false; } }