Package: osmium
Version: 0.0~20111213-g7f3500a-3
Severity: important
Tags: sid patch
Justification: FTBFS
User: [email protected]
Usertags: mips-patch
Hello,
Package osmium_ FTBFS on mips big-endian.
mips build log:
https://buildd.debian.org/status/fetch.php?pkg=osmium&arch=mips&ver=0.0~20111213-g7f3500a-3&stamp=1397047060
Test values are hard-coded in little-endian.
I am sending a patch which detects endianess used and adds big-endian test
values.
Best Regards,
Jurica
--- osmium-0.0~20111213-g7f3500a.orig/include/osmium/geometry.hpp
+++ osmium-0.0~20111213-g7f3500a/include/osmium/geometry.hpp
@@ -23,6 +23,7 @@ You should have received a copy of the L
*/
#include <sstream>
+#include <endian.h>
#ifdef OSMIUM_WITH_GEOS
# include <geos/geom/GeometryFactory.h>
@@ -40,6 +41,14 @@ You should have received a copy of the L
#include <osmium/exceptions.hpp>
#include <osmium/osm/types.hpp>
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+# define BYTE_ORDER_LITTLE_ENDIAN
+#elif __BYTE_ORDER == __BIG_ENDIAN
+# define BYTE_ORDER_BIG_ENDIAN
+#else
+# error unknown byte order
+#endif
+
namespace Osmium {
/**
@@ -161,7 +173,11 @@ namespace Osmium {
* - (optionally) the SRID
*/
inline void write_binary_wkb_header(std::ostream& out, bool with_srid, uint32_t type) {
+#ifdef BYTE_ORDER_LITTLE_ENDIAN // LITTLE_ENDIAN
write_binary<uint8_t>(out, wkbNDR);
+#else // BIG_ENDIAN
+ write_binary<uint8_t>(out, wkbXDR);
+#endif
if (with_srid) {
write_binary<uint32_t>(out, type | wkbSRID);
write_binary<uint32_t>(out, srid);
@@ -178,7 +194,11 @@ namespace Osmium {
* - (optionally) the SRID
*/
inline void write_hex_wkb_header(std::ostream& out, bool with_srid, uint32_t type) {
+#ifdef BYTE_ORDER_LITTLE_ENDIAN // LITTLE_ENDIAN
write_hex<uint8_t>(out, wkbNDR);
+#else // BIG_ENDIAN
+ write_hex<uint8_t>(out, wkbXDR);
+#endif
if (with_srid) {
write_hex<uint32_t>(out, type | wkbSRID);
write_hex<uint32_t>(out, srid);
--- osmium-0.0~20111213-g7f3500a.orig/test/testgroup_ogr/geometry/test_geometry.cpp
+++ osmium-0.0~20111213-g7f3500a/test/testgroup_ogr/geometry/test_geometry.cpp
@@ -53,7 +53,11 @@ BOOST_AUTO_TEST_CASE(polygon_from_way) {
OGRPolygon* ogrpolygon = polygon.create_ogr_geometry();
std::string ogrwkb;
ogrwkb.resize(ogrpolygon->WkbSize());
+#ifdef BYTE_ORDER_LITTLE_ENDIAN
ogrpolygon->exportToWkb(wkbNDR, (unsigned char*)ogrwkb.c_str());
+#else
+ ogrpolygon->exportToWkb(wkbXDR, (unsigned char*)ogrwkb.c_str());
+#endif
output_test_stream osmiumwkb;
osmiumwkb << polygon.as_WKB();
BOOST_CHECK_EQUAL(osmiumwkb.str().size(), ogrpolygon->WkbSize());
--- osmium-0.0~20111213-g7f3500a.orig/test/testgroup_plain/geometry/test_linestring_geometry.cpp
+++ osmium-0.0~20111213-g7f3500a/test/testgroup_plain/geometry/test_linestring_geometry.cpp
@@ -47,19 +47,35 @@ BOOST_AUTO_TEST_CASE(output) {
std::ostringstream out_wkb;
out_wkb << line2.as_WKB();
+#ifdef BYTE_ORDER_LITTLE_ENDIAN
BOOST_CHECK_EQUAL(Osmium::Test::to_hex(out_wkb.str()), "01020000000300000033333333333307403333333333330740666666666666FE3F3333333333330740666666666666FE3F666666666666FE3F");
+#else
+ BOOST_CHECK_EQUAL(Osmium::Test::to_hex(out_wkb.str()), "000000000200000003400733333333333340073333333333333FFE66666666666640073333333333333FFE6666666666663FFE666666666666");
+#endif
std::ostringstream out_ewkb;
out_ewkb << line2.as_WKB(true);
+#ifdef BYTE_ORDER_LITTLE_ENDIAN
BOOST_CHECK_EQUAL(Osmium::Test::to_hex(out_ewkb.str()), "0102000020E61000000300000033333333333307403333333333330740666666666666FE3F3333333333330740666666666666FE3F666666666666FE3F");
+#else
+ BOOST_CHECK_EQUAL(Osmium::Test::to_hex(out_ewkb.str()), "0020000002000010E600000003400733333333333340073333333333333FFE66666666666640073333333333333FFE6666666666663FFE666666666666");
+#endif
std::ostringstream out_hexwkb;
out_hexwkb << line1.as_HexWKB();
+#ifdef BYTE_ORDER_LITTLE_ENDIAN
BOOST_CHECK_EQUAL(out_hexwkb.str(), "010200000003000000666666666666FE3F666666666666FE3F666666666666FE3F333333333333074033333333333307403333333333330740");
+#else
+ BOOST_CHECK_EQUAL(out_hexwkb.str(), "0000000002000000033FFE6666666666663FFE6666666666663FFE666666666666400733333333333340073333333333334007333333333333");
+#endif
std::ostringstream out_hexewkb;
out_hexewkb << line1.as_HexWKB(true);
+#ifdef BYTE_ORDER_LITTLE_ENDIAN
BOOST_CHECK_EQUAL(out_hexewkb.str(), "0102000020E610000003000000666666666666FE3F666666666666FE3F666666666666FE3F333333333333074033333333333307403333333333330740");
+#else
+ BOOST_CHECK_EQUAL(out_hexewkb.str(), "0020000002000010E6000000033FFE6666666666663FFE6666666666663FFE666666666666400733333333333340073333333333334007333333333333");
+#endif
}
BOOST_AUTO_TEST_SUITE_END()
--- osmium-0.0~20111213-g7f3500a.orig/test/testgroup_plain/geometry/test_point_geometry.cpp
+++ osmium-0.0~20111213-g7f3500a/test/testgroup_plain/geometry/test_point_geometry.cpp
@@ -36,19 +36,35 @@ BOOST_AUTO_TEST_CASE(output) {
std::ostringstream out_wkb;
out_wkb << point1.as_WKB();
+#ifdef BYTE_ORDER_LITTLE_ENDIAN
BOOST_CHECK_EQUAL(Osmium::Test::to_hex(out_wkb.str()), "0101000000333333333333F33F3333333333330B40");
+#else
+ BOOST_CHECK_EQUAL(Osmium::Test::to_hex(out_wkb.str()), "00000000013FF3333333333333400B333333333333");
+#endif
std::ostringstream out_ewkb;
out_ewkb << point1.as_WKB(true);
+#ifdef BYTE_ORDER_LITTLE_ENDIAN
BOOST_CHECK_EQUAL(Osmium::Test::to_hex(out_ewkb.str()), "0101000020E6100000333333333333F33F3333333333330B40");
+#else
+ BOOST_CHECK_EQUAL(Osmium::Test::to_hex(out_ewkb.str()), "0020000001000010E63FF3333333333333400B333333333333");
+#endif
std::ostringstream out_hexwkb;
out_hexwkb << point1.as_HexWKB();
+#ifdef BYTE_ORDER_LITTLE_ENDIAN
BOOST_CHECK_EQUAL(out_hexwkb.str(), "0101000000333333333333F33F3333333333330B40");
+#else
+ BOOST_CHECK_EQUAL(out_hexwkb.str(), "00000000013FF3333333333333400B333333333333");
+#endif
std::ostringstream out_hexewkb;
out_hexewkb << point1.as_HexWKB(true);
+#ifdef BYTE_ORDER_LITTLE_ENDIAN
BOOST_CHECK_EQUAL(out_hexewkb.str(), "0101000020E6100000333333333333F33F3333333333330B40");
+#else
+ BOOST_CHECK_EQUAL(out_hexewkb.str(), "0020000001000010E63FF3333333333333400B333333333333");
+#endif
}
BOOST_AUTO_TEST_SUITE_END()
--- osmium-0.0~20111213-g7f3500a.orig/test/testgroup_plain/geometry/test_polygon_geometry.cpp
+++ osmium-0.0~20111213-g7f3500a/test/testgroup_plain/geometry/test_polygon_geometry.cpp
@@ -51,19 +51,35 @@ BOOST_AUTO_TEST_CASE(output) {
std::ostringstream out_wkb;
out_wkb << polygon.as_WKB();
+#ifdef BYTE_ORDER_LITTLE_ENDIAN
BOOST_CHECK_EQUAL(Osmium::Test::to_hex(out_wkb.str()), "01030000000100000004000000666666666666FE3F666666666666FE3F666666666666FE3F333333333333074033333333333307403333333333330740666666666666FE3F666666666666FE3F");
+#else
+ BOOST_CHECK_EQUAL(Osmium::Test::to_hex(out_wkb.str()), "000000000300000001000000043FFE6666666666663FFE6666666666663FFE6666666666664007333333333333400733333333333340073333333333333FFE6666666666663FFE666666666666");
+#endif
std::ostringstream out_ewkb;
out_ewkb << polygon.as_WKB(true);
+#ifdef BYTE_ORDER_LITTLE_ENDIAN
BOOST_CHECK_EQUAL(Osmium::Test::to_hex(out_ewkb.str()), "0103000020E61000000100000004000000666666666666FE3F666666666666FE3F666666666666FE3F333333333333074033333333333307403333333333330740666666666666FE3F666666666666FE3F");
+#else
+ BOOST_CHECK_EQUAL(Osmium::Test::to_hex(out_ewkb.str()), "0020000003000010E600000001000000043FFE6666666666663FFE6666666666663FFE6666666666664007333333333333400733333333333340073333333333333FFE6666666666663FFE666666666666");
+#endif
std::ostringstream out_hexwkb;
out_hexwkb << polygon.as_HexWKB();
+#ifdef BYTE_ORDER_LITTLE_ENDIAN
BOOST_CHECK_EQUAL(out_hexwkb.str(), "01030000000100000004000000666666666666FE3F666666666666FE3F666666666666FE3F333333333333074033333333333307403333333333330740666666666666FE3F666666666666FE3F");
+#else
+ BOOST_CHECK_EQUAL(out_hexwkb.str(), "000000000300000001000000043FFE6666666666663FFE6666666666663FFE6666666666664007333333333333400733333333333340073333333333333FFE6666666666663FFE666666666666");
+#endif
std::ostringstream out_hexewkb;
out_hexewkb << polygon.as_HexWKB(true);
+#ifdef BYTE_ORDER_LITTLE_ENDIAN
BOOST_CHECK_EQUAL(out_hexewkb.str(), "0103000020E61000000100000004000000666666666666FE3F666666666666FE3F666666666666FE3F333333333333074033333333333307403333333333330740666666666666FE3F666666666666FE3F");
+#else
+ BOOST_CHECK_EQUAL(out_hexewkb.str(), "0020000003000010E600000001000000043FFE6666666666663FFE6666666666663FFE6666666666664007333333333333400733333333333340073333333333333FFE6666666666663FFE666666666666");
+#endif
}
BOOST_AUTO_TEST_SUITE_END()