Skip to content

Commit

Permalink
Convenience function on the geometadata
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkvdb committed Jan 31, 2018
1 parent 5610b1c commit 32a5952
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
15 changes: 15 additions & 0 deletions geometadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,21 @@ void GeoMetadata::computeRectOnMapAround(const int32_t row, const int32_t col, c
}
}

Point<double> GeoMetadata::center() const
{
return Point<double>(xll + ((rows * cellSize) / 2), yll + ((rows * cellSize) / 2));
}

Point<double> GeoMetadata::topLeft() const
{
return Point<double>(xll, yll + (rows * cellSize));
}

Point<double> GeoMetadata::bottomRight() const
{
return Point<double>(xll + (cols * cellSize), yll);
}

std::string GeoMetadata::toString() const
{
std::ostringstream os;
Expand Down
5 changes: 5 additions & 0 deletions include/infra/geometadata.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "infra/cell.h"
#include "infra/point.h"

#include <optional>
#include <sstream>
Expand Down Expand Up @@ -29,6 +30,10 @@ struct GeoMetadata
bool isOnMap(int32_t r, int32_t c) const;
void computeRectOnMapAround(int32_t row, int32_t col, int32_t radius, int32_t& r0, int32_t& c0, int32_t& r1, int32_t& c1) const;

Point<double> center() const;
Point<double> topLeft() const;
Point<double> bottomRight() const;

std::string toString() const;

int32_t rows = 0;
Expand Down

0 comments on commit 32a5952

Please sign in to comment.