-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from Quetzal-framework/develop
doc: add examples and documentation for spatial graphs
- Loading branch information
Showing
17 changed files
with
455 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "quetzal/geography.hpp" | ||
|
||
namespace geo = quetzal::geography; | ||
|
||
struct MyVertexInfo { | ||
std::string label = "NA"; | ||
std::vector<double> pop_data_chunk; | ||
}; | ||
|
||
struct MyEdgeInfo { | ||
double distance; | ||
MyEdgeInfo() = default; | ||
// required by from_grid | ||
MyEdgeInfo(auto u, auto v, auto const& land){ | ||
distance = land.to_lonlat(u).great_circle_distance_to( land.to_lonlat(v) ); | ||
} | ||
}; | ||
|
||
int main() | ||
{ | ||
auto file = std::filesystem::current_path() / "data/bio1.tif"; | ||
|
||
// The raster have 10 bands that we will assign to 2001 ... 2010. | ||
std::vector<int> times(10); | ||
std::iota(times.begin(), times.end(), 2001); | ||
|
||
using landscape_type = geo::raster<>; | ||
auto land = geo::raster<>::from_file(file, times); | ||
auto graph = geo::from_grid(land, MyVertexInfo(), MyEdgeInfo(), geo::connect_fully(), geo::isotropy(), geo::mirror()); | ||
|
||
std::cout << "Graph has " << graph.num_vertices() << " vertices, " << graph.num_edges() << " edges." << std::endl; | ||
|
||
for( auto const& e : graph.edges() ){ | ||
std::cout << graph.source(e) << " <-> " << graph.target(e) << " : " << graph[e].distance << std::endl; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.