Skip to content

Commit

Permalink
add raw tweets in datacollection page
Browse files Browse the repository at this point in the history
  • Loading branch information
hyang authored and hyang committed Aug 23, 2013
1 parent 4ebf36b commit 481610b
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
56 changes: 56 additions & 0 deletions public_html/assets/php/geo_mongo2json.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
// Config
$dbhost = 'localhost';
$dbname = 'data';
$task_id = 2;
// Connect to test database
$m = new Mongo("mongodb://$dbhost");
$db = $m->$dbname;

// select a collection (analogous to a relational database's table)
$collection = $db->libya;

//count the number of items in this collection
echo '<h3>The entire collection has ', $collection->count(), ' tweets';

// condition $query
$nullgeolat = "0.00000";

$query = array("geo_lat" => array('$ne' => $nullgeolat));

$cursor = $collection->find($query)->limit(1000);

//count the number of items in this query
echo '; This query returns ', $cursor->count(), ' geo-tagged tweets</h3>';

echo '<center><h4>The 1000 samples are as follows</h3></center><hr>';

echo '<table cellpadding="0" cellspacing="0" class="db-table">';
echo '<tr>
<th>Index</th>
<th>Lat </th>
<th>Long </th>
<th>Tweet </th>
</tr>';

// iterate geo info with tweets
$index = 1;

foreach ($cursor as $document) {
echo '<tr>';
echo '<td>',$index,'</td>';
$index++;
echo '<td>',$document["geo_lat"],'</td>';
echo '<td>',$document["geo_long"],'</td>';
echo '<td>',$document["tweet_text"],'</td>';
echo '<tr>';

// echo $document["tweet_id"],' ',$document["tweet_text"],' ',$document["geo_lat"],'',$document["geo_long"];

}

?>


</body>
</html>
4 changes: 3 additions & 1 deletion public_html/datacollection.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
<!-- Jumbotron -->
<div class="row-fluid">


<iframe src="//localhost/MinervaApp/public_html/assets/php/geo_mongo2json.php" width="1200" height="680" frameborder="0">

</iframe>

</div>

Expand Down

0 comments on commit 481610b

Please sign in to comment.