コード例 #1
0
ファイル: test_definition.py プロジェクト: NCPP/ocgis
 def test_parse(self):
     keywords = dict(geom_uid=[None, 'ID'],
                     geom=[None, get_geometry_dictionaries(), get_geometry_dictionaries(uid='ID')])
     for k in self.iter_product_keywords(keywords):
         g = Geom(k.geom, geom_uid=k.geom_uid)
         ret = g.parse(k.geom)
         if k.geom is None:
             self.assertIsNone(ret)
         else:
             if k.geom_uid is None:
                 actual = constants.OCGIS_UNIQUE_GEOMETRY_IDENTIFIER
             else:
                 actual = k.geom_uid
             for element in ret:
                 self.assertEqual(element.geom.ugid.name, actual)
コード例 #2
0
 def test_parse(self):
     keywords = dict(geom_uid=[None, 'ID'],
                     geom=[
                         None,
                         get_geometry_dictionaries(),
                         get_geometry_dictionaries(uid='ID')
                     ])
     for k in self.iter_product_keywords(keywords):
         g = Geom(k.geom, geom_uid=k.geom_uid)
         ret = g.parse(k.geom)
         if k.geom is None:
             self.assertIsNone(ret)
         else:
             if k.geom_uid is None:
                 actual = constants.OCGIS_UNIQUE_GEOMETRY_IDENTIFIER
             else:
                 actual = k.geom_uid
             for element in ret:
                 self.assertEqual(element.geom.ugid.name, actual)
コード例 #3
0
ファイル: test_spatial_subset.py プロジェクト: moghimis/ocgis
    def test_get_spatial_subset_circular_geometries(self):
        """Test circular geometries. They were causing wrapping errors."""

        geoms = get_geometry_dictionaries()
        rd = self.test_data.get_rd('cancm4_tas')
        buffered = [element['geom'].buffer(rd.get().grid.resolution * 2) for element in geoms]
        for buff in buffered:
            ss = SpatialSubsetOperation(rd.get(), wrap=False)
            gvar = GeometryVariable(value=buff, name='geom', dimensions='dim', crs=WGS84())
            ret = ss.get_spatial_subset('intersects', gvar)
            self.assertTrue(np.all(ret.grid.x.get_value() >= 0))
コード例 #4
0
    def test_system_geometry_dictionary(self):
        """Test geometry dictionaries come out properly as collections."""

        subset = self.get_subset_operation()
        conv = NumpyConverter(subset)
        coll = conv.write()
        geom = get_geometry_dictionaries()
        container = coll.children[2]
        self.assertEqual(container['COUNTRY'].get_value()[0], 'Germany')
        self.assertEqual(container.geom.get_value()[0], geom[1]['geom'])
        self.assertEqual(len(coll.children), 3)
コード例 #5
0
ファイル: test_definition.py プロジェクト: NCPP/ocgis
    def test_geometry_dictionaries(self):
        """Test geometry dictionaries as input."""

        for crs in [None, WGS84(), CoordinateReferenceSystem(epsg=2136)]:
            geom = get_geometry_dictionaries()
            if crs is not None:
                for g in geom:
                    g['crs'] = crs
            g = Geom(geom)
            self.assertEqual(len(g.value), 3)
            for gdict, field in zip(geom, g.value):
                self.assertEqual(field.geom.geom_type, 'Point')
                if crs is None:
                    self.assertIsInstance(field.crs, env.DEFAULT_COORDSYS.__class__)
                else:
                    self.assertIsInstance(field.crs, crs.__class__)
                self.assertEqual(set([v.name for v in field.data_variables]), set(['UGID', 'COUNTRY']))
                self.assertEqual(field.geom.ugid.shape[0], 1)
                self.assertEqual(field['UGID'].get_value()[0], gdict['properties']['UGID'])
                self.assertEqual(field['COUNTRY'].get_value()[0], gdict['properties']['COUNTRY'])
コード例 #6
0
    def test_geometry_dictionaries(self):
        """Test geometry dictionaries as input."""

        for crs in [None, WGS84(), CoordinateReferenceSystem(epsg=2136)]:
            geom = get_geometry_dictionaries()
            if crs is not None:
                for g in geom:
                    g['crs'] = crs
            g = Geom(geom)
            self.assertEqual(len(g.value), 3)
            for gdict, field in zip(geom, g.value):
                self.assertEqual(field.geom.geom_type, 'Point')
                if crs is None:
                    self.assertIsInstance(field.crs,
                                          env.DEFAULT_COORDSYS.__class__)
                else:
                    self.assertIsInstance(field.crs, crs.__class__)
                self.assertEqual(set([v.name for v in field.data_variables]),
                                 set(['UGID', 'COUNTRY']))
                self.assertEqual(field.geom.ugid.shape[0], 1)
                self.assertEqual(field['UGID'].get_value()[0],
                                 gdict['properties']['UGID'])
                self.assertEqual(field['COUNTRY'].get_value()[0],
                                 gdict['properties']['COUNTRY'])
コード例 #7
0
 def get_subset_operation(self):
     geom = get_geometry_dictionaries()
     rd = self.test_data.get_rd('cancm4_tas')
     ops = ocgis.OcgOperations(dataset=rd, geom=geom, select_nearest=True)
     subset = OperationsEngine(ops)
     return subset