MCPcopy
hub / github.com/django/django / test_multilinestring

Method test_multilinestring

tests/gis_tests/geos_tests/test_geos.py:539–570  ·  view source on GitHub ↗

Testing MultiLineString objects.

(self)

Source from the content-addressed store, hash-verified

537 LinearRing((0, 0), (1, 0), (0, 1), (0, 0)).is_counterclockwise
538
539 def test_multilinestring(self):
540 "Testing MultiLineString objects."
541 prev = fromstr("POINT(0 0)")
542 for line in self.geometries.multilinestrings:
543 ml = fromstr(line.wkt)
544 with self.subTest(line=line):
545 self.assertEqual(ml.geom_type, "MultiLineString")
546 self.assertEqual(ml.geom_typeid, 5)
547 self.assertEqual(ml.dims, 1)
548
549 self.assertAlmostEqual(line.centroid[0], ml.centroid.x, 9)
550 self.assertAlmostEqual(line.centroid[1], ml.centroid.y, 9)
551
552 self.assertEqual(ml, fromstr(line.wkt))
553 self.assertIs(ml == prev, False) # Use assertIs() to test __eq__.
554 prev = ml
555
556 for ls in ml:
557 self.assertEqual(ls.geom_type, "LineString")
558 self.assertEqual(ls.geom_typeid, 1)
559 self.assertIs(ls.empty, False)
560
561 ml_len = len(ml)
562 msg = f"invalid index: {ml_len}"
563 with self.assertRaisesMessage(IndexError, msg):
564 ml.__getitem__(ml_len)
565 self.assertEqual(
566 ml.wkt, MultiLineString(*tuple(s.clone() for s in ml)).wkt
567 )
568 self.assertEqual(
569 ml, MultiLineString(*tuple(LineString(s.tuple) for s in ml))
570 )
571
572 def test_linearring(self):
573 "Testing LinearRing objects."

Callers

nothing calls this directly

Calls 6

fromstrFunction · 0.90
MultiLineStringClass · 0.90
LineStringClass · 0.90
assertRaisesMessageMethod · 0.80
__getitem__Method · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected