Check the behavior of the Geometry constructor. There are 5 options: 1) A geoJSON object. 2) A not-computed geometry. 3) A not-computed geometry with overrides. 4) A computed geometry with no overrides. 5) something to cast to geometry.
(self)
| 685 | self.assertFalse(projected.toGeoJSON()['geodesic']) |
| 686 | |
| 687 | def test_constructor(self): |
| 688 | """Check the behavior of the Geometry constructor. |
| 689 | |
| 690 | There are 5 options: |
| 691 | 1) A geoJSON object. |
| 692 | 2) A not-computed geometry. |
| 693 | 3) A not-computed geometry with overrides. |
| 694 | 4) A computed geometry with no overrides. |
| 695 | 5) something to cast to geometry. |
| 696 | """ |
| 697 | line = ee.Geometry.LineString(1, 2, 3, 4) |
| 698 | |
| 699 | # GeoJSON. |
| 700 | from_json = ee.Geometry(line.toGeoJSON()) |
| 701 | self.assertIsNone(from_json.func) |
| 702 | self.assertEqual(from_json._type, 'LineString') |
| 703 | self.assertEqual(from_json._coordinates, [[1, 2], [3, 4]]) |
| 704 | |
| 705 | # GeoJSON with a CRS specified. |
| 706 | json_with_crs = line.toGeoJSON() |
| 707 | json_with_crs['crs'] = { |
| 708 | 'type': 'name', |
| 709 | 'properties': {'name': 'SR-ORG:6974'}, |
| 710 | } |
| 711 | from_json_with_crs = ee.Geometry(json_with_crs) |
| 712 | self.assertIsNone(from_json_with_crs.func) |
| 713 | self.assertEqual(from_json_with_crs._type, 'LineString') |
| 714 | self.assertEqual(from_json_with_crs._proj, 'SR-ORG:6974') |
| 715 | |
| 716 | # A not-computed geometry. |
| 717 | self.assertEqual(ee.Geometry(line), line) |
| 718 | |
| 719 | # A not-computed geometry with an override. |
| 720 | with_override = ee.Geometry(line, 'SR-ORG:6974') |
| 721 | self.assertEqual(with_override._proj, 'SR-ORG:6974') |
| 722 | |
| 723 | # A computed geometry. |
| 724 | self.assertEqual(ee.Geometry(line.bounds()), line.bounds()) |
| 725 | |
| 726 | # Something to cast to a geometry. |
| 727 | computed = ee.ComputedObject(ee.Function(), {'a': 1}) |
| 728 | geom = ee.Geometry(computed) |
| 729 | self.assertEqual(computed.func, geom.func) |
| 730 | self.assertEqual(computed.args, geom.args) |
| 731 | |
| 732 | @parameterized.named_parameters( |
| 733 | ('_proj', {'proj': 'some-proj'}), |
nothing calls this directly
no test coverage detected