Skip to content

Commit

Permalink
Added a more realistic example of using the Chicago Open Data portal;…
Browse files Browse the repository at this point in the history
… get data on neighborhood boundaries and printout the coordinates of one such neighborhood (Albany Park)
  • Loading branch information
pdweinstein committed Sep 25, 2011
1 parent cfefcf2 commit 13d3a80
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
2 changes: 1 addition & 1 deletion class.windy.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* @package windy-php
* @author Paul Weinstein, <pdw@weinstein.org>
* @version 0.5
* @version 0.75
* @copyright Copyright (c) 2011 Paul Weinstein, <pdw@weinstein.org>
* @license MIT License, <https://github.com/pdweinstein/PHP-Wrapper-for-CTA-APIs/blob/master/LICENSE>
*
Expand Down
39 changes: 35 additions & 4 deletions example.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,44 @@
// Create an object to get city data
$chicago = new windy( 'city' );

// Create an object to get county data
$cook = new windy( 'county' );
// Let's find any views that describe themselves as about Chicago's neighborhood boundaries and are tagged with KML data
$views = $chicago->getViews( '', '', 'neighborhood boundaries', 'kml', '', 'false', '', '' );

echo "Here are the views with a description including 'neighborhood boundaries' and are tagged as KML:\n";
foreach ( $views as $view ) {

echo "View ID: ".$view->id. " is named " .$view->name. " and is described as a " .$view->description. "\n\n";

// With a little foreknowledge View ID buma-fjbv looks interesting, let's get that file
if ( $view->id == 'buma-fjbv' ) {

$file = $chicago->getFileByViewID( $view->blobId, $view->id );

echo var_dump( $chicago->getViews() );
//echo var_dump( $cook->getViews() );
// Foreknowledge tells us this is an XML file, so let's use SimpleXML to parse this data
// Note: SimpleXML requires the libxml PHP extension
$xml = simplexml_load_string( $file );

// Ok, now let's find out what the boundaries are for Albany Park
foreach ( $xml->Document->Folder->Placemark as $hood ) {

if ( preg_match( '/Albany Park/', $hood->description )) {

echo "Here are Albany Park's boundaries: " .$hood->MultiGeometry->Polygon->outerBoundaryIs->LinearRing->coordinates. "\n";

}

}

}

}

//echo var_dump( $chicago->getDocs() );
//echo var_dump( $chicago->getDocsByID( 'views' ))

// Create an object to get county data
//$cook = new windy( 'county' );

//echo var_dump( $cook->getViews() );

?>

0 comments on commit 13d3a80

Please sign in to comment.