diff --git a/engines/maps/openstreetmap.php b/engines/maps/openstreetmap.php new file mode 100644 index 0000000..63fd218 --- /dev/null +++ b/engines/maps/openstreetmap.php @@ -0,0 +1,37 @@ +query)); + $results = array(); + + // TODO allow the nominatim instance to be customised + $url = "https://nominatim.openstreetmap.org/search?q=$query_encoded&format=json"; + + return $url; + } + + + public function parse_results($response) { + $json_response = json_decode($response, true); + if (!$json_response) + return array(); + + $results = array(); + foreach ($json_response as $item) { + array_push($results, array( + "title" => $item["name"], + "description" => $item["display_name"], + "url" => "https://www.openstreetmap.org/node/" . $item["osm_id"], + "base_url" => "www.openstreetmap.org" + )); + } + return $results; + } + + public static function print_results($results, $opts) { + TextSearch::print_results($results, $opts); + } + } +?> diff --git a/locale/en.php b/locale/en.php index 1cb4b86..a123b2c 100644 --- a/locale/en.php +++ b/locale/en.php @@ -18,6 +18,7 @@ return array( "category_videos" => "Videos", "category_torrents" => "Torrents", "category_tor" => "Tor", + "category_maps" => "Maps", "feature_disabled" => "The host has disabled this feature :C", diff --git a/misc/search_engine.php b/misc/search_engine.php index a032640..378cae8 100644 --- a/misc/search_engine.php +++ b/misc/search_engine.php @@ -135,6 +135,10 @@ require "engines/ahmia/hidden_service.php"; return new TorSearch($opts, $mh); + case 5: + require "engines/maps/openstreetmap.php"; + return new OSMRequest($opts, $mh); + default: require "engines/text/text.php"; return new TextSearch($opts, $mh); diff --git a/search.php b/search.php index 0f71087..18a6e33 100644 --- a/search.php +++ b/search.php @@ -53,7 +53,7 @@