Skip to content

Commit

Permalink
fixes to web interface to work with new geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
robkooper committed Sep 4, 2014
1 parent b82fc69 commit 3c0a9fc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions web/03-inputs.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
}

// get site information
$stmt = $pdo->prepare("SELECT * FROM sites WHERE sites.id=?");
$stmt = $pdo->prepare("SELECT sitename, city, state, country, ST_X(sites.geometry) AS lon, ST_Y(sites.geometry) AS lat FROM sites WHERE sites.id=?");
if (!$stmt->execute(array($siteid))) {
die('Invalid query: ' . error_database());
}
Expand All @@ -91,7 +91,7 @@
$stmt->closeCursor();

// get list of tags
$tags=[];
$tags=array();
foreach($inputs as $input) {
$tags[$input['tag']] = $input['required'];
}
Expand Down
7 changes: 2 additions & 5 deletions web/04-runpecan.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
}
}

print_r($_REQUEST);


# boolean parameters
$userok=isset($_REQUEST['userok']);
$offline=isset($_REQUEST['offline']);
Expand Down Expand Up @@ -91,13 +88,13 @@
}

// get model info
$stmt = $pdo->prepare("SELECT model_type, revision FROM models, modeltypes WHERE models.id=? AND modeltypes.id=models.modeltype_id");
$stmt = $pdo->prepare("SELECT name, revision FROM models, modeltypes WHERE models.id=? AND modeltypes.id=models.modeltype_id");
if (!$stmt->execute(array($modelid))) {
die('Invalid query: ' . (error_database()));
}
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$revision=$row['revision'];
$modeltype=$row['model_type'];
$modeltype=$row['name'];
$stmt->closeCursor();

// create the workflow execution
Expand Down
8 changes: 4 additions & 4 deletions web/sites.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
$stmt->closeCursor();

// 3. Get list of all sites, formats
$stmt = $pdo->prepare("SELECT DISTINCT sites.*, format_id FROM sites, inputs, dbfiles, machines" .
$stmt = $pdo->prepare("SELECT DISTINCT sites.id, sites.sitename, sites.city, sites.country, ST_X(sites.geometry) AS lon, ST_Y(sites.geometry) AS lat, format_id FROM sites, inputs, dbfiles, machines" .
" WHERE sites.id=inputs.site_id AND inputs.id=dbfiles.container_id" .
" AND dbfiles.container_type='Input' and dbfiles.machine_id=machines.id" .
" AND machines.hostname=? GROUP BY sites.id, format_id;");
Expand All @@ -66,13 +66,13 @@
}

// 4. Loop over result, collecting formats used
$sites = [];
$sites = array();
while ($row = @$stmt->fetch(PDO::FETCH_ASSOC)) {
if (in_array($row['format_id'], $formats)) {
if (array_key_exists($row['id'], $sites)) {
$sites[$row['id']]['format_id'][] = $row['format_id'];
} else {
$row['format_id'] = [$row['format_id']];
$row['format_id'] = array($row['format_id']);
$sites[$row['id']] = $row;
}
}
Expand All @@ -96,7 +96,7 @@ function allSites() {
global $pdo;

// Select all the rows in the markers table
$result = $pdo->query("SELECT * FROM sites;");
$result = $pdo->query("SELECT id, sitename, city, country, ST_X(geometry) AS lon, ST_Y(geometry) AS lat FROM sites;");
if (!$result) {
die('Invalid query: ' . error_database());
}
Expand Down

0 comments on commit 3c0a9fc

Please sign in to comment.