Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

KageNoNeko/osm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

osm

OpenStreetMap API Integration

Basic Usage

Find nodes in Germany bounding box: NE 55.05814, 15.04205 SW 47.27021, 5.86624

$south = 47.27021;
$west = 5.86624;
$north = 55.05814;
$east = 15.04205;

// create bounding box
$bBox = new \KageNoNeko\OSM\BoundingBox($south, $west, $north, $east);

// slice to lesser boxes to reduce memory usage
$slices = $bBox->slices(4, 4);

// create connection to Overpass API source
$osm = new \KageNoNeko\OSM\OverpassConnection(['interpreter' => 'http://overpass-api.de/api/interpreter']);

// build query, like we usually do with Database queries
$q = $osm->element('node')
    ->whereTag('aeroway', 'aerodrome')
    ->verbosity('meta')
    ->asJson();

$nodes = [];
foreach ($slices as $slice) {
    //add constraint by boundary box of each slice and get result
    $response = $q->whereInBBox($slice)->get();
    $data = json_decode($response->getBody()->getContents());
    $nodes = array_merge($nodes, $data->elements);
}

About

OpenStreetMap API Integration

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages