Skip to content

Commit f78042a

Browse files
committed
Fix implicit sign conversion in projection code
1 parent e265a43 commit f78042a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/reprojection.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <osmium/geom/mercator_projection.hpp>
1111

12+
#include "format.hpp"
1213
#include "reprojection.hpp"
1314

1415
namespace {
@@ -82,5 +83,9 @@ std::shared_ptr<reprojection> reprojection::create_projection(int srs)
8283
break;
8384
}
8485

86+
if (srs <= 0) {
87+
throw std::runtime_error{"Invalid projection SRID '{}'."_format(srs)};
88+
}
89+
8590
return make_generic_projection(srs);
8691
}

src/wkb.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ inline std::string create_point(double x, double y, uint32_t srid = 4326)
102102
class writer_t
103103
{
104104
public:
105-
explicit writer_t(uint32_t srid) : m_srid(srid) {}
105+
explicit writer_t(int srid) : m_srid(static_cast<uint32_t>(srid))
106+
{
107+
assert(srid > 0);
108+
}
106109

107110
void add_sub_geometry(std::string const &part)
108111
{

0 commit comments

Comments
 (0)