diff --git a/src/ewkb.rs b/src/ewkb.rs
index ae325d6..fde2eb0 100644
--- a/src/ewkb.rs
+++ b/src/ewkb.rs
@@ -571,7 +571,9 @@ macro_rules! impl_read_for_geometry_container_type {
let mut $itemname: Vec<$itemtype
> = vec![];
let size = read_u32(raw, is_be)? as usize;
for _ in 0..size {
- $itemname.push($itemtype::read_ewkb(raw)?);
+ let _byte_order = raw.read_i8()?;
+ let type_id = read_u32(raw, is_be)?;
+ $itemname.push($itemtype::read_ewkb_body(raw, is_be, type_id, srid)?);
}
Ok($geotype::
{
$itemname: $itemname,
@@ -1883,3 +1885,21 @@ fn test_iterators() {
let line = self::LineStringT:: {srid: Some(4326), points: vec![p(10.0, -20.0), p(0., -0.5)]};
assert_eq!(line.points().last(), Some(&Point { x: 0., y: -0.5, srid: None }));
}
+
+#[test]
+#[cfg_attr(rustfmt, rustfmt_skip)]
+fn test_srid_on_multipolygons() {
+ let p = |x, y| Point { x: x, y: y, srid: Some(4326) };
+ // SELECT 'SRID=4326;MULTIPOLYGON (((0 0, 2 0, 2 2, 0 2, 0 0)), ((10 10, -2 10, -2 -2, 10 -2, 10 10)))'::geometry
+ let line = LineStringT:: {srid: Some(4326), points: vec![p(0., 0.), p(2., 0.), p(2., 2.), p(0., 2.), p(0., 0.)]};
+ let poly1 = PolygonT:: {srid: Some(4326), rings: vec![line]};
+ let line = LineStringT:: {srid: Some(4326), points: vec![p(10., 10.), p(-2., 10.), p(-2., -2.), p(10., -2.), p(10., 10.)]};
+ let poly2 = PolygonT:: {srid: Some(4326), rings: vec![line]};
+ let multipoly = MultiPolygonT:: {srid: Some(4326), polygons: vec![poly1, poly2]};
+ let hex = multipoly.as_ewkb().to_hex_ewkb();
+ let ewkb = hex_to_vec(&hex);
+ let geom = MultiPolygon::read_ewkb(&mut ewkb.as_slice()).unwrap();
+
+ assert_eq!(geom.srid, Some(4326));
+ assert_eq!(geom.polygons[0].srid, Some(4326));
+}
\ No newline at end of file